scfgxtrn.c 72.8 KB
Newer Older
1
2
3
4
5
6
/* $Id$ */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
7
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
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
 *																			*
 * 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.	*
 ****************************************************************************/
rswindell's avatar
rswindell committed
33
34
35
36
37
38
/****************************************************************************/
/* Synchronet configuration utility 										*/
/****************************************************************************/

#include "scfg.h"

39
char *daystr(char days);
40
41
static void hotkey_cfg(void);

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#define CUT_XTRNSEC_NUM	USHRT_MAX

static bool new_timed_event(unsigned new_event_num)
{
	event_t* new_event;
	if ((new_event = (event_t *)malloc(sizeof(*new_event))) == NULL) {
		errormsg(WHERE, ERR_ALLOC, "timed event", sizeof(*new_event));
		return false;
	}
	memset(new_event, 0, sizeof(*new_event));
	new_event->node = 1;
	new_event->days = (uchar)0xff;

	event_t** new_event_list = realloc(cfg.event, sizeof(event_t *)*(cfg.total_events + 1));
	if (new_event_list == NULL) {
		errormsg(WHERE, ERR_ALLOC, "timed event list", cfg.total_events + 1);
		return false;
	}
	cfg.event = new_event_list;

	for (unsigned u = cfg.total_events; u > new_event_num; u--)
		cfg.event[u] = cfg.event[u - 1];

	cfg.event[new_event_num] = new_event;
	cfg.total_events++;
	return true;
}

static bool new_external_program_section(unsigned new_section_num)
{
	xtrnsec_t* new_xtrnsec = malloc(sizeof(*new_xtrnsec));
	if (new_xtrnsec == NULL) {
		errormsg(WHERE, ERR_ALLOC, "external program section", sizeof(*new_xtrnsec));
		return false;
	}
	memset(new_xtrnsec, 0, sizeof(*new_xtrnsec));

	xtrnsec_t** new_xtrnsec_list = realloc(cfg.xtrnsec, sizeof(xtrnsec_t *)*(cfg.total_xtrnsecs + 1));
	if (new_xtrnsec_list == NULL) {
		errormsg(WHERE, ERR_ALLOC, "external program section list", cfg.total_xtrnsecs + 1);
		return false;
	}
	cfg.xtrnsec = new_xtrnsec_list;
	for (unsigned u = cfg.total_xtrnsecs; u > new_section_num; u--)
		cfg.xtrnsec[u] = cfg.xtrnsec[u - 1];
	for (unsigned j = 0; j < cfg.total_xtrns; j++) {
		if (cfg.xtrn[j]->sec >= new_section_num && cfg.xtrn[j]->sec != CUT_XTRNSEC_NUM)
			cfg.xtrn[j]->sec++;
	}

	cfg.xtrnsec[new_section_num] = new_xtrnsec;
	cfg.total_xtrnsecs++;
	return true;
}

static bool new_external_program(unsigned new_xtrn_num, unsigned section)
{
	xtrn_t* new_xtrn = malloc(sizeof(*new_xtrn));
	if (new_xtrn == NULL) {
		errormsg(WHERE, ERR_ALLOC, "external program", sizeof(*new_xtrn));
		return false;
	}
	memset(new_xtrn, 0, sizeof(*new_xtrn));
	new_xtrn->sec = section;

	xtrn_t ** new_xtrn_list = realloc(cfg.xtrn, sizeof(xtrn_t *)*(cfg.total_xtrns + 1));
	if (new_xtrn_list == NULL) {
		errormsg(WHERE, ERR_ALLOC, "external program list", cfg.total_xtrns + 1);
		return false;
	}
	cfg.xtrn = new_xtrn_list;
	for (unsigned n = cfg.total_xtrns; n > new_xtrn_num; n--)
		cfg.xtrn[n] = cfg.xtrn[n - 1];

	cfg.xtrn[new_xtrn_num] = new_xtrn;
	cfg.total_xtrns++;
	return true;
}

static bool new_external_editor(unsigned new_xedit_num)
{
	xedit_t* new_xedit = malloc(sizeof(*new_xedit));
	if (new_xedit == NULL) {
		errormsg(WHERE, ERR_ALLOC, "external editor", sizeof(*new_xedit));
		return false;
	}
	memset(new_xedit, 0, sizeof(*new_xedit));

	xedit_t** new_xedit_list = realloc(cfg.xedit, sizeof(xedit_t *)*(cfg.total_xedits + 1));
	if (new_xedit_list == NULL) {
		errormsg(WHERE, ERR_ALLOC, "external editor list", cfg.total_xedits + 1);
		return false;
	}
	cfg.xedit = new_xedit_list;
	for (unsigned u = cfg.total_xedits; u > new_xedit_num; u--)
		cfg.xedit[u] = cfg.xedit[u - 1];

	cfg.xedit[new_xedit_num] = new_xedit;
	cfg.total_xedits++;
	return true;
}

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
static char* monthstr(uint16_t months)
{
	int		i;
	static	char str[256];

	if(months==0)
		return("Any");

	str[0]=0;
	for(i=0;i<12;i++) {
		if((months&(1<<i))==0)
			continue;
		if(str[0])
			strcat(str," ");
		strcat(str,mon[i]);
	}
	
	return(str);
}

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
static char* mdaystr(long mdays)
{
	int		i;
	char	tmp[16];
	static	char str[256];

	if(mdays==0 || mdays==1)
		return("Any");

	str[0]=0;
	for(i=1;i<32;i++) {
		if((mdays&(1<<i))==0)
			continue;
		if(str[0])
			strcat(str," ");
		sprintf(tmp,"%u",i);
		strcat(str,tmp);
	}
	
	return(str);
}

186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
static char* dropfile(int type, ulong misc)
{
	static char str[128];
	char fname[64]="";

	switch(type) {
		case XTRN_SBBS:
			strcpy(fname,"XTRN.DAT");
			break;
		case XTRN_WWIV:
			strcpy(fname,"CHAIN.TXT");
			break;
		case XTRN_GAP:
			strcpy(fname,"DOOR.SYS");
			break;
		case XTRN_RBBS:
			strcpy(fname,"DORINFO#.DEF");
			break;
		case XTRN_RBBS1:
			strcpy(fname,"DORINFO1.DEF");
            break;
		case XTRN_WILDCAT:
			strcpy(fname,"CALLINFO.BBS");
			break;
		case XTRN_PCBOARD:
			strcpy(fname,"PCBOARD.SYS");
			break;
		case XTRN_SPITFIRE:
			strcpy(fname,"SFDOORS.DAT");
			break;
		case XTRN_UTI:
			strcpy(fname,"UTIDOOR.TXT");
			break;
		case XTRN_SR:
			strcpy(fname,"DOORFILE.SR");
			break;
		case XTRN_TRIBBS:
			strcpy(fname,"TRIBBS.SYS");
			break;
        case XTRN_DOOR32:
            strcpy(fname,"DOOR32.SYS");
            break;
	}

	if(misc&XTRN_LWRCASE)
		strlwr(fname);

	switch(type) {
		case XTRN_SBBS:
			sprintf(str,"%-15s %s","Synchronet",fname);
			break;
		case XTRN_WWIV:
			sprintf(str,"%-15s %s","WWIV",fname);
			break;
		case XTRN_GAP:
			sprintf(str,"%-15s %s","GAP",fname);
			break;
		case XTRN_RBBS:
			sprintf(str,"%-15s %s","RBBS/QuickBBS",fname);
			break;
		case XTRN_RBBS1:
			sprintf(str,"%-15s %s","RBBS/QuickBBS",fname);
            break;
		case XTRN_WILDCAT:
			sprintf(str,"%-15s %s","Wildcat",fname);
			break;
		case XTRN_PCBOARD:
			sprintf(str,"%-15s %s","PCBoard",fname);
			break;
		case XTRN_SPITFIRE:
			sprintf(str,"%-15s %s","SpitFire",fname);
			break;
		case XTRN_UTI:
			sprintf(str,"%-15s %s","MegaMail",fname);
			break;
		case XTRN_SR:
			sprintf(str,"%-15s %s","Solar Realms",fname);
			break;
		case XTRN_TRIBBS:
			sprintf(str,"%-15s %s","TriBBS",fname);
			break;
        case XTRN_DOOR32:
            sprintf(str,"%-15s %s","Mystic",fname);
            break;
		default:
			strcpy(str,"None");
			break; 
	}
	return(str);
}

rswindell's avatar
rswindell committed
277
278
279
280
281
void xprogs_cfg()
{
	static int xprogs_dflt;
	int 	i;

282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
	while(1) {
		i=0;
		strcpy(opt[i++],"Fixed Events");
		strcpy(opt[i++],"Timed Events");
		strcpy(opt[i++],"Native Program List");
		strcpy(opt[i++],"External Editors");
		strcpy(opt[i++],"Global Hot Key Events");
		strcpy(opt[i++],"Online Programs (Doors)");
		opt[i][0]=0;
		uifc.helpbuf=
			"`Online External Programs:`\n"
			"\n"
			"From this menu, you can configure external events, external editors, or\n"
			"online external programs (doors).\n"
		;
		switch(uifc.list(WIN_ORG|WIN_CHE|WIN_ACT,0,0,0,&xprogs_dflt,0
			,"External Programs",opt)) {
			case -1:
				i=save_changes(WIN_MID);
				if(i==-1)
					break;
				if(!i) {
					cfg.new_install=new_install;
					write_xtrn_cfg(&cfg,backup_level);
					write_main_cfg(&cfg,backup_level);
					refresh_cfg(&cfg);
				}
				return;
			case 0:
				fevents_cfg();
				break;
			case 1:
				tevents_cfg();
				break;
			case 2:
				natvpgm_cfg();
				break;
			case 3:
				xedit_cfg();
				break;
			case 4:
				hotkey_cfg();
				break;
			case 5:
				xtrnsec_cfg();
				break; 
328
329
		}
	}
rswindell's avatar
rswindell committed
330
331
332
333
334
335
336
}

