File: command.h

package info (click to toggle)
tinymux 2.10.1.14-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 6,212 kB
  • ctags: 8,535
  • sloc: cpp: 111,587; sh: 5,867; ansic: 141; makefile: 139
file content (320 lines) | stat: -rw-r--r-- 15,199 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*! \file command.h
 * \brief declarations used by the command processor.
 *
 * $Id: command.h 5886 2017-01-01 13:04:21Z sdennis $
 *
 */

#ifndef __COMMAND_H
#define __COMMAND_H

#define CMD_NO_ARG(name)       extern void name(dbref executor, dbref caller, dbref enactor, int eval, int key)
#define CMD_ONE_ARG(name)      extern void name(dbref executor, dbref caller, dbref enactor, int eval, int key, UTF8 *arg1, const UTF8 *cargs[], int ncargs)
#define CMD_TWO_ARG(name)      extern void name(dbref executor, dbref caller, dbref enactor, int eval, int key, int nargs, UTF8 *arg1, UTF8 *arg2, const UTF8 *cargs[], int ncargs)
#define CMD_TWO_ARG_ARGV(name) extern void name(dbref executor, dbref caller, dbref enactor, int eval, int key, UTF8 *arg1, UTF8 *args[], int nargs, const UTF8 *cargs[], int ncargs)

/* Command function handlers */
/* from comsys.cpp */

CMD_TWO_ARG(do_cemit);          /* channel emit */
CMD_TWO_ARG(do_chboot);         /* channel boot */
CMD_TWO_ARG(do_editchannel);    /* edit a channel */
CMD_ONE_ARG(do_checkchannel);   /* check a channel */
CMD_ONE_ARG(do_createchannel);  /* create a channel */
CMD_ONE_ARG(do_destroychannel); /* destroy a channel */
CMD_TWO_ARG(do_edituser);       /* edit a channel user */
CMD_ONE_ARG(do_chanlist);       /* gives a channel listing */
CMD_TWO_ARG(do_chopen);         /* opens a channel */
CMD_ONE_ARG(do_channelwho);     /* who's on a channel */
CMD_TWO_ARG(do_addcom);         /* adds a comalias */
CMD_ONE_ARG(do_allcom);         /* on, off, who, all aliases */
CMD_ONE_ARG(do_comlist);        /* channel who by alias */
CMD_TWO_ARG(do_comtitle);       /* sets a title on a channel */
//CMD_NO_ARG(do_clearcom);      /* clears all comaliases */
CMD_ONE_ARG(do_delcom);         /* deletes a comalias */

/* from mail.cpp */

CMD_TWO_ARG(do_mail);           /* mail command */
CMD_TWO_ARG(do_folder);         /* mail folder commands */
CMD_TWO_ARG(do_malias);         /* mail alias command */
CMD_ONE_ARG(do_prepend);
CMD_ONE_ARG(do_postpend);

