Lines 1-183
Link Here
|
1 |
--- cfg_param.c.orig 2014-11-21 23:05:59.123552647 +0100 |
|
|
2 |
+++ cfg_param.c 2014-11-21 23:08:29.362542582 +0100 |
3 |
@@ -40,7 +40,7 @@ |
4 |
int ARGC; |
5 |
char **ARGV; |
6 |
|
7 |
-struct ci_server_conf CONF = { |
8 |
+struct ci_server_conf CI_CONF = { |
9 |
NULL, /* LISTEN ADDRESS */ 1344, /*PORT*/ AF_INET, /*SOCK_FAMILY */ |
10 |
#ifdef _WIN32 |
11 |
"c:\\TEMP", /*TMPDIR*/ "c:\\TEMP\\c-icap.pid", /*PIDFILE*/ "\\\\.\\pipe\\c-icap", /*COMMANDS_SOCKET; */ |
12 |
@@ -134,34 +134,34 @@ |
13 |
}; |
14 |
|
15 |
static struct ci_conf_entry conf_variables[] = { |
16 |
- {"ListenAddress", &CONF.ADDRESS, intl_cfg_set_str, NULL}, |
17 |
- {"PidFile", &CONF.PIDFILE, intl_cfg_set_str, NULL}, |
18 |
- {"CommandsSocket", &CONF.COMMANDS_SOCKET, intl_cfg_set_str, NULL}, |
19 |
+ {"ListenAddress", &CI_CONF.ADDRESS, intl_cfg_set_str, NULL}, |
20 |
+ {"PidFile", &CI_CONF.PIDFILE, intl_cfg_set_str, NULL}, |
21 |
+ {"CommandsSocket", &CI_CONF.COMMANDS_SOCKET, intl_cfg_set_str, NULL}, |
22 |
{"Timeout", (void *) (&TIMEOUT), intl_cfg_set_int, NULL}, |
23 |
{"KeepAlive", NULL, NULL, NULL}, |
24 |
{"MaxKeepAliveRequests", &MAX_KEEPALIVE_REQUESTS, intl_cfg_set_int, NULL}, |
25 |
{"KeepAliveTimeout", &KEEPALIVE_TIMEOUT, intl_cfg_set_int, NULL}, |
26 |
- {"StartServers", &CONF.START_SERVERS, intl_cfg_set_int, NULL}, |
27 |
- {"MaxServers", &CONF.MAX_SERVERS, intl_cfg_set_int, NULL}, |
28 |
- {"MinSpareThreads", &CONF.MIN_SPARE_THREADS, intl_cfg_set_int, NULL}, |
29 |
- {"MaxSpareThreads", &CONF.MAX_SPARE_THREADS, intl_cfg_set_int, NULL}, |
30 |
- {"ThreadsPerChild", &CONF.THREADS_PER_CHILD, intl_cfg_set_int, NULL}, |
31 |
+ {"StartServers", &CI_CONF.START_SERVERS, intl_cfg_set_int, NULL}, |
32 |
+ {"MaxServers", &CI_CONF.MAX_SERVERS, intl_cfg_set_int, NULL}, |
33 |
+ {"MinSpareThreads", &CI_CONF.MIN_SPARE_THREADS, intl_cfg_set_int, NULL}, |
34 |
+ {"MaxSpareThreads", &CI_CONF.MAX_SPARE_THREADS, intl_cfg_set_int, NULL}, |
35 |
+ {"ThreadsPerChild", &CI_CONF.THREADS_PER_CHILD, intl_cfg_set_int, NULL}, |
36 |
{"MaxRequestsPerChild", &MAX_REQUESTS_PER_CHILD, intl_cfg_set_int, NULL}, |
37 |
{"MaxRequestsReallocateMem", &MAX_REQUESTS_BEFORE_REALLOCATE_MEM, |
38 |
intl_cfg_set_int, NULL}, |
39 |
- {"Port", &CONF.PORT, intl_cfg_set_int, NULL}, |
40 |
- {"User", &CONF.RUN_USER, intl_cfg_set_str, NULL}, |
41 |
- {"Group", &CONF.RUN_GROUP, intl_cfg_set_str, NULL}, |
42 |
- {"ServerAdmin", &CONF.SERVER_ADMIN, intl_cfg_set_str, NULL}, |
43 |
- {"ServerName", &CONF.SERVER_NAME, intl_cfg_set_str, NULL}, |
44 |
+ {"Port", &CI_CONF.PORT, intl_cfg_set_int, NULL}, |
45 |
+ {"User", &CI_CONF.RUN_USER, intl_cfg_set_str, NULL}, |
46 |
+ {"Group", &CI_CONF.RUN_GROUP, intl_cfg_set_str, NULL}, |
47 |
+ {"ServerAdmin", &CI_CONF.SERVER_ADMIN, intl_cfg_set_str, NULL}, |
48 |
+ {"ServerName", &CI_CONF.SERVER_NAME, intl_cfg_set_str, NULL}, |
49 |
{"LoadMagicFile", NULL, cfg_load_magicfile, NULL}, |
50 |
{"Logger", &default_logger, cfg_set_logger, NULL}, |
51 |
{"ServerLog", &SERVER_LOG_FILE, intl_cfg_set_str, NULL}, |
52 |
{"AccessLog", NULL, cfg_set_accesslog, NULL}, |
53 |
{"LogFormat", NULL, cfg_set_logformat, NULL}, |
54 |
{"DebugLevel", NULL, cfg_set_debug_level, NULL}, /*Set library's debug level */ |
55 |
- {"ServicesDir", &CONF.SERVICES_DIR, intl_cfg_set_str, NULL}, |
56 |
- {"ModulesDir", &CONF.MODULES_DIR, intl_cfg_set_str, NULL}, |
57 |
+ {"ServicesDir", &CI_CONF.SERVICES_DIR, intl_cfg_set_str, NULL}, |
58 |
+ {"ModulesDir", &CI_CONF.MODULES_DIR, intl_cfg_set_str, NULL}, |
59 |
{"Service", NULL, cfg_load_service, NULL}, |
60 |
{"ServiceAlias", NULL, cfg_service_alias, NULL}, |
61 |
{"Module", NULL, cfg_load_module, NULL}, |
62 |
@@ -451,7 +451,7 @@ |
63 |
} |
64 |
|
65 |
db_file = argv[0]; |
66 |
- if (strcmp(CONF.magics_file, db_file) == 0) { |
67 |
+ if (strcmp(CI_CONF.magics_file, db_file) == 0) { |
68 |
ci_debug_printf(2, "The db file %s is the same as default. Ignoring...\n", db_file); |
69 |
return 1; |
70 |
} |
71 |
@@ -461,8 +461,8 @@ |
72 |
ci_debug_printf(1, "Can not load magic file %s!!!\n", db_file); |
73 |
return 0; |
74 |
} |
75 |
- if (!CONF.MAGIC_DB) |
76 |
- CONF.MAGIC_DB = ndb; |
77 |
+ if (!CI_CONF.MAGIC_DB) |
78 |
+ CI_CONF.MAGIC_DB = ndb; |
79 |
|
80 |
return 1; |
81 |
} |
82 |
@@ -517,24 +517,24 @@ |
83 |
return 0; |
84 |
} |
85 |
|
86 |
- cfg_default_value_store(&CONF.TMPDIR, &CONF.TMPDIR, sizeof(char *)); |
87 |
+ cfg_default_value_store(&CI_CONF.TMPDIR, &CI_CONF.TMPDIR, sizeof(char *)); |
88 |
len = strlen(argv[0]); |
89 |
|
90 |
- CONF.TMPDIR = ci_cfg_alloc_mem((len + 2) * sizeof(char)); |
91 |
- strcpy(CONF.TMPDIR, argv[0]); |
92 |
+ CI_CONF.TMPDIR = ci_cfg_alloc_mem((len + 2) * sizeof(char)); |
93 |
+ strcpy(CI_CONF.TMPDIR, argv[0]); |
94 |
#ifdef _WIN32 |
95 |
- if (CONF.TMPDIR[len] != '\\') { |
96 |
- CONF.TMPDIR[len] = '\\'; |
97 |
- CONF.TMPDIR[len + 1] = '\0'; |
98 |
+ if (CI_CONF.TMPDIR[len] != '\\') { |
99 |
+ CI_CONF.TMPDIR[len] = '\\'; |
100 |
+ CI_CONF.TMPDIR[len + 1] = '\0'; |
101 |
} |
102 |
#else |
103 |
- if (CONF.TMPDIR[len] != '/') { |
104 |
- CONF.TMPDIR[len] = '/'; |
105 |
- CONF.TMPDIR[len + 1] = '\0'; |
106 |
+ if (CI_CONF.TMPDIR[len] != '/') { |
107 |
+ CI_CONF.TMPDIR[len] = '/'; |
108 |
+ CI_CONF.TMPDIR[len + 1] = '\0'; |
109 |
} |
110 |
#endif |
111 |
/*Check if tmpdir exists. If no try to build it , report an error and uses the default... */ |
112 |
- CI_TMPDIR = CONF.TMPDIR; /*Sets the library's temporary dir to .... */ |
113 |
+ CI_TMPDIR = CI_CONF.TMPDIR; /*Sets the library's temporary dir to .... */ |
114 |
ci_debug_printf(2, "Setting parameter :%s=%s\n", directive, argv[0]); |
115 |
return 1; |
116 |
} |
117 |
@@ -842,7 +842,7 @@ |
118 |
/* #endif */ |
119 |
|
120 |
static struct ci_options_entry options[] = { |
121 |
- {opt_pre "f", "filename", &CONF.cfg_file, ci_cfg_set_str, |
122 |
+ {opt_pre "f", "filename", &CI_CONF.cfg_file, ci_cfg_set_str, |
123 |
"Specify the configuration file"}, |
124 |
{opt_pre "N", NULL, &DAEMON_MODE, ci_cfg_disable, "Do not run as daemon"}, |
125 |
{opt_pre "d", "level", NULL, cfg_set_debug_level_cmd, |
126 |
@@ -864,7 +864,7 @@ |
127 |
ci_args_usage(argv[0], options); |
128 |
exit(-1); |
129 |
} |
130 |
- if (!parse_file(CONF.cfg_file)) { |
131 |
+ if (!parse_file(CI_CONF.cfg_file)) { |
132 |
ci_debug_printf(1, "Error opening/parsing config file\n"); |
133 |
exit(0); |
134 |
} |
135 |
@@ -883,7 +883,7 @@ |
136 |
"Error in command line options, while reconfiguring!\n"); |
137 |
return 0; |
138 |
} |
139 |
- if (!parse_file(CONF.cfg_file)) { |
140 |
+ if (!parse_file(CI_CONF.cfg_file)) { |
141 |
ci_debug_printf(1, |
142 |
"Error opening/parsing config file, while reconfiguring!\n"); |
143 |
return 0; |
144 |
@@ -923,7 +923,7 @@ |
145 |
Release other subsystems |
146 |
*/ |
147 |
ci_magic_db_free(); |
148 |
- CONF.MAGIC_DB = NULL; |
149 |
+ CI_CONF.MAGIC_DB = NULL; |
150 |
ci_txt_template_close(); |
151 |
} |
152 |
|
153 |
@@ -939,9 +939,9 @@ |
154 |
|
155 |
ci_debug_printf(1, "All resources released. Going to reload!\n"); |
156 |
ci_txt_template_init(); |
157 |
- if (!(CONF.MAGIC_DB = ci_magic_db_load(CONF.magics_file))) { |
158 |
+ if (!(CI_CONF.MAGIC_DB = ci_magic_db_load(CI_CONF.magics_file))) { |
159 |
ci_debug_printf(1, "Can not load magic file %s!!!\n", |
160 |
- CONF.magics_file); |
161 |
+ CI_CONF.magics_file); |
162 |
} |
163 |
init_modules(); |
164 |
init_services(); |
165 |
@@ -950,15 +950,15 @@ |
166 |
- Freeing all memory and resources used by configuration parameters (is it possible???) |
167 |
- reopen and read config file. Now the monitor process has now the new config parameters. |
168 |
*/ |
169 |
- old_port = CONF.PORT; |
170 |
+ old_port = CI_CONF.PORT; |
171 |
if (!reconfig()) |
172 |
return 0; |
173 |
|
174 |
/* |
175 |
- reinit listen socket if needed |
176 |
*/ |
177 |
- if (old_port != CONF.PORT) { |
178 |
- init_server(CONF.ADDRESS, CONF.PORT, &(CONF.PROTOCOL_FAMILY)); |
179 |
+ if (old_port != CI_CONF.PORT) { |
180 |
+ init_server(CI_CONF.ADDRESS, CI_CONF.PORT, &(CI_CONF.PROTOCOL_FAMILY)); |
181 |
} |
182 |
|
183 |
log_open(); |