| 1 |
#ifndef __COMMAND_H |
|---|
| 2 |
#define __COMMAND_H |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
typedef uint8_t *switch_mask; |
|---|
| 6 |
extern int switch_bytes; |
|---|
| 7 |
#define SW_ALLOC() mush_calloc(switch_bytes, 1, "cmd.switch.vector"); |
|---|
| 8 |
#define SW_FREE(s) mush_free((s), "cmd.switch.vector"); |
|---|
| 9 |
#define SW_SET(m,n) (m[(n) >> 3] |= (1 << ((n) & 0x7))) |
|---|
| 10 |
#define SW_CLR(m,n) (m[(n) >> 3] &= ~(1 << ((n) & 0x7))) |
|---|
| 11 |
#define SW_ISSET(m,n) (m[(n) >> 3] & (1 << ((n) & 0x7))) |
|---|
| 12 |
bool SW_BY_NAME(switch_mask, const char *); |
|---|
| 13 |
#define SW_ZERO(m) memset(m, 0, switch_bytes) |
|---|
| 14 |
#define SW_COPY(new,old) memcpy((new), (old), switch_bytes) |
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
#define CMD_T_ROOM 0x80000000 |
|---|
| 18 |
#define CMD_T_THING 0x40000000 |
|---|
| 19 |
#define CMD_T_EXIT 0x20000000 |
|---|
| 20 |
#define CMD_T_PLAYER 0x10000000 |
|---|
| 21 |
#define CMD_T_ANY 0xF0000000 |
|---|
| 22 |
#define CMD_T_GOD 0x08000000 |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
#define CMD_T_SWITCHES 0x02000000 |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
#define CMD_T_DISABLED 0x01000000 |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
#define CMD_T_NOGAGGED 0x00800000 |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
#define CMD_T_NOGUEST 0x00400000 |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
#define CMD_T_NOFIXED 0x00200000 |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
#define CMD_T_LISTED 0x00080000 |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
#define CMD_T_INTERNAL 0x00040000 |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
#define CMD_T_LOGNAME 0x00020000 |
|---|
| 49 |
#define CMD_T_LOGARGS 0x00010000 |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
#define CMD_T_EQSPLIT 0x0001 |
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
#define CMD_T_ARGS 0x0010 |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
#define CMD_T_ARG_SPACE 0x0020 |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
#define CMD_T_NOPARSE 0x0040 |
|---|
| 62 |
|
|---|
| 63 |
#define CMD_T_LS_ARGS CMD_T_ARGS |
|---|
| 64 |
#define CMD_T_LS_SPACE CMD_T_ARG_SPACE |
|---|
| 65 |
#define CMD_T_LS_NOPARSE CMD_T_NOPARSE |
|---|
| 66 |
#define CMD_T_RS_ARGS CMD_T_ARGS<<4 |
|---|
| 67 |
#define CMD_T_RS_SPACE CMD_T_ARG_SPACE<<4 |
|---|
| 68 |
#define CMD_T_RS_NOPARSE CMD_T_NOPARSE<<4 |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
#define COMMAND(command_name) \ |
|---|
| 92 |
void command_name (COMMAND_INFO *cmd, dbref player, dbref cause, \ |
|---|
| 93 |
switch_mask sw,char *raw, const char *switches, char *args_raw, \ |
|---|
| 94 |
char *arg_left, char *args_left[MAX_ARG], \ |
|---|
| 95 |
char *arg_right, char *args_right[MAX_ARG]); \ |
|---|
| 96 |
void command_name(COMMAND_INFO *cmd __attribute__ ((__unused__)), \ |
|---|
| 97 |
dbref player __attribute__ ((__unused__)), \ |
|---|
| 98 |
dbref cause __attribute__ ((__unused__)), \ |
|---|
| 99 |
switch_mask sw __attribute__ ((__unused__)), \ |
|---|
| 100 |
char *raw __attribute__ ((__unused__)), \ |
|---|
| 101 |
const char *switches __attribute__ ((__unused__)), \ |
|---|
| 102 |
char *args_raw __attribute__ ((__unused__)), \ |
|---|
| 103 |
char *arg_left __attribute__ ((__unused__)), \ |
|---|
| 104 |
char *args_left[MAX_ARG] __attribute__ ((__unused__)), \ |
|---|
| 105 |
char *arg_right __attribute__ ((__unused__)), \ |
|---|
| 106 |
char *args_right[MAX_ARG] __attribute__ ((__unused__))) |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
#define COMMAND_PROTO(command_name) \ |
|---|
| 110 |
void command_name (COMMAND_INFO *cmd, dbref player, dbref cause, switch_mask sw,char *raw, const char *switches, char *args_raw, \ |
|---|
| 111 |
char *arg_left, char *args_left[MAX_ARG], \ |
|---|
| 112 |
char *arg_right, char *args_right[MAX_ARG]) |
|---|
| 113 |
|
|---|
| 114 |
typedef struct command_info COMMAND_INFO; |
|---|
| 115 |
typedef void (*command_func) (COMMAND_INFO *, dbref, dbref, switch_mask, char *, |
|---|
| 116 |
const char *, char *, char *, char *[MAX_ARG], |
|---|
| 117 |
char *, char *[MAX_ARG]); |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
struct hook_data { |
|---|
| 122 |
dbref obj; |
|---|
| 123 |
char *attrname; |
|---|
| 124 |
}; |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
struct command_info { |
|---|
| 130 |
const char *name; |
|---|
| 131 |
const char *restrict_message; |
|---|
| 132 |
command_func func; |
|---|
| 133 |
unsigned int type; |
|---|
| 134 |
object_flag_type flagmask; |
|---|
| 135 |
object_flag_type powers; |
|---|
| 136 |
|
|---|
| 137 |
union { |
|---|
| 138 |
switch_mask mask; |
|---|
| 139 |
const char *names; |
|---|
| 140 |
} sw; |
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
struct { |
|---|
| 144 |
struct hook_data before; |
|---|
| 145 |
struct hook_data after; |
|---|
| 146 |
struct hook_data ignore; |
|---|
| 147 |
struct hook_data override; |
|---|
| 148 |
} hooks; |
|---|
| 149 |
}; |
|---|
| 150 |
|
|---|
| 151 |
typedef struct command_list COMLIST; |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
struct command_list { |
|---|
| 158 |
const char *name; |
|---|
| 159 |
const char *switches; |
|---|
| 160 |
command_func func; |
|---|
| 161 |
unsigned int type; |
|---|
| 162 |
const char *flagstr; |
|---|
| 163 |
const char *powers; |
|---|
| 164 |
}; |
|---|
| 165 |
|
|---|
| 166 |
typedef struct switch_value SWITCH_VALUE; |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
struct switch_value { |
|---|
| 173 |
const char *name; |
|---|
| 174 |
int value; |
|---|
| 175 |
}; |
|---|
| 176 |
|
|---|
| 177 |
typedef struct com_sort_struc COMSORTSTRUC; |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
struct com_sort_struc { |
|---|
| 184 |
struct com_sort_struc *next; |
|---|
| 185 |
COMMAND_INFO *cmd; |
|---|
| 186 |
}; |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
struct command_perms_t { |
|---|
| 193 |
const char *name; |
|---|
| 194 |
unsigned int type; |
|---|
| 195 |
}; |
|---|
| 196 |
|
|---|
| 197 |
#define SWITCH_NONE 0 |
|---|
| 198 |
#include "switches.h" |
|---|
| 199 |
|
|---|
| 200 |
switch_mask switchmask(const char *switches); |
|---|
| 201 |
COMMAND_INFO *command_find(const char *name); |
|---|
| 202 |
COMMAND_INFO *command_find_exact(const char *name); |
|---|
| 203 |
COMMAND_INFO *command_add |
|---|
| 204 |
(const char *name, int type, const char *flagstr, const char *powers, |
|---|
| 205 |
const char *switchstr, command_func func); |
|---|
| 206 |
COMMAND_INFO *make_command |
|---|
| 207 |
(const char *name, int type, object_flag_type flagmask, |
|---|
| 208 |
object_flag_type powers, const char *sw, command_func func); |
|---|
| 209 |
COMMAND_INFO *command_modify(const char *name, int type, |
|---|
| 210 |
object_flag_type flagmask, |
|---|
| 211 |
object_flag_type powers, switch_mask sw, |
|---|
| 212 |
command_func func); |
|---|
| 213 |
void reserve_alias(const char *a); |
|---|
| 214 |
int alias_command(const char *command, const char *alias); |
|---|
| 215 |
void command_init_preconfig(void); |
|---|
| 216 |
void command_init_postconfig(void); |
|---|
| 217 |
void command_splitup |
|---|
| 218 |
(dbref player, dbref cause, char *from, char *to, char **args, |
|---|
| 219 |
COMMAND_INFO *cmd, int side); |
|---|
| 220 |
void command_argparse |
|---|
| 221 |
(dbref player, dbref cause, char **from, char *to, char **argv, |
|---|
| 222 |
COMMAND_INFO *cmd, int side, int forcenoparse); |
|---|
| 223 |
char *command_parse(dbref player, dbref cause, char *string, int fromport); |
|---|
| 224 |
void do_list_commands(dbref player, int lc); |
|---|
| 225 |
char *list_commands(void); |
|---|
| 226 |
int command_check_byname(dbref player, const char *name); |
|---|
| 227 |
int restrict_command(const char *name, const char *restriction); |
|---|
| 228 |
void reserve_aliases(void); |
|---|
| 229 |
void local_commands(void); |
|---|
| 230 |
void do_command_add(dbref player, char *name, int flags); |
|---|
| 231 |
void do_command_delete(dbref player, char *name); |
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
#endif |
|---|