atcodes.cpp 34.1 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
247
	if(strcmp(sp, "SPLITP") == 0)
		return (useron.chat&CHAT_SPLITP) ? text[On] : text[Off];

248
249
	if(!strcmp(sp,"INETADDR"))
		return(cfg.sys_inetaddr);
250

251
252
253
	if(!strcmp(sp,"HOSTNAME"))
		return(startup->host_name);

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

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

264
265
	if(!strcmp(sp,"QWKID"))
		return(cfg.sys_id);
266

267
	if(!strcmp(sp,"TIME") || !strcmp(sp,"SYSTIME")) {
268
		now=time(NULL);
269
		memset(&tm,0,sizeof(tm));
270
		localtime_r(&now,&tm);
271
		if(cfg.sys_misc&SM_MILITARY)
272
273
			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
		        	,tm.tm_hour,tm.tm_min,tm.tm_sec);
274
		else
275
			safe_snprintf(str,maxlen,"%02d:%02d %s"
276
277
278
				,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");
279
		return(str);
280
281
	}

rswindell's avatar
rswindell committed
282
283
284
	if(!strcmp(sp,"TIMEZONE"))
		return(smb_zonestr(sys_timezone(&cfg),str));

285
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
286
		return(unixtodstr(&cfg,time32(NULL),str));
287
	}
288

rswindell's avatar
rswindell committed
289
290
291
	if(!strcmp(sp,"DATETIME"))
		return(timestr(time(NULL)));

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

300
	if(!strcmp(sp,"TUSER")) {
301
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
302
303
		return(str);
	}
304

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

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

319
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
320
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
321
		return(lastuseron);
322

rswindell's avatar
rswindell committed
323
	if(!strcmp(sp,"CLS") || !strcmp(sp,"CLEAR")) {
324
		CLS;
325
326
		return(nulstr);
	}
327

328
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
329
		pause();
330
331
		return(nulstr);
	}
332

333
	if(!strcmp(sp,"RESETPAUSE")) {
334
		lncntr=0;
335
336
		return(nulstr);
	}
337

338
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
339
		sys_status^=SS_PAUSEOFF;
340
341
		return(nulstr);
	}
342

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

348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
	if(strncmp(sp, "POS:", 4) == 0) {	// PCBoard	(nn is 0 or 1 based?)
		for(l = atoi(sp + 4) - column; l > 0; l--)
			outchar(' ');
		return nulstr;
	}

	if(strncmp(sp, "DELAY:", 6) == 0) {	// PCBoard
		mswait(atoi(sp + 6) * 100);
		return nulstr;
	}

	if(strcmp(sp, "YESCHAR") == 0) {	// PCBoard
		safe_snprintf(str, maxlen, "%c", text[YNQP][0]);
		return str;
	}

	if(strcmp(sp, "NOCHAR") == 0) {		// PCBoard
		safe_snprintf(str, maxlen, "%c", text[YNQP][1]);
		return str;
	}

	if(strcmp(sp, "QUITCHAR") == 0) {
		safe_snprintf(str, maxlen, "%c", text[YNQP][2]);
		return str;
	}

374
375
376
377
	/* NOSTOP */

	/* STOP */

378
379
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
380

381
382
383
	if(!strcmp(sp,"EVENT")) {
		if(event_time==0)
			return("<none>");
384
		return(timestr(event_time));
385
	}
386
387
388

	/* LASTCALL */

389
	if(!strncmp(sp,"NODE",4)) {
390
391
392
		i=atoi(sp+4);
		if(i && i<=cfg.sys_nodes) {
			getnodedat(i,&node,0);
393
394
			printnodedat(i,&node);
		}
395
396
		return(nulstr);
	}
397

398
	if(!strcmp(sp,"WHO")) {
399
		whos_online(true);
400
401
		return(nulstr);
	}
402
403
404

	/* User Codes */

405
406
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
407

408
	if(!strcmp(sp,"FIRST")) {
409
		safe_snprintf(str,maxlen,"%s",useron.alias);
410
		tp=strchr(str,' ');
411
		if(tp) *tp=0;
412
		return(str);
413
	}
414

415
	if(!strcmp(sp,"USERNUM")) {
416
		safe_snprintf(str,maxlen,"%u",useron.number);
417
418
		return(str);
	}
419

