atcodes.cpp 33.6 KB
Newer Older
1
/* Synchronet "@code" functions */
2
// vi: tabstop=4
3
4
5
6
7
8
9

/* $Id$ */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
10
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
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
 *																			*
 * This program is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU General Public License				*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU General Public License for more details: gpl.txt or			*
 * http://www.fsf.org/copyleft/gpl.html										*
 *																			*
 * Anonymous FTP access to the most recent released source is available at	*
 * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net	*
 *																			*
 * Anonymous CVS access to the development source and modification history	*
 * is available at cvs.synchro.net:/cvsroot/sbbs, example:					*
 * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login			*
 *     (just hit return, no password is necessary)							*
 * cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src		*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * You are encouraged to submit any modifications (preferably in Unix diff	*
 * format) via e-mail to mods@synchro.net									*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/

#include "sbbs.h"
#include "cmdshell.h"

40
41
42
43
44
45
46
#if defined(_WINSOCKAPI_)
	extern WSADATA WSAData;
	#define SOCKLIB_DESC WSAData.szDescription
#else
	#define	SOCKLIB_DESC NULL
#endif

47
48
49
/****************************************************************************/
/* Returns 0 if invalid @ code. Returns length of @ code if valid.          */
/****************************************************************************/
50
int sbbs_t::show_atcode(const char *instr)
51
{
52
	char	str[128],str2[128],*tp,*sp,*p;
53
    int     len;
54
	int		disp_len;
55
56
	bool	padded_left=false;
	bool	padded_right=false;
57
	bool	centered=false;
58
	bool	zero_padded=false;
59
	const char *cp;
60

61
	SAFECOPY(str,instr);
62
63
64
	tp=strchr(str+1,'@');
	if(!tp)                 /* no terminating @ */
		return(0);
65
	sp=strchr(str+1,' ');
66
67
68
69
70
71
	if(sp && sp<tp)         /* space before terminating @ */
		return(0);
	len=(tp-str)+1;
	(*tp)=0;
	sp=(str+1);

72
	disp_len=len;
73
74
75
76
	if((p=strstr(sp,"-L"))!=NULL)
		padded_left=true;
	else if((p=strstr(sp,"-R"))!=NULL)
		padded_right=true;
77
78
	else if((p=strstr(sp,"-C"))!=NULL)
		centered=true;
79
80
	else if((p=strstr(sp,"-Z"))!=NULL)
		zero_padded=true;
81
82
83
	if(p!=NULL) {
		if(*(p+2) && isdigit(*(p+2)))
			disp_len=atoi(p+2);
84
		*p=0;
85
	}
86

87
88
	cp=atcode(sp,str2,sizeof(str2));
	if(cp==NULL)
89
90
91
		return(0);

	if(padded_left)
92
		bprintf("%-*.*s",disp_len,disp_len,cp);
93
	else if(padded_right)
94
		bprintf("%*.*s",disp_len,disp_len,cp);
95
	else if(centered) {
rswindell's avatar
rswindell committed
96
		int vlen = strlen(cp);
97
98
99
100
		if(vlen < disp_len) {
			int left = (disp_len - vlen) / 2;
			bprintf("%*s%-*s", left, "", disp_len - left, cp);
		} else
101
			bprintf("%.*s", disp_len, cp);
102
	} else if(zero_padded) {
103
104
		int vlen = strlen(cp);
		if(vlen < disp_len)
105
			bprintf("%-.*s%s", (int)(disp_len - strlen(cp)), "0000000000", cp);
106
107
		else
			bprintf("%.*s", disp_len, cp);
108
	} else
109
		bputs(cp);
110
111
112
113

	return(len);
}

