summaryrefslogtreecommitdiff
path: root/servicecmd/servicecmd.h
blob: ce5e58fde8b75909c494e00a02acacd9d74538ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 */