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 2010 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
150
		extern time_t uptime;
		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
167
	if(!strcmp(sp,"SERVED")) {
		extern DWORD 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
		now=time(NULL);
246
		return(unixtodstr(&cfg,now,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(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
456
		memset(&tm,0,sizeof(tm));
		localtime_r(&useron.laston,&tm);
457
		safe_snprintf(str,maxlen,"%02d:%02d %s"
458
459
			,tm.tm_hour==0 ? 12
			: tm.tm_hour>12 ? tm.tm_hour-12
460
			: tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
461
		return(str);
462
463
	}

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

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

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

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

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

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

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

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

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

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

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

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

	/* MAXDL */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	/* Synchronet Specific */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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