fbsplash: move to /sbin; small shrink

function                                             old     new   delta
fb_drawprogressbar                                   413     423     +10
fbsplash_main                                       1146    1121     -25
This commit is contained in:
Denis Vlasenko 2008-03-28 11:17:35 +00:00
parent c4523c2b3d
commit a38ba59cc3
2 changed files with 27 additions and 28 deletions

View File

@ -149,7 +149,7 @@ USE_EXPR(APPLET(expr, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
USE_FALSE(APPLET_NOFORK(false, false, _BB_DIR_BIN, _BB_SUID_NEVER, false)) USE_FALSE(APPLET_NOFORK(false, false, _BB_DIR_BIN, _BB_SUID_NEVER, false))
USE_FBSET(APPLET(fbset, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) USE_FBSET(APPLET(fbset, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
USE_FBSPLASH(APPLET(fbsplash, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_FBSPLASH(APPLET(fbsplash, _BB_DIR_SBIN, _BB_SUID_NEVER))
USE_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_NEVER, fdflush)) USE_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_NEVER, fdflush))
USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER)) USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))

View File

@ -95,16 +95,15 @@ static void fb_open(const char *strfb_device)
/** /**
* Draw hollow rectangle on framebuffer * Draw hollow rectangle on framebuffer
* \param nx1pos,ny1pos upper left position
* \param nx2pos,ny2pos down right position
* \param nred,ngreen,nblue rgb color
*/ */
static void fb_drawrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos, static void fb_drawrectangle(void)
unsigned char nred, unsigned char ngreen, unsigned char nblue)
{ {
int cnt; int cnt;
DATA thispix; DATA thispix;
DATA *ptr1, *ptr2; DATA *ptr1, *ptr2;
unsigned char nred = G.nbar_colr/2;
unsigned char ngreen = G.nbar_colg/2;
unsigned char nblue = G.nbar_colb/2;
nred >>= 3; // 5-bit red nred >>= 3; // 5-bit red
ngreen >>= 2; // 6-bit green ngreen >>= 2; // 6-bit green
@ -112,18 +111,18 @@ static void fb_drawrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos,
thispix = nblue + (ngreen << 5) + (nred << (5+6)); thispix = nblue + (ngreen << 5) + (nred << (5+6));
// horizontal lines // horizontal lines
ptr1 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
ptr2 = (DATA*)(G.addr + (ny2pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); ptr2 = (DATA*)(G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
cnt = nx2pos - nx1pos; cnt = G.nbar_width - 1;
do { do {
*ptr1++ = thispix; *ptr1++ = thispix;
*ptr2++ = thispix; *ptr2++ = thispix;
} while (--cnt >= 0); } while (--cnt >= 0);
// vertical lines // vertical lines
ptr1 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
ptr2 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx2pos) * BYTES_PER_PIXEL); ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL);
cnt = ny2pos - ny1pos; cnt = G.nbar_posy + G.nbar_height - 1 - G.nbar_posy;
do { do {
*ptr1 = thispix; ptr1 += G.scr_var.xres; *ptr1 = thispix; ptr1 += G.scr_var.xres;
*ptr2 = thispix; ptr2 += G.scr_var.xres; *ptr2 = thispix; ptr2 += G.scr_var.xres;
@ -179,10 +178,7 @@ static void fb_drawprogressbar(unsigned percent)
if ((height | width) < 0) if ((height | width) < 0)
return; return;
// NB: "width" of 1 actually makes rect with width of 2! // NB: "width" of 1 actually makes rect with width of 2!
fb_drawrectangle( fb_drawrectangle();
left_x, top_y,
left_x + width, top_y + height,
G.nbar_colr/2, G.nbar_colg/2, G.nbar_colb/2);
// inner "empty" rectangle // inner "empty" rectangle
left_x++; left_x++;
@ -280,8 +276,9 @@ static void fb_drawimage(void)
/** /**
* Parse configuration file * Parse configuration file
* \param *cfg_filename name of the configuration file
*/ */
static void init(const char *ini_filename) static void init(const char *cfg_filename)
{ {
static const char const param_names[] ALIGN1 = static const char const param_names[] ALIGN1 =
"BAR_LEFT\0" "BAR_TOP\0" "BAR_LEFT\0" "BAR_TOP\0"
@ -295,7 +292,7 @@ static void init(const char *ini_filename)
FILE *inifile; FILE *inifile;
char *buf; char *buf;
inifile = xfopen_stdin(ini_filename); inifile = xfopen_stdin(cfg_filename);
while ((buf = xmalloc_fgetline(inifile)) != NULL) { while ((buf = xmalloc_fgetline(inifile)) != NULL) {
char *value_str; char *value_str;
@ -361,7 +358,7 @@ static void init(const char *ini_filename)
int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv) int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
{ {
const char *fb_device, *ini_filename, *fifo_filename; const char *fb_device, *cfg_filename, *fifo_filename;
FILE *fp = fp; // for compiler FILE *fp = fp; // for compiler
bool bCursorOff; bool bCursorOff;
@ -369,22 +366,19 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
// parse command line options // parse command line options
fb_device = "/dev/fb0"; fb_device = "/dev/fb0";
ini_filename = NULL; cfg_filename = NULL;
fifo_filename = NULL; fifo_filename = NULL;
bCursorOff = 1 & getopt32(argv, "cs:d:i:f:", bCursorOff = 1 & getopt32(argv, "cs:d:i:f:",
&G.image_filename, &fb_device, &ini_filename, &fifo_filename); &G.image_filename, &fb_device, &cfg_filename, &fifo_filename);
// parse configuration file // parse configuration file
if (ini_filename) if (cfg_filename)
init(ini_filename); init(cfg_filename);
// We must have -s IMG // We must have -s IMG
if (!G.image_filename) if (!G.image_filename)
bb_show_usage(); bb_show_usage();
if (fifo_filename)
fp = xfopen_stdin(fifo_filename);
fb_open(fb_device); fb_open(fb_device);
if (fifo_filename && bCursorOff) { if (fifo_filename && bCursorOff) {
@ -394,7 +388,12 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
fb_drawimage(); fb_drawimage();
if (fifo_filename) while (1) { if (!fifo_filename)
return EXIT_SUCCESS;
fp = xfopen_stdin(fifo_filename);
while (1) {
struct stat statbuf; struct stat statbuf;
unsigned num; unsigned num;
char *num_buf; char *num_buf;