From 2a7d8f8fc2c474c19cda8a255c3cac2647a60f52 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Thu, 7 May 2015 14:12:42 +0200 Subject: [PATCH] mx_getopt: rename bee_*() to mx_*() and BEE_* to MX_* --- mx_getopt.c | 94 ++++++++++++------------- mx_getopt.h | 194 ++++++++++++++++++++++++++-------------------------- mxqd.c | 40 +++++------ mxqdump.c | 26 +++---- mxqkill.c | 26 +++---- mxqsub.c | 58 ++++++++-------- 6 files changed, 219 insertions(+), 219 deletions(-) diff --git a/mx_getopt.c b/mx_getopt.c index 6b053bdb..32716633 100644 --- a/mx_getopt.c +++ b/mx_getopt.c @@ -45,7 +45,7 @@ #include "mx_getopt.h" -int bee_getopt_init(struct bee_getopt_ctl *ctl, int argc, char **argv, struct bee_option *optv) +int mx_getopt_init(struct mx_getopt_ctl *ctl, int argc, char **argv, struct mx_option *optv) { int err = 0; @@ -67,8 +67,8 @@ int bee_getopt_init(struct bee_getopt_ctl *ctl, int argc, char **argv, struct be for(ctl->_optcnt=0; optv[ctl->_optcnt].long_opt || optv[ctl->_optcnt].short_opt; ctl->_optcnt++) { if(optv[ctl->_optcnt].long_opt) optv[ctl->_optcnt]._long_len = strlen(optv[ctl->_optcnt].long_opt); - if(optv[ctl->_optcnt].value < 0 && optv[ctl->_optcnt].value != BEE_GETOPT_NOVALUE) { - fprintf(stderr, "*** bee_getopt_init() ERROR: negative value (%d) set for opt %d (long: %s, short: %c)\n", ctl->_optcnt, optv[ctl->_optcnt].value, optv[ctl->_optcnt].long_opt, optv[ctl->_optcnt].short_opt); + if(optv[ctl->_optcnt].value < 0 && optv[ctl->_optcnt].value != MX_GETOPT_NOVALUE) { + fprintf(stderr, "*** mx_getopt_init() ERROR: negative value (%d) set for opt %d (long: %s, short: %c)\n", ctl->_optcnt, optv[ctl->_optcnt].value, optv[ctl->_optcnt].long_opt, optv[ctl->_optcnt].short_opt); err++; } } @@ -81,7 +81,7 @@ int bee_getopt_init(struct bee_getopt_ctl *ctl, int argc, char **argv, struct be return err?0:1; } -static int find_long_option_by_name(struct bee_option *options, char *name, char **optarg) +static int find_long_option_by_name(struct mx_option *options, char *name, char **optarg) { int i = 0; @@ -114,10 +114,10 @@ static int find_long_option_by_name(struct bee_option *options, char *name, char } /* not match found */ - return BEE_GETOPT_OPTUNKNOWN; + return MX_GETOPT_OPTUNKNOWN; } -static int find_short_option(struct bee_option *options, char **name, char **optarg) +static int find_short_option(struct mx_option *options, char **name, char **optarg) { char short_opt; int i; @@ -144,7 +144,7 @@ static int find_short_option(struct bee_option *options, char **name, char **opt if (idx == -1) { /* reset unhandled options */ *name = NULL; - return BEE_GETOPT_OPTUNKNOWN; + return MX_GETOPT_OPTUNKNOWN; } /* skip this short option */ @@ -162,7 +162,7 @@ static int find_short_option(struct bee_option *options, char **name, char **opt return idx; } -static int find_long_option_by_subname(struct bee_option *options, char *name, char **optarg) +static int find_long_option_by_subname(struct mx_option *options, char *name, char **optarg) { int i; int l; @@ -197,7 +197,7 @@ static int find_long_option_by_subname(struct bee_option *options, char *name, c if (idx >= 0) { if (options[i].value != options[idx].value) - return BEE_GETOPT_AMBIGUOUS; + return MX_GETOPT_AMBIGUOUS; } else { idx = i; } @@ -205,7 +205,7 @@ static int find_long_option_by_subname(struct bee_option *options, char *name, c /* return error if option was not found */ if (idx == -1) - return BEE_GETOPT_OPTUNKNOWN; + return MX_GETOPT_OPTUNKNOWN; /* set optarg if assigned */ if (s && optarg) @@ -214,9 +214,9 @@ static int find_long_option_by_subname(struct bee_option *options, char *name, c return idx; } -static int handle_option(struct bee_getopt_ctl *ctl, const int index) +static int handle_option(struct mx_getopt_ctl *ctl, const int index) { - struct bee_option *o = &(ctl->options[index]); + struct mx_option *o = &(ctl->options[index]); int argc; ctl->optargc = 0; @@ -232,7 +232,7 @@ static int handle_option(struct bee_getopt_ctl *ctl, const int index) if (!ctl->optarg) { /* no optarg and no more arguments -> required argument missing */ if (ctl->optind == ctl->_argc) - return (o->required_args == 1)?BEE_GETOPT_NOARG:BEE_GETOPT_NOARGS; + return (o->required_args == 1)?MX_GETOPT_NOARG:MX_GETOPT_NOARGS; /* set optarg to this argument and skip it */ ctl->optarg = ctl->argv[ctl->optind++]; @@ -249,7 +249,7 @@ static int handle_option(struct bee_getopt_ctl *ctl, const int index) if (ctl->optind+argc > ctl->_argc) { /* on error: set optargc to number of args available */ ctl->optargc = ctl->optind - ctl->_argc; - return BEE_GETOPT_NOARGS; + return MX_GETOPT_NOARGS; } /* all required args are available */ @@ -299,7 +299,7 @@ static int handle_option(struct bee_getopt_ctl *ctl, const int index) return o->value; } -void bee_getopt_pop_current_argument(struct bee_getopt_ctl *optctl) +void mx_getopt_pop_current_argument(struct mx_getopt_ctl *optctl) { int i; @@ -316,13 +316,13 @@ void bee_getopt_pop_current_argument(struct bee_getopt_ctl *optctl) optctl->_argc--; } -void bee_getopt_pop_all_arguments(struct bee_getopt_ctl *optctl) +void mx_getopt_pop_all_arguments(struct mx_getopt_ctl *optctl) { while(optctl->optind < optctl->_argc) - bee_getopt_pop_current_argument(optctl); + mx_getopt_pop_current_argument(optctl); } -static int _bee_getopt_long(struct bee_getopt_ctl *optctl, int *optindex) +static int _mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex) { int this; @@ -332,7 +332,7 @@ static int _bee_getopt_long(struct bee_getopt_ctl *optctl, int *optindex) int idx; if(optctl->optind == optctl->_argc) - return BEE_GETOPT_END; + return MX_GETOPT_END; assert(optctl->optind < optctl->_argc); @@ -352,17 +352,17 @@ static int _bee_getopt_long(struct bee_getopt_ctl *optctl, int *optindex) /* not an option: pop arguement */ if(!maybe_option) { - bee_getopt_pop_current_argument(optctl); - return BEE_GETOPT_NOOPT; + mx_getopt_pop_current_argument(optctl); + return MX_GETOPT_NOOPT; } /* match & skip '--' and pop all remaining arguments */ if(maybe_long && (optctl->argv[this][2] == '\0')) { - if(!(optctl->flags & BEE_FLAG_KEEPOPTIONEND)) + if(!(optctl->flags & MX_FLAG_KEEPOPTIONEND)) optctl->optind++; - bee_getopt_pop_all_arguments(optctl); - return BEE_GETOPT_END; + mx_getopt_pop_all_arguments(optctl); + return MX_GETOPT_END; } /* match long option */ @@ -396,56 +396,56 @@ static int _bee_getopt_long(struct bee_getopt_ctl *optctl, int *optindex) return handle_option(optctl, idx); } -int bee_getopt_long(struct bee_getopt_ctl *optctl, int *optindex) +int mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex) { - return _bee_getopt_long(optctl, optindex); + return _mx_getopt_long(optctl, optindex); } -int bee_getopt(struct bee_getopt_ctl *optctl, int *optindex) +int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex) { int opt; - while((opt = _bee_getopt_long(optctl, optindex)) != BEE_GETOPT_END) { + while((opt = _mx_getopt_long(optctl, optindex)) != MX_GETOPT_END) { switch(opt) { - case BEE_GETOPT_NOVALUE: - return BEE_GETOPT_NOVALUE; + case MX_GETOPT_NOVALUE: + return MX_GETOPT_NOVALUE; - case BEE_GETOPT_NOOPT: - if (optctl->flags & BEE_FLAG_STOPONNOOPT) { - bee_getopt_pop_all_arguments(optctl); - return BEE_GETOPT_END; + case MX_GETOPT_NOOPT: + if (optctl->flags & MX_FLAG_STOPONNOOPT) { + mx_getopt_pop_all_arguments(optctl); + return MX_GETOPT_END; } break; - case BEE_GETOPT_AMBIGUOUS: + case MX_GETOPT_AMBIGUOUS: if (optctl->program) fprintf(stderr, "%s: ", optctl->program); fprintf(stderr, "option '%s' is ambiguous.\n", optctl->argv[optctl->optind]); - return BEE_GETOPT_ERROR; + return MX_GETOPT_ERROR; - case BEE_GETOPT_OPTUNKNOWN: - if (optctl->flags & BEE_FLAG_STOPONUNKNOWN) { - bee_getopt_pop_all_arguments(optctl); - return BEE_GETOPT_END; + case MX_GETOPT_OPTUNKNOWN: + if (optctl->flags & MX_FLAG_STOPONUNKNOWN) { + mx_getopt_pop_all_arguments(optctl); + return MX_GETOPT_END; } - if (!(optctl->flags & BEE_FLAG_SKIPUNKNOWN)) { + if (!(optctl->flags & MX_FLAG_SKIPUNKNOWN)) { if (optctl->program) fprintf(stderr, "%s: ", optctl->program); fprintf(stderr, "unrecognized option '%s'.\n", optctl->argv[optctl->optind]); - return BEE_GETOPT_ERROR; + return MX_GETOPT_ERROR; } - bee_getopt_pop_current_argument(optctl); + mx_getopt_pop_current_argument(optctl); break; - case BEE_GETOPT_NOARG: - case BEE_GETOPT_NOARGS: + case MX_GETOPT_NOARG: + case MX_GETOPT_NOARGS: if (optctl->program) fprintf(stderr, "%s: ", optctl->program); if (optctl->options[*optindex].long_opt) fprintf(stderr, "option '--%s' requires an argument.\n", optctl->options[*optindex].long_opt); else fprintf(stderr, "option '-%c' requires an argument.\n", optctl->options[*optindex].short_opt); - return BEE_GETOPT_ERROR; + return MX_GETOPT_ERROR; default: assert(opt >= 0); @@ -456,7 +456,7 @@ int bee_getopt(struct bee_getopt_ctl *optctl, int *optindex) return opt; } -void bee_getopt_print_quoted(char *s) +void mx_getopt_print_quoted(char *s) { putchar('\''); while (*s) { diff --git a/mx_getopt.h b/mx_getopt.h index 9961ad58..fe9ef256 100644 --- a/mx_getopt.h +++ b/mx_getopt.h @@ -21,125 +21,125 @@ ** along with this program; if not, see . */ -#ifndef BEE_GETOPT_H -#define BEE_GETOPT_H 1 - -#define BEE_TYPE_STRING 1 -#define BEE_TYPE_INTEGER 2 -#define BEE_TYPE_FLOAT 3 -#define BEE_TYPE_FLAG 4 -#define BEE_TYPE_NO 5 -#define BEE_TYPE_ENABLE 6 -#define BEE_TYPE_WITH 7 -#define BEE_TYPE_TOGGLE 8 -#define BEE_TYPE_COUNT 9 - -#define BEE_FLAG_SKIPUNKNOWN (1<<0) -#define BEE_FLAG_STOPONNOOPT (1<<1) -#define BEE_FLAG_STOPONUNKNOWN (1<<2) -#define BEE_FLAG_KEEPOPTIONEND (1<<3) - -#define BEE_OPT_LONG(name) .long_opt = (name) -#define BEE_OPT_SHORT(short) .short_opt = (short) -#define BEE_OPT_VALUE(v) .value = (v) -#define BEE_OPT_FLAG(f) .flag = (f) -#define BEE_OPT_TYPE(t) .type = (t) -#define BEE_OPT_OPTIONAL(args) .optional_args = (args) -#define BEE_OPT_REQUIRED(args) .required_args = (args) -#define _BEE_OPT_LEN(l) ._long_len = (l) - -#define BEE_GETOPT_END -1 -#define BEE_GETOPT_ERROR -2 -#define BEE_GETOPT_NOVALUE -3 -#define BEE_GETOPT_NOOPT -4 -#define BEE_GETOPT_AMBIGUOUS -5 -#define BEE_GETOPT_OPTUNKNOWN -6 -#define BEE_GETOPT_NOARG -7 -#define BEE_GETOPT_NOARGS -8 - -#define BEE_OPTION_DEFAULTS \ - BEE_OPT_LONG(NULL), \ - BEE_OPT_SHORT(0), \ - BEE_OPT_VALUE(BEE_GETOPT_NOVALUE), \ - BEE_OPT_FLAG(NULL), \ - BEE_OPT_TYPE(BEE_TYPE_FLAG), \ - BEE_OPT_OPTIONAL(0), \ - BEE_OPT_REQUIRED(0), \ - _BEE_OPT_LEN(0) - - -#define BEE_INIT_OPTION_DEFAULTS(opt) \ +#ifndef MX_GETOPT_H +#define MX_GETOPT_H 1 + +#define MX_TYPE_STRING 1 +#define MX_TYPE_INTEGER 2 +#define MX_TYPE_FLOAT 3 +#define MX_TYPE_FLAG 4 +#define MX_TYPE_NO 5 +#define MX_TYPE_ENABLE 6 +#define MX_TYPE_WITH 7 +#define MX_TYPE_TOGGLE 8 +#define MX_TYPE_COUNT 9 + +#define MX_FLAG_SKIPUNKNOWN (1<<0) +#define MX_FLAG_STOPONNOOPT (1<<1) +#define MX_FLAG_STOPONUNKNOWN (1<<2) +#define MX_FLAG_KEEPOPTIONEND (1<<3) + +#define MX_OPT_LONG(name) .long_opt = (name) +#define MX_OPT_SHORT(short) .short_opt = (short) +#define MX_OPT_VALUE(v) .value = (v) +#define MX_OPT_FLAG(f) .flag = (f) +#define MX_OPT_TYPE(t) .type = (t) +#define MX_OPT_OPTIONAL(args) .optional_args = (args) +#define MX_OPT_REQUIRED(args) .required_args = (args) +#define _MX_OPT_LEN(l) ._long_len = (l) + +#define MX_GETOPT_END -1 +#define MX_GETOPT_ERROR -2 +#define MX_GETOPT_NOVALUE -3 +#define MX_GETOPT_NOOPT -4 +#define MX_GETOPT_AMBIGUOUS -5 +#define MX_GETOPT_OPTUNKNOWN -6 +#define MX_GETOPT_NOARG -7 +#define MX_GETOPT_NOARGS -8 + +#define MX_OPTION_DEFAULTS \ + MX_OPT_LONG(NULL), \ + MX_OPT_SHORT(0), \ + MX_OPT_VALUE(MX_GETOPT_NOVALUE), \ + MX_OPT_FLAG(NULL), \ + MX_OPT_TYPE(MX_TYPE_FLAG), \ + MX_OPT_OPTIONAL(0), \ + MX_OPT_REQUIRED(0), \ + _MX_OPT_LEN(0) + + +#define MX_INIT_OPTION_DEFAULTS(opt) \ (opt)->long_opt = NULL; \ (opt)->short_opt = 0; \ - (opt)->value = BEE_GETOPT_NOVALUE; \ + (opt)->value = MX_GETOPT_NOVALUE; \ (opt)->flag = NULL; \ - (opt)->type = BEE_TYPE_FLAG; \ + (opt)->type = MX_TYPE_FLAG; \ (opt)->optional_args = 0; \ (opt)->required_args = 0; \ (opt)->_long_len = 0 -#define BEE_INIT_OPTION_END(opt) BEE_INIT_OPTION_DEFAULTS((opt)) +#define MX_INIT_OPTION_END(opt) MX_INIT_OPTION_DEFAULTS((opt)) -#define BEE_OPTION_END { BEE_OPT_LONG(NULL), BEE_OPT_SHORT(0) } +#define MX_OPTION_END { MX_OPT_LONG(NULL), MX_OPT_SHORT(0) } -#define BEE_OPTION(...) { BEE_OPTION_DEFAULTS, ## __VA_ARGS__ } +#define MX_OPTION(...) { MX_OPTION_DEFAULTS, ## __VA_ARGS__ } -#define BEE_OPTION_NO_ARG(name, short, ...) \ - BEE_OPTION(BEE_OPT_LONG(name), \ - BEE_OPT_SHORT(short), \ - BEE_OPT_VALUE(short), \ +#define MX_OPTION_NO_ARG(name, short, ...) \ + MX_OPTION(MX_OPT_LONG(name), \ + MX_OPT_SHORT(short), \ + MX_OPT_VALUE(short), \ ## __VA_ARGS__) -#define BEE_OPTION_REQUIRED_ARG(name, short, ...) \ - BEE_OPTION(BEE_OPT_LONG(name), \ - BEE_OPT_SHORT(short), \ - BEE_OPT_VALUE(short), \ - BEE_OPT_TYPE(BEE_TYPE_STRING), \ - BEE_OPT_REQUIRED(1), \ +#define MX_OPTION_REQUIRED_ARG(name, short, ...) \ + MX_OPTION(MX_OPT_LONG(name), \ + MX_OPT_SHORT(short), \ + MX_OPT_VALUE(short), \ + MX_OPT_TYPE(MX_TYPE_STRING), \ + MX_OPT_REQUIRED(1), \ ## __VA_ARGS__ ) -#define BEE_OPTION_REQUIRED_ARGS(name, short, n, ...) \ - BEE_OPTION(BEE_OPT_LONG(name), \ - BEE_OPT_SHORT(short), \ - BEE_OPT_VALUE(short), \ - BEE_OPT_TYPE(BEE_TYPE_STRING), \ - BEE_OPT_REQUIRED(n), \ +#define MX_OPTION_REQUIRED_ARGS(name, short, n, ...) \ + MX_OPTION(MX_OPT_LONG(name), \ + MX_OPT_SHORT(short), \ + MX_OPT_VALUE(short), \ + MX_OPT_TYPE(MX_TYPE_STRING), \ + MX_OPT_REQUIRED(n), \ ## __VA_ARGS__ ) -#define BEE_OPTION_OPTIONAL_ARG(name, short, ...) \ - BEE_OPTION(BEE_OPT_LONG(name), \ - BEE_OPT_SHORT(short), \ - BEE_OPT_VALUE(short), \ - BEE_OPT_TYPE(BEE_TYPE_STRING), \ - BEE_OPT_OPTIONAL(1), \ +#define MX_OPTION_OPTIONAL_ARG(name, short, ...) \ + MX_OPTION(MX_OPT_LONG(name), \ + MX_OPT_SHORT(short), \ + MX_OPT_VALUE(short), \ + MX_OPT_TYPE(MX_TYPE_STRING), \ + MX_OPT_OPTIONAL(1), \ ## __VA_ARGS__ ) -#define BEE_OPTION_OPTIONAL_ARGS(name, short, n, ...) \ - BEE_OPTION(BEE_OPT_LONG(name), \ - BEE_OPT_SHORT(short), \ - BEE_OPT_VALUE(short), \ - BEE_OPT_TYPE(BEE_TYPE_STRING), \ - BEE_OPT_OPTIONAL(n), \ +#define MX_OPTION_OPTIONAL_ARGS(name, short, n, ...) \ + MX_OPTION(MX_OPT_LONG(name), \ + MX_OPT_SHORT(short), \ + MX_OPT_VALUE(short), \ + MX_OPT_TYPE(MX_TYPE_STRING), \ + MX_OPT_OPTIONAL(n), \ ## __VA_ARGS__ ) -#define BEE_OPTION_ARGS(name, short, opt, req, ...) \ - BEE_OPTION(BEE_OPT_LONG(name), \ - BEE_OPT_SHORT(short), \ - BEE_OPT_VALUE(short), \ - BEE_OPT_TYPE(BEE_TYPE_STRING), \ - BEE_OPT_OPTIONAL(opt), \ - BEE_OPT_REQUIRED(req), \ +#define MX_OPTION_ARGS(name, short, opt, req, ...) \ + MX_OPTION(MX_OPT_LONG(name), \ + MX_OPT_SHORT(short), \ + MX_OPT_VALUE(short), \ + MX_OPT_TYPE(MX_TYPE_STRING), \ + MX_OPT_OPTIONAL(opt), \ + MX_OPT_REQUIRED(req), \ ## __VA_ARGS__ ) -#define BEE_GETOPT_FINISH(optctl, argc, argv) \ +#define MX_GETOPT_FINISH(optctl, argc, argv) \ do { \ (argv) = &(optctl).argv[(optctl).optind]; \ (argc) = (optctl).argc - (optctl).optind; \ } while(0) -struct bee_option { +struct mx_option { char *long_opt; char short_opt; @@ -154,7 +154,7 @@ struct bee_option { int _long_len; }; -struct bee_getopt_ctl { +struct mx_getopt_ctl { int optind; char *program; @@ -167,7 +167,7 @@ struct bee_getopt_ctl { int argc; char **argv; - struct bee_option *options; + struct mx_option *options; int _argc; int _optcnt; @@ -176,12 +176,12 @@ struct bee_getopt_ctl { int flags; }; -void bee_getopt_pop_current_argument(struct bee_getopt_ctl *optctl); +void mx_getopt_pop_current_argument(struct mx_getopt_ctl *optctl); -int bee_getopt_init(struct bee_getopt_ctl *ctl, int argc, char **argv, struct bee_option *optv); -int bee_getopt_long(struct bee_getopt_ctl *optctl, int *optindex); -int bee_getopt(struct bee_getopt_ctl *optctl, int *optindex); +int mx_getopt_init(struct mx_getopt_ctl *ctl, int argc, char **argv, struct mx_option *optv); +int mx_getopt_long(struct mx_getopt_ctl *optctl, int *optindex); +int mx_getopt(struct mx_getopt_ctl *optctl, int *optindex); -void bee_getopt_print_quoted(char *s); +void mx_getopt_print_quoted(char *s); #endif diff --git a/mxqd.c b/mxqd.c index 4f1205a2..f6985dce 100644 --- a/mxqd.c +++ b/mxqd.c @@ -209,20 +209,20 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) unsigned long memory_max = 0; int i; - struct bee_getopt_ctl optctl; - struct bee_option opts[] = { - BEE_OPTION_NO_ARG("help", 'h'), - BEE_OPTION_NO_ARG("version", 'V'), - BEE_OPTION_NO_ARG("daemonize", 1), - BEE_OPTION_NO_ARG("no-log", 3), - BEE_OPTION_REQUIRED_ARG("pid-file", 2), - BEE_OPTION_REQUIRED_ARG("slots", 'j'), - BEE_OPTION_REQUIRED_ARG("memory", 'm'), - BEE_OPTION_REQUIRED_ARG("max-memory-per-slot", 'x'), - BEE_OPTION_REQUIRED_ARG("server-id", 'N'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), - BEE_OPTION_END + struct mx_getopt_ctl optctl; + struct mx_option opts[] = { + MX_OPTION_NO_ARG("help", 'h'), + MX_OPTION_NO_ARG("version", 'V'), + MX_OPTION_NO_ARG("daemonize", 1), + MX_OPTION_NO_ARG("no-log", 3), + MX_OPTION_REQUIRED_ARG("pid-file", 2), + MX_OPTION_REQUIRED_ARG("slots", 'j'), + MX_OPTION_REQUIRED_ARG("memory", 'm'), + MX_OPTION_REQUIRED_ARG("max-memory-per-slot", 'x'), + MX_OPTION_REQUIRED_ARG("server-id", 'N'), + MX_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), + MX_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), + MX_OPTION_END }; arg_server_id = "main"; @@ -235,13 +235,13 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) if (!arg_mysql_default_file) arg_mysql_default_file = MYSQL_DEFAULT_FILE; - bee_getopt_init(&optctl, argc-1, &argv[1], opts); + mx_getopt_init(&optctl, argc-1, &argv[1], opts); - optctl.flags = BEE_FLAG_STOPONUNKNOWN|BEE_FLAG_STOPONNOOPT; -// optctl.flags = BEE_FLAG_STOPONUNKNOWN; + optctl.flags = MX_FLAG_STOPONUNKNOWN|MX_FLAG_STOPONNOOPT; +// optctl.flags = MX_FLAG_STOPONUNKNOWN; - while ((opt=bee_getopt(&optctl, &i)) != BEE_GETOPT_END) { - if (opt == BEE_GETOPT_ERROR) { + while ((opt=mx_getopt(&optctl, &i)) != MX_GETOPT_END) { + if (opt == MX_GETOPT_ERROR) { exit(EX_USAGE); } @@ -305,7 +305,7 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) } } - BEE_GETOPT_FINISH(optctl, argc, argv); + MX_GETOPT_FINISH(optctl, argc, argv); if (arg_daemonize && arg_nolog) { mx_log_err("Error while using conflicting options --daemonize and --no-log at once."); diff --git a/mxqdump.c b/mxqdump.c index 67e6f453..7389ec8d 100644 --- a/mxqdump.c +++ b/mxqdump.c @@ -76,14 +76,14 @@ int main(int argc, char *argv[]) char *arg_mysql_default_file; int opt; - struct bee_getopt_ctl optctl; - struct bee_option opts[] = { - BEE_OPTION_NO_ARG("help", 'h'), - BEE_OPTION_NO_ARG("version", 'V'), - - BEE_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), - BEE_OPTION_END + struct mx_getopt_ctl optctl; + struct mx_option opts[] = { + MX_OPTION_NO_ARG("help", 'h'), + MX_OPTION_NO_ARG("version", 'V'), + + MX_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), + MX_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), + MX_OPTION_END }; arg_mysql_default_group = getenv("MXQ_MYSQL_DEFAULT_GROUP"); @@ -95,11 +95,11 @@ int main(int argc, char *argv[]) arg_mysql_default_file = MYSQL_DEFAULT_FILE; - bee_getopt_init(&optctl, argc-1, &argv[1], opts); - optctl.flags = BEE_FLAG_STOPONUNKNOWN|BEE_FLAG_STOPONNOOPT; + mx_getopt_init(&optctl, argc-1, &argv[1], opts); + optctl.flags = MX_FLAG_STOPONUNKNOWN|MX_FLAG_STOPONNOOPT; - while ((opt=bee_getopt(&optctl, &i)) != BEE_GETOPT_END) { - if (opt == BEE_GETOPT_ERROR) { + while ((opt=mx_getopt(&optctl, &i)) != MX_GETOPT_END) { + if (opt == MX_GETOPT_ERROR) { exit(EX_USAGE); } @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) } } - BEE_GETOPT_FINISH(optctl, argc, argv); + MX_GETOPT_FINISH(optctl, argc, argv); mmysql.default_file = arg_mysql_default_file; mmysql.default_group = arg_mysql_default_group; diff --git a/mxqkill.c b/mxqkill.c index f9e92a00..80936447 100644 --- a/mxqkill.c +++ b/mxqkill.c @@ -95,16 +95,16 @@ int main(int argc, char *argv[]) int i; int opt; - struct bee_getopt_ctl optctl; - struct bee_option opts[] = { - BEE_OPTION_NO_ARG("help", 'h'), - BEE_OPTION_NO_ARG("version", 'V'), + struct mx_getopt_ctl optctl; + struct mx_option opts[] = { + MX_OPTION_NO_ARG("help", 'h'), + MX_OPTION_NO_ARG("version", 'V'), - BEE_OPTION_REQUIRED_ARG("group-id", 'g'), + MX_OPTION_REQUIRED_ARG("group-id", 'g'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), - BEE_OPTION_END + MX_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), + MX_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), + MX_OPTION_END }; arg_mysql_default_group = getenv("MXQ_MYSQL_DEFAULT_GROUP"); @@ -119,11 +119,11 @@ int main(int argc, char *argv[]) mx_log_level_set(MX_LOG_INFO); - bee_getopt_init(&optctl, argc-1, &argv[1], opts); - optctl.flags = BEE_FLAG_STOPONUNKNOWN|BEE_FLAG_STOPONNOOPT; + mx_getopt_init(&optctl, argc-1, &argv[1], opts); + optctl.flags = MX_FLAG_STOPONUNKNOWN|MX_FLAG_STOPONNOOPT; - while ((opt=bee_getopt(&optctl, &i)) != BEE_GETOPT_END) { - if (opt == BEE_GETOPT_ERROR) { + while ((opt=mx_getopt(&optctl, &i)) != MX_GETOPT_END) { + if (opt == MX_GETOPT_ERROR) { exit(EX_USAGE); } @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) } } - BEE_GETOPT_FINISH(optctl, argc, argv); + MX_GETOPT_FINISH(optctl, argc, argv); mmysql.default_file = arg_mysql_default_file; mmysql.default_group = arg_mysql_default_group; diff --git a/mxqsub.c b/mxqsub.c index c629e41a..7bdfc7b1 100644 --- a/mxqsub.c +++ b/mxqsub.c @@ -426,38 +426,38 @@ int main(int argc, char *argv[]) struct group *grp; int opt; - struct bee_getopt_ctl optctl; - struct bee_option opts[] = { - BEE_OPTION_NO_ARG("help", 'h'), - BEE_OPTION_NO_ARG("version", 'V'), + struct mx_getopt_ctl optctl; + struct mx_option opts[] = { + MX_OPTION_NO_ARG("help", 'h'), + MX_OPTION_NO_ARG("version", 'V'), - BEE_OPTION_REQUIRED_ARG("group_id", 1), - BEE_OPTION_REQUIRED_ARG("group_priority", 2), - BEE_OPTION_REQUIRED_ARG("group-id", 3), - BEE_OPTION_REQUIRED_ARG("time", 4), + MX_OPTION_REQUIRED_ARG("group_id", 1), + MX_OPTION_REQUIRED_ARG("group_priority", 2), + MX_OPTION_REQUIRED_ARG("group-id", 3), + MX_OPTION_REQUIRED_ARG("time", 4), - BEE_OPTION_NO_ARG("debug", 5), + MX_OPTION_NO_ARG("debug", 5), - BEE_OPTION_REQUIRED_ARG("group-name", 'N'), - BEE_OPTION_REQUIRED_ARG("group-priority", 'P'), + MX_OPTION_REQUIRED_ARG("group-name", 'N'), + MX_OPTION_REQUIRED_ARG("group-priority", 'P'), - BEE_OPTION_REQUIRED_ARG("command-alias", 'a'), + MX_OPTION_REQUIRED_ARG("command-alias", 'a'), - BEE_OPTION_REQUIRED_ARG("workdir", 'w'), - BEE_OPTION_REQUIRED_ARG("stdout", 'o'), - BEE_OPTION_REQUIRED_ARG("stderr", 'e'), - BEE_OPTION_REQUIRED_ARG("umask", 'u'), - BEE_OPTION_REQUIRED_ARG("priority", 'p'), + MX_OPTION_REQUIRED_ARG("workdir", 'w'), + MX_OPTION_REQUIRED_ARG("stdout", 'o'), + MX_OPTION_REQUIRED_ARG("stderr", 'e'), + MX_OPTION_REQUIRED_ARG("umask", 'u'), + MX_OPTION_REQUIRED_ARG("priority", 'p'), - BEE_OPTION_REQUIRED_ARG("threads", 'j'), - BEE_OPTION_REQUIRED_ARG("memory", 'm'), - BEE_OPTION_REQUIRED_ARG("runtime", 't'), + MX_OPTION_REQUIRED_ARG("threads", 'j'), + MX_OPTION_REQUIRED_ARG("memory", 'm'), + MX_OPTION_REQUIRED_ARG("runtime", 't'), - BEE_OPTION_REQUIRED_ARG("define", 'D'), + MX_OPTION_REQUIRED_ARG("define", 'D'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), - BEE_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), - BEE_OPTION_END + MX_OPTION_OPTIONAL_ARG("mysql-default-file", 'M'), + MX_OPTION_OPTIONAL_ARG("mysql-default-group", 'S'), + MX_OPTION_END }; @@ -492,11 +492,11 @@ int main(int argc, char *argv[]) /******************************************************************/ - bee_getopt_init(&optctl, argc-1, &argv[1], opts); - optctl.flags = BEE_FLAG_STOPONUNKNOWN|BEE_FLAG_STOPONNOOPT; + mx_getopt_init(&optctl, argc-1, &argv[1], opts); + optctl.flags = MX_FLAG_STOPONUNKNOWN|MX_FLAG_STOPONNOOPT; - while ((opt=bee_getopt(&optctl, &i)) != BEE_GETOPT_END) { - if (opt == BEE_GETOPT_ERROR) { + while ((opt=mx_getopt(&optctl, &i)) != MX_GETOPT_END) { + if (opt == MX_GETOPT_ERROR) { exit(EX_USAGE); } @@ -613,7 +613,7 @@ int main(int argc, char *argv[]) } } - BEE_GETOPT_FINISH(optctl, argc, argv); + MX_GETOPT_FINISH(optctl, argc, argv); if (argc < 1) { print_usage(); exit(EX_USAGE);