]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/socket.c
Load cups into easysw/current.
[thirdparty/cups.git] / backend / socket.c
index e6889cf8f7b58943de04cd81cc516fb6275fd59f..20fb7e31dfabadcffba0174356a22cb858ce03ab 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: socket.c 6061 2006-10-23 00:26:52Z mike $"
+ * "$Id: socket.c 6170 2007-01-02 17:26:41Z mike $"
  *
  *   AppSocket backend for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Easy Software Products and are protected by Federal
@@ -25,7 +25,8 @@
  *
  * Contents:
  *
- *   main() - Send a file to the printer or server.
+ *   main()    - Send a file to the printer or server.
+ *   side_cb() - Handle side-channel requests...
  */
 
 /*
 #endif /* WIN32 */
 
 
+/*
+ * Local functions...
+ */
+
+static void    side_cb(int print_fd, int device_fd, int use_bc);
+
+
 /*
  * 'main()' - Send a file to the printer or server.
  *
@@ -325,7 +333,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
       lseek(print_fd, 0, SEEK_SET);
     }
 
-    tbytes = backendRunLoop(print_fd, device_fd, 1);
+    tbytes = backendRunLoop(print_fd, device_fd, 1, side_cb);
 
     if (print_fd != 0 && tbytes >= 0)
       fprintf(stderr, "INFO: Sent print file, " CUPS_LLFMT " bytes...\n",
@@ -398,5 +406,54 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
 
 
 /*
- * End of "$Id: socket.c 6061 2006-10-23 00:26:52Z mike $".
+ * 'side_cb()' - Handle side-channel requests...
+ */
+
+static void
+side_cb(int print_fd,                  /* I - Print file */
+        int device_fd,                 /* I - Device file */
+       int use_bc)                     /* I - Using back-channel? */
+{
+  cups_sc_command_t    command;        /* Request command */
+  cups_sc_status_t     status;         /* Request/response status */
+  char                 data[2048];     /* Request/response data */
+  int                  datalen;        /* Request/response data size */
+
+
+  datalen = sizeof(data);
+
+  if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
+  {
+    fputs("WARNING: Failed to read side-channel request!\n", stderr);
+    return;
+  }
+
+  switch (command)
+  {
+    case CUPS_SC_CMD_DRAIN_OUTPUT :
+       /*
+        * Our sockets disable the Nagle algorithm and data is sent immediately.
+       */
+
+        status  = CUPS_SC_STATUS_OK;
+       datalen = 0;
+        break;
+
+    case CUPS_SC_CMD_GET_BIDI :
+        data[0] = use_bc;
+        datalen = 1;
+        break;
+
+    default :
+        status  = CUPS_SC_STATUS_NOT_IMPLEMENTED;
+       datalen = 0;
+       break;
+  }
+
+  cupsSideChannelWrite(command, status, data, datalen, 1.0);
+}
+
+
+/*
+ * End of "$Id: socket.c 6170 2007-01-02 17:26:41Z mike $".
  */