summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfadhil riyanto <me@fadev.org>2024-09-24 08:32:44 +0700
committerfadhil riyanto <me@fadev.org>2024-09-24 08:32:44 +0700
commitc4ffc63134d906868e78864aff48ff2cd8a13fa1 (patch)
tree61d5b855b41bdc0f68470d2f05081841c1625ee4
parent94cdd0d39d352dc57ee456e2b1dc74ae46636360 (diff)
add getopt
-rw-r--r--main.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/main.c b/main.c
index e9c0e82..4efc086 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,33 @@
+
#include <stdio.h>
+#include <getopt.h>
+#include "submodule/log.c-patched/src/log.h"
+
+#define dbgchr(x) log_info("%c", x)
+
+static int parseopt(int argc, char **argv)
+{
+ int optcounter = 0;
+ int c = 0;
+
+ static struct option opt_table[] = {
+ {"mode", required_argument, 0, 'm'},
+ {0, 0, 0, 0}
+ };
+
+ while(1) {
+ c = getopt_long(argc, argv, "m:", opt_table, &optcounter);
+ dbgchr(c);
+
+ if (c == -1)
+ break;
+
+ }
+
+
+}
-int main()
+int main(int argc, char **argv)
{
- printf("hello world!");
+ parseopt(argc, argv);
} \ No newline at end of file