summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index b581f42..b865b01 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,10 +1,43 @@
+#include <getopt.h>
#include <stdio.h>
+#include "config.h"
+
+static void
+usage(const char *argv_0)
+{
+ fprintf(stderr, "Usage: %s [-C path]\n", argv_0);
+}
int
main(int argc, char **argv)
{
- printf("Hello world!\n");
- (void)argc;
- (void)argv;
+ struct gmnisrv_config conf = {0};
+
+ char *confpath = SYSCONFDIR "/gmnisrv.ini";
+ int c;
+ while ((c = getopt(argc, argv, "C:h")) != -1) {
+ switch (c) {
+ case 'C':
+ confpath = optarg;
+ break;
+ case 'h':
+ usage(argv[0]);
+ return 0;
+ default:
+ fprintf(stderr, "Unknown flag %c\n", c);
+ usage(argv[0]);
+ return 1;
+ }
+ }
+ if (optind < argc) {
+ usage(argv[0]);
+ return 1;
+ }
+
+ int r = load_config(&conf, confpath);
+ if (r != 0) {
+ return r;
+ }
+
return 0;
}