atcodes.cpp 26 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 2011 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
	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
78
	if(p!=NULL) {
		if(*(p+2) && isdigit(*(p+2)))
			disp_len=atoi(p+2);
79
		*p=0;
80
	}
81

82
83
	cp=atcode(sp,str2,sizeof(str2));
	if(cp==NULL)
84
85
86
		return(0);

	if(padded_left)
87
		bprintf("%-*.*s",disp_len,disp_len,cp);
88
	else if(padded_right)
89
		bprintf("%*.*s",disp_len,disp_len,cp);
90
	else
91
		bputs(cp);
92
93
94
95

	return(len);
}

96
const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
97
98
99
{
	char*	tp;
	uint	i;
100
101
	uint	ugrp;
	uint	usub;
102
103
104
105
106
107
108
	long	l;
    stats_t stats;
    node_t  node;
	struct	tm tm;

	str[0]=0;

109
	if(!strcmp(sp,"VER"))
110
		return(VERSION);
111

112
	if(!strcmp(sp,"REV")) {
113
		safe_snprintf(str,maxlen,"%c",REVISION);
114
115
		return(str);
	}
116

117
	if(!strcmp(sp,"FULL_VER")) {
118
		safe_snprintf(str,maxlen,"%s%c%s",VERSION,REVISION,beta_version);
119
		truncsp(str);
120
#if defined(_DEBUG)
121
		strcat(str," Debug");
122
#endif
123
		return(str);
124
125
	}

126
	if(!strcmp(sp,"VER_NOTICE"))
127
		return(VERSION_NOTICE);
128

129
130
	if(!strcmp(sp,"OS_VER"))
		return(os_version(str));
131
132

#ifdef JAVASCRIPT
133
134
	if(!strcmp(sp,"JS_VER"))
		return((char *)JS_GetImplementationVersion());
135
136
#endif

137
138
	if(!strcmp(sp,"PLATFORM"))
		return(PLATFORM_DESC);
139

140
141
	if(!strcmp(sp,"COPYRIGHT"))
		return(COPYRIGHT_NOTICE);
142

143
	if(!strcmp(sp,"COMPILER")) {
144
		DESCRIBE_COMPILER(str);
145
		return(str);
146
147
	}

148
	if(!strcmp(sp,"UPTIME")) {
149
		extern volatile time_t uptime;
150
		time_t up=time(NULL)-uptime;
151
152
		if(up<0)
			up=0;
153
154
		char   days[64]="";
		if((up/(24*60*60))>=2) {
155
	        sprintf(days,"%lu days ",(ulong)(up/(24L*60L*60L)));
156
157
			up%=(24*60*60);
		}
158
		safe_snprintf(str,maxlen,"%s%lu:%02lu"
159
	        ,days
160
161
			,(ulong)(up/(60L*60L))
			,(ulong)((up/60L)%60L)
162
			);
163
		return(str);
164
165
	}

166
	if(!strcmp(sp,"SERVED")) {
167
		extern volatile ulong served;
168
		safe_snprintf(str,maxlen,"%lu",served);
169
170
171
		return(str);
	}

172
	if(!strcmp(sp,"SOCKET_LIB"))
173
		return(socklib_version(str,SOCKLIB_DESC));
174

175
	if(!strcmp(sp,"MSG_LIB")) {
176
		safe_snprintf(str,maxlen,"SMBLIB %s",smb_lib_ver());
177
178
		return(str);
	}
179

180
181
	if(!strcmp(sp,"BBS") || !strcmp(sp,"BOARDNAME"))
		return(cfg.sys_name);
182

183
	if(!strcmp(sp,"BAUD") || !strcmp(sp,"BPS")) {
184
		safe_snprintf(str,maxlen,"%lu",cur_rate);
185
186
		return(str);
	}
187

188
189
	if(!strcmp(sp,"CONN"))
		return(connection);
190

191
192
	if(!strcmp(sp,"SYSOP"))
		return(cfg.sys_op);
193

194
195
	if(!strcmp(sp,"LOCATION"))
		return(cfg.sys_location);
196

197
	if(!strcmp(sp,"NODE")) {
198
		safe_snprintf(str,maxlen,"%u",cfg.node_num);
199
200
		return(str);
	}
201

202
	if(!strcmp(sp,"TNODE")) {
203
		safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
204
205
		return(str);
	}
206

207
208
	if(!strcmp(sp,"INETADDR"))
		return(cfg.sys_inetaddr);
209

210
211
212
	if(!strcmp(sp,"HOSTNAME"))
		return(startup->host_name);

213
	if(!strcmp(sp,"FIDOADDR")) {
214
		if(cfg.total_faddrs)
215
			return(smb_faddrtoa(&cfg.faddr[0],str));
216
		return(nulstr);
217
218
	}

219
	if(!strcmp(sp,"EMAILADDR"))
220
		return(usermailaddr(&cfg, str
221
			,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name));
222

223
224
	if(!strcmp(sp,"QWKID"))
		return(cfg.sys_id);
225

226
	if(!strcmp(sp,"TIME") || !strcmp(sp,"SYSTIME")) {
227
		now=time(NULL);
228
		memset(&tm,0,sizeof(tm));
229
		localtime_r(&now,&tm);
230
		if(cfg.sys_misc&SM_MILITARY)
231
232
			safe_snprintf(str,maxlen,"%02d:%02d:%02d"
		        	,tm.tm_hour,tm.tm_min,tm.tm_sec);
233
		else
234
			safe_snprintf(str,maxlen,"%02d:%02d %s"
235
236
237
				,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");
238
		return(str);
239
240
	}

rswindell's avatar
rswindell committed
241
242
243
	if(!strcmp(sp,"TIMEZONE"))
		return(smb_zonestr(sys_timezone(&cfg),str));

244
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
245
		return(unixtodstr(&cfg,time32(NULL),str));
246
	}
247

rswindell's avatar
rswindell committed
248
249
250
	if(!strcmp(sp,"DATETIME"))
		return(timestr(time(NULL)));

251
	if(!strcmp(sp,"TMSG")) {
252
253
		l=0;
		for(i=0;i<cfg.total_subs;i++)
254
			l+=getposts(&cfg,i); 		/* l=total posts */
255
		safe_snprintf(str,maxlen,"%lu",l);
256
257
		return(str);
	}
258

259
	if(!strcmp(sp,"TUSER")) {
260
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
261
262
		return(str);
	}
263

264
	if(!strcmp(sp,"TFILE")) {
265
266
		l=0;
		for(i=0;i<cfg.total_dirs;i++)
267
			l+=getfiles(&cfg,i);
268
		safe_snprintf(str,maxlen,"%lu",l);
269
270
		return(str);
	}
271

272
	if(!strcmp(sp,"TCALLS") || !strcmp(sp,"NUMCALLS")) {
273
		getstats(&cfg,0,&stats);
274
		safe_snprintf(str,maxlen,"%lu",stats.logons);
275
276
		return(str);
	}
277

278
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
279
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
280
		return(lastuseron);
281

282
	if(!strcmp(sp,"CLS")) {
283
		CLS;
284
285
		return(nulstr);
	}
286

287
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
288
		pause();
289
290
		return(nulstr);
	}
