ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/commandtree.h
Revision: 1.5
Committed: Sat Sep 22 14:27:26 2007 UTC (16 years, 7 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +2 -2 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

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