420
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
421
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
422
		return(useron.phone);
423

424
425
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
426

427
428
	if(!strcmp(sp,"FROM"))
		return(useron.location);
429

430
	if(!strcmp(sp,"CITY")) {
431
		safe_snprintf(str,maxlen,"%s",useron.location);
432
		char* p=strchr(str,',');
433
434
		if(p) {
			*p=0;
435
436
			return(str);
		}
437
438
		return(nulstr);
	}
439

440
441
	if(!strcmp(sp,"STATE")) {
		char* p=strchr(useron.location,',');
442
443
		if(p) {
			p++;
444
			if(*p==' ')
445
				p++;
446
447
			return(p);
		}
448
449
		return(nulstr);
	}
450

451
452
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
453

454
455
	if(!strcmp(sp,"HOST"))
		return(client_name);
456

457
458
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
459

460
	if(!strcmp(sp,"AGE")) {
461
		safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
462
463
		return(str);
	}
rswindell's avatar
rswindell committed
464

465
	if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
466
		safe_snprintf(str,maxlen,"%u",useron.logons);
467
468
		return(str);
	}
469

470
471
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
472

473
	if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
474
		safe_snprintf(str,maxlen,"%u",useron.level);
475
476
		return(str);
	}
477

478
479
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
480

481
	if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
482
		now=time(NULL);
483
		safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
484
485
		return(str);
	}
486

487
	if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
488
		now=time(NULL);
489
		return(sectostr((uint)(now-logontime),str)+1);
490
	}
491

492
	if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
493
		gettimeleft();
494
		return(sectostr(timeleft,str)+1);
495
	}
496

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

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

503
	if(!strcmp(sp,"TIMELIMIT")) {
504
		safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
505
506
		return(str);
	}
507

508
	if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
509
		gettimeleft();
510
		safe_snprintf(str,maxlen,"%lu",timeleft/60);
511
512
		return(str);
	}
513

514
	if(!strcmp(sp,"LASTON"))
515
		return(timestr(useron.laston));
516

517
518
	if(!strcmp(sp,"LASTDATEON"))
		return(unixtodstr(&cfg,useron.laston,str));
519

520
	if(!strcmp(sp,"LASTTIMEON")) {
521
		memset(&tm,0,sizeof(tm));
522
		localtime32(&useron.laston,&tm);
523
524
525
526
527
528
529
530
		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");
531
		return(str);
532
533
	}

534
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
535
		safe_snprintf(str,maxlen,"%u",useron.posts);
536
537
		return(str);
	}
538

539
	if(!strcmp(sp,"MSGREAD")) {
540
		safe_snprintf(str,maxlen,"%lu",posts_read);
541
542
		return(str);
	}
543

544
	if(!strcmp(sp,"FREESPACE")) {
545
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
546
547
548
549
		return(str);
	}

	if(!strcmp(sp,"FREESPACEK")) {
550
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,1024));
551
552
		return(str);
	}
553

554
	if(!strcmp(sp,"UPBYTES")) {
555
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
556
557
		return(str);
	}
558

559
	if(!strcmp(sp,"UPK")) {
560
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
561
562
		return(str);
	}
563

564
	if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
565
		safe_snprintf(str,maxlen,"%u",useron.uls);
566
567
		return(str);
	}
568

569
	if(!strcmp(sp,"DLBYTES")) {
570
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
571
572
		return(str);
	}
573

574
	if(!strcmp(sp,"DOWNK")) {
575
		safe_snprintf(str,maxlen,"%lu",useron.dlb/1024L);
576
577
		return(str);
	}
578

579
	if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
580
		safe_snprintf(str,maxlen,"%u",useron.dls);
581
582
		return(str);
	}
583

584
	if(!strcmp(sp,"LASTNEW"))
585
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
586

587
	if(!strcmp(sp,"NEWFILETIME"))
588
		return(timestr(ns_time));
589
590
591

	/* MAXDL */

592
	if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
593
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
594
595
		return(str);
	}
596

597
	if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
598
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
599
600
		return(str);
	}
601

602
	if(!strcmp(sp,"BYTELIMIT")) {
603
		safe_snprintf(str,maxlen,"%ld", (long)cfg.level_freecdtperday[useron.level]);
604
605
		return(str);
	}
606