114
const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
115
116
117
{
	char*	tp;
	uint	i;
118
119
	uint	ugrp;
	uint	usub;
120
121
122
123
124
125
126
	long	l;
    stats_t stats;
    node_t  node;
	struct	tm tm;

	str[0]=0;

127
	if(!strcmp(sp,"VER"))
128
		return(VERSION);
129

130
	if(!strcmp(sp,"REV")) {
131
		safe_snprintf(str,maxlen,"%c",REVISION);
132
133
		return(str);
	}
134

135
	if(!strcmp(sp,"FULL_VER")) {
136
		safe_snprintf(str,maxlen,"%s%c%s",VERSION,REVISION,beta_version);
137
		truncsp(str);
138
#if defined(_DEBUG)
139
		strcat(str," Debug");
140
#endif
141
		return(str);
142
143
	}

144
	if(!strcmp(sp,"VER_NOTICE"))
145
		return(VERSION_NOTICE);
146

147
148
	if(!strcmp(sp,"OS_VER"))
		return(os_version(str));
149
150

#ifdef JAVASCRIPT
151
152
	if(!strcmp(sp,"JS_VER"))
		return((char *)JS_GetImplementationVersion());
153
154
#endif

155
156
	if(!strcmp(sp,"PLATFORM"))
		return(PLATFORM_DESC);
157

158
159
	if(!strcmp(sp,"COPYRIGHT"))
		return(COPYRIGHT_NOTICE);
160

161
	if(!strcmp(sp,"COMPILER")) {
162
163
164
		char compiler[32];
		DESCRIBE_COMPILER(compiler);
		strncpy(str, compiler, maxlen);
165
		return(str);
166
167
	}

168
	if(!strcmp(sp,"UPTIME")) {
169
		extern volatile time_t uptime;
170
171
172
173
		time_t up=0;
		now = time(NULL);
		if (uptime != 0 && now >= uptime)
			up = now-uptime;
174
175
		char   days[64]="";
		if((up/(24*60*60))>=2) {
176
	        sprintf(days,"%lu days ",(ulong)(up/(24L*60L*60L)));
177
178
			up%=(24*60*60);
		}
179
		safe_snprintf(str,maxlen,"%s%lu:%02lu"
180
	        ,days
181
182
			,(ulong)(up/(60L*60L))
			,(ulong)((up/60L)%60L)
183
			);
184
		return(str);
185
186
	}

187
	if(!strcmp(sp,"SERVED")) {
188
		extern volatile ulong served;
189
		safe_snprintf(str,maxlen,"%lu",served);
190
191
192
		return(str);
	}

193
	if(!strcmp(sp,"SOCKET_LIB"))
194
		return(socklib_version(str,SOCKLIB_DESC));
195

196
	if(!strcmp(sp,"MSG_LIB")) {
197
		safe_snprintf(str,maxlen,"SMBLIB %s",smb_lib_ver());
198
199
		return(str);
	}
200

201
202
	if(!strcmp(sp,"BBS") || !strcmp(sp,"BOARDNAME"))
		return(cfg.sys_name);
203

204
	if(!strcmp(sp,"BAUD") || !strcmp(sp,"BPS")) {
205
		safe_snprintf(str,maxlen,"%lu",cur_rate);
206
207
		return(str);
	}
208

rswindell's avatar
rswindell committed
209
210
211
212
213
214
215
216
217
218
219
	if(!strcmp(sp,"COLS")) {
		safe_snprintf(str,maxlen,"%lu",cols);
		return(str);
	}
	if(!strcmp(sp,"ROWS")) {
		safe_snprintf(str,maxlen,"%lu",rows);
		return(str);
	}
	if(!strcmp(sp,"TERM"))
		return(terminal);

220
221
	if(!strcmp(sp,"CONN"))
		return(connection);
222

223
224
	if(!strcmp(sp,"SYSOP"))
		return(cfg.sys_op);
225

226
227
	if(!strcmp(sp,"LOCATION"))
		return(cfg.sys_location);
228

229
	if(!strcmp(sp,"NODE")) {
230
		safe_snprintf(str,maxlen,"%u",cfg.node_num);
231
232
		return(str);
	}
233

234
	if(!strcmp(sp,"TNODE")) {
235
		safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
236
237
		return(str);
	}
238

239
240
241
242
243
244
	if(strcmp(sp, "PAGER") == 0)
		return (thisnode.misc&NODE_POFF) ? text[Off] : text[On];

	if(strcmp(sp, "ALERTS") == 0)
		return (thisnode.misc&NODE_AOFF) ? text[Off] : text[On];

245
246
	if(!strcmp(sp,"INETADDR"))
		return(cfg.sys_inetaddr);
247

248
249
250
	if(!strcmp(sp,"HOSTNAME"))
		return(startup->host_name);

251
	if(!strcmp(sp,"FIDOADDR")) {
252
		if(cfg.total_faddrs)
253
			return(smb_faddrtoa(&cfg.faddr[0],str));
254
		return(nulstr);
255
256
	}

257
	if(!strcmp(sp,"EMAILADDR"))
258
		return(usermailaddr(&cfg, str
259
			,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name));
260

261
262
	if(!strcmp(sp,"QWKID"))
		return(cfg.sys_id);
263

264
	if(!strcmp(sp,"TIME") || !strcmp(sp,"SYSTIME")) {
265
		now=time(NULL);
266
		memset(&tm,0,sizeof(tm));
267
		localtime_r(&now,&tm);
268
		if(cfg.sys_misc&SM_MILITARY)
269
270
			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
		        	,tm.tm_hour,tm.tm_min,tm.tm_sec);
271
		else
272
			safe_snprintf(str,maxlen,"%02d:%02d %s"
273
274
275
				,tm.tm_hour==0 ? 12
				: tm.tm_hour>12 ? tm.tm_hour-12
				: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
276
		return(str);
277
278
	}

rswindell's avatar
rswindell committed
279
280
281
	if(!strcmp(sp,"TIMEZONE"))
		return(smb_zonestr(sys_timezone(&cfg),str));

282
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
283
		return(unixtodstr(&cfg,time32(NULL),str));
284
	}
