… | |
… | |
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 | |
24 | |
24 | #include <stdio.h> |
25 | #include <stdio.h> |
25 | #include <stdlib.h> |
26 | #include <stdlib.h> |
26 | #include <string.h> |
27 | #include <string.h> |
27 | #include <sys/types.h> |
28 | #include <sys/types.h> |
… | |
… | |
37 | |
38 | |
38 | #ifndef CONFIGURATION_SEARCH_PATH |
39 | #ifndef CONFIGURATION_SEARCH_PATH |
39 | #define CONFIGURATION_SEARCH_PATH "/etc/psiconv.conf:~/.psiconv.conf" |
40 | #define CONFIGURATION_SEARCH_PATH "/etc/psiconv.conf:~/.psiconv.conf" |
40 | #endif |
41 | #endif |
41 | static struct psiconv_config_s default_config = |
42 | static struct psiconv_config_s default_config = |
42 | { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL }; |
43 | { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?' }; |
43 | |
44 | |
44 | static void psiconv_config_parse_statement(const char *filename, |
45 | static void psiconv_config_parse_statement(const char *filename, |
45 | int linenr, |
46 | int linenr, |
46 | const char *var, int value, |
47 | const char *var, int value, |
47 | psiconv_config *config); |
48 | psiconv_config *config); |
… | |
… | |
63 | void psiconv_config_parse_statement(const char *filename, |
64 | void psiconv_config_parse_statement(const char *filename, |
64 | int linenr, |
65 | int linenr, |
65 | const char *var, int value, |
66 | const char *var, int value, |
66 | psiconv_config *config) |
67 | psiconv_config *config) |
67 | { |
68 | { |
|
|
69 | int charnr; |
|
|
70 | |
68 | if (!(strcasecmp(var,"verbosity"))) { |
71 | if (!(strcasecmp(var,"verbosity"))) { |
69 | if ((value >= 1) && (value <= 4)) |
72 | if ((value >= 1) && (value <= 4)) |
70 | (*config)->verbosity = value; |
73 | (*config)->verbosity = value; |
71 | else |
74 | else |
72 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
75 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
73 | "Verbosity should be between 1 and 4",filename,linenr); |
76 | "Verbosity should be between 1 and 5",filename,linenr); |
74 | } else if (!(strcasecmp(var,"color"))) { |
77 | } else if (!(strcasecmp(var,"color"))) { |
75 | if ((value == 0) || (value == 1)) |
78 | if ((value == 0) || (value == 1)) |
76 | (*config)->color = value; |
79 | (*config)->color = value; |
77 | else |
80 | else |
78 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
81 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
… | |
… | |
99 | if ((value >= 0) && (value <= 32)) |
102 | if ((value >= 0) && (value <= 32)) |
100 | (*config)->bluebits = value; |
103 | (*config)->bluebits = value; |
101 | else |
104 | else |
102 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
105 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
103 | "BlueBits should be between 1 and 32 or 0",filename,linenr); |
106 | "BlueBits should be between 1 and 32 or 0",filename,linenr); |
|
|
107 | } else if (!(strcasecmp(var,"characterset"))) { |
|
|
108 | if ((value >= 0) && (value <= 1)) |
|
|
109 | psiconv_unicode_select_characterset(*config,value); |
|
|
110 | else |
|
|
111 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
|
|
112 | "CharacterSet should be between 0 and 0", |
|
|
113 | filename,linenr); |
|
|
114 | } else if (!(strcasecmp(var,"unknownunicodechar"))) { |
|
|
115 | if ((value >= 1) && (value < 0x10000)) |
|
|
116 | (*config)->unknown_unicode_char = value; |
|
|
117 | else |
|
|
118 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
|
|
119 | "UnknownUnicodeChar should be between 1 and 65535", |
|
|
120 | filename,linenr); |
|
|
121 | } else if (!(strcasecmp(var,"unknownepocchar"))) { |
|
|
122 | if ((value >= 1) && (value < 0x100)) |
|
|
123 | (*config)->unknown_epoc_char = value; |
|
|
124 | else |
|
|
125 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
|
|
126 | "UnknownEPOCChar should be between 1 and 255", |
|
|
127 | filename,linenr); |
|
|
128 | } else if (sscanf(var,"char%d",&charnr) == strlen(var)) { |
|
|
129 | if ((charnr < 0) || (charnr > 255)) |
|
|
130 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
|
|
131 | "CharXXX should have XXX between 0 and 255", |
|
|
132 | filename,linenr); |
|
|
133 | if ((value >= 1) && (value <= 0x10000)) |
|
|
134 | (*config)->unicode_table[charnr] = value; |
|
|
135 | else |
|
|
136 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
|
|
137 | "CharXXX should be between 1 and 65535", |
|
|
138 | filename,linenr); |
104 | } else { |
139 | } else { |
105 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
140 | psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " |
106 | "Unknown variable %s",filename,linenr,var); |
141 | "Unknown variable %s",filename,linenr,var); |
107 | } |
142 | } |
108 | psiconv_debug(*config,0,0,"Configuration file %s, line %d: " |
143 | psiconv_debug(*config,0,0,"Configuration file %s, line %d: " |