fbsplash: support this usage:
mkfifo cmd_pipe fbsplash -f cmd_pipe .... & ... echo 33 >cmd_pipe ... echo 66 >cmd_pipe Code size: fbsplash_main +116 bytes :(
This commit is contained in:
parent
11b9f26610
commit
72b3442aeb
@ -133,8 +133,6 @@
|
|||||||
"\n -f Control pipe (else exit after drawing image)" \
|
"\n -f Control pipe (else exit after drawing image)" \
|
||||||
"\n commands: 'NN' (% for progress bar) or 'exit'" \
|
"\n commands: 'NN' (% for progress bar) or 'exit'" \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define brctl_trivial_usage \
|
#define brctl_trivial_usage \
|
||||||
"COMMAND [BRIDGE [INTERFACE]]"
|
"COMMAND [BRIDGE [INTERFACE]]"
|
||||||
#define brctl_full_usage \
|
#define brctl_full_usage \
|
||||||
|
@ -214,13 +214,13 @@ config FBSPLASH
|
|||||||
-c: hide cursor
|
-c: hide cursor
|
||||||
-d /dev/fbN: framebuffer device (if not /dev/fb0)
|
-d /dev/fbN: framebuffer device (if not /dev/fb0)
|
||||||
-s path_to_image_file (can be "-" for stdin)
|
-s path_to_image_file (can be "-" for stdin)
|
||||||
-i path_to_cfg_file
|
-i path_to_cfg_file (can be "-" for stdin)
|
||||||
-f path_to_fifo (can be "-" for stdin)
|
-f path_to_fifo (can be "-" for stdin)
|
||||||
- if you want to run it only in presence of kernel parameter:
|
- if you want to run it only in presence of kernel parameter:
|
||||||
grep -q "fbsplash=on" </proc/cmdline && setsid fbsplash [params] &
|
grep -q "fbsplash=on" </proc/cmdline && setsid fbsplash [params] &
|
||||||
- commands for fifo:
|
- commands for fifo:
|
||||||
"NN" (ASCII decimal number) - percentage to show on progress bar
|
"NN" (ASCII decimal number) - percentage to show on progress bar
|
||||||
"exit" (or just close fifo) - well you guessed it
|
"exit" - well you guessed it
|
||||||
|
|
||||||
config LAST
|
config LAST
|
||||||
bool "last"
|
bool "last"
|
||||||
|
@ -394,7 +394,8 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
|
|
||||||
fb_drawimage();
|
fb_drawimage();
|
||||||
|
|
||||||
if (fifo_filename) {
|
if (fifo_filename) while (1) {
|
||||||
|
struct stat statbuf;
|
||||||
unsigned num;
|
unsigned num;
|
||||||
char *num_buf;
|
char *num_buf;
|
||||||
|
|
||||||
@ -402,11 +403,16 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
// Block on read, waiting for some input.
|
// Block on read, waiting for some input.
|
||||||
// Use of <stdio.h> style I/O allows to correctly
|
// Use of <stdio.h> style I/O allows to correctly
|
||||||
// handle a case when we have many buffered lines
|
// handle a case when we have many buffered lines
|
||||||
// already in the pipe.
|
// already in the pipe
|
||||||
while ((num_buf = xmalloc_fgetline(fp)) != NULL) {
|
while ((num_buf = xmalloc_fgetline(fp)) != NULL) {
|
||||||
if (strncmp(num_buf, "exit", 4) == 0) {
|
if (strncmp(num_buf, "exit", 4) == 0) {
|
||||||
DEBUG_MESSAGE("exit");
|
DEBUG_MESSAGE("exit");
|
||||||
break;
|
exit_cmd:
|
||||||
|
if (bCursorOff) {
|
||||||
|
// restore cursor
|
||||||
|
full_write(STDOUT_FILENO, "\x1b" "[?25h", 6);
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
num = atoi(num_buf);
|
num = atoi(num_buf);
|
||||||
if (isdigit(num_buf[0]) && (num <= 100)) {
|
if (isdigit(num_buf[0]) && (num <= 100)) {
|
||||||
@ -419,13 +425,28 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
free(num_buf);
|
free(num_buf);
|
||||||
}
|
}
|
||||||
if (bCursorOff) {
|
// We got EOF/error on fp
|
||||||
// restore cursor
|
if (ferror(fp))
|
||||||
full_write(STDOUT_FILENO, "\x1b" "[?25h", 6);
|
goto exit_cmd;
|
||||||
|
fclose(fp);
|
||||||
|
if (LONE_DASH(fifo_filename)
|
||||||
|
|| stat(fifo_filename, &statbuf) != 0
|
||||||
|
|| !S_ISFIFO(statbuf.st_mode)
|
||||||
|
) {
|
||||||
|
goto exit_cmd;
|
||||||
}
|
}
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
// It's really a named pipe!
|
||||||
fclose(fp);
|
// 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)
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user