atcodes.cpp 30.1 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
100
		if(vlen < disp_len) {
			int left = (disp_len - vlen) / 2;
			bprintf("%*s%-*s", left, "", disp_len - left, cp);
		} else
			bputs(cp);
101
102
	} else if(zero_padded) {
		bprintf("%-.*s%s", disp_len - strlen(cp), "0000000000", cp);
103
	} else
104
		bputs(cp);
105
106
107
108

	return(len);
}

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

	str[0]=0;

122
	if(!strcmp(sp,"VER"))
123
		return(VERSION);
124

125
	if(!strcmp(sp,"REV")) {
126
		safe_snprintf(str,maxlen,"%c",REVISION);
127
128
		return(str);
	}
129

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

139
	if(!strcmp(sp,"VER_NOTICE"))
140
		return(VERSION_NOTICE);
141

142
143
	if(!strcmp(sp,"OS_VER"))
		return(os_version(str));
144
145

#ifdef JAVASCRIPT
146
147
	if(!strcmp(sp,"JS_VER"))
		return((char *)JS_GetImplementationVersion());
148
149
#endif

150
151
	if(!strcmp(sp,"PLATFORM"))
		return(PLATFORM_DESC);
152

153
154
	if(!strcmp(sp,"COPYRIGHT"))
		return(COPYRIGHT_NOTICE);
155

156
	if(!strcmp(sp,"COMPILER")) {
157
		DESCRIBE_COMPILER(str);
158
		return(str);
159
160
	}

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

180
	if(!strcmp(sp,"SERVED")) {
181
		extern volatile ulong served;
182
		safe_snprintf(str,maxlen,"%lu",served);
183
184
185
		return(str);
	}

186
	if(!strcmp(sp,"SOCKET_LIB"))
187
		return(socklib_version(str,SOCKLIB_DESC));
188

189
	if(!strcmp(sp,"MSG_LIB")) {
190
		safe_snprintf(str,maxlen,"SMBLIB %s",smb_lib_ver());
191
192
		return(str);
	}
193

194
195
	if(!strcmp(sp,"BBS") || !strcmp(sp,"BOARDNAME"))
		return(cfg.sys_name);
196

197
	if(!strcmp(sp,"BAUD") || !strcmp(sp,"BPS")) {
198
		safe_snprintf(str,maxlen,"%lu",cur_rate);
199
200
		return(str);
	}
201

202
203
	if(!strcmp(sp,"CONN"))
		return(connection);
204

205
206
	if(!strcmp(sp,"SYSOP"))
		return(cfg.sys_op);
207

208
209
	if(!strcmp(sp,"LOCATION"))
		return(cfg.sys_location);
210

211
	if(!strcmp(sp,"NODE")) {
212
		safe_snprintf(str,maxlen,"%u",cfg.node_num);
213
214
		return(str);
	}
215

216
	if(!strcmp(sp,"TNODE")) {
217
		safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
218
219
		return(str);
	}
220

221
222
	if(!strcmp(sp,"INETADDR"))
		return(cfg.sys_inetaddr);
223

224
225
226
	if(!strcmp(sp,"HOSTNAME"))
		return(startup->host_name);

227
	if(!strcmp(sp,"FIDOADDR")) {
228
		if(cfg.total_faddrs)
229
			return(smb_faddrtoa(&cfg.faddr[0],str));
230
		return(nulstr);
231
232
	}

233
	if(!strcmp(sp,"EMAILADDR"))
234
		return(usermailaddr(&cfg, str
235
			,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name));
236

237
238
	if(!strcmp(sp,"QWKID"))
		return(cfg.sys_id);
239

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

rswindell's avatar
rswindell committed
255
256
257
	if(!strcmp(sp,"TIMEZONE"))
		return(smb_zonestr(sys_timezone(&cfg),str));

258
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
259
		return(unixtodstr(&cfg,time32(NULL),str));
260
	}
