Create the basic parser shell
This commit is contained in:
parent
4bad91fd37
commit
c9ee108cd5
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef __GARGOYLE_H_
|
||||||
|
#define __GARGOYLE_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
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
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include <gargoyle.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue