uedit.c 50.3 KB
Newer Older
1
/* uedit.c */
2
3
4
5
6
7
8
9
10
11
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
41
42
43
44
45

/* Synchronet for *nix user editor */

/* $Id$ */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
 * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html		*
 *																			*
 * 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 "conwrap.h"	/* this has to go BEFORE curses.h so getkey() can be macroed around */
#include <sys/types.h>
#include <time.h>
#ifdef __QNX__
#include <string.h>
#endif
#include <stdio.h>
46
#ifdef __unix__
47
#include <unistd.h>
48
49
50
#include <curses.h>
#include <sys/time.h>
#endif
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "genwrap.h"
#include "uifc.h"
#include "sbbsdefs.h"
#include "genwrap.h"	/* stricmp */
#include "dirwrap.h"	/* lock/unlock/sopen */
#include "filewrap.h"	/* lock/unlock/sopen */
#include "sbbs_ini.h"	/* INI parsing */
#include "scfglib.h"	/* SCFG files */
#include "ars_defs.h"	/* needed for SCFG files */
#include "userdat.h"	/* getnodedat() */

#define CTRL(x) (x&037)

deuce's avatar
deuce committed
64
65
66
67
68
struct user_list {
	char	info[MAX_OPLN];
	int		usernum;
};

69
70
71
72
/********************/
/* Global Variables */
/********************/
uifcapi_t uifc; /* User Interface (UIFC) Library API */
deuce's avatar
deuce committed
73
74
char YesStr[]="Yes";
char NoStr[]="No";
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

int lprintf(char *fmt, ...)
{
	va_list argptr;
	char sbuf[1024];
	int	len;

	va_start(argptr,fmt);
	len=vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
	sbuf[sizeof(sbuf)-1]=0;
	va_end(argptr);
	uifc.msg(sbuf);
	return(len);
}

void bail(int code)
{
    if(code) {
        puts("\nHit a key...");
        getch(); 
	}
    uifc.bail();

    exit(code);
}

void allocfail(uint size)
{
    printf("\7Error allocating %u bytes of memory.\n",size);
    bail(1);
}

void freeopt(char** opt)
{
	int i;

	for(i=0;i<(MAX_OPTS+1);i++)
		free(opt[i]);

	free(opt);
}

deuce's avatar
deuce committed
117
118
119
120
121
122
123
124
125
int confirm(char *prompt)
{
	int i=0;
	char *opt[3]={
		 YesStr
		,NoStr
		,""
	};

deuce's avatar
deuce committed
126
	i=uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&i,0,prompt,opt);
deuce's avatar
deuce committed
127
128
	if(i==0)
		return(1);
129
130
131
	if(i==-1)
		return(-1);
	return(0);
deuce's avatar
deuce committed
132
133
}

deuce's avatar
deuce committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/****************************************************************************/
/* Takes a string in the format HH:MM:SS and returns in seconds             */
/****************************************************************************/
time_t DLLCALL strtosec(char *str)
{
	char *p1;
	char *p2;
	long int hour=0;
	long int min=0;
	long int sec2=0;
	time_t	sec=0;

	hour=strtol(str,&p1,10);
	if(hour<0 || hour > 24)
		return(-1);
	if(*p1==':') {
		p1++;
		min=strtol(p1,&p2,10);
		if(min<0 || min > 59)
			return(-1);
		if(*p2==':') {
			p2++;
			sec2=strtol(p2,&p1,10);
			if(sec2 < 0 || sec2 > 59)
				return(-1);
		}
	}

	sec=hour*60*60;
	sec+=min*60;
	sec+=sec2;
	return(sec);
}

deuce's avatar
deuce committed
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
char *geteditor(char *edit)
{
	if(getenv("EDITOR")==NULL && (getenv("VISUAL")==NULL || getenv("DISPLAY")==NULL))
#ifdef __unix__
		strcpy(edit,"vi");
#else
		strcpy(edit,"notepad");
#endif
	else {
		if(getenv("DISPLAY")!=NULL && getenv("VISUAL")!=NULL)
			strcpy(edit,getenv("VISUAL"));
		else
			strcpy(edit,getenv("EDITOR"));
	}
	return(edit);
}

int do_cmd(char *cmd)
{
	int i;

#ifdef __unix__	
	endwin();
#endif
	i=system(cmd);
#ifdef __unix__
	refresh();
#endif
	return(i);
}

deuce's avatar
deuce committed
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/* Edit terminal settings
 *       Auto-Detect
 *       Extended ASCII
 *       ANSI
 *       Color
 *       RIP
 *       WIP
 *       Pause
 *       Hot Keys
 *       Spinning Cursor
 *       Number of Rows
 */