void fevents_cfg()
{
	static int event_dflt;
	int i;

337
338
339
340
341
342
	while(1) {
		i=0;
		sprintf(opt[i++],"%-32.32s%.40s","Logon Event",cfg.sys_logon);
		sprintf(opt[i++],"%-32.32s%.40s","Logout Event",cfg.sys_logout);
		sprintf(opt[i++],"%-32.32s%.40s","Daily Event",cfg.sys_daily);
		opt[i][0]=0;
343
		uifc.helpbuf=
344
			"`External Events:`\n"
345
			"\n"
346
347
			"From this menu, you can configure the logon and logout events, and the\n"
			"system daily event.\n"
348
		;
349
350
		switch(uifc.list(WIN_ACT|WIN_SAV|WIN_CHE|WIN_BOT|WIN_RHT,0,0,60,&event_dflt,0
			,"Fixed Events",opt)) {
rswindell's avatar
rswindell committed
351
			case -1:
352
				return;
rswindell's avatar
rswindell committed
353
			case 0:
354
				uifc.helpbuf=
355
					"`Logon Event:`\n"
356
					"\n"
357
358
359
360
361
362
363
					"This is the command line for a program that will execute during the\n"
					"logon sequence of every user. The program cannot have user interaction.\n"
					"The program will be executed after the LOGON message is displayed and\n"
					"before the logon user list is displayed. If you wish to place a program\n"
					"in the logon sequence of users that includes interaction or requires\n"
					"account information, you probably want to use an online external\n"
					"program configured to run as a logon event.\n"
364
				;
365
366
				uifc.input(WIN_MID|WIN_SAV,0,0,"Logon Event"
					,cfg.sys_logon,sizeof(cfg.sys_logon)-1,K_EDIT);
367
				break;
368
			case 1:
369
				uifc.helpbuf=
370
					"`Logout Event:`\n"
371
					"\n"
372
373
374
375
376
377
					"This is the command line for a program that will execute during the\n"
					"logout sequence of every user. This program cannot have user\n"
					"interaction because it is executed after carrier is dropped. If you\n"
					"wish to have a program execute before carrier is dropped, you probably\n"
					"want to use an `Online External Program` configured to run as a logoff\n"
					"event.\n"
378
				;
379
380
				uifc.input(WIN_MID|WIN_SAV,0,0,"Logout Event"
					,cfg.sys_logout,sizeof(cfg.sys_logout)-1,K_EDIT);
rswindell's avatar
rswindell committed
381
				break;
382
			case 2:
383
				uifc.helpbuf=
384
					"`Daily Event:`\n"
385
					"\n"
386
387
					"This is the command line for a program that will run after the first\n"
					"user that logs on after midnight, logs off (regardless of what node).\n"
388
				;
389
390
				uifc.input(WIN_MID|WIN_SAV,0,0,"Daily Event"
					,cfg.sys_daily,sizeof(cfg.sys_daily)-1,K_EDIT);
391

392
				break; 
393
394
		} 
	}
rswindell's avatar
rswindell committed
395
396
}

