ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/commandtree.h
(Generate patch)

Comparing ermyth/include/commandtree.h (file contents):
Revision 1.2 by pippijn, Sat Jul 21 01:29:07 2007 UTC vs.
Revision 1.3 by pippijn, Tue Aug 28 17:08:06 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines