diff options
Diffstat (limited to 'src/opthelp.c')
-rw-r--r-- | src/opthelp.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/opthelp.c b/src/opthelp.c index c9b7b46..702852a 100644 --- a/src/opthelp.c +++ b/src/opthelp.c @@ -1,4 +1,4 @@ -/* grecs - Gray's Extensible Configuration System +/* argot - Gray's Extensible Configuration System Copyright (C) 2007-2016 Sergey Poznyakoff Grecs is free software; you can redistribute it and/or modify it @@ -20,8 +20,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "grecs.h" -#include "grecs/opt.h" +#include "argot.h" +#include "argot/opt.h" #include "wordsplit.h" static void @@ -60,8 +60,8 @@ print_option_descr(const char *descr, size_t lmargin, size_t rmargin) static int optcmp(const void *a, const void *b) { - struct grecs_opthelp const *ap = (struct grecs_opthelp const *)a; - struct grecs_opthelp const *bp = (struct grecs_opthelp const *)b; + struct argot_opthelp const *ap = (struct argot_opthelp const *)a; + struct argot_opthelp const *bp = (struct argot_opthelp const *)b; const char *opta, *optb; size_t alen, blen; @@ -80,13 +80,13 @@ optcmp(const void *a, const void *b) } static void -sort_options(struct grecs_opthelp *opthelp, int start, int count) +sort_options(struct argot_opthelp *opthelp, int start, int count) { qsort(opthelp + start, count, sizeof(opthelp[0]), optcmp); } static int -sort_group(struct grecs_opthelp *opthelp, size_t optcount, int start) +sort_group(struct argot_opthelp *opthelp, size_t optcount, int start) { int i; @@ -97,7 +97,7 @@ sort_group(struct grecs_opthelp *opthelp, size_t optcount, int start) } static void -sort_opthelp(struct grecs_opthelp *opthelp, size_t optcount) +sort_opthelp(struct argot_opthelp *opthelp, size_t optcount) { int start; @@ -112,11 +112,11 @@ sort_opthelp(struct grecs_opthelp *opthelp, size_t optcount) #define ISEMPTY(s) ((s) == NULL || *(s) == 0) void -grecs_print_help(struct grecs_proginfo *pinfo) +argot_print_help(struct argot_proginfo *pinfo) { unsigned i; int argsused = 0; - struct grecs_opthelp *opthelp; + struct argot_opthelp *opthelp; size_t optcount; printf("%s %s ", @@ -210,8 +210,8 @@ grecs_print_help(struct grecs_proginfo *pinfo) static int cmpidx_short(const void *a, const void *b) { - struct grecs_opthelp const **opta = (struct grecs_opthelp const **)a; - struct grecs_opthelp const **optb = (struct grecs_opthelp const **)b; + struct argot_opthelp const **opta = (struct argot_opthelp const **)a; + struct argot_opthelp const **optb = (struct argot_opthelp const **)b; return (*opta)->opt[1] - (*optb)->opt[1]; } @@ -220,8 +220,8 @@ cmpidx_short(const void *a, const void *b) static int cmpidx_long(const void *a, const void *b) { - struct grecs_opthelp const **ap = (struct grecs_opthelp const **)a; - struct grecs_opthelp const **bp = (struct grecs_opthelp const **)b; + struct argot_opthelp const **ap = (struct argot_opthelp const **)a; + struct argot_opthelp const **bp = (struct argot_opthelp const **)b; char const *opta, *optb; size_t lena, lenb; @@ -241,15 +241,15 @@ cmpidx_long(const void *a, const void *b) #endif void -grecs_print_usage(struct grecs_proginfo *pinfo) +argot_print_usage(struct argot_proginfo *pinfo) { unsigned i; unsigned n; char *buf; size_t bufsize; unsigned nidx; - struct grecs_opthelp **optidx; - struct grecs_opthelp *opthelp = pinfo->opthelp; + struct argot_opthelp **optidx; + struct argot_opthelp *opthelp = pinfo->opthelp; size_t optcount = pinfo->optcount; #define FLUSH do { \ @@ -261,10 +261,10 @@ grecs_print_usage(struct grecs_proginfo *pinfo) #define ADDC(c) \ do { if (n == RMARGIN) FLUSH; buf[n++] = c; } while (0) - optidx = grecs_calloc(optcount, sizeof(optidx[0])); + optidx = argot_calloc(optcount, sizeof(optidx[0])); bufsize = RMARGIN + 1; - buf = grecs_malloc(bufsize); + buf = argot_malloc(bufsize); n = snprintf(buf, bufsize, "%s %s ", _("Usage:"), pinfo->progname); if (pinfo->subcmd) @@ -302,7 +302,7 @@ grecs_print_usage(struct grecs_proginfo *pinfo) qsort(optidx, nidx, sizeof(optidx[0]), cmpidx_short); for (i = 0; i < nidx; i++) { - struct grecs_opthelp *opt = optidx[i]; + struct argot_opthelp *opt = optidx[i]; size_t len = 5 + strlen(opt->arg) + (opt->is_optional ? 2 : 1); @@ -338,7 +338,7 @@ grecs_print_usage(struct grecs_proginfo *pinfo) qsort (optidx, nidx, sizeof(optidx[0]), cmpidx_long); for (i = 0; i < nidx; i++) { - struct grecs_opthelp *opt = optidx[i]; + struct argot_opthelp *opt = optidx[i]; size_t len; const char *longopt; @@ -358,7 +358,7 @@ grecs_print_usage(struct grecs_proginfo *pinfo) the string cannot be split */ if (n + len > bufsize) { bufsize = n + len; - buf = grecs_realloc(buf, bufsize); + buf = argot_realloc(buf, bufsize); } } buf[n++] = ' '; @@ -408,7 +408,7 @@ grecs_print_usage(struct grecs_proginfo *pinfo) split */ if (n + len > bufsize) { bufsize = n + len; - buf = grecs_realloc(buf, + buf = argot_realloc(buf, bufsize); } } @@ -442,7 +442,7 @@ const char version_etc_copyright[] = "Copyright %s %s %s"; void -grecs_print_version_only(struct grecs_proginfo *pinfo, FILE *stream) +argot_print_version_only(struct argot_proginfo *pinfo, FILE *stream) { fprintf(stream, "%s", pinfo->progname); if (!ISEMPTY(pinfo->package)) @@ -469,9 +469,9 @@ static const char gplv3[] = "There is NO WARRANTY, to the extent permitted by law.\n\n"); void -grecs_print_version(struct grecs_proginfo *pinfo, FILE *stream) +argot_print_version(struct argot_proginfo *pinfo, FILE *stream) { - grecs_print_version_only(pinfo, stream); + argot_print_version_only(pinfo, stream); fputs(gettext(ISEMPTY(pinfo->license) ? gplv3 : pinfo->license), stream); if (pinfo->print_version_hook) |