397
void tevents_cfg()
rswindell's avatar
rswindell committed
398
{
399
400
	static int dflt,dfltopt,bar;
	char str[81],done=0,*p;
rswindell's avatar
rswindell committed
401
	int j,k;
402
403
	uint i;
	static event_t savevent;
404

405
406
407
408
409
410
411
412
413
414
415
	while(1) {
		for(i=0;i<cfg.total_events && i<MAX_OPTS;i++)
			sprintf(opt[i],"%-8.8s      %.50s",cfg.event[i]->code,cfg.event[i]->cmd);
		opt[i][0]=0;
		j=WIN_SAV|WIN_ACT|WIN_CHE|WIN_RHT;
		if(cfg.total_events)
			j|=WIN_DEL|WIN_COPY;
		if(cfg.total_events<MAX_OPTS)
			j|=WIN_INS|WIN_INSACT|WIN_XTR;
		if(savevent.code[0])
			j|=WIN_PASTE | WIN_PASTEXTR;
416
		uifc.helpbuf=
417
			"`Timed Events:`\n"
418
			"\n"
419
420
421
			"This is a list of the configured timed external events.\n"
			"\n"
			"To add an event hit ~ INS ~.\n"
422
			"\n"
423
424
425
			"To delete an event, select it and hit ~ DEL ~.\n"
			"\n"
			"To configure an event, select it and hit ~ ENTER ~.\n"
426
		;
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
		i=uifc.list(j,0,0,45,&dflt,&bar,"Timed Events",opt);
		if((signed)i==-1)
			return;
		int msk = i & MSK_ON;
		i &= MSK_OFF;
		if(msk == MSK_INS) {
			uifc.helpbuf=
				"`Timed Event Internal Code:`\n"
				"\n"
				"This is the internal code for the timed event.\n"
			;
			if(uifc.input(WIN_MID|WIN_SAV,0,0,"Event Internal Code",str,LEN_CODE
				,K_UPPER)<1)
				continue;
			if (!new_timed_event(i))
				continue;
			SAFECOPY(cfg.event[i]->code,str);
			uifc.changes=1;
			continue; 
446
		}
447
448
449
450
451
452
453
454
455
		if(msk == MSK_DEL || msk == MSK_CUT) {
			if(msk == MSK_CUT)
				savevent = *cfg.event[i];
			free(cfg.event[i]);
			cfg.total_events--;
			for(j=i;j<cfg.total_events;j++)
				cfg.event[j]=cfg.event[j+1];
			uifc.changes=1;
			continue; 
456
		}
457
458
		if(msk == MSK_COPY) {
			savevent=*cfg.event[i];
459
460
			continue; 
		}
461
462
463
464
465
466
467
468
469
470
471
472
		if(msk == MSK_PASTE_OVER || msk == MSK_PASTE_INSERT) {
			if (msk == MSK_PASTE_INSERT) {
				if (!new_timed_event(i))
					continue;
			}
			else if (opt[i][0] == 0) {	/* Paste-over extra/blank item */
				if (!new_timed_event(cfg.total_events))
					continue;
			}
			*cfg.event[i]=savevent;
			uifc.changes=1;
			continue; 
473
		}
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
		if (msk != 0)
			continue;
		done=0;
		while(!done) {
			k=0;
			sprintf(opt[k++],"%-32.32s%s","Internal Code",cfg.event[i]->code);
			sprintf(opt[k++],"%-32.32s%.40s","Start-up Directory",cfg.event[i]->dir);
			sprintf(opt[k++],"%-32.32s%.40s","Command Line",cfg.event[i]->cmd);
			sprintf(opt[k++],"%-32.32s%s","Enabled"
				,cfg.event[i]->misc&EVENT_DISABLED ? "No":"Yes");
			sprintf(opt[k++],"%-32.32s%u","Execution Node",cfg.event[i]->node);
			sprintf(opt[k++],"%-32.32s%s","Execution Months"
				,monthstr(cfg.event[i]->months));
			sprintf(opt[k++],"%-32.32s%s","Execution Days of Month"
				,mdaystr(cfg.event[i]->mdays));
			sprintf(opt[k++],"%-32.32s%s","Execution Days of Week",daystr(cfg.event[i]->days));
			if(cfg.event[i]->freq) {
				sprintf(str,"%u times a day",1440/cfg.event[i]->freq);
				sprintf(opt[k++],"%-32.32s%s","Execution Frequency",str);
			} else {
				sprintf(str,"%2.2u:%2.2u"
					,cfg.event[i]->time/60,cfg.event[i]->time%60);
				sprintf(opt[k++],"%-32.32s%s","Execution Time",str);
			}
			sprintf(opt[k++],"%-32.32s%s","Requires Exclusive Execution"
				,cfg.event[i]->misc&EVENT_EXCL ? "Yes":"No");
			sprintf(opt[k++],"%-32.32s%s","Force Users Off-line For Event"
				,cfg.event[i]->misc&EVENT_FORCE ? "Yes":"No");
			sprintf(opt[k++],"%-32.32s%s","Native Executable"
				,cfg.event[i]->misc&EX_NATIVE ? "Yes" : "No");
			sprintf(opt[k++],"%-32.32s%s","Use Shell to Execute"
				,cfg.event[i]->misc&XTRN_SH ? "Yes" : "No");
			sprintf(opt[k++],"%-32.32s%s","Background Execution"
				,cfg.event[i]->misc&EX_BG ? "Yes" : "No");
			sprintf(opt[k++],"%-32.32s%s","Always Run After Init/Re-init"
				,cfg.event[i]->misc&EVENT_INIT ? "Yes":"No");

			opt[k][0]=0;
			uifc.helpbuf=
				"`Timed Event:`\n"
				"\n"
				"This is the configuration menu for a timed event. An event is an\n"
				"external program that performs some type of automated function on the\n"
				"system. Use this menu to configure how and when this event will be\n"
				"executed.\n"
				"\n"
				"If you need the BBS to swap out of memory for this event (to make more\n"
				"available memory), add the program name (first word of the command line)\n"
				"to `Global Swap List` from the `External Programs` menu.\n"
			;
			sprintf(str,"%s Timed Event",cfg.event[i]->code);
			switch(uifc.list(WIN_SAV|WIN_ACT|WIN_L2R|WIN_BOT,0,0,70,&dfltopt,0
				,str,opt)) {
				case -1:
					done=1;
					break;
				case 0:
					strcpy(str,cfg.event[i]->code);
					uifc.helpbuf=
						"`Timed Event Internal Code:`\n"
						"\n"
						"Every timed event must have its own unique internal code for Synchronet\n"
536
						"to reference it by. It is helpful if this code is an abbreviation of the\n"
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
						"command line.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)"
						,str,LEN_CODE,K_EDIT|K_UPPER);
					if(code_ok(str))
						strcpy(cfg.event[i]->code,str);
					else {
						uifc.helpbuf=invalid_code;
						uifc.msg("Invalid Code");
						uifc.helpbuf=0; 
					}
					break;
				case 1:
					uifc.helpbuf=
						"`Timed Event Start-up Directory:`\n"
						"\n"
						"This is the DOS drive/directory where the event program is located.\n"
						"If a path is specified here, it will be made the current directory\n"
						"before the event's command line is executed. This eliminates the need\n"
						"for batch files that just change the current drive and directory before\n"
						"executing the event.\n"
						"\n"
						"If this option is not used, the current NODE's directory will be the\n"
						"current DOS drive/directory before the command line is executed.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,10,"Directory"
						,cfg.event[i]->dir,sizeof(cfg.event[i]->dir)-1,K_EDIT);
					break;
				case 2:
					uifc.helpbuf=
						"`Timed Event Command Line:`\n"
						"\n"
						"This is the command line to execute upon this timed event.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,10,"Command"
						,cfg.event[i]->cmd,sizeof(cfg.event[i]->cmd)-1,K_EDIT);
					break;

				case 3:
					k=(cfg.event[i]->misc&EVENT_DISABLED) ? 1:0;
					uifc.helpbuf=
						"`Event Enabled:`\n"
						"\n"
						"If you want disable this event from executing, set this option to ~No~.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Enabled",uifcYesNoOpts);
					if((k==0 && cfg.event[i]->misc&EVENT_DISABLED) 
						|| (k==1 && !(cfg.event[i]->misc&EVENT_DISABLED))) {
						cfg.event[i]->misc^=EVENT_DISABLED;
						uifc.changes=1; 
					}
					break;

				case 4:
					uifc.helpbuf=
						"`Timed Event Node:`\n"
						"\n"
						"This is the node number to execute the timed event.\n"
					;
					sprintf(str,"%u",cfg.event[i]->node);
					uifc.input(WIN_MID|WIN_SAV,0,0,"Node Number"
						,str,3,K_EDIT|K_NUMBER);
					cfg.event[i]->node=atoi(str);
					break;
				case 5:
					uifc.helpbuf=
						"`Months to Execute Event:`\n"
						"\n"
						"Specifies the months (`Jan`-`Dec`, separated by spaces) on which \n"
						"to execute this event, or `Any` to execute event for any/all months.\n"
					;
					SAFECOPY(str,monthstr(cfg.event[i]->months));
					uifc.input(WIN_MID|WIN_SAV,0,0,"Months to Execute Event (or Any)"
						,str,50,K_EDIT);
					cfg.event[i]->months=0;
					for(p=str;*p;p++) {
						if(atoi(p)) {
							cfg.event[i]->months|=(1<<(atoi(p)-1));
							while(*p && isdigit(*p))
								p++;
						} else {
							for(j=0;j<12;j++)
								if(strnicmp(mon[j],p,3)==0) {
									cfg.event[i]->months|=(1<<j);
									p+=2;
									break;
								}
							p++;
626
						}
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
					}
					break;
				case 6:
					uifc.helpbuf=
						"`Days of Month to Execute Event:`\n"
						"\n"
						"Specifies the days of the month (`1-31`, separated by spaces) on which \n"
						"to execute this event, or `Any` to execute event on any and all days of\n"
						"the month.\n"
					;
					SAFECOPY(str,mdaystr(cfg.event[i]->mdays));
					uifc.input(WIN_MID|WIN_SAV,0,0,"Days of Month to Execute Event (or Any)"
						,str,16,K_EDIT);
					cfg.event[i]->mdays=0;
					for(p=str;*p;p++) {
						if(!isdigit(*p))
							continue;
						cfg.event[i]->mdays|=(1<<atoi(p));
						while(*p && isdigit(*p))
							p++;
					}
					break;
				case 7:
					j=0;
					while(1) {
						for(k=0;k<7;k++)
							sprintf(opt[k],"%-30s %3s"
								,wday[k],(cfg.event[i]->days&(1<<k)) ? "Yes":"No");
						strcpy(opt[k++],"All");
						strcpy(opt[k++],"None");
						opt[k][0]=0;
658
						uifc.helpbuf=
659
							"`Days of Week to Execute Event:`\n"
660
							"\n"
661
							"These are the days of the week that this event will be executed.\n"
662
						;
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
						k=uifc.list(WIN_MID|WIN_SAV|WIN_ACT,0,0,0,&j,0
							,"Days of Week to Execute Event",opt);
						if(k==-1)
							break;
						if(k==7)
							cfg.event[i]->days=(uchar)0xff;
						else if(k==8)
							cfg.event[i]->days=0;
						else
							cfg.event[i]->days^=(1<<k);
						uifc.changes=1; 
					}
					break;
				case 8:
					if(cfg.event[i]->freq==0)
						k=0;
					else
						k=1;
					uifc.helpbuf=
						"`Execute Event at a Specific Time:`\n"
						"\n"
						"If you want the system execute this event at a specific time, set\n"
						"this option to `Yes`. If you want the system to execute this event more\n"
						"than once a day at predetermined intervals, set this option to `No`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Execute Event at a Specific Time",uifcYesNoOpts);
					if(k==0) {
						sprintf(str,"%2.2u:%2.2u",cfg.event[i]->time/60
							,cfg.event[i]->time%60);
						uifc.helpbuf=
							"`Time to Execute Event:`\n"
							"\n"
							"This is the time (in 24 hour HH:MM format) to execute the event.\n"
						;
						if(uifc.input(WIN_MID|WIN_SAV,0,0
							,"Time to Execute Event (HH:MM)"
							,str,5,K_UPPER|K_EDIT)>0) {
							cfg.event[i]->freq=0;
							cfg.event[i]->time=atoi(str)*60;
							if((p=strchr(str,':'))!=NULL)
								cfg.event[i]->time+=atoi(p+1); 
						} 
					}
					else if(k==1) {
						sprintf(str,"%u"
							,cfg.event[i]->freq && cfg.event[i]->freq<=1440
								? 1440/cfg.event[i]->freq : 0);
						uifc.helpbuf=
							"`Number of Executions Per Day:`\n"
							"\n"
							"This is the maximum number of times the system will execute this event\n"
							"per day.\n"
						;
						if(uifc.input(WIN_MID|WIN_SAV,0,0
							,"Number of Executions Per Day"
							,str,4,K_NUMBER|K_EDIT)>0) {
							cfg.event[i]->time=0;
							k=atoi(str);
							if(k && k<=1440)
								cfg.event[i]->freq=1440/k;
							else
								cfg.event[i]->freq=0;
							}
727
						}
rswindell's avatar
rswindell committed
728
					break;
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
				case 9:
					k=(cfg.event[i]->misc&EVENT_EXCL) ? 0:1;
					uifc.helpbuf=
						"`Exclusive Event Execution:`\n"
						"\n"
						"If this event must be run exclusively (all nodes inactive), set this\n"
						"option to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0,"Exclusive Execution"
						,uifcYesNoOpts);
					if(!k && !(cfg.event[i]->misc&EVENT_EXCL)) {
						cfg.event[i]->misc|=EVENT_EXCL;
						uifc.changes=1; 
					}
					else if(k==1 && cfg.event[i]->misc&EVENT_EXCL) {
						cfg.event[i]->misc&=~EVENT_EXCL;
						uifc.changes=1; 
746
					}
rswindell's avatar
rswindell committed
747
					break;
748
749
750
751
752
753
754
755
756
757
758
759
760
				case 10:
					k=(cfg.event[i]->misc&EVENT_FORCE) ? 0:1;
					uifc.helpbuf=
						"`Force Users Off-line for Event:`\n"
						"\n"
						"If you want to have your users' on-line time reduced so the event can\n"
						"execute precisely on time, set this option to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Force Users Off-line for Event",uifcYesNoOpts);
					if(!k && !(cfg.event[i]->misc&EVENT_FORCE)) {
						cfg.event[i]->misc|=EVENT_FORCE;
						uifc.changes=1; 
761
					}