291

292
	if(!strcmp(sp,"RESETPAUSE")) {
293
		lncntr=0;
294
295
		return(nulstr);
	}
296

297
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
298
		sys_status^=SS_PAUSEOFF;
299
300
		return(nulstr);
	}
301

302
	if(!strcmp(sp,"PON") || !strcmp(sp,"AUTOMORE")) {
303
		sys_status^=SS_PAUSEON;
304
305
		return(nulstr);
	}
306
307
308
309
310

	/* NOSTOP */

	/* STOP */

311
312
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
313

314
315
316
	if(!strcmp(sp,"EVENT")) {
		if(event_time==0)
			return("<none>");
317
		return(timestr(event_time));
318
	}
319
320
321

	/* LASTCALL */

322
	if(!strncmp(sp,"NODE",4)) {
323
324
325
		i=atoi(sp+4);
		if(i && i<=cfg.sys_nodes) {
			getnodedat(i,&node,0);
326
327
			printnodedat(i,&node);
		}
328
329
		return(nulstr);
	}
330

331
	if(!strcmp(sp,"WHO")) {
332
		whos_online(true);
333
334
		return(nulstr);
	}
335
336
337

	/* User Codes */

338
339
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
340

341
	if(!strcmp(sp,"FIRST")) {
342
		safe_snprintf(str,maxlen,"%s",useron.alias);
343
		tp=strchr(str,' ');
344
		if(tp) *tp=0;
345
		return(str);
346
	}