int edit_terminal(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
213
214
215
216
217
218
219
220
221
222
223
224
	int 	i,j;
	char 	**opt;
	char	str[256];

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
deuce's avatar
deuce committed
225
		getuserdat(cfg,user);
deuce's avatar
deuce committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
		i=0;
		sprintf(opt[i++],"Auto-detect:     %s",user->misc & AUTOTERM?"Yes":"No");
		sprintf(opt[i++],"Extended ASCII:  %s",user->misc & NO_EXASCII?"No":"Yes");
		sprintf(opt[i++],"ANSI:            %s",user->misc & ANSI?"Yes":"No");
		sprintf(opt[i++],"Colour:          %s",user->misc & COLOR?"Yes":"No");
		sprintf(opt[i++],"RIP:             %s",user->misc & RIP?"Yes":"No");
		sprintf(opt[i++],"WIP:             %s",user->misc & WIP?"Yes":"No");
		sprintf(opt[i++],"Pause:           %s",user->misc & UPAUSE?"Yes":"No");
		sprintf(opt[i++],"Hot Keys:        %s",user->misc & COLDKEYS?"No":"Yes");
		sprintf(opt[i++],"Spinning Cursor: %s",user->misc & SPIN?"Yes":"No");
		sprintf(str,"%u",user->rows);
		sprintf(opt[i++],"Number of Rows:  %s",user->rows?str:"Auto");
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Terminal Settings",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* Auto-detect */
				user->misc ^= AUTOTERM;
deuce's avatar
deuce committed
247
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
248
249
250
251
				break;
			case 1:
				/* EX-ASCII */
				user->misc ^= NO_EXASCII;
deuce's avatar
deuce committed
252
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
253
254
255
256
				break;
			case 2:
				/* ANSI */
				user->misc ^= ANSI;
deuce's avatar
deuce committed
257
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
258
259
260
261
				break;
			case 3:
				/* Colour */
				user->misc ^= COLOR;
deuce's avatar
deuce committed
262
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
263
264
265
266
				break;
			case 4:
				/* RIP */
				user->misc ^= RIP;
deuce's avatar
deuce committed
267
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
268
269
270
271
				break;
			case 5:
				/* WIP */
				user->misc ^= WIP;
deuce's avatar
deuce committed
272
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
273
274
275
276
				break;
			case 6:
				/* Pause */
				user->misc ^= UPAUSE;
deuce's avatar
deuce committed
277
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
278
279
280
281
				break;
			case 7:
				/* Hot Keys */
				user->misc ^= COLDKEYS;
deuce's avatar
deuce committed
282
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
283
284
285
286
				break;
			case 8:
				/* Spinning Cursor */
				user->misc ^= SPIN;
deuce's avatar
deuce committed
287
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
288
289
290
291
				break;
			case 9:
				/* Rows */
				sprintf(str,"%u",user->rows);
deuce's avatar
deuce committed
292
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Rows",str,2,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
293
294
				if(uifc.changes) {
					user->rows=strtoul(str,NULL,10);
deuce's avatar
deuce committed
295
					putuserrec(cfg,user->number,U_ROWS,2,ultoa(user->rows,str,10));
deuce's avatar
deuce committed
296
297
298
299
				}
				break;
		}
	}	
deuce's avatar
deuce committed
300
301
302
303
304
305
306
307
308
309
310
311
	return(0);
}

/* Edit Logon settings
 *       Ask for New Message Scan
 *       Ask for Your Message Scan
 *       Remember Current Sub-board
 *       Quiet Mode (Q exempt)
 *       Auto-Login via IP (V exempt)
 */
int edit_logon(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
312
313
	int 	i,j;
	char 	**opt;
deuce's avatar
deuce committed
314
	char	str[256];
deuce's avatar
deuce committed
315
316
317
318
319
320
321
322
323
324

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
		i=0;
deuce's avatar
deuce committed
325
		getuserdat(cfg,user);
deuce's avatar
deuce committed
326
327
328
329
330
331
332
333
334
335
336
337
338
339
		sprintf(opt[i++],"Ask for New Message Scan:    %s",user->misc & ASK_NSCAN?"Yes":"No");
		sprintf(opt[i++],"Ask for Your Message Scan:   %s",user->misc & ASK_SSCAN?"Yes":"No");
		sprintf(opt[i++],"Remember Current Sub:        %s",user->misc & CURSUB?"Yes":"No");
		sprintf(opt[i++],"Quiet Mode: (Q exempt)       %s",user->misc & QUIET?"Yes":"No");
		sprintf(opt[i++],"Auto-Login via IP (V exempt) %s",user->misc & AUTOLOGON?"Yes":"No");
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Logon Settings",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* Ask New MSG Scan */
				user->misc ^= ASK_NSCAN;
deuce's avatar
deuce committed
340
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
341
342
343
344
				break;
			case 1:
				/* Ask YOUR MSG scan */
				user->misc ^= ASK_SSCAN;
deuce's avatar
deuce committed
345
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
346
347
348
349
				break;
			case 2:
				/* Remember Curr Sub */
				user->misc ^= CURSUB;
deuce's avatar
deuce committed
350
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
351
352
353
354
				break;
			case 3:
				/* Quiet Mode */
				user->misc ^= QUIET;
deuce's avatar
deuce committed
355
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
356
357
358
359
				break;
			case 4:
				/* Auto-Login by IP */
				user->misc ^= AUTOLOGON;
deuce's avatar
deuce committed
360
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
361
362
363
				break;
		}
	}
deuce's avatar
deuce committed
364
365
366
367
368
369
370
371
372
373
374
375
	return(0);
}

/* Edit Chat Settings
 *       Multinode Chat Echo
 *       Multinode Chat Actions
 *       Available for Internode chat
 *       Multinode Activity Alerts
 *       Split-screen Private Chat
 */
int edit_chat(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
376
377
	int 	i,j;
	char 	**opt;
deuce's avatar
deuce committed
378
	char	str[256];
deuce's avatar
deuce committed
379
380
381
382
383
384
385
386
387
388

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
		i=0;
deuce's avatar
deuce committed
389
		getuserdat(cfg,user);
deuce's avatar
deuce committed
390
391
392
393
394
395
396
397
398
399
400
401
402
403
		sprintf(opt[i++],"Chat Echo:                 %s",user->chat & CHAT_ECHO?"Yes":"No");
		sprintf(opt[i++],"Chat Actions:              %s",user->chat & CHAT_ACTION?"Yes":"No");
		sprintf(opt[i++],"Available for Chat:        %s",user->chat & CHAT_NOPAGE?"No":"Yes");
		sprintf(opt[i++],"Activity Alerts            %s",user->chat & CHAT_NOACT?"No":"Yes");
		sprintf(opt[i++],"Split-Screen Private Chat: %s",user->chat & CHAT_SPLITP?"Yes":"No");
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Chat Settings",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* Chat Echo */
				user->chat ^= CHAT_ECHO;
deuce's avatar
deuce committed
404
				putuserrec(cfg,user->number,U_CHAT,8,ultoa(user->chat,str,16));
deuce's avatar
deuce committed
405
406
407
408
				break;
			case 1:
				/* Chat Actions */
				user->chat ^= CHAT_ACTION;
deuce's avatar
deuce committed
409
				putuserrec(cfg,user->number,U_CHAT,8,ultoa(user->chat,str,16));
deuce's avatar
deuce committed
410
411
412
413
				break;
			case 2:
				/* Availabe for Chat */
				user->chat ^= CHAT_NOPAGE;
deuce's avatar
deuce committed
414
				putuserrec(cfg,user->number,U_CHAT,8,ultoa(user->chat,str,16));
deuce's avatar
deuce committed
415
416
417
418
				break;
			case 3:
				/* Activity Alerts */
				user->chat ^= CHAT_NOACT;
deuce's avatar
deuce committed
419
				putuserrec(cfg,user->number,U_CHAT,8,ultoa(user->chat,str,16));
deuce's avatar
deuce committed
420
421
422
423
				break;
			case 4:
				/* Split-Screen Priv Chat */
				user->chat ^= CHAT_SPLITP;
deuce's avatar
deuce committed
424
				putuserrec(cfg,user->number,U_CHAT,8,ultoa(user->chat,str,16));
deuce's avatar
deuce committed
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
				break;
		}
	}
	return(0);
}