762
763
764
					else if(k==1 && (cfg.event[i]->misc&EVENT_FORCE)) {
						cfg.event[i]->misc&=~EVENT_FORCE;
						uifc.changes=1; 
765
					}
766
767
768
769
					break;

				case 11:
					k=(cfg.event[i]->misc&EX_NATIVE) ? 0:1;
770
					uifc.helpbuf=
771
						"`Native Executable:`\n"
772
						"\n"
773
774
						"If this event program is a native (e.g. non-DOS) executable,\n"
						"set this option to `Yes`.\n"
775
					;
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Native",uifcYesNoOpts);
					if(!k && !(cfg.event[i]->misc&EX_NATIVE)) {
						cfg.event[i]->misc|=EX_NATIVE;
						uifc.changes=TRUE;
					}
					else if(k==1 && (cfg.event[i]->misc&EX_NATIVE)) {
						cfg.event[i]->misc&=~EX_NATIVE;
						uifc.changes=TRUE;
					}
					break;

				case 12:
					k=(cfg.event[i]->misc&XTRN_SH) ? 0:1;
					uifc.helpbuf=
						"`Use Shell to Execute Command:`\n"
						"\n"
						"If this command-line requires the system command shell to execute, (Unix \n"
794
						"shell script or DOS/Windows batch/command file), set this option to ~Yes~.\n"
795
796
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
797
						,"Use System Command Shell",uifcYesNoOpts);
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
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
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
					if(!k && !(cfg.event[i]->misc&XTRN_SH)) {
						cfg.event[i]->misc|=XTRN_SH;
						uifc.changes=TRUE;
					}
					else if(k==1 && (cfg.event[i]->misc&XTRN_SH)) {
						cfg.event[i]->misc&=~XTRN_SH;
						uifc.changes=TRUE;
					}
					break;

				case 13:
					k=(cfg.event[i]->misc&EX_BG) ? 0:1;
					uifc.helpbuf=
						"`Execute Event in Background (Asynchronously):`\n"
						"\n"
						"If you would like this event to run simultaneously with other events,\n"
						"set this option to `Yes`. Exclusive events will not run in the background.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Background (Asynchronous) Execution",uifcYesNoOpts);
					if(!k && !(cfg.event[i]->misc&EX_BG)) {
						cfg.event[i]->misc|=EX_BG;
						uifc.changes=TRUE;
					}
					else if(k==1 && (cfg.event[i]->misc&EX_BG)) {
						cfg.event[i]->misc&=~EX_BG;
						uifc.changes=TRUE;
					}
					break;

				case 14:
					k=(cfg.event[i]->misc&EVENT_INIT) ? 0:1;
					uifc.helpbuf=
						"`Always Run After Initialization or Re-initialization:`\n"
						"\n"
						"If you want this event to always run after the BBS is initialized or\n"
						"re-initialized, set this option to ~Yes~.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Always Run After Initialization or Re-initialization",uifcYesNoOpts);
					if(!k && !(cfg.event[i]->misc&EVENT_INIT)) {
						cfg.event[i]->misc|=EVENT_INIT;
						uifc.changes=1; 
					}
					else if(k==1 && (cfg.event[i]->misc&EVENT_INIT)) {
						cfg.event[i]->misc&=~EVENT_INIT;
						uifc.changes=1; 
					}
					break;
			} 
		} 
	}
}