261

rswindell's avatar
rswindell committed
262
263
264
	if(!strcmp(sp,"DATETIME"))
		return(timestr(time(NULL)));

265
	if(!strcmp(sp,"TMSG")) {
266
267
		l=0;
		for(i=0;i<cfg.total_subs;i++)
268
			l+=getposts(&cfg,i); 		/* l=total posts */
269
		safe_snprintf(str,maxlen,"%lu",l);
270
271
		return(str);
	}
272

273
	if(!strcmp(sp,"TUSER")) {
274
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
275
276
		return(str);
	}
277

278
	if(!strcmp(sp,"TFILE")) {
279
280
		l=0;
		for(i=0;i<cfg.total_dirs;i++)
281
			l+=getfiles(&cfg,i);
282
		safe_snprintf(str,maxlen,"%lu",l);
283
284
		return(str);
	}
285

286
	if(!strcmp(sp,"TCALLS") || !strcmp(sp,"NUMCALLS")) {
287
		getstats(&cfg,0,&stats);
288
		safe_snprintf(str,maxlen,"%lu",stats.logons);
289
290
		return(str);
	}
291

292
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
293
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
294
		return(lastuseron);
295

296
	if(!strcmp(sp,"CLS")) {
297
		CLS;
298
299
		return(nulstr);
	}
300

301
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
302
		pause();
303
304
		return(nulstr);
	}
305

306
	if(!strcmp(sp,"RESETPAUSE")) {
307
		lncntr=0;
308
309
		return(nulstr);
	}
310

311
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
312
		sys_status^=SS_PAUSEOFF;
313
314
		return(nulstr);
	}
315

316
	if(!strcmp(sp,"PON") || !strcmp(sp,"AUTOMORE")) {
317
		sys_status^=SS_PAUSEON;
318
319
		return(nulstr);
	}
320
321
322
323
324

	/* NOSTOP */

	/* STOP */

325
326
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
327

328
329
330
	if(!strcmp(sp,"EVENT")) {
		if(event_time==0)
			return("<none>");
331
		return(timestr(event_time));
332
	}
333
334
335

	/* LASTCALL */

336
	if(!strncmp(sp,"NODE",4)) {
337
338
339
		i=atoi(sp+4);
		if(i && i<=cfg.sys_nodes) {
			getnodedat(i,&node,0);
340
341
			printnodedat(i,&node);
		}
342
343
		return(nulstr);
	}
344

345
	if(!strcmp(sp,"WHO")) {
346
		whos_online(true);
347
348
		return(nulstr);
	}
349
350
351

	/* User Codes */

352
353
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
354

355
	if(!strcmp(sp,"FIRST")) {
356
		safe_snprintf(str,maxlen,"%s",useron.alias);
357
		tp=strchr(str,' ');
358
		if(tp) *tp=0;
359
		return(str);
360
	}
361

362
	if(!strcmp(sp,"USERNUM")) {
363
		safe_snprintf(str,maxlen,"%u",useron.number);
364
365
		return(str);
	}
366

367
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
368
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
369
		return(useron.phone);
370

371
372
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
373

374
375
	if(!strcmp(sp,"FROM"))
		return(useron.location);
376

377
	if(!strcmp(sp,"CITY")) {
378
		safe_snprintf(str,maxlen,"%s",useron.location);
379
		char* p=strchr(str,',');
380
381
		if(p) {
			*p=0;
382
383
			return(str);
		}
384
385
		return(nulstr);
	}
386

387
388
	if(!strcmp(sp,"STATE")) {
		char* p=strchr(useron.location,',');
389
390
		if(p) {
			p++;
391
			if(*p==' ')
392
				p++;
393
394
			return(p);
		}
395
396
		return(nulstr);
	}
397

398
399
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
400

401
402
	if(!strcmp(sp,"HOST"))
		return(client_name);
403

404
405
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
406