347

348
	if(!strcmp(sp,"USERNUM")) {
349
		safe_snprintf(str,maxlen,"%u",useron.number);
350
351
		return(str);
	}
352

353
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
354
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
355
		return(useron.phone);
356

357
358
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
359

360
361
	if(!strcmp(sp,"FROM"))
		return(useron.location);
362

363
	if(!strcmp(sp,"CITY")) {
364
		safe_snprintf(str,maxlen,"%s",useron.location);
365
		char* p=strchr(str,',');
366
367
		if(p) {
			*p=0;
368
369
			return(str);
		}
370
371
		return(nulstr);
	}
372

373
374
	if(!strcmp(sp,"STATE")) {
		char* p=strchr(useron.location,',');
375
376
		if(p) {
			p++;
377
			if(*p==' ')
378
				p++;
379
380
			return(p);
		}
381
382
		return(nulstr);
	}
383

384
385
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
386

387
388
	if(!strcmp(sp,"HOST"))
		return(client_name);
389

390
391
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
392

393
	if(!strcmp(sp,"AGE")) {
394
		safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
395
396
		return(str);
	}
rswindell's avatar
rswindell committed
397

398
	if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
399
		safe_snprintf(str,maxlen,"%u",useron.logons);
400
401
		return(str);
	}
402

403
404
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
405

406
	if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
407
		safe_snprintf(str,maxlen,"%u",useron.level);
408
409
		return(str);
	}
410

411
412
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
413

414
	if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
415
		now=time(NULL);
416
		safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
417
418
		return(str);
	}
419

420
	if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
421
		now=time(NULL);
422
		return(sectostr((uint)(now-logontime),str)+1);
423
	}
424

425
	if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
426
		gettimeleft();
427
		return(sectostr(timeleft,str)+1);
428
	}
429

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

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

436
	if(!strcmp(sp,"TIMELIMIT")) {
437
		safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
438
439
		return(str);
	}
440

441
	if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
442
		gettimeleft();
443
		safe_snprintf(str,maxlen,"%lu",timeleft/60);
444
445
		return(str);
	}
446

447
	if(!strcmp(sp,"LASTON"))
448
		return(timestr(useron.laston));
449

450
451
	if(!strcmp(sp,"LASTDATEON"))
		return(unixtodstr(&cfg,useron.laston,str));
452

453
	if(!strcmp(sp,"LASTTIMEON")) {
454
		memset(&tm,0,sizeof(tm));
455
		localtime32(&useron.laston,&tm);
456
457
458
459
460
461
462
463
		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");
464
		return(str);
465
466
	}

467
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
468
		safe_snprintf(str,maxlen,"%u",useron.posts);
469
470
		return(str);
	}
471

472
	if(!strcmp(sp,"MSGREAD")) {
473
		safe_snprintf(str,maxlen,"%lu",posts_read);
474
475
		return(str);
	}
476

477
	if(!strcmp(sp,"FREESPACE")) {
478
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
479
480
481
482
		return(str);
	}

	if(!strcmp(sp,"FREESPACEK")) {
483
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,1024));
484
485
		return(str);
	}
486

487
	if(!strcmp(sp,"UPBYTES")) {
488
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
489
490
		return(str);
	}
491

492
	if(!strcmp(sp,"UPK")) {
493
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
494
495
		return(str);
	}
496

497
	if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
498
		safe_snprintf(str,maxlen,"%u",useron.uls);
499
500
		return(str);
	}
501

502
	if(!strcmp(sp,"DLBYTES")) {
503
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
504
505
		return(str);
	}
506

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

512
	if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
513
		safe_snprintf(str,maxlen,"%u",useron.dls);
514
515
		return(str);
	}
516

517
	if(!strcmp(sp,"LASTNEW"))
518
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
519

520
	if(!strcmp(sp,"NEWFILETIME"))
521
		return(timestr(ns_time));
522
523
524

	/* MAXDL */

525
	if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
526
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
527
528
		return(str);
	}
529

530
	if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
531
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
532
533
		return(str);
	}
534

535
	if(!strcmp(sp,"BYTELIMIT")) {
536
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
537
538
		return(str);
	}
539