/* Pick Command Shell */
int edit_shell(scfg_t *cfg, user_t *user)
{
	int 	i,j;
	char 	**opt;

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));


	for(i=0;i<cfg->total_shells;i++) {
		opt[i]=cfg->shell[i]->name;
	}
	opt[i]="";
	j=user->shell-1;
	switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,0,"Shell",opt)) {
		case -1:
			break;
		default:
deuce's avatar
deuce committed
450
451
452
453
			if(user->shell != j+1) {
				user->shell=j+1;
				putuserrec(cfg,user->number,U_SHELL,8,cfg->shell[j+1]->code);
			}
deuce's avatar
deuce committed
454
455
456
			break;
	}
	free(opt);
deuce's avatar
deuce committed
457
458
459
460
461
462
463
464
465
	return(0);
}

/* Edit Command Shell
 *       Name
 *       Expert Mode
 */
int edit_cmd(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
466
467
	int 	i,j;
	char 	**opt;
deuce's avatar
deuce committed
468
	char	str[256];
deuce's avatar
deuce committed
469
470
471
472
473
474
475
476
477
478

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
		i=0;
deuce's avatar
deuce committed
479
		getuserdat(cfg,user);
deuce's avatar
deuce committed
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
		sprintf(opt[i++],"Command Shell: %s",cfg->shell[user->shell]->name);
		sprintf(opt[i++],"Expert Mode:   %s",user->misc & EXPERT?"Yes":"No");
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Command Shell",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* Command Shell */
				edit_shell(cfg,user);
				break;
			case 1:
				/* Expoert Mode */
				user->misc ^= EXPERT;
deuce's avatar
deuce committed
495
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
496
497
498
499
				break;
		}
	}

deuce's avatar
deuce committed
500
501
502
	return(0);
}

deuce's avatar
deuce committed
503
504
505
506
507
508
509
510
511
/* Pick External Editor */
int edit_xedit(scfg_t *cfg, user_t *user)
{
	int 	i,j;
	char 	**opt;

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));

deuce's avatar
deuce committed
512
	getuserdat(cfg,user);
deuce's avatar
deuce committed
513
514
515
516
517
518
519
520
521
522
	opt[0]="None";
	for(i=1;i<=cfg->total_xedits;i++) {
		opt[i]=cfg->xedit[i-1]->name;
	}
	opt[i]="";
	j=user->xedit;
	switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,0,"Shell",opt)) {
		case -1:
			break;
		default:
deuce's avatar
deuce committed
523
524
525
526
			if(user->xedit != j) {
				user->xedit=j;
				putuserrec(cfg,user->number,U_XEDIT,8,cfg->xedit[j]->code);
			}
deuce's avatar
deuce committed
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
			break;
	}
	free(opt);
	return(0);
}

/* Edit Message Options
 *       Forward Email to NetMail
 *       Clear Screen Between Messages
 *       External Editor
 */
int edit_msgopts(scfg_t *cfg, user_t *user)
{	
	int 	i,j;
	char 	**opt;
deuce's avatar
deuce committed
542
	char	str[256];
deuce's avatar
deuce committed
543
544
545
546
547
548
549
550
551

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
deuce's avatar
deuce committed
552
		getuserdat(cfg,user);
deuce's avatar
deuce committed
553
554
555
556
557
558
559
560
561
562
563
564
565
		i=0;
		sprintf(opt[i++],"Forward Email to NetMail:      %s",user->misc & NETMAIL?"Yes":"No");
		sprintf(opt[i++],"Clear Screen Between Messages: %s",user->misc & CLRSCRN?"Yes":"No");
		sprintf(opt[i++],"External Editor:               %s",user->xedit?cfg->xedit[user->xedit-1]->name:"None");
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Message Options",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* FWD Email */
				user->misc ^= NETMAIL;
deuce's avatar
deuce committed
566
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
567
568
569
570
				break;
			case 1:
				/* Clear Between MSGS */
				user->misc ^=CLRSCRN;
deuce's avatar
deuce committed
571
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
				break;
			case 2:
				/* External Editor */
				edit_xedit(cfg,user);
				break;
		}
	}
	return(0);
}

/* Pick Tmp/QWK File Type */
int edit_tmpqwktype(scfg_t *cfg, user_t *user)
{
	int 	i;
	int		j=0;
	char 	**opt;

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));

deuce's avatar
deuce committed
592
	getuserdat(cfg,user);
deuce's avatar
deuce committed
593
594
595
596
597
598
599
600
601
602
	for(i=0;i<cfg->total_fcomps;i++) {
		opt[i]=cfg->fcomp[i]->ext;
		if(!strcmp(cfg->fcomp[i]->ext,user->tmpext))
			j=i;
	}
	opt[i]="";
	switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,0,"Temp/QWK File Type",opt)) {
		case -1:
			break;
		default:
deuce's avatar
deuce committed
603
604
605
606
			if(strcmp(cfg->fcomp[j]->ext,user->tmpext)) {
				strcpy(user->tmpext,cfg->fcomp[j]->ext);
				putuserrec(cfg,user->number,U_TMPEXT,3,user->tmpext);
			}
deuce's avatar
deuce committed
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
			break;
	}
	free(opt);
	return(0);
}

