nc: use symbolic SHUT_WR instead of literal 1
[oweals/busybox.git] / printutils / lpd.c
index 15f1ba20b20e3c0807a92c7e5fd46542efa73125..642e8a89e70b06938d9c97e4ff6f55656bab3c04 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
  *
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
  */
 
 /*
  * mv -f ./"$DATAFILE" save/
  */
 
+//usage:#define lpd_trivial_usage
+//usage:       "SPOOLDIR [HELPER [ARGS]]"
+//usage:#define lpd_full_usage "\n\n"
+//usage:       "SPOOLDIR must contain (symlinks to) device nodes or directories"
+//usage:     "\nwith names matching print queue names. In the first case, jobs are"
+//usage:     "\nsent directly to the device. Otherwise each job is stored in queue"
+//usage:     "\ndirectory and HELPER program is called. Name of file to print"
+//usage:     "\nis passed in $DATAFILE variable."
+//usage:     "\nExample:"
+//usage:     "\n       tcpsvd -E 0 515 softlimit -m 999999 lpd /var/spool ./print"
+
 #include "libbb.h"
 
 // strip argument of bad chars
@@ -91,7 +102,7 @@ static char *xmalloc_read_stdin(void)
 {
        // SECURITY:
        size_t max = 4 * 1024; // more than enough for commands!
-       return xmalloc_reads(STDIN_FILENO, NULL, &max);
+       return xmalloc_reads(STDIN_FILENO, &max);
 }
 
 int lpd_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE;
@@ -135,7 +146,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
        while (1) {
                char *fname;
                int fd;
-               // int is easier than ssize_t: can use xatoi_u,
+               // int is easier than ssize_t: can use xatoi_positive,
                // and can correctly display error returns (-1)
                int expected_len, real_len;
 
@@ -181,8 +192,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
                        // this call reopens stdio fds to "/dev/null"
                        // (no daemonization is done)
                        bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO | DAEMON_ONLY_SANITIZE, NULL);
-                       BB_EXECVP(argv[0], argv);
-                       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
+                       BB_EXECVP_or_die(argv);
                }
 
                // validate input.