aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-24 23:38:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-24 23:38:04 +0000
commit0f99d49ae680e675809428deace3c4fe839d323c (patch)
tree712afab828ee4fb02493bc60e1a37f1142231263 /miscutils
parent22f741484391c3b2fd94881fd41c8c0df9749e95 (diff)
downloadbusybox-w32-0f99d49ae680e675809428deace3c4fe839d323c.tar.gz
busybox-w32-0f99d49ae680e675809428deace3c4fe839d323c.tar.bz2
busybox-w32-0f99d49ae680e675809428deace3c4fe839d323c.zip
*: conversion to config parser
function old new delta config_read 540 597 +57 config_open2 41 44 +3 rtnl_rtprot_initialize 70 66 -4 rtnl_rttable_initialize 78 73 -5 rtnl_rtscope_initialize 88 83 -5 rtnl_rtrealm_initialize 48 43 -5 rtnl_rtdsfield_initialize 48 43 -5 process_module 566 560 -6 bbunpack 391 383 -8 rtnl_tab_initialize 279 121 -158 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/8 up/down: 60/-196) Total: -136 bytes
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/fbsplash.c86
1 files changed, 21 insertions, 65 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 380f09bea..6357f78ea 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -38,13 +38,7 @@ struct globals {
38 FILE *logfile_fd; // log file 38 FILE *logfile_fd; // log file
39#endif 39#endif
40 unsigned char *addr; // pointer to framebuffer memory 40 unsigned char *addr; // pointer to framebuffer memory
41 unsigned nbar_width; // progress bar width 41 unsigned ns[7]; // n-parameters
42 unsigned nbar_height; // progress bar height
43 unsigned nbar_posx; // progress bar horizontal position
44 unsigned nbar_posy; // progress bar vertical position
45 unsigned char nbar_colr; // progress bar color red component
46 unsigned char nbar_colg; // progress bar color green component
47 unsigned char nbar_colb; // progress bar color blue component
48 const char *image_filename; 42 const char *image_filename;
49 struct fb_var_screeninfo scr_var; 43 struct fb_var_screeninfo scr_var;
50 struct fb_fix_screeninfo scr_fix; 44 struct fb_fix_screeninfo scr_fix;
@@ -54,6 +48,13 @@ struct globals {
54 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 48 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
55} while (0) 49} while (0)
56 50
51#define nbar_width ns[0] // progress bar width
52#define nbar_height ns[1] // progress bar height
53#define nbar_posx ns[2] // progress bar horizontal position
54#define nbar_posy ns[3] // progress bar vertical position
55#define nbar_colr ns[4] // progress bar color red component
56#define nbar_colg ns[5] // progress bar color green component
57#define nbar_colb ns[6] // progress bar color blue component
57 58
58#if DEBUG 59#if DEBUG
59#define DEBUG_MESSAGE(strMessage, args...) \ 60#define DEBUG_MESSAGE(strMessage, args...) \
@@ -280,77 +281,32 @@ static void fb_drawimage(void)
280static void init(const char *cfg_filename) 281static void init(const char *cfg_filename)
281{ 282{
282 static const char const param_names[] ALIGN1 = 283 static const char const param_names[] ALIGN1 =
283 "BAR_LEFT\0" "BAR_TOP\0"
284 "BAR_WIDTH\0" "BAR_HEIGHT\0" 284 "BAR_WIDTH\0" "BAR_HEIGHT\0"
285 "BAR_LEFT\0" "BAR_TOP\0"
285 "BAR_R\0" "BAR_G\0" "BAR_B\0" 286 "BAR_R\0" "BAR_G\0" "BAR_B\0"
286#if DEBUG 287#if DEBUG
287 "DEBUG\0" 288 "DEBUG\0"
288#endif 289#endif
289 ; 290 ;
290 291
291 FILE *inifile; 292 char *token[2];
292 char *buf; 293 parser_t *parser = config_open2(cfg_filename, xfopen_stdin);
293 294 while (config_read(parser, token, 2, 2, "#=", PARSE_MIN_DIE)) {
294 inifile = xfopen_stdin(cfg_filename); 295 unsigned val = xatoi_u(token[1]);
295 296 int i = index_in_strings(param_names, token[0]);
296 while ((buf = xmalloc_fgetline(inifile)) != NULL) { 297 if (i < 0)
297 char *value_str; 298 bb_error_msg_and_die("syntax error: '%s'", token[0]);
298 int val; 299 if (i >= 0 && i < 7)
299 300 G.ns[i] = val;
300 if (*buf == '#') { // it's a comment
301 free(buf);
302 continue;
303 }
304
305 value_str = strchr(buf, '=');
306 if (!value_str)
307 goto err;
308 *value_str++ = '\0';
309 val = xatoi_u(value_str);
310
311 switch (index_in_strings(param_names, buf)) {
312 case 0:
313 // progress bar horizontal position
314 G.nbar_posx = val;
315 break;
316 case 1:
317 // progress bar vertical position
318 G.nbar_posy = val;
319 break;
320 case 2:
321 // progress bar width
322 G.nbar_width = val;
323 break;
324 case 3:
325 // progress bar height
326 G.nbar_height = val;
327 break;
328 case 4:
329 // progress bar color - red component
330 G.nbar_colr = val;
331 break;
332 case 5:
333 // progress bar color - green component
334 G.nbar_colg = val;
335 break;
336 case 6:
337 // progress bar color - blue component
338 G.nbar_colb = val;
339 break;
340#if DEBUG 301#if DEBUG
341 case 7: 302 if (i == 7) {
342 G.bdebug_messages = val; 303 G.bdebug_messages = val;
343 if (G.bdebug_messages) 304 if (G.bdebug_messages)
344 G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log"); 305 G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");
345 break;
346#endif
347 err:
348 default:
349 bb_error_msg_and_die("syntax error: '%s'", buf);
350 } 306 }
351 free(buf); 307#endif
352 } 308 }
353 fclose(inifile); 309 config_close(parser);
354} 310}
355 311
356 312