aboutsummaryrefslogtreecommitdiff
path: root/printutils/lpr.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-25 20:30:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-25 20:30:24 +0000
commit394eebed6656dfc2e56a79500b602023000ac415 (patch)
treeb5b5858663e7333b9624cb4f329e91ae649f3247 /printutils/lpr.c
parent38b8831b3201a9e44cfb156b5b8577e4f5e8d761 (diff)
downloadbusybox-w32-394eebed6656dfc2e56a79500b602023000ac415.tar.gz
busybox-w32-394eebed6656dfc2e56a79500b602023000ac415.tar.bz2
busybox-w32-394eebed6656dfc2e56a79500b602023000ac415.zip
lpd: spool mode added by Vladimir
lpr: more robust error reporting *: introduce and use xchroot libbb: full_read/write now will report partial data counts prior to error isdirectory.c: style fixes lpd_main 249 486 +237 xchroot - 29 +29 get_response_or_say_and_die 110 139 +29 full_write 52 60 +8 full_read 55 63 +8 static.newline 1 - -1 switch_root_main 404 400 -4 chpst_main 1089 1079 -10 getopt32 1370 1359 -11 chroot_main 115 101 -14 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 4/4 up/down: 311/-40) Total: 271 bytes text data bss dec hex filename 798472 728 7484 806684 c4f1c busybox_old 798775 728 7484 806987 c504b busybox_unstripped
Diffstat (limited to 'printutils/lpr.c')
-rw-r--r--printutils/lpr.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/printutils/lpr.c b/printutils/lpr.c
index 52983bfb7..09fbc6ad1 100644
--- a/printutils/lpr.c
+++ b/printutils/lpr.c
@@ -19,19 +19,26 @@
19 */ 19 */
20static void get_response_or_say_and_die(const char *errmsg) 20static void get_response_or_say_and_die(const char *errmsg)
21{ 21{
22 static const char newline = '\n'; 22 ssize_t sz;
23 char buf = ' '; 23 char buf[128];
24 24
25 fflush(stdout); 25 fflush(stdout);
26 26
27 safe_read(STDOUT_FILENO, &buf, 1); 27 buf[0] = ' ';
28 if ('\0' != buf) { 28 sz = safe_read(STDOUT_FILENO, buf, 1);
29 if ('\0' != buf[0]) {
29 // request has failed 30 // request has failed
30 bb_error_msg("error while %s. Server said:", errmsg); 31 // try to make sure last char is '\n', but do not add
31 safe_write(STDERR_FILENO, &buf, 1); 32 // superfluous one
32 logmode = 0; /* no error messages from bb_copyfd_eof() pls */ 33 sz = full_read(STDOUT_FILENO, buf + 1, 126);
33 bb_copyfd_eof(STDOUT_FILENO, STDERR_FILENO); 34 bb_error_msg("error while %s%s", errmsg,
34 safe_write(STDERR_FILENO, &newline, 1); 35 (sz > 0 ? ". Server said:" : ""));
36 if (sz > 0) {
37 // sz = (bytes in buf) - 1
38 if (buf[sz] != '\n')
39 buf[++sz] = '\n';
40 safe_write(STDERR_FILENO, buf, sz + 1);
41 }
35 xfunc_die(); 42 xfunc_die();
36 } 43 }
37} 44}