gargoyle/src/gargoyle.c

39 lines
737 B
C

#include <gargoyle.h>
#include <stddef.h>
uint8_t gargoyle_digest(uint16_t optc, struct gargoyle_opt *optv, int *argc, char ***argv) {
uint8_t status = 1;
while(status) {
const char *arg = **argv;
if(!arg || *arg != '-' || !*(arg + 1)) {
status = 0;
break;
} else if(*arg == '-' && *(arg + 1) == '-' && !*(arg + 2)) {
*argc -= 1;
*argv += 1;
status = 0;
break;
}
struct gargoyle_opt *opt = NULL;
if(*(arg + 1) == '-') {
opt = gargoyle_find_brand(optc, optv, arg + 2);
} else {
/* loop through short opts */
}
if(!opt) {
status = GARGOYLE_ERR_UNKNOWN_OPT;
break;
}
*argc -= 1;
*argv += 1;
}
return status;
}