Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

atcodes.cpp 32.9 KB
Newer Older
1 2 3 4 5 6 7 8
/* Synchronet "@code" functions */

/* $Id$ */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
9
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
10 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
 *																			*
 * 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"

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

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

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

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

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

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

	return(len);
}

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

	str[0]=0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

208 209
	if(!strcmp(sp,"CONN"))
		return(connection);
210

211 212
	if(!strcmp(sp,"SYSOP"))
		return(cfg.sys_op);
213

214 215
	if(!strcmp(sp,"LOCATION"))
		return(cfg.sys_location);
216

217
	if(!strcmp(sp,"NODE")) {
218
		safe_snprintf(str,maxlen,"%u",cfg.node_num);
219 220
		return(str);
	}
221

222
	if(!strcmp(sp,"TNODE")) {
223
		safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
224 225
		return(str);
	}
226

227 228
	if(!strcmp(sp,"INETADDR"))
		return(cfg.sys_inetaddr);
229

230 231 232
	if(!strcmp(sp,"HOSTNAME"))
		return(startup->host_name);

233
	if(!strcmp(sp,"FIDOADDR")) {
234
		if(cfg.total_faddrs)
235
			return(smb_faddrtoa(&cfg.faddr[0],str));
236
		return(nulstr);
237 238
	}

239
	if(!strcmp(sp,"EMAILADDR"))
240
		return(usermailaddr(&cfg, str
241
			,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name));
242

243 244
	if(!strcmp(sp,"QWKID"))
		return(cfg.sys_id);
245

246
	if(!strcmp(sp,"TIME") || !strcmp(sp,"SYSTIME")) {
247
		now=time(NULL);
248
		memset(&tm,0,sizeof(tm));
249
		localtime_r(&now,&tm);
250
		if(cfg.sys_misc&SM_MILITARY)
251 252
			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
		        	,tm.tm_hour,tm.tm_min,tm.tm_sec);
253
		else
254
			safe_snprintf(str,maxlen,"%02d:%02d %s"
255 256 257
				,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");
258
		return(str);
259 260
	}

rswindell's avatar
rswindell committed
261 262 263
	if(!strcmp(sp,"TIMEZONE"))
		return(smb_zonestr(sys_timezone(&cfg),str));

264
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
265
		return(unixtodstr(&cfg,time32(NULL),str));
266
	}
267

rswindell's avatar
rswindell committed
268 269 270
	if(!strcmp(sp,"DATETIME"))
		return(timestr(time(NULL)));

271
	if(!strcmp(sp,"TMSG")) {
272 273
		l=0;
		for(i=0;i<cfg.total_subs;i++)
274
			l+=getposts(&cfg,i); 		/* l=total posts */
275
		safe_snprintf(str,maxlen,"%lu",l);
276 277
		return(str);
	}
278

279
	if(!strcmp(sp,"TUSER")) {
280
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
281 282
		return(str);
	}
283

284
	if(!strcmp(sp,"TFILE")) {
285 286
		l=0;
		for(i=0;i<cfg.total_dirs;i++)
287
			l+=getfiles(&cfg,i);
288
		safe_snprintf(str,maxlen,"%lu",l);
289 290
		return(str);
	}
291

292
	if(!strcmp(sp,"TCALLS") || !strcmp(sp,"NUMCALLS")) {
293
		getstats(&cfg,0,&stats);
294
		safe_snprintf(str,maxlen,"%lu",stats.logons);
295 296
		return(str);
	}
297

298
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
299
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
300
		return(lastuseron);
301

302
	if(!strcmp(sp,"CLS")) {
303
		CLS;
304 305
		return(nulstr);
	}
306

307
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
308
		pause();
309 310
		return(nulstr);
	}
311

312
	if(!strcmp(sp,"RESETPAUSE")) {
313
		lncntr=0;
314 315
		return(nulstr);
	}
316

317
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
318
		sys_status^=SS_PAUSEOFF;
319 320
		return(nulstr);
	}
321

322
	if(!strcmp(sp,"PON") || !strcmp(sp,"AUTOMORE")) {
323
		sys_status^=SS_PAUSEON;
324 325
		return(nulstr);
	}
