aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-03-10 14:32:54 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-03-10 14:37:36 +0200
commit059c0c9af70f3d55b4ed18ce537d433a21a176bd (patch)
tree9b6da3bd0f3a84f36b35863e66223ea8b331012a /include
parent9ce9968745dc64fafc800d7ede0fb13bedc6f1db (diff)
Add optparse.h
Diffstat (limited to 'include')
-rw-r--r--include/optparse.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/optparse.h b/include/optparse.h
new file mode 100644
index 0000000..816b192
--- /dev/null
+++ b/include/optparse.h
@@ -0,0 +1,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 */