summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko2008-07-24 23:38:04 +0000
committerDenis Vlasenko2008-07-24 23:38:04 +0000
commit0f99d49ae680e675809428deace3c4fe839d323c (patch)
tree712afab828ee4fb02493bc60e1a37f1142231263 /miscutils
parent22f741484391c3b2fd94881fd41c8c0df9749e95 (diff)
downloadbusybox-0f99d49ae680e675809428deace3c4fe839d323c.zip
busybox-0f99d49ae680e675809428deace3c4fe839d323c.tar.gz
*: 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 380f09b..6357f78 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -38,13 +38,7 @@ struct globals {
FILE *logfile_fd; // log file
#endif
unsigned char *addr; // pointer to framebuffer memory
- unsigned nbar_width; // progress bar width
- unsigned nbar_height; // progress bar height
- unsigned nbar_posx; // progress bar horizontal position
- unsigned nbar_posy; // progress bar vertical position
- unsigned char nbar_colr; // progress bar color red component
- unsigned char nbar_colg; // progress bar color green component
- unsigned char nbar_colb; // progress bar color blue component
+ unsigned ns[7]; // n-parameters
const char *image_filename;
struct fb_var_screeninfo scr_var;
struct fb_fix_screeninfo scr_fix;
@@ -54,6 +48,13 @@ struct globals {
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
+#define nbar_width ns[0] // progress bar width
+#define nbar_height ns[1] // progress bar height
+#define nbar_posx ns[2] // progress bar horizontal position
+#define nbar_posy ns[3] // progress bar vertical position
+#define nbar_colr ns[4] // progress bar color red component
+#define nbar_colg ns[5] // progress bar color green component
+#define nbar_colb ns[6] // progress bar color blue component
#if DEBUG
#define DEBUG_MESSAGE(strMessage, args...) \
@@ -280,77 +281,32 @@ static void fb_drawimage(void)
static void init(const char *cfg_filename)
{
static const char const param_names[] ALIGN1 =
- "BAR_LEFT\0" "BAR_TOP\0"
"BAR_WIDTH\0" "BAR_HEIGHT\0"
+ "BAR_LEFT\0" "BAR_TOP\0"
"BAR_R\0" "BAR_G\0" "BAR_B\0"
#if DEBUG
"DEBUG\0"
#endif
;
- FILE *inifile;
- char *buf;
-
- inifile = xfopen_stdin(cfg_filename);
-
- while ((buf = xmalloc_fgetline(inifile)) != NULL) {
- char *value_str;
- int val;
-
- if (*buf == '#') { // it's a comment
- free(buf);
- continue;
- }
-
- value_str = strchr(buf, '=');
- if (!value_str)
- goto err;
- *value_str++ = '\0';
- val = xatoi_u(value_str);
-
- switch (index_in_strings(param_names, buf)) {
- case 0:
- // progress bar horizontal position
- G.nbar_posx = val;
- break;
- case 1:
- // progress bar vertical position
- G.nbar_posy = val;
- break;
- case 2:
- // progress bar width
- G.nbar_width = val;
- break;
- case 3:
- // progress bar height
- G.nbar_height = val;
- break;
- case 4:
- // progress bar color - red component
- G.nbar_colr = val;
- break;
- case 5:
- // progress bar color - green component
- G.nbar_colg = val;
- break;
- case 6:
- // progress bar color - blue component
- G.nbar_colb = val;
- break;
+ char *token[2];
+ parser_t *parser = config_open2(cfg_filename, xfopen_stdin);
+ while (config_read(parser, token, 2, 2, "#=", PARSE_MIN_DIE)) {
+ unsigned val = xatoi_u(token[1]);
+ int i = index_in_strings(param_names, token[0]);
+ if (i < 0)
+ bb_error_msg_and_die("syntax error: '%s'", token[0]);
+ if (i >= 0 && i < 7)
+ G.ns[i] = val;
#if DEBUG
- case 7:
+ if (i == 7) {
G.bdebug_messages = val;
if (G.bdebug_messages)
G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");
- break;
-#endif
- err:
- default:
- bb_error_msg_and_die("syntax error: '%s'", buf);
}
- free(buf);
+#endif
}
- fclose(inifile);
+ config_close(parser);
}