34 #include <gwenhywfar/misc.h>
35 #include <gwenhywfar/debug.h>
36 #include <gwenhywfar/text.h>
39 #define DISABLE_DEBUGLOG
60 while(i<argc && !stop) {
61 GWEN_ARGS_ELEMENT_TYPE t;
72 t=GWEN_ArgsElementTypeLong;
75 t=GWEN_ArgsElementTypeShort;
78 t=GWEN_ArgsElementTypeFreeParam;
81 case GWEN_ArgsElementTypeFreeParam:
89 DBG_ERROR(
GWEN_LOGDOMAIN,
"Only options are allowed, but argument \"%s\" was not recognized as a known option.", p);
99 case GWEN_ArgsElementTypeShort:
100 for(tmpArgs=args;;tmpArgs++) {
107 tmpArgs->
name, 0, 0)+1);
127 switch(tmpArgs->
type) {
131 tmpArgs->
name, argv[i]);
135 if (sscanf(argv[i],
"%i", &value)!=1) {
142 tmpArgs->
name, value);
165 case GWEN_ArgsElementTypeLong:
169 while(*v && *v!=
'=') v++;
170 tmpBuf=(
char*)malloc(v-p+1);
172 memmove(tmpBuf, p, v-p);
175 for(tmpArgs=args;;tmpArgs++) {
182 tmpArgs->
name, 0, 0)+1);
215 switch(tmpArgs->
type) {
223 if (sscanf(v,
"%i", &value)!=1) {
232 tmpArgs->
name, value);
265 for(tmpArgs=args;;tmpArgs++) {
277 if (tmpArgs->
minNum && ((
unsigned int)c<tmpArgs->minNum)) {
290 if (tmpArgs->
maxNum && ((
unsigned int)c>tmpArgs->
maxNum)) {
292 "Option \"%s\" needed at most %d times (have %d)",
331 for(tmpArgs=args;;tmpArgs++) {
377 "Option \"%s\" has neither a long nor a short name",