-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandtable.h
61 lines (40 loc) · 953 Bytes
/
commandtable.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _COMMANDTABLE_H_
#define _COMMANDTABLE_H_
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
typedef union
{
int i;
float f;
char c;
char *s;
void *v;
} cmd_arg;
typedef struct
{
char *name;
int (*func)(cmd_arg *args);
char *args;
char *doc;
} cmd;
typedef struct cmd_table_entry_p
{
char *key;
cmd *value;
struct cmd_table_entry_p *next;
} cmd_table_entry;
typedef struct
{
int size;
cmd_table_entry **table;
} cmd_table;
cmd_table *cmd_table_create (const int size);
int cmd_table_init (cmd_table *commands, const int size);
cmd_table *cmd_table_free (cmd_table *commands);
int cmd_table_hash (const cmd_table *commands, const char *key);
cmd_table_entry *cmd_table_pair (char *key, cmd *value);
int cmd_table_set (const cmd_table *commands, char *key, cmd *value);
cmd *cmd_table_get (const cmd_table *commands, const char *key);
#endif