326 327 328 329 330

	/* NOSTOP */

	/* STOP */

331 332
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
333

334 335 336
	if(!strcmp(sp,"EVENT")) {
		if(event_time==0)
			return("<none>");
337
		return(timestr(event_time));
338
	}
339 340 341

	/* LASTCALL */

342
	if(!strncmp(sp,"NODE",4)) {
343 344 345
		i=atoi(sp+4);
		if(i && i<=cfg.sys_nodes) {
			getnodedat(i,&node,0);
346 347
			printnodedat(i,&node);
		}
348 349
		return(nulstr);
	}
350

351
	if(!strcmp(sp,"WHO")) {
352
		whos_online(true);
353 354
		return(nulstr);
	}
355 356 357

	/* User Codes */

358 359
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
360

361
	if(!strcmp(sp,"FIRST")) {
362
		safe_snprintf(str,maxlen,"%s",useron.alias);
363
		tp=strchr(str,' ');
364
		if(tp) *tp=0;
365
		return(str);
366
	}
367

368
	if(!strcmp(sp,"USERNUM")) {
369
		safe_snprintf(str,maxlen,"%u",useron.number);
370 371
		return(str);
	}
372

373
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
374
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
375
		return(useron.phone);
376

377 378
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
379

380 381
	if(!strcmp(sp,"FROM"))
		return(useron.location);
382

383
	if(!strcmp(sp,"CITY")) {
384
		safe_snprintf(str,maxlen,"%s",useron.location);
385
		char* p=strchr(str,',');
386 387
		if(p) {
			*p=0;
388 389
			return(str);
		}
390 391
		return(nulstr);
	}
392

393 394
	if(!strcmp(sp,"STATE")) {
		char* p=strchr(useron.location,',');
395 396
		if(p) {
			p++;
397
			if(*p==' ')
398
				p++;
399 400
			return(p);
		}
401 402
		return(nulstr);
	}
403

404 405
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
406

407 408
	if(!strcmp(sp,"HOST"))
		return(client_name);
409

410 411
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
412

413
	if(!strcmp(sp,"AGE")) {
414
		safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
415 416
		return(str);
	}
rswindell's avatar
rswindell committed
417

418
	if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
419
		safe_snprintf(str,maxlen,"%u",useron.logons);
420 421
		return(str);
	}
422

423 424
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
425

426
	if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
427
		safe_snprintf(str,maxlen,"%u",useron.level);
428 429
		return(str);
	}
430

431 432
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
433

434
	if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
435
		now=time(NULL);
436
		safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
437 438
		return(str);
	}
439

440
	if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
441
		now=time(NULL);
442
		return(sectostr((uint)(now-logontime),str)+1);
443
	}
444

445
	if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
446
		gettimeleft();
447
		return(sectostr(timeleft,str)+1);
448
	}
449

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

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

456
	if(!strcmp(sp,"TIMELIMIT")) {
457
		safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
458 459
		return(str);
	}
460

461
	if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
462
		gettimeleft();
463
		safe_snprintf(str,maxlen,"%lu",timeleft/60);
464 465
		return(str);
	}
466

467
	if(!strcmp(sp,"LASTON"))
468
		return(timestr(useron.laston));
469

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

473
	if(!strcmp(sp,"LASTTIMEON")) {
474
		memset(&tm,0,sizeof(tm));
475
		localtime32(&useron.laston,&tm);
476 477 478 479 480 481 482 483
		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");
484
		return(str);
485 486
	}

487
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
488
		safe_snprintf(str,maxlen,"%u",useron.posts);
489 490
		return(str);
	}
491

492
	if(!strcmp(sp,"MSGREAD")) {
493
		safe_snprintf(str,maxlen,"%lu",posts_read);
494 495
		return(str);
	}
496

497
	if(!strcmp(sp,"FREESPACE")) {
498
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
499 500 501 502
		return(str);
	}

	if(!strcmp(sp,"FREESPACEK")) {
503
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,1024));
504 505
		return(str);
	}
506