407
	if(!strcmp(sp,"AGE")) {
408
		safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
409
410
		return(str);
	}
rswindell's avatar
rswindell committed
411

412
	if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
413
		safe_snprintf(str,maxlen,"%u",useron.logons);
414
415
		return(str);
	}
416

417
418
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
419

420
	if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
421
		safe_snprintf(str,maxlen,"%u",useron.level);
422
423
		return(str);
	}
424

425
426
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
427

428
	if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
429
		now=time(NULL);
430
		safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
431
432
		return(str);
	}
433

434
	if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
435
		now=time(NULL);
436
		return(sectostr((uint)(now-logontime),str)+1);
437
	}
438

439
	if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
440
		gettimeleft();
441
		return(sectostr(timeleft,str)+1);
442
	}
443

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

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

450
	if(!strcmp(sp,"TIMELIMIT")) {
451
		safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
452
453
		return(str);
	}
454

455
	if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
456
		gettimeleft();
457
		safe_snprintf(str,maxlen,"%lu",timeleft/60);
458
459
		return(str);
	}
460

461
	if(!strcmp(sp,"LASTON"))
462
		return(timestr(useron.laston));
463

464
465
	if(!strcmp(sp,"LASTDATEON"))
		return(unixtodstr(&cfg,useron.laston,str));
466

467
	if(!strcmp(sp,"LASTTIMEON")) {
468
		memset(&tm,0,sizeof(tm));
469
		localtime32(&useron.laston,&tm);
470
471
472
473
474
475
476
477
		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");
478
		return(str);
479
480
	}

481
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
482
		safe_snprintf(str,maxlen,"%u",useron.posts);
483
484
		return(str);
	}
485

486
	if(!strcmp(sp,"MSGREAD")) {
487
		safe_snprintf(str,maxlen,"%lu",posts_read);
488
489
		return(str);
	}
490

491
	if(!strcmp(sp,"FREESPACE")) {
492
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
493
494
495
496
		return(str);
	}

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

501
	if(!strcmp(sp,"UPBYTES")) {
502
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
503
504
		return(str);
	}
505

506
	if(!strcmp(sp,"UPK")) {
507
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
508
509
		return(str);
	}
510

511
	if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
512
		safe_snprintf(str,maxlen,"%u",useron.uls);
513
514
		return(str);
	}
515

516
	if(!strcmp(sp,"DLBYTES")) {
517
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
518
519
		return(str);
	}
520

521
	if(!strcmp(sp,"DOWNK")) {
522
		safe_snprintf(str,maxlen,"%lu",useron.dlb/1024L);
523
524
		return(str);
	}
525

526
	if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
527
		safe_snprintf(str,maxlen,"%u",useron.dls);
528
529
		return(str);
	}
530

531
	if(!strcmp(sp,"LASTNEW"))
532
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
533

534
	if(!strcmp(sp,"NEWFILETIME"))
535
		return(timestr(ns_time));
536
537
538

	/* MAXDL */

539
	if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
540
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
541
542
		return(str);
	}
543

544
	if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
545
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
546
547
		return(str);
	}
548

549
	if(!strcmp(sp,"BYTELIMIT")) {
550
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
551
552
		return(str);
	}
553

554
	if(!strcmp(sp,"KBLEFT")) {
555
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
556
557
		return(str);
	}
558

559
	if(!strcmp(sp,"BYTESLEFT")) {
560
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
561
562
		return(str);
	}
563

