ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/commandtree.h
Revision: 1.3
Committed: Tue Aug 28 17:08:06 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +17 -15 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
3     * Copyright © 2005 William Pitcock, et al.
4 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
5 pippijn 1.1 *
6     * Commandlist manipulation routines.
7     *
8 pippijn 1.3 * $Id: commandtree.h,v 1.2 2007-07-21 01:29:07 pippijn Exp $
9 pippijn 1.1 */
10    
11     #ifndef COMMANDLIST_H
12     #define COMMANDLIST_H
13    
14     #include <vector>
15    
16 pippijn 1.3 #include <common/memory.h>
17 pippijn 1.1
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 pippijn 1.3 char const * const name;
42     char const * const file;
43 pippijn 1.1 void (*func) (sourceinfo_t *si);
44 pippijn 1.3
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 pippijn 1.1 };
50    
51     typedef std::vector<helpentry_t *> helpvec;
52    
53     /* commandtree.c */
54 pippijn 1.3 void operator << (cmdvec &commandlist, command_t const &cmd);
55 pippijn 1.1 void operator << (cmdvec &commandlist, command_t const *cmd[]);
56 pippijn 1.3 void operator >> (cmdvec &commandlist, command_t const &cmd);
57 pippijn 1.1 void operator >> (cmdvec &commandlist, command_t const *cmd[]);
58 pippijn 1.3 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 pippijn 1.1
62     /* help.c */
63 pippijn 1.3 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 pippijn 1.1
67     #endif