void xtrn_cfg(uint section)
{
	static int ext_dflt,ext_bar,sub_bar,opt_dflt,time_dflt;
	char str[128],code[128],done=0;
	int j,k;
	uint i,xtrnnum[MAX_OPTS+1];
	static xtrn_t savxtrn;

	sub_bar=0;
	opt_dflt=0;

	while(1) {
		for(i=0,j=0;i<cfg.total_xtrns && j<MAX_OPTS;i++)
			if(cfg.xtrn[i]->sec==section) {
				sprintf(opt[j],"%-25s",cfg.xtrn[i]->name);
				xtrnnum[j++]=i; 
			}
		xtrnnum[j]=cfg.total_xtrns;
		opt[j][0]=0;
		i=WIN_ACT|WIN_CHE|WIN_SAV|WIN_RHT;
		if(j)
			i|=WIN_DEL | WIN_COPY;
		if(cfg.total_xtrns<MAX_OPTS)
			i|=WIN_INS|WIN_INSACT|WIN_XTR;
		if(savxtrn.name[0])
			i|=WIN_PASTE | WIN_PASTEXTR;
		uifc.helpbuf=
			"`Online External Programs:`\n"
			"\n"
			"This is a list of the configured online external programs (doors).\n"
			"\n"
			"To add a program, select the desired location with the arrow keys and\n"
			"hit ~ INS ~.\n"
			"\n"
			"To delete a program, select it with the arrow keys and hit ~ DEL ~.\n"
			"\n"
			"To configure a program, select it with the arrow keys and hit ~ ENTER ~.\n"
		;
		sprintf(str,"%s Online Programs",cfg.xtrnsec[section]->name);
		i=uifc.list(i,0,0,45,&ext_dflt,&ext_bar,str,opt);
		if((signed)i==-1)
			return;
		int msk = i & MSK_ON;
		i &= MSK_OFF;
		if(msk == MSK_INS) {
			uifc.helpbuf=
				"`Online Program Name:`\n"
				"\n"
				"This is the name or description of the online program (door).\n"
			;
			if(uifc.input(WIN_MID|WIN_SAV,0,0,"Online Program Name",str,25
				,0)<1)
				continue;
			SAFECOPY(code,str);
			prep_code(code,/* prefix: */NULL);
			uifc.helpbuf=
				"`Online Program Internal Code:`\n"
				"\n"
				"Every online program must have its own unique code for Synchronet to\n"
912
				"refer to it internally. This code is usually an abbreviation of the\n"
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
				"online program name.\n"
			;
			if(uifc.input(WIN_MID|WIN_SAV,0,0,"Internal Code"
				,code,LEN_CODE,K_EDIT|K_UPPER)<1)
				continue;
			if(!code_ok(code)) {
				uifc.helpbuf=invalid_code;
				uifc.msg("Invalid Code");
				uifc.helpbuf=0;
				continue; 
			}
			if (!new_external_program(xtrnnum[i], section))
				continue;
			SAFECOPY(cfg.xtrn[xtrnnum[i]]->name,str);
			SAFECOPY(cfg.xtrn[xtrnnum[i]]->code,code);
			uifc.changes=TRUE;
			continue; 
		}
		if(msk == MSK_DEL || msk == MSK_CUT) {
			if(msk == MSK_CUT)
				savxtrn = *cfg.xtrn[xtrnnum[i]];
			free(cfg.xtrn[xtrnnum[i]]);
			cfg.total_xtrns--;
			for(j=xtrnnum[i];j<cfg.total_xtrns;j++)
				cfg.xtrn[j]=cfg.xtrn[j+1];
			uifc.changes=TRUE;
			continue; 
		}
		if(msk == MSK_COPY) {
			savxtrn=*cfg.xtrn[xtrnnum[i]];
			continue; 
		}
		if(msk == MSK_PASTE_OVER || msk == MSK_PASTE_INSERT) {
			if (msk == MSK_PASTE_INSERT) {
				if (!new_external_program(xtrnnum[i], section))
					continue;
			}
			else if (opt[i][0] == 0) {	/* Paste-over extra/blank item */
				if (!new_external_program(cfg.total_xtrns, section))
					continue;
			}
			*cfg.xtrn[xtrnnum[i]]=savxtrn;
			cfg.xtrn[xtrnnum[i]]->sec=section;
			uifc.changes=TRUE;
			continue; 
		}
		if (msk != 0)
			continue;
		done=0;
		i=xtrnnum[i];
		while(!done) {
			k=0;
			sprintf(opt[k++],"%-27.27s%s","Name",cfg.xtrn[i]->name);
			sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.xtrn[i]->code);
			sprintf(opt[k++],"%-27.27s%.40s","Start-up Directory",cfg.xtrn[i]->path);
			sprintf(opt[k++],"%-27.27s%.40s","Command Line",cfg.xtrn[i]->cmd);
			sprintf(opt[k++],"%-27.27s%.40s","Clean-up Command Line",cfg.xtrn[i]->clean);
			if(cfg.xtrn[i]->cost)
				sprintf(str,"%"PRIu32" credits",cfg.xtrn[i]->cost);
			else
				strcpy(str,"None");
			sprintf(opt[k++],"%-27.27s%s","Execution Cost",str);
			sprintf(opt[k++],"%-27.27s%.40s","Access Requirements",cfg.xtrn[i]->arstr);
			sprintf(opt[k++],"%-27.27s%.40s","Execution Requirements"
				,cfg.xtrn[i]->run_arstr);
			sprintf(opt[k++],"%-27.27s%s","Multiple Concurrent Users"
				,cfg.xtrn[i]->misc&MULTIUSER ? "Yes" : "No");
			sprintf(opt[k++],"%-27.27s%s%s%s","Intercept I/O"
				,cfg.xtrn[i]->misc&XTRN_STDIO ? "Standard"
					: cfg.xtrn[i]->misc&XTRN_CONIO ? "Console":"No"
				,(cfg.xtrn[i]->misc&(XTRN_STDIO|WWIVCOLOR))
					==(XTRN_STDIO|WWIVCOLOR) ? ", WWIV Color" : nulstr
				,(cfg.xtrn[i]->misc&(XTRN_STDIO|XTRN_NOECHO))
					==(XTRN_STDIO|XTRN_NOECHO) ? ", No Echo" : nulstr);
			sprintf(opt[k++],"%-27.27s%s","Native Executable"
				,cfg.xtrn[i]->misc&XTRN_NATIVE ? "Yes" : "No");
			sprintf(opt[k++],"%-27.27s%s","Use Shell to Execute"
				,cfg.xtrn[i]->misc&XTRN_SH ? "Yes" : "No");
			sprintf(opt[k++],"%-27.27s%s","Modify User Data"
				,cfg.xtrn[i]->misc&MODUSERDAT ? "Yes" : "No");
			switch(cfg.xtrn[i]->event) {
				case EVENT_LOGON:
					strcpy(str,"Logon");
					break;
				case EVENT_LOGOFF:
					strcpy(str,"Logoff");
					break;
				case EVENT_NEWUSER:
					strcpy(str,"New User");
					break;
				case EVENT_BIRTHDAY:
					strcpy(str,"Birthday");
					break;
				case EVENT_POST:
					strcpy(str,"Message Posted");
					break;
				case EVENT_UPLOAD:
					strcpy(str,"File Uploaded");
					break;
				case EVENT_DOWNLOAD:
					strcpy(str,"File Downloaded");
					break;
				case EVENT_LOCAL_CHAT:
					strcpy(str,"Local/Sysop Chat");
					break;
				default:
					strcpy(str,"No");
					break; 
			}
			if((cfg.xtrn[i]->misc&EVENTONLY) && cfg.xtrn[i]->event)
				strcat(str,", Only");
			sprintf(opt[k++],"%-27.27s%s","Execute on Event",str);
			sprintf(opt[k++],"%-27.27s%s","Pause After Execution"
				,cfg.xtrn[i]->misc&XTRN_PAUSE ? "Yes" : "No");
			sprintf(opt[k++],"%-23.23s%-4s%s","BBS Drop File Type"
				,cfg.xtrn[i]->misc&REALNAME ? "(R)":nulstr
				,dropfile(cfg.xtrn[i]->type,cfg.xtrn[i]->misc));
			sprintf(opt[k++],"%-27.27s%s","Place Drop File In"
				,cfg.xtrn[i]->misc&STARTUPDIR ? "Start-Up Directory":"Node Directory");
			sprintf(opt[k++],"Time Options...");
			opt[k][0]=0;
			uifc.helpbuf=
				"`Online Program Configuration:`\n"
				"\n"
				"This menu is for configuring the selected online program.\n"
			;
			switch(uifc.list(WIN_SAV|WIN_ACT|WIN_MID,0,0,60,&opt_dflt,&sub_bar,cfg.xtrn[i]->name
				,opt)) {
				case -1:
					done=1;
					break;
				case 0:
					uifc.helpbuf=
						"`Online Program Name:`\n"
						"\n"
						"This is the name or description of the online program (door).\n"
					;
					strcpy(str,cfg.xtrn[i]->name);
					if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Online Program Name"
						,cfg.xtrn[i]->name,sizeof(cfg.xtrn[i]->name)-1,K_EDIT))
						strcpy(cfg.xtrn[i]->name,str);
					break;
				case 1:
					uifc.helpbuf=
						"`Online Program Internal Code:`\n"
						"\n"
						"Every online program must have its own unique code for Synchronet to\n"
1060
						"refer to it internally. This code is usually an abbreviation of the\n"
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
						"online program name.\n"
					;
					strcpy(str,cfg.xtrn[i]->code);
					uifc.input(WIN_MID|WIN_SAV,0,10,"Internal Code"
						,str,LEN_CODE,K_UPPER|K_EDIT);
					if(code_ok(str))
						strcpy(cfg.xtrn[i]->code,str);
					else {
						uifc.helpbuf=invalid_code;
						uifc.msg("Invalid Code");
						uifc.helpbuf=0; 
					}
					break;
				case 2:
					uifc.helpbuf=
						"`Online Program Start-up Directory:`\n"
						"\n"
						"This is the DOS drive/directory where the online program is located.\n"
						"If a path is specified here, it will be made the current directory\n"
						"before the program's command line is executed. This eliminates the need\n"
						"for batch files that just change the current drive and directory before\n"
						"executing the program.\n"
						"\n"
						"If this option is not used, the current NODE's directory will be the\n"
						"current DOS drive/directory before the command line is executed.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,10,""
						,cfg.xtrn[i]->path,sizeof(cfg.xtrn[i]->path)-1,K_EDIT);
					break;
				case 3:
					uifc.helpbuf=
						"`Online Program Command Line:`\n"
						"\n"
						"This is the command line to execute to run the online program.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,10,"Command"
						,cfg.xtrn[i]->cmd,sizeof(cfg.xtrn[i]->cmd)-1,K_EDIT);
					break;
				case 4:
					uifc.helpbuf=
						"`Online Program Clean-up Command:`\n"
						"\n"
						"This is the command line to execute after the main command line. This\n"
						"option is usually only used for multiuser online programs.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,10,"Clean-up"
						,cfg.xtrn[i]->clean,sizeof(cfg.xtrn[i]->clean)-1,K_EDIT);
					break;
				case 5:
					ultoa(cfg.xtrn[i]->cost,str,10);
					uifc.helpbuf=
						"`Online Program Cost to Run:`\n"
						"\n"
						"If you want users to be charged credits to run this online program,\n"
						"set this value to the number of credits to charge. If you want this\n"
						"online program to be free, set this value to `0`.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,0,"Cost to Run (in Credits)"
						,str,10,K_EDIT|K_NUMBER);
					cfg.xtrn[i]->cost=atol(str);
					break;
				case 6:
					sprintf(str,"%s Access",cfg.xtrn[i]->name);
					getar(str,cfg.xtrn[i]->arstr);
					break;
				case 7:
					sprintf(str,"%s Execution",cfg.xtrn[i]->name);
					getar(str,cfg.xtrn[i]->run_arstr);
					break;
				case 8:
					k=(cfg.xtrn[i]->misc&MULTIUSER) ? 0:1;
					uifc.helpbuf=
						"`Supports Multiple Users:`\n"
						"\n"
						"If this online program supports multiple simultaneous users (nodes),\n"
						"set this option to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0,"Supports Multiple Users"
						,uifcYesNoOpts);
					if(!k && !(cfg.xtrn[i]->misc&MULTIUSER)) {
						cfg.xtrn[i]->misc|=MULTIUSER;
						uifc.changes=TRUE; 
					}
					else if(k==1 && (cfg.xtrn[i]->misc&MULTIUSER)) {
						cfg.xtrn[i]->misc&=~MULTIUSER;
						uifc.changes=TRUE; 
					}
					break;
				case 9:
					switch(cfg.xtrn[i]->misc&(XTRN_STDIO|XTRN_CONIO)) {
						case XTRN_STDIO:
							k=0;
rswindell's avatar
rswindell committed
1153
							break;
1154
1155
						case XTRN_CONIO:
							k=1;
rswindell's avatar
rswindell committed
1156
							break;
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
						default:
							k=2;
					}
					strcpy(opt[0],"Standard");
					strcpy(opt[1],"Console");
					strcpy(opt[2],"No");
					opt[3][0]=0;
					uifc.helpbuf=
						"`Intercept I/O:`\n"
						"\n"
						"If this online program uses a FOSSIL driver or SOCKET communications,\n"
						"set this option to `No`.\n"
					;
					switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0,"Intercept I/O"
						,opt)) {
						case 0: /* Standard I/O */
							if((cfg.xtrn[i]->misc&(XTRN_STDIO|XTRN_CONIO)) != XTRN_STDIO) {
								cfg.xtrn[i]->misc|=XTRN_STDIO;
								cfg.xtrn[i]->misc&=~XTRN_CONIO;
								uifc.changes=1;
							}
							k=(cfg.xtrn[i]->misc&WWIVCOLOR) ? 0:1;
1179
							uifc.helpbuf=
1180
								"`Program Uses WWIV Color Codes:`\n"
1181
								"\n"
1182
1183
								"If this program was written for use exclusively under ~WWIV~ BBS\n"
								"software, set this option to ~Yes~.\n"
1184
							;
1185
							k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
1186
1187
1188
1189
								,"Program Uses WWIV Color Codes"
								,uifcYesNoOpts);
							if(!k && !(cfg.xtrn[i]->misc&WWIVCOLOR)) {
								cfg.xtrn[i]->misc|=WWIVCOLOR;
1190
1191
								uifc.changes=TRUE; 
							}
1192
1193
							else if(k==1 && (cfg.xtrn[i]->misc&WWIVCOLOR)) {
								cfg.xtrn[i]->misc&=~WWIVCOLOR;
1194
1195
								uifc.changes=TRUE; 
							}
1196
							k=(cfg.xtrn[i]->misc&XTRN_NOECHO) ? 1:0;
1197
							uifc.helpbuf=
1198
								"`Echo Input:`\n"