607
	if(!strcmp(sp,"KBLEFT")) {
608
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
609
610
		return(str);
	}
611

612
	if(!strcmp(sp,"BYTESLEFT")) {
613
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
614
615
		return(str);
	}
616

617
	if(!strcmp(sp,"CONF")) {
618
		safe_snprintf(str,maxlen,"%s %s"
619
620
			,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
			,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
621
622
		return(str);
	}
623

624
	if(!strcmp(sp,"CONFNUM")) {
625
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
626
627
		return(str);
	}
628

629
	if(!strcmp(sp,"NUMDIR")) {
630
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
631
632
		return(str);
	}
633

634
635
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
636

637
	if(!strcmp(sp,"EXPDAYS")) {
638
		now=time(NULL);
639
		l=(long)(useron.expire-now);
640
641
		if(l<0)
			l=0;
642
		safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
643
644
		return(str);
	}
645

646
647
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
648

649
650
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
651

652
653
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
654

655
	if(!strcmp(sp,"HANGUP")) {
656
		hangup();
657
658
		return(nulstr);
	}
659
660
661

	/* Synchronet Specific */

662
	if(!strncmp(sp,"SETSTR:",7)) {
663
		strcpy(main_csi.str,sp+7);
664
665
		return(nulstr);
	}
666

667
	if(!strncmp(sp,"EXEC:",5)) {
668
		exec_bin(sp+5,&main_csi);
669
670
		return(nulstr);
	}
671

672
	if(!strncmp(sp,"EXEC_XTRN:",10)) {
673
		for(i=0;i<cfg.total_xtrns;i++)
674
			if(!stricmp(cfg.xtrn[i]->code,sp+10))
675
676
677
678
679
680
				break;
		if(i<cfg.total_xtrns)
			exec_xtrn(i);
		return(nulstr);
	}

681
	if(!strncmp(sp,"MENU:",5)) {
682
		menu(sp+5);
683
684
		return(nulstr);
	}
685

686
687
688
689
690
	if(!strncmp(sp,"CONDMENU:",9)) {
		menu(sp+9, P_NOERROR);
		return(nulstr);
	}

691
692
693
694
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
695

696
	if(!strncmp(sp,"INCLUDE:",8)) {
697
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
698
699
700
		return(nulstr);
	}

701
702
	if(!strcmp(sp,"QUESTION"))
		return(question);
703

704
705
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
706

707
708
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
709

deuce's avatar
deuce committed
710
711
	if(!strcmp(sp,"LOCAL-IP"))
		return(local_addr);
712

713
714
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
715

716
	if(!strcmp(sp,"PUSHXY")) {
717
		ansi_save();
718
719
		return(nulstr);
	}
720

721
	if(!strcmp(sp,"POPXY")) {
722
		ansi_restore();
723
724
		return(nulstr);
	}
725

rswindell's avatar
rswindell committed
726
727
728
729
730
731
732
733
734
735
	if(!strcmp(sp,"HOME")) {
		cursor_home();
		return(nulstr);
	}

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

736
	if(!strcmp(sp,"CLR2EOL") || !strcmp(sp,"CLREOL")) {
rswindell's avatar
rswindell committed
737
738
739
740
741
742
743
744
745
		cleartoeol();
		return(nulstr);
	}

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

746
	if(!strncmp(sp,"UP:",3)) {
747
		cursor_up(atoi(sp+3));
748
749
		return(str);
	}
750

751
	if(!strncmp(sp,"DOWN:",5)) {
752
		cursor_down(atoi(sp+5));
753
754
		return(str);
	}
755

756
	if(!strncmp(sp,"LEFT:",5)) {
757
		cursor_left(atoi(sp+5));
758
759
		return(str);
	}
760

761
	if(!strncmp(sp,"RIGHT:",6)) {
762
		cursor_right(atoi(sp+6));
763
764
		return(str);
	}
765

766
	if(!strncmp(sp,"GOTOXY:",7)) {
767
768
769
		tp=strchr(sp,',');
		if(tp!=NULL) {
			tp++;
770
			ansi_gotoxy(atoi(sp+7),atoi(tp));
771
		}
772
		return(nulstr);
773
774
	}

775
776
777
778
779
780
781
	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);
		}
782
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
783
	}
784

785
786
787
788
789
790
791
	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);
		}
792
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->lname : nulstr);