mux/src/functions.h

Go to the documentation of this file.
00001 // functions.h -- declarations for functions & function processing.
00002 //
00003 // $Id: functions.h,v 1.19 2006/01/07 21:48:00 sdennis Exp $
00004 //
00005 
00006 #include "copyright.h"
00007 
00008 #ifndef __FUNCTIONS_H
00009 #define __FUNCTIONS_H
00010 
00011 typedef struct tagFun
00012 {
00013     char *name;     // function name
00014     void (*fun)(char *buff, char **bufc, dbref executor, dbref caller,
00015         dbref enactor, char *fargs[], int nfargs, char *cargs[],
00016         int ncargs);  // handler
00017     int maxArgsParsed;// Maximum number of arguments parsed.
00018     int minArgs;      // Minimum number of args needed or expected
00019     int maxArgs;      // Maximum number of arguments permitted
00020     int flags;        // Function flags
00021     int perms;        // Access to function
00022 } FUN;
00023 
00024 typedef struct ufun {
00025     char *name;     /* function name */
00026     dbref obj;      /* Object ID */
00027     int atr;        /* Attribute ID */
00028     int flags;      /* Function flags */
00029     int perms;      /* Access to function */
00030     struct ufun *next;  /* Next ufun in chain */
00031 } UFUN;
00032 
00033 #define FN_NOEVAL   2   // Don't evaluate args to function.
00034 #define FN_PRIV     4   // Perform user-def function as holding obj.
00035 #define FN_PRES     8   // Preseve r-regs before user-def functions.
00036 
00037 #define FN_LIST     1   // Corresponds to /list switch. -not- used in
00038                         // UFUN structure.
00039 
00040 void init_functab(void);
00041 void list_functable(dbref);
00042 extern UFUN *ufun_head;
00043 
00044 /* Special handling of separators. */
00045 
00046 #define print_sep(ps,b,p) safe_copy_buf((ps)->str,(ps)->n,(b),(p))
00047 
00048 #define MAX_SEP_LEN 50
00049 typedef struct
00050 {
00051     size_t n;
00052     char   str[MAX_SEP_LEN+1];
00053 } SEP;
00054 
00055 extern SEP sepSpace;
00056 
00057 // dflags in delim_check() accepts the following options.
00058 //
00059 #define DELIM_DFLT   0x0000  // Default processing.
00060 #define DELIM_EVAL   0x0001  // Evaluate delimiter.
00061 #define DELIM_NULL   0x0002  // Allow '@@'.
00062 #define DELIM_CRLF   0x0004  // Allow '%r'.
00063 #define DELIM_STRING 0x0008  // Multi-character.
00064 #define DELIM_INIT   0x0010  // The sep is initialized.
00065 
00066 bool delim_check
00067 (
00068     char *buff, char **bufc,
00069     dbref executor, dbref caller, dbref enactor,
00070     char *fargs[], int nfargs,
00071     char *cargs[], int ncargs,
00072     int sep_arg, SEP *sep, int dflags
00073 );
00074 
00075 void arr2list(char *arr[], int alen, char *list, char **bufc, SEP *psep);
00076 int list2arr(char *arr[], int maxlen, char *list, SEP *psep);
00077 char *trim_space_sep(char *str, SEP *psep);
00078 char *trim_space_sep_LEN(char *str, int nStr, SEP *psep, int *nTrim);
00079 char *next_token(char *str, SEP *psep);
00080 char *split_token(char **sp, SEP *psep);
00081 int countwords(char *str, SEP *psep);
00082 
00083 // This is the prototype for functions
00084 //
00085 #define FUNCTION(x) \
00086     void x(char *buff, char **bufc, dbref executor, dbref caller,     \
00087         dbref enactor, char *fargs[], int nfargs, char *cargs[],      \
00088         int ncargs)
00089 
00090 // This is for functions that take an optional delimiter character.
00091 //
00092 #define OPTIONAL_DELIM(iSep, Sep, dflags)                        \
00093     delim_check(buff, bufc, executor, caller, enactor,           \
00094         fargs, nfargs, cargs, ncargs, (iSep), &(Sep), (dflags))
00095 
00096 #define XFUNCTION(x) void x(char *buff, char **bufc, dbref executor,    \
00097  dbref caller, dbref enactor, char *fargs[], int nfargs, char *cargs[],        \
00098  int ncargs)
00099 
00100 // Interface for adding additional hardcode functions.
00101 //
00102 void function_add(FUN *fp);
00103 void functions_add(FUN funlist[]);
00104 
00105 // Function definitions from funceval.cpp
00106 //
00107 
00108 // In comsys.cpp
00109 XFUNCTION(fun_channels);
00110 XFUNCTION(fun_comalias);
00111 XFUNCTION(fun_comtitle);
00112 // In funceval.cpp
00113 XFUNCTION(fun_alphamax);
00114 XFUNCTION(fun_alphamin);
00115 XFUNCTION(fun_andflags);
00116 XFUNCTION(fun_ansi);
00117 XFUNCTION(fun_beep);
00118 XFUNCTION(fun_children);
00119 XFUNCTION(fun_columns);
00120 XFUNCTION(fun_cwho);
00121 XFUNCTION(fun_decrypt);
00122 XFUNCTION(fun_default);
00123 XFUNCTION(fun_die);
00124 XFUNCTION(fun_dumping);
00125 XFUNCTION(fun_edefault);
00126 XFUNCTION(fun_elements);
00127 XFUNCTION(fun_empty);
00128 XFUNCTION(fun_encrypt);
00129 XFUNCTION(fun_entrances);
00130 XFUNCTION(fun_fcount);
00131 XFUNCTION(fun_fdepth);
00132 XFUNCTION(fun_findable);
00133 XFUNCTION(fun_foreach);
00134 XFUNCTION(fun_grab);
00135 XFUNCTION(fun_graball);
00136 XFUNCTION(fun_grep);
00137 XFUNCTION(fun_grepi);
00138 XFUNCTION(fun_hasattr);
00139 XFUNCTION(fun_hasattrp);
00140 XFUNCTION(fun_hastype);
00141 XFUNCTION(fun_ifelse);
00142 XFUNCTION(fun_inzone);
00143 XFUNCTION(fun_isword);
00144 XFUNCTION(fun_items);
00145 XFUNCTION(fun_last);
00146 XFUNCTION(fun_lit);
00147 XFUNCTION(fun_localize);
00148 XFUNCTION(fun_lparent);
00149 XFUNCTION(fun_lrand);
00150 XFUNCTION(fun_lrooms);
00151 XFUNCTION(fun_lstack);
00152 XFUNCTION(fun_mail);
00153 XFUNCTION(fun_mailfrom);
00154 XFUNCTION(fun_matchall);
00155 XFUNCTION(fun_mix);
00156 XFUNCTION(fun_munge);
00157 XFUNCTION(fun_null);
00158 XFUNCTION(fun_objeval);
00159 XFUNCTION(fun_objmem);
00160 XFUNCTION(fun_orflags);
00161 XFUNCTION(fun_pack);
00162 XFUNCTION(fun_peek);
00163 XFUNCTION(fun_pickrand);
00164 XFUNCTION(fun_playmem);
00165 XFUNCTION(fun_pop);
00166 XFUNCTION(fun_ports);
00167 XFUNCTION(fun_push);
00168 XFUNCTION(fun_regmatch);
00169 XFUNCTION(fun_regmatchi);
00170 XFUNCTION(fun_regrab);
00171 XFUNCTION(fun_regraball);
00172 XFUNCTION(fun_regraballi);
00173 XFUNCTION(fun_regrabi);
00174 XFUNCTION(fun_scramble);
00175 XFUNCTION(fun_shuffle);
00176 XFUNCTION(fun_sortby);
00177 XFUNCTION(fun_squish);
00178 XFUNCTION(fun_strcat);
00179 XFUNCTION(fun_stripansi);
00180 XFUNCTION(fun_strtrunc);
00181 XFUNCTION(fun_table);
00182 XFUNCTION(fun_translate);
00183 XFUNCTION(fun_udefault);
00184 XFUNCTION(fun_unpack);
00185 XFUNCTION(fun_valid);
00186 XFUNCTION(fun_visible);
00187 XFUNCTION(fun_zfun);
00188 XFUNCTION(fun_zone);
00189 XFUNCTION(fun_zwho);
00190 #ifdef SIDE_EFFECT_FUNCTIONS
00191 XFUNCTION(fun_create);
00192 XFUNCTION(fun_emit);
00193 XFUNCTION(fun_link);
00194 XFUNCTION(fun_oemit);
00195 XFUNCTION(fun_pemit);
00196 XFUNCTION(fun_remit);
00197 XFUNCTION(fun_cemit);
00198 XFUNCTION(fun_set);
00199 XFUNCTION(fun_tel);
00200 XFUNCTION(fun_textfile);
00201 #endif
00202 // In netcommon.cpp
00203 XFUNCTION(fun_doing);
00204 XFUNCTION(fun_host);
00205 XFUNCTION(fun_motd);
00206 XFUNCTION(fun_poll);
00207 // In quota.cpp
00208 XFUNCTION(fun_hasquota);
00209 
00210 #endif // !__FUNCTIONS_H

Generated on Mon May 28 04:40:09 2007 for MUX by  doxygen 1.4.7