564
	if(!strcmp(sp,"CONF")) {
565
		safe_snprintf(str,maxlen,"%s %s"
566
567
			,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
			,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
568
569
		return(str);
	}
570

571
	if(!strcmp(sp,"CONFNUM")) {
572
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
573
574
		return(str);
	}
575

576
	if(!strcmp(sp,"NUMDIR")) {
577
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
578
579
		return(str);
	}
580

581
582
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
583

584
	if(!strcmp(sp,"EXPDAYS")) {
585
		now=time(NULL);
586
		l=(long)(useron.expire-now);
587
588
		if(l<0)
			l=0;
589
		safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
590
591
		return(str);
	}
592

593
594
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
595

596
597
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
598

599
600
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
601

602
	if(!strcmp(sp,"HANGUP")) {
603
		hangup();
604
605
		return(nulstr);
	}
606
607
608

	/* Synchronet Specific */

609
	if(!strncmp(sp,"SETSTR:",7)) {
610
		strcpy(main_csi.str,sp+7);
611
612
		return(nulstr);
	}
613

614
	if(!strncmp(sp,"EXEC:",5)) {
615
		exec_bin(sp+5,&main_csi);
616
617
		return(nulstr);
	}
618

619
	if(!strncmp(sp,"EXEC_XTRN:",10)) {
620
		for(i=0;i<cfg.total_xtrns;i++)
621
			if(!stricmp(cfg.xtrn[i]->code,sp+10))
622
623
624
625
626
627
				break;
		if(i<cfg.total_xtrns)
			exec_xtrn(i);
		return(nulstr);
	}

628
	if(!strncmp(sp,"MENU:",5)) {
629
		menu(sp+5);
630
631
		return(nulstr);
	}
632

633
634
635
636
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
637

638
	if(!strncmp(sp,"INCLUDE:",8)) {
639
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
640
641
642
		return(nulstr);
	}

643
644
	if(!strcmp(sp,"QUESTION"))
		return(question);
645

646
647
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
648

649
650
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
651

deuce's avatar
deuce committed
652
653
	if(!strcmp(sp,"LOCAL-IP"))
		return(local_addr);
654

655
656
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
657

658
	if(!strcmp(sp,"PUSHXY")) {
659
		ansi_save();
660
661
		return(nulstr);
	}
662

663
	if(!strcmp(sp,"POPXY")) {
664
		ansi_restore();
665
666
		return(nulstr);
	}
667

rswindell's avatar
rswindell committed
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
	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);
	}

688
	if(!strncmp(sp,"UP:",3)) {
689
		cursor_up(atoi(sp+3));
690
691
		return(str);
	}
692

693
	if(!strncmp(sp,"DOWN:",5)) {
694
		cursor_down(atoi(sp+5));
695
696
		return(str);
	}
697

698
	if(!strncmp(sp,"LEFT:",5)) {
699
		cursor_left(atoi(sp+5));
700
701
		return(str);
	}
702

703
	if(!strncmp(sp,"RIGHT:",6)) {
704
		cursor_right(atoi(sp+6));
705
706
		return(str);
	}
707

708
	if(!strncmp(sp,"GOTOXY:",7)) {
709
710
711
		tp=strchr(sp,',');
		if(tp!=NULL) {
			tp++;
712
			ansi_gotoxy(atoi(sp+7),atoi(tp));
713
		}
714
		return(nulstr);
715
716
	}

717
718
719
720
721
722
723
	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);
		}
724
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
725
	}
726

727
728
729
730
731
732
733
	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);
		}
734
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->lname : nulstr);
735
	}
736

737
	if(!strcmp(sp,"GN")) {
738
739
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
740
		else
741
			ugrp=usrgrps ? curgrp+1 : 0;
742
		safe_snprintf(str,maxlen,"%u",ugrp);
743
744
		return(str);
	}
745

746
	if(!strcmp(sp,"GL")) {
747
748
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
749
		else
750
			ugrp=usrgrps ? curgrp+1 : 0;
751
		safe_snprintf(str,maxlen,"%-4u",ugrp);
752
753
		return(str);
	}
754

755
	if(!strcmp(sp,"GR")) {
756
757
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
758
		else
759
			ugrp=usrgrps ? curgrp+1 : 0;
760
		safe_snprintf(str,maxlen,"%4u",ugrp);
761
762
		return(str);
	}
763

rswindell's avatar