mash/rdconfig.c

changeset 143
54f9b5d39e4c
parent 103
99c47a8a61cb
equal deleted inserted replaced
142:4f21ffc16cd4 143:54f9b5d39e4c
22 22
23 #include "mash.h" 23 #include "mash.h"
24 #include "xutil.h" 24 #include "xutil.h"
25 25
26 26
27 bool debug = FALSE; 27 int debug = FALSE;
28 static char *mypath; 28 static char *mypath;
29 static char *k, *v; 29 static char *k, *v;
30 static int linecnt = 0; 30 static int linecnt = 0;
31 sys_config Config; /* System configuration */ 31 sys_config Config; /* System configuration */
32 32
33 33
34 34
35 //static int getstr(char **);
36 static int getint(char **); 35 static int getint(char **);
37 static int getw1(char **); 36 static int getw1(char **);
38 //static int getuch(char **); 37
39 //static int getfloat(char **);
40 //static int getbyt(char **);
41 //static int gethex(char **);
42 38
43 #define XSTR(x) #x 39 #define XSTR(x) #x
44 #define STR(x) XSTR(x) 40 #define STR(x) XSTR(x)
45 41
46 /* 42 /*
221 217
222 return rc; 218 return rc;
223 } 219 }
224 220
225 221
226 /*
227 static int getstr(char **dest)
228 {
229 if (debug)
230 syslog(LOG_NOTICE, "rdconfig: getstr: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
231
232 *dest = xstrcpy(v);
233 return 0;
234 }
235 */
236
237 222
238 static int getint(char **dest) 223 static int getint(char **dest)
239 { 224 {
240 if (debug) 225 if (debug)
241 syslog(LOG_NOTICE, "rdconfig: getint: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v)); 226 syslog(LOG_NOTICE, "rdconfig: getint: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
297 282
298 return 0; 283 return 0;
299 } 284 }
300 285
301 286
302 /*
303 static int getuch(char **dest)
304 {
305 if (debug)
306 syslog(LOG_NOTICE, "rdconfig: getuch: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
307
308 if (isalnum(v[0])) {
309 *((unsigned char*)dest) = v[0];
310 } else {
311 syslog(LOG_NOTICE, "rdconfig: %s(%d): %s %s - bad character", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
312 }
313 return 0;
314 }
315
316
317
318 static int getfloat(char **dest)
319 {
320 float val = 0.0;
321 int rc;
322
323 if (debug)
324 syslog(LOG_NOTICE, "rdconfig: getfloat: %s(%d): %s %s", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
325
326 rc = sscanf(v, "%f", &val);
327 if (rc != 1) {
328 syslog(LOG_NOTICE, "rdconfig: %s(%d): %s %s - bad float value", mypath, linecnt, MBSE_SS(k), MBSE_SS(v));
329 return 1;
330 }
331 *((float*)dest) = val;
332
333 return 0;
334 }
335 */
336
337 /*
338 static int getbyt(char **dest)
339 {
340 Log_Msg("[rdconfig] getbyt: %s(%d): %s %s", mypath, linecnt, k, v);
341 if (strspn(v,"0123456789") != strlen(v))
342 Log_Msg("[rdconfig] %s(%d): %s %s - bad numeric", mypath, linecnt, S(k), S(v));
343 else
344 *((Uint8*)dest)=atoi(v);
345 return 0;
346 }
347 */
348
349
350 /*
351 static int gethex(char **dest)
352 {
353 unsigned int val = 0;
354 int rc;
355
356 Log_Msg("[rdconfig] gethex: %s(%d): %s %s", mypath, linecnt, k, v);
357 rc = sscanf(v, "%08x", &val);
358 if (rc != 1) {
359 Log_Msg("[rdconfig] %s(%d): %s %s - bad hex value", mypath, linecnt, S(k), S(v));
360 return 1;
361 }
362 *((int*)dest) = val;
363
364 return 0;
365 }
366 */
367
368

mercurial