--- psiconv/trunk/lib/psiconv/configuration.c 2003/12/13 23:26:37 180 +++ psiconv/trunk/lib/psiconv/configuration.c 2004/02/04 14:32:28 197 @@ -1,6 +1,6 @@ /* configuration.c - Part of psiconv, a PSION 5 file formats converter - Copyright (c) 1999, 2000,2003 Frodo Looijaard + Copyright (c) 1999-2004 Frodo Looijaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,12 +18,14 @@ */ #include "config.h" -#include "error.h" #include "compat.h" +#include "error.h" +#include "unicode.h" #include #include #include +#include #include #include #include @@ -36,10 +38,10 @@ #endif #ifndef CONFIGURATION_SEARCH_PATH -#define CONFIGURATION_SEARCH_PATH "/etc/psiconv.conf:~/.psiconv.conf" +#define CONFIGURATION_SEARCH_PATH PSICONVETCDIR "/psiconv.conf:~/.psiconv.conf" #endif static struct psiconv_config_s default_config = - { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL }; + { PSICONV_VERB_WARN, 2, 0,0,0,psiconv_bool_false,NULL,'?' }; static void psiconv_config_parse_statement(const char *filename, int linenr, @@ -65,12 +67,14 @@ const char *var, int value, psiconv_config *config) { + int charnr; + if (!(strcasecmp(var,"verbosity"))) { if ((value >= 1) && (value <= 4)) (*config)->verbosity = value; else psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " - "Verbosity should be between 1 and 4",filename,linenr); + "Verbosity should be between 1 and 5",filename,linenr); } else if (!(strcasecmp(var,"color"))) { if ((value == 0) || (value == 1)) (*config)->color = value; @@ -101,6 +105,38 @@ else psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " "BlueBits should be between 1 and 32 or 0",filename,linenr); + } else if (!(strcasecmp(var,"characterset"))) { + if ((value >= 0) && (value <= 1)) + psiconv_unicode_select_characterset(*config,value); + else + psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " + "CharacterSet should be between 0 and 0", + filename,linenr); + } else if (!(strcasecmp(var,"unknownunicodechar"))) { + if ((value >= 1) && (value < 0x10000)) + (*config)->unknown_unicode_char = value; + else + psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " + "UnknownUnicodeChar should be between 1 and 65535", + filename,linenr); + } else if (!(strcasecmp(var,"unknownepocchar"))) { + if ((value >= 1) && (value < 0x100)) + (*config)->unknown_epoc_char = value; + else + psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " + "UnknownEPOCChar should be between 1 and 255", + filename,linenr); + } else if (sscanf(var,"char%d",&charnr) == strlen(var)) { + if ((charnr < 0) || (charnr > 255)) + psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " + "CharXXX should have XXX between 0 and 255", + filename,linenr); + if ((value >= 1) && (value <= 0x10000)) + (*config)->unicode_table[charnr] = value; + else + psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " + "CharXXX should be between 1 and 65535", + filename,linenr); } else { psiconv_fatal(*config,0,0,"Configuration file %s, line %d: " "Unknown variable %s",filename,linenr,var);