34 lines
554 B
C
34 lines
554 B
C
#ifndef ULIB_ARGS_H_
|
|
#define ULIB_ARGS_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
|
|
char **args(void);
|
|
size_t argslen(void);
|
|
|
|
typedef struct {
|
|
char *shortname;
|
|
enum { ARG_STRING, ARG_BOOL } expected_value;
|
|
void *ptr;
|
|
bool end;
|
|
} Arg;
|
|
|
|
#define ARG(sn, ev, p) ((Arg){ \
|
|
.shortname = (sn), \
|
|
.expected_value = (ev), \
|
|
.ptr = (void *)(p), \
|
|
.end = false, \
|
|
})
|
|
|
|
#define ARG_END() ((Arg){ .end = true, })
|
|
|
|
enum {
|
|
ARGP_OK = 0,
|
|
};
|
|
|
|
int32_t parse_args(char **argv, size_t argc, Arg *defs);
|
|
|
|
#endif // ULIB_ARGS_H_
|