Files
mop3/libu/cmdline_parser.h
kamkow1 fbf067d418
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 2m6s
Build documentation / build-and-deploy (push) Successful in 1m18s
Parse commandline strings, move away from old env vars
2026-04-28 22:45:31 +02:00

37 lines
1.1 KiB
C

#ifndef _LIBU_CMDLINE_PARSER_H
#define _LIBU_CMDLINE_PARSER_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define CMDLINE_OPT_NAME_MAX 32
#define CMDLINE_OPT_VALUE_MAX 512
#define CMDLINE_OPT_VALUE_STRING 0
#define CMDLINE_OPT_VALUE_BOOL 1
#define CMDLINE_OPT_VALUE_INT 2
struct cmdline_opt {
const char* name;
const char* altname;
int type;
bool required;
void* valueptr;
bool end;
bool set;
};
#define CMDLINE_OPT(name1, altname1, type1, required1, valueptr1) \
((struct cmdline_opt){.name = (name1), \
.altname = (altname1), \
.type = (type1), \
.required = (required1), \
.valueptr = (valueptr1)})
#define CMDLINE_END() ((struct cmdline_opt){.end = true})
int cmdline_parse(const char* cmdline, struct cmdline_opt* opt_array);
#endif // _LIBU_CMDLINE_PARSER_H