~ubuntu-branches/ubuntu/trusty/lcd4linux/trusty-proposed

« back to all changes in this revision

Viewing changes to cfg.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-01-10 10:30:49 UTC
  • mfrom: (2.1.7 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080110103049-pai7ayvojkg2wf7i
Tags: 0.10.1~rc2-2
* Bugfix: "lcd4linux: FTBFS: undefined reference to `rdtscl'" Patch
  taken from upstream svn. Thanks to Robert Buchholz and Michael Reinelt
  (upstream) for reviewing the patch. Closes: #436332
* Urgency medium for RC bug
* bump to standards version 3.7.3 (no changes needed)
* add Vcs-Bzr and Homepage header.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: cfg.c,v 1.49 2006/02/07 05:36:13 reinelt Exp $^
 
1
/* $Id: cfg.c 750 2007-01-20 06:58:56Z michael $
 
2
 * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/cfg.c $
 
3
 * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/cfg.c $
2
4
 *
3
5
 * config file stuff
4
6
 *
21
23
 * along with this program; if not, write to the Free Software
22
24
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
25
 *
24
 
 *
25
 
 * $Log: cfg.c,v $
26
 
 * Revision 1.49  2006/02/07 05:36:13  reinelt
27
 
 * Layers added to Layout
28
 
 *
29
 
 * Revision 1.48  2006/01/30 12:53:07  reinelt
30
 
 * replaced strncpy with strcpy where possible
31
 
 *
32
 
 * Revision 1.47  2005/05/08 04:32:43  reinelt
33
 
 * CodingStyle added and applied
34
 
 *
35
 
 * Revision 1.46  2005/05/02 05:15:46  reinelt
36
 
 * make busy-flag checking configurable for LCD-Linux driver
37
 
 *
38
 
 * Revision 1.45  2005/01/18 06:30:21  reinelt
39
 
 * added (C) to all copyright statements
40
 
 *
41
 
 * Revision 1.44  2005/01/17 06:29:24  reinelt
42
 
 * added software-controlled backlight support to HD44780
43
 
 *
44
 
 * Revision 1.43  2004/11/29 04:42:06  reinelt
45
 
 * removed the 99999 msec limit on widget update time (thanks to Petri Damsten)
46
 
 *
47
 
 * Revision 1.42  2004/06/26 12:04:59  reinelt
48
 
 *
49
 
 * uh-oh... the last CVS log message messed up things a lot...
50
 
 *
51
 
 * Revision 1.41  2004/06/26 09:27:20  reinelt
52
 
 *
53
 
 * added '-W' to CFLAGS
54
 
 * changed all C++ comments to C ones
55
 
 * cleaned up a lot of signed/unsigned mistakes
56
 
 *
57
 
 * Revision 1.40  2004/06/20 10:09:52  reinelt
58
 
 *
59
 
 * 'const'ified the whole source
60
 
 *
61
 
 * Revision 1.39  2004/03/11 06:39:58  reinelt
62
 
 * big patch from Martin:
63
 
 * - reuse filehandles
64
 
 * - memory leaks fixed
65
 
 * - earlier busy-flag checking with HD44780
66
 
 * - reuse memory for strings in RESULT and hash
67
 
 * - netdev_fast to wavid time-consuming regex
68
 
 *
69
 
 * Revision 1.38  2004/03/08 16:26:26  reinelt
70
 
 * re-introduced \nnn (octal) characters in strings
71
 
 * text widgets can have a 'update' speed of 0 which means 'never'
72
 
 * (may be used for static content)
73
 
 *
74
 
 * Revision 1.37  2004/03/06 20:31:16  reinelt
75
 
 * Complete rewrite of the evaluator to get rid of the code
76
 
 * from mark Morley (because of license issues).
77
 
 * The new Evaluator does a pre-compile of expressions, and
78
 
 * stores them in trees. Therefore it should be reasonable faster...
79
 
 *
80
 
 * Revision 1.36  2004/03/03 03:47:04  reinelt
81
 
 * big patch from Martin Hejl:
82
 
 * - use qprintf() where appropriate
83
 
 * - save CPU cycles on gettimeofday()
84
 
 * - add quit() functions to free allocated memory
85
 
 * - fixed lots of memory leaks
86
 
 *
87
 
 * Revision 1.35  2004/03/01 04:29:51  reinelt
88
 
 * cfg_number() returns -1 on error, 0 if value not found (but default val used),
89
 
 *  and 1 if value was used from the configuration.
90
 
 * HD44780 driver adopted to new cfg_number()
91
 
 * Crystalfontz 631 driver nearly finished
92
 
 *
93
 
 * Revision 1.34  2004/02/18 06:39:20  reinelt
94
 
 * T6963 driver for graphic displays finished
95
 
 *
96
 
 * Revision 1.33  2004/02/01 18:08:50  reinelt
97
 
 * removed strtok() from layout processing (took me hours to find this bug)
98
 
 * further strtok() removind should be done!
99
 
 *
100
 
 * Revision 1.32  2004/01/30 20:57:55  reinelt
101
 
 * HD44780 patch from Martin Hejl
102
 
 * dmalloc integrated
103
 
 *
104
 
 * Revision 1.31  2004/01/29 04:40:02  reinelt
105
 
 * every .c file includes "config.h" now
106
 
 *
107
 
 * Revision 1.30  2004/01/22 07:57:45  reinelt
108
 
 * several bugs fixed where segfaulting on layout>display
109
 
 * Crystalfontz driver optimized, 632 display already works
110
 
 *
111
 
 * Revision 1.29  2004/01/18 06:54:08  reinelt
112
 
 * bug in expr.c fixed (thanks to Xavier)
113
 
 * some progress with /proc/stat parsing
114
 
 *
115
 
 * Revision 1.28  2004/01/16 05:04:53  reinelt
116
 
 * started plugin proc_stat which should parse /proc/stat
117
 
 * which again is a paint in the a**
118
 
 * thinking over implementation methods of delta functions
119
 
 * (CPU load, ...)
120
 
 *
121
 
 * Revision 1.27  2004/01/14 11:33:00  reinelt
122
 
 * new plugin 'uname' which does what it's called
123
 
 * text widget nearly finished
124
 
 * first results displayed on MatrixOrbital
125
 
 *
126
 
 * Revision 1.26  2004/01/11 18:26:02  reinelt
127
 
 * further widget and layout processing
128
 
 *
129
 
 * Revision 1.25  2004/01/11 09:26:15  reinelt
130
 
 * layout starts to exist...
131
 
 *
132
 
 * Revision 1.24  2004/01/10 20:22:33  reinelt
133
 
 * added new function 'cfg_list()' (not finished yet)
134
 
 * added layout.c (will replace processor.c someday)
135
 
 * added widget_text.c (will be the first and most important widget)
136
 
 * modified lcd4linux.c so that old-style configs should work, too
137
 
 *
138
 
 * Revision 1.23  2004/01/09 04:16:06  reinelt
139
 
 * added 'section' argument to cfg_get(), but NULLed it on all calls by now.
140
 
 *
141
 
 * Revision 1.22  2004/01/08 06:00:28  reinelt
142
 
 * allowed '.' in key names
143
 
 * allowed empty section keys (not only "section anything {", but "anything {")
144
 
 *
145
 
 * Revision 1.21  2004/01/08 05:28:12  reinelt
146
 
 * Luk Claes added to AUTHORS
147
 
 * cfg: section handling ('{}') added
148
 
 *
149
 
 * Revision 1.20  2004/01/07 10:15:41  reinelt
150
 
 * small glitch in evaluator fixed
151
 
 * made config table sorted and access with bsearch(),
152
 
 * which should be much faster
153
 
 *
154
 
 * Revision 1.19  2003/12/19 05:35:14  reinelt
155
 
 * renamed 'client' to 'plugin'
156
 
 *
157
 
 * Revision 1.18  2003/10/11 06:01:52  reinelt
158
 
 *
159
 
 * renamed expression.{c,h} to client.{c,h}
160
 
 * added config file client
161
 
 * new functions 'AddNumericVariable()' and 'AddStringVariable()'
162
 
 * new parameter '-i' for interactive mode
163
 
 *
164
 
 * Revision 1.17  2003/10/05 17:58:50  reinelt
165
 
 * libtool junk; copyright messages cleaned up
166
 
 *
167
 
 * Revision 1.16  2003/09/09 06:54:43  reinelt
168
 
 * new function 'cfg_number()'
169
 
 *
170
 
 * Revision 1.15  2003/08/24 05:17:58  reinelt
171
 
 * liblcd4linux patch from Patrick Schemitz
172
 
 *
173
 
 * Revision 1.14  2003/08/14 03:47:40  reinelt
174
 
 * remove PID file if driver initialisation fails
175
 
 *
176
 
 * Revision 1.13  2003/02/22 07:53:10  reinelt
177
 
 * cfg_get(key,defval)
178
 
 *
179
 
 * Revision 1.12  2001/03/09 12:14:24  reinelt
180
 
 *
181
 
 * minor cleanups
182
 
 *
183
 
 * Revision 1.11  2001/03/08 15:25:38  ltoetsch
184
 
 * improved exec
185
 
 *
186
 
 * Revision 1.10  2001/03/07 18:10:21  ltoetsch
187
 
 * added e(x)ec commands
188
 
 *
189
 
 * Revision 1.9  2000/08/10 09:44:09  reinelt
190
 
 *
191
 
 * new debugging scheme: error(), info(), debug()
192
 
 * uses syslog if in daemon mode
193
 
 *
194
 
 * Revision 1.8  2000/07/31 06:46:35  reinelt
195
 
 *
196
 
 * eliminated some compiler warnings with glibc
197
 
 *
198
 
 * Revision 1.7  2000/04/15 11:13:54  reinelt
199
 
 *
200
 
 * added '-d' (debugging) switch
201
 
 * added several debugging messages
202
 
 * removed config entry 'Delay' for HD44780 driver
203
 
 * delay loop for HD44780 will be calibrated automatically
204
 
 *
205
 
 * Revision 1.6  2000/04/03 04:46:38  reinelt
206
 
 *
207
 
 * added '-c key=val' option
208
 
 *
209
 
 * Revision 1.5  2000/03/28 07:22:15  reinelt
210
 
 *
211
 
 * version 0.95 released
212
 
 * X11 driver up and running
213
 
 * minor bugs fixed
214
 
 *
215
 
 * Revision 1.4  2000/03/26 20:00:44  reinelt
216
 
 *
217
 
 * README.Raster added
218
 
 *
219
 
 * Revision 1.3  2000/03/26 19:03:52  reinelt
220
 
 *
221
 
 * more Pixmap renaming
222
 
 * quoting of '#' in config file
223
 
 *
224
 
 * Revision 1.2  2000/03/10 17:36:02  reinelt
225
 
 *
226
 
 * first unstable but running release
227
 
 *
228
 
 * Revision 1.1  2000/03/10 11:40:47  reinelt
229
 
 * *** empty log message ***
230
 
 *
231
 
 * Revision 1.3  2000/03/07 11:01:34  reinelt
232
 
 *
233
 
 * system.c cleanup
234
 
 *
235
 
 * Revision 1.2  2000/03/06 06:04:06  reinelt
236
 
 *
237
 
 * minor cleanups
238
 
 *
239
26
 */
240
27
 
241
28
/* 
564
351
 
565
352
    if (val != NULL)
566
353
        return val;
 
354
 
567
355
    return (char *) defval;
568
356
}
569
357
 
625
413
    DelResult(&result);
626
414
 
627
415
    if (*value < min) {
628
 
        error("bad '%s' value '%d' in %s, minimum is %d", key, *value, cfg_source(), min);
 
416
        error("bad '%s.%s' value '%d' in %s, minimum is %d", section, key, *value, cfg_source(), min);
629
417
        *value = min;
630
418
        return -1;
631
419
    }
632
420
 
633
421
    if (max > min && max != -1 && *value > max) {
634
 
        error("bad '%s' value '%d' in %s, maximum is %d", key, *value, cfg_source(), max);
 
422
        error("bad '%s.%s' value '%d' in %s, maximum is %d", section, key, *value, cfg_source(), max);
635
423
        *value = max;
636
424
        return -1;
637
425
    }