atcodes.cpp 25.8 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 2008 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(char *instr)
52
{
53
	char	str[128],str2[128],*p,*tp,*sp;
54
    int     len;
55
	int		disp_len;
56
57
	bool	padded_left=false;
	bool	padded_right=false;
58

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

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

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

	if(padded_left)
86
		rprintf("%-*.*s",disp_len,disp_len,p);
87
	else if(padded_right)
88
		rprintf("%*.*s",disp_len,disp_len,p);
89
90
91
92
93
94
	else
		rputs(p);

	return(len);
}

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

	str[0]=0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

240
	if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
241
		now=time(NULL);
242
		return(unixtodstr(&cfg,now,str));
243
	}
244

245
	if(!strcmp(sp,"TMSG")) {
246
247
		l=0;
		for(i=0;i<cfg.total_subs;i++)
248
			l+=getposts(&cfg,i); 		/* l=total posts */
249
		safe_snprintf(str,maxlen,"%lu",l);
250
251
		return(str);
	}
252

253
	if(!strcmp(sp,"TUSER")) {
254
		safe_snprintf(str,maxlen,"%u",total_users(&cfg));
255
256
		return(str);
	}
257

258
	if(!strcmp(sp,"TFILE")) {
259
260
		l=0;
		for(i=0;i<cfg.total_dirs;i++)
261
			l+=getfiles(&cfg,i);
262
		safe_snprintf(str,maxlen,"%lu",l);
263
264
		return(str);
	}
265

266
	if(!strcmp(sp,"TCALLS") || !strcmp(sp,"NUMCALLS")) {
267
		getstats(&cfg,0,&stats);
268
		safe_snprintf(str,maxlen,"%lu",stats.logons);
269
270
		return(str);
	}
271

272
	if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
273
		|| !strcmp(sp,"LASTCALLERSYSTEM"))
274
		return(lastuseron);
275

276
	if(!strcmp(sp,"CLS")) {
277
		CLS;
278
279
		return(nulstr);
	}
280

281
	if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
282
		pause();
283
284
		return(nulstr);
	}
285

286
	if(!strcmp(sp,"RESETPAUSE")) {
287
		lncntr=0;
288
289
		return(nulstr);
	}
290

291
	if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
292
		sys_status^=SS_PAUSEOFF;
293
294
		return(nulstr);
	}
295

296
	if(!strcmp(sp,"PON") || !strcmp(sp,"AUTOMORE")) {
297
		sys_status^=SS_PAUSEON;
298
299
		return(nulstr);
	}
300
301
302
303
304

	/* NOSTOP */

	/* STOP */

305
306
	if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
		return("\a");
307

308
309
310
	if(!strcmp(sp,"EVENT")) {
		if(event_time==0)
			return("<none>");
311
		return(timestr(event_time));
312
	}
313
314
315

	/* LASTCALL */

316
	if(!strncmp(sp,"NODE",4)) {
317
318
319
		i=atoi(sp+4);
		if(i && i<=cfg.sys_nodes) {
			getnodedat(i,&node,0);
320
321
			printnodedat(i,&node);
		}
322
323
		return(nulstr);
	}
324

325
	if(!strcmp(sp,"WHO")) {
326
		whos_online(true);
327
328
		return(nulstr);
	}
329
330
331

	/* User Codes */

332
333
	if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
		return(useron.alias);
334

335
	if(!strcmp(sp,"FIRST")) {
336
		safe_snprintf(str,maxlen,"%s",useron.alias);
337
		tp=strchr(str,' ');
338
		if(tp) *tp=0;
339
		return(str);
340
	}
341

342
	if(!strcmp(sp,"USERNUM")) {
343
		safe_snprintf(str,maxlen,"%u",useron.number);
344
345
		return(str);
	}
346

347
	if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
348
		|| !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
349
		return(useron.phone);
350

351
352
	if(!strcmp(sp,"ADDR1"))
		return(useron.address);
353

354
355
	if(!strcmp(sp,"FROM"))
		return(useron.location);
356

357
	if(!strcmp(sp,"CITY")) {
358
		safe_snprintf(str,maxlen,"%s",useron.location);
359
		char* p=strchr(str,',');
360
361
		if(p) {
			*p=0;
362
363
			return(str);
		}
364
365
		return(nulstr);
	}
366

