From a7e337c459b2b7284757127b64235579b061561c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 25 Mar 2013 21:33:29 +0100 Subject: cethcan: skeleton --- cethcan/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 cethcan/main.c (limited to 'cethcan/main.c') 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; +} -- cgit v1.2.1