optparser.c

changeset 5
f878a9ffa3e0
parent 3
b1fbfab67908
child 9
55e7f2ff6021
equal deleted inserted replaced
4:ee28b655297b 5:f878a9ffa3e0
8 */ 8 */
9 9
10 #include <string.h> 10 #include <string.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 12
13 #include "include/util.h" 13 #include <libtu/util.h>
14 #include "include/misc.h" 14 #include <libtu/misc.h>
15 #include "include/optparser.h" 15 #include <libtu/optparser.h>
16 #include "include/output.h" 16 #include <libtu/output.h>
17 17
18 18
19 #define O_ARGS(o) (o->flags&OPT_OPT_ARG) 19 #define O_ARGS(o) (o->flags&OPT_OPT_ARG)
20 #define O_ARG(o) (o->flasg&OPT_ARG) 20 #define O_ARG(o) (o->flasg&OPT_ARG)
21 #define O_OPT_ARG(o) (O_ARGS(o)==OPT_OPT_ARG) 21 #define O_OPT_ARG(o) (O_ARGS(o)==OPT_OPT_ARG)
58 return o; 58 return o;
59 } 59 }
60 return NULL; 60 return NULL;
61 } 61 }
62 62
63
64 /*static bool valid_chain(const char *p, const OptParserOpt *o)
65 {
66 while(*p!='\0'){
67 if(!find_chain_opt(*p, o))
68 return FALSE;
69 p++;
70 }
71 return TRUE;
72 }*/
73
74 63
75 static bool is_option(const char *p) 64 static bool is_option(const char *p)
76 { 65 {
77 if(p==NULL) 66 if(p==NULL)
78 return FALSE; 67 return FALSE;
136 if(*(p+2)=='\0'){ 125 if(*(p+2)=='\0'){
137 /* -- arguments */ 126 /* -- arguments */
138 o_args_left=o_left; 127 o_args_left=o_left;
139 RET(OPT_ID_ARGUMENT); 128 RET(OPT_ID_ARGUMENT);
140 } 129 }
141 /*argptr=strchr(p, '=');
142 if(argptr!=NULL)
143 argptr++;
144 */
145 type=LONG; 130 type=LONG;
146 p2=p+2; 131 p2=p+2;
147 }else{ 132 }else{
148 /* -foo */ 133 /* -foo */
149 if(*(p+1)=='\0'){ 134 if(*(p+1)=='\0'){

mercurial