285

rswindell's avatar
rswindell committed
286
287
288
	if(!strcmp(sp,"DATETIME"))
		return(timestr(time(NULL)));

289
	if(!strcmp(sp,"TMSG")) {
290
291
		l=0;
		for(i=0;i<cfg.total_subs;i++)
292
			l+=getposts(&cfg,i); 		/* l=total posts */
293
		safe_snprintf(str,maxlen,"%lu",l);
294
295
		return(str);
	}
296

297
	if(!strcmp(sp,"TUSER")) {
298
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
299
300
		return(str);
	}
301

302
	if(!strcmp(sp,"TFILE")) {
303
304
		l=0;
		for(i=0;i<cfg.total_dirs;i++)
305
			l+=getfiles(&cfg,i);
306
		safe_snprintf(str,maxlen,"%lu",l);
307
308
		return(str);
	}
309

310
	if(!strcmp(sp,"TCALLS") || !strcmp(sp,"NUMCALLS")) {
311
		getstats(&cfg,0,&stats);
312
		safe_snprintf(str,maxlen,"%lu",stats.logons);
313
314
		return(str);
	}
315

316
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
317
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
318
		return(lastuseron);
319

rswindell's avatar
rswindell committed
320
	if(!strcmp(sp,"CLS") || !strcmp(sp,"CLEAR")) {
321
		CLS;
322
323
		return(nulstr);
	}
324

325
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
326
		pause();
327
328
		return(nulstr);
	}
329

330
	if(!strcmp(sp,"RESETPAUSE")) {
331
		lncntr=0;
332
333
		return(nulstr);
	}
334

335
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
336
		sys_status^=SS_PAUSEOFF;
337
338
		return(nulstr);
	}
339

340
	if(!strcmp(sp,"PON") || !strcmp(sp,"AUTOMORE")) {
341
		sys_status^=SS_PAUSEON;
342
343
		return(nulstr);
	}
344
345
346
347
348

	/* NOSTOP */

	/* STOP */

349
350
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
351

352
353
354
	if(!strcmp(sp,"EVENT")) {
		if(event_time==0)
			return("<none>");
355
		return(timestr(event_time));
356
	}
357
358
359

	/* LASTCALL */

360
	if(!strncmp(sp,"NODE",4)) {
361
362
363
		i=atoi(sp+4);
		if(i && i<=cfg.sys_nodes) {
			getnodedat(i,&node,0);
364
365
			printnodedat(i,&node);
		}
366
367
		return(nulstr);
	}
368

369
	if(!strcmp(sp,"WHO")) {
370
		whos_online(true);
371
372
		return(nulstr);
	}
373
374
375

	/* User Codes */

376
377
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
378

379
	if(!strcmp(sp,"FIRST")) {
380
		safe_snprintf(str,maxlen,"%s",useron.alias);
381
		tp=strchr(str,' ');
382
		if(tp) *tp=0;
383
		return(str);
384
	}
385

386
	if(!strcmp(sp,"USERNUM")) {
387
		safe_snprintf(str,maxlen,"%u",useron.number);
388
389
		return(str);
	}
390

391
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
392
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
393
		return(useron.phone);
394

395
396
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
397

398
399
	if(!strcmp(sp,"FROM"))
		return(useron.location);
400

401
	if(!strcmp(sp,"CITY")) {
402
		safe_snprintf(str,maxlen,"%s",useron.location);
403
		char* p=strchr(str,',');
404
405
		if(p) {
			*p=0;
406
407
			return(str);
		}
408
409
		return(nulstr);
	}
410

411
412
	if(!strcmp(sp,"STATE")) {
		char* p=strchr(useron.location,',');
413
414
		if(p) {
			p++;
415
			if(*p==' ')
416
				p++;
417
418
			return(p);
		}
419
420
		return(nulstr);
	}
421

422
423
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
424

425
426
	if(!strcmp(sp,"HOST"))
		return(client_name);
427

428
429
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
430

