atcodes.cpp 25.9 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
			safe_snprintf(str,maxlen,"%02d:%02d"
232
233
		        	,tm.tm_hour,tm.tm_min);
		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
		safe_snprintf(str,maxlen,"%02d:%02d %s"
457
458
			,tm.tm_hour==0 ? 12
			: tm.tm_hour>12 ? tm.tm_hour-12
459
			: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
460
		return(str);
461
462
	}

463
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
464
		safe_snprintf(str,maxlen,"%u",useron.posts);
465
466
		return(str);
	}
467

468
	if(!strcmp(sp,"MSGREAD")) {
469
		safe_snprintf(str,maxlen,"%lu",posts_read);
470
471
		return(str);
	}
472

473
	if(!strcmp(sp,"FREESPACE")) {
474
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
475
476
477
478
		return(str);
	}

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

483
	if(!strcmp(sp,"UPBYTES")) {
484
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
485
486
		return(str);
	}
487

488
	if(!strcmp(sp,"UPK")) {
489
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
490
491
		return(str);
	}
492

493
	if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
494
		safe_snprintf(str,maxlen,"%u",useron.uls);
495
496
		return(str);
	}
497

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

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

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

513
	if(!strcmp(sp,"LASTNEW"))
514
		return(unixtodstr(&cfg,(time32_t)ns_time,str));
515

516
	if(!strcmp(sp,"NEWFILETIME"))
517
		return(timestr(ns_time));
518
519
520

	/* MAXDL */

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

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

531
	if(!strcmp(sp,"BYTELIMIT")) {
532
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
533
534
		return(str);
	}
535

536
	if(!strcmp(sp,"KBLEFT")) {
537
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
538
539
		return(str);
	}
540

541
	if(!strcmp(sp,"BYTESLEFT")) {
542
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
543
544
		return(str);
	}
545

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

553
	if(!strcmp(sp,"CONFNUM")) {
554
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
555
556
		return(str);
	}
557

558
	if(!strcmp(sp,"NUMDIR")) {
559
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
560
561
		return(str);
	}
562

563
564
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
565

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

575
576
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
577

578
579
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
580

581
582
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
583

584
	if(!strcmp(sp,"HANGUP")) {
585
		hangup();
586
587
		return(nulstr);
	}
588
589
590

	/* Synchronet Specific */

591
	if(!strncmp(sp,"SETSTR:",7)) {
592
		strcpy(main_csi.str,sp+7);
593
594
		return(nulstr);
	}
595

596
	if(!strncmp(sp,"EXEC:",5)) {
597
		exec_bin(sp+5,&main_csi);
598
599
		return(nulstr);
	}
600

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

610
	if(!strncmp(sp,"MENU:",5)) {
611
		menu(sp+5);
612
613
		return(nulstr);
	}
614

615
616
617
618
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
619

620
	if(!strncmp(sp,"INCLUDE:",8)) {
621
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
622
623
624
		return(nulstr);
	}

625
626
	if(!strcmp(sp,"QUESTION"))
		return(question);
627

628
629
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
630

631
632
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
633

634
	if(!strcmp(sp,"LOCAL-IP")) {
635
		struct in_addr in_addr;
636
		in_addr.s_addr=local_addr;
637
		return(inet_ntoa(in_addr));
638
639
	}

640
641
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
642

643
	if(!strcmp(sp,"PUSHXY")) {
644
		ansi_save();
645
646
		return(nulstr);
	}
647

648
	if(!strcmp(sp,"POPXY")) {
649
		ansi_restore();
650
651
		return(nulstr);
	}
652

653
	if(!strncmp(sp,"UP:",3)) {
654
		cursor_up(atoi(sp+3));
655
656
		return(str);
	}
657

658
	if(!strncmp(sp,"DOWN:",5)) {
659
		cursor_down(atoi(sp+5));
660
661
		return(str);
	}
662

663
	if(!strncmp(sp,"LEFT:",5)) {
664
		cursor_left(atoi(sp+5));
665
666
		return(str);
	}
667

668
	if(!strncmp(sp,"RIGHT:",6)) {
669
		cursor_right(atoi(sp+6));
670
671
		return(str);
	}
672

673
	if(!strncmp(sp,"GOTOXY:",7)) {
674
675
676
		tp=strchr(sp,',');
		if(tp!=NULL) {
			tp++;
677
			ansi_gotoxy(atoi(sp+7),atoi(tp));
678
		}
679
		return(nulstr);
680
681
	}

682
683
684
685
686
687
688
	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);
		}
689
		return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
690
	}
691

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

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

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

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

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

739
740
741
742
743
744
745
	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);
		}
746
		return(usrgrps  ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->lname : nulstr);