aboutsummaryrefslogtreecommitdiff
path: root/servicecmd/servicecmd.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-02-25 14:33:19 +0100
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-24 17:04:20 +0100
commit9a88f7da453eadc72d8f333700dbd80777feecd1 (patch)
tree8a096e37123ece1d20bcb4d0ae8e064bdd39747a /servicecmd/servicecmd.h
Initial commit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'servicecmd/servicecmd.h')
-rw-r--r--servicecmd/servicecmd.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/servicecmd/servicecmd.h b/servicecmd/servicecmd.h
new file mode 100644
index 0000000..ce5e58f
--- /dev/null
+++ b/servicecmd/servicecmd.h
@@ -0,0 +1,36 @@
+#ifndef SERVICECMD_H
+#define SERVICECMD_H
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "util.h"
+
+typedef struct command_t {
+ struct command_t *next;
+
+ const char *cmd;
+ const char *usage;
+ const char *s_desc;
+ const char *l_desc;
+
+ int (*run_cmd)(int argc, char **argv);
+} command_t;
+
+extern command_t *commands;
+
+void usage(int status) NORETURN;
+
+#define REGISTER_COMMAND(cmd) \
+ static void __attribute__((constructor)) register_##cmd(void) \
+ { \
+ command_t *c = (command_t *)&cmd; \
+ \
+ c->next = commands; \
+ commands = c; \
+ }
+
+#endif /* SERVICECMD_H */
+