367
368
	if(!strcmp(sp,"STATE")) {
		char* p=strchr(useron.location,',');
369
370
		if(p) {
			p++;
371
			if(*p==' ')
372
				p++;
373
374
			return(p);
		}
375
376
		return(nulstr);
	}
377

378
379
	if(!strcmp(sp,"CPU"))
		return(useron.comp);
380

381
382
	if(!strcmp(sp,"HOST"))
		return(client_name);
383

384
385
	if(!strcmp(sp,"BDATE"))
		return(useron.birth);
386

387
	if(!strcmp(sp,"AGE")) {
388
		safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
389
390
		return(str);
	}
rswindell's avatar
rswindell committed
391

392
	if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
393
		safe_snprintf(str,maxlen,"%u",useron.logons);
394
395
		return(str);
	}
396

397
398
	if(!strcmp(sp,"MEMO"))
		return(unixtodstr(&cfg,useron.pwmod,str));
399

400
	if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
401
		safe_snprintf(str,maxlen,"%u",useron.level);
402
403
		return(str);
	}
404

405
406
	if(!strcmp(sp,"SINCE"))
		return(unixtodstr(&cfg,useron.firston,str));
407

408
	if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
409
		now=time(NULL);
410
		safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
411
412
		return(str);
	}
413

414
	if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
415
		now=time(NULL);
416
		return(sectostr(now-logontime,str)+1);
417
	}
418

419
	if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
420
		gettimeleft();
421
		return(sectostr(timeleft,str)+1);
422
	}
423

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

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

430
	if(!strcmp(sp,"TIMELIMIT")) {
431
		safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
432
433
		return(str);
	}
434

435
	if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
436
		gettimeleft();
437
		safe_snprintf(str,maxlen,"%lu",timeleft/60);
438
439
		return(str);
	}
440

441
	if(!strcmp(sp,"LASTON"))
442
		return(timestr(useron.laston));
443

444
445
	if(!strcmp(sp,"LASTDATEON"))
		return(unixtodstr(&cfg,useron.laston,str));
446

447
	if(!strcmp(sp,"LASTTIMEON")) {
448
449
		memset(&tm,0,sizeof(tm));
		localtime_r(&useron.laston,&tm);
450
		safe_snprintf(str,maxlen,"%02d:%02d %s"
451
452
			,tm.tm_hour==0 ? 12
			: tm.tm_hour>12 ? tm.tm_hour-12
453
			: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
454
		return(str);
455
456
	}

457
	if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
458
		safe_snprintf(str,maxlen,"%u",useron.posts);
459
460
		return(str);
	}
461

462
	if(!strcmp(sp,"MSGREAD")) {
463
		safe_snprintf(str,maxlen,"%lu",posts_read);
464
465
		return(str);
	}
466

467
	if(!strcmp(sp,"FREESPACE")) {
468
		safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
469
470
471
472
		return(str);
	}

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

477
	if(!strcmp(sp,"UPBYTES")) {
478
		safe_snprintf(str,maxlen,"%lu",useron.ulb);
479
480
		return(str);
	}
481

482
	if(!strcmp(sp,"UPK")) {
483
		safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
484
485
		return(str);
	}
486

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

492
	if(!strcmp(sp,"DLBYTES")) {
493
		safe_snprintf(str,maxlen,"%lu",useron.dlb);
494
495
		return(str);
	}
496

497
	if(!strcmp(sp,"DOWNK")) {
498
		safe_snprintf(str,maxlen,"%lu",useron.dlb/1024L);
499
500
		return(str);
	}
501

502
	if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
503
		safe_snprintf(str,maxlen,"%u",useron.dls);
504
505
		return(str);
	}
506

507
508
	if(!strcmp(sp,"LASTNEW"))
		return(unixtodstr(&cfg,ns_time,str));
509

510
	if(!strcmp(sp,"NEWFILETIME"))
511
		return(timestr(ns_time));
512
513
514

	/* MAXDL */

515
	if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
516
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
517
518
		return(str);
	}
519

520
	if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
521
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
522
523
		return(str);
	}
524

525
	if(!strcmp(sp,"BYTELIMIT")) {
526
		safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
527
528
		return(str);
	}
529

530
	if(!strcmp(sp,"KBLEFT")) {
531
		safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
532
533
		return(str);
	}
