1 |
/* |
2 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
3 |
* Copyright © 2005 William Pitcock, et al. |
4 |
* Rights to this code are as documented in doc/pod/license.pod. |
5 |
* |
6 |
* Commandlist manipulation routines. |
7 |
* |
8 |
* $Id: commandtree.h,v 1.2 2007-07-21 01:29:07 pippijn Exp $ |
9 |
*/ |
10 |
|
11 |
#ifndef COMMANDLIST_H |
12 |
#define COMMANDLIST_H |
13 |
|
14 |
#include <vector> |
15 |
|
16 |
#include <common/memory.h> |
17 |
|
18 |
struct command_t |
19 |
{ |
20 |
char const * const name; |
21 |
char const * const desc; |
22 |
char const *access; |
23 |
const int maxparc; |
24 |
void (*cmd) (sourceinfo_t *, const int parc, char *parv[]); |
25 |
|
26 |
void exec (service_t *svs, sourceinfo_t *si, int parc, char *parv[]) const; |
27 |
}; |
28 |
|
29 |
struct cmdvec : std::vector<command_t const *> |
30 |
{ |
31 |
typedef cmdvec::iterator iterator; |
32 |
|
33 |
command_t const *find (char const *command); |
34 |
}; |
35 |
|
36 |
E cmdvec null_cmdvec; |
37 |
|
38 |
/* struct for help command hash table */ |
39 |
struct helpentry_t : zero_initialised |
40 |
{ |
41 |
char const * const name; |
42 |
char const * const file; |
43 |
void (*func) (sourceinfo_t *si); |
44 |
|
45 |
helpentry_t (char const * const cmdname, char const * const filename, void (*function) (sourceinfo_t *si)) |
46 |
: name (cmdname), file (filename ? filename : 0), func (function ? function : 0) |
47 |
{ |
48 |
} |
49 |
}; |
50 |
|
51 |
typedef std::vector<helpentry_t *> helpvec; |
52 |
|
53 |
/* commandtree.c */ |
54 |
void operator << (cmdvec &commandlist, command_t const &cmd); |
55 |
void operator << (cmdvec &commandlist, command_t const *cmd[]); |
56 |
void operator >> (cmdvec &commandlist, command_t const &cmd); |
57 |
void operator >> (cmdvec &commandlist, command_t const *cmd[]); |
58 |
E void command_exec_split (service_t *svs, sourceinfo_t *si, char const * const cmd, char const * const text, cmdvec &commandlist); |
59 |
E void command_help (sourceinfo_t *si, cmdvec &commandlist); |
60 |
E void command_help_short (sourceinfo_t *si, cmdvec &commandlist, char const * const maincmds); |
61 |
|
62 |
/* help.c */ |
63 |
E void help_display (sourceinfo_t *si, char const * const command, helpvec &list); |
64 |
E void help_addentry (helpvec &list, char const * const topic, char const * const fname, void (*func) (sourceinfo_t *si)); |
65 |
E void help_delentry (helpvec &list, char const * const name); |
66 |
|
67 |
#endif |