aboutsummaryrefslogtreecommitdiff
path: root/include/optparse.h
blob: 816b1925932f42f9e027a5a9ac9b6cba410e9275 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef MLIB_OPTPARSE_H
#define MLIB_OPTPARSE_H

#include <stddef.h>

#include "__charN_t.h"
#include "__rune.h"
#include "__u8view.h"

struct optparse {
	int optind, subopt;
	char errmsg[128];
	char **argv;
	struct u8view optarg;
};

enum op_argkind {
	OPT_NONE,
	OPT_OPT,
	OPT_REQ,
};

struct op_option {
	rune shortopt;
	const char8_t *longopt;
	enum op_argkind argtype;
};

rune optparse(struct optparse *, const struct op_option *, size_t);
void optparse_init(struct optparse *, char **);

#endif /* !MLIB_OPTPARSE_H */