1199
								"\n"
1200
1201
								"If you want the BBS to copy (\"echo\") all keyboard input to the screen\n"
								"output, set this option to ~Yes~ (for native Win32 programs only).\n"
1202
							;
1203
							k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
1204
1205
1206
1207
1208
1209
1210
								,"Echo Keyboard Input"
								,uifcYesNoOpts);
							if(!k && (cfg.xtrn[i]->misc&XTRN_NOECHO)) {
								cfg.xtrn[i]->misc&=~XTRN_NOECHO;
								uifc.changes=TRUE; 
							} else if(k==1 && !(cfg.xtrn[i]->misc&XTRN_NOECHO)) {
								cfg.xtrn[i]->misc|=XTRN_NOECHO;
1211
1212
								uifc.changes=TRUE; 
							}
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
							break;
						case 1: /* Console I/O */
							if((cfg.xtrn[i]->misc&(XTRN_STDIO|XTRN_CONIO)) != XTRN_CONIO) {
								cfg.xtrn[i]->misc|=XTRN_CONIO;
								cfg.xtrn[i]->misc&=~(XTRN_STDIO|WWIVCOLOR|XTRN_NOECHO);
								uifc.changes=TRUE; 
							}
							break;
						case 2:	/* No */
							if((cfg.xtrn[i]->misc&(XTRN_STDIO|XTRN_CONIO)) != 0) {
								cfg.xtrn[i]->misc&=~(XTRN_CONIO|XTRN_STDIO|WWIVCOLOR|XTRN_NOECHO);
1224
1225
								uifc.changes=TRUE; 
							}
1226
							break;
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
					}
					break;
				case 10:
					k=(cfg.xtrn[i]->misc&XTRN_NATIVE) ? 0:1;
					uifc.helpbuf=
						"`Native Executable:`\n"
						"\n"
						"If this online program is a native (e.g. non-DOS) executable,\n"
						"set this option to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Native",uifcYesNoOpts);
					if(!k && !(cfg.xtrn[i]->misc&XTRN_NATIVE)) {
						cfg.xtrn[i]->misc|=XTRN_NATIVE;
						uifc.changes=TRUE; 
					}
					else if(k==1 && (cfg.xtrn[i]->misc&XTRN_NATIVE)) {
						cfg.xtrn[i]->misc&=~XTRN_NATIVE;
						uifc.changes=TRUE; 
					}
					break;
				case 11:
					k=(cfg.xtrn[i]->misc&XTRN_SH) ? 0:1;
					uifc.helpbuf=
						"`Use Shell to Execute Command:`\n"
						"\n"
						"If this command-line requires the system command shell to execute, (Unix \n"
						"shell script or DOS batch file), set this option to ~Yes~.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Use Shell",uifcYesNoOpts);
					if(!k && !(cfg.xtrn[i]->misc&XTRN_SH)) {
						cfg.xtrn[i]->misc|=XTRN_SH;
						uifc.changes=TRUE; 
					}
					else if(k==1 && (cfg.xtrn[i]->misc&XTRN_SH)) {
						cfg.xtrn[i]->misc&=~XTRN_SH;
						uifc.changes=TRUE; 
					}
					break;
				case 12:
					k=(cfg.xtrn[i]->misc&MODUSERDAT) ? 0:1;
					uifc.helpbuf=
						"`Program Can Modify User Data:`\n"
						"\n"
						"If this online programs recognizes the Synchronet MODUSER.DAT format\n"
						"or the RBBS/QuickBBS EXITINFO.BBS format and you want it to be able to\n"
						"modify the data of users who run the program, set this option to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Program Can Modify User Data",uifcYesNoOpts);
					if(!k && !(cfg.xtrn[i]->misc&MODUSERDAT)) {
						cfg.xtrn[i]->misc|=MODUSERDAT;
						uifc.changes=TRUE; 
					}
					else if(k==1 && (cfg.xtrn[i]->misc&MODUSERDAT)) {
						cfg.xtrn[i]->misc&=~MODUSERDAT;
						uifc.changes=TRUE; 
					}
					break;
				case 13:
					k=0;
					strcpy(opt[k++],"No");
					strcpy(opt[k++],"Logon");
					strcpy(opt[k++],"Logoff");
					strcpy(opt[k++],"New User");
					strcpy(opt[k++],"Birthday");
					strcpy(opt[k++],"Message Posted");
					strcpy(opt[k++],"File Uploaded");
					strcpy(opt[k++],"File Downloaded");
					strcpy(opt[k++],"Local/Sysop Chat");
					opt[k][0]=0;
					k=cfg.xtrn[i]->event;
					uifc.helpbuf=
						"`Execute Online Program on Event:`\n"
						"\n"
						"If you would like this online program to automatically execute on a\n"
						"specific user event, select the event. Otherwise, select `No`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Execute on Event",opt);
					if(k==-1)
						break;
					if(cfg.xtrn[i]->event!=k) {
						cfg.xtrn[i]->event=k;
						uifc.changes=TRUE; 
					}
					if(!cfg.xtrn[i]->event) {
						if(cfg.xtrn[i]->misc&EVENTONLY) {
							cfg.xtrn[i]->misc&=~EVENTONLY;
							uifc.changes=TRUE; 
						}
						break;
					}
					k=(cfg.xtrn[i]->misc&EVENTONLY) ? 0:1;
					uifc.helpbuf=
						"`Execute Online Program as Event Only:`\n"
						"\n"
						"If you would like this online program to execute as an event only\n"
						"(not available to users on the online program menu), set this option\n"
						"to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k
						,0,"Execute as Event Only"
						,uifcYesNoOpts);
					if(!k && !(cfg.xtrn[i]->misc&EVENTONLY)) {
						cfg.xtrn[i]->misc|=EVENTONLY;
						uifc.changes=TRUE; 
					}
					else if(k==1 && (cfg.xtrn[i]->misc&EVENTONLY)) {
						cfg.xtrn[i]->misc&=~EVENTONLY;
						uifc.changes=TRUE; 
					}
					break;
				case 14:
					k=(cfg.xtrn[i]->misc&XTRN_PAUSE) ? 0:1;
					uifc.helpbuf=
						"`Pause Screen After Execution:`\n"
						"\n"
						"Set this option to ~Yes~ if you would like an automatic screen pause\n"
						"(`[Hit a key]` prompt) to appear after the program executes.\n"
						"\n"
						"This can be useful if the program displays information just before exiting\n"
						"or you want to debug a program with a program not running correctly.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Pause After Execution",uifcYesNoOpts);
					if((!k && !(cfg.xtrn[i]->misc&XTRN_PAUSE))
						|| (k && (cfg.xtrn[i]->misc&XTRN_PAUSE))) {
						cfg.xtrn[i]->misc^=XTRN_PAUSE;
						uifc.changes=TRUE; 
					}
					break;
				case 15:
					k=0;
					strcpy(opt[k++],"None");
					sprintf(opt[k++],"%-15s %s","Synchronet","XTRN.DAT");
					sprintf(opt[k++],"%-15s %s","WWIV","CHAIN.TXT");
					sprintf(opt[k++],"%-15s %s","GAP","DOOR.SYS");
					sprintf(opt[k++],"%-15s %s","RBBS/QuickBBS","DORINFO#.DEF");
					sprintf(opt[k++],"%-15s %s","Wildcat","CALLINFO.BBS");
					sprintf(opt[k++],"%-15s %s","PCBoard","PCBOARD.SYS");
					sprintf(opt[k++],"%-15s %s","SpitFire","SFDOORS.DAT");
					sprintf(opt[k++],"%-15s %s","MegaMail","UTIDOOR.TXT");
					sprintf(opt[k++],"%-15s %s","Solar Realms","DOORFILE.SR");
					sprintf(opt[k++],"%-15s %s","RBBS/QuickBBS","DORINFO1.DEF");
					sprintf(opt[k++],"%-15s %s","TriBBS","TRIBBS.SYS");
					sprintf(opt[k++],"%-15s %s","Mystic","DOOR32.SYS");
					opt[k][0]=0;
					k=cfg.xtrn[i]->type;
					uifc.helpbuf=
						"`Online Program BBS Drop File Type:`\n"
						"\n"
						"If this online program requires a specific BBS data (drop) file\n"
						"format, select the file format from the list.\n"
					;
					k=uifc.list(WIN_MID|WIN_ACT,0,0,0,&k,0
						,"BBS Drop File Type",opt);
					if(k==-1)
						break;
					if(cfg.xtrn[i]->type!=k) {
						cfg.xtrn[i]->type=k;
						if(cfg.xtrn[i]->type==XTRN_DOOR32)
							cfg.xtrn[i]->misc|=XTRN_NATIVE;
						uifc.changes=TRUE; 
					}
					if(cfg.xtrn[i]->type && cfg.uq&UQ_ALIASES) {
						k=(cfg.xtrn[i]->misc&REALNAME) ? 0:1;
						k=uifc.list(WIN_MID,0,0,0,&k,0,"Use Real Names",uifcYesNoOpts);
						if(k==0 && !(cfg.xtrn[i]->misc&REALNAME)) {
							cfg.xtrn[i]->misc|=REALNAME;
							uifc.changes=TRUE; 
						}
						else if(k==1 && (cfg.xtrn[i]->misc&REALNAME)) {
							cfg.xtrn[i]->misc&=~REALNAME;
							uifc.changes=TRUE; 
						} 
					}
					if(cfg.xtrn[i]->type) {
						k=(cfg.xtrn[i]->misc&XTRN_LWRCASE) ? 0:1;
						k=uifc.list(WIN_MID,0,0,0,&k,0,"Lowercase Filename",uifcYesNoOpts);
						if(k==0 && !(cfg.xtrn[i]->misc&XTRN_LWRCASE)) {
							cfg.xtrn[i]->misc|=XTRN_LWRCASE;
							uifc.changes=TRUE; 
						}
						else if(k==1 && (cfg.xtrn[i]->misc&XTRN_LWRCASE)) {
							cfg.xtrn[i]->misc&=~XTRN_LWRCASE;
							uifc.changes=TRUE; 
1415
1416
						} 
					}
