/[public]/psiconv/trunk/lib/psiconv/configuration.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/configuration.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 200 Revision 218
39 39
40#ifndef CONFIGURATION_SEARCH_PATH 40#ifndef CONFIGURATION_SEARCH_PATH
41#define CONFIGURATION_SEARCH_PATH PSICONVETCDIR "/psiconv.conf:~/.psiconv.conf" 41#define CONFIGURATION_SEARCH_PATH PSICONVETCDIR "/psiconv.conf:~/.psiconv.conf"
42#endif 42#endif
43static struct psiconv_config_s default_config = 43static struct psiconv_config_s default_config =
44 { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?' }; 44 { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?','?',{ 0 },psiconv_bool_false };
45 45
46static void psiconv_config_parse_statement(const char *filename, 46static void psiconv_config_parse_statement(const char *filename,
47 int linenr, 47 int linenr,
48 const char *var, int value, 48 const char *var, int value,
49 psiconv_config *config); 49 psiconv_config *config);
57psiconv_config psiconv_config_default(void) 57psiconv_config psiconv_config_default(void)
58{ 58{
59 psiconv_config result; 59 psiconv_config result;
60 result = malloc(sizeof(*result)); 60 result = malloc(sizeof(*result));
61 *result = default_config; 61 *result = default_config;
62 psiconv_unicode_select_characterset(result,1);
62 return result; 63 return result;
64}
65
66void psiconv_config_free(psiconv_config config)
67{
68 free(config);
63} 69}
64 70
65void psiconv_config_parse_statement(const char *filename, 71void psiconv_config_parse_statement(const char *filename,
66 int linenr, 72 int linenr,
67 const char *var, int value, 73 const char *var, int value,
68 psiconv_config *config) 74 psiconv_config *config)
69{ 75{
70 int charnr; 76 int charnr;
71 77
72 if (!(strcasecmp(var,"verbosity"))) { 78 if (!(strcasecmp(var,"verbosity"))) {
73 if ((value >= 1) && (value <= 4)) 79 if ((value >= 1) && (value <= 5))
74 (*config)->verbosity = value; 80 (*config)->verbosity = value;
75 else 81 else
76 psiconv_error(*config,0,0,"Configuration file %s, line %d: " 82 psiconv_error(*config,0,0,"Configuration file %s, line %d: "
77 "Verbosity should be between 1 and 5",filename,linenr); 83 "Verbosity should be between 1 and 5",filename,linenr);
78 } else if (!(strcasecmp(var,"color"))) { 84 } else if (!(strcasecmp(var,"color"))) {
108 } else if (!(strcasecmp(var,"characterset"))) { 114 } else if (!(strcasecmp(var,"characterset"))) {
109 if ((value >= 0) && (value <= 1)) 115 if ((value >= 0) && (value <= 1))
110 psiconv_unicode_select_characterset(*config,value); 116 psiconv_unicode_select_characterset(*config,value);
111 else 117 else
112 psiconv_error(*config,0,0,"Configuration file %s, line %d: " 118 psiconv_error(*config,0,0,"Configuration file %s, line %d: "
113 "CharacterSet should be between 0 and 0", 119 "CharacterSet should be between 0 and 1",
114 filename,linenr); 120 filename,linenr);
115 } else if (!(strcasecmp(var,"unknownunicodechar"))) { 121 } else if (!(strcasecmp(var,"unknownunicodechar"))) {
116 if ((value >= 1) && (value < 0x10000)) 122 if ((value >= 1) && (value < 0x10000))
117 (*config)->unknown_unicode_char = value; 123 (*config)->unknown_unicode_char = value;
118 else 124 else
352 } 358 }
353 359
354 psiconv_config_parse_file(filename,config); 360 psiconv_config_parse_file(filename,config);
355 free(filename); 361 free(filename);
356 } 362 }
363 free(path);
357} 364}

Legend:
Removed from v.200  
changed lines
  Added in v.218

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26