summaryrefslogtreecommitdiff
path: root/cethcan/main.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2013-03-25 21:33:29 +0100
committerDavid Lamparter <equinox@diac24.net>2013-03-25 21:33:46 +0100
commita7e337c459b2b7284757127b64235579b061561c (patch)
tree4ae5cc432a944c2cfbbed76792ec185e732f0132 /cethcan/main.c
parent2a44e256924a2cf19fe2548aaff88ad782b0d7b8 (diff)
cethcan: skeleton
Diffstat (limited to 'cethcan/main.c')
-rw-r--r--cethcan/main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/cethcan/main.c b/cethcan/main.c
new file mode 100644
index 0000000..938721e
--- /dev/null
+++ b/cethcan/main.c
@@ -0,0 +1,45 @@
+#include "cethcan.h"
+
+struct event_base *ev_base;
+json_t *config;
+
+int main(int argc, char **argv)
+{
+ int optch = 0;
+ const char *cfgfile = "cethcan.json";
+ json_error_t je;
+
+ do {
+ optch = getopt(argc, argv, "c:");
+ switch (optch) {
+ case 'c':
+ cfgfile = optarg;
+ break;
+ case -1:
+ break;
+ }
+ } while (optch != -1);
+
+ if (optind < argc) {
+ fprintf(stderr, "leftover arguments\n");
+ return 1;
+ }
+
+ config = json_load_file(cfgfile, JSON_REJECT_DUPLICATES, &je);
+ if (!config) {
+ fprintf(stderr, "failed to load config:\n%s:%d:%d %s\n",
+ je.source, je.line, je.column, je.text);
+ return 1;
+ }
+ if (!json_is_object(config)) {
+ fprintf(stderr, "config must be object/dictionary\n");
+ return 1;
+ }
+
+ ev_base = event_base_new();
+
+ can_init();
+
+ event_base_loop(ev_base, 0);
+ return 0;
+}