| 1 |
pippijn |
1.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/LICENSE. |
| 5 |
|
|
* |
| 6 |
|
|
* Commandlist manipulation routines. |
| 7 |
|
|
* |
| 8 |
|
|
* $Id: commandtree.h,v 1.1 2007-07-11 11:04:40 pippijn Exp $ |
| 9 |
|
|
*/ |
| 10 |
|
|
|
| 11 |
|
|
#ifndef COMMANDLIST_H |
| 12 |
|
|
#define COMMANDLIST_H |
| 13 |
|
|
|
| 14 |
|
|
#include <vector> |
| 15 |
|
|
|
| 16 |
|
|
#include <common/util.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 |
|
|
E command_t null_cmd; |
| 30 |
|
|
|
| 31 |
|
|
struct cmdvec : std::vector<command_t const *> |
| 32 |
|
|
{ |
| 33 |
|
|
typedef cmdvec::iterator iterator; |
| 34 |
|
|
|
| 35 |
|
|
command_t const *find (char const *command); |
| 36 |
|
|
}; |
| 37 |
|
|
|
| 38 |
|
|
E cmdvec null_cmdvec; |
| 39 |
|
|
|
| 40 |
|
|
/* struct for help command hash table */ |
| 41 |
|
|
struct helpentry_t : zero_initialised |
| 42 |
|
|
{ |
| 43 |
|
|
char *name; |
| 44 |
|
|
char const * const access; |
| 45 |
|
|
char *file; |
| 46 |
|
|
void (*func) (sourceinfo_t *si); |
| 47 |
|
|
}; |
| 48 |
|
|
|
| 49 |
|
|
typedef std::vector<helpentry_t *> helpvec; |
| 50 |
|
|
|
| 51 |
|
|
/* commandtree.c */ |
| 52 |
|
|
void operator << (cmdvec *commandlist, command_t const &cmd); |
| 53 |
|
|
void operator << (cmdvec &commandlist, command_t const *cmd[]); |
| 54 |
|
|
void operator >> (cmdvec *commandlist, command_t const &cmd); |
| 55 |
|
|
void operator >> (cmdvec &commandlist, command_t const *cmd[]); |
| 56 |
|
|
E void command_exec_split (service_t *svs, sourceinfo_t *si, char *cmd, char *text, cmdvec *commandlist); |
| 57 |
|
|
E void command_help (sourceinfo_t *si, cmdvec *commandlist); |
| 58 |
|
|
E void command_help_short (sourceinfo_t *si, cmdvec *commandlist, char *maincmds); |
| 59 |
|
|
|
| 60 |
|
|
/* help.c */ |
| 61 |
|
|
E void help_display (sourceinfo_t *si, char *command, helpvec *list); |
| 62 |
|
|
E void help_addentry (helpvec *list, char *topic, char *fname, void (*func) (sourceinfo_t *si)); |
| 63 |
|
|
E void help_delentry (helpvec *list, char *name); |
| 64 |
|
|
|
| 65 |
|
|
#endif |