CMD_ONE_ARG(do_apply_marked);   /* Apply command to marked objects */
CMD_TWO_ARG(do_admin);          /* Change config parameters */
CMD_TWO_ARG(do_alias);          /* Change the alias of something */
CMD_TWO_ARG(do_attribute);      /* Manage user-named attributes */
CMD_ONE_ARG(do_boot);           /* Force-disconnect a player */
CMD_TWO_ARG(do_chown);          /* Change object or attribute owner */
CMD_TWO_ARG(do_chownall);       /* Give away all of someone's objs */
CMD_TWO_ARG(do_chzone);         /* Change an object's zone. */
CMD_TWO_ARG(do_clone);          /* Create a copy of an object */
CMD_NO_ARG(do_comment);         /* Ignore argument and do nothing */
CMD_TWO_ARG_ARGV(do_cpattr);    /* Copy attributes */
CMD_TWO_ARG(do_create);         /* Create a new object */
CMD_ONE_ARG(do_cut);            /* Truncate contents or exits list */
CMD_NO_ARG(do_dbck);            /* Consistency check */
CMD_TWO_ARG(do_decomp);         /* Reproduce commands to recreate obj */
CMD_ONE_ARG(do_destroy);        /* Destroy an object */
CMD_TWO_ARG_ARGV(do_dig);       /* Dig a new room */
CMD_ONE_ARG(do_doing);          /* Set doing string in WHO report */
CMD_TWO_ARG(do_dolist);         /* Iterate command on list members */
CMD_ONE_ARG(do_drop);           /* Drop an object */
CMD_NO_ARG(do_dump);            /* Dump the database */
CMD_TWO_ARG_ARGV(do_edit);      /* Edit one or more attributes */
CMD_ONE_ARG(do_enter);          /* Enter an object */
CMD_ONE_ARG(do_entrances);      /* List exits and links to loc */
CMD_ONE_ARG(do_eval);           /* Evaluate argument and do nothing else */
CMD_ONE_ARG(do_examine);        /* Examine an object */
CMD_ONE_ARG(do_find);           /* Search for name in database */
CMD_TWO_ARG(do_fixdb);          /* Database repair functions */
CMD_TWO_ARG(do_force);          /* Force someone to do something */
CMD_ONE_ARG(do_force_prefixed); /* #<num> <cmd> variant of FORCE */
CMD_TWO_ARG(do_forwardlist);    // Set a forwardlist on something
CMD_TWO_ARG(do_function);       /* Make user-def global function */
CMD_ONE_ARG(do_get);            /* Get an object */
CMD_TWO_ARG(do_give);           /* Give something away */
CMD_ONE_ARG(do_global);         /* Enable/disable global flags */
CMD_ONE_ARG(do_halt);           /* Remove commands from the queue */
CMD_ONE_ARG(do_help);           /* Print info from help files */
CMD_TWO_ARG_ARGV(do_if);        // Execute cmd based on truth of expression
CMD_NO_ARG(do_inventory);       /* Print what I am carrying */
CMD_TWO_ARG(do_prog);           /* Interactive input */
CMD_ONE_ARG(do_quitprog);       /* Quits @prog */
CMD_TWO_ARG(do_kill);           /* Kill something */
CMD_ONE_ARG(do_last);           /* Get recent login info */
CMD_NO_ARG(do_leave);           /* Leave the current object */
CMD_TWO_ARG(do_link);           /* Set home, dropto, or dest */
CMD_ONE_ARG(do_list);           /* List contents of internal tables */
CMD_ONE_ARG(do_list_file);      /* List contents of message files */
CMD_TWO_ARG(do_lock);           /* Set a lock on an object */
CMD_TWO_ARG(do_log);            /* Extra logging routine */
CMD_ONE_ARG(do_look);           /* Look here or at something */
CMD_NO_ARG(do_markall);         /* Mark or unmark all objects */
CMD_ONE_ARG(do_motd);           /* Set/list MOTD messages */
CMD_ONE_ARG(do_move);           /* Move about using exits */
CMD_TWO_ARG_ARGV(do_mvattr);    /* Move attributes on object */
CMD_TWO_ARG(do_name);           /* Change the name of something */
CMD_TWO_ARG(do_newpassword);    /* Change passwords */
CMD_TWO_ARG(do_notify);         /* Notify or drain semaphore */
CMD_TWO_ARG_ARGV(do_open);      /* Open an exit */
CMD_TWO_ARG(do_page);           /* Send message to faraway player */
CMD_TWO_ARG(do_parent);         /* Set parent field */
CMD_TWO_ARG(do_password);       /* Change my password */
CMD_TWO_ARG(do_pcreate);        /* Create new characters */
CMD_TWO_ARG(do_pemit);          /* Messages to specific player */
CMD_ONE_ARG(do_poor);           /* Reduce wealth of all players */
CMD_TWO_ARG(do_power);          /* Sets powers */
CMD_ONE_ARG(do_ps);             /* List contents of queue */
CMD_ONE_ARG(do_queue);          /* Force queue processing */
CMD_TWO_ARG(do_quota);          /* Set or display quotas */
CMD_NO_ARG(do_readcache);       /* Reread text file cache */
CMD_NO_ARG(do_restart);         /* Restart the game. */
CMD_NO_ARG(do_backup);          /* Backup the database and restart */
CMD_TWO_ARG(do_reference);
CMD_ONE_ARG(do_say);            /* Messages to all */
CMD_NO_ARG(do_score);           /* Display my wealth */
CMD_ONE_ARG(do_search);         /* Search for objs matching criteria */
CMD_TWO_ARG(do_set);            /* Set flags or attributes */
CMD_TWO_ARG(do_setattr);        /* Set object attribute */
CMD_TWO_ARG(do_setvattr);       /* Set variable attribute */
CMD_ONE_ARG(do_shout);          /* Messages to all */
CMD_ONE_ARG(do_shutdown);       /* Stop the game */
CMD_ONE_ARG(do_stats);          /* Display object type breakdown */
CMD_ONE_ARG(do_sweep);          /* Check for listeners */
CMD_TWO_ARG_ARGV(do_switch);    /* Execute cmd based on match */
CMD_TWO_ARG(do_teleport);       /* Teleport elsewhere */
CMD_ONE_ARG(do_think);          /* Think command */
CMD_NO_ARG(do_timecheck);       /* Check time used by objects */
CMD_ONE_ARG(do_timewarp);       /* Warp various timers */
CMD_TWO_ARG(do_toad);           /* Turn a tinyjerk into a tinytoad */
CMD_TWO_ARG_ARGV(do_trigger);   /* Trigger an attribute */
CMD_ONE_ARG(do_unlock);         /* Remove a lock from an object */
CMD_ONE_ARG(do_unlink);         /* Unlink exit or remove dropto */
CMD_ONE_ARG(do_use);            /* Use object */
CMD_NO_ARG(do_version);         /* List MUX version number */
CMD_NO_ARG(do_report);          /* Do player/game statistics report */
CMD_TWO_ARG_ARGV(do_verb);      /* Execute a user-created verb */
CMD_TWO_ARG(do_wait);           /* Perform command after a wait */
CMD_TWO_ARG(do_query);          /* Generic external queries (e.g., SQL) */
CMD_ONE_ARG(do_wipe);           /* Mass-remove attrs from obj */
CMD_NO_ARG(do_dbclean);         /* Remove stale vattr entries */
CMD_TWO_ARG(do_addcommand);     /* Add or replace a global command */
CMD_TWO_ARG(do_delcommand);     /* Delete an added global command */
CMD_ONE_ARG(do_listcommands);   /* List added global commands */
CMD_TWO_ARG(do_assert);         /* Stop evaluating an action list */
CMD_TWO_ARG(do_break);          /* Stop evaluating an action list */
#ifdef REALITY_LVLS
CMD_TWO_ARG(do_rxlevel);        /* set Rx Levels */
CMD_TWO_ARG(do_txlevel);        /* set Tx Levels */
#endif
CMD_TWO_ARG_ARGV(do_icmd);      // Disable commands on a player or room
CMD_ONE_ARG(do_hook);           // Set additional operations for a command
CMD_TWO_ARG(do_flag);           // Rename a flag or remove flag aliases
CMD_ONE_ARG(do_train);          // Display code to room, then execute
CMD_TWO_ARG(do_moniker);        // Set accented, colorized name of object
CMD_TWO_ARG(do_plusemail);

