]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/socket.c
Fix design/designed typo in backend.man manpage
[thirdparty/cups.git] / backend / socket.c
index 77255a394f871310b85d03bea8c1385f0bcaa284..e5158239470dae89fe271129cc947eb56fb7406e 100644 (file)
@@ -1,23 +1,16 @@
 /*
- * "$Id: socket.c 7881 2008-08-28 20:21:56Z mike $"
+ * AppSocket backend for CUPS.
  *
- *   AppSocket backend for CUPS.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   Copyright 2007-2012 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file.  If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   "LICENSE" which should have been included with this file.  If this
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   main()    - Send a file to the printer or server.
- *   wait_bc() - Wait for back-channel data...
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
@@ -46,7 +39,7 @@
  * Local functions...
  */
 
-static int     wait_bc(int device_fd, int secs);
+static ssize_t wait_bc(int device_fd, int secs);
 
 
 /*
@@ -73,10 +66,6 @@ main(int  argc,                              /* I - Number of command-line arguments (6 or 7) */
   int          print_fd;               /* Print file */
   int          copies;                 /* Number of copies to print */
   time_t       start_time;             /* Time of first connect */
-#ifdef __APPLE__
-  time_t       current_time,           /* Current time */
-               wait_time;              /* Time to wait before shutting down socket */
-#endif /* __APPLE__ */
   int          contimeout;             /* Connection timeout */
   int          waiteof;                /* Wait for end-of-file? */
   int          port;                   /* Port number */
@@ -254,8 +243,8 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
          */
 
          snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") ||
-                        _cups_strcasecmp(value, "yes") ||
-                        _cups_strcasecmp(value, "true");
+                        !_cups_strcasecmp(value, "yes") ||
+                        !_cups_strcasecmp(value, "true");
       }
       else if (!_cups_strcasecmp(name, "contimeout"))
       {
@@ -389,7 +378,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
              break;
         }
 
-       sleep(delay);
+       sleep((unsigned)delay);
 
        if (delay < 30)
          delay += 5;
@@ -410,7 +399,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
   fprintf(stderr, "DEBUG: Connected to %s:%d...\n",
          httpAddrString(&(addr->addr), addrname, sizeof(addrname)),
-         _httpAddrPort(&(addr->addr)));
+         httpAddrPort(&(addr->addr)));
 
  /*
   * Print everything...
@@ -419,7 +408,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   tbytes = 0;
 
   if (bytes > 0)
-    tbytes += write(device_fd, buffer, bytes);
+    tbytes += write(device_fd, buffer, (size_t)bytes);
 
   while (copies > 0 && tbytes >= 0)
   {
@@ -438,16 +427,7 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
       _cupsLangPrintFilter(stderr, "INFO", _("Print file sent."));
   }
 
-#ifdef __APPLE__
- /*
-  * Wait up to 5 seconds to get any pending back-channel data...
-  */
-
-  wait_time = time(NULL) + 5;
-  while (wait_time >= time(&current_time))
-    if (wait_bc(device_fd, wait_time - current_time) <= 0)
-      break;
-#endif /* __APPLE__ */
+  fputs("STATE: +cups-waiting-for-job-completed\n", stderr);
 
   if (waiteof)
   {
@@ -494,7 +474,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
  * 'wait_bc()' - Wait for back-channel data...
  */
 
-static int                             /* O - # bytes read or -1 on error */
+static ssize_t                         /* O - # bytes read or -1 on error */
 wait_bc(int device_fd,                 /* I - Socket */
         int secs)                      /* I - Seconds to wait */
 {
@@ -524,7 +504,7 @@ wait_bc(int device_fd,                      /* I - Socket */
     {
       fprintf(stderr, "DEBUG: Received %d bytes of back-channel data\n",
              (int)bytes);
-      cupsBackChannelWrite(buffer, bytes, 1.0);
+      cupsBackChannelWrite(buffer, (size_t)bytes, 1.0);
     }
 
     return (bytes);
@@ -532,8 +512,3 @@ wait_bc(int device_fd,                      /* I - Socket */
   else
     return (-1);
 }
-
-
-/*
- * End of "$Id: socket.c 7881 2008-08-28 20:21:56Z mike $".
- */