]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/testlpd.c
Sync up with CUPS 1.7svn-r10893
[thirdparty/cups.git] / scheduler / testlpd.c
index e7527339de85fe8ee2108f3362c1b024d32701cb..c000ddc83bcb6663dda86cc3cb840b370e6402a6 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * "$Id: testlpd.c 6789 2007-08-13 19:52:43Z mike $"
  *
- *   cups-lpd test program for the Common UNIX Printing System (CUPS).
+ *   cups-lpd test program for CUPS.
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 2006 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  */
 
 #include <cups/cups.h>
-#include <cups/string.h>
-#include <stdlib.h>
+#include <cups/string-private.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
-#include <errno.h>
 #include <signal.h>
 #include <unistd.h>
 #include <fcntl.h>
  */
 
 static int     do_command(int outfd, int infd, const char *command);
-static int     print_job(int outfd, int infd, char *dest, char **args);
+static int     print_job(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
 static int     print_waiting(int outfd, int infd, char *dest);
-static int     remove_job(int outfd, int infd, char *dest, char **args);
-static int     status_long(int outfd, int infd, char *dest, char **args);
-static int     status_short(int outfd, int infd, char *dest, char **args);
-static void    usage(void);
+static int     remove_job(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
+static int     status_long(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
+static int     status_short(int outfd, int infd, char *dest, char **args) __attribute__((nonnull(4)));
+static void    usage(void) __attribute__((noreturn));
 
 
 /*
@@ -78,7 +76,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
   */
 
   op              = NULL;
-  opargs          = NULL;
+  opargs          = argv + argc;
   dest            = NULL;
   cupslpd_argc    = 1;
   cupslpd_argv[0] = (char *)"cups-lpd";
@@ -145,13 +143,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
     * Child goes here...
     */
 
-    close(0);
-    dup(cupslpd_stdin[0]);
+    dup2(cupslpd_stdin[0], 0);
     close(cupslpd_stdin[0]);
     close(cupslpd_stdin[1]);
 
-    close(1);
-    dup(cupslpd_stdout[1]);
+    dup2(cupslpd_stdout[1], 1);
     close(cupslpd_stdout[0]);
     close(cupslpd_stdout[1]);