431
	if(!strcmp(sp,"AGE")) {
432
		safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
433
434
		return(str);
	}
rswindell's avatar
rswindell committed
435

436
	if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
437
		safe_snprintf(str,maxlen,"%u",useron.logons);
438
439
		return(str);
	}
440

441
442
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
443

444
	if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
445
		safe_snprintf(str,maxlen,"%u",useron.level);
446
447
		return(str);
	}
448

449
450
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
451

452
	if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
453
		now=time(NULL);
454
		safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
455
456
		return(str);
	}
457

458
	if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
459
		now=time(NULL);
460
		return(sectostr((uint)(now-logontime),str)+1);
461
	}
462

463
	if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
464
		gettimeleft();
465
		return(sectostr(timeleft,str)+1);
466
	}
467

468
469
	if(!strcmp(sp,"TPERD"))                /* Synchronet only */
		return(sectostr(cfg.level_timeperday[useron.level],str)+1);
470

471
472
	if(!strcmp(sp,"TPERC"))                /* Synchronet only */
		return(sectostr(cfg.level_timepercall[useron.level],str)+1);
473

474
	if(!strcmp(sp,"TIMELIMIT")) {
475
		safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
476
477
		return(str);
	}
478

479
	if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
480
		gettimeleft();
481
		safe_snprintf(str,maxlen,"%lu",timeleft/60);
482
483
		return(str);
	}
484

485
	if(!strcmp(sp,"LASTON"))
486
		return(timestr(useron.laston));
487

488
489
	if(!strcmp(sp,"LASTDATEON"))
		return(unixtodstr(&cfg,useron.laston,str));
490

491
	if(!strcmp(sp,"LASTTIMEON")) {
492
		memset(&tm,0,sizeof(tm));
493
		localtime32(&useron.laston,&tm);
494
495
496
497
498
499
500
501
		if(cfg.sys_misc&SM_MILITARY)
			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
				,tm.tm_hour, tm.tm_min, tm.tm_sec);
		else
			safe_snprintf(str,maxlen,"%02d:%02d %s"
				,tm.tm_hour==0 ? 12
				: tm.tm_hour>12 ? tm.tm_hour-12
				: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
502
		return(str);
503
504
	}

505
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
506
		safe_snprintf(str,maxlen,"%u",useron.posts);
507
508
		return(str);
	}
509

510
	if(!strcmp(sp,"MSGREAD")) {
511
		safe_snprintf(str,maxlen,"%lu",posts_read);
512
513
		return(str);
	}
514

515
	if(!strcmp(sp,"FREESPACE")) {
516
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
517
518
519
520
		return(str);
	}

	if(!strcmp(sp,"FREESPACEK")) {
521
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,1024));
522
523
		return(str);
	}
524

525
	if(!strcmp(sp,"UPBYTES")) {
526
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
527
528
		return(str);
	}
529

530
	if(!strcmp(sp,"UPK")) {
531
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
532
533
		return(str);
	}
534

535
	if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
536
		safe_snprintf(str,maxlen,"%u",useron.uls);
537
538
		return(str);
	}
539

540
	if(!strcmp(sp,"DLBYTES")) {
541
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
542
543
		return(str);
	}
544

545
	if(!strcmp(sp,"DOWNK")) {
546
		safe_snprintf(str,maxlen,"%lu",useron.dlb/1024L);
547
548
		return(str);
	}
549

550
	if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
551
		safe_snprintf(str,maxlen,"%u",useron.dls);
552
553
		return(str);
	}
554

555
	if(!strcmp(sp,"LASTNEW"))
556
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
557

558
	if(!strcmp(sp,"NEWFILETIME"))
559
		return(timestr(ns_time));
560
561
562

	/* MAXDL */

563
	if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
564
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
565
566
		return(str);
	}
567

568
	if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
569
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
570
571
		return(str);
	}
572

573
	if(!strcmp(sp,"BYTELIMIT")) {
574
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
575
576
		return(str);
	}
577

578
	if(!strcmp(sp,"KBLEFT")) {
579
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
580
581
		return(str);
	}
582

583
	if(!strcmp(sp,"BYTESLEFT")) {
584
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
585
586
		return(str);
	}
587

