This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, generate has been updated via 63b5c2d57786aff8babac4c17c5fc5996c33cd4a (commit) from 36c8c982d2d3a3f672a293664a04e7a0491a6a97 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/63b5c2d57786aff8babac4c17c5fc5996c33c...
commit 63b5c2d57786aff8babac4c17c5fc5996c33cd4a Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 29 02:19:56 2011 +0200
Help is autogenerated from parameter descriptions.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index a4ef8c5..3d099b2 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -76,9 +76,9 @@ static int resize_check_ratio(const struct param *self __attribute__((unused)), }
static struct param resize_params[] = { - {"alg", PARAM_ENUM, resize_algs, NULL}, - {"ratio", PARAM_FLOAT, NULL, resize_check_ratio}, - {NULL, 0, NULL, NULL} + {"alg", PARAM_ENUM, "algorithm to be used", resize_algs, NULL}, + {"ratio", PARAM_FLOAT, "scale ratio", NULL, resize_check_ratio}, + {NULL, 0, NULL, NULL, NULL} };
static GP_RetCode resize(GP_Context **c, const char *params) @@ -137,10 +137,10 @@ static int scale_check_size(const struct param *self __attribute__((unused)), }
static struct param scale_params[] = { - {"alg", PARAM_ENUM, scale_algs, NULL}, - {"w", PARAM_INT, NULL, scale_check_size}, - {"h", PARAM_INT, NULL, scale_check_size}, - {NULL, 0, NULL, NULL} + {"alg", PARAM_ENUM, "algorithm to be used", scale_algs, NULL}, + {"w", PARAM_INT, "new width", NULL, scale_check_size}, + {"h", PARAM_INT, "new height", NULL, scale_check_size}, + {NULL, 0, NULL, NULL, NULL} };
static GP_RetCode scale(GP_Context **c, const char *params) @@ -187,8 +187,8 @@ static const char *rotate_rots[] = { };
static struct param rotate_params[] = { - {"rot", PARAM_ENUM, rotate_rots, NULL}, - {NULL, 0, NULL, NULL} + {"rot", PARAM_ENUM, "image rotation", rotate_rots, NULL}, + {NULL, 0, NULL, NULL, NULL} };
static GP_RetCode rotate(GP_Context **c, const char *params) @@ -222,8 +222,8 @@ static GP_RetCode rotate(GP_Context **c, const char *params) /* brightness filter */
static struct param bright_params[] = { - {"val", PARAM_INT, NULL, NULL}, - {NULL, 0, NULL, NULL} + {"val", PARAM_INT, "brightness increment", NULL, NULL}, + {NULL, 0, NULL, NULL, NULL} };
static GP_RetCode bright(GP_Context **c, const char *params) @@ -252,17 +252,18 @@ static GP_RetCode bright(GP_Context **c, const char *params) /* filters */
struct filter { - char *name; - char *param_help; + const char *name; + const char *desc; + struct param *param_desc; GP_RetCode (*apply)(GP_Context **c, const char *params); };
static struct filter filter_table[] = { - {"resize", "alg=nn|cubic:ratio=float", resize}, - {"scale", "alg=nn|cubic:w=int:h=int", scale}, - {"rotate", "rot=90|180|270", rotate}, - {"bright", "val=int", bright}, - {NULL, NULL, NULL} + {"resize", "resize image by given ratio", resize_params, resize}, + {"scale", "scale image to given width and height", scale_params, scale}, + {"rotate", "rotate image", rotate_params, rotate}, + {"bright", "alter image brightness", bright_params, bright}, + {NULL, NULL, NULL, NULL} };
static struct filter *get_filter(const char *name) @@ -277,13 +278,24 @@ static struct filter *get_filter(const char *name) return NULL; }
-static void print_filter_help(const char *prefix) +static void print_filter_help(void) { - unsigned int i; + unsigned int i, j;
for (i = 0; filter_table[i].name != NULL; i++) { - printf("%s%s : %sn", prefix, filter_table[i].name, - filter_table[i].param_help); + printf("%sn", filter_table[i].name); + + j = strlen(filter_table[i].name); + + while (j--) + putchar('-'); + putchar('n'); + + printf("* %sn", filter_table[i].desc); + putchar('n'); + + param_describe(filter_table[i].param_desc, " "); + putchar('n'); } }
@@ -328,19 +340,31 @@ static void apply_filters(GP_Context **src) }
static const char *app_help = { - " <- Bitmap Grinder -> n" " n" - "-h : prints this help n" - "-v int : sets gfxprim verbosity level n" - "-f params : apply filter, multiple filters may be usedn" + " <-= Bitmap Grinder =-> n" + " n" + " +-+-----+ n" + " / | +-+| .11. n" + " +-{ D| |010101011. n" + " | \ | +-.0100101. n" + " O=+ +-+-----+ .10110101. n" + " .010101. n" + " .1. n" + " Program options n" + " =============== n" + " n" + "-h - prints this help n" + "-v int - sets gfxprim verbosity level n" + "-f params - apply filter, multiple filters may be usedn" " n" " List of filters n" + " =============== n" };
static void print_help(void) { puts(app_help); - print_filter_help(" "); + print_filter_help(); }
int main(int argc, char *argv[]) diff --git a/demos/grinder/params.c b/demos/grinder/params.c index 1c02b7d..827d3e9 100644 --- a/demos/grinder/params.c +++ b/demos/grinder/params.c @@ -45,6 +45,58 @@ const char *param_type_name(enum param_type type) return param_type_names[type]; }
+static const char *param_type_names_padd[] = { + "bool ", + "integer", + "float ", + "string ", + "enum ", +}; + +static void padd(unsigned int n) +{ + while (n--) + putchar(' '); +} + + +static void print_enum(const char *enum_table[]) +{ + unsigned int i; + + printf(" = ["); + + for (i = 0; enum_table[i] != NULL; i++) + if (enum_table[i+1] == NULL) + printf("%s]", enum_table[i]); + else + printf("%s | ", enum_table[i]); +} + +void param_describe(const struct param *param_desc, const char *prefix) +{ + unsigned int i, len = 0, l; + + for (i = 0; param_desc[i].name != NULL; i++) { + l = strlen(param_desc[i].name); + + if (l > len) + len = l; + } + + for (i = 0; param_desc[i].name != NULL; i++) { + printf("%s%s", prefix, param_desc[i].name); + padd(len - strlen(param_desc[i].name)); + printf(" : %s", param_type_names_padd[param_desc[i].type]); + printf(" - %s", param_desc[i].desc); + + if (param_desc[i].type == PARAM_ENUM) + print_enum(param_desc[i].enum_table); + + printf("n"); + } +} + static unsigned int count_params(const char *params) { unsigned int ret = 1, i; diff --git a/demos/grinder/params.h b/demos/grinder/params.h index 3efea7d..e633c00 100644 --- a/demos/grinder/params.h +++ b/demos/grinder/params.h @@ -34,6 +34,7 @@ enum param_type { struct param { const char *name; enum param_type type; + const char *desc; const char **enum_table;
int (*check)(const struct param *self, void *val); @@ -41,6 +42,8 @@ struct param {
const char *param_type_name(enum param_type type);
+void param_describe(const struct param *param_desc, const char *prefix); + int param_parse(const char *params, const struct param *param_desc, void *priv, int (*err)(const struct param *self, const char *val, void *priv), ...);
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 78 ++++++++++++++++++++++++++++++---------------- demos/grinder/params.c | 52 +++++++++++++++++++++++++++++++ demos/grinder/params.h | 3 ++ 3 files changed, 106 insertions(+), 27 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.