summaryrefslogtreecommitdiff
path: root/servicecmd/servicecmd.h
diff options
context:
space:
mode:
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 */
+