MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | #ifndef __TOOL_H__ |
| 2 | #define __TOOL_H__ |
| 3 | |
| 4 | /* |
| 5 | * MGtool-1.3 |
| 6 | * File: tool.h |
| 7 | * Maintainer: Kirk@MorgenGrauen |
| 8 | */ |
| 9 | |
| 10 | /*------------------------------------------*/ |
| 11 | /* the original Xtool is copyrighted by Hyp */ |
| 12 | /*------------------------------------------*/ |
| 13 | |
| 14 | #ifndef MASTER |
| 15 | #define MASTER __MASTER_OBJECT__ |
| 16 | #endif |
| 17 | |
| 18 | #define VOID "/room/void" |
| 19 | |
| 20 | #define NULL (0) |
| 21 | #define FALSE (0) |
| 22 | #define TRUE (1) |
| 23 | #define ERROR (-1) |
| 24 | #define PREV previous_object() |
| 25 | #define TP efun::this_player() |
| 26 | #define RTP efun::this_interactive() |
| 27 | #define TOOL_NAME "MGtool" |
| 28 | #define TOOL_VERSION "1.3.3" |
| 29 | #define TOOL_TITLE TOOL_NAME+" v"+TOOL_VERSION |
| 30 | #define TOOL_INTERNAL "1.3.3-10.07.97" |
| 31 | |
| 32 | #define TOOL_PATH "/obj/tools/MGtool" |
| 33 | |
| 34 | #define TOOL_MANPAGE TOOL_PATH+"/tool.doc" |
| 35 | #define TOOL_NEWS TOOL_PATH+"/tool.news" |
| 36 | #define TOOL_LOG "/log/xtool" |
| 37 | #define XPROF_MACRO TOOL_PATH+"/prof.h" |
| 38 | #define LAG_O_DAEMON "/p/daemon/lag-o-daemon" |
| 39 | |
| 40 | #define TOOL_LEVEL (40) |
| 41 | |
| 42 | #define MORE_LINES (20) |
| 43 | #define MAX_HISTORY (25) |
| 44 | #define MAX_RECURSION (6) |
| 45 | #define TRACE_LEVEL (1|2|4|8) |
| 46 | #define AUTOLOAD_ARGS ({TOOL_INTERNAL, modi, morelines}) |
| 47 | #define EXEC_LINES (10) |
| 48 | #define EXEC_TIME (1) |
| 49 | |
| 50 | #define IA(x) interactive(x) |
| 51 | #define ENV(x) environment(x) |
| 52 | #define LOWER(x) lower_case(x) |
| 53 | #define NAME(x) ((string)x->query_name()) |
| 54 | #define CNAME(x) CAP((string)NAME(x)) |
| 55 | |
| 56 | #define RNAME(x) getuid(x) |
| 57 | #define CRNAME(x) CAP(RNAME(x)) |
| 58 | |
| 59 | #define LEVEL(x) query_wiz_level(x) |
| 60 | |
| 61 | #define FORALL(x, y) for(x=first_inventory(y);x;x=next_inventory(x)) |
| 62 | #define DESTRUCT(x) Destruct(x) |
| 63 | #define ALEFT(x,y,z) sprintf("%-*'"+z+"'s", y, (""+(x))[0..y-1]) |
| 64 | #define ARIGHT(x,y,z) sprintf("%*'"+z+"'s" , y, (""+(x))[0..y-1]) |
| 65 | #define W(x) Write(x) |
| 66 | #define WLN(x) W(x+"\n") |
| 67 | #define WDLN(x) W(x+".\n") |
| 68 | |
| 69 | #define MODE_ON(x) (modi|=x) |
| 70 | #define MODE_OFF(x) (modi&=~x) |
| 71 | #define MODE(x) (modi&x) |
| 72 | #define MODE_HEART (1) |
| 73 | #define MODE_FIRST (2) |
| 74 | #define MODE_PROTECT (4) |
| 75 | #define MODE_INVCHECK (8) |
| 76 | #define MODE_ENVCHECK (16) |
| 77 | #define MODE_NDCHECK (32) |
| 78 | #define MODE_VARCHECK (64) |
| 79 | #define MODE_ECHO (128) |
| 80 | #define MODE_SHORT (256) |
| 81 | #define MODE_SNOOPCHK (512) |
| 82 | #define MODE_INVISCHK (1024) |
| 83 | #define MODE_SCANCHK (2048) |
| 84 | |
| 85 | #define ERR_FILE "/players/"+RNAME(cloner)+"/.err" |
| 86 | #define LPC_FILE "/players/"+RNAME(cloner)+"/.tool.lpc" |
| 87 | #define TMP_FILE "/players/"+RNAME(cloner)+"/.tool.tmp" |
| 88 | #define SAVE_FILE "/players/"+RNAME(cloner)+"/.toolrc" |
| 89 | #define XPROF_FILE "/players/"+RNAME(cloner)+"/prof.c" |
| 90 | #define PIPE_FILE "/players/"+RNAME(cloner)+"/.tool.pipe" |
| 91 | #define PRIVATE_HEADER "/players/"+RNAME(cloner)+"/.xtool.h" |
| 92 | #define PIPE_DELETE(x) if(pipe_out&&pipe_ovr&&file_size(x)>=0) rm(x) |
| 93 | |
| 94 | #define PIPE_IN 1 |
| 95 | #define PIPE_OUT 2 |
| 96 | #define PIPE_MAX 10000 |
| 97 | |
| 98 | #define XGREP_REVERT 1 |
| 99 | #define XGREP_ICASE 2 |
| 100 | |
| 101 | #define SECURE1() if(!security()) return; |
| 102 | #define SECURE2(x) if(!security()) return x; |
| 103 | #define USAGE1(x,y) notify_fail("Usage: "+(y)+"\n");\ |
| 104 | if((x)=="?") return FALSE; |
| 105 | #define USAGE2(x,y) notify_fail("Usage: "+(y)+"\n");\ |
| 106 | if((!(x))||((x)=="?")) return FALSE; |
| 107 | #define USAGE3(x) return WLN("Usage: "+(x)) |
| 108 | |
| 109 | static int CatFile(); |
| 110 | static int Command(string str); |
| 111 | int CommandScan(string arg); |
| 112 | int DoAlias(string verb, string arg); |
| 113 | int DoHistory(string line); |
| 114 | static int MoveObj(object obj1, object obj2, int silent); |
| 115 | static int XGrepFile(string pat, string file, int revert); |
| 116 | int Xcall(string str); |
| 117 | int Xcallouts(string str); |
| 118 | int Xcat(string str); |
| 119 | int Xcindent(string str); |
| 120 | int Xclean(string str); |
| 121 | int Xclone(string str); |
| 122 | int Xuclone(string str); |
| 123 | int Xcmds(string str); |
| 124 | int Xdate(string str); |
| 125 | int Xdbg(string str); |
| 126 | int Xdclean(string str); |
| 127 | int Xddes(string str); |
| 128 | int Xdes(string str); |
| 129 | int Xdlook(string str); |
| 130 | int Xdo(string str); |
| 131 | int Xdupdate(string str); |
| 132 | int Xecho(string str); |
| 133 | int Xeval(string str); |
| 134 | int Xforall(string str); |
| 135 | int Xgoto(string str); |
| 136 | int Xgrep(string str); |
| 137 | int Xhbeats(string str); |
| 138 | int Xhead(string str); |
| 139 | int Xhelp(string str); |
| 140 | int Xids(string str); |
| 141 | int Xinfo(string str); |
| 142 | int Xinherit(string str); |
| 143 | int Xinventory(string str); |
| 144 | int Xlag(string str); |
| 145 | int Xlight(string str); |
| 146 | int Xload(string str); |
| 147 | int Xlook(string str); |
| 148 | int Xlpc(string str); |
| 149 | int Xman(string str); |
| 150 | int Xmore(string str); |
| 151 | int Xmove(string str); |
| 152 | int Xmsg(string str); |
| 153 | int Xmtp(string str); |
| 154 | int Xproc(string str); |
| 155 | int Xprops(string str); |
| 156 | int Xprof(string str); |
| 157 | int Xquit(string str); |
| 158 | int Xscan(string str); |
| 159 | int Xset(string str); |
| 160 | int Xsh(string str); |
| 161 | int Xsort(string str); |
| 162 | int Xstop(string str); |
| 163 | int Xtool(string str); |
| 164 | int Xtrace(string str); |
| 165 | int Xtrans(string str); |
| 166 | int Xupdate(string str); |
| 167 | int Xwc(string str); |
| 168 | int Xwho(string opt); |
| 169 | static string crname(object who); |
| 170 | int id(string str); |
| 171 | int move(mixed dest); |
| 172 | static int security(); |
| 173 | int write_newinvobj(object who); |
| 174 | int write_newenvobj(object who); |
| 175 | int write_netdead(object who); |
| 176 | int write_alive(object who); |
| 177 | int write_snoopee(object who); |
| 178 | int write_nosnoop(object who); |
| 179 | int write_invisobj(object who); |
| 180 | int write_invislvg(object who); |
| 181 | int write_invisply(object who); |
| 182 | int write_visibobj(object who); |
| 183 | int write_visiblvg(object who); |
| 184 | int write_visibply(object who); |
| 185 | static object *SubNodes(object obj); |
| 186 | static varargs object FindObj(string str, object env, int silent); |
| 187 | static object VarToObj(string str); |
| 188 | static varargs object XFindObj(string str, int silent); |
| 189 | static string ObjFile(object obj); |
| 190 | static string PlayerAge(object obj); |
| 191 | static string PlayerDomain(object obj, int flag); |
| 192 | static string PlayerIP(object obj, int flag); |
| 193 | static string PlayerIdle(object obj); |
| 194 | static string PlayerMail(object obj, int flag); |
| 195 | static string PlayerRace(object obj, int flag); |
| 196 | static string PlayerSnoop(object obj, int flag); |
| 197 | static string PlayerStats(object obj, int flag); |
| 198 | static string PlayerWho(object obj); |
| 199 | static string VarToFile(string str); |
| 200 | static string VarToPureFile(string str); |
| 201 | static string XFile(string file); |
| 202 | static string XFindFile(string file); |
| 203 | static varargs void DeepPrintShort(object env, int indent, string pre, string file); |
| 204 | static void Destruct(object obj); |
| 205 | static void DumpProperties(object obj, int flag); |
| 206 | static void Inheritance(object obj, string func, string pre); |
| 207 | void InvisCheck(); |
| 208 | static void MoreFile(string str); |
| 209 | void NetDeadCheck(int show); |
| 210 | static void PrintObj(object obj, string file); |
| 211 | static varargs void PrintShort(string pre, object obj, string file); |
| 212 | void SnoopCheck(); |
| 213 | static void VarCheck(int show); |
| 214 | static int Write(string str); |
| 215 | static void XExecFile(int line); |
| 216 | static void XMoreFile(string file, int flag); |
| 217 | static void XMsgSay(string str); |
| 218 | static void XMsgShout(string str); |
| 219 | static void XMsgTell(string str); |
| 220 | static void XmtpScript(string dir, string file, string opt); |
| 221 | void actions(); |
| 222 | void init(); |
| 223 | void update_tool(mixed *args, object obj); |
| 224 | string _query_long(); |
| 225 | string _query_short(); |
| 226 | |
| 227 | static int CallFunc(string verb, string str); |
| 228 | static string GetFunc(string verb, int test); |
| 229 | |
| 230 | static string PrepareLine(string str); |
| 231 | static string QuoteLine(string str); |
| 232 | static string UnquoteLine(string str); |
| 233 | int QuoteOk(string str); |
| 234 | static string *ExplodeCmds(string str); |
| 235 | |
| 236 | string read_buffer(string filename, int start, int number); |
| 237 | string load_buffer(int line); |
| 238 | int read_line(int offset); |
| 239 | |
| 240 | /* |
| 241 | * debug stuff |
| 242 | */ |
| 243 | void TK(string str); |
| 244 | int Xtk(string str); |
| 245 | |
| 246 | #endif /* __TOOL_H__ */ |