540
	if(!strcmp(sp,"KBLEFT")) {
541
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
542
543
		return(str);
	}
544

545
	if(!strcmp(sp,"BYTESLEFT")) {
546
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
547
548
		return(str);
	}
549

550
	if(!strcmp(sp,"CONF")) {
551
		safe_snprintf(str,maxlen,"%s %s"
552
553
			,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
			,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
554
555
		return(str);
	}
556

557
	if(!strcmp(sp,"CONFNUM")) {
558
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
559
560
		return(str);
	}
561

562
	if(!strcmp(sp,"NUMDIR")) {
563
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
564
565
		return(str);
	}
566

567
568
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
569

570
	if(!strcmp(sp,"EXPDAYS")) {
571
		now=time(NULL);
572
		l=(long)(useron.expire-now);
573
574
		if(l<0)
			l=0;
575
		safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
576
577
		return(str);
	}
578

579
580
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
581

582
583
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
584

585
586
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
587

588
	if(!strcmp(sp,"HANGUP")) {
589
		hangup();
590
591
		return(nulstr);
	}
592
593
594

	/* Synchronet Specific */

595
	if(!strncmp(sp,"SETSTR:",7)) {
596
		strcpy(main_csi.str,sp+7);
597
598
		return(nulstr);
	}
599

600
	if(!strncmp(sp,"EXEC:",5)) {
601
		exec_bin(sp+5,&main_csi);
602
603
		return(nulstr);
	}
604

605
	if(!strncmp(sp,"EXEC_XTRN:",10)) {
606
		for(i=0;i<cfg.total_xtrns;i++)
607
			if(!stricmp(cfg.xtrn[i]->code,sp+10))
608
609
610
611
612
613
				break;
		if(i<cfg.total_xtrns)
			exec_xtrn(i);
		return(nulstr);
	}

614
	if(!strncmp(sp,"MENU:",5)) {
615
		menu(sp+5);
616
617
		return(nulstr);
	}
618

619
620
621
622
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
623

624
	if(!strncmp(sp,"INCLUDE:",8)) {
625
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
626
627
628
		return(nulstr);
	}

629
630
	if(!strcmp(sp,"QUESTION"))
		return(question);
631

632
633
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
634

635
636
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
637

638
	if(!strcmp(sp,"LOCAL-IP")) {
639
		struct in_addr in_addr;
640
		in_addr.s_addr=local_addr;
641
		return(inet_ntoa(in_addr));
642
643
	}

644
645
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
646

647
	if(!strcmp(sp,"PUSHXY")) {
648
		ansi_save();
649
650
		return(nulstr);
	}
651

652
	if(!strcmp(sp,"POPXY")) {
653
		ansi_restore();
654
655
		return(nulstr);
	}
656

657
	if(!strncmp(sp,"UP:",3)) {
658
		cursor_up(atoi(sp+3));
659
660
		return(str);
	}
661

662
	if(!strncmp(sp,"DOWN:",5)) {
663
		cursor_down(atoi(sp+5));
664
665
		return(str);
	}
666

667
	if(!strncmp(sp,"LEFT:",5)) {
668
		cursor_left(atoi(sp+5));
669
670
		return(str);
	}
671

672
	if(!strncmp(sp,"RIGHT:",6)) {
673
		cursor_right(atoi(sp+6));
674
675
		return(str);
	}
676

677
	if(!strncmp(sp,"GOTOXY:",7)) {
678
679
680
		tp=strchr(sp,',');
		if(tp!=NULL) {
			tp++;
681
			ansi_gotoxy(atoi(sp+7),atoi(tp));
682
		}
683
		return(nulstr);
684
685
	}

686
687
688
689
690
691
692
	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);
		}
693
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
694
	}
695

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

706
	if(!strcmp(sp,"GN")) {
707
708
		if(SMB_IS_OPEN(&smb))
			ugrp=getusrgrp(smb.subnum);
709
		else
710
			ugrp=usrgrps ? curgrp+1 : 0;
711
		safe_snprintf(str,maxlen,"%u",ugrp);
712
713
		return(str);
	}
714

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

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

733
734
735
736
737
738
739
	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);
		}
740
		return(usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
741
	}
742

743
744
745
746
747
748
749
	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);
		}
750
		return(usrgrps  ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->lname : nulstr);
751
	}