/* Edit QWK Packet Options
 *       Include New Files List
 *       Include Unread Email
 *       Delete Email After Download
 *       Include Messages From Self
 *       Expand CTRL-A Codes to ANSI
 *       Strip CTRL-A Codes
 *       Include File Attachments
 *       Include Index Files
 *       Include Time Zone (@TZ)
 *       Include Seen-Bys (@VIA)
 *       Extraneous Control Files
 */
int edit_qwk(scfg_t *cfg, user_t *user)
{
	int 	i,j;
	char 	**opt;
deuce's avatar
deuce committed
630
	char	str[256];
deuce's avatar
deuce committed
631
632
633
634
635
636
637
638
639
640

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
		i=0;
deuce's avatar
deuce committed
641
		getuserdat(cfg,user);
deuce's avatar
deuce committed
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
		sprintf(opt[i++],"Include New Files List:       %s",user->qwk & QWK_FILES?"Yes":"No");
		sprintf(opt[i++],"Include Unread Email:         %s",user->qwk & QWK_EMAIL?"Yes":"No");
		sprintf(opt[i++],"Include ALL Email:            %s",user->qwk & QWK_ALLMAIL?"Yes":"No");
		sprintf(opt[i++],"Delete Email After Download:  %s",user->qwk & QWK_DELMAIL?"Yes":"No");
		sprintf(opt[i++],"Include Messages from Self:   %s",user->qwk & QWK_BYSELF?"Yes":"No");
		sprintf(opt[i++],"Expand CTRL-A to ANSI:        %s",user->qwk & QWK_EXPCTLA?"Yes":"No");
		sprintf(opt[i++],"Strip CTRL-A Codes:           %s",user->qwk & QWK_RETCTLA?"No":"Yes");
		sprintf(opt[i++],"Include File Attachments:     %s",user->qwk & QWK_ATTACH?"Yes":"No");
		sprintf(opt[i++],"Include Index Files:          %s",user->qwk & QWK_NOINDEX?"No":"Yes");
		sprintf(opt[i++],"Include Time Zone (@TZ):      %s",user->qwk & QWK_TZ?"Yes":"No");
		sprintf(opt[i++],"Include Seen-Bys (@VIA):      %s",user->qwk & QWK_VIA?"Yes":"No");
		sprintf(opt[i++],"Extraneous Control Files:     %s",user->qwk & QWK_NOCTRL?"No":"Yes");
		sprintf(opt[i++],"Extended (QWKE) Format:       %s",user->qwk & QWK_EXT?"Yes":"No");
		sprintf(opt[i++],"Include Message IDs (@MSGID): %s",user->qwk & QWK_MSGID?"Yes":"No");
		sprintf(opt[i++],"Temp/QWK File Type:           %s",user->tmpext);
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"Command Shell",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* New Files List */
				user->qwk ^= QWK_FILES;
deuce's avatar
deuce committed
666
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
667
668
669
670
				break;
			case 1:
				/* Unread Email */
				user->qwk ^= QWK_EMAIL;
deuce's avatar
deuce committed
671
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
672
673
674
675
				break;
			case 2:
				/* ALL Email */
				user->qwk ^= QWK_ALLMAIL;
deuce's avatar
deuce committed
676
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
677
678
679
680
				break;
			case 3:
				/* Del Email after Download */
				user->qwk ^= QWK_DELMAIL;
deuce's avatar
deuce committed
681
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
682
683
684
685
				break;
			case 4:
				/* Include From Self */
				user->qwk ^= QWK_BYSELF;
deuce's avatar
deuce committed
686
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
687
688
689
690
				break;
			case 5:
				/* Expand CTRL-A */
				user->qwk ^= QWK_EXPCTLA;
deuce's avatar
deuce committed
691
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
692
693
694
695
				break;
			case 6:
				/* Strip CTRL-A */
				user->qwk ^= QWK_RETCTLA;
deuce's avatar
deuce committed
696
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
697
698
699
700
				break;
			case 7:
				/* Include Attach */
				user->qwk ^= QWK_ATTACH;
deuce's avatar
deuce committed
701
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
702
703
704
705
				break;
			case 8:
				/* Include Indexes */
				user->qwk ^= QWK_NOINDEX;
deuce's avatar
deuce committed
706
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
707
708
709
710
				break;
			case 9:
				/* Include TZ */
				user->qwk ^= QWK_TZ;
deuce's avatar
deuce committed
711
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
712
713
714
715
				break;
			case 10:
				/* Include VIA */
				user->qwk ^= QWK_VIA;
deuce's avatar
deuce committed
716
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
717
718
719
720
				break;
			case 11:
				/* Extra CTRL Files */
				user->qwk ^= QWK_NOCTRL;
deuce's avatar
deuce committed
721
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
722
723
724
725
				break;
			case 12:
				/* Extended QWKE */
				user->qwk ^= QWK_EXT;
deuce's avatar
deuce committed
726
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
727
728
729
730
				break;
			case 13:
				/* Include MSGID */
				user->qwk ^= QWK_MSGID;
deuce's avatar
deuce committed
731
				putuserrec(cfg,user->number,U_QWK,8,ultoa(user->qwk,str,16));
deuce's avatar
deuce committed
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
				break;
			case 14:
				/* Temp/QWK Type */
				edit_tmpqwktype(cfg,user);
				break;
		}
	}
	return(0);
}

/* Pick Protocol */
int edit_proto(scfg_t *cfg, user_t *user)
{
	int 	i;
	int		j=0;
	char 	**opt;

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));

deuce's avatar
deuce committed
752
	getuserdat(cfg,user);
deuce's avatar
deuce committed
753
754
755
756
757
758
759
760
761
762
763
764
	opt[0]="None";
	for(i=1;i<=cfg->total_prots;i++) {
		opt[i]=cfg->prot[i-1]->name;
		if(cfg->prot[i-1]->mnemonic == user->prot)
			j=i;
	}
	opt[i]="";
	switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,0,"Default Protcol",opt)) {
		case -1:
			break;
		case 0:
			if(user->prot != ' ')
deuce's avatar
deuce committed
765
				putuserrec(cfg,user->number,U_PROT,1," ");
deuce's avatar
deuce committed
766
767
768
			user->prot=' ';
			break;
		default:
deuce's avatar
deuce committed
769
770
771
772
			if(user->prot != cfg->prot[j-1]->mnemonic) {
				user->prot=cfg->prot[j-1]->mnemonic;
				putuserrec(cfg,user->number,U_PROT,1,&user->prot);
			}
deuce's avatar
deuce committed
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
			break;
	}
	free(opt);
	return(0);
}

