scfg.h 6.53 KB
Newer Older
1 2 3 4
/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
5
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
6 7 8 9 10 11 12 13 14 15 16 17 18
 *																			*
 * 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										*
 *																			*
 * For Synchronet coding style and modification guidelines, see				*
 * http://www.synchro.net/source.html										*
 *																			*
 * Note: If this box doesn't appear square, then you need to fix your tabs.	*
 ****************************************************************************/
rswindell's avatar
rswindell committed
19 20 21

#include <stdio.h>
#include <stdlib.h>
22
#include <stdbool.h>
23
#include <limits.h>	/* USHRT_MAX */
rswindell's avatar
rswindell committed
24

25 26 27 28
#include "scfgsave.h"
#include "scfglib.h"
#include "date_str.h"
#include "str_util.h"
29
#include "gen_defs.h"
30 31 32
#include "smblib.h"
#include "load_cfg.h"
#include "ini_file.h"
33
#include "uifc.h"
34
#include "nopen.h"
rswindell's avatar
rswindell committed
35 36 37 38 39

/**********/
/* Macros */
/**********/

40 41
#define SETHELP(where)  uifc.sethelp(where)

42 43 44 45 46 47
#define SCFG_CMDLINE_PREFIX_HELP "\n"																				\
								"Command lines may begin with a special `prefix` character to indicate:\n"			\
								"\n"																				\
								"  `*`   Program is either a JavaScript (`.js`) or Baja (`.bin`) module\n"			\
								"  `?`   Program is a JavaScript (`.js`) module\n"

48
#define SCFG_CMDLINE_SPEC_HELP 	"\n"																				\
49
								"The following is a list of commonly-used command line specifiers:\n"				\
50
								"\n"																				\
51
								"  `%f`  The path/filename of the file to act upon or door/game `drop file`\n"		\
52 53
								"  `%s`  File specification (e.g. `*.txt`) or the current `Startup Directory`\n"	\
								"  `%.`  Executable file extension (`.exe`, or blank for Unix systems)\n"			\
54 55 56 57 58 59 60 61 62 63
								"  `%!`  The Synchronet `exec directory` (use `%@` for non-Unix only)\n"			\
								"  `%g`  The Synchronet `temp directory`\n"											\
								"  `%j`  The Synchronet `data directory`\n"											\
								"  `%k`  The Synchronet `ctrl directory`\n"											\
								"  `%z`  The Synchronet `text directory`\n"											\
								"  `%n`  The current `node directory`\n"											\
								"  `%#`  The current `node number`\n"												\
								"  `%a`  The current `user's alias`\n"												\
								"  `%1`  The current `user's number` (use `%2`, `%3`, etc. for 0-padded values)\n"	\
								"  `%h`  The current TCP/IP `socket` descriptor (handle) value\n"					\
64
								"  `%p`  The current connection type (protocol, e.g. `telnet`, `rlogin`, etc.)\n"	\
65 66
								"  `%r`  The current user's terminal height (`rows`)\n"								\
								"  `%w`  The current user's terminal width (`columns`)\n"							\
67 68 69 70
								"\n"																				\
								"For a complete list of the supported command-line specifiers, see:\n"				\
								"`http://wiki.synchro.net/config:cmdline`\n"

71 72 73 74
#define strInvalidCode			"Invalid Internal Code Rejected!"
#define strInvalidCodePrefix	"Invalid Internal Code Prefix Rejected!"
#define strDuplicateCode		"Duplicate Internal Code Rejected!"
#define strDuplicateCodePrefix	"Duplicate Internal Code Prefix Rejected!"
75

rswindell's avatar
rswindell committed
76 77 78 79 80 81
/*************/
/* Constants */
/*************/

#define SUB_HDRMOD	(1L<<31)		/* Modified sub-board header info */

82 83 84 85 86 87 88 89
#define MAX_UNIQUE_CODE_ATTEMPTS (36*36*36)

enum import_list_type {
	IMPORT_LIST_TYPE_SUBS_TXT,
	IMPORT_LIST_TYPE_QWK_CONTROL_DAT,
	IMPORT_LIST_TYPE_GENERIC_AREAS_BBS,
	IMPORT_LIST_TYPE_SBBSECHO_AREAS_BBS,
	IMPORT_LIST_TYPE_BACKBONE_NA,
90
	IMPORT_LIST_TYPE_BAD_AREAS,
91 92
	IMPORT_LIST_TYPE_ECHOSTATS,
	IMPORT_LIST_TYPE_NEWSGROUPS
93 94
};

