diff --git a/include/gargoyle.h b/include/gargoyle.h new file mode 100644 index 0000000..b8b304a --- /dev/null +++ b/include/gargoyle.h @@ -0,0 +1,22 @@ +#ifndef __GARGOYLE_H_ +#define __GARGOYLE_H_ + +#include + +const uint8_t GARGOYLE_TYPE_UINT = 1 << 0; +const uint8_t GARGOYLE_TYPE_BOOL = 1 << 1; +const uint8_t GARGOYLE_TYPE_FILE = 1 << 2; +const uint8_t GARGOYLE_TYPE_ROPE = 1 << 3; +const uint8_t GARGOYLE_TYPE_DBLE = 1 << 4; + +struct gargoyle_opt { + const char *brand; + uint16_t length; + const char emblem; + void *value; + uint8_t type; +}; + +uint8_t gargoyle_digest(struct gargoyle_opt *args, uint16_t *argc, const char ***argv); + +#endif diff --git a/src/gargoyle.c b/src/gargoyle.c new file mode 100644 index 0000000..aa30240 --- /dev/null +++ b/src/gargoyle.c @@ -0,0 +1,24 @@ +#include + +uint8_t gargoyle_digest(struct gargoyle_opt *args, uint16_t *argc, const char ***argv) { + uint8_t parsing = 1; + + while(parsing) { + const char *arg = **argv; + + if(!arg || *arg != '-' || !*(arg + 1)) { + parsing = 0; + break; + } else if(*arg == '-' && *(arg + 1) == '-' && !*(arg + 2)) { + *argc -= 1; + *argv += 1; + parsing = 0; + break; + } + + *argc -= 1; + *argv += 1; + } + + return parsing; +}