/* Edit File Options
 *       Auto-New Scan
 *       Extended Descriptions
 *       Batch Flagging
 *       Auto-Hangup After Transfer
 *       Default download Protocol
 *       Temp/QWK File Type
 */
int edit_fileopts(scfg_t *cfg, user_t *user)
{
	int 	i,j;
	int		k;
	char 	**opt;
	char 	str[256];

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
deuce's avatar
deuce committed
802
		getuserdat(cfg,user);
deuce's avatar
deuce committed
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
		i=0;
		sprintf(opt[i++],"Auto-New Scan:             %s",user->misc & ANFSCAN?"Yes":"No");
		sprintf(opt[i++],"Extended Descriptions:     %s",user->misc & EXTDESC?"Yes":"No");
		sprintf(opt[i++],"Batch Flagging:            %s",user->misc & BATCHFLAG?"Yes":"No");
		sprintf(opt[i++],"Auto Transfer Hangup:      %s",user->misc & AUTOHANG?"Yes":"No");
		strcpy(str,"None");
		for(k=0;k<cfg->total_prots;k++)
			if(cfg->prot[k]->mnemonic==user->prot)
				strcpy(str,cfg->prot[k]->name);
		sprintf(opt[i++],"Default Download Protocol: %s",str);
		sprintf(opt[i++],"Temp/QWK File Type:        %s",user->tmpext);
		opt[i][0]=0;
		switch(uifc.list(WIN_MID|WIN_ACT|WIN_SAV,0,0,0,&j,0,"File Options",opt)) {
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* Auto-New Scan */
				user->misc ^= ANFSCAN;
deuce's avatar
deuce committed
823
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
824
825
826
827
				break;
			case 1:
				/* Extended Descs */
				user->misc ^= EXTDESC;
deuce's avatar
deuce committed
828
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
829
830
831
832
				break;
			case 2:
				/* Batch Flagging */
				user->misc ^= BATCHFLAG;
deuce's avatar
deuce committed
833
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
834
835
836
837
				break;
			case 3:
				/* Atuo-Hangup */
				user->misc ^= AUTOHANG;
deuce's avatar
deuce committed
838
				putuserrec(cfg,user->number,U_MISC,8,ultoa(user->misc,str,16));
deuce's avatar
deuce committed
839
840
841
842
843
844
845
846
847
848
849
850
851
852
				break;
			case 4:
				/* Default Download Protocol */
				edit_proto(cfg,user);
				break;
			case 5:
				/* Temp/QWK File Type */
				edit_tmpqwktype(cfg,user);
				break;
		}
	}
	return(0);
}

deuce's avatar
deuce committed
853
854
855
/* Edit "Extended comment" */
int edit_comment(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
856
857
858
	char str[1024];
	char editor[1024];

deuce's avatar
deuce committed
859
	sprintf(str,"%s %suser/%04u.msg",geteditor(editor),cfg->data_dir,user->number);
deuce's avatar
deuce committed
860
	do_cmd(str);
deuce's avatar
deuce committed
861
862
863
864
865
866
867
868
869
870
	return(0);
}

/* MSG and File settings
 *      - Message Options
 *      - QWK Message Packet
 *      - File Options
 */
int edit_msgfile(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
	char *opt[4]={
		 "Message Options"
		,"QWK Message Packet"
		,"File Options"
		,""};
	int i=0;
	while(1) {
		switch(uifc.list(WIN_BOT|WIN_RHT|WIN_ACT,0,0,0,&i,0,"Settings",opt)) {
			case -1:
				return(0);
				break;
			case 0:
				/* Message Options */
				edit_msgopts(cfg,user);
				break;
			case 1:
				/* QWK Message Packet */
				edit_qwk(cfg,user);
				break;
			case 2:
				/* File Options */
				edit_fileopts(cfg,user);
				break;
		}
	}
deuce's avatar
deuce committed
896
897
898
899
900
901
902
903
904
905
906
	return(0);
}

/* Settings
 *     - Terminal Settings
 *     - Logon Toggles
 *     - Chat Toggles
 *     - Command Shell
 */
int edit_settings(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
907
908
909
910
911
912
913
914
915
	char *opt[5]={
		 "Terminal Settings"
		,"Logon Toggles"
		,"Chat Toggles"
		,"Command Shell"
		,""};
	int i=0;

	while(1) {
deuce's avatar
deuce committed
916
		switch(uifc.list(WIN_BOT|WIN_RHT|WIN_ACT,0,0,0,&i,0,"Settings",opt)) {
deuce's avatar
deuce committed
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
			case -1:
				return(0);
				break;
			case 0:
				/* Terminal Settings */
				edit_terminal(cfg,user);
				break;
			case 1:
				/* Logon Toggles */
				edit_logon(cfg,user);
				break;
			case 2:
				/* Chat Toggles */
				edit_chat(cfg,user);
				break;
			case 3:
				/* Command Shell */
				edit_cmd(cfg,user);
				break;
		}
	}
deuce's avatar
deuce committed
938
939
940
941
942
943
944
945
946
947
948
949
950
951
	return(0);
}

/* Statistics
 *     First On
 *     Last On
 *     Total Logons
 *     Todays Logons
 *     Total Posts
 *     Todays Posts
 *     Total Uploads
 *     Todays Uploads
 *     Total Time On
 *     Todays Time On
deuce's avatar
deuce committed
952
 *     Last Call Time On
deuce's avatar
deuce committed
953
954
955
956
957
958
959
960
961
962
 *     Extra
 *     Total Downloads
 *     Bytes
 *     Leech
 *     Total Email
 *     Todays Email
 *     Email to Sysop
 */