507
	if(!strcmp(sp,"UPBYTES")) {
508
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
509 510
		return(str);
	}
511

512
	if(!strcmp(sp,"UPK")) {
513
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
514 515
		return(str);
	}
516

517
	if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
518
		safe_snprintf(str,maxlen,"%u",useron.uls);
519 520
		return(str);
	}
521

522
	if(!strcmp(sp,"DLBYTES")) {
523
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
524 525
		return(str);
	}
526

527
	if(!strcmp(sp,"DOWNK")) {
528
		safe_snprintf(str,maxlen,"%lu",useron.dlb/1024L);
529 530
		return(str);
	}
531

532
	if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
533
		safe_snprintf(str,maxlen,"%u",useron.dls);
534 535
		return(str);
	}
536

537
	if(!strcmp(sp,"LASTNEW"))
538
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
539

540
	if(!strcmp(sp,"NEWFILETIME"))
541
		return(timestr(ns_time));
542 543 544

	/* MAXDL */

545
	if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
546
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
547 548
		return(str);
	}
549

550
	if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
551
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
552 553
		return(str);
	}
554

555
	if(!strcmp(sp,"BYTELIMIT")) {
556
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
557 558
		return(str);
	}
559

560
	if(!strcmp(sp,"KBLEFT")) {
561
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
562 563
		return(str);
	}
564

565
	if(!strcmp(sp,"BYTESLEFT")) {
566
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
567 568
		return(str);
	}
569

570
	if(!strcmp(sp,"CONF")) {
571
		safe_snprintf(str,maxlen,"%s %s"
572 573
			,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
			,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
574 575
		return(str);
	}
576

577
	if(!strcmp(sp,"CONFNUM")) {
578
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
579 580
		return(str);
	}
581

582
	if(!strcmp(sp,"NUMDIR")) {
583
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
584 585
		return(str);
	}
586

587 588
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
589

590
	if(!strcmp(sp,"EXPDAYS")) {
591
		now=time(NULL);
592
		l=(long)(useron.expire-now);
593 594
		if(l<0)
			l=0;
595
		safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
596 597
		return(str);
	}
598

599 600
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
601

602 603
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
604

605 606
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
607

608
	if(!strcmp(sp,"HANGUP")) {
609
		hangup();
610 611
		return(nulstr);
	}
612 613 614

	/* Synchronet Specific */

615
	if(!strncmp(sp,"SETSTR:",7)) {
616
		strcpy(main_csi.str,sp+7);
617 618
		return(nulstr);
	}
619

620
	if(!strncmp(sp,"EXEC:",5)) {
621
		exec_bin(sp+5,&main_csi);
622 623
		return(nulstr);
	}
624

625
	if(!strncmp(sp,"EXEC_XTRN:",10)) {
626
		for(i=0;i<cfg.total_xtrns;i++)
627
			if(!stricmp(cfg.xtrn[i]->code,sp+10))
628 629 630 631 632 633
				break;
		if(i<cfg.total_xtrns)
			exec_xtrn(i);
		return(nulstr);
	}

634
	if(!strncmp(sp,"MENU:",5)) {
635
		menu(sp+5);
636 637
		return(nulstr);
	}
638

639 640 641 642
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
643

644
	if(!strncmp(sp,"INCLUDE:",8)) {
645
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
646 647 648
		return(nulstr);
	}

649 650
	if(!strcmp(sp,"QUESTION"))
		return(question);
651

652 653
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
654

655 656
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
657

deuce's avatar
deuce committed
658 659
	if(!strcmp(sp,"LOCAL-IP"))
		return(local_addr);
660

661 662
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
663

664
	if(!strcmp(sp,"PUSHXY")) {
665
		ansi_save();
666 667
		return(nulstr);
	}
668

669
	if(!strcmp(sp,"POPXY")) {
670
		ansi_restore();
671 672
		return(nulstr);
	}
673

rswindell's avatar
rswindell committed
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
	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);
	}

694
	if(!strncmp(sp,"UP:",3)) {
695
		cursor_up(atoi(sp+3));
696 697
		return(str);
	}
698

699
	if(!strncmp(sp,"DOWN:",5)) {