/** * commandtree.h: Commandlist manipulation routines. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Copyright © 2005 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: commandtree.h,v 1.5 2007/09/22 14:27:26 pippijn Exp $ */ #ifndef COMMANDLIST_H #define COMMANDLIST_H #include #include struct command_t { char const * const name; char const * const desc; char const *access; const int maxparc; void (*cmd) (sourceinfo_t *, const int parc, char *parv[]); void exec (service_t *svs, sourceinfo_t *si, int parc, char *parv[]) const; }; struct cmdvec : std::vector { typedef cmdvec::iterator iterator; command_t const *find (char const *command); }; E cmdvec null_cmdvec; /* struct for help command hash table */ struct helpentry_t : zero_initialised { char const * const name; char const * const file; void (*func) (sourceinfo_t *si); helpentry_t (char const * const cmdname, char const * const filename, void (*function) (sourceinfo_t *si)) : name (cmdname), file (filename ? filename : 0), func (function ? function : 0) { } }; typedef std::vector helpvec; /* commandtree.c */ void operator << (cmdvec &commandlist, command_t const &cmd); void operator << (cmdvec &commandlist, command_t const *cmd[]); void operator >> (cmdvec &commandlist, command_t const &cmd); void operator >> (cmdvec &commandlist, command_t const *cmd[]); E void command_exec_split (service_t *svs, sourceinfo_t *si, char const * const cmd, char const * const text, cmdvec &commandlist); E void command_help (sourceinfo_t *si, cmdvec &commandlist); E void command_help_short (sourceinfo_t *si, cmdvec &commandlist, char const * const maincmds); /* help.c */ E void help_display (sourceinfo_t *si, char const * const command, helpvec &list); E void help_addentry (helpvec &list, char const * const topic, char const * const fname, void (*func) (sourceinfo_t *si)); E void help_delentry (helpvec &list, char const * const name); #endif