int edit_stats(scfg_t *cfg, user_t *user)
{
deuce's avatar
deuce committed
963
964
965
966
967
968
969
970
971
972
973
974
975
	int 	i,j;
	char 	**opt;
	char	str[256];
	time_t	temptime,temptime2;

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

	j=0;
	while(1) {
deuce's avatar
deuce committed
976
		getuserdat(cfg,user);
deuce's avatar
deuce committed
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
		i=0;
		sprintf(opt[i++],"First On:          %s",user->firston?timestr(cfg, &user->firston, str):"Never");
		sprintf(opt[i++],"Last On:           %s",user->laston?timestr(cfg, &user->laston, str):"Never");
		sprintf(opt[i++],"Logon Time:        %s",user->laston?timestr(cfg, &user->logontime, str):"Not On");
		sprintf(opt[i++],"Total Logons:      %hu",user->logons);
		sprintf(opt[i++],"Todays Logons:     %hu",user->ltoday);
		sprintf(opt[i++],"Total Posts:       %hu",user->posts);
		sprintf(opt[i++],"Todays Posts:      %hu",user->ptoday);
		sprintf(opt[i++],"Total Email:       %hu",user->emails);
		sprintf(opt[i++],"Todays Email:      %hu",user->etoday);
		sprintf(opt[i++],"Email To Sysop:    %hu",user->fbacks);
		sprintf(opt[i++],"Total Time On:     %hu",user->timeon);
		sprintf(opt[i++],"Time On Today:     %hu",user->ttoday);
		sprintf(opt[i++],"Time On Last Call: %hu",user->tlast);
		sprintf(opt[i++],"Extra Time Today:  %hu",user->textra);
		sprintf(opt[i++],"Total Downloads:   %hu",user->dls);
		sprintf(opt[i++],"Downloaded Bytes:  %lu",user->dlb);
		sprintf(opt[i++],"Total Uploads:     %hu",user->uls);
		sprintf(opt[i++],"Uploaded Bytes:    %lu",user->ulb);
		sprintf(opt[i++],"Leech:             %u",user->leech);
deuce's avatar
deuce committed
997
998
		sprintf(opt[i++],"Password Modified: %s",user->pwmod?timestr(cfg, &user->pwmod, str):"Never");
		opt[i][0]=0;
deuce's avatar
deuce committed
999
		switch(uifc.list(WIN_MID|WIN_ACT,0,0,0,&j,0,"Statistics",opt)) {
deuce's avatar
deuce committed
1000
1001
1002
1003
1004
1005
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* First On */
deuce's avatar
deuce committed
1006
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1007
1008
				temptime=user->firston;
				unixtodstr(cfg,temptime,str);
deuce's avatar
deuce committed
1009
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"First On Date",str,8,K_EDIT);
deuce's avatar
deuce committed
1010
1011
1012
				user->firston=dstrtounix(cfg, str);
				temptime2=temptime-user->firston;
				sectostr(temptime2,str);
deuce's avatar
deuce committed
1013
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"First On Time",str,8,K_EDIT);
deuce's avatar
deuce committed
1014
1015
1016
1017
				temptime2=strtosec(str);
				if(temptime2!=-1)
					user->firston += temptime2;
				if(temptime!=user->firston)
deuce's avatar
deuce committed
1018
					putuserrec(cfg,user->number,U_FIRSTON,8,ultoa(user->firston,str,16));
deuce's avatar
deuce committed
1019
1020
1021
				break;
			case 1:
				/* Last On */
deuce's avatar
deuce committed
1022
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1023
1024
				temptime=user->laston;
				unixtodstr(cfg,temptime,str);
deuce's avatar
deuce committed
1025
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Last On Date",str,8,K_EDIT);
deuce's avatar
deuce committed
1026
1027
1028
				user->laston=dstrtounix(cfg, str);
				temptime2=temptime-user->laston;
				sectostr(temptime2,str);
deuce's avatar
deuce committed
1029
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Last On Time",str,8,K_EDIT);
deuce's avatar
deuce committed
1030
1031
1032
1033
				temptime2=strtosec(str);
				if(temptime2!=-1)
					user->laston += temptime2;
				if(temptime!=user->laston)
deuce's avatar
deuce committed
1034
					putuserrec(cfg,user->number,U_LASTON,8,ultoa(user->laston,str,16));
deuce's avatar
deuce committed
1035
1036
1037
				break;
			case 2:
				/* Logon Time */
deuce's avatar
deuce committed
1038
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1039
1040
				temptime=user->logontime;
				unixtodstr(cfg,temptime,str);
deuce's avatar
deuce committed
1041
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Logon Date",str,8,K_EDIT);
deuce's avatar
deuce committed
1042
1043
1044
				user->logontime=dstrtounix(cfg, str);
				temptime2=temptime-user->logontime;
				sectostr(temptime2,str);
deuce's avatar
deuce committed
1045
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Logon Time",str,8,K_EDIT);
deuce's avatar
deuce committed
1046
1047
1048
1049
				temptime2=strtosec(str);
				if(temptime2!=-1)
					user->logontime += temptime2;
				if(temptime!=user->logontime)
deuce's avatar
deuce committed
1050
					putuserrec(cfg,user->number,U_LOGONTIME,8,ultoa(user->logontime,str,16));
deuce's avatar
deuce committed
1051
1052
1053
				break;
			case 3:
				/* Total Logons */
deuce's avatar
deuce committed
1054
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1055
				sprintf(str,"%hu",user->logons);
deuce's avatar
deuce committed
1056
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Total Logons",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1057
1058
				if(uifc.changes) {
					user->logons=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1059
					putuserrec(cfg,user->number,U_LOGONS,5,ultoa(user->logons,str,10));
deuce's avatar
deuce committed
1060
1061
1062
1063
				}
				break;
			case 4:
				/* Todays Logons */
deuce's avatar
deuce committed
1064
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1065
				sprintf(str,"%hu",user->ltoday);
deuce's avatar
deuce committed
1066
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Todays Logons",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1067
1068
				if(uifc.changes) {
					user->ltoday=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1069
					putuserrec(cfg,user->number,U_LTODAY,5,ultoa(user->ltoday,str,10));
deuce's avatar
deuce committed
1070
1071
1072
1073
				}
				break;
			case 5:
				/* Total Posts */
deuce's avatar
deuce committed
1074
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1075
				sprintf(str,"%hu",user->posts);
deuce's avatar
deuce committed
1076
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Total Posts",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1077
1078
				if(uifc.changes) {
					user->posts=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1079
					putuserrec(cfg,user->number,U_POSTS,5,ultoa(user->posts,str,10));
deuce's avatar
deuce committed
1080
1081
1082
1083
				}
				break;
			case 6:
				/* Todays Posts */
deuce's avatar
deuce committed
1084
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1085
				sprintf(str,"%hu",user->ptoday);
deuce's avatar
deuce committed
1086
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Todays Posts",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1087
1088
				if(uifc.changes) {
					user->ptoday=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1089
					putuserrec(cfg,user->number,U_PTODAY,5,ultoa(user->ptoday,str,10));
deuce's avatar
deuce committed
1090
1091
1092
1093
				}
				break;
			case 7:
				/* Total Emails */
deuce's avatar
deuce committed
1094
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1095
				sprintf(str,"%hu",user->emails);
deuce's avatar
deuce committed
1096
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Total Emails",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1097
1098
				if(uifc.changes) {
					user->emails=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1099
					putuserrec(cfg,user->number,U_EMAILS,5,ultoa(user->emails,str,10));
deuce's avatar
deuce committed
1100
1101
1102
1103
				}
				break;
			case 8:
				/* Todays Emails */
deuce's avatar
deuce committed
1104
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1105
				sprintf(str,"%hu",user->etoday);
deuce's avatar
deuce committed
1106
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Todays Emails",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1107
1108
				if(uifc.changes) {
					user->etoday=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1109
					putuserrec(cfg,user->number,U_ETODAY,5,ultoa(user->etoday,str,10));
deuce's avatar
deuce committed
1110
1111
1112
1113
				}
				break;
			case 9:
				/* Emails to Sysop */
deuce's avatar
deuce committed
1114
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1115
				sprintf(str,"%hu",user->fbacks);
deuce's avatar
deuce committed
1116
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Emails to Sysop",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1117
1118
				if(uifc.changes) {
					user->fbacks=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1119
					putuserrec(cfg,user->number,U_FBACKS,5,ultoa(user->fbacks,str,10));
deuce's avatar
deuce committed
1120
1121
1122
1123
				}
				break;
			case 10:
				/* Total Time On */
deuce's avatar
deuce committed
1124
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1125
				sprintf(str,"%hu",user->timeon);
deuce's avatar
deuce committed
1126
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Total Time On",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1127
1128
				if(uifc.changes) {
					user->timeon=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1129
					putuserrec(cfg,user->number,U_TIMEON,5,ultoa(user->timeon,str,10));
deuce's avatar
deuce committed
1130
1131
1132
1133
				}
				break;
			case 11:
				/* Time On Today */
deuce's avatar
deuce committed
1134
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1135
				sprintf(str,"%hu",user->ttoday);
deuce's avatar
deuce committed
1136
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Time On Today",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1137
1138
				if(uifc.changes) {
					user->ttoday=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1139
					putuserrec(cfg,user->number,U_TTODAY,5,ultoa(user->ttoday,str,10));
deuce's avatar
deuce committed
1140
1141
1142
1143
				}
				break;
			case 12:
				/* Time On Last Call */
deuce's avatar
deuce committed
1144
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1145
				sprintf(str,"%hu",user->tlast);
deuce's avatar
deuce committed
1146
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Time On Last Call",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1147
1148
				if(uifc.changes) {
					user->tlast=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1149
					putuserrec(cfg,user->number,U_TLAST,5,ultoa(user->tlast,str,10));
deuce's avatar
deuce committed
1150
1151
1152
1153
				}
				break;
			case 13:
				/* Extra Time Today */
deuce's avatar
deuce committed
1154
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1155
				sprintf(str,"%hu",user->textra);
deuce's avatar
deuce committed
1156
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Extra Time Today",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1157
1158
				if(uifc.changes) {
					user->textra=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1159
					putuserrec(cfg,user->number,U_TEXTRA,5,ultoa(user->textra,str,10));
deuce's avatar
deuce committed
1160
1161
1162
1163
				}
				break;
			case 14:
				/* Total Downloads */
deuce's avatar
deuce committed
1164
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1165
				sprintf(str,"%hu",user->dls);
deuce's avatar
deuce committed
1166
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Total Downloads",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1167
1168
				if(uifc.changes) {
					user->dls=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1169
					putuserrec(cfg,user->number,U_DLS,5,ultoa(user->dls,str,10));
deuce's avatar
deuce committed
1170
1171
1172
1173
				}
				break;
			case 15:
				/* Downloaded Bytes */
deuce's avatar
deuce committed
1174
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1175
				sprintf(str,"%lu",user->dlb);
deuce's avatar
deuce committed
1176
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Downloaded Bytes",str,10,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1177
1178
				if(uifc.changes) {
					user->dlb=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1179
					putuserrec(cfg,user->number,U_DLB,10,ultoa(user->dlb,str,10));
deuce's avatar
deuce committed
1180
1181
1182
1183
				}
				break;
			case 16:
				/* Total Uploads */
deuce's avatar
deuce committed
1184
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1185
				sprintf(str,"%hu",user->uls);
deuce's avatar
deuce committed
1186
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Total Uploads",str,5,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1187
1188
				if(uifc.changes) {
					user->uls=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1189
					putuserrec(cfg,user->number,U_ULS,5,ultoa(user->uls,str,10));
deuce's avatar
deuce committed
1190
1191
1192
1193
				}
				break;
			case 17:
				/* Uploaded Bytes */
deuce's avatar
deuce committed
1194
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1195
				sprintf(str,"%lu",user->ulb);
deuce's avatar
deuce committed
1196
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Uploaded Bytes",str,10,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1197
1198
				if(uifc.changes) {
					user->ulb=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1199
					putuserrec(cfg,user->number,U_ULB,10,ultoa(user->ulb,str,10));
deuce's avatar
deuce committed
1200
1201
1202
1203
				}
				break;
			case 18:
				/* Leech Counter */
deuce's avatar
deuce committed
1204
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1205
				sprintf(str,"%u",user->leech);
deuce's avatar
deuce committed
1206
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Leech Counter",str,3,K_EDIT|K_NUMBER);
deuce's avatar
deuce committed
1207
1208
				if(uifc.changes) {
					user->leech=strtoul(str,NULL,10);
deuce's avatar
deuce committed
1209
					putuserrec(cfg,user->number,U_LEECH,2,ultoa(user->leech,str,16));
deuce's avatar
deuce committed
1210
1211
				}
				break;
deuce's avatar
deuce committed
1212
1213
			case 19:
				/* Password Last Modified */
deuce's avatar
deuce committed
1214
				getuserdat(cfg,user);
deuce's avatar
deuce committed
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
				temptime=user->pwmod;
				unixtodstr(cfg,temptime,str);
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Password Modified Date",str,8,K_EDIT);
				user->firston=dstrtounix(cfg, str);
				temptime2=temptime-user->pwmod;
				sectostr(temptime2,str);
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Password Modified Time",str,8,K_EDIT);
				temptime2=strtosec(str);
				if(temptime2!=-1)
					user->pwmod += temptime2;
				if(temptime!=user->pwmod)
deuce's avatar
deuce committed
1226
					putuserrec(cfg,user->number,U_PWMOD,8,ultoa(user->pwmod,str,16));
deuce's avatar
deuce committed
1227
				break;
deuce's avatar
deuce committed
1228
1229
		}
	}
