From acea10b2030e6738eca947a83fc1f1bb4d183042 Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Fri, 8 Feb 2013 21:00:58 +0100 Subject: [PATCH] mnc: initial arg handling --- tools/munin-node-c/main.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/munin-node-c/main.c b/tools/munin-node-c/main.c index e173ee59..ad54a8f4 100644 --- a/tools/munin-node-c/main.c +++ b/tools/munin-node-c/main.c @@ -21,6 +21,8 @@ int main(int argc, char *argv[]) { char format[] = "vd:h:s:"; + char line[LINE_MAX]; + opterr = 1; while ((optch = getopt(argc, argv, format)) != -1) @@ -51,8 +53,30 @@ int main(int argc, char *argv[]) { gethostname(host, HOST_NAME_MAX); } - printf("verbose: %d, host: %s, plugin_dir: %s, spoolfetch_dir: %s\n", verbose, host, plugin_dir, spoolfetch_dir); + fprintf(stderr, "verbose: %d, host: %s, plugin_dir: %s, spoolfetch_dir: %s\n", verbose, host, plugin_dir, spoolfetch_dir); + printf("# munin node at %s\n", host); + while (fgets(line, LINE_MAX, stdin) != NULL) { + char* cmd; + char* arg; + + line[LINE_MAX-1] = '\0'; + + cmd = strtok(line, " \t\n"); + arg = strtok(line, " \t\n"); + + if (strlen(cmd) == 0) continue; + + if (strcmp(cmd, "version") == 0) { + } else if (strcmp(cmd, "nodes") == 0) { + } else if (strcmp(cmd, "quit") == 0) { + } else if (strcmp(cmd, "list") == 0) { + } else if (strcmp(cmd, "config") == 0) { + } else if (strcmp(cmd, "fetch") == 0) { + } else if (strcmp(cmd, "cap") == 0) { + } else if (strcmp(cmd, "spoolfetch") == 0) { + } + } return 0; }