diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-24 23:32:36 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-24 23:32:36 +0000 |
| commit | f99afb5dff00534df6cf8f4d9de5d274c7818eac (patch) | |
| tree | 72eb7ab8b462f2adf8adc8d7ffeef3cf9c1135cc | |
| parent | a2f47358eb5479d65510b0eb506d52435ca26c21 (diff) | |
| download | busybox-w32-f99afb5dff00534df6cf8f4d9de5d274c7818eac.tar.gz busybox-w32-f99afb5dff00534df6cf8f4d9de5d274c7818eac.tar.bz2 busybox-w32-f99afb5dff00534df6cf8f4d9de5d274c7818eac.zip | |
lpd: new applet by Vladimir Dronnikov <dronnikov AT gmail.com>
| -rw-r--r-- | include/applets.h | 1 | ||||
| -rw-r--r-- | include/usage.h | 6 | ||||
| -rw-r--r-- | libbb/read.c | 3 | ||||
| -rw-r--r-- | printutils/Config.in | 6 | ||||
| -rw-r--r-- | printutils/Kbuild | 1 | ||||
| -rw-r--r-- | printutils/lpr.c | 12 |
6 files changed, 24 insertions, 5 deletions
diff --git a/include/applets.h b/include/applets.h index ffd7afc67..cdb19958c 100644 --- a/include/applets.h +++ b/include/applets.h | |||
| @@ -227,6 +227,7 @@ USE_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_ALWAYS)) | |||
| 227 | USE_LOGNAME(APPLET_NOFORK(logname, logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER, logname)) | 227 | USE_LOGNAME(APPLET_NOFORK(logname, logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER, logname)) |
| 228 | USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 228 | USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 229 | USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 229 | USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 230 | USE_LPD(APPLET(lpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | ||
| 230 | USE_LPQ(APPLET_ODDNAME(lpq, lpqr, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lpq)) | 231 | USE_LPQ(APPLET_ODDNAME(lpq, lpqr, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lpq)) |
| 231 | USE_LPR(APPLET_ODDNAME(lpr, lpqr, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lpr)) | 232 | USE_LPR(APPLET_ODDNAME(lpr, lpqr, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lpr)) |
| 232 | USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls)) | 233 | USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls)) |
diff --git a/include/usage.h b/include/usage.h index c9329b30b..7c9a90e77 100644 --- a/include/usage.h +++ b/include/usage.h | |||
| @@ -2051,6 +2051,12 @@ USE_FEATURE_BRCTL_FANCY("\n" \ | |||
| 2051 | "with an optional offset (-o 12345). Encryption is not yet supported.\n" \ | 2051 | "with an optional offset (-o 12345). Encryption is not yet supported.\n" \ |
| 2052 | "losetup -f will show the first loop free loop device\n\n" | 2052 | "losetup -f will show the first loop free loop device\n\n" |
| 2053 | 2053 | ||
| 2054 | #define lpd_trivial_usage \ | ||
| 2055 | "SPOOLDIR" | ||
| 2056 | #define lpd_full_usage \ | ||
| 2057 | "Example:" \ | ||
| 2058 | "\n tcpsvd -E localhost 515 lpd /var/spool" | ||
| 2059 | |||
| 2054 | #define lpq_trivial_usage \ | 2060 | #define lpq_trivial_usage \ |
| 2055 | "[-P queue[@host[:port]]] [-U USERNAME] [-d JOBID...] [-fs]" | 2061 | "[-P queue[@host[:port]]] [-U USERNAME] [-d JOBID...] [-fs]" |
| 2056 | #define lpq_full_usage \ | 2062 | #define lpq_full_usage \ |
diff --git a/libbb/read.c b/libbb/read.c index 640293b70..4ad41d589 100644 --- a/libbb/read.c +++ b/libbb/read.c | |||
| @@ -161,8 +161,7 @@ char *xmalloc_reads(int fd, char *buf) | |||
| 161 | } | 161 | } |
| 162 | /* nonblock_safe_read() because we are used by e.g. shells */ | 162 | /* nonblock_safe_read() because we are used by e.g. shells */ |
| 163 | if (nonblock_safe_read(fd, p, 1) != 1) { /* EOF/error */ | 163 | if (nonblock_safe_read(fd, p, 1) != 1) { /* EOF/error */ |
| 164 | if (p == buf) { | 164 | if (p == buf) { /* we read nothing */ |
| 165 | /* we read nothing [and buf was NULL initially] */ | ||
| 166 | free(buf); | 165 | free(buf); |
| 167 | return NULL; | 166 | return NULL; |
| 168 | } | 167 | } |
diff --git a/printutils/Config.in b/printutils/Config.in index b53b9e7fa..e5f18646c 100644 --- a/printutils/Config.in +++ b/printutils/Config.in | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | menu "print support" | 1 | menu "print support" |
| 2 | 2 | ||
| 3 | config LPD | ||
| 4 | bool "lpd" | ||
| 5 | default n | ||
| 6 | help | ||
| 7 | lpd is a print spooling daemon. | ||
| 8 | |||
| 3 | config LPR | 9 | config LPR |
| 4 | bool "lpr" | 10 | bool "lpr" |
| 5 | default n | 11 | default n |
diff --git a/printutils/Kbuild b/printutils/Kbuild index 4f97d0d15..008290ee9 100644 --- a/printutils/Kbuild +++ b/printutils/Kbuild | |||
| @@ -4,5 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | lib-y := | 5 | lib-y := |
| 6 | 6 | ||
| 7 | lib-$(CONFIG_LPD) += lpd.o | ||
| 7 | lib-$(CONFIG_LPR) += lpr.o | 8 | lib-$(CONFIG_LPR) += lpr.o |
| 8 | lib-$(CONFIG_LPQ) += lpr.o | 9 | lib-$(CONFIG_LPQ) += lpr.o |
diff --git a/printutils/lpr.c b/printutils/lpr.c index 86fcd9b1b..52983bfb7 100644 --- a/printutils/lpr.c +++ b/printutils/lpr.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | */ | 19 | */ |
| 20 | static void get_response_or_say_and_die(const char *errmsg) | 20 | static void get_response_or_say_and_die(const char *errmsg) |
| 21 | { | 21 | { |
| 22 | static const char newline = '\n'; | ||
| 22 | char buf = ' '; | 23 | char buf = ' '; |
| 23 | 24 | ||
| 24 | fflush(stdout); | 25 | fflush(stdout); |
| @@ -28,8 +29,9 @@ static void get_response_or_say_and_die(const char *errmsg) | |||
| 28 | // request has failed | 29 | // request has failed |
| 29 | bb_error_msg("error while %s. Server said:", errmsg); | 30 | bb_error_msg("error while %s. Server said:", errmsg); |
| 30 | safe_write(STDERR_FILENO, &buf, 1); | 31 | safe_write(STDERR_FILENO, &buf, 1); |
| 31 | logmode = 0; /* no errors from bb_copyfd_eof() */ | 32 | logmode = 0; /* no error messages from bb_copyfd_eof() pls */ |
| 32 | bb_copyfd_eof(STDOUT_FILENO, STDERR_FILENO); | 33 | bb_copyfd_eof(STDOUT_FILENO, STDERR_FILENO); |
| 34 | safe_write(STDERR_FILENO, &newline, 1); | ||
| 33 | xfunc_die(); | 35 | xfunc_die(); |
| 34 | } | 36 | } |
| 35 | } | 37 | } |
| @@ -190,8 +192,12 @@ int lpqr_main(int argc, char *argv[]) | |||
| 190 | , remote_filename | 192 | , remote_filename |
| 191 | ); | 193 | ); |
| 192 | // delete possible "\nX\n" patterns | 194 | // delete possible "\nX\n" patterns |
| 193 | while ((c = strchr(controlfile, '\n')) != NULL && c[1] && c[2] == '\n') | 195 | c = controlfile; |
| 194 | memmove(c, c+2, strlen(c+1)); /* strlen(c+1) == strlen(c+2) + 1 */ | 196 | while ((c = strchr(c, '\n')) != NULL) { |
| 197 | c++; | ||
| 198 | while (c[0] && c[1] == '\n') | ||
| 199 | memmove(c, c+2, strlen(c+1)); /* strlen(c+1) == strlen(c+2) + 1 */ | ||
| 200 | } | ||
| 195 | 201 | ||
| 196 | // send control file | 202 | // send control file |
| 197 | if (opts & LPR_V) | 203 | if (opts & LPR_V) |
