1 | /* |
1 | /* |
2 | configuration.c - Part of psiconv, a PSION 5 file formats converter |
2 | configuration.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999, 2000,2003 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
16 | along with this program; if not, write to the Free Software |
16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ |
18 | */ |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
|
|
21 | #include "compat.h" |
21 | #include "error.h" |
22 | #include "error.h" |
22 | #include "compat.h" |
|
|
23 | #include "unicode.h" |
23 | #include "unicode.h" |
24 | |
24 | |
25 | #include <stdio.h> |
25 | #include <stdio.h> |
26 | #include <stdlib.h> |
26 | #include <stdlib.h> |
27 | #include <string.h> |
27 | #include <string.h> |
|
|
28 | #include <strings.h> |
28 | #include <sys/types.h> |
29 | #include <sys/types.h> |
29 | #include <sys/stat.h> |
30 | #include <sys/stat.h> |
30 | #include <unistd.h> |
31 | #include <unistd.h> |
31 | #include <fcntl.h> |
32 | #include <fcntl.h> |
32 | |
33 | |
… | |
… | |
35 | #ifdef DMALLOC |
36 | #ifdef DMALLOC |
36 | #include <dmalloc.h> |
37 | #include <dmalloc.h> |
37 | #endif |
38 | #endif |
38 | |
39 | |
39 | #ifndef CONFIGURATION_SEARCH_PATH |
40 | #ifndef CONFIGURATION_SEARCH_PATH |
40 | #define CONFIGURATION_SEARCH_PATH "/etc/psiconv.conf:~/.psiconv.conf" |
41 | #define CONFIGURATION_SEARCH_PATH PSICONVETCDIR "/psiconv.conf:~/.psiconv.conf" |
41 | #endif |
42 | #endif |
42 | static struct psiconv_config_s default_config = |
43 | static struct psiconv_config_s default_config = |
43 | { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?' }; |
44 | { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?' }; |
44 | |
45 | |
45 | static void psiconv_config_parse_statement(const char *filename, |
46 | static void psiconv_config_parse_statement(const char *filename, |
… | |
… | |
71 | if (!(strcasecmp(var,"verbosity"))) { |
72 | if (!(strcasecmp(var,"verbosity"))) { |
72 | if ((value >= 1) && (value <= 4)) |
73 | if ((value >= 1) && (value <= 4)) |
73 | (*config)->verbosity = value; |
74 | (*config)->verbosity = value; |
74 | else |
75 | else |
75 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
76 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
76 | "Verbosity should be between 1 and 4",filename,linenr); |
77 | "Verbosity should be between 1 and 5",filename,linenr); |
77 | } else if (!(strcasecmp(var,"color"))) { |
78 | } else if (!(strcasecmp(var,"color"))) { |
78 | if ((value == 0) || (value == 1)) |
79 | if ((value == 0) || (value == 1)) |
79 | (*config)->color = value; |
80 | (*config)->color = value; |
80 | else |
81 | else |
81 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
82 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |