atcodes.cpp 28.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/* atcodes.cpp */

/* 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)		*
 *																			*
11
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
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
40
 *																			*
 * 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"

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

48
49
50
/****************************************************************************/
/* Returns 0 if invalid @ code. Returns length of @ code if valid.          */
/****************************************************************************/
51
int sbbs_t::show_atcode(const char *instr)
52
{
53
	char	str[128],str2[128],*tp,*sp,*p;
54
    int     len;
55
	int		disp_len;
56
57
	bool	padded_left=false;
	bool	padded_right=false;
58
	bool	centered=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
81
	if(p!=NULL) {
		if(*(p+2) && isdigit(*(p+2)))
			disp_len=atoi(p+2);
82
		*p=0;
83
	}
84

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

	if(padded_left)
90
		bprintf("%-*.*s",disp_len,disp_len,cp);
91
	else if(padded_right)
92
		bprintf("%*.*s",disp_len,disp_len,cp);
93
94
95
96
97
98
99
100
	else if(centered) {
		size_t vlen = strlen(cp);
		if(vlen < disp_len) {
			int left = (disp_len - vlen) / 2;
			bprintf("%*s%-*s", left, "", disp_len - left, cp);
		} else
			bputs(cp);
	} else
101
		bputs(cp);
102
103
104
105

	return(len);
}

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

	str[0]=0;

119
	if(!strcmp(sp,"VER"))
120
		return(VERSION);
121

122
	if(!strcmp(sp,"REV")) {
123
		safe_snprintf(str,maxlen,"%c",REVISION);
124
125
		return(str);
	}
126

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

136
	if(!strcmp(sp,"VER_NOTICE"))
137
		return(VERSION_NOTICE);
138

139
140
	if(!strcmp(sp,"OS_VER"))
		return(os_version(str));
141
142

#ifdef JAVASCRIPT
143
144
	if(!strcmp(sp,"JS_VER"))
		return((char *)JS_GetImplementationVersion());
145
146
#endif

147
148
	if(!strcmp(sp,"PLATFORM"))
		return(PLATFORM_DESC);
149

150
151
	if(!strcmp(sp,"COPYRIGHT"))
		return(COPYRIGHT_NOTICE);
152

153
	if(!strcmp(sp,"COMPILER")) {
154
		DESCRIBE_COMPILER(str);
155
		return(str);
156
157
	}

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

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

183
	if(!strcmp(sp,"SOCKET_LIB"))
184
		return(socklib_version(str,SOCKLIB_DESC));
185

186
	if(!strcmp(sp,"MSG_LIB")) {
187
		safe_snprintf(str,maxlen,"SMBLIB %s",smb_lib_ver());
188
189
		return(str);
	}
190

191
192
	if(!strcmp(sp,"BBS") || !strcmp(sp,"BOARDNAME"))
		return(cfg.sys_name);
193

194
	if(!strcmp(sp,"BAUD") || !strcmp(sp,"BPS")) {
195
		safe_snprintf(str,maxlen,"%lu",cur_rate);
196
197
		return(str);
	}
198

199
200
	if(!strcmp(sp,"CONN"))
		return(connection);
201

202
203
	if(!strcmp(sp,"SYSOP"))
		return(cfg.sys_op);
204

205
206
	if(!strcmp(sp,"LOCATION"))
		return(cfg.sys_location);
207

208
	if(!strcmp(sp,"NODE")) {
209
		safe_snprintf(str,maxlen,"%u",cfg.node_num);
210
211
		return(str);
	}
212

213
	if(!strcmp(sp,"TNODE")) {
214
		safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
215
216
		return(str);
	}
217

218
219
	if(!strcmp(sp,"INETADDR"))
		return(cfg.sys_inetaddr);
220

221
222
223
	if(!strcmp(sp,"HOSTNAME"))
		return(startup->host_name);

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

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

234
235
	if(!strcmp(sp,"QWKID"))
		return(cfg.sys_id);
236

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

rswindell's avatar
rswindell committed
252
253
254
	if(!strcmp(sp,"TIMEZONE"))
		return(smb_zonestr(sys_timezone(&cfg),str));

255
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
256
		return(unixtodstr(&cfg,time32(NULL),str));
257
	}
258

rswindell's avatar
rswindell committed
259
260
261
	if(!strcmp(sp,"DATETIME"))
		return(timestr(time(NULL)));

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

270
	if(!strcmp(sp,"TUSER")) {
271
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
272
273
		return(str);
	}
274

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

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

289
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
290
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
291
		return(lastuseron);
292

293
	if(!strcmp(sp,"CLS")) {
294
		CLS;
295
296
		return(nulstr);
	}
297

298
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
299
		pause();
300
301
		return(nulstr);
	}
302

303
	if(!strcmp(sp,"RESETPAUSE")) {
304
		lncntr=0;
305
306
		return(nulstr);
	}
307

308
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
309
		sys_status^=SS_PAUSEOFF;
310
311
		return(nulstr);
	}
312

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

	/* NOSTOP */

	/* STOP */

322
323
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
324

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

	/* LASTCALL */

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

342
	if(!strcmp(sp,"WHO")) {
343
		whos_online(true);
344
345
		return(nulstr);
	}
346
347
348

	/* User Codes */

349
350
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
351

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