588
	if(!strcmp(sp,"CONF")) {
589
		safe_snprintf(str,maxlen,"%s %s"
590
591
			,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
			,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
592
593
		return(str);
	}
594

595
	if(!strcmp(sp,"CONFNUM")) {
596
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
597
598
		return(str);
	}
599

600
	if(!strcmp(sp,"NUMDIR")) {
601
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
602
603
		return(str);
	}
604

605
606
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
607

608
	if(!strcmp(sp,"EXPDAYS")) {
609
		now=time(NULL);
610
		l=(long)(useron.expire-now);
611
612
		if(l<0)
			l=0;
613
		safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
614
615
		return(str);
	}
616

617
618
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
619

620
621
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
622

623
624
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
625

626
	if(!strcmp(sp,"HANGUP")) {
627
		hangup();
628
629
		return(nulstr);
	}
630
631
632

	/* Synchronet Specific */

633
	if(!strncmp(sp,"SETSTR:",7)) {
634
		strcpy(main_csi.str,sp+7);
635
636
		return(nulstr);
	}
637

638
	if(!strncmp(sp,"EXEC:",5)) {
639
		exec_bin(sp+5,&main_csi);
640
641
		return(nulstr);
	}
642

643
	if(!strncmp(sp,"EXEC_XTRN:",10)) {
644
		for(i=0;i<cfg.total_xtrns;i++)
645
			if(!stricmp(cfg.xtrn[i]->code,sp+10))
646
647
648
649
650
651
				break;
		if(i<cfg.total_xtrns)
			exec_xtrn(i);
		return(nulstr);
	}

652
	if(!strncmp(sp,"MENU:",5)) {
653
		menu(sp+5);
654
655
		return(nulstr);
	}
656

657
658
659
660
661
	if(!strncmp(sp,"CONDMENU:",9)) {
		menu(sp+9, P_NOERROR);
		return(nulstr);
	}

662
663
664
665
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
666

667
	if(!strncmp(sp,"INCLUDE:",8)) {
668
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
669
670
671
		return(nulstr);
	}

672
673
	if(!strcmp(sp,"QUESTION"))
		return(question);
674

675
676
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
677

678
679
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
680

deuce's avatar
deuce committed
681
682
	if(!strcmp(sp,"LOCAL-IP"))
		return(local_addr);
683

684
685
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
686

687
	if(!strcmp(sp,"PUSHXY")) {
688
		ansi_save();
689
690
		return(nulstr);
	}
691

692
	if(!strcmp(sp,"POPXY")) {
693
		ansi_restore();
694
695
		return(nulstr);
	}
696

rswindell's avatar
rswindell committed
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
	if(!strcmp(sp,"HOME")) {
		cursor_home();
		return(nulstr);
	}

	if(!strcmp(sp,"CLRLINE")) {
		clearline();
		return(nulstr);
	}

	if(!strcmp(sp,"CLR2EOL")) {
		cleartoeol();
		return(nulstr);
	}

	if(!strcmp(sp,"CLR2EOS")) {
		cleartoeos();
		return(nulstr);
	}

717
	if(!strncmp(sp,"UP:",3)) {
718
		cursor_up(atoi(sp+3));
719
720
		return(str);
	}
721

722
	if(!strncmp(sp,"DOWN:",5)) {
723
		cursor_down(atoi(sp+5));
724
725
		return(str);
	}
726

727
	if(!strncmp(sp,"LEFT:",5)) {
728
		cursor_left(atoi(sp+5));
729
730
		return(str);
	}
731

732
	if(!strncmp(sp,"RIGHT:",6)) {
733
		cursor_right(atoi(sp+6));
734
735
		return(str);
	}
736

737
	if(!strncmp(sp,"GOTOXY:",7)) {
738
739
740
		tp=strchr(sp,',');
		if(tp!=NULL) {
			tp++;
741
			ansi_gotoxy(atoi(sp+7),atoi(tp));
742
		}
743
		return(nulstr);
744
745
	}

746
747
748
749
750
751
752
	if(!strcmp(sp,"GRP")) {
		if(SMB_IS_OPEN(&smb)) {
			if(smb.subnum==INVALID_SUB)
				return("Local");
			if(smb.subnum<cfg.total_subs)
				return(cfg.grp[cfg.sub[smb.subnum]->grp]->sname);
		}
753
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
754
	}
755

756
757
758
759
760
761
762
	if(!strcmp(sp,"GRPL")) {
		if(SMB_IS_OPEN(&smb)) {
			if(smb.subnum==INVALID_SUB)
				return("Local");
			if(smb.subnum<cfg.total_subs)
				return(cfg.grp[cfg.sub[smb.subnum]->grp]->lname);
		}
763
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->lname : nulstr);
764
	}
765

766
	if(!strcmp(sp,"GN")) {
767
768
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
769
		else
770
			ugrp=usrgrps ? curgrp+1 : 0;
771
		safe_snprintf(str,maxlen,"%u",ugrp);
772
773
		return(str);
	}
774

775
	if(!strcmp(sp,"GL")) {