rswindell's avatar
rswindell committed
95 96 97 98 99 100 101 102
/************/
/* Typedefs */
/************/

/********************/
/* Global Variables */
/********************/
extern scfg_t cfg;
103
extern uifcapi_t uifc;
rswindell's avatar
rswindell committed
104 105 106
extern char item;
extern char **opt;
extern char tmp[256];
107
extern char error[256];
108
extern const char *nulstr;
rswindell's avatar
rswindell committed
109 110
extern char *invalid_code,*num_flags;
extern int	backup_level;
111
extern BOOL new_install;
rswindell's avatar
rswindell committed
112
extern char* area_sort_desc[AREA_SORT_TYPES+1];
rswindell's avatar
rswindell committed
113 114 115 116 117 118

/***********************/
/* Function Prototypes */
/***********************/

void bail(int code);
119
void errormsg(int line, const char* function, const char *source, const char* action, const char *object, ulong access);
rswindell's avatar
rswindell committed
120
void clearptrs(int subnum);
rswindell's avatar
rswindell committed
121
int  save_changes(int mode);
rswindell's avatar
rswindell committed
122 123
void node_menu(void);
void node_cfg(void);
rswindell's avatar
rswindell committed
124
void results(int i);
rswindell's avatar
rswindell committed
125 126 127 128
void sys_cfg(void);
void net_cfg(void);
void msgs_cfg(void);
void msg_opts(void);
rswindell's avatar
rswindell committed
129
void sub_cfg(uint grpnum);
rswindell's avatar
rswindell committed
130 131 132
void xfer_cfg(void);
void xfer_opts(void);
void libs_cfg(void);
rswindell's avatar
rswindell committed
133
void dir_cfg(uint libnum);
rswindell's avatar
rswindell committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
void xprogs_cfg(void);
void fevents_cfg(void);
void tevents_cfg(void);
void xtrn_cfg(uint section);
void swap_cfg(void);
void xtrnsec_cfg(void);
int  natvpgm_cfg(void);
void page_cfg(void);
void xedit_cfg(void);
void txt_cfg(void);
void shell_cfg(void);
void init_mdms(void);
void guru_cfg(void);
void actsets_cfg(void);
void chan_cfg(void);
rswindell's avatar
rswindell committed
149 150
void mdm_cfg(int mdmnum);
int export_mdm(char *fname);
151
int code_ok(char *str);
rswindell's avatar
rswindell committed
152 153
int  bits(long l);
void getar(char *desc, char *ar);
154
bool new_sub(unsigned new_subnum, unsigned group_num, sub_t* pasted_sub, long misc);
155
bool new_qhub_sub(qhub_t*, unsigned qsubnum, sub_t*, unsigned confnum);
156
void remove_sub(scfg_t*, unsigned subnum, bool cut);
157 158 159 160
void sort_subs(int grpnum);
void sort_dirs(int libnum);
unsigned subs_in_group(unsigned grpnum);
char random_code_char(void);
161 162
const char* io_method(uint32_t mode);
void choose_io_method(uint32_t* misc);
163 164 165 166 167 168
BOOL load_main_cfg(scfg_t*, char*, size_t);
BOOL load_node_cfg(scfg_t*, char*, size_t);
BOOL load_msgs_cfg(scfg_t*, char*, size_t);
BOOL load_file_cfg(scfg_t*, char*, size_t);
BOOL load_chat_cfg(scfg_t*, char*, size_t);
BOOL load_xtrn_cfg(scfg_t*, char*, size_t);
rswindell's avatar
rswindell committed
169 170 171 172 173 174
BOOL save_main_cfg(scfg_t*, int);
BOOL save_node_cfg(scfg_t*, int);
BOOL save_msgs_cfg(scfg_t*, int);
BOOL save_file_cfg(scfg_t*, int);
BOOL save_chat_cfg(scfg_t*, int);	
BOOL save_xtrn_cfg(scfg_t*, int);
175

176
long import_msg_areas(enum import_list_type, FILE*, unsigned grpnum, int min_confnum, int max_confnum
177
	, qhub_t*, const char* pkt_orig, faddr_t* faddr, uint32_t misc, long* added);
rswindell's avatar
rswindell committed
178

179 180
/* Prepare a string to be used as an internal code; Note: use the return value, Luke */
char* prep_code(char *str, const char* prefix);
181

rswindell's avatar
rswindell committed
182 183
/* scfgnet.h */
faddr_t atofaddr(char *str);