typedef struct
{
    const UTF8 *cmdname;
    NAMETAB *switches;
    unsigned int perms;
    int     extra;
    int     callseq;
    int     flags;
    void    (*handler)(dbref executor, dbref caller, dbref enactor, int eval, int key);
} CMDENT_NO_ARG;

typedef struct
{
    const UTF8 *cmdname;
    NAMETAB *switches;
    unsigned int perms;
    int     extra;
    int     callseq;
    int     flags;
    void    (*handler)(dbref executor, dbref caller, dbref enactor, int eval, int key, UTF8 *arg1, const UTF8 *cargs[], int ncargs);
} CMDENT_ONE_ARG;

typedef struct
{
    const UTF8 *cmdname;
    NAMETAB *switches;
    unsigned int perms;
    int     extra;
    int     callseq;
    int     flags;
    void    (*handler)(dbref executor, dbref caller, dbref enactor, int eval, int key, int nargs, UTF8 *arg1, UTF8 *arg2, const UTF8 *cargs[], int ncargs);
} CMDENT_TWO_ARG;

typedef struct
{
    const UTF8 *cmdname;
    NAMETAB *switches;
    unsigned int perms;
    int     extra;
    int     callseq;
    int     flags;
    void    (*handler)(dbref executor, dbref caller, dbref enactor, int eval, int key, UTF8 *arg1, UTF8 *args[], int nargs, const UTF8 *cargs[], int ncargs);
} CMDENT_TWO_ARG_ARGV;

typedef struct addedentry ADDENT;
struct addedentry
{
    dbref   thing;
    int     atr;
    UTF8    *name;
    struct addedentry *next;
};

typedef struct
{
    UTF8 *cmdname;
    NAMETAB *switches;
    int     perms;
    int     extra;
    int     callseq;
    int     flags;
    union
    {
        void (*handler)(void);
        ADDENT *addent;
    };
} CMDENT;

void commands_no_arg_add(CMDENT_NO_ARG cmdent[]);
void commands_one_arg_add(CMDENT_ONE_ARG cmdent[]);
void commands_one_arg_cmdarg_add(CMDENT_ONE_ARG cmdent[]);
void commands_two_arg_add(CMDENT_TWO_ARG cmdent[]);
void commands_two_arg_argv_add(CMDENT_TWO_ARG_ARGV cmdent[]);
void init_cmdtab();
void finish_cmdtab();

extern NAMETAB access_nametab[];
extern NAMETAB attraccess_nametab[];
extern NAMETAB indiv_attraccess_nametab[];
extern NAMETAB lock_sw[];
extern NAMETAB logoptions_nametab[];
extern NAMETAB logdata_nametab[];
extern NAMETAB list_names[];
extern NAMETAB allow_charset_nametab[];

/* Command handler call conventions */

