Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

interp.h

Go to the documentation of this file.
00001 #ifndef ___interp_h___
00002 #define ___interp_h___
00003 
00012 /*
00013  * Copyright (c) 2001 James Hess
00014  * All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions
00018  * are met:
00019  * 1. Redistributions of source code must retain the above copyright
00020  *    notice, this list of conditions and the following disclaimer.
00021  * 2. Redistributions in binary form must reproduce the above copyright
00022  *    notice, this list of conditions and the following disclaimer in the
00023  *    documentation and/or other materials provided with the distribution.
00024  * 3. Neither the name of the authors nor the names of its contributors
00025  *    may be used to endorse or promote products derived from this software
00026  *    without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
00029  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
00032  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00034  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00035  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00036  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00037  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00038  * SUCH DAMAGE.
00039  */
00040 
00041 class SLogfile;
00042 extern SLogfile *nicklog, *chanlog, *operlog;
00043 
00044 /*
00045  *
00046  * These are short names to eliminate redundancy -- the primary reason
00047  * they are used is so that common names for parameters are enforced
00048  * for all command functions: IOW, no matter what command function you
00049  * are looking at, 'nick' is always the sender, for example.
00050  *
00051  * -Mysid
00052  */
00053 
00055 #define SCMD_DECL(func) cmd_return func(UserList *nick, char **args, int numargs)
00056 
00058 #define OCMD(func)  SCMD_DECL(func)
00059 
00061 #define NCMD(func)  SCMD_DECL(func)
00062 
00064 #define CCMD(func)  SCMD_DECL(func)
00065 
00067 #define MCMD(func)  SCMD_DECL(func)
00068 
00070 #define GCMD(func)  SCMD_DECL(func)
00071 
00073 #define ICMD(func)  SCMD_DECL(func)
00074 
00076 typedef enum {
00078      RET_OK,
00079 
00081      RET_OK_DB,
00082 
00084      RET_OK_NOCHANGE = RET_OK,
00085 
00087      RET_OK_DBCHANGE = RET_OK_DB,
00088 
00090      RET_SYNTAX,
00091 
00093      RET_NOPERM,
00094 
00096      RET_BADPW,
00097 
00100      RET_NOROOT,
00101 
00105      RET_EFAULT,
00106 
00108      RET_NOTARGET,
00109 
00112      RET_FAIL,
00113 
00116      RET_MEMORY,
00117 
00119      RET_INVALID,
00120 
00123      RET_KILLED,
00124 } cmd_return;
00125 
00126 /* OperServ Commands */
00127 OCMD(os_shutdown);
00128 OCMD(os_reset);
00129 OCMD(os_jupe);
00130 OCMD(os_uptime);
00131 OCMD(os_timers);
00132 OCMD(os_sync);
00133 OCMD(os_trigger);
00134 OCMD(os_match);
00135 OCMD(os_cloneset);
00136 OCMD(os_remsra);
00137 OCMD(os_tempakill);
00138 OCMD(os_clonerule);
00139 OCMD(os_grpop);
00140 OCMD(os_setop);
00141 OCMD(os_override);
00142 OCMD(os_strike);
00143 OCMD(os_nixghost);
00144 OCMD(os_help);
00145 OCMD(os_akill);
00146 OCMD(os_ignore);
00147 OCMD(os_help);
00148 OCMD(os_ahurt);
00149 OCMD(os_mode);
00150 OCMD(os_raw);
00151 OCMD(os_akill);
00152 OCMD(os_ignore);
00153 OCMD(os_heal);
00154 
00155 /* NickServ Commands */
00156 NCMD(ns_help);
00157 NCMD(ns_identify);
00158 NCMD(ns_cidentify);
00159 NCMD(ns_set);
00160 NCMD(ns_register);
00161 NCMD(ns_info);
00162 NCMD(ns_drop);
00163 NCMD(ns_addmask);
00164 NCMD(ns_access);
00165 NCMD(ns_acc);
00166 NCMD(ns_release);
00167 NCMD(ns_setflags);
00168 NCMD(ns_setopflags);
00169 NCMD(ns_bypass);
00170 NCMD(ns_banish);
00171 NCMD(ns_getpass);
00172 NCMD(ns_getrealpass);
00173 NCMD(ns_delete);
00174 NCMD(ns_list);
00175 NCMD(ns_ghost);
00176 NCMD(ns_recover);
00177 NCMD(ns_save);
00178 NCMD(ns_mark);
00179 NCMD(ns_vacation);
00180 NCMD(ms_save);
00181 NCMD(ns_logoff);
00182 NCMD(ns_verify);
00183 NCMD(ns_setemail);
00184 NCMD(ns_setemail);
00185 NCMD(ns_setpass);
00186 
00187 /* ChanServ Commands: */
00188 CCMD(cs_help);
00189 CCMD(cs_clean);
00190 CCMD(cs_clist);
00191 CCMD(cs_info);
00192 CCMD(cs_register);
00193 CCMD(cs_drop);
00194 CCMD(cs_delete);
00195 CCMD(cs_access);
00196 CCMD(cs_addop);
00197 CCMD(cs_addak);
00198 CCMD(cs_wipeak);
00199 CCMD(cs_wipeop);
00200 CCMD(cs_delak);
00201 CCMD(cs_listop);
00202 CCMD(cs_listak);
00203 CCMD(cs_identify);
00204 CCMD(cs_op);
00205 CCMD(cs_deop);
00206 CCMD(cs_modelock);
00207 CCMD(cs_restrict);
00208 CCMD(cs_topiclock);
00209 CCMD(cs_set);
00210 CCMD(cs_save);
00211 CCMD(cs_getpass);
00212 CCMD(cs_getrealpass);
00213 CCMD(cs_invite);
00214 CCMD(cs_unban);
00215 CCMD(cs_list);
00216 CCMD(cs_mdeop);
00217 CCMD(cs_mkick);
00218 CCMD(cs_whois);
00219 CCMD(cs_banish);
00220 CCMD(cs_whois);
00221 CCMD(cs_whois);
00222 CCMD(cs_banish);
00223 CCMD(cs_close);
00224 CCMD(cs_hold);
00225 CCMD(cs_mark);
00226 CCMD(cs_chanop);
00227 CCMD(cs_akick);
00228 CCMD(cs_log);
00229 CCMD(cs_setpass);
00230 CCMD(cs_setrealpass);
00231 CCMD(cs_trigger);
00232 CCMD(cs_dmod);
00233 
00234 /* GameServ Commands */
00235 GCMD(gs_roll);
00236 GCMD(gs_help);
00237 
00238 /* InfoServ Commands */
00239 ICMD(is_help);
00240 ICMD(is_sendinfo);
00241 ICMD(is_listnews);
00242 ICMD(is_postnews);
00243 ICMD(is_delete);
00244 ICMD(is_save);
00245 
00246 /* MemoServ Commands */
00247 MCMD(ms_help);
00248 MCMD(ms_read);
00249 MCMD(ms_send);
00250 MCMD(ms_sendsop);
00251 MCMD(ms_forward);
00252 MCMD(ms_nomemo);
00253 MCMD(ms_clean);
00254 MCMD(ms_delete);
00255 MCMD(ms_list);
00256 NCMD(ms_savememo);
00257 MCMD(ms_unsend);
00258 MCMD(ms_mblock);
00259 
00260 namespace interp { 
00261    namespace commands {
00269    typedef enum
00270    {
00271     SVC_CMD_NONE,
00272 
00273     // ChanServ Commands
00274     CS_HELP,        CS_INFO,    CS_ACCESS,  CS_CHANOP,
00275     CS_LISTOP,      CS_ADDOP,   CS_DELOP,   CS_AKICK,
00276     CS_LISTAK,      CS_ADDAK,   CS_DELAK,   CS_WIPEAK,
00277     CS_WIPEOP,
00278     CS_REGISTER,        CS_IDENTIFY,    CS_MDEOP,   CS_MKICK,
00279     CS_DELETE,      CS_DROP,    CS_OP,      CS_DEOP,
00280     CS_CLIST,       CS_BANISH,  CS_CLOSE,   CS_HOLD,
00281     CS_MARK,        CS_MLOCK,   CS_RESTRICT,    CS_TOPICLOCK,
00282     CS_SET,         CS_GETPASS, CS_GETREALPASS, CS_SAVE,
00283     CS_UNBAN,       CS_INVITE,  CS_LIST,    CS_WHOIS,
00284     CS_LOG,         CS_SETPASS, CS_CLEAN,   CS_TRIGGER,
00285     CS_DMOD,        CS_SETREALPASS,
00286     CSS_GETPASS_XFER,   CSE_IPC,
00287 
00288     // NickServ Commands
00289     NS_HELP,        NS_CIDENTIFY,   NS_IDENTIFY,    NS_XIDENTIFY,
00290     NS_LOGOUT,      NS_REGISTER,    NS_INFO,    NS_GHOST,
00291     NS_RECOVER,     NS_RELEASE, NS_SET,     NS_DROP,
00292     NS_ADDMASK,     NS_ACCESS,  NS_ACC,     NS_SETFLAG,
00293     NS_SETOP,       NS_MARK,    NS_BYPASS,  NS_BANISH,
00294     NS_GETPASS,     NS_GETREALPASS, NS_DELETE,  NS_LIST,
00295     NS_SAVE,        NS_LOGOFF,  NS_SAVEMEMO,    NS_SETPASS,
00296     NS_SETEMAIL,        NSS_GETPASS_XFER,   NSE_IPC,
00297 
00298     // MemoServ Commands
00299     MS_HELP,        MS_READ,    MS_LIST,    MS_SEND,
00300     MS_SENDSOP,     MS_DEL,     MS_DELETE,  MS_PURGE,
00301     MS_FORWARD,     MS_NOMEMO,  MS_UNSEND,  MS_MBLOCK,
00302     MS_SAVEMEMO,        MSE_IPC,
00303 
00304     // OperServ Commands
00305     OS_HELP,        OS_AKILL,   OS_TEMPAKILL,   OS_AHURT,
00306     OS_CLONERULE,       OS_IGNORE,  OS_MODE,    OS_RAW,
00307     OS_SHUTDOWN,        OS_RESET,   OS_REHASH,  OS_JUPE,
00308     OS_UPTIME,      OS_TIMERS,  OS_SYNC,    OS_TRIGGER,
00309     OS_MATCH,       OS_CLONESET,    OS_REMSRA,  OS_SETOP,
00310     OS_GRPOP,       OS_OVERRIDE,    OS_STRIKE,  OS_ALLOCSTAT,
00311     OS_HEAL,        OS_NIXGHOST,    OSE_IPC,
00312 
00313     // InfoServ Commands
00314     IS_HELP,        IS_READ,    IS_LIST,    IS_POST,
00315     IS_DEL,         IS_SAVE,
00316 
00317     // GameServ Commands
00318     GS_HELP,        GS_ROLL,
00319 
00320     // Services events
00321     NSE_EXPIRE,     CSE_EXPIRE
00322    } services_cmd_id; 
00323 
00324    typedef enum {
00325        CMD_NONE     = (0),
00326        CMD_AHURT    = (1 << 0),     
00327        CMD_REG      = (1 << 1),     
00328        CMD_MATCH    = (1 << 2),     
00329        CMD_IDENT    = (1 << 3),     
00330    } svc_cmd_flags;
00331 
00332    }
00333    namespace logging {
00334        typedef enum {
00335            LOG_NONE   = (0),        
00336            LOG_NO     = LOG_NONE,   
00337            LOG_ALWAYS = (1 << 0),   
00338            LOG_OK     = (1 << 1),   
00339            LOG_DB     = (1 << 2),   
00340            LOG_OK_WARN = (1 << 3),  
00341        } os_log_bits;
00342    }
00343 
00344    using namespace interp::commands;
00345    using namespace interp::logging;
00346 
00347    extern class cmd_name_table global_cmd_table[];
00348    const char *cmd_name(int);
00349 
00350    extern struct service_cmd_t {
00351        char  *cmd;
00352        cmd_return (*func)(UserList *, char **, int);
00353        u_int32_t root;
00354        os_log_bits log;
00355        u_int32_t flags;
00356        unsigned short int flood;
00357 
00358        services_cmd_id cmd_id;
00359    } operserv_commands[];
00360 
00361    struct cmd_name_table {
00362        const services_cmd_id cnum;
00363        const char *name;
00364        cmd_return (*func)(UserList *, char **, int);
00365    };
00366 
00367    class parser { 
00368      public:
00369      parser(const char *service, u_int32_t opflags, service_cmd_t *cmdlist, const char *incmd);
00370      cmd_return run(UserList *nick, char **args, int numargs);
00371 
00372      u_int32_t getCmdFlags() {
00373             if (!theCmd)
00374                 return 0;
00375             return theCmd->flags;
00376      }
00377 
00378      private:
00379         u_int32_t      theOpflags;
00380         service_cmd_t *theCmd;
00381         const char    *theService;
00382    };
00383 }
00384 
00385 using namespace interp::commands;
00386 using namespace interp::logging;
00387 #endif

Generated at Sat Oct 25 20:56:08 2003 for Services using Doxygen.
Services Copyr. 1996-2001 Chip Norkus, Max Byrd, Greg Poma, Michael Graff, James Hess, Dafydd James. All rights reserved See LICENSE for licensing information.