534

535
	if(!strcmp(sp,"BYTESLEFT")) {
536
		safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
537
538
		return(str);
	}
539

540
	if(!strcmp(sp,"CONF")) {
541
		safe_snprintf(str,maxlen,"%s %s"
542
543
			,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
			,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
544
545
		return(str);
	}
546

547
	if(!strcmp(sp,"CONFNUM")) {
548
		safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
549
550
		return(str);
	}
551

552
	if(!strcmp(sp,"NUMDIR")) {
553
		safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
554
555
		return(str);
	}
556

557
558
	if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
		return(unixtodstr(&cfg,useron.expire,str));
559

560
	if(!strcmp(sp,"EXPDAYS")) {
561
562
563
564
		now=time(NULL);
		l=useron.expire-now;
		if(l<0)
			l=0;
565
		safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
566
567
		return(str);
	}
568

569
570
	if(!strcmp(sp,"MEMO1"))
		return(useron.note);
571

572
573
	if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
		return(useron.name);
574

575
576
	if(!strcmp(sp,"ZIP"))
		return(useron.zipcode);
577

578
	if(!strcmp(sp,"HANGUP")) {
579
		hangup();
580
581
		return(nulstr);
	}
582
583
584

	/* Synchronet Specific */

585
	if(!strncmp(sp,"SETSTR:",7)) {
586
		strcpy(main_csi.str,sp+7);
587
588
		return(nulstr);
	}
589

590
	if(!strncmp(sp,"EXEC:",5)) {
591
		exec_bin(sp+5,&main_csi);
592
593
		return(nulstr);
	}
594

595
	if(!strncmp(sp,"EXEC_XTRN:",10)) {
596
		for(i=0;i<cfg.total_xtrns;i++)
597
			if(!stricmp(cfg.xtrn[i]->code,sp+10))
598
599
600
601
602
603
				break;
		if(i<cfg.total_xtrns)
			exec_xtrn(i);
		return(nulstr);
	}

604
	if(!strncmp(sp,"MENU:",5)) {
605
		menu(sp+5);
606
607
		return(nulstr);
	}
608

609
610
611
612
	if(!strncmp(sp,"TYPE:",5)) {
		printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
		return(nulstr);
	}
613

614
	if(!strncmp(sp,"INCLUDE:",5)) {
615
		printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
616
617
618
		return(nulstr);
	}

619
620
	if(!strcmp(sp,"QUESTION"))
		return(question);
621

622
623
	if(!strcmp(sp,"HANDLE"))
		return(useron.handle);
624

625
626
	if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
		return(cid);
627

628
	if(!strcmp(sp,"LOCAL-IP")) {
629
		struct in_addr in_addr;
630
		in_addr.s_addr=local_addr;
631
		return(inet_ntoa(in_addr));
632
633
	}

634
635
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
636

637
	if(!strcmp(sp,"PUSHXY")) {
638
		ANSI_SAVE();
639
640
		return(nulstr);
	}
641

642
	if(!strcmp(sp,"POPXY")) {
643
		ANSI_RESTORE();
644
645
		return(nulstr);
	}
646

647
	if(!strcmp(sp,"UP"))
648
		return("\x1b[A");
649

650
	if(!strcmp(sp,"DOWN"))
651
		return("\x1b[B");
652

653
	if(!strcmp(sp,"RIGHT"))
654
		return("\x1b[C");
655

656
	if(!strcmp(sp,"LEFT"))
657
		return("\x1b[D");
658

659
	if(!strncmp(sp,"UP:",3)) {
660
		safe_snprintf(str,maxlen,"\x1b[%dA",atoi(sp+3));
661
662
		return(str);
	}
663

664
	if(!strncmp(sp,"DOWN:",5)) {
665
		safe_snprintf(str,maxlen,"\x1b[%dB",atoi(sp+5));
666
667
		return(str);
	}
668

669
	if(!strncmp(sp,"LEFT:",5)) {
670
		safe_snprintf(str,maxlen,"\x1b[%dC",atoi(sp+5));
671
672
		return(str);
	}
673

674
	if(!strncmp(sp,"RIGHT:",6)) {
675
		safe_snprintf(str,maxlen,"\x1b[%dD",atoi(sp+6));
676
677
		return(str);
	}
678

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

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

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

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

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

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

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

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