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

Legend:
Removed from v.180  
changed lines
  Added in v.196

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