359
	if(!strcmp(sp,"USERNUM")) {
360
		safe_snprintf(str,maxlen,"%u",useron.number);
361
362
		return(str);
	}
363

364
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
365
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
366
		return(useron.phone);
367

368
369
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
370

371
372
	if(!strcmp(sp,"FROM"))
		return(useron.location);
373

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

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

395
396
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
397

398
399
	if(!strcmp(sp,"HOST"))
		return(client_name);
400

401
402
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
403

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

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

414
415
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
416

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

422
423
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
424

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

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

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

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

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

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

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

458
	if(!strcmp(sp,"LASTON"))
459
		return(timestr(useron.laston));
460

461
462
	if(!strcmp(sp,"LASTDATEON"))
		return(unixtodstr(&cfg,useron.laston,str));
463

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

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

483
	if(!strcmp(sp,"MSGREAD")) {
484
		safe_snprintf(str,maxlen,"%lu",posts_read);
485
486
		return(str);
	}
487

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

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

498
	if(!strcmp(sp,"UPBYTES")) {
499
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
500
501
		return(str);
	}
502

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

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

513
	if(!strcmp(sp,"DLBYTES")) {
514
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
515
516
		return(str);
	}
517

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

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

528
	if(!strcmp(sp,"LASTNEW"))
529
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
530

531
	if(!strcmp(sp,"NEWFILETIME"))
532
		return(timestr(ns_time));
533
534
535

	/* MAXDL */

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

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

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

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

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

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

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

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

578
579
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
580

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

590
591
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
592

593
594
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
595

596
597
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
598

599
	if(!strcmp(sp,"HANGUP")) {
600
		hangup();
601
602
		return(nulstr);
	}
603
604
605

	/* Synchronet Specific */

606
	if(!strncmp(sp,"SETSTR:",7)) {
607
		strcpy(main_csi.str,sp+7);
608
609
		return(nulstr);
	}
610

611
	if(!strncmp(sp,"EXEC:",5)) {
612
		exec_bin(sp+5,&main_csi);
613
614
		return(nulstr);
	}
615

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

625
	if(!strncmp(sp,"MENU:",5)) {
626
		menu(sp+5);
627
628
		return(nulstr);
	}
629

630
631
632
633
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
634

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

640
641
	if(!strcmp(sp,"QUESTION"))
		return(question);
642

643
644
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
645

646
647
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
648

deuce's avatar
deuce committed
649
650
	if(!strcmp(sp,"LOCAL-IP"))
		return(local_addr);
651

652
653
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
654

655
	if(!strcmp(sp,"PUSHXY")) {
656
		ansi_save();
657
658
		return(nulstr);
	}
659

660
	if(!strcmp(sp,"POPXY")) {
661
		ansi_restore();
662
663
		return(nulstr);
	}
664

665
	if(!strncmp(sp,"UP:",3)) {
666
		cursor_up(atoi(sp+3));
667
668
		return(str);
	}
669

670
	if(!strncmp(sp,"DOWN:",5)) {
671
		cursor_down(atoi(sp+5));
672
673
		return(str);
	}
674

675
	if(!strncmp(sp,"LEFT:",5)) {
676
		cursor_left(atoi(sp+5));
677
678
		return(str);
	}
679

680
	if(!strncmp(sp,"RIGHT:",6)) {
681
		cursor_right(atoi(sp+6));
682
683
		return(str);
	}
684

685
	if(!strncmp(sp,"GOTOXY:",7)) {
686
687
688
		tp=strchr(sp,',');
		if(tp!=NULL) {
			tp++;
689
			ansi_gotoxy(atoi(sp+7),atoi(tp));
690
		}
691
		return(nulstr);
692
693
	}

694
695
696
697
698
699
700
	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);
		}
701
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
702
	}
703

704
705
706
707
708
709
710
	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);
		}
711
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->lname : nulstr);
712
	}
713

714
	if(!strcmp(sp,"GN")) {
715
716
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
717
		else
718
			ugrp=usrgrps ? curgrp+1 : 0;
719
		safe_snprintf(str,maxlen,"%u",ugrp);
720
721
		return(str);
	}
722

723
	if(!strcmp(sp,"GL")) {
724
725
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
726
		else
727
			ugrp=usrgrps ? curgrp+1 : 0;
728
		safe_snprintf(str,maxlen,"%-4u",ugrp);
729
730
		return(str);
	}
731

732
	if(!strcmp(sp,"GR")) {
733
734
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
735
		else
736
			ugrp=usrgrps ? curgrp+1 : 0;
737
		safe_snprintf(str,maxlen,"%4u",ugrp);
738
739
		return(str);
	}
740

741
742
743
744
745
746
747
	if(!strcmp(sp,"SUB")) {
		if(SMB_IS_OPEN(&smb)) {
			if(smb.subnum==INVALID_SUB)
				return("Mail");
			else if(smb.subnum<cfg.total_subs)
				return(cfg.sub[smb.subnum]->sname);
		}
748
		return(usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
749
	}
750

751
752
753
754
755
756
757
	if(!strcmp(sp,"SUBL")) {
		if(SMB_IS_OPEN(&smb)) {
			if(smb.subnum==INVALID_SUB)
				return("Mail");
			else if(smb.subnum<cfg.total_subs)
				return(cfg.sub[smb.subnum]->lname);
		}
758
		return(usrgrps  ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->lname : nulstr);
759
	}