#define CS_NO_ARGS    0x0000    /* No arguments */
#define CS_ONE_ARG    0x0001    /* One argument */
#define CS_TWO_ARG    0x0002    /* Two arguments */
#define CS_NARG_MASK  0x0003    /* Argument count mask */
#define CS_ARGV       0x0004    /* ARG2 is in ARGV form */
#define CS_INTERP     0x0010    /* Interpret ARG2 if 2 args, ARG1 if 1 */
#define CS_NOINTERP   0x0020    /* Never interp ARG2 if 2 or ARG1 if 1 */
#define CS_CAUSE      0x0040    /* Pass cause to old command handler */
#define CS_UNPARSE    0x0080    /* Pass unparsed cmd to old-style handler */
#define CS_CMDARG     0x0100    /* Pass in given command args */
#define CS_STRIP      0x0200    /* Strip braces even when not interpreting */
#define CS_STRIP_AROUND 0x0400  /* Strip braces around entire string only */
#define CS_ADDED      0x0800    /* Command has been added by @addcommand */
#define CS_LEADIN     0x1000    /* Command is a single-letter lead-in */
#define CS_NOSQUISH   0x4000    // Do not space-compress.

/* Command permission flags */

#define CA_PUBLIC     0x00000000  /* No access restrictions */
#define CA_GOD        0x00000001  /* GOD only... */
#define CA_WIZARD     0x00000002  /* Wizards only */
#define CA_BUILDER    0x00000004  /* Builders only */
#define CA_IMMORTAL   0x00000008  /* Immortals only */
#define CA_STAFF      0x00000010  /* Must have STAFF flag */
#define CA_HEAD       0x00000020  /* Must have HEAD flag */
//#define CA_SQL_OK     0x00000040  /* Must have SQL_OK power */
#define CA_ADMIN      0x00000080  /* Wizard or royal */
#define CA_ROBOT      0x00000100  /* Robots only */
#define CA_ANNOUNCE   0x00000200  /* Announce Power */
#define CA_UNINS      0x00000400  /* Uninspected players ONLY */
#define CA_MUSTBE_MASK  (CA_GOD|CA_WIZARD|CA_BUILDER|CA_IMMORTAL|CA_STAFF|CA_HEAD|CA_ADMIN|CA_ROBOT|CA_ANNOUNCE|CA_UNINS)

#define CA_NO_HAVEN   0x00001000  /* Not by HAVEN players */
#define CA_NO_ROBOT   0x00002000  /* Not by ROBOT players */
#define CA_NO_SLAVE   0x00004000  /* Not by SLAVE players */
#define CA_NO_SUSPECT 0x00008000  /* Not by SUSPECT players */
#define CA_NO_GUEST   0x00010000  /* Not by GUEST players */
#define CA_NO_UNINS   0x00020000  /* Not by UNINSPECTED players */
#if defined(FIRANMUX)
#define CA_NO_IMMOBILE   0x00040000    /* Not by IMMOBILE players */
#define CA_NO_RESTRICTED 0x00080000    /* Not by RESTRICTED players */
#define CA_CANTBE_MASK (CA_NO_HAVEN|CA_NO_ROBOT|CA_NO_SLAVE|CA_NO_SUSPECT|CA_NO_GUEST|CA_NO_UNINS|CA_NO_IMMOBILE|CA_NO_RESTRICTED)
#else
#define CA_CANTBE_MASK (CA_NO_HAVEN|CA_NO_ROBOT|CA_NO_SLAVE|CA_NO_SUSPECT|CA_NO_GUEST|CA_NO_UNINS)
#endif // FIRANMUX

#define CA_MARKER0    0x00002000
#define CA_MARKER1    0x00004000
#define CA_MARKER2    0x00008000
#define CA_MARKER3    0x00010000
#define CA_MARKER4    0x00020000
#define CA_MARKER5    0x00040000
#define CA_MARKER6    0x00080000
#define CA_MARKER7    0x00100000
#define CA_MARKER8    0x00200000
#define CA_MARKER9    0x00400000

#define CA_GBL_BUILD  0x00800000  /* Requires the global BUILDING flag */
#define CA_GBL_INTERP 0x01000000  /* Requires the global INTERP flag */
#define CA_DISABLED   0x02000000  /* Command completely disabled */
#define CA_STATIC     0x04000000  /* Cannot be changed at runtime */
#define CA_NO_DECOMP  0x08000000  /* Don't include in @decompile */

#define CA_LOCATION   0x10000000  /* Invoker must have location */
#define CA_CONTENTS   0x20000000  /* Invoker must have contents */
#define CA_PLAYER     0x40000000  /* Invoker must be a player */
#define CF_DARK       0x80000000  /* Command doesn't show up in list */

#define SW_MULTIPLE   0x80000000  /* This sw may be spec'd w/others */
#define SW_GOT_UNIQUE 0x40000000  /* Already have a unique option */
#define SW_NOEVAL     0x20000000  /* Don't parse args before calling */
                                  /* handler (typically via a switch */
                                  /* alias) */

#endif // !__COMMAND_H