blob: 1eff23d0356e98844ca064e4a4e13e1b178e7ce8 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001#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
109static int CatFile();
110static int Command(string str);
111int CommandScan(string arg);
112int DoAlias(string verb, string arg);
113int DoHistory(string line);
114static int MoveObj(object obj1, object obj2, int silent);
115static int XGrepFile(string pat, string file, int revert);
116int Xcall(string str);
117int Xcallouts(string str);
118int Xcat(string str);
119int Xcindent(string str);
120int Xclean(string str);
121int Xclone(string str);
122int Xuclone(string str);
123int Xcmds(string str);
124int Xdate(string str);
125int Xdbg(string str);
126int Xdclean(string str);
127int Xddes(string str);
128int Xdes(string str);
129int Xdlook(string str);
130int Xdo(string str);
131int Xdupdate(string str);
132int Xecho(string str);
133int Xeval(string str);
134int Xforall(string str);
135int Xgoto(string str);
136int Xgrep(string str);
137int Xhbeats(string str);
138int Xhead(string str);
139int Xhelp(string str);
140int Xids(string str);
141int Xinfo(string str);
142int Xinherit(string str);
143int Xinventory(string str);
144int Xlag(string str);
145int Xlight(string str);
146int Xload(string str);
147int Xlook(string str);
148int Xlpc(string str);
149int Xman(string str);
150int Xmore(string str);
151int Xmove(string str);
152int Xmsg(string str);
153int Xmtp(string str);
154int Xproc(string str);
155int Xprops(string str);
156int Xprof(string str);
157int Xquit(string str);
158int Xscan(string str);
159int Xset(string str);
160int Xsh(string str);
161int Xsort(string str);
162int Xstop(string str);
163int Xtool(string str);
164int Xtrace(string str);
165int Xtrans(string str);
166int Xupdate(string str);
167int Xwc(string str);
168int Xwho(string opt);
169static string crname(object who);
170int id(string str);
171int move(mixed dest);
172static int security();
173int write_newinvobj(object who);
174int write_newenvobj(object who);
175int write_netdead(object who);
176int write_alive(object who);
177int write_snoopee(object who);
178int write_nosnoop(object who);
179int write_invisobj(object who);
180int write_invislvg(object who);
181int write_invisply(object who);
182int write_visibobj(object who);
183int write_visiblvg(object who);
184int write_visibply(object who);
185static object *SubNodes(object obj);
186static varargs object FindObj(string str, object env, int silent);
187static object VarToObj(string str);
188static varargs object XFindObj(string str, int silent);
189static string ObjFile(object obj);
190static string PlayerAge(object obj);
191static string PlayerDomain(object obj, int flag);
192static string PlayerIP(object obj, int flag);
193static string PlayerIdle(object obj);
194static string PlayerMail(object obj, int flag);
195static string PlayerRace(object obj, int flag);
196static string PlayerSnoop(object obj, int flag);
197static string PlayerStats(object obj, int flag);
198static string PlayerWho(object obj);
199static string VarToFile(string str);
200static string VarToPureFile(string str);
201static string XFile(string file);
202static string XFindFile(string file);
203static varargs void DeepPrintShort(object env, int indent, string pre, string file);
204static void Destruct(object obj);
205static void DumpProperties(object obj, int flag);
206static void Inheritance(object obj, string func, string pre);
207void InvisCheck();
208static void MoreFile(string str);
209void NetDeadCheck(int show);
210static void PrintObj(object obj, string file);
211static varargs void PrintShort(string pre, object obj, string file);
212void SnoopCheck();
213static void VarCheck(int show);
214static int Write(string str);
215static void XExecFile(int line);
216static void XMoreFile(string file, int flag);
217static void XMsgSay(string str);
218static void XMsgShout(string str);
219static void XMsgTell(string str);
220static void XmtpScript(string dir, string file, string opt);
221void actions();
222void init();
223void update_tool(mixed *args, object obj);
224string _query_long();
225string _query_short();
226
227static int CallFunc(string verb, string str);
228static string GetFunc(string verb, int test);
229
230static string PrepareLine(string str);
231static string QuoteLine(string str);
232static string UnquoteLine(string str);
233int QuoteOk(string str);
234static string *ExplodeCmds(string str);
235
236string read_buffer(string filename, int start, int number);
237string load_buffer(int line);
238int read_line(int offset);
239
240/*
241 * debug stuff
242 */
243void TK(string str);
244int Xtk(string str);
245
246#endif /* __TOOL_H__ */