atcodes.cpp 27.7 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 2014 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
151
152
153
		time_t up=0;
		now = time(NULL);
		if (uptime != 0 && now >= uptime)
			up = now-uptime;
154
155
		char   days[64]="";
		if((up/(24*60*60))>=2) {
156
	        sprintf(days,"%lu days ",(ulong)(up/(24L*60L*60L)));
157
158
			up%=(24*60*60);
		}
159
		safe_snprintf(str,maxlen,"%s%lu:%02lu"
160
	        ,days
161
162
			,(ulong)(up/(60L*60L))
			,(ulong)((up/60L)%60L)
163
			);
164
		return(str);
165
166
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	/* NOSTOP */

	/* STOP */

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

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

	/* LASTCALL */

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

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

	/* User Codes */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	/* MAXDL */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	/* Synchronet Specific */

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

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

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

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

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

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

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

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

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

deuce's avatar
deuce committed
639
640
	if(!strcmp(sp,"LOCAL-IP"))
		return(local_addr);
641

642
643
	if(!strcmp(sp,"CRLF"))
		return("\r\n");
644

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

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

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

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

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

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

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

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

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

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

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

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

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

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

751
	if(!strcmp(sp,"SN")) {
752
753
754
755
		if(SMB_IS_OPEN(&smb))
			usub=getusrsub(smb.subnum);
		else
			usub=usrgrps ? cursub[curgrp]+1 : 0;
rswindell's avatar