# HG changeset patch # User tuomov # Date 956174631 -7200 # Node ID ee28b655297b406aa876d3f7217e6c72804751ff # Parent b1fbfab67908406c03673c6a59369939ab826ed3 trunk: changeset 7 Simpler optparser diff -r b1fbfab67908 -r ee28b655297b include/misc.h --- a/include/misc.h Wed Apr 19 22:03:38 2000 +0200 +++ b/include/misc.h Wed Apr 19 22:03:51 2000 +0200 @@ -12,7 +12,6 @@ #include #include -#include #include #include "types.h" diff -r b1fbfab67908 -r ee28b655297b include/optparser.h --- a/include/optparser.h Wed Apr 19 22:03:38 2000 +0200 +++ b/include/optparser.h Wed Apr 19 22:03:51 2000 +0200 @@ -16,13 +16,25 @@ #define OPT_ID(X) ((X)|0x10000) #define OPT_ID_RESERVED(X) ((X)|0x20000) +/* OPTP_CHAIN is the normal behavior, i.e. single-letter options can be + * "chained" together: 'lr -lR'. Use for normal command line programs. + * OPTP_MIDLONG allows '-display foo' -like args but disables chaining + * of single-letter options. X programs should probably use this. + * OPTP_IMMEDIATE allows immediate arguments (-I/usr/include) (and disables + * chaining and midlong options). + * OPTP_NO_DASH is the same as OPTP_CHAIN but allows the dash to be omitted + * for 'tar xzf foo' -like behavior. + * Long '--foo=bar' options are supported in all of the modes. + */ + enum{ - OPT__IMM_ARG=0x0100, - OPT_IMM_ARG=0x0101, /* may have immediate argument (-fblaah) */ - OPT_CHAINABLE=0x0200, /* chainable (-xzf) */ - OPT_NO_DASH=0x0400, /* dash not necessary (xzf) */ - OPT_MIDLONG=0x0800, /* have midlong opt (-help) */ - OPT_NO_LONG=0x1000, /* no long opt (--help) */ + OPTP_CHAIN=0, + OPTP_MIDLONG=1, + OPTP_IMMEDIATE=2, + OPTP_NO_DASH=3 +}; + +enum{ OPT_ARG=1, /* option has an argument */ OPT_OPT_ARG=3 /* option may have an argument */ }; @@ -47,7 +59,7 @@ }; -extern void optparser_init(int argc, char *const argv[], +extern void optparser_init(int argc, char *const argv[], int mode, const OptParserOpt *opts); extern int optparser_get_opt(); extern const char* optparser_get_arg();