Patch for the today tarball.
> [line 387]
> if (fifo_filename)
> fp = xfopen_stdin(fifo_filename);
'xfopen_stdin' blocks on open so, using the fifo it isn't showed any
image until the first command is received.
I modified it and the old way of parsing the commands.
> Il giorno mer, 26/03/2008 alle 14.58 +0100, Bernhard Fischer ha scritto:
> > >+USE_FBSPLASH(APPLET(fbsplash, _BB_DIR_BIN, _BB_SUID_NEVER))
> >
> > Perhaps it would make more sense to put this into /sbin ?
Done.
> As said previously, it may be benefical to pass a pointer to struct
> geometry to the drawing functions instead of passing x/y and
> eventually
> r/g/b/a as individual parameters.
The geometry struct is global so it isn't necessary to pass the pointer
to it --> I removed any parameters to the function 'fb_drawrectangle'.
For the function 'fb_drawfullrectangle', called several times with
runtime variable parameters (in order to shows different lenghts of the
progress bar), I don't know whether it is convenient create a special
structure for this function.
Denys, can you try this patch and, if it is correct, add it to svn.
Thanks.
Michele
diff -urP busybox/include/applets.h busybox_modificata28/include/applets.h
--- busybox/include/applets.h 2008-03-28 08:20:16.000000000 +0100
+++ busybox_modificata28/include/applets.h 2008-03-28 09:35:21.000000000 +0100
@@ -149,7 +149,7 @@
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_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_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_NEVER))
diff -urP busybox/miscutils/fbsplash.c busybox_modificata28/miscutils/fbsplash.c
--- busybox/miscutils/fbsplash.c 2008-03-28 08:20:16.000000000 +0100
+++ busybox_modificata28/miscutils/fbsplash.c 2008-03-28 10:50:24.000000000 +0100
@@ -95,16 +95,15 @@
/**
* 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,
- unsigned char nred, unsigned char ngreen, unsigned char nblue)
+static void fb_drawrectangle(void)
{
int cnt;
DATA thispix;
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
ngreen >>= 2; // 6-bit green
@@ -112,18 +111,18 @@
thispix = nblue + (ngreen << 5) + (nred << (5+6));
// horizontal lines
- ptr1 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL);
- ptr2 = (DATA*)(G.addr + (ny2pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL);
- cnt = nx2pos - nx1pos;
+ ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * 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 = G.nbar_width - 1;
do {
*ptr1++ = thispix;
*ptr2++ = thispix;
} while (--cnt >= 0);
// vertical lines
- ptr1 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL);
- ptr2 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx2pos) * BYTES_PER_PIXEL);
- cnt = ny2pos - ny1pos;
+ ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * 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 = G.nbar_posy + G.nbar_height - 1 - G.nbar_posy;
do {
*ptr1 = thispix; ptr1 += G.scr_var.xres;
*ptr2 = thispix; ptr2 += G.scr_var.xres;
@@ -179,10 +178,7 @@
if ((height | width) < 0)
return;
// NB: "width" of 1 actually makes rect with width of 2!
- fb_drawrectangle(
- left_x, top_y,
- left_x + width, top_y + height,
- G.nbar_colr/2, G.nbar_colg/2, G.nbar_colb/2);
+ fb_drawrectangle();
// inner "empty" rectangle
left_x++;
@@ -280,8 +276,9 @@
/**
* 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 =
"BAR_LEFT\0" "BAR_TOP\0"
@@ -295,7 +292,7 @@
FILE *inifile;
char *buf;
- inifile = xfopen_stdin(ini_filename);
+ inifile = xfopen_stdin(cfg_filename);
while ((buf = xmalloc_fgetline(inifile)) != NULL) {
char *value_str;
@@ -361,29 +358,29 @@
int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
- const char *fb_device, *ini_filename, *fifo_filename;
- FILE *fp = fp; // for compiler
+ const char *fb_device, *cfg_filename, *fifo_filename;
+ int fp = fp; // for compiler
bool bCursorOff;
INIT_G();
// parse command line options
fb_device = "/dev/fb0";
- ini_filename = NULL;
+ cfg_filename = NULL;
fifo_filename = NULL;
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
- if (ini_filename)
- init(ini_filename);
+ if (cfg_filename)
+ init(cfg_filename);
// We must have -s IMG
if (!G.image_filename)
bb_show_usage();
if (fifo_filename)
- fp = xfopen_stdin(fifo_filename);
+ fp = xopen(fifo_filename, O_RDWR);
fb_open(fb_device);
@@ -394,27 +391,32 @@
fb_drawimage();
- if (fifo_filename) while (1) {
- struct stat statbuf;
+ if (fifo_filename) {
unsigned num;
- char *num_buf;
+ char num_buf[64];
+ int len;
fb_drawprogressbar(0);
// Block on read, waiting for some input.
- // Use of <stdio.h> style I/O allows to correctly
- // handle a case when we have many buffered lines
- // already in the pipe
- while ((num_buf = xmalloc_fgetline(fp)) != NULL) {
+ while (1) {
+ len = read(fp, num_buf, 64);
+ if (len == -1) {
+#if DEBUG
+ DEBUG_MESSAGE("error reading the fifo");
+#endif
+ break;
+ }
+ num_buf[len] = '\0';
+
if (strncmp(num_buf, "exit", 4) == 0) {
+#if DEBUG
DEBUG_MESSAGE("exit");
- exit_cmd:
- if (bCursorOff) {
- // restore cursor
- full_write(STDOUT_FILENO, "\x1b" "[?25h", 6);
- }
- return EXIT_SUCCESS;
+#endif
+ break;
}
+
num = atoi(num_buf);
+
if (isdigit(num_buf[0]) && (num <= 100)) {
#if DEBUG
char strVal[10];
@@ -423,30 +425,16 @@
#endif
fb_drawprogressbar(num);
}
- free(num_buf);
- }
- // We got EOF/error on fp
- if (ferror(fp))
- goto exit_cmd;
- fclose(fp);
- if (LONE_DASH(fifo_filename)
- || stat(fifo_filename, &statbuf) != 0
- || !S_ISFIFO(statbuf.st_mode)
- ) {
- goto exit_cmd;
+ } // end of while (1)
+
+ if (bCursorOff) {
+ // restore cursor
+ full_write(STDOUT_FILENO, "\x1b" "[?25h", 6);
}
- // It's really a named pipe!
- // For named pipes, we want to support this:
- // mkfifo cmd_pipe
- // fbsplash -f cmd_pipe .... &
- // ...
- // echo 33 >cmd_pipe
- // ...
- // echo 66 >cmd_pipe
- // This means that on EOF, we need to close/open cmd_pipe
- // (just reading again works too, but it hogs CPU)
- fp = xfopen_stdin(fifo_filename); // blocks on open
- } // end of while (1)
+
+ if (ENABLE_FEATURE_CLEAN_UP)
+ close(fp);
+ }
return EXIT_SUCCESS;
}
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox