trunk: changeset 7

Wed, 19 Apr 2000 22:03:51 +0200

author
tuomov
date
Wed, 19 Apr 2000 22:03:51 +0200
changeset 4
ee28b655297b
parent 3
b1fbfab67908
child 5
f878a9ffa3e0

trunk: changeset 7
Simpler optparser

include/misc.h file | annotate | diff | comparison | revisions
include/optparser.h file | annotate | diff | comparison | revisions
--- 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 <stdlib.h>
 #include <stdio.h>
-#include <malloc.h>
 #include <assert.h>
 #include "types.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();

mercurial