13 |
#include "pathnames.h" |
#include "pathnames.h" |
14 |
|
|
15 |
|
|
16 |
extern char logfile[PATH_MAX]; |
extern opts_t opts; |
|
extern unsigned int options; |
|
|
extern char charset[CHARSET_LEN]; |
|
17 |
extern unsigned int flags; |
extern unsigned int flags; |
|
extern unsigned int interval; |
|
|
extern long timeout; |
|
18 |
extern char *home; |
extern char *home; |
19 |
|
|
20 |
#ifdef ENCRYPTED_PASSWORDS |
#ifdef ENCRYPTED_PASSWORDS |
63 |
|
|
64 |
fclose(fd); |
fclose(fd); |
65 |
|
|
66 |
debug("options: %0#10x '%s'\n", options, charset); |
debug("options: %0#10x '%s'\n", opts, opts.charset); |
67 |
|
|
68 |
return 0; |
return 0; |
69 |
} |
} |
222 |
set_options(char *line, regmatch_t * m) |
set_options(char *line, regmatch_t * m) |
223 |
{ |
{ |
224 |
if (!strncasecmp(line + m[2].rm_so, "logfile", 7)) { |
if (!strncasecmp(line + m[2].rm_so, "logfile", 7)) { |
225 |
if (*logfile == '\0') { |
if (*opts.logfile == '\0') { |
226 |
if (*(line + m[3].rm_so) == '"' && |
if (*(line + m[3].rm_so) == '"' && |
227 |
*(line + m[3].rm_eo - 1) == '"') |
*(line + m[3].rm_eo - 1) == '"') |
228 |
strncat(logfile, line + m[3].rm_so + 1, |
strncat(opts.logfile, line + m[3].rm_so + 1, |
229 |
min((m[3].rm_eo - m[3].rm_so - 2), |
min((m[3].rm_eo - m[3].rm_so - 2), |
230 |
PATH_MAX - 1)); |
PATH_MAX - 1)); |
231 |
else |
else |
232 |
strncat(logfile, line + m[3].rm_so, |
strncat(opts.logfile, line + m[3].rm_so, |
233 |
min((m[3].rm_eo - m[3].rm_so), |
min((m[3].rm_eo - m[3].rm_so), |
234 |
PATH_MAX - 1)); |
PATH_MAX - 1)); |
235 |
} |
} |
236 |
} else if (!strncasecmp(line + m[2].rm_so, "charset", 7)) { |
} else if (!strncasecmp(line + m[2].rm_so, "charset", 7)) { |
237 |
if (*(line + m[3].rm_so) == '"' && |
if (*(line + m[3].rm_so) == '"' && |
238 |
*(line + m[3].rm_eo - 1) == '"') |
*(line + m[3].rm_eo - 1) == '"') |
239 |
strncat(charset, line + m[3].rm_so + 1, |
strncat(opts.charset, line + m[3].rm_so + 1, |
240 |
min((m[3].rm_eo - m[3].rm_so - 2), |
min((m[3].rm_eo - m[3].rm_so - 2), |
241 |
CHARSET_LEN - 1)); |
CHARSET_LEN - 1)); |
242 |
else |
else |
243 |
strncat(charset, line + m[3].rm_so, |
strncat(opts.charset, line + m[3].rm_so, |
244 |
min((m[3].rm_eo - m[3].rm_so), CHARSET_LEN - 1)); |
min((m[3].rm_eo - m[3].rm_so), CHARSET_LEN - 1)); |
245 |
} else if (!strncasecmp(line + m[2].rm_so, "errors", 6)) { |
} else if (!strncasecmp(line + m[2].rm_so, "errors", 6)) { |
246 |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
247 |
options |= OPTION_ERRORS; |
opts.errors = 1; |
248 |
else |
else |
249 |
options &= ~(OPTION_ERRORS); |
opts.errors = 0; |
250 |
} else if (!strncasecmp(line + m[2].rm_so, "expunge", 7)) { |
} else if (!strncasecmp(line + m[2].rm_so, "expunge", 7)) { |
251 |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
252 |
options |= OPTION_EXPUNGE; |
opts.expunge = 1; |
253 |
else |
else |
254 |
options &= ~(OPTION_EXPUNGE); |
opts.expunge = 0; |
255 |
} else if (!strncasecmp(line + m[2].rm_so, "header", 6)) { |
} else if (!strncasecmp(line + m[2].rm_so, "header", 6)) { |
256 |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
257 |
options |= OPTION_HEADERS; |
opts.headers = 1; |
258 |
else |
else |
259 |
options &= ~(OPTION_HEADERS); |
opts.headers = 0; |
260 |
} else if (!strncasecmp(line + m[2].rm_so, "namespace", 9)) { |
} else if (!strncasecmp(line + m[2].rm_so, "namespace", 9)) { |
261 |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
262 |
options |= OPTION_NAMESPACE; |
opts.namespace = 1; |
263 |
else |
else |
264 |
options &= ~(OPTION_NAMESPACE); |
opts.namespace = 0; |
265 |
} else if (!strncasecmp(line + m[2].rm_so, "peek", 4)) { |
} else if (!strncasecmp(line + m[2].rm_so, "peek", 4)) { |
266 |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
267 |
options |= OPTION_PEEK; |
opts.peek = 1; |
268 |
else |
else |
269 |
options &= ~(OPTION_PEEK); |
opts.peek = 0; |
270 |
} else if (!strncasecmp(line + m[2].rm_so, "subscribe", 9)) { |
} else if (!strncasecmp(line + m[2].rm_so, "subscribe", 9)) { |
271 |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
if (!strncasecmp(line + m[3].rm_so, "yes", 3)) |
272 |
options |= OPTION_SUBSCRIBE; |
opts.subscribe = 1; |
273 |
else |
else |
274 |
options &= ~(OPTION_SUBSCRIBE); |
opts.subscribe = 0; |
275 |
} else if (!strncasecmp(line + m[2].rm_so, "timeout", 7)) { |
} else if (!strncasecmp(line + m[2].rm_so, "timeout", 7)) { |
276 |
errno = 0; |
errno = 0; |
277 |
timeout = strtol(line + m[3].rm_so, NULL, 10); |
opts.timeout = strtol(line + m[3].rm_so, NULL, 10); |
278 |
if (errno) |
if (errno) |
279 |
timeout = 0; |
opts.timeout = 0; |
280 |
} else if (!strncasecmp(line + m[2].rm_so, "daemon", 6) && |
} else if (!strncasecmp(line + m[2].rm_so, "daemon", 6) && |
281 |
!(options & OPTION_DAEMON_MODE)) { |
!opts.daemon) { |
|
options |= OPTION_DAEMON_MODE; |
|
282 |
errno = 0; |
errno = 0; |
283 |
interval = strtoul(line + m[3].rm_so, NULL, 10); |
opts.daemon = strtoul(line + m[3].rm_so, NULL, 10); |
284 |
if (errno) |
if (errno) |
285 |
interval = 0; |
opts.daemon = 0; |
286 |
} |
} |
287 |
} |
} |
288 |
|
|