rswindell's avatar
rswindell committed
1417
					break;
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
				case 16:
					k=0;
					strcpy(opt[0],"Node Directory");
					strcpy(opt[1],"Start-up Directory");
					opt[2][0]=0;
					uifc.helpbuf=
						"`Directory for Drop File:`\n"
						"\n"
						"You can have the data file created in the current `Node Directory` or the\n"
						"`Start-up Directory` (if one is specified).\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0,"Create Drop File In"
						,opt);
					if(!k && cfg.xtrn[i]->misc&STARTUPDIR) {
						cfg.xtrn[i]->misc&=~STARTUPDIR;
						uifc.changes=TRUE; 
					}
					else if(k==1 && !(cfg.xtrn[i]->misc&STARTUPDIR)) {
						cfg.xtrn[i]->misc|=STARTUPDIR;
						uifc.changes=TRUE; 
					}
					break;
				case 17:
					while(1) {
						k=0;
						if(cfg.xtrn[i]->textra)
							sprintf(str,"%u minutes",cfg.xtrn[i]->textra);
						else
							strcpy(str,"None");
						sprintf(opt[k++],"%-25.25s%s","Extra Time",str);
						if(cfg.xtrn[i]->maxtime)
							sprintf(str,"%u minutes",cfg.xtrn[i]->maxtime);
						else
							strcpy(str,"None");
						sprintf(opt[k++],"%-25.25s%s","Maximum Time",str);
						sprintf(opt[k++],"%-25.25s%s","Suspended (Free) Time"
							,cfg.xtrn[i]->misc&FREETIME ? "Yes" : "No");
						sprintf(opt[k++],"%-25.25s%s","Monitor Time Left"
							,cfg.xtrn[i]->misc&XTRN_CHKTIME ? "Yes" : "No");
						opt[k][0]=0;
						uifc.helpbuf=
							"`Online Program Time Options:`\n"
							"\n"
							"This sub-menu allows you to define specific preferences regarding the\n"
							"time users spend running this program.\n"
						;
						k=uifc.list(WIN_SAV|WIN_ACT|WIN_RHT|WIN_BOT,0,0,40
							,&time_dflt,0
							,"Online Program Time Options",opt);
						if(k==-1)
							break;
						switch(k) {
							case 0:
								ultoa(cfg.xtrn[i]->textra,str,10);
								uifc.helpbuf=
									"`Extra Time to Give User in Program:`\n"
									"\n"
									"If you want to give users extra time while in this online program,\n"
									"set this value to the number of minutes to add to their current time\n"
									"left online.\n"
								;
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Extra Time to Give User (in minutes)"
									,str,2,K_EDIT|K_NUMBER);
								cfg.xtrn[i]->textra=atoi(str);
								break;
							case 1:
								ultoa(cfg.xtrn[i]->maxtime,str,10);
								uifc.helpbuf=
									"`Maximum Time Allowed in Program:`\n"
									"\n"
									"If this program supports a drop file that contains the number of minutes\n"
									"left online for the current user, this option allows the sysop to set\n"
									"the maximum number of minutes that will be allowed in the drop file.\n"
									"\n"
									"Setting this option to `0`, disables this feature.\n"
								;
								uifc.input(WIN_MID|WIN_SAV,0,0
									,"Maximum Time (in minutes, 0=disabled)"
									,str,2,K_EDIT|K_NUMBER);
								cfg.xtrn[i]->maxtime=atoi(str);
								break;
							case 2:
								k=(cfg.xtrn[i]->misc&FREETIME) ? 0:1;
								uifc.helpbuf=
									"`Suspended (Free) Time:`\n"
									"\n"
									"If you want the user's time online to be suspended while running this\n"
									"online program (e.g. Free Time), set this option to `Yes`.\n"
								;
								k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
									,"Suspended (Free) Time",uifcYesNoOpts);
								if(!k && !(cfg.xtrn[i]->misc&FREETIME)) {
									cfg.xtrn[i]->misc|=FREETIME;
									uifc.changes=TRUE; 
								}
								else if(k==1 && (cfg.xtrn[i]->misc&FREETIME)) {
									cfg.xtrn[i]->misc&=~FREETIME;
									uifc.changes=TRUE; 
								}
								break; 
							case 3:
								k=(cfg.xtrn[i]->misc&XTRN_CHKTIME) ? 0:1;
								uifc.helpbuf=
									"`Monitor Time Left:`\n"
									"\n"
									"If you want Synchronet to monitor the user's time left online while this\n"
									"program runs (and disconnect the user if their time runs out), set this\n"
									"option to `Yes`.\n"
								;
								k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
									,"Monitor Time Left",uifcYesNoOpts);
								if(!k && !(cfg.xtrn[i]->misc&XTRN_CHKTIME)) {
									cfg.xtrn[i]->misc|=XTRN_CHKTIME;
									uifc.changes=TRUE; 
								}
								else if(k==1 && (cfg.xtrn[i]->misc&XTRN_CHKTIME)) {
									cfg.xtrn[i]->misc&=~XTRN_CHKTIME;
									uifc.changes=TRUE; 
								}
								break;
							} 
						}
						break;
1542
1543
1544
				} 
			} 
	}
rswindell's avatar
rswindell committed
1545
1546
1547
1548
1549
}