deuce's avatar
deuce committed
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
	return(0);
}

/* Security settings
 *     Level
 *     Expiration
 *     Flag Set 1
 *     Flag Set 2
 *     Flag Set 3
 *     Flag Set 4
 *     Exemptions
 *     Restrictions
 *     Credits
 *     Free Credits
 *     Minutes
 */
int edit_security(scfg_t *cfg, user_t *user)
{
1248
1249
	int 	i,j;
	char 	**opt;
1250
	char	str[256];
1251
1252
1253
1254
1255
1256
1257

	if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
		allocfail(sizeof(char *)*(MAX_OPTS+1));
	for(i=0;i<(MAX_OPTS+1);i++)
		if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
			allocfail(MAX_OPLN);

1258
	j=0;
deuce's avatar
deuce committed
1259
	getuserdat(cfg,user);
1260
1261
	while(1) {
		i=0;
deuce's avatar
deuce committed
1262
		sprintf(opt[i++],"Level:        %d",user->level);
1263
1264
1265
1266
1267
1268
1269
		sprintf(opt[i++],"Expiration:   %s",user->expire?unixtodstr(cfg, user->expire, str):"Never");
		sprintf(opt[i++],"Flag Set 1:   %s",ltoaf(user->flags1,str));
		sprintf(opt[i++],"Flag Set 2:   %s",ltoaf(user->flags2,str));
		sprintf(opt[i++],"Flag Set 3:   %s",ltoaf(user->flags3,str));
		sprintf(opt[i++],"Flag Set 4:   %s",ltoaf(user->flags4,str));
		sprintf(opt[i++],"Exemptions:   %s",ltoaf(user->exempt,str));
		sprintf(opt[i++],"Restrictions: %s",ltoaf(user->rest,str));
deuce's avatar
deuce committed
1270
1271
1272
		sprintf(opt[i++],"Credits:      %lu",user->cdt);
		sprintf(opt[i++],"Free Credits: %lu",user->freecdt);
		sprintf(opt[i++],"Minutes:      %lu",user->min);
1273
		opt[i][0]=0;
deuce's avatar
deuce committed
1274
		switch(uifc.list(WIN_MID|WIN_ACT,0,0,0,&j,0,"Security Settings",opt)) {
1275
1276
1277
1278
1279
1280
			case -1:
				freeopt(opt);
				return(0);
				break;
			case 0:
				/* Level */
deuce's avatar
deuce committed
1281
				getuserdat(cfg,user);
1282
				sprintf(str,"%d",user->level);
deuce's avatar
deuce committed
1283
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Level",str,2,K_EDIT|K_NUMBER);
1284
1285
				if(uifc.changes) {
					user->level=atoi(str);
deuce's avatar
deuce committed
1286
					putuserrec(cfg,user->number,U_LEVEL,2,str);
1287
1288
1289
1290
				}
				break;
			case 1:
				/* Expiration */
deuce's avatar
deuce committed
1291
				getuserdat(cfg,user);
1292
				unixtodstr(cfg,user->expire,str);
deuce's avatar
deuce committed
1293
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Expiration",str,8,K_EDIT);
1294
1295
				if(uifc.changes && dstrtounix(cfg, str)!=user->expire) {
					user->expire=dstrtounix(cfg, str);
deuce's avatar
deuce committed
1296
					putuserrec(cfg,user->number,U_EXPIRE,8,ultoa(user->expire,str,16));
1297
1298
1299
1300
				}
				break;
			case 2:
				/* Flag Set 1 */
deuce's avatar
deuce committed
1301
				getuserdat(cfg,user);
1302
				ltoaf(user->flags1,str);
deuce's avatar
deuce committed
1303
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Flag Set 1",str,26,K_EDIT|K_UPPER|K_ALPHA);
1304
1305
				if(uifc.changes) {
					user->flags1=aftol(str);
deuce's avatar
deuce committed
1306
					putuserrec(cfg,user->number,U_FLAGS1,8,ultoa(user->flags1,str,16));
1307
1308
1309
1310
				}
				break;
			case 3:
				/* Flag Set 2 */
deuce's avatar
deuce committed
1311
				getuserdat(cfg,user);
1312
				ltoaf(user->flags2,str);
deuce's avatar
deuce committed
1313
				uifc.input(WIN_MID|WIN_ACT|WIN_SAV,0,0,"Flag Set 2",str,26,K_EDIT|K_UPPER|K_ALPHA);
1314
1315
				if(uifc.changes) {
					user->flags2=aftol(str);
deuce's avatar
deuce committed
1316
					putuserrec(cfg,user->number,U_FLAGS2,8,ultoa(user->flags2,str,16));
1317
1318
1319
1320
				}
				break;
			case 4:
				/* Flag Set 3 */