svn commit: trunk/busybox: include libbb printutils

vda at busybox.net vda at busybox.net
Sun Feb 24 23:32:36 UTC 2008


Author: vda
Date: 2008-02-24 15:32:36 -0800 (Sun, 24 Feb 2008)
New Revision: 21108

Log:
lpd: new applet by Vladimir Dronnikov <dronnikov AT gmail.com>



Modified:
   trunk/busybox/include/applets.h
   trunk/busybox/include/usage.h
   trunk/busybox/libbb/read.c
   trunk/busybox/printutils/Config.in
   trunk/busybox/printutils/Kbuild
   trunk/busybox/printutils/lpr.c


Changeset:
Modified: trunk/busybox/include/applets.h
===================================================================
--- trunk/busybox/include/applets.h	2008-02-24 23:02:56 UTC (rev 21107)
+++ trunk/busybox/include/applets.h	2008-02-24 23:32:36 UTC (rev 21108)
@@ -227,6 +227,7 @@
 USE_LOGNAME(APPLET_NOFORK(logname, logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER, logname))
 USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER))
 USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER))
+USE_LPD(APPLET(lpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
 USE_LPQ(APPLET_ODDNAME(lpq, lpqr, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lpq))
 USE_LPR(APPLET_ODDNAME(lpr, lpqr, _BB_DIR_USR_BIN, _BB_SUID_NEVER, lpr))
 USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls))

Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2008-02-24 23:02:56 UTC (rev 21107)
+++ trunk/busybox/include/usage.h	2008-02-24 23:32:36 UTC (rev 21108)
@@ -2051,6 +2051,12 @@
        "with an optional offset (-o 12345). Encryption is not yet supported.\n" \
        "losetup -f will show the first loop free loop device\n\n"
 
+#define lpd_trivial_usage \
+       "SPOOLDIR"
+#define lpd_full_usage \
+       "Example:" \
+       "\n	tcpsvd -E localhost 515 lpd /var/spool"
+
 #define lpq_trivial_usage \
        "[-P queue[@host[:port]]] [-U USERNAME] [-d JOBID...] [-fs]"
 #define lpq_full_usage \

Modified: trunk/busybox/libbb/read.c
===================================================================
--- trunk/busybox/libbb/read.c	2008-02-24 23:02:56 UTC (rev 21107)
+++ trunk/busybox/libbb/read.c	2008-02-24 23:32:36 UTC (rev 21108)
@@ -161,8 +161,7 @@
 		}
 		/* nonblock_safe_read() because we are used by e.g. shells */
 		if (nonblock_safe_read(fd, p, 1) != 1) { /* EOF/error */
-			if (p == buf) {
-				/* we read nothing [and buf was NULL initially] */
+			if (p == buf) { /* we read nothing */
 				free(buf);
 				return NULL;
 			}

Modified: trunk/busybox/printutils/Config.in
===================================================================
--- trunk/busybox/printutils/Config.in	2008-02-24 23:02:56 UTC (rev 21107)
+++ trunk/busybox/printutils/Config.in	2008-02-24 23:32:36 UTC (rev 21108)
@@ -1,5 +1,11 @@
 menu "print support"
 
+config LPD
+	bool "lpd"
+	default n
+	help
+	  lpd is a print spooling daemon.
+
 config LPR
 	bool "lpr"
 	default n

Modified: trunk/busybox/printutils/Kbuild
===================================================================
--- trunk/busybox/printutils/Kbuild	2008-02-24 23:02:56 UTC (rev 21107)
+++ trunk/busybox/printutils/Kbuild	2008-02-24 23:32:36 UTC (rev 21108)
@@ -4,5 +4,6 @@
 
 lib-y :=
 
+lib-$(CONFIG_LPD) += lpd.o
 lib-$(CONFIG_LPR) += lpr.o
 lib-$(CONFIG_LPQ) += lpr.o

Modified: trunk/busybox/printutils/lpr.c
===================================================================
--- trunk/busybox/printutils/lpr.c	2008-02-24 23:02:56 UTC (rev 21107)
+++ trunk/busybox/printutils/lpr.c	2008-02-24 23:32:36 UTC (rev 21108)
@@ -19,6 +19,7 @@
  */
 static void get_response_or_say_and_die(const char *errmsg)
 {
+	static const char newline = '\n';
 	char buf = ' ';
 
 	fflush(stdout);
@@ -28,8 +29,9 @@
 		// request has failed
 		bb_error_msg("error while %s. Server said:", errmsg);
 		safe_write(STDERR_FILENO, &buf, 1);
-		logmode = 0; /* no errors from bb_copyfd_eof() */
+		logmode = 0; /* no error messages from bb_copyfd_eof() pls */
 		bb_copyfd_eof(STDOUT_FILENO, STDERR_FILENO);
+		safe_write(STDERR_FILENO, &newline, 1);
 		xfunc_die();
 	}
 }
@@ -190,8 +192,12 @@
 			, remote_filename
 		);
 		// delete possible "\nX\n" patterns
-		while ((c = strchr(controlfile, '\n')) != NULL && c[1] && c[2] == '\n')
-			memmove(c, c+2, strlen(c+1)); /* strlen(c+1) == strlen(c+2) + 1 */
+		c = controlfile;
+		while ((c = strchr(c, '\n')) != NULL) {
+			c++;
+			while (c[0] && c[1] == '\n')
+				memmove(c, c+2, strlen(c+1)); /* strlen(c+1) == strlen(c+2) + 1 */
+		}
 
 		// send control file
 		if (opts & LPR_V)




More information about the busybox-cvs mailing list