void xedit_cfg()
{
	static int dflt,dfltopt,bar;
1550
	char str[81],code[81],done=0;
rswindell's avatar
rswindell committed
1551
1552
1553
1554
	int j,k;
	uint i;
	static xedit_t savxedit;

1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
	while(1) {
		for(i=0;i<cfg.total_xedits && i<MAX_OPTS;i++)
			sprintf(opt[i],"%-8.8s    %.40s",cfg.xedit[i]->code,cfg.xedit[i]->rcmd);
		opt[i][0]=0;
		j=WIN_SAV|WIN_ACT|WIN_CHE|WIN_RHT;
		if(cfg.total_xedits)
			j|=WIN_DEL | WIN_COPY;
		if(cfg.total_xedits<MAX_OPTS)
			j|=WIN_INS|WIN_INSACT|WIN_XTR;
		if(savxedit.name[0])
			j|=WIN_PASTE | WIN_PASTEXTR;
1566
		uifc.helpbuf=
1567
			"`External Editors:`\n"
1568
			"\n"
1569
1570
1571
			"This is a list of the configured external editors.\n"
			"\n"
			"To add an editor, select the desired location and hit ~ INS ~.\n"
1572
			"\n"
1573
1574
1575
			"To delete an editor, select it and hit ~ DEL ~.\n"
			"\n"
			"To configure an editor, select it and hit ~ ENTER ~.\n"
1576
		;
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
		i=uifc.list(j,0,0,45,&dflt,&bar,"External Editors",opt);
		if((signed)i==-1)
			return;
		int msk = i & MSK_ON;
		i &= MSK_OFF;
		if(msk == MSK_INS) {
			uifc.helpbuf=
				"`External Editor Name:`\n"
				"\n"
				"This is the name or description of the external editor.\n"
			;
			if(uifc.input(WIN_MID|WIN_SAV,0,0,"External Editor Name",str,40
				,0)<1)
				continue;
			SAFECOPY(code,str);
			prep_code(code,/* prefix: */NULL);
			uifc.helpbuf=
				"`External Editor Internal Code:`\n"
				"\n"
				"This is the internal code for the external editor.\n"
			;
			if(uifc.input(WIN_MID|WIN_SAV,0,0,"External Editor Internal Code",code,8
				,K_UPPER|K_EDIT)<1)
				continue;
			if(!code_ok(code)) {
				uifc.helpbuf=invalid_code;
				uifc.msg("Invalid Code");
				uifc.helpbuf=0;
				continue; 
			}
			if (!new_external_editor(i))
				continue;
			SAFECOPY(cfg.xedit[i]->name,str);
			SAFECOPY(cfg.xedit[i]->code,code);
			uifc.changes=TRUE;
			continue; 
1613
		}
1614
1615
1616
1617
1618
1619
1620
1621
1622
		if(msk == MSK_DEL || msk == MSK_CUT) {
			if(msk == MSK_CUT)
				savxedit = *cfg.xedit[i];
			free(cfg.xedit[i]);
			cfg.total_xedits--;
			for(j=i;j<cfg.total_xedits;j++)
				cfg.xedit[j]=cfg.xedit[j+1];
			uifc.changes=TRUE;
			continue; 
1623
		}
1624
1625
		if(msk == MSK_COPY) {
			savxedit=*cfg.xedit[i];
1626
1627
			continue; 
		}
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
		if(msk == MSK_PASTE_OVER || msk == MSK_PASTE_INSERT) {
			if (msk == MSK_PASTE_INSERT) {
				if (!new_external_editor(i))
					continue;
			}
			else if (opt[i][0] == 0) {	/* Paste-over extra/blank item */
				if (!new_external_editor(cfg.total_xedits))
					continue;
			}
			*cfg.xedit[i]=savxedit;
			uifc.changes=TRUE;
			continue; 
		}
		if (msk != 0)
			continue;
		done=0;
		while(!done) {
			k=0;
			sprintf(opt[k++],"%-32.32s%s","Name",cfg.xedit[i]->name);
			sprintf(opt[k++],"%-32.32s%s","Internal Code",cfg.xedit[i]->code);
			sprintf(opt[k++],"%-32.32s%.40s","Command Line",cfg.xedit[i]->rcmd);
			sprintf(opt[k++],"%-32.32s%.40s","Access Requirements",cfg.xedit[i]->arstr);
			sprintf(opt[k++],"%-32.32s%s%s","Intercept I/O"
				,cfg.xedit[i]->misc&XTRN_STDIO ? "Standard"
					:cfg.xedit[i]->misc&XTRN_CONIO ? "Console":"No"
				,(cfg.xedit[i]->misc&(XTRN_STDIO|WWIVCOLOR))
					==(XTRN_STDIO|WWIVCOLOR) ? ", WWIV Color" : nulstr);
			sprintf(opt[k++],"%-32.32s%s","Native Executable"
				,cfg.xedit[i]->misc&XTRN_NATIVE ? "Yes" : "No");
			sprintf(opt[k++],"%-32.32s%s","Use Shell to Execute"
				,cfg.xedit[i]->misc&XTRN_SH ? "Yes" : "No");
			sprintf(opt[k++],"%-32.32s%s","Word Wrap Quoted Text"
				,cfg.xedit[i]->misc&QUOTEWRAP ? "Yes":"No");
			sprintf(opt[k++],"%-32.32s%s","Automatically Quoted Text"
				,cfg.xedit[i]->misc&QUOTEALL ? "All":cfg.xedit[i]->misc&QUOTENONE
					? "None" : "Prompt User");
			sprintf(opt[k++],"%-32.32s%s","Editor Information Files"
				,cfg.xedit[i]->misc&QUICKBBS ? "QuickBBS MSGINF/MSGTMP":"WWIV EDITOR.INF/RESULT.ED");
			sprintf(opt[k++],"%-32.32s%s","Expand Line Feeds to CRLF"
				,cfg.xedit[i]->misc&EXPANDLF ? "Yes":"No");
			sprintf(opt[k++],"%-32.32s%s","Strip FidoNet Kludge Lines"
				,cfg.xedit[i]->misc&STRIPKLUDGE ? "Yes":"No");
			sprintf(opt[k++],"%-32.32s%s","BBS Drop File Type"
				,dropfile(cfg.xedit[i]->type,cfg.xedit[i]->misc));
			opt[k][0]=0;
			uifc.helpbuf=
				"`External Editor Configuration:`\n"
				"\n"
				"This menu allows you to change the settings for the selected external\n"
				"message editor. External message editors are very common on BBSs. Some\n"
				"popular editors include `SyncEdit`, `WWIVedit`, `FEdit`, `GEdit`, `IceEdit`,\n"
				"and many others.\n"
			;
rswindell's avatar
rswindell committed
1681

1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
			sprintf(str,"%s Editor",cfg.xedit[i]->name);
			switch(uifc.list(WIN_SAV|WIN_ACT|WIN_L2R|WIN_BOT,0,0,70,&dfltopt,0
				,str,opt)) {
				case -1:
					done=1;
					break;
				case 0:
					uifc.helpbuf=
						"`External Editor Name:`\n"
						"\n"
						"This is the name or description of the external editor.\n"
					;
					strcpy(str,cfg.xedit[i]->name);
					if(!uifc.input(WIN_MID|WIN_SAV,0,10,"External Editor Name"
						,cfg.xedit[i]->name,sizeof(cfg.xedit[i]->name)-1,K_EDIT))
						strcpy(cfg.xedit[i]->name,str);
					break;
				case 1:
					strcpy(str,cfg.xedit[i]->code);
					uifc.helpbuf=
						"`External Editor Internal Code:`\n"
						"\n"
						"Every external editor must have its own unique internal code for\n"
						"Synchronet to reference it by. It is helpful if this code is an\n"
1706
						"abbreviation of the name.\n"
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
					;
					uifc.input(WIN_MID|WIN_SAV,0,17,"Internal Code (unique)"
						,str,LEN_CODE,K_EDIT|K_UPPER);
					if(code_ok(str))
						strcpy(cfg.xedit[i]->code,str);
					else {
						uifc.helpbuf=invalid_code;
						uifc.msg("Invalid Code");
						uifc.helpbuf=0; 
					}
					break;
			   case 2:
					uifc.helpbuf=
						"`External Editor Command Line:`\n"
						"\n"
						"This is the command line to execute when using this editor.\n"
					;
					uifc.input(WIN_MID|WIN_SAV,0,10,"Command"
						,cfg.xedit[i]->rcmd,sizeof(cfg.xedit[i]->rcmd)-1,K_EDIT);
					break;
				case 3:
					sprintf(str,"%s External Editor",cfg.xedit[i]->name);
					getar(str,cfg.xedit[i]->arstr);
					break;
				case 4:
					switch(cfg.xedit[i]->misc&(XTRN_STDIO|XTRN_CONIO)) {
						case XTRN_STDIO:
							k=0;
							break;
						case XTRN_CONIO:
							k=1;
							break;
						default:
							k=2;
							break;
					}
					strcpy(opt[0],"Standard");
					strcpy(opt[1],"Console");
					strcpy(opt[2],"No");
					opt[3][0]=0;
					uifc.helpbuf=
						"`Intercept I/O:`\n"
						"\n"
						"If this program uses FOSSIL, Socket, or UART communications,\n"
						"set this option to `No`.\n"
					;
					switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0,"Intercept I/O"	,opt)) {
						case 0: /* Standard */
							if((cfg.xedit[i]->misc&(XTRN_STDIO|XTRN_CONIO)) != XTRN_STDIO) {
								cfg.xedit[i]->misc|=XTRN_STDIO;
								cfg.xedit[i]->misc&=~XTRN_CONIO;
								uifc.changes=TRUE; 
							}
							k=(cfg.xedit[i]->misc&WWIVCOLOR) ? 0:1;
							uifc.helpbuf=
								".Editor Uses WWIV Color Codes:.\n"
								"\n"
								"If this editor was written for use exclusively under WWIV, set this\n"
								"option to .Yes..\n"
							;
							k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
								,"Editor Uses WWIV Color Codes",uifcYesNoOpts);
							if(!k && !(cfg.xedit[i]->misc&WWIVCOLOR)) {
								cfg.xedit[i]->misc|=WWIVCOLOR;
								uifc.changes=TRUE; 
							}
							else if(k==1 && (cfg.xedit[i]->misc&WWIVCOLOR)) {
								cfg.xedit[i]->misc&=~WWIVCOLOR;
								uifc.changes=TRUE; 
							}
							break;
						case 1: /* Console */
							if((cfg.xedit[i]->misc&(XTRN_STDIO|XTRN_CONIO)) != XTRN_CONIO) {
								cfg.xedit[i]->misc|=XTRN_CONIO;
								cfg.xedit[i]->misc&=~(XTRN_STDIO|WWIVCOLOR);
								uifc.changes=TRUE; 
							}
							break;
						case 2: /* No */
							if((cfg.xedit[i]->misc&(XTRN_STDIO|XTRN_CONIO)) != 0) {
								cfg.xedit[i]->misc&=~(XTRN_CONIO|XTRN_STDIO|WWIVCOLOR);
								uifc.changes=TRUE; 
							}
							break;
					}
					break;
				case 5:
					k=(cfg.xedit[i]->misc&XTRN_NATIVE) ? 0:1;
					uifc.helpbuf=
						"`Native Executable:`\n"
						"\n"
						"If this editor is a native (non-DOS) executable, set this option to `Yes`.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Native",uifcYesNoOpts);
					if(!k && !(cfg.xedit[i]->misc&XTRN_NATIVE)) {
						cfg.xedit[i]->misc|=XTRN_NATIVE;
						uifc.changes=TRUE; 
					}
					else if(k==1 && (cfg.xedit[i]->misc&XTRN_NATIVE)) {
						cfg.xedit[i]->misc&=~XTRN_NATIVE;
						uifc.changes=TRUE; 
					}
					break;
				case 6:
					k=(cfg.xedit[i]->misc&XTRN_SH) ? 0:1;
					uifc.helpbuf=
						"`Use Shell to Execute Command:`\n"
						"\n"
						"If this command-line requires the system command shell to execute, (Unix \n"
						"shell script or DOS batch file), set this option to ~Yes~.\n"
					;
					k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
						,"Use Shell",uifcYesNoOpts);
					if(!k && !(cfg.xedit[i