]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Load cups into easysw/current.
authorjlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be>
Sun, 29 Jan 2006 16:52:03 +0000 (16:52 +0000)
committerjlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be>
Sun, 29 Jan 2006 16:52:03 +0000 (16:52 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@39 a1ca3aef-8c08-0410-bb20-df032aa958be

59 files changed:
Makedefs.in
Makefile
backend/ipp.c
backend/lpd.c
backend/parallel.c
backend/scsi.c
backend/serial.c
backend/socket.c
backend/usb.c
berkeley/lpc.c
berkeley/lpq.c
berkeley/lprm.c
cgi-bin/admin.c
cgi-bin/classes.c
cgi-bin/ipp-var.c
cgi-bin/printers.c
config-scripts/cups-defaults.m4
config-scripts/cups-directories.m4
config-scripts/cups-launchd.m4 [new file with mode: 0644]
config.h.in
configure.in
cups/Makefile
cups/backend.c [new file with mode: 0644]
cups/backend.h
cups/getputfile.c
cups/http-support.c
cups/http.c
cups/http.h
cups/ipp.c
cups/ipp.h
cups/testhttp.c
cups/testipp.c
cups/util.c
doc/Makefile
doc/cups.css
doc/help/spec-ppd.html
init/cups.osx [changed mode: 0644->0755]
init/cupsd-launchd.plist [new file with mode: 0644]
init/cupsd-launchd.sh [new file with mode: 0755]
locale/translate.c
scheduler/client.c
scheduler/conf.c
scheduler/conf.h
scheduler/cups-lpd.c
scheduler/dirsvc.c
scheduler/dirsvc.h
scheduler/ipp.c
scheduler/job.c
scheduler/listen.c
scheduler/main.c
scheduler/sysman.c
systemv/accept.c
systemv/cancel.c
systemv/cupsaddsmb.c
systemv/lpadmin.c
systemv/lpmove.c
systemv/lpstat.c
test/ipptest.c
tools/testosx

index 4c6ccb6764dfef0655b4200c250725e25b13496a..4bc2e371d0f432541bfd7b3e616b4baf6381d9a4 100644 (file)
@@ -1,5 +1,5 @@
 #
-# "$Id: Makedefs.in 5008 2006-01-27 19:30:34Z mike $"
+# "$Id: Makedefs.in 5020 2006-01-28 13:36:15Z mike $"
 #
 #   Common makefile definitions for the Common UNIX Printing System (CUPS).
 #
@@ -118,6 +118,7 @@ OPTIONS             =
 PAMLIBS                =       @PAMLIBS@
 SSLFLAGS       =       @SSLFLAGS@
 SSLLIBS                =       @SSLLIBS@
+LAUNCHDLIBS    =       @LAUNCHDLIBS@
 
 #
 # Directories...
@@ -177,6 +178,8 @@ MAN8DIR             =       @MAN8DIR@
 PAMDIR         =       $(BUILDROOT)@PAMDIR@
 PAMFILE                =       @PAMFILE@
 
+DEFAULT_LAUNCHD_CONF   =       @DEFAULT_LAUNCHD_CONF@
+
 
 #
 # Rules...
@@ -205,5 +208,5 @@ PAMFILE             =       @PAMFILE@
 
 
 #
-# End of "$Id: Makedefs.in 5008 2006-01-27 19:30:34Z mike $"
+# End of "$Id: Makedefs.in 5020 2006-01-28 13:36:15Z mike $"
 #
index 9cfaec9bbabf432161e83c5b14c2cec06bcf49a4..99a042d5b98e71a37b0658a3b4af20879049b4a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile 5003 2006-01-27 02:33:36Z mike $"
+# "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $"
 #
 #   Top-level Makefile for the Common UNIX Printing System (CUPS).
 #
@@ -29,7 +29,7 @@ include Makedefs
 #
 
 DIRS   =       cups backend berkeley cgi-bin filter locale man pdftops \
-               notifier scheduler systemv
+               notifier scheduler systemv test
 
 #
 # Make all targets...
@@ -107,6 +107,12 @@ install:   installhdrs
                        $(INSTALL_DATA) init/cups.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
                        $(INSTALL_DIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
                        $(INSTALL_DATA) init/cups.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
+               elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \
+                       $(INSTALL_DATA) init/cupsd-launchd.plist $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \
+                       $(INSTALL_SCRIPT) init/cupsd-launchd.sh $(BUILDROOT)/System/Library/StartupItems/PrintingServices/PrintingServices; \
+                       $(INSTALL_DATA) init/cups.plist $(BUILDROOT)/System/Library/StartupItems/PrintingServices/StartupParameters.plist; \
+                       $(INSTALL_DIR) $(BUILDROOT)/System/Library/StartupItems/PrintingServices/Resources/English.lproj; \
+                       $(INSTALL_DATA) init/cups.strings $(BUILDROOT)/System/Library/StartupItems/PrintingServices/Resources/English.lproj/Localizable.strings; \
                else \
                        $(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
                fi \
@@ -165,5 +171,5 @@ tardist:
        epm $(EPMFLAGS) -f tardist cups packaging/cups.list
 
 #
-# End of "$Id: Makefile 5003 2006-01-27 02:33:36Z mike $".
+# End of "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $".
 #
index 468f69dd2f39161b05e960ca2c075f5225d43597..9db806cb6882d9b56bf8619c4b3a8ee222e2f5e7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c 4926 2006-01-13 03:12:13Z mike $"
+ * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   IPP backend for the Common UNIX Printing System (CUPS).
  *
@@ -209,20 +209,13 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Extract the hostname and printer name from the URI...
   */
 
-  if (getenv("DEVICE_URI") != NULL)
-    /* authentication information is only available in the env var */
-    httpSeparateURI(getenv("DEVICE_URI"), method, sizeof(method),
-                    username, sizeof(username),
-                    hostname, sizeof(hostname), &port,
-                   resource, sizeof(resource));
-  else if (strchr(argv[0], ':') != NULL)
-    httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                    hostname, sizeof(hostname), &port,
-                   resource, sizeof(resource));
-  else
+  if (httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+                      method, sizeof(method), username, sizeof(username),
+                     hostname, sizeof(hostname), &port,
+                     resource, sizeof(resource)) < HTTP_URI_OK)
   {
-    fputs("ERROR: Missing device URI on command-line and no DEVICE_URI environment variable!\n",
-          stderr);
+    fputs("ERROR: Missing device URI on command-line and no DEVICE_URI "
+          "environment variable!\n", stderr);
     return (CUPS_BACKEND_STOP);
   }
 
@@ -1375,5 +1368,5 @@ sigterm_handler(int sig)          /* I - Signal */
 
 
 /*
- * End of "$Id: ipp.c 4926 2006-01-13 03:12:13Z mike $".
+ * End of "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 9407fe6cf5a5b22c45b88e4dde7c50253dbfa329..30dea23725215992d21dddfd3d91f03d0af696a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpd.c 4991 2006-01-26 15:01:46Z mike $"
+ * "$Id: lpd.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
  *
@@ -231,8 +231,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   * Extract the hostname and printer name from the URI...
   */
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
+  httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+                  method, sizeof(method), username, sizeof(username),
+                 hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
   if (!username[0])
@@ -1223,5 +1224,5 @@ sigterm_handler(int sig)          /* I - Signal */
 
 
 /*
- * End of "$Id: lpd.c 4991 2006-01-26 15:01:46Z mike $".
+ * End of "$Id: lpd.c 5023 2006-01-29 14:39:44Z mike $".
  */
index d80f8e21460edd9e308d52d1d46bcd04cd5fefd3..d1a85a0bb43c885225996e2a94db150a27717499 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: parallel.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: parallel.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Parallel port backend for the Common UNIX Printing System (CUPS).
  *
@@ -174,8 +174,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   * Extract the device name and options from the URI...
   */
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
+  httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+                  method, sizeof(method), username, sizeof(username),
+                 hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
  /*
@@ -727,5 +728,5 @@ list_devices(void)
 
 
 /*
- * End of "$Id: parallel.c 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: parallel.c 5023 2006-01-29 14:39:44Z mike $".
  */
index fdbc7f2f3738e3a628dc426727e01686edca2ada..06a088899f0520f3a2983f7e7ccd1f23fe042284 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: scsi.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: scsi.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   SCSI printer backend for the Common UNIX Printing System (CUPS).
  *
@@ -183,8 +183,9 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
   * Extract the device name and options from the URI...
   */
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
+  httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+                  method, sizeof(method), username, sizeof(username),
+                 hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
  /*
@@ -219,5 +220,5 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
 
 
 /*
- * End of "$Id: scsi.c 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: scsi.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 3079eef5e41139333f90a547a4aa356a9d8fa044..32aa2f4b8d724604423fe68e6034c4852ecee66e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: serial.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: serial.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Serial port backend for the Common UNIX Printing System (CUPS).
  *
@@ -196,8 +196,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   * Extract the device name and options from the URI...
   */
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
+  httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+                  method, sizeof(method), username, sizeof(username),
+                 hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
  /*
@@ -1110,5 +1111,5 @@ list_devices(void)
 
 
 /*
- * End of "$Id: serial.c 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: serial.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 240adca1ffd57ce345328cfec0b95c47d0b15b06..713b21337c58ea2bd21293408284171dea398ae0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: socket.c 4974 2006-01-25 07:04:33Z mike $"
+ * "$Id: socket.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   AppSocket backend for the Common UNIX Printing System (CUPS).
  *
@@ -164,8 +164,9 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
   * Extract the hostname and port number from the URI...
   */
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
+  httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+                  method, sizeof(method), username, sizeof(username),
+                 hostname, sizeof(hostname), &port,
                  resource, sizeof(resource));
 
   if (port == 0)
@@ -487,5 +488,5 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
 
 /*
- * End of "$Id: socket.c 4974 2006-01-25 07:04:33Z mike $".
+ * End of "$Id: socket.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 3ffe2d0d131cf280631a77d0cd6323a9f7e9101b..92fae2eddaed36a746e02127ec3f55befa50e2ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: usb.c 4906 2006-01-10 20:53:28Z mike $"
+ * "$Id: usb.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   USB port backend for the Common UNIX Printing System (CUPS).
  *
@@ -196,21 +196,17 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
   * Extract the device name and options from the URI...
   */
 
-  if (strncmp(argv[0], "usb:", 4))
-    uri = getenv("DEVICE_URI");
-  else
-    uri = argv[0];
+  uri = cupsBackendDeviceURI(argv);
 
-  if (!uri)
+  if (httpSeparateURI(HTTP_URI_CODING_ALL, uri,
+                      method, sizeof(method), username, sizeof(username),
+                     hostname, sizeof(hostname), &port,
+                     resource, sizeof(resource)) < HTTP_URI_OK)
   {
     fputs("ERROR: No device URI found in argv[0] or in DEVICE_URI environment variable!\n", stderr);
     return (1);
   }
 
-  httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username),
-                  hostname, sizeof(hostname), &port,
-                 resource, sizeof(resource));
-
  /*
   * See if there are any options...
   */
@@ -269,5 +265,5 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
 
 
 /*
- * End of "$Id: usb.c 4906 2006-01-10 20:53:28Z mike $".
+ * End of "$Id: usb.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 5edbeafb7ec28da9c86772f73eba3d536eb06466..271d6047766e1c7e4b06ffb9ae402917cef45a68 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpc.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: lpc.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "lpc" command for the Common UNIX Printing System (CUPS).
  *
@@ -444,8 +444,9 @@ show_status(http_t     *http,               /* I - HTTP connection to server */
                      "attributes-natural-language", NULL,
                     language->language);
 
-        httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
-                        "localhost", 631, "/printers/%s", printer);
+        httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+                        "ipp", NULL, "localhost", 631, "/printers/%s",
+                        printer);
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                     "printer-uri", NULL, printer_uri);
 
@@ -517,5 +518,5 @@ show_status(http_t     *http,               /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: lpc.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: lpc.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 6fd1dfc91ede849029b923472d82250b5a11e75f..d1d06db1d2fae52ca9672f45245a740574d91172 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpq.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: lpq.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "lpq" command for the Common UNIX Printing System (CUPS).
  *
@@ -368,8 +368,8 @@ show_jobs(const char *command,              /* I - Command name */
   }
   else
   {
-    httpAssembleURIf(resource, sizeof(resource), "ipp", NULL, "localhost", 0,
-                    "/printers/%s", dest);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, resource, sizeof(resource), "ipp",
+                     NULL, "localhost", 0, "/printers/%s", dest);
 
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                  NULL, resource);
@@ -592,8 +592,8 @@ show_printer(const char *command,   /* I - Command name */
 
   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                  "/printers/%s", dest);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", dest);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -651,5 +651,5 @@ usage(void)
 
 
 /*
- * End of "$Id: lpq.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: lpq.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 8497ff532b0a06cd08ec8adeeaa34cb2542b6c65..67479b5a3a4a4ca30d2a45427138c58086f6c135 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lprm.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: lprm.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "lprm" command for the Common UNIX Printing System (CUPS).
  *
@@ -223,8 +223,8 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
       if (dest)
       {
-        httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                        "/printers/%s", dest);
+        httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                        "localhost", 0, "/printers/%s", dest);
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                     "printer-uri", NULL, uri);
        ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
@@ -283,5 +283,5 @@ main(int  argc,                     /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: lprm.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: lprm.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 01252ba5cf65b356d87b803da37bb9fdbd9c7a28..55ab8fd4db03c58e09dafd736de119222a91c16e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: admin.c 4943 2006-01-18 20:30:42Z mike $"
+ * "$Id: admin.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Administration CGI for the Common UNIX Printing System (CUPS).
  *
@@ -87,6 +87,15 @@ main(int  argc,                              /* I - Number of command-line arguments */
 
   http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
 
+  if (!http)
+  {
+    perror("ERROR: Unable to connect to cupsd");
+    fprintf(stderr, "DEBUG: cupsServer()=\"%s\"\n", cupsServer());
+    fprintf(stderr, "DEBUG: ippPort()=%d\n", ippPort());
+    fprintf(stderr, "DEBUG: cupsEncryption()=%d\n", cupsEncryption());
+    exit(1);
+  }
+
  /*
   * Set the web interface section...
   */
@@ -303,8 +312,8 @@ do_am_class(http_t *http,           /* I - HTTP connection */
 
       request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-      httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                       "/classes/%s", name);
+      httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                       "localhost", 0, "/classes/%s", name);
       ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                    NULL, uri);
 
@@ -408,8 +417,9 @@ do_am_class(http_t *http,           /* I - HTTP connection */
 
   request = ippNewRequest(CUPS_ADD_CLASS);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/classes/%s", cgiGetVariable("PRINTER_NAME"));
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/classes/%s",
+                  cgiGetVariable("PRINTER_NAME"));
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                NULL, uri);
 
@@ -526,8 +536,9 @@ do_am_printer(http_t *http,         /* I - HTTP connection */
 
     request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", cgiGetVariable("PRINTER_NAME"));
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s",
+                    cgiGetVariable("PRINTER_NAME"));
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                  NULL, uri);
 
@@ -611,6 +622,8 @@ do_am_printer(http_t *http,         /* I - HTTP connection */
     *    printer-uri
     */
 
+    fputs("DEBUG: Getting list of devices...\n", stderr);
+
     request = ippNewRequest(CUPS_GET_DEVICES);
 
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
@@ -620,11 +633,19 @@ do_am_printer(http_t *http,               /* I - HTTP connection */
     * Do the request and get back a response...
     */
 
+    fprintf(stderr, "DEBUG: http=%p (%s)\n", http, http->hostname);
+
     if ((response = cupsDoRequest(http, request, "/")) != NULL)
     {
+      fputs("DEBUG: Got device list!\n", stderr);
+
       cgiSetIPPVars(response, NULL, NULL, NULL, 0);
       ippDelete(response);
     }
+    else
+      fprintf(stderr,
+              "ERROR: CUPS-Get-Devices request failed with status %x: %s\n",
+             cupsLastError(), cupsLastErrorString());
 
    /*
     * Let the user choose...
@@ -705,6 +726,7 @@ do_am_printer(http_t *http,         /* I - HTTP connection */
       http_status_t    get_status;     /* Status of GET */
 
 
+      /* TODO: Use cupsGetFile() API... */
       snprintf(uri, sizeof(uri), "/printers/%s.ppd", name);
 
       if (httpGet(http, uri))
@@ -719,7 +741,7 @@ do_am_printer(http_t *http,         /* I - HTTP connection */
       }
       else if ((fd = cupsTempFd(filename, sizeof(filename))) >= 0)
       {
-       while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
+       while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
           write(fd, buffer, bytes);
 
        close(fd);
@@ -921,8 +943,9 @@ do_am_printer(http_t *http,         /* I - HTTP connection */
 
     request = ippNewRequest(CUPS_ADD_PRINTER);
 
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", cgiGetVariable("PRINTER_NAME"));
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s",
+                    cgiGetVariable("PRINTER_NAME"));
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                  NULL, uri);
 
@@ -1055,8 +1078,8 @@ do_config_printer(http_t *http)           /* I - HTTP connection */
   */
 
   if ((printer = cgiGetVariable("PRINTER_NAME")) != NULL)
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", printer);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s", printer);
   else
   {
     cgiSetVariable("ERROR", cgiText(_("Missing form variable!")));
@@ -1220,8 +1243,8 @@ do_config_printer(http_t *http)           /* I - HTTP connection */
 
     request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", printer);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s", printer);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                  NULL, uri);
 
@@ -1460,8 +1483,9 @@ do_config_printer(http_t *http)           /* I - HTTP connection */
 
     request = ippNewRequest(CUPS_ADD_PRINTER);
 
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", cgiGetVariable("PRINTER_NAME"));
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s",
+                    cgiGetVariable("PRINTER_NAME"));
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                  NULL, uri);
 
@@ -2323,8 +2347,8 @@ do_delete_class(http_t *http)             /* I - HTTP connection */
   }
 
   if ((pclass = cgiGetVariable("PRINTER_NAME")) != NULL)
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/classes/%s", pclass);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/classes/%s", pclass);
   else
   {
     cgiSetVariable("ERROR", cgiText(_("Missing form variable!")));
@@ -2384,8 +2408,8 @@ do_delete_printer(http_t *http)           /* I - HTTP connection */
   }
 
   if ((printer = cgiGetVariable("PRINTER_NAME")) != NULL)
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", printer);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s", printer);
   else
   {
     cgiSetVariable("ERROR", cgiText(_("Missing form variable!")));
@@ -3127,8 +3151,9 @@ do_printer_op(http_t      *http,  /* I - HTTP connection */
 
   request = ippNewRequest(op);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   is_class ? "/classes/%s" : "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
+                  printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                NULL, uri);
 
@@ -3236,8 +3261,9 @@ do_set_allowed_users(http_t *http)        /* I - HTTP connection */
 
     request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     is_class ? "/classes/%s" : "/printers/%s", printer);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
+                    printer);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                 NULL, uri);
 
@@ -3322,8 +3348,9 @@ do_set_allowed_users(http_t *http)        /* I - HTTP connection */
 
     request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER);
 
-    httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                     is_class ? "/classes/%s" : "/printers/%s", printer);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
+                    printer);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                 NULL, uri);
 
@@ -3465,8 +3492,9 @@ do_set_sharing(http_t *http)              /* I - HTTP connection */
 
   request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   is_class ? "/classes/%s" : "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
+                  printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                NULL, uri);
 
@@ -3562,5 +3590,5 @@ match_string(const char *a,               /* I - First string */
 
     
 /*
- * End of "$Id: admin.c 4943 2006-01-18 20:30:42Z mike $".
+ * End of "$Id: admin.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 355928af679abd3ece48516d68a8d3792914b3b9..fbea241992d95b4795a90654dc396eea72d7f955 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: classes.c 4931 2006-01-14 20:37:40Z mike $"
+ * "$Id: classes.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Class status CGI for the Common UNIX Printing System (CUPS).
  *
@@ -385,8 +385,8 @@ show_class(http_t     *http,                /* I - Connection to server */
 
   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/classes/%s", pclass);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/classes/%s", pclass);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
                uri);
 
@@ -459,5 +459,5 @@ show_class(http_t     *http,                /* I - Connection to server */
 
 
 /*
- * End of "$Id: classes.c 4931 2006-01-14 20:37:40Z mike $".
+ * End of "$Id: classes.c 5023 2006-01-29 14:39:44Z mike $".
  */
index bc20e75d2b218ea0baddf00573b499dd332ef4cd..6a59d5c8b757cb35e67399168317899d211594da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp-var.c 4931 2006-01-14 20:37:40Z mike $"
+ * "$Id: ipp-var.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   CGI <-> IPP variable routines for the Common UNIX Printing System (CUPS).
  *
@@ -457,8 +457,9 @@ cgiMoveJobs(http_t     *http,               /* I - Connection to server */
       snprintf(resource, sizeof(resource), "/%s/%s",
                cgiGetVariable("SECTION"), dest);
 
-      httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", ippPort(),
-                       "/%s/%s", cgiGetVariable("SECTION"), dest);
+      httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                       "localhost", ippPort(), "/%s/%s",
+                      cgiGetVariable("SECTION"), dest);
       ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                    NULL, uri);
     }
@@ -549,8 +550,9 @@ cgiPrintTestPage(http_t     *http,  /* I - Connection to server */
   snprintf(resource, sizeof(resource), "/%s/%s", cgiGetVariable("SECTION"),
            dest);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", ippPort(),
-                   "/%s/%s", cgiGetVariable("SECTION"), dest);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", ippPort(), "/%s/%s", cgiGetVariable("SECTION"),
+                  dest);
 
  /*
   * Build an IPP_PRINT_JOB request, which requires the following
@@ -672,8 +674,8 @@ cgiRewriteURL(const char *uri,              /* I - Current URI */
   * Convert the URI to a URL...
   */
 
-  httpSeparateURI(uri, method, sizeof(method), userpass, sizeof(userpass),
-                  hostname, sizeof(hostname), &port,
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,
+                  sizeof(userpass), hostname, sizeof(hostname), &port,
                  rawresource, sizeof(rawresource));
 
   if (!strcmp(method, "ipp") ||
@@ -1090,8 +1092,8 @@ cgiShowJobs(http_t     *http,             /* I - Connection to server */
 
   if (dest)
   {
-    httpAssembleURIf(url, sizeof(url), "ipp", NULL, "localhost", ippPort(),
-                     "/printers/%s", dest);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, url, sizeof(url), "ipp", NULL,
+                     "localhost", ippPort(), "/printers/%s", dest);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                  NULL, url);
   }
@@ -1270,5 +1272,5 @@ cgiText(const char *message)              /* I - Message */
 
 
 /*
- * End of "$Id: ipp-var.c 4931 2006-01-14 20:37:40Z mike $".
+ * End of "$Id: ipp-var.c 5023 2006-01-29 14:39:44Z mike $".
  */
index ddc027f51bb878e0e97d4e4ebe23d29ea490a9dd..fc0b65a9ec02fd801d4450d98e675101c6798509 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.c 4931 2006-01-14 20:37:40Z mike $"
+ * "$Id: printers.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Printer status CGI for the Common UNIX Printing System (CUPS).
  *
@@ -392,8 +392,8 @@ show_printer(http_t     *http,              /* I - Connection to server */
 
   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
                uri);
 
@@ -466,5 +466,5 @@ show_printer(http_t     *http,              /* I - Connection to server */
 
 
 /*
- * End of "$Id: printers.c 4931 2006-01-14 20:37:40Z mike $".
+ * End of "$Id: printers.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 26bfae8c712586b4e9f396d50db5b9e0c8413b96..6edee7473ccd9da675899496849d0bf0a38dc422 100644 (file)
@@ -25,17 +25,21 @@ dnl
 
 dnl Default ConfigFilePerm
 AC_ARG_WITH(config_perm, [  --with-config-file-perm set default ConfigFilePerm value, default=0640],
-            CUPS_CONFIG_FILE_PERM="$withval",
-           CUPS_CONFIG_FILE_PERM="0640")
+       CUPS_CONFIG_FILE_PERM="$withval",
+       if test "x$uname" = xDarwin; then
+               CUPS_CONFIG_FILE_PERM="644"
+       else
+               CUPS_CONFIG_FILE_PERM="640"
+       fi)
 AC_SUBST(CUPS_CONFIG_FILE_PERM)
-AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, $CUPS_CONFIG_FILE_PERM)
+AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, 0$CUPS_CONFIG_FILE_PERM)
 
 dnl Default LogFilePerm
 AC_ARG_WITH(log_perm, [  --with-log-file-perm    set default LogFilePerm value, default=0644],
-            CUPS_LOG_FILE_PERM="$withval",
-           CUPS_LOG_FILE_PERM="0644")
+       CUPS_LOG_FILE_PERM="$withval",
+       CUPS_LOG_FILE_PERM="644")
 AC_SUBST(CUPS_LOG_FILE_PERM)
-AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, $CUPS_LOG_FILE_PERM)
+AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, 0$CUPS_LOG_FILE_PERM)
 
 dnl Default Browsing
 AC_ARG_ENABLE(browsing, [  --enable-browsing       enable Browsing by default, default=yes])
@@ -50,19 +54,19 @@ AC_SUBST(CUPS_BROWSING)
 
 dnl Default BrowseLocalProtocols
 AC_ARG_WITH(browse_local, [  --with-local-protocols  set default BrowseLocalProtocols, default="CUPS"],
-            CUPS_BROWSE_LOCAL_PROTOCOLS="$withval",
-           CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS")
+       CUPS_BROWSE_LOCAL_PROTOCOLS="$withval",
+       CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS")
 AC_SUBST(CUPS_BROWSE_LOCAL_PROTOCOLS)
 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS,
-                   "$CUPS_BROWSE_LOCAL_PROTOCOLS")
+       "$CUPS_BROWSE_LOCAL_PROTOCOLS")
 
 dnl Default BrowseRemoteProtocols
 AC_ARG_WITH(browse_remote, [  --with-remote-protocols set default BrowseRemoteProtocols, default="CUPS"],
-            CUPS_BROWSE_REMOTE_PROTOCOLS="$withval",
-           CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS")
+       CUPS_BROWSE_REMOTE_PROTOCOLS="$withval",
+       CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS")
 AC_SUBST(CUPS_BROWSE_REMOTE_PROTOCOLS)
 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS,
-                   "$CUPS_BROWSE_REMOTE_PROTOCOLS")
+       "$CUPS_BROWSE_REMOTE_PROTOCOLS")
 
 dnl Default BrowseShortNames
 AC_ARG_ENABLE(browse_short, [  --enable-browse-short-names
index 836ec6742ff9f300a260a0cc5f4f963c8f986bb1..7418740254512202f7ef5b1be6bcb1bbf29b9a52 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl "$Id: cups-directories.m4 4933 2006-01-16 00:26:57Z mike $"
+dnl "$Id: cups-directories.m4 5023 2006-01-29 14:39:44Z mike $"
 dnl
 dnl   Directory stuff for the Common UNIX Printing System (CUPS).
 dnl
@@ -126,7 +126,9 @@ if test x$rcdir = x; then
                Darwin*)
                        # Darwin and MacOS X...
                        INITDIR=""
-                       INITDDIR="/System/Library/StartupItems/PrintingServices"
+                       AC_CHECK_PROG(INITDDIR, launchd, 
+                               "/System/Library/LaunchDaemons", 
+                               "/System/Library/StartupItems/PrintingServices")
                        ;;
 
                Linux | GNU)
@@ -177,7 +179,11 @@ dnl Setup default locations...
 AC_ARG_WITH(cachedir, [  --with-cachedir         set path for cache files],cachedir="$withval",cachedir="")
 
 if test x$cachedir = x; then
-       CUPS_CACHEDIR="$localstatedir/cache/cups"
+       if test "x$uname" = xDarwin; then
+               CUPS_CACHEDIR="$localstatedir/tmp/cups"
+       else
+               CUPS_CACHEDIR="$localstatedir/cache/cups"
+       fi
 else
        CUPS_CACHEDIR="$cachedir"
 fi
@@ -279,5 +285,5 @@ AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$localstatedir/run/cups")
 AC_SUBST(CUPS_STATEDIR)
 
 dnl
-dnl End of "$Id: cups-directories.m4 4933 2006-01-16 00:26:57Z mike $".
+dnl End of "$Id: cups-directories.m4 5023 2006-01-29 14:39:44Z mike $".
 dnl
diff --git a/config-scripts/cups-launchd.m4 b/config-scripts/cups-launchd.m4
new file mode 100644 (file)
index 0000000..8e075e9
--- /dev/null
@@ -0,0 +1,53 @@
+dnl
+dnl "$Id$"
+dnl
+dnl   launchd stuff for the Common UNIX Printing System (CUPS).
+dnl
+dnl   Copyright 1997-2005 by Easy Software Products, all rights reserved.
+dnl
+dnl   These coded instructions, statements, and computer programs are the
+dnl   property of Easy Software Products and are protected by Federal
+dnl   copyright law.  Distribution and use rights are outlined in the file
+dnl   "LICENSE.txt" which should have been included with this file.  If this
+dnl   file is missing or damaged please contact Easy Software Products
+dnl   at:
+dnl
+dnl       Attn: CUPS Licensing Information
+dnl       Easy Software Products
+dnl       44141 Airport View Drive, Suite 204
+dnl       Hollywood, Maryland 20636 USA
+dnl
+dnl       Voice: (301) 373-9600
+dnl       EMail: cups-info@cups.org
+dnl         WWW: http://www.cups.org
+dnl
+
+
+AC_ARG_ENABLE(launchd, [  --enable-launchd            turn on launchd support, default=yes])
+
+DEFAULT_LAUNCHD_CONF=""
+LAUNCHDLIBS=""
+
+if test x$enable_launchd != xno; then
+       AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD))
+       AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
+
+       case "$uname" in
+               Darwin*)
+                       # Darwin, MacOS X
+                       DEFAULT_LAUNCHD_CONF="/System/Library/LaunchDaemons/org.cups.cupsd.plist"
+                       # liblaunch is already part of libSystem
+                       ;;
+               *)
+                       # All others; this test will need to be updated
+                       ;;
+       esac
+fi
+
+AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LAUNCHD_CONF, "$DEFAULT_LAUNCHD_CONF")
+AC_SUBST(DEFAULT_LAUNCHD_CONF)
+AC_SUBST(LAUNCHDLIBS)
+
+dnl
+dnl End of "$Id$".
+dnl
index a6f0f49047048ef389056b09b10d58c2c68f0b55..ee1e4bc3468327e1060fc95d1e3be58b310f8f43 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: config.h.in 5008 2006-01-27 19:30:34Z mike $"
+ * "$Id: config.h.in 5020 2006-01-28 13:36:15Z mike $"
  *
  *   Configuration file for the Common UNIX Printing System (CUPS).
  *
 #undef HAVE_PTHREAD_H
 
 
+/*
+ * Do we have launchd support?
+ */
+
+#undef HAVE_LAUNCH_H
+#undef HAVE_LAUNCHD
+#define CUPS_DEFAULT_LAUNCHD_CONF ""
+
+
 /*
  * Various scripting languages...
  */
 #endif /* !_CUPS_CONFIG_H_ */
 
 /*
- * End of "$Id: config.h.in 5008 2006-01-27 19:30:34Z mike $".
+ * End of "$Id: config.h.in 5020 2006-01-28 13:36:15Z mike $".
  */
index 58dff5694ff0badfcf4b9891037a847ab64bb4f4..811d48b5fe8187b59d33389e51e6d8ed97c4cf5a 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl "$Id: configure.in 5008 2006-01-27 19:30:34Z mike $"
+dnl "$Id: configure.in 5020 2006-01-28 13:36:15Z mike $"
 dnl
 dnl   Configuration script for the Common UNIX Printing System (CUPS).
 dnl
@@ -41,6 +41,7 @@ sinclude(config-scripts/cups-ssl.m4)
 sinclude(config-scripts/cups-pam.m4)
 sinclude(config-scripts/cups-threads.m4)
 sinclude(config-scripts/cups-largefile.m4)
+sinclude(config-scripts/cups-launchd.m4)
 
 MAKEDEFS="../Makedefs"
 AC_SUBST(MAKEDEFS)
@@ -55,5 +56,5 @@ AC_OUTPUT(Makedefs packaging/cups.list init/cups.sh cups-config
 chmod +x cups-config
 
 dnl
-dnl End of "$Id: configure.in 5008 2006-01-27 19:30:34Z mike $".
+dnl End of "$Id: configure.in 5020 2006-01-28 13:36:15Z mike $".
 dnl
index 94ff53a2906e9bfd4078ec3515b1d354e16abb21..e23017bf394d1825f8a362763953bf0916ed0f50 100644 (file)
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $"
+# "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $"
 #
 #   API library Makefile for the Common UNIX Printing System (CUPS).
 #
@@ -35,6 +35,7 @@ LIBOBJS       =       \
                attr.o \
                auth.o \
                backchannel.o \
+               backend.o \
                custom.o \
                dest.o \
                dir.o \
@@ -356,5 +357,5 @@ include Dependencies
 
 
 #
-# End of "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $".
+# End of "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $".
 #
diff --git a/cups/backend.c b/cups/backend.c
new file mode 100644 (file)
index 0000000..68d234d
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * "$Id: backend.c 5024 2006-01-29 14:58:15Z mike $"
+ *
+ *   Backend functions for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 2006 by Easy Software Products.
+ *
+ *   These coded instructions, statements, and computer programs are the
+ *   property of Easy Software Products and are protected by Federal
+ *   copyright law.  Distribution and use rights are outlined in the file
+ *   "LICENSE.txt" which should have been included with this file.  If this
+ *   file is missing or damaged please contact Easy Software Products
+ *   at:
+ *
+ *       Attn: CUPS Licensing Information
+ *       Easy Software Products
+ *       44141 Airport View Drive, Suite 204
+ *       Hollywood, Maryland 20636 USA
+ *
+ *       Voice: (301) 373-9600
+ *       EMail: cups-info@cups.org
+ *         WWW: http://www.cups.org
+ *
+ *   This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ *   cupsBackendDeviceURI() - Get the device URI for a backend.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include <stdlib.h>
+#include "backend.h"
+#include "string.h"
+
+
+/*
+ * 'cupsBackendDeviceURI()' - Get the device URI for a backend.
+ *
+ * The "argv" argument is the argv argument passed to main(). This
+ * function returns the device URI passed in the DEVICE_URI environment
+ * variable or the device URI passed in argv[0], whichever is found
+ * first.
+ */
+
+const char *                           /* O - Device URI or NULL */
+cupsBackendDeviceURI(char **argv)      /* I - Command-line arguments */
+{
+  const char   *device_uri;            /* Device URI */
+
+
+  if ((device_uri = getenv("DEVICE_URI")) != NULL)
+    return (device_uri);
+
+  if (!argv || !argv[0] || !strchr(argv[0], ':'))
+    return (NULL);
+  else
+    return (argv[0]);
+}
+
+
+/*
+ * End of "$Id: backend.c 5024 2006-01-29 14:58:15Z mike $".
+ */
index a816b2f07d41a1760adb4536f56787a326c77121..ca107c93fdd434ec64a1878cd9900085feeef368 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: backend.h 4973 2006-01-25 02:36:02Z mike $"
+ * "$Id: backend.h 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Backend definitions for the Common UNIX Printing System (CUPS).
  *
@@ -43,8 +43,15 @@ typedef enum cups_backend_e          /**** Backend exit codes ****/
 } cups_backend_t;
 
 
+/*
+ * Prototypes...
+ */
+
+extern const char      *cupsBackendDeviceURI(char **argv);
+
+
 #endif /* !_CUPS_BACKEND_H_ */
 
 /*
- * End of "$Id: backend.h 4973 2006-01-25 02:36:02Z mike $".
+ * End of "$Id: backend.h 5023 2006-01-29 14:39:44Z mike $".
  */
index 82c9bdf289b4062d65d9656db02ee0fcf2537f72..da1579fa840c94b00508948fc299e710716b290d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: getputfile.c 4984 2006-01-25 21:55:36Z mike $"
+ * "$Id: getputfile.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Get/put file functions for the Common UNIX Printing System (CUPS).
  *
@@ -166,7 +166,7 @@ cupsGetFd(http_t     *http,         /* I - HTTP connection to server */
     * Yes, copy the file...
     */
 
-    while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
+    while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
       write(fd, buffer, bytes);
   }
   else
@@ -322,11 +322,11 @@ cupsPutFd(http_t     *http,               /* I - HTTP connection to server */
           break;
       }
       else
-        httpWrite(http, buffer, bytes);
+        httpWrite2(http, buffer, bytes);
 
     if (status == HTTP_CONTINUE)
     {
-      httpWrite(http, buffer, 0);
+      httpWrite2(http, buffer, 0);
 
       while ((status = httpUpdate(http)) == HTTP_CONTINUE);
     }
@@ -447,5 +447,5 @@ cupsPutFile(http_t     *http,               /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: getputfile.c 4984 2006-01-25 21:55:36Z mike $".
+ * End of "$Id: getputfile.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 0770f138aec6b711533f9658cb9a66c987378226..3103007aadd9a8d1078f6d207a48dbc12e34fd1a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http-support.c 4961 2006-01-20 22:19:13Z mike $"
+ * "$Id: http-support.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   HTTP support routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -93,9 +93,11 @@ static const char * const http_months[12] =
  */
 
 static const char      *http_copy_decode(char *dst, const char *src,
-                                         int dstsize, const char *term);
+                                         int dstsize, const char *term,
+                                         int decode);
 static char            *http_copy_encode(char *dst, const char *src,
-                                         char *dstend, const char *reserved);
+                                         char *dstend, const char *reserved,
+                                         const char *term, int encode);
 
 
 /*
@@ -110,46 +112,18 @@ static char               *http_copy_encode(char *dst, const char *src,
  */
 
 http_uri_status_t                      /* O - URI status */
-httpAssembleURI(char       *uri,       /* I - URI buffer */
-                int        urilen,     /* I - Size of URI buffer */
-               const char *scheme,     /* I - Scheme name */
-               const char *username,   /* I - Username */
-               const char *host,       /* I - Hostname or address */
-               int        port,        /* I - Port number */
-               const char *resource)   /* I - Resource */
-{
-  return (httpAssembleURIf(uri, urilen, scheme, username, host, port, "%s",
-                           resource));
-}
-
-
-/*
- * 'httpAssembleURIf()' - Assemble a uniform resource identifier from its
- *                        components with a formatted resource.
- *
- * This function creates a formatted version of the resource string
- * argument "resourcef" and properly escapes all reserved characters
- * in a URI.  You should use this function in place of traditional
- * string functions whenever you need to create a URI string.
- *
- * @since CUPS 1.2@
- */
-
-http_uri_status_t                      /* O - URI status */
-httpAssembleURIf(char       *uri,      /* I - URI buffer */
-                 int        urilen,    /* I - Size of URI buffer */
-                const char *scheme,    /* I - Scheme name */
-                const char *username,  /* I - Username */
-                const char *host,      /* I - Hostname or address */
-                int        port,       /* I - Port number */
-                const char *resourcef, /* I - Printf-style resource */
-                ...)                   /* I - Additional arguments as needed */
+httpAssembleURI(
+    http_uri_coding_t encoding,                /* I - Encoding flags */
+    char              *uri,            /* I - URI buffer */
+    int               urilen,          /* I - Size of URI buffer */
+    const char        *scheme,         /* I - Scheme name */
+    const char        *username,       /* I - Username */
+    const char        *host,           /* I - Hostname or address */
+    int               port,            /* I - Port number */
+    const char        *resource)       /* I - Resource */
 {
   char         *ptr,                   /* Pointer into URI buffer */
                *end;                   /* End of URI buffer */
-  va_list      ap;                     /* Pointer to additional arguments */
-  char         resource[1024];         /* Formatted resource string */
-  int          bytes;                  /* Bytes in formatted string */
 
 
  /*
@@ -169,7 +143,7 @@ httpAssembleURIf(char       *uri,   /* I - URI buffer */
   */
 
   end = uri + urilen - 1;
-  ptr = http_copy_encode(uri, scheme, end, NULL);
+  ptr = http_copy_encode(uri, scheme, end, NULL, NULL, 0);
 
   if (!ptr)
     goto assemble_overflow;
@@ -213,7 +187,8 @@ httpAssembleURIf(char       *uri,   /* I - URI buffer */
       * Add username@ first...
       */
 
-      ptr = http_copy_encode(ptr, username, end, "/?@");
+      ptr = http_copy_encode(ptr, username, end, "/?@", NULL,
+                             encoding & HTTP_URI_CODING_USERNAME);
 
       if (!ptr)
         goto assemble_overflow;
@@ -294,7 +269,8 @@ httpAssembleURIf(char       *uri,   /* I - URI buffer */
       * Otherwise, just copy the host string...
       */
 
-      ptr = http_copy_encode(ptr, host, end, NULL);
+      ptr = http_copy_encode(ptr, host, end, NULL, NULL,
+                             encoding & HTTP_URI_CODING_HOSTNAME);
 
       if (!ptr)
         goto assemble_overflow;
@@ -318,26 +294,18 @@ httpAssembleURIf(char       *uri, /* I - URI buffer */
   * Last but not least, add the resource string...
   */
 
-  if (resourcef)
+  if (resource)
   {
     char       *query;                 /* Pointer to query string */
 
 
-    va_start(ap, resourcef);
-    bytes = vsnprintf(resource, sizeof(resource), resourcef, ap);
-    va_end(ap);
-
-    if (bytes >= sizeof(resource))
-      goto assemble_overflow;
-
    /*
-    * Temporarily remove query string if present...
+    * Copy the resource string up to the query string if present...
     */
 
-    if ((query = strchr(resource, '?')) != NULL)
-      *query = '\0';
-
-    ptr = http_copy_encode(ptr, resource, end, NULL);
+    query = strchr(resource, '?');
+    ptr   = http_copy_encode(ptr, resource, end, NULL, "?",
+                             encoding & HTTP_URI_CODING_RESOURCE);
     if (!ptr)
       goto assemble_overflow;
 
@@ -347,9 +315,10 @@ httpAssembleURIf(char       *uri,  /* I - URI buffer */
       * Copy query string without encoding...
       */
 
-      *query = '?';
-      strlcpy(ptr, query, end - ptr);
-      ptr += strlen(ptr);
+      ptr = http_copy_encode(ptr, query, end, NULL, NULL,
+                            encoding & HTTP_URI_CODING_QUERY);
+      if (!ptr)
+       goto assemble_overflow;
     }
   }
   else if (ptr < end)
@@ -377,6 +346,66 @@ httpAssembleURIf(char       *uri,  /* I - URI buffer */
 }
 
 
+/*
+ * 'httpAssembleURIf()' - Assemble a uniform resource identifier from its
+ *                        components with a formatted resource.
+ *
+ * This function creates a formatted version of the resource string
+ * argument "resourcef" and properly escapes all reserved characters
+ * in a URI.  You should use this function in place of traditional
+ * string functions whenever you need to create a URI string.
+ *
+ * @since CUPS 1.2@
+ */
+
+http_uri_status_t                      /* O - URI status */
+httpAssembleURIf(
+    http_uri_coding_t encoding,                /* I - Encoding flags */
+    char              *uri,            /* I - URI buffer */
+    int               urilen,          /* I - Size of URI buffer */
+    const char        *scheme,         /* I - Scheme name */
+    const char        *username,       /* I - Username */
+    const char        *host,           /* I - Hostname or address */
+    int               port,            /* I - Port number */
+    const char        *resourcef,      /* I - Printf-style resource */
+    ...)                               /* I - Additional arguments as needed */
+{
+  va_list      ap;                     /* Pointer to additional arguments */
+  char         resource[1024];         /* Formatted resource string */
+  int          bytes;                  /* Bytes in formatted string */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!uri || urilen < 1 || !scheme || port < 0 || !resourcef)
+  {
+    if (uri)
+      *uri = '\0';
+
+    return (HTTP_URI_BAD_ARGUMENTS);
+  }
+
+ /*
+  * Format the resource string and assemble the URI...
+  */
+
+  va_start(ap, resourcef);
+  bytes = vsnprintf(resource, sizeof(resource), resourcef, ap);
+  va_end(ap);
+
+  if (bytes >= sizeof(resource))
+  {
+    *uri = '\0';
+    return (HTTP_URI_OVERFLOW);
+  }
+  else
+    return (httpAssembleURI(encoding,  uri, urilen, scheme, username, host,
+                            port, resource));
+}
+
+
 /*
  * 'httpDecode64()' - Base64-decode a string.
  */
@@ -714,8 +743,9 @@ httpSeparate(const char *uri,               /* I - Universal Resource Identifier */
             int        *port,          /* O - Port number to use */
              char       *resource)     /* O - Resource/filename [1024] */
 {
-  httpSeparateURI(uri, scheme, 32, username, HTTP_MAX_URI, host, HTTP_MAX_URI,
-                  port, resource, HTTP_MAX_URI);
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, 32, username,
+                  HTTP_MAX_URI, host, HTTP_MAX_URI, port, resource,
+                 HTTP_MAX_URI);
 }
 
 
@@ -738,8 +768,8 @@ httpSeparate2(const char *uri,              /* I - Universal Resource Identifier */
               char       *resource,    /* O - Resource/filename */
              int        resourcelen)   /* I - Size of resource buffer */
 {
-  httpSeparateURI(uri, scheme, schemelen, username, usernamelen, host, hostlen,
-                  port, resource, resourcelen);
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, schemelen, username,
+                  usernamelen, host, hostlen, port, resource, resourcelen);
 }
 
 
@@ -751,16 +781,18 @@ httpSeparate2(const char *uri,            /* I - Universal Resource Identifier */
  */
 
 http_uri_status_t                      /* O - Result of separation */
-httpSeparateURI(const char *uri,       /* I - Universal Resource Identifier */
-                char       *scheme,    /* O - Scheme (http, https, etc.) */
-               int        schemelen,   /* I - Size of scheme buffer */
-               char       *username,   /* O - Username */
-               int        usernamelen, /* I - Size of username buffer */
-               char       *host,       /* O - Hostname */
-               int        hostlen,     /* I - Size of hostname buffer */
-               int        *port,       /* O - Port number to use */
-               char       *resource,   /* O - Resource/filename */
-               int        resourcelen) /* I - Size of resource buffer */
+httpSeparateURI(
+    http_uri_coding_t decoding,                /* I - Decoding flags */
+    const char        *uri,            /* I - Universal Resource Identifier */
+    char              *scheme,         /* O - Scheme (http, https, etc.) */
+    int               schemelen,       /* I - Size of scheme buffer */
+    char              *username,       /* O - Username */
+    int               usernamelen,     /* I - Size of username buffer */
+    char              *host,           /* O - Hostname */
+    int               hostlen,         /* I - Size of hostname buffer */
+    int               *port,           /* O - Port number to use */
+    char              *resource,       /* O - Resource/filename */
+    int               resourcelen)     /* I - Size of resource buffer */
 {
   char                 *ptr,           /* Pointer into string... */
                        *end;           /* End of string */
@@ -886,7 +918,8 @@ httpSeparateURI(const char *uri,    /* I - Universal Resource Identifier */
       * Get a username:password combo...
       */
 
-      uri = http_copy_decode(username, uri, usernamelen, "@");
+      uri = http_copy_decode(username, uri, usernamelen, "@",
+                             decoding & HTTP_URI_CODING_USERNAME);
 
       if (!uri)
       {
@@ -911,7 +944,8 @@ httpSeparateURI(const char *uri,    /* I - Universal Resource Identifier */
       if (!strncmp(uri, "v1.", 3))
         uri += 3;                      /* Skip IPvN leader... */
 
-      uri = http_copy_decode(host, uri, hostlen, "]");
+      uri = http_copy_decode(host, uri, hostlen, "]",
+                             decoding & HTTP_URI_CODING_HOSTNAME);
 
       if (!uri)
       {
@@ -953,7 +987,8 @@ httpSeparateURI(const char *uri,    /* I - Universal Resource Identifier */
       * Grab hostname or IPv4 address...
       */
 
-      uri = http_copy_decode(host, uri, hostlen, ":?/");
+      uri = http_copy_decode(host, uri, hostlen, ":?/",
+                             decoding & HTTP_URI_CODING_HOSTNAME);
 
       if (!uri)
       {
@@ -1022,29 +1057,30 @@ httpSeparateURI(const char *uri,        /* I - Universal Resource Identifier */
     *resource = '/';
 
    /*
-    * Copy any query string without decoding it...
+    * Copy any query string...
     */
 
     if (*uri == '?')
-    {
-      strlcpy(resource + 1, uri, resourcelen - 1);
-      uri += strlen(uri);
-    }
+      uri = http_copy_decode(resource + 1, uri, resourcelen - 1, NULL,
+                             decoding & HTTP_URI_CODING_QUERY);
     else
       resource[1] = '\0';
   }
   else
   {
-    uri = http_copy_decode(resource, uri, resourcelen, "?");
+    uri = http_copy_decode(resource, uri, resourcelen, "?",
+                           decoding & HTTP_URI_CODING_RESOURCE);
 
     if (uri && *uri == '?')
     {
      /*
-      * Concatenate any query string without decoding it...
+      * Concatenate any query string...
       */
 
-      strlcat(resource, uri, resourcelen);
-      uri += strlen(uri);
+      char *resptr = resource + strlen(resource);
+
+      uri = http_copy_decode(resptr, uri, resourcelen - (resptr - resource),
+                             NULL, decoding & HTTP_URI_CODING_QUERY);
     }
   }
 
@@ -1143,7 +1179,8 @@ static const char *                       /* O - New source pointer or NULL on error */
 http_copy_decode(char       *dst,      /* O - Destination buffer */ 
                  const char *src,      /* I - Source pointer */
                 int        dstsize,    /* I - Destination size */
-                const char *term)      /* I - Terminating characters */
+                const char *term,      /* I - Terminating characters */
+                int        decode)     /* I - Decode %-encoded values */
 {
   char *ptr,                           /* Pointer into buffer */
        *end;                           /* End of buffer */
@@ -1158,7 +1195,7 @@ http_copy_decode(char       *dst, /* O - Destination buffer */
   for (ptr = dst, end = dst + dstsize - 1; *src && !strchr(term, *src); src ++)
     if (ptr < end)
     {
-      if (*src == '%')
+      if (*src == '%' && decode)
       {
         if (isxdigit(src[1] & 255) && isxdigit(src[2] & 255))
        {
@@ -1208,15 +1245,20 @@ static char *                           /* O - End of current URI */
 http_copy_encode(char       *dst,      /* O - Destination buffer */ 
                  const char *src,      /* I - Source pointer */
                 char       *dstend,    /* I - End of destination buffer */
-                 const char *reserved) /* I - Extra reserved characters */
+                 const char *reserved, /* I - Extra reserved characters */
+                const char *term,      /* I - Terminating characters */
+                int        encode)     /* I - %-encode reserved chars? */
 {
   static const char *hex = "0123456789ABCDEF";
 
 
   while (*src && dst < dstend)
   {
-    if (*src == '%' || *src <= ' ' || *src & 128 ||
-        (reserved && strchr(reserved, *src)))
+    if (term && *src == *term)
+      return (dst);
+
+    if (encode && (*src == '%' || *src <= ' ' || *src & 128 ||
+                   (reserved && strchr(reserved, *src))))
     {
      /*
       * Hex encode reserved characters...
@@ -1243,5 +1285,5 @@ http_copy_encode(char       *dst, /* O - Destination buffer */
 
 
 /*
- * End of "$Id: http-support.c 4961 2006-01-20 22:19:13Z mike $".
+ * End of "$Id: http-support.c 5023 2006-01-29 14:39:44Z mike $".
  */
index b094a5d4974835a6107730ffda90886e21673b4e..fc6a20d077cbaad68bca2b038b6696f374ad9ce5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.c 4995 2006-01-26 20:14:42Z mike $"
+ * "$Id: http.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   HTTP routines for the Common UNIX Printing System (CUPS).
  *
@@ -50,6 +50,7 @@
  *   httpPrintf()         - Print a formatted string to a HTTP connection.
  *   httpPut()            - Send a PUT request to the server.
  *   httpRead()           - Read data from a HTTP connection.
+ *   httpRead2()          - Read data from a HTTP connection.
  *   _httpReadCDSA()      - Read function for CDSA decryption code.
  *   httpReconnect()      - Reconnect to a HTTP server...
  *   httpSetCookie()      - Set the cookie value(s)...
@@ -59,6 +60,7 @@
  *   httpUpdate()         - Update the current HTTP state for incoming data.
  *   httpWait()           - Wait for data available on a connection.
  *   httpWrite()          - Write data to a HTTP connection.
+ *   httpWrite2()         - Write data to a HTTP connection.
  *   _httpWriteCDSA()     - Write function for CDSA encryption code.
  *   http_field()         - Return the field index for a field name.
  *   http_read_ssl()      - Read from a SSL/TLS connection.
@@ -395,7 +397,7 @@ httpFlush(http_t *http)                     /* I - HTTP data */
   * Read any data we can...
   */
 
-  while (httpRead(http, buffer, sizeof(buffer)) > 0);
+  while (httpRead2(http, buffer, sizeof(buffer)) > 0);
 
  /*
   * Restore blocking and reset the connection if we didn't get all of
@@ -988,6 +990,11 @@ httpPut(http_t     *http,          /* I - HTTP data */
 
 /*
  * 'httpRead()' - Read data from a HTTP connection.
+ *
+ * This function is deprecated. Use the httpRead2() function which can
+ * read more than 2GB of data.
+ *
+ * @deprecated@
  */
 
 int                                    /* O - Number of bytes read */
@@ -995,7 +1002,20 @@ httpRead(http_t *http,                    /* I - HTTP data */
          char   *buffer,               /* I - Buffer for data */
         int    length)                 /* I - Maximum number of bytes */
 {
-  int          bytes;                  /* Bytes read */
+  return ((int)httpRead2(http, buffer, length));
+}
+
+
+/*
+ * 'httpRead2()' - Read data from a HTTP connection.
+ */
+
+ssize_t                                        /* O - Number of bytes read */
+httpRead2(http_t *http,                        /* I - HTTP data */
+          char   *buffer,              /* I - Buffer for data */
+         size_t length)                /* I - Maximum number of bytes */
+{
+  ssize_t      bytes;                  /* Bytes read */
   char         len[32];                /* Length string */
 
 
@@ -1013,23 +1033,23 @@ httpRead(http_t *http,                  /* I - HTTP data */
   if (http->data_encoding == HTTP_ENCODE_CHUNKED &&
       http->data_remaining <= 0)
   {
-    DEBUG_puts("httpRead: Getting chunk length...");
+    DEBUG_puts("httpRead2: Getting chunk length...");
 
     if (httpGets(len, sizeof(len), http) == NULL)
     {
-      DEBUG_puts("httpRead: Could not get length!");
+      DEBUG_puts("httpRead2: Could not get length!");
       return (0);
     }
 
     http->data_remaining = strtoll(len, NULL, 16);
     if (http->data_remaining < 0)
     {
-      DEBUG_puts("httpRead: Negative chunk length!");
+      DEBUG_puts("httpRead2: Negative chunk length!");
       return (0);
     }
   }
 
-  DEBUG_printf(("httpRead: data_remaining=" CUPS_LLFMT "\n",
+  DEBUG_printf(("httpRead2: data_remaining=" CUPS_LLFMT "\n",
                 CUPS_LLCAST http->data_remaining));
 
   if (http->data_remaining <= 0)
@@ -1078,12 +1098,12 @@ httpRead(http_t *http,                  /* I - HTTP data */
     else
 #endif /* HAVE_SSL */
     {
-      DEBUG_printf(("httpRead: reading %d bytes from socket into buffer...\n",
+      DEBUG_printf(("httpRead2: reading %d bytes from socket into buffer...\n",
                     bytes));
 
       bytes = recv(http->fd, http->buffer, bytes, 0);
 
-      DEBUG_printf(("httpRead: read %d bytes from socket into buffer...\n",
+      DEBUG_printf(("httpRead2: read %d bytes from socket into buffer...\n",
                     bytes));
     }
 
@@ -1116,7 +1136,7 @@ httpRead(http_t *http,                    /* I - HTTP data */
 
     bytes = length;
 
-    DEBUG_printf(("httpRead: grabbing %d bytes from input buffer...\n", bytes));
+    DEBUG_printf(("httpRead2: grabbing %d bytes from input buffer...\n", bytes));
 
     memcpy(buffer, http->buffer, length);
     http->used -= length;
@@ -1138,13 +1158,13 @@ httpRead(http_t *http,                  /* I - HTTP data */
     if (!http->blocking && !httpWait(http, 1000))
       return (0);
 
-    DEBUG_printf(("httpRead: reading %d bytes from socket...\n", length));
+    DEBUG_printf(("httpRead2: reading %d bytes from socket...\n", length));
 
     while ((bytes = recv(http->fd, buffer, length, 0)) < 0)
       if (errno != EINTR)
         break;
 
-    DEBUG_printf(("httpRead: read %d bytes from socket...\n", bytes));
+    DEBUG_printf(("httpRead2: read %d bytes from socket...\n", bytes));
   }
 
   if (bytes > 0)
@@ -1190,7 +1210,7 @@ httpRead(http_t *http,                    /* I - HTTP data */
 #ifdef DEBUG
   {
     int i, j, ch;
-    printf("httpRead: Read %d bytes:\n", bytes);
+    printf("httpRead2: Read %d bytes:\n", bytes);
     for (i = 0; i < bytes; i += 16)
     {
       printf("   ");
@@ -1635,6 +1655,11 @@ httpWait(http_t *http,                   /* I - HTTP data */
 
 /*
  * 'httpWrite()' - Write data to a HTTP connection.
+ *
+ * This function is deprecated. Use the httpWrite2() function which can
+ * write more than 2GB of data.
+ *
+ * @deprecated@
  */
  
 int                                    /* O - Number of bytes written */
@@ -1642,7 +1667,20 @@ httpWrite(http_t     *http,              /* I - HTTP data */
           const char *buffer,          /* I - Buffer for data */
          int        length)            /* I - Number of bytes to write */
 {
-  int  bytes;                          /* Bytes written */
+  return ((int)httpWrite2(http, buffer, length));
+}
+
+
+/*
+ * 'httpWrite2()' - Write data to a HTTP connection.
+ */
+ssize_t                                        /* O - Number of bytes written */
+httpWrite2(http_t     *http,           /* I - HTTP data */
+           const char *buffer,         /* I - Buffer for data */
+          size_t     length)           /* I - Number of bytes to write */
+{
+  ssize_t      bytes;                  /* Bytes written */
 
 
   DEBUG_printf(("httpWrite(http=%p, buffer=%p, length=%d)\n", http,
@@ -2535,5 +2573,5 @@ http_write_ssl(http_t     *http,  /* I - HTTP data */
 
 
 /*
- * End of "$Id: http.c 4995 2006-01-26 20:14:42Z mike $".
+ * End of "$Id: http.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 1384e6d7db839a563d621135612b0816a4e380cd..9c346eebfca2be8194374a8640c667fb178cc5c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.h 4973 2006-01-25 02:36:02Z mike $"
+ * "$Id: http.h 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Hyper-Text Transport Protocol definitions for the Common UNIX Printing
  *   System (CUPS).
@@ -268,6 +268,17 @@ typedef enum http_uri_status_e             /**** URI separation status @since CUPS1.2@ ****
   HTTP_URI_MISSING_RESOURCE            /* Missing resource in URI (warning) */
 } http_uri_status_t;
 
+typedef enum http_uri_coding_e         /**** URI en/decode flags ****/
+{
+  HTTP_URI_CODING_NONE = 0,            /* Don't en/decode anything */
+  HTTP_URI_CODING_USERNAME = 1,                /* En/decode the username portion */
+  HTTP_URI_CODING_HOSTNAME = 2,                /* En/decode the hostname portion */
+  HTTP_URI_CODING_RESOURCE = 4,                /* En/decode the resource portion */
+  HTTP_URI_CODING_MOST = 7,            /* En/decode all but the query */
+  HTTP_URI_CODING_QUERY = 8,           /* En/decode the query portion */
+  HTTP_URI_CODING_ALL = 15             /* En/decode everything */
+} http_uri_coding_t;
+
 typedef enum http_version_e            /**** HTTP version numbers ****/
 {
   HTTP_0_9 = 9,                                /* HTTP/0.9 */
@@ -384,7 +395,7 @@ __attribute__ ((__format__ (__printf__, 2, 3)))
 #  endif /* __GNUC__ */
 ;
 extern int             httpPut(http_t *http, const char *uri);
-extern int             httpRead(http_t *http, char *buffer, int length);
+extern int             httpRead(http_t *http, char *buffer, int length) _HTTP_DEPRECATED;
 extern int             httpReconnect(http_t *http);
 extern void            httpSeparate(const char *uri, char *method,
                                     char *username, char *host, int *port,
@@ -394,7 +405,7 @@ extern void         httpSetField(http_t *http, http_field_t field,
 extern const char      *httpStatus(http_status_t status);
 extern int             httpTrace(http_t *http, const char *uri);
 extern http_status_t   httpUpdate(http_t *http);
-extern int             httpWrite(http_t *http, const char *buffer, int length);
+extern int             httpWrite(http_t *http, const char *buffer, int length) _HTTP_DEPRECATED;
 extern char            *httpEncode64(char *out, const char *in) _HTTP_DEPRECATED;
 extern char            *httpDecode64(char *out, const char *in) _HTTP_DEPRECATED;
 extern int             httpGetLength(http_t *http) _HTTP_DEPRECATED;
@@ -434,12 +445,14 @@ extern char               *httpAddrLookup(const http_addr_t *addr,
                                         char *name, int namelen);
 extern char            *httpAddrString(const http_addr_t *addr,
                                        char *s, int slen);
-extern http_uri_status_t httpAssembleURI(char *uri, int urilen,
+extern http_uri_status_t httpAssembleURI(http_uri_coding_t encoding,
+                                        char *uri, int urilen,
                                         const char *scheme,
                                         const char *username,
                                         const char *host, int port,
                                         const char *resource);
-extern http_uri_status_t httpAssembleURIf(char *uri, int urilen,
+extern http_uri_status_t httpAssembleURIf(http_uri_coding_t encoding,
+                                         char *uri, int urilen,
                                          const char *scheme,
                                          const char *username,
                                          const char *host, int port,
@@ -451,12 +464,16 @@ extern off_t              httpGetLength2(http_t *http);
 extern char            *httpGetSubField2(http_t *http, http_field_t field,
                                          const char *name, char *value,
                                          int valuelen);
-extern http_uri_status_t httpSeparateURI(const char *uri,
+extern ssize_t         httpRead2(http_t *http, char *buffer, size_t length);
+extern http_uri_status_t httpSeparateURI(http_uri_coding_t decoding,
+                                        const char *uri,
                                         char *scheme, int schemelen,
                                         char *username, int usernamelen,
                                         char *host, int hostlen, int *port,
                                         char *resource, int resourcelen);
 extern void            httpSetLength(http_t *http, size_t length);
+extern ssize_t         httpWrite2(http_t *http, const char *buffer,
+                                  size_t length);
 
 
 /*
@@ -469,5 +486,5 @@ extern void         httpSetLength(http_t *http, size_t length);
 #endif /* !_CUPS_HTTP_H_ */
 
 /*
- * End of "$Id: http.h 4973 2006-01-25 02:36:02Z mike $".
+ * End of "$Id: http.h 5023 2006-01-29 14:39:44Z mike $".
  */
index fbe7e39de5049c51170e813c45cbfc0f05459434..be6f0bbc96965a4aae3eba5e33220d05fd98c178 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $"
+ * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Internet Printing Protocol support functions for the Common UNIX
  *   Printing System (CUPS).
  */
 
 static size_t          ipp_length(ipp_t *ipp, int collection);
-static int             ipp_read_http(http_t *http, ipp_uchar_t *buffer, int length);
-static int             ipp_read_file(int *fd, ipp_uchar_t *buffer, int length);
-static int             ipp_write_file(int *fd, ipp_uchar_t *buffer, int length);
+static ssize_t         ipp_read_http(http_t *http, ipp_uchar_t *buffer,
+                                     size_t length);
+static ssize_t         ipp_read_file(int *fd, ipp_uchar_t *buffer,
+                                     size_t length);
+static ssize_t         ipp_write_file(int *fd, ipp_uchar_t *buffer,
+                                      size_t length);
 
 
 /*
@@ -1580,7 +1583,7 @@ ippWrite(http_t *http,                    /* I - HTTP connection */
   if (http == NULL)
     return (IPP_ERROR);
 
-  return (ippWriteIO(http, (ipp_iocb_t)httpWrite,
+  return (ippWriteIO(http, (ipp_iocb_t)httpWrite2,
                      http->blocking, NULL, ipp));
 }
 
@@ -2623,10 +2626,10 @@ ipp_length(ipp_t *ipp,                  /* I - IPP message or collection */
  * 'ipp_read_http()' - Semi-blocking read on a HTTP connection...
  */
 
-static int                             /* O - Number of bytes read */
+static ssize_t                         /* O - Number of bytes read */
 ipp_read_http(http_t      *http,       /* I - Client connection */
               ipp_uchar_t *buffer,     /* O - Buffer for data */
-             int         length)       /* I - Total length */
+             size_t      length)       /* I - Total length */
 {
   int          tbytes,                 /* Total bytes read */
                bytes;                  /* Bytes read this pass */
@@ -2718,7 +2721,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
        }
       }
 
-      if ((bytes = httpRead(http, (char *)buffer, length - tbytes)) <= 0)
+      if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) <= 0)
         break;
     }
   }
@@ -2740,10 +2743,10 @@ ipp_read_http(http_t      *http,        /* I - Client connection */
  * 'ipp_read_file()' - Read IPP data from a file.
  */
 
-static int                             /* O - Number of bytes read */
+static ssize_t                         /* O - Number of bytes read */
 ipp_read_file(int         *fd,         /* I - File descriptor */
               ipp_uchar_t *buffer,     /* O - Read buffer */
-             int         length)       /* I - Number of bytes to read */
+             size_t      length)       /* I - Number of bytes to read */
 {
   return (read(*fd, buffer, length));
 }
@@ -2753,15 +2756,15 @@ ipp_read_file(int         *fd,          /* I - File descriptor */
  * 'ipp_write_file()' - Write IPP data to a file.
  */
 
-static int                             /* O - Number of bytes written */
+static ssize_t                         /* O - Number of bytes written */
 ipp_write_file(int         *fd,                /* I - File descriptor */
                ipp_uchar_t *buffer,    /* I - Data to write */
-               int         length)     /* I - Number of bytes to write */
+               size_t      length)     /* I - Number of bytes to write */
 {
   return (write(*fd, buffer, length));
 }
 
 
 /*
- * End of "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $".
+ * End of "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $".
  */
index f011a35e4a35015abbd7ca8f485133f23e854ca2..4a337a84e0e31397732c55a73cf0223e8a9cc926 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.h 4995 2006-01-26 20:14:42Z mike $"
+ * "$Id: ipp.h 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Internet Printing Protocol definitions for the Common UNIX Printing
  *   System (CUPS).
@@ -310,9 +310,9 @@ typedef enum                                /**** IPP status codes... ****/
 
 typedef unsigned char ipp_uchar_t;     /**** Unsigned 8-bit integer/character ****/
 
-/**** New in CUPS 1.1.19 ****/
-typedef int    (*ipp_iocb_t)(void *, ipp_uchar_t *, int);
-                                       /**** IPP IO Callback Function ****/
+/**** New in CUPS 1.2 ****/
+typedef ssize_t        (*ipp_iocb_t)(void *, ipp_uchar_t *, size_t);
+                                       /**** IPP IO Callback Function @since CUPS 1.2@ ****/
 
 typedef union                          /**** Request Header ****/
 {
@@ -470,11 +470,7 @@ extern ipp_attribute_t     *ippAddCollections(ipp_t *ipp, ipp_tag_t group,
                                           const ipp_t **values);
 extern void            ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr);
 extern ipp_state_t     ippReadFile(int fd, ipp_t *ipp);
-extern ipp_state_t     ippReadIO(void *src, ipp_iocb_t cb, int blocking,
-                                 ipp_t *parent, ipp_t *ipp);
 extern ipp_state_t     ippWriteFile(int fd, ipp_t *ipp);
-extern ipp_state_t     ippWriteIO(void *dst, ipp_iocb_t cb, int blocking,
-                                  ipp_t *parent, ipp_t *ipp);
 
 /**** New in CUPS 1.2 ****/
 extern ipp_attribute_t *ippAddOctetString(ipp_t *ipp, ipp_tag_t group,
@@ -484,6 +480,10 @@ extern ipp_status_t        ippErrorValue(const char *name);
 extern ipp_t           *ippNewRequest(ipp_op_t op);
 extern const char      *ippOpString(ipp_op_t op);
 extern ipp_op_t                ippOpValue(const char *name);
+extern ipp_state_t     ippReadIO(void *src, ipp_iocb_t cb, int blocking,
+                                 ipp_t *parent, ipp_t *ipp);
+extern ipp_state_t     ippWriteIO(void *dst, ipp_iocb_t cb, int blocking,
+                                  ipp_t *parent, ipp_t *ipp);
 
 
 /*
@@ -496,5 +496,5 @@ extern ipp_op_t             ippOpValue(const char *name);
 #endif /* !_CUPS_IPP_H_ */
 
 /*
- * End of "$Id: ipp.h 4995 2006-01-26 20:14:42Z mike $".
+ * End of "$Id: ipp.h 5023 2006-01-29 14:39:44Z mike $".
  */
index 69f9595418d2f77f4ba5ef2e087a2f2085262adb..71b8709f9a448c28057e2ee533425f71df18bcd1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: testhttp.c 4943 2006-01-18 20:30:42Z mike $"
+ * "$Id: testhttp.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   HTTP test program for the Common UNIX Printing System (CUPS).
  *
@@ -325,7 +325,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
     fputs("httpSeparateURI(): ", stdout);
     for (i = 0, j = 0; i < (int)(sizeof(uri_tests) / sizeof(uri_tests[0])); i ++)
     {
-      uri_status = httpSeparateURI(uri_tests[i].uri, scheme, sizeof(scheme),
+      uri_status = httpSeparateURI(HTTP_URI_CODING_MOST,
+                                  uri_tests[i].uri, scheme, sizeof(scheme),
                                    username, sizeof(username),
                                   hostname, sizeof(hostname), &port,
                                   resource, sizeof(resource));
@@ -390,7 +391,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
           strstr(uri_tests[i].uri, "//"))
       {
         k ++;
-       uri_status = httpAssembleURI(buffer, sizeof(buffer),
+       uri_status = httpAssembleURI(HTTP_URI_CODING_MOST,
+                                    buffer, sizeof(buffer),
                                     uri_tests[i].scheme,
                                     uri_tests[i].username,
                                     uri_tests[i].hostname,
@@ -459,7 +461,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
       continue;
     }
 
-    httpSeparateURI(argv[i], scheme, sizeof(scheme), username, sizeof(username),
+    httpSeparateURI(HTTP_URI_CODING_MOST, argv[i], scheme, sizeof(scheme),
+                    username, sizeof(username),
                     hostname, sizeof(hostname), &port,
                    resource, sizeof(resource));
 
@@ -485,7 +488,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
     length = httpGetLength2(http);
     total  = 0;
 
-    while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
+    while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
     {
       total += bytes;
       fwrite(buffer, bytes, 1, out);
@@ -512,5 +515,5 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: testhttp.c 4943 2006-01-18 20:30:42Z mike $".
+ * End of "$Id: testhttp.c 5023 2006-01-29 14:39:44Z mike $".
  */
index dbe50b54d6847e3f6c55cc0459b044ede867c54b..07bcdffc0d32461b530c0593e6ce424f9b8c9867 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: testipp.c 4731 2005-09-30 23:11:10Z mike $"
+ * "$Id: testipp.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   IPP test program for the Common UNIX Printing System (CUPS).
  *
@@ -144,8 +144,8 @@ ipp_uchar_t collection[] =                  /* Collection buffer */
 
 void   hex_dump(const char *title, ipp_uchar_t *buffer, int bytes);
 void   print_attributes(ipp_t *ipp, int indent);
-int    read_cb(void *data, ipp_uchar_t *buffer, int bytes);
-int    write_cb(void *data, ipp_uchar_t *buffer, int bytes);
+ssize_t        read_cb(void *data, ipp_uchar_t *buffer, size_t bytes);
+ssize_t        write_cb(void *data, ipp_uchar_t *buffer, size_t bytes);
 
 
 /*
@@ -594,10 +594,10 @@ print_attributes(ipp_t *ipp,              /* I - IPP request */
  * 'read_cb()' - Read data from a buffer.
  */
 
-int                                    /* O - Number of bytes read */
+ssize_t                                        /* O - Number of bytes read */
 read_cb(void        *data,             /* I - Data */
         ipp_uchar_t *buffer,           /* O - Buffer to read */
-       int         bytes)              /* I - Number of bytes to read */
+       size_t      bytes)              /* I - Number of bytes to read */
 {
   int  count;                          /* Number of bytes */
 
@@ -621,10 +621,10 @@ read_cb(void        *data,                /* I - Data */
  * 'write_cb()' - Write data into a buffer.
  */
 
-int                                    /* O - Number of bytes written */
+ssize_t                                        /* O - Number of bytes written */
 write_cb(void        *data,            /* I - Data */
          ipp_uchar_t *buffer,          /* I - Buffer to write */
-        int         bytes)             /* I - Number of bytes to write */
+        size_t      bytes)             /* I - Number of bytes to write */
 {
   int  count;                          /* Number of bytes */
 
@@ -645,5 +645,5 @@ write_cb(void        *data,         /* I - Data */
 
 
 /*
- * End of "$Id: testipp.c 4731 2005-09-30 23:11:10Z mike $".
+ * End of "$Id: testipp.c 5023 2006-01-29 14:39:44Z mike $".
  */
index e26db23f29520a3caec565f80a46d0d0c6d99c3f..b1108effb3c40c967c1c5b26396869b3fef68a68 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: util.c 4987 2006-01-26 00:25:21Z mike $"
+ * "$Id: util.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Printing utilities for the Common UNIX Printing System (CUPS).
  *
@@ -121,8 +121,8 @@ cupsCancelJob(const char *name,             /* I - Name of printer or class */
   * Create a printer URI...
   */
 
-  if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                       "/printers/%s", printer) != HTTP_URI_OK)
+  if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                       "localhost", 0, "/printers/%s", printer) != HTTP_URI_OK)
   {
     cups_set_error(IPP_INTERNAL_ERROR, NULL);
 
@@ -336,7 +336,7 @@ cupsDoFileRequest(http_t     *http, /* I - HTTP connection to server */
              break;
           }
 
-         if (httpWrite(http, buffer, bytes) < bytes)
+         if (httpWrite2(http, buffer, bytes) < bytes)
             break;
         }
       }
@@ -891,8 +891,8 @@ cupsGetJobs2(http_t     *http,              /* I - HTTP connection */
 
   if (mydest)
   {
-    if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                         "/printers/%s", mydest) != HTTP_URI_OK)
+    if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                         "localhost", 0, "/printers/%s", mydest) != HTTP_URI_OK)
     {
       cups_set_error(IPP_INTERNAL_ERROR, NULL);
 
@@ -1552,8 +1552,8 @@ cupsPrintFiles2(http_t        *http,      /* I - HTTP connection */
   * Setup the printer URI...
   */
 
-  if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                       "/printers/%s", name) != HTTP_URI_OK)
+  if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                       "localhost", 0, "/printers/%s", name) != HTTP_URI_OK)
   {
     cups_set_error(IPP_INTERNAL_ERROR, NULL);
 
@@ -1816,8 +1816,8 @@ cups_get_printer_uri(
   * Setup the printer URI...
   */
 
-  if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                       "/printers/%s", name) != HTTP_URI_OK)
+  if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                       "localhost", 0, "/printers/%s", name) != HTTP_URI_OK)
   {
     cups_set_error(IPP_INTERNAL_ERROR, NULL);
 
@@ -1877,9 +1877,9 @@ cups_get_printer_uri(
 
       for (i = 0; i < attr->num_values; i ++)
       {
-       httpSeparateURI(attr->values[i].string.text, scheme, sizeof(scheme),
-                       username, sizeof(username), host, hostsize,
-                       port, resource, resourcesize);
+       httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text,
+                       scheme, sizeof(scheme), username, sizeof(username),
+                       host, hostsize, port, resource, resourcesize);
        if (!strncmp(resource, "/printers/", 10))
        {
         /*
@@ -1901,9 +1901,9 @@ cups_get_printer_uri(
       {
        for (i = 0; i < attr->num_values; i ++)
        {
-         httpSeparateURI(attr->values[i].string.text, scheme, sizeof(scheme),
-                         username, sizeof(username), host, hostsize,
-                         port, resource, resourcesize);
+         httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text,
+                         scheme, sizeof(scheme), username, sizeof(username),
+                         host, hostsize, port, resource, resourcesize);
          if (!strncmp(resource, "/classes/", 9))
          {
           /*
@@ -1945,9 +1945,9 @@ cups_get_printer_uri(
     else if ((attr = ippFindAttribute(response, "printer-uri-supported",
                                       IPP_TAG_URI)) != NULL)
     {
-      httpSeparateURI(attr->values[0].string.text, scheme, sizeof(scheme),
-                     username, sizeof(username), host, hostsize,
-                     port, resource, resourcesize);
+      httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text,
+                      scheme, sizeof(scheme), username, sizeof(username),
+                     host, hostsize, port, resource, resourcesize);
       ippDelete(response);
 
       return (1);
@@ -1990,5 +1990,5 @@ cups_set_error(ipp_status_t status,       /* I - IPP status code */
 
 
 /*
- * End of "$Id: util.c 4987 2006-01-26 00:25:21Z mike $".
+ * End of "$Id: util.c 5023 2006-01-29 14:39:44Z mike $".
  */
index a6aa8a3cda2fb89b38eb009c113ce507437b45d7..c8f86cdba662189dea799d3871bf32d9adb8ae64 100644 (file)
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile 4950 2006-01-19 16:07:57Z mike $"
+# "$Id: Makefile 5020 2006-01-28 13:36:15Z mike $"
 #
 #   Documentation makefile for the Common UNIX Printing System (CUPS).
 #
@@ -30,6 +30,7 @@ include ../Makedefs
 
 WEBPAGES       =       cups.css cupsdoc.css index.html robots.txt
 WEBIMAGES      =       \
+                       favicon.ico \
                        images/accept-jobs.gif \
                        images/add-class.gif \
                        images/add-printer.gif \
index 24c7f5ea4f8cb90a6d684125d642e298c1e12f3d..a1981b58ae8a038f67218a6ff21493152477d2f7 100644 (file)
@@ -221,3 +221,8 @@ DT {
 DD {
   margin-left: 5em;
 }
+
+P.summary {
+  margin-left: 5em;
+  font-family: monospace;
+}
index a6d70ba73f59d45bcf0dd30cb865994c1616e566..eb9ac267bff71ee2a9fef4872b6fe097927f2f7e 100644 (file)
@@ -4,10 +4,11 @@
 <head>
        <title>CUPS PPD Extensions</title>
        <meta name='keywords' content='Programming, PostScript Printer Description'>
+       <link rel='stylesheet' type='text/css' href='../cups.css'>
 </head>
 <body>
 <!--
-  "$Id: spec-ppd.html 4941 2006-01-18 13:16:40Z mike $"
+  "$Id: spec-ppd.html 5023 2006-01-29 14:39:44Z mike $"
 
   CUPS PPD extensions specification for the Common UNIX Printing System (CUPS).
 
@@ -74,18 +75,32 @@ LINE-END = CR / LF / CR LF
 
 <h2 class='title'><a name='ATTRIBUTES'>General Attributes</a></h2>
 
-<h3>cupsFilter</h3>
+<h3>APDuplexRequiresFlippedMargin</h3>
+
+<p class='summary'>*APDuplexRequiresFlippedMargin: boolean</p>
+
+<p>This boolean attribute notifies the RIP filters that the
+destination printer does not require the top and bottom margins
+of the <tt>ImageableArea</tt> swapped for the back page. The
+default value is <code>true</code>.</p>
 
-<p>This string attribute provides a conversion rule of the
-form:</p>
+<p>Example:</p>
 
 <pre class='command'>
-source/type cost program
+<em>*% Don't swap the top and bottom margins for the back side</em> 
+*APDuplexRequiresFlippedMargin: false
 </pre>
 
-<p>The destination type is assumed to the printer's type. If a
-printer supports the source type directly, the special filter
-program "-" may be specified.</p>
+<p>Also see the related <tt>cupsFlipDuplex</tt> attribute.</p>
+
+<h3>cupsFilter</h3>
+
+<p class='summary'>*cupsFilter: "source/type cost program"</p>
+
+<p>This string attribute provides a conversion rule from the
+given source type to the printer's native format using the
+filter "program". If a printer supports the source type directly,
+the special filter program "-" may be specified.</p>
 
 <p>Examples:</p>
 
@@ -102,9 +117,11 @@ program "-" may be specified.</p>
 
 <h3>cupsFlipDuplex</h3>
 
+<p class='summary'>*cupsFlipDuplex: boolean</p>
+
 <p>This boolean attribute notifies the RIP filters that the
 destination printer requires an upside-down image for the back
-page. The default value is false.</p>
+page. The default value is <code>false</code>.</p>
 
 <p>Example:</p>
 
@@ -113,11 +130,30 @@ page. The default value is false.</p>
 *cupsFlipDuplex: true
 </pre>
 
+<p>Also see the related <tt>APDuplexRequiresFlippedMargins</tt> attribute.</p>
+
+<h3>cupsLanguages</h3>
+
+<p class='summary'>*cupsLanguages: "locale list"</p>
+
+<p>This attribute describes which language localizations are
+included in the PPD. The "locale list" string is a space-delimited
+list of locale names ("en", "en_US", "fr_FR", etc.)</p>
+
+<p>Example:</p>
+
+<pre class='command'>
+<em>*% Specify Canadian, UK, and US English, and Candian and French French</em> 
+*cupsLanguages: "en_CA en_UK en_US fr_CA fr_FR"
+</pre>
+
 <h3>cupsManualCopies</h3>
 
+<p class='summary'>*cupsManualCopies: boolean</p>
+
 <p>This boolean attribute notifies the RIP filters that the
 destination printer does not support copy generation in
-hardware. The default value is false.</p>
+hardware. The default value is <code>false</code>.</p>
 
 <p>Example:</p>
 
@@ -128,6 +164,8 @@ hardware. The default value is false.</p>
 
 <h3>cupsModelNumber</h3>
 
+<p class='summary'>*cupsModelNumber: number</p>
+
 <p>This integer attribute specifies a printer-specific model
 number. This number can be used by a filter program to adjust
 the output for a specific model of printer.</p>
@@ -141,6 +179,8 @@ the output for a specific model of printer.</p>
 
 <h3>cupsPortMonitor</h3>
 
+<p class='summary'>*cupsPortMonitor urischeme/Descriptive Text: "port monitor"</p>
+
 <p>This string attribute specifies printer-specific "port
 monitor" filters that may be used with the printer. The CUPS
 scheduler also looks for the <tt>Protocols</tt> attribute to see
@@ -149,18 +189,30 @@ so, the corresponding port monitor ("bcp" and "tbcp",
 respectively) is listed in the printer's
 <tt>port-monitor-supported</tt> attribute.</p>
 
+<p>The "urischeme" portion of the attribute specifies the URI scheme
+that this port monitor should be used for. Typically this is used to
+pre-select a particular port monitor for each type of connection that
+is supported by the printer. The "port monitor" string can be "none"
+to disable the port monitor for the given URI scheme.</p>
+
 <p>Examples:</p>
 
 <pre class='command'>
 <em>*% Specify a PostScript printer that supports the TBCP protocol</em>
 *Protocols: TBCP PJL
 
+<em>*% Specify that TBCP should be used for socket connections but not USB</em>
+*cupsPortMonitor socket/AppSocket Printing: "tbcp"
+*cupsPortMonitor usb/USB Printing: "none"
+
 <em>*% Specify a printer-specific port monitor for an Epson USB printer</em> 
-*cupsPortMonitor epson-usb/USB Status Monitor: "epson-usb"
+*cupsPortMonitor usb/USB Status Monitor: "epson-usb"
 </pre>
 
 <h3>cupsVersion</h3>
 
+<p class='summary'>*cupsVersion: major.minor</p>
+
 <p>This required attribute describes which version of the CUPS
 PPD file extensions was used. Currently it must be the string
 "1.0", "1.1", or "1.2".</p>
@@ -190,11 +242,18 @@ syntax:</p>
 <p>When the base option is part of the <tt>JCLSetup</tt> section,
 the "command" string contains JCL commands with "\order"
 placeholders for each numbered parameter. The CUPS API handles
-any necessary value quoting for HP-PJL commands.</p>
+any necessary value quoting for HP-PJL commands. For example, if
+the JCL command string is "@PJL SET PASSCODE=\1" and the first
+option value is "1234" then CUPS will output the string
+"@PJL SET PASSCODE=1234".</p>
 
 <p>For non-<tt>JCLSetup</tt> options, the "order" value is a
 number from 1 to N and specifies the order of values as they are
-placed on the stack before the command.</p>
+placed on the stack before the command. For example, if the
+PostScript command string is
+"&lt;&lt;/cupsReal1 2 1 roll&gt;&gt;setpagedevice" and the
+option value is "2.0" then CUPS will output the string
+"2.0 &lt;&lt;/cupsReal1 2 1 roll&gt;&gt;setpagedevice".</p>
 
 <blockquote><b>Note:</b> Currently only CustomPageSize supports
 more than 1 parameter. This restriction is due to value encoding
@@ -221,13 +280,13 @@ allow string values to contain spaces.</blockquote>
 
        <li><tt>passcode</tt> - a string of numbers value with a
        minimum of "minimum" numbers and a maximum of "maximum"
-       numbers (passcode strings are not displayed in the user
-       interface)</li>
+       numbers ("minimum" and "maximum" are numbers and passcode
+       strings are not displayed in the user interface)</li>
 
        <li><tt>password</tt> - a string value with a minimum of
        "minimum" characters and a maximum of "maximum"
-       characters (password strings are not displayed in the
-       user interface)</li>
+       characters ("minimum" and "maximum" are numbers and password
+       strings are not displayed in the user interface)</li>
 
        <li><tt>points</tt> - a measurement value in points from
        "minimum" to "maximum"</li>
@@ -237,7 +296,7 @@ allow string values to contain spaces.</blockquote>
 
        <li><tt>string</tt> - a string value with a minimum of
        "minimum" characters and a maximum of "maximum"
-       characters</li>
+       characters ("minimum" and "maximum" are numbers)</li>
 
 </ul>
 
@@ -259,6 +318,19 @@ allow string values to contain spaces.</blockquote>
 *ParamCustomJCLPasscode Code/Key Code: 1 passcode 4 4
 
 
+<em>*% Base PostScript watermark option</em>
+*OpenUI WatermarkText/Watermark Text: PickOne
+*OrderDependency: 10 AnySetup *WatermarkText
+*DefaultWatermarkText: None
+*WatermarkText None: ""
+*WatermarkText Draft: "&lt;&lt;/cupsString1(Draft)&gt;&gt;setpagedevice"
+*CloseUI: *WatermarkText
+
+<em>*% Custom PostScript watermark option</em>
+*CustomWatermarkText True: "&lt;&lt;/cupsString1 2 1 roll&gt;&gt;setpagedevice"
+*ParamCustomWatermarkText Text: 1 string 0 32
+
+
 <em>*% Base PostScript gamma/density option</em> 
 *OpenUI GammaDensity/Gamma and Density: PickOne
 *OrderDependency: 10 AnySetup *GammaDensity
@@ -266,7 +338,7 @@ allow string values to contain spaces.</blockquote>
 *GammaDensity Normal/Normal: "&lt;&lt;/cupsReal1 1.0/cupsReal2 1.0&gt;&gt;setpagedevice"
 *GammaDensity Light/Lighter: "&lt;&lt;/cupsReal1 0.9/cupsReal2 0.67&gt;&gt;setpagedevice"
 *GammaDensity Dark/Darker: "&lt;&lt;/cupsReal1 1.1/cupsReal2 1.5&gt;&gt;setpagedevice"
-*JCLCloseUI: *GammaDensity
+*CloseUI: *GammaDensity
 
 <em>*% Custom PostScript gamma/density option</em> 
 *CustomGammaDensity True: "&lt;&lt;/cupsReal1 3 1 roll/cupsReal2 3 1&gt;&gt;setpagedevice"
@@ -277,14 +349,23 @@ allow string values to contain spaces.</blockquote>
 
 <h2 class='title'><a name='PROFILES'>Color Profiles</a></h2>
 
+<p>CUPS supports two types of color profiles. The first type is
+based on sRGB and is used by the standard CUPS raster filters and
+ESP Ghostscript. The second type is based on ICC profiles and is
+used by the Core Graphics-based filters on MacOS X.</p>
+
+<blockquote><b>Note:</b> At this time, none of the CUPS raster
+filters support ICC profiles. This will be addressed as time
+and resources permit.</blockquote>
+
 <h3>cupsColorProfile</h3>
 
-<p>This string attribute specifies a color profile of the
-form:</p>
+<p class='summary'>*cupsColorProfile Resolution/MediaType: "density
+gamma m00 m01 m02 m10 m11 m12 m20 m21 m22"</p>
 
-<pre class='command'>
-*cupsColorProfile Resolution/MediaType: "density gamma m00 m01 m02 m10 m11 m12 m20 m21 m22"
-</pre>
+<p>This string attribute specifies an sRGB-based color profile
+consisting of gamma and density controls and a 3x3 CMY color
+transform matrix.</p>
 
 <p>The <i>Resolution</i> and <i>MediaType</i> values may be "-"
 to act as a wildcard. Otherwise they must match one of the
@@ -323,14 +404,12 @@ function is applied <i>after</i> the CMY transformation:</p>
 
 <h3>cupsICCProfile</h3>
 
-<p>This attribute specifies an ICC color profile of the
-form:</p>
-
-<pre class='command'>
-*cupsICCProfile ColorModel.MediaType.Resolution/Description: "filename"
-</pre>
+<p class='summary'>*cupsICCProfile
+ColorModel.MediaType.Resolution/Description: "filename"</p>
 
-<p>The <tt>ColorModel</tt>, <tt>MediaType</tt>, and
+<p>This attribute specifies an ICC color profile that is
+used to convert the document colors to the device
+colorspace. The <tt>ColorModel</tt>, <tt>MediaType</tt>, and
 <tt>Resolution</tt> keywords specify a selector for color
 profiles. If omitted, the color profile will match any option
 keyword for the corresponding main keyword.</p>
@@ -378,53 +457,76 @@ attributes define the mapping from selector to main keyword:</p>
 </pre>
 
 
-<h2 class='title'><a name='I18N'>I18N Support</a></h2>
+<h2 class='title'><a name='I18N'>Global PPD Support</a></h2>
 
 <p>CUPS 1.2 and higher adds support for PPD files containing multiple
-languages by following the following rules:</p>
+languages by following the following additional rules:</p>
 
 <ol>
 
-       <li>The <tt>LanguageVersion</tt> is <tt>English</tt></li>
+       <li>The <tt>LanguageVersion</tt> MUST be <tt>English</tt></li>
+
+       <li>The <tt>LanguageEncoding</tt> MUST be <tt>ISOLatin1</tt></li>
+
+       <li>The <tt>cupsLanguages</tt> attribute MUST be provided and
+       list each of the supported locales in the PPD file</li>
+
+       <li>Main and option keywords MUST NOT exceed 34 (instead of 40)
+       characters to allow room for the locale prefixes in translation
+       attributes</li>
 
-       <li>The <tt>LanguageEncoding</tt> is <tt>ISOLatin1</tt></li>
+       <li>The main keyword "Translation" MUST NOT be used</li>
 
-       <li>Main and option keywords may not exceed 34
-       characters, which is a subset of what the Adobe PPD spec
-       allows.</li>
+       <li>Translation strings included with the main and option
+       keywords MUST NOT contain characters outside the ASCII
+       subset of ISOLatin1 and UTF-8; developers wishing to use
+       characters outside ASCII MUST provide a separate set of
+       English localization attributes for the affected keywords.</li>
 
-       <li>Translations are specified using a locale prefix of
+       <li>Localizations are specified using a locale prefix of
        the form "ll" or "ll_CC." where "ll" is the 2-letter ISO
        language code and "CC" is the 2-letter ISO country
        code</li>
 
-       <li>Translation strings are encoded using UTF-8.</li>
+       <li>Locale-specific translation strings MUST be encoded
+       using UTF-8.</li>
 
-       <li>Main keywords are translated using any of the
+       <li>Main keywords MUST be localized using one of the
        following forms:
        <p><tt>*ll.Translation MainKeyword/translation
        text: ""</tt><br />
        <tt>*ll_CC.Translation MainKeyword/translation
        text: ""</tt></p></li>
 
-       <li>Option keywords are translated using any of the
+       <li>Option keywords MUST be localized using one of the
        following forms:
        <p><tt>*ll.MainKeyword OptionKeyword/translation
        text: ""</tt><br />
        <tt>*ll_CC.MainKeyword OptionKeyword/translation
        text: ""</tt></p></li>
 
+       <li>Localization attributes MAY appear anywhere after the
+       first line of the PPD file</li>
+
 </ol>
 
-<p>Examples:</p>
+<blockquote><b>Note:</b>
+We use a <tt>LanguageEncoding</tt> value of <tt>ISOLatin1</tt>
+and limit the allowed base translation strings to ASCII to avoid
+character coding issues that would otherwise occur. In addition,
+requiring the base translation strings to be in English allows
+for easier fallback translation when no localization is provided
+in the PPD file for a given locale.</blockquote>
 
+<p>Examples:</p>
 
 <pre class='command'>
 *LanguageVersion: English
 *LanguageEncoding: ISOLatin1
+*cupsLanguages: "de_DE fr_FR"
 *ModelName: "Foobar Laser 9999"
 
-<em>*% Localize for French and German</em>
+<em>*% Localize ModelName for French and German</em>
 *fr_FR.Translation ModelName/La Foobar Laser 9999: ""
 *de_DE.Translation ModelName/Foobar LaserDrucken 9999: ""
 
@@ -433,15 +535,15 @@ languages by following the following rules:</p>
 *OpenUI *InputSlot/Paper Source: PickOne
 *OrderDependency: 10 AnySetup *InputSlot
 *DefaultInputSlot: Auto
-<em>*% Localize for French and German</em>
+<em>*% Localize InputSlot for French and German</em>
 *fr_FR.Translation InputSlot/Papier source: ""
 *de_DE.Translation InputSlot/Papiereinzug: ""
 *InputSlot Auto/Default: "&lt;&lt;/ManualFeed false&gt;&gt;setpagedevice"
-<em>*% Localize for French and German</em>
+<em>*% Localize InputSlot=Auto for French and German</em>
 *fr_FR.InputSlot Auto/Par Defaut: ""
 *de_DE.InputSlot Auto/Standard: ""
 *InputSlot Manual/Manual Feed: "&lt;&lt;/ManualFeed true&gt;&gt;setpagedevice"
-<em>*% Localize for French and German</em>
+<em>*% Localize InputSlot=Manual for French and German</em>
 *fr_FR.InputSlot Manual/Manuel mecanisme de alimentation: ""
 *de_DE.InputSlot Manual/Manueller Einzug: ""
 *CloseUI: *InputSlot
@@ -458,8 +560,12 @@ languages by following the following rules:</p>
 
        <li>Added custom option values support</li>
 
+       <li>Added <tt>APDuplexRequiresFlippedMargin</tt> attribute</li>
+
        <li>Added <tt>cupsICCProfile</tt> attribute</li>
 
+       <li>Added <tt>cupsLanguages</tt> attribute</li>
+
        <li>Added <tt>cupsPortMonitor</tt> attribute</li>
 
        <li>Removed <tt>cupsProtocol</tt> attribute</li>
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/init/cupsd-launchd.plist b/init/cupsd-launchd.plist
new file mode 100644 (file)
index 0000000..67f19cb
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>Enabled</key>
+       <true/>
+       <key>Label</key>
+       <string>org.cups.cupsd</string>
+       <key>OnDemand</key>
+       <true/>
+       <key>ProgramArguments</key>
+       <array>
+               <string>/usr/sbin/cupsd</string>
+               <string>-l</string>
+       </array>
+       <key>RunAtLoad</key>
+       <true/>
+       <key>ServiceIPC</key>
+       <true/>
+       <key>Sockets</key>
+       <dict>
+               <key>Listeners</key>
+               <array>
+                       <dict>
+                               <key>SockNodeName</key>
+                               <string>localhost</string>
+                               <key>SockServiceName</key>
+                               <string>ipp</string>
+                       </dict>
+                       <dict>
+                               <key>SockPathMode</key>
+                               <integer>49663</integer>
+                               <key>SockPathName</key>
+                               <string>/private/var/run/cupsd</string>
+                       </dict>
+               </array>
+       </dict>
+</dict>
+</plist>
diff --git a/init/cupsd-launchd.sh b/init/cupsd-launchd.sh
new file mode 100755 (executable)
index 0000000..c956220
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# This is a dummy script to ensure that the CUPS domain socket is world-
+# writable.  This works around a problem in launchd...
+
+if test -e /private/var/run/cupsd; then
+       chmod g+w,o+w /private/var/run/cupsd
+fi
index e082b858da19f4caf2404c65e34abd5491bf1356..25e8fab3d5c96e8a8191cc225d7e46eb1f3bbd58 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: translate.c 4896 2006-01-08 03:57:45Z mike $"
+ * "$Id: translate.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   HTTP-based translation program for the Common UNIX Printing System (CUPS).
  *
@@ -261,7 +261,7 @@ translate_messages(cups_array_t *cat,       /* I - Message catalog */
        httpPost(http, "/translate_t");
       }
 
-      httpWrite(http, buffer, bufptr - buffer);
+      httpWrite2(http, buffer, bufptr - buffer);
 
       while ((status = httpUpdate(http)) == HTTP_CONTINUE);
 
@@ -281,7 +281,7 @@ translate_messages(cups_array_t *cat,       /* I - Message catalog */
       bufptr = buffer;
       bufend = buffer + sizeof(buffer) - 1;
 
-      while ((bytes = httpRead(http, bufptr, bufend - bufptr)) > 0)
+      while ((bytes = httpRead2(http, bufptr, bufend - bufptr)) > 0)
         bufptr += bytes;
 
       if (bytes < 0)
@@ -444,5 +444,5 @@ write_string(cups_file_t *fp,               /* I - File to write to */
 
 
 /*
- * End of "$Id: translate.c 4896 2006-01-08 03:57:45Z mike $".
+ * End of "$Id: translate.c 5023 2006-01-29 14:39:44Z mike $".
  */
index b550ec4487b04c80600aab0e922a52f058c882ee..47e80dd39d71259269b2e14e6629c20cc1f3ad05 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.c 4950 2006-01-19 16:07:57Z mike $"
+ * "$Id: client.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Client routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -1145,7 +1145,8 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
          * Separate the URI into its components...
          */
 
-          httpSeparateURI(con->uri, method, sizeof(method),
+          httpSeparateURI(HTTP_URI_CODING_MOST, con->uri,
+                         method, sizeof(method),
                          userpass, sizeof(userpass),
                          hostname, sizeof(hostname), &port,
                          resource, sizeof(resource));
@@ -1883,7 +1884,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
                            "CHUNKED" : "LENGTH",
                        CUPS_LLCAST con->http.data_remaining, con->file);
 
-        if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0)
+        if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
          return (cupsdCloseClient(con));
        else if (bytes > 0)
        {
@@ -2025,7 +2026,7 @@ cupsdReadClient(cupsd_client_t *con)      /* I - Client to read from */
 
        if (con->http.state != HTTP_POST_SEND)
        {
-          if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0)
+          if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
            return (cupsdCloseClient(con));
          else if (bytes > 0)
          {
@@ -2588,7 +2589,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
       }
     }
 
-    if (httpWrite(HTTP(con), buf, bytes) < 0)
+    if (httpWrite2(HTTP(con), buf, bytes) < 0)
     {
       cupsdLogMessage(CUPSD_LOG_DEBUG2,
                       "cupsdWriteClient: %d Write of %d bytes failed!",
@@ -3485,5 +3486,5 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
 
 
 /*
- * End of "$Id: client.c 4950 2006-01-19 16:07:57Z mike $".
+ * End of "$Id: client.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 1849d64363e6031704dfdeb69f6c221414af7bf6..595cd825bc590c3fc6865f2e4d5d6754036baecb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: conf.c 5008 2006-01-27 19:30:34Z mike $"
+ * "$Id: conf.c 5020 2006-01-28 13:36:15Z mike $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
@@ -154,6 +154,10 @@ static cupsd_var_t variables[] =
   { "ServerKey",               &ServerKey,             CUPSD_VARTYPE_STRING },
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
 #endif /* HAVE_SSL */
+#ifdef HAVE_LAUNCHD
+  { "LaunchdTimeout",          &LaunchdTimeout,        CUPSD_VARTYPE_INTEGER },
+  { "LaunchdConf",             &LaunchdConf,           CUPSD_VARTYPE_STRING },
+#endif /* HAVE_LAUNCHD */
   { "ServerName",              &ServerName,            CUPSD_VARTYPE_STRING },
   { "ServerRoot",              &ServerRoot,            CUPSD_VARTYPE_STRING },
   { "StateDir",                        &StateDir,              CUPSD_VARTYPE_STRING },
@@ -208,12 +212,6 @@ cupsdReadConfiguration(void)
   char         *old_serverroot,        /* Old ServerRoot */
                *old_requestroot;       /* Old RequestRoot */
 
- /*
-  * Shutdown the server...
-  */
-
-  cupsdStopServer();
-
  /*
   * Save the old root paths...
   */
@@ -450,6 +448,11 @@ cupsdReadConfiguration(void)
   DefaultLeaseDuration       = 86400;
   MaxLeaseDuration           = 0;
 
+#ifdef HAVE_LAUNCHD
+  LaunchdTimeout = DEFAULT_TIMEOUT + 10;
+  cupsdSetString(&LaunchdConf, CUPS_DEFAULT_LAUNCHD_CONF);
+#endif /* HAVE_LAUNCHD */
+
  /*
   * Read the configuration file...
   */
@@ -1010,12 +1013,6 @@ cupsdReadConfiguration(void)
   cupsdClearString(&old_serverroot);
   cupsdClearString(&old_requestroot);
 
- /*
-  * Startup the server and return...
-  */
-
-  cupsdStartServer();
-
   return (1);
 }
 
@@ -1988,12 +1985,16 @@ read_configuration(cups_file_t *fp)     /* I - File to read from */
 
        memset(lis, 0, sizeof(cupsd_listener_t));
        memcpy(&(lis->address), &(addr->addr), sizeof(lis->address));
+       lis->fd = -1;
 
 #ifdef HAVE_SSL
         if (!strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen"))
           lis->encryption = HTTP_ENCRYPT_ALWAYS;
 #endif /* HAVE_SSL */
 
+
+       httpAddrString(&lis->address, temp, sizeof(temp));
+
 #ifdef AF_INET6
         if (lis->address.addr.sa_family == AF_INET6)
           cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv6)", temp,
@@ -3122,5 +3123,5 @@ read_policy(cups_file_t *fp,              /* I - Configuration file */
 
 
 /*
- * End of "$Id: conf.c 5008 2006-01-27 19:30:34Z mike $".
+ * End of "$Id: conf.c 5020 2006-01-28 13:36:15Z mike $".
  */
index 7f83f80da4dfd44bc58c3eed9c30038dd59a5ae2..00e98bc63f04523dfce48df29c7cc6f95622d3b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: conf.h 4988 2006-01-26 00:53:00Z mike $"
+ * "$Id: conf.h 5020 2006-01-28 13:36:15Z mike $"
  *
  *   Configuration file definitions for the Common UNIX Printing System (CUPS)
  *   scheduler.
@@ -192,6 +192,12 @@ VAR CFArrayRef             ServerCertificatesArray VALUE(NULL);
 #  endif /* HAVE_LIBSSL || HAVE_GNUTLS */
 #endif /* HAVE_SSL */
 
+#ifdef HAVE_LAUNCHD
+VAR int                        LaunchdTimeout          VALUE(DEFAULT_TIMEOUT);
+                                       /* Time after which an idle cupsd will exit */
+VAR char               *LaunchdConf            VALUE(NULL);
+                                       /* launchd(8) configuration file */
+#endif /* HAVE_LAUNCHD */
 
 /*
  * Prototypes...
@@ -209,5 +215,5 @@ extern int  cupsdLogPage(cupsd_job_t *job, const char *page);
 
 
 /*
- * End of "$Id: conf.h 4988 2006-01-26 00:53:00Z mike $".
+ * End of "$Id: conf.h 5020 2006-01-28 13:36:15Z mike $".
  */
index 25c9e8b8ddc3ef278e21c265a9e62b16a282d6cc..1f7bdcf0b8b63b3a815a0090385cff8fda7256c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cups-lpd.c 4807 2005-10-21 19:17:52Z mike $"
+ * "$Id: cups-lpd.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Line Printer Daemon interface for the Common UNIX Printing System (CUPS).
  *
@@ -324,8 +324,8 @@ check_printer(const char *name)             /* I - Printer or class name */
   request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
   request->request.op.request_id   = 1;
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", name);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", name);
 
   language = cupsLangDefault();
 
@@ -428,8 +428,8 @@ print_file(const char    *name,             /* I - Printer or class name */
   request->request.op.operation_id = IPP_PRINT_JOB;
   request->request.op.request_id   = 1;
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", name);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", name);
 
   language = cupsLangDefault();
 
@@ -1139,8 +1139,8 @@ send_state(const char *dest,              /* I - Destination */
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
                "attributes-natural-language", NULL, language->language);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", queue);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", queue);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1214,8 +1214,8 @@ send_state(const char *dest,              /* I - Destination */
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
                "attributes-natural-language", NULL, language->language);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", queue);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", queue);
 
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
                NULL, uri);
@@ -1437,5 +1437,5 @@ smart_gets(char *s,                       /* I - Pointer to line buffer */
 
 
 /*
- * End of "$Id: cups-lpd.c 4807 2005-10-21 19:17:52Z mike $".
+ * End of "$Id: cups-lpd.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 893ca6145a79153c52ffbb3b27834f72957800de..dd63491d96472125dbacb3b3b1fc7cf977e701d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: dirsvc.c 5008 2006-01-27 19:30:34Z mike $"
+ * "$Id: dirsvc.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Directory services routines for the Common UNIX Printing System (CUPS).
  *
@@ -458,8 +458,9 @@ cupsdProcessBrowseData(
   * Pull the URI apart to see if this is a local or remote printer...
   */
 
-  httpSeparateURI(uri, method, sizeof(method), username, sizeof(username),
-                  host, sizeof(host), &port, resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), username,
+                  sizeof(username), host, sizeof(host), &port, resource,
+                 sizeof(resource));
 
  /*
   * Determine if the URI contains any illegal characters in it...
@@ -1400,8 +1401,8 @@ cupsdSendCUPSBrowse(cupsd_printer_t *p)   /* I - Printer to send */
              iface->address.addr.sa_family != AF_INET)
            continue;
 
-         httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, iface->hostname,
-                          iface->port,
+         httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                          iface->hostname, iface->port,
                           (p->type & CUPS_PRINTER_CLASS) ? "/classes/%s%s" :
                                                            "/printers/%s",
                           p->name);
@@ -1442,8 +1443,8 @@ cupsdSendCUPSBrowse(cupsd_printer_t *p)   /* I - Printer to send */
 
         if (iface)
        {
-         httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, iface->hostname,
-                          iface->port,
+         httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                          iface->hostname, iface->port,
                           (p->type & CUPS_PRINTER_CLASS) ? "/classes/%s%s" :
                                                            "/printers/%s",
                           p->name);
@@ -2235,8 +2236,9 @@ cupsdUpdateCUPSBrowse(void)
   * Pull the URI apart to see if this is a local or remote printer...
   */
 
-  httpSeparateURI(uri, method, sizeof(method), username, sizeof(username),
-                  host, sizeof(host), &port, resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), username,
+                  sizeof(username), host, sizeof(host), &port, resource,
+                 sizeof(resource));
 
   DEBUG_printf(("host=\"%s\", ServerName=\"%s\"\n", host, ServerName));
 
@@ -2386,8 +2388,9 @@ cupsdUpdateSLPBrowse(void)
       * Pull the URI apart to see if this is a local or remote printer...
       */
 
-      httpSeparateURI(uri, method, sizeof(method), username, sizeof(username),
-                      host, sizeof(host), &port, resource, sizeof(resource));
+      httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method),
+                      username, sizeof(username), host, sizeof(host), &port,
+                     resource, sizeof(resource));
 
       if (strcasecmp(host, ServerName) == 0)
        continue;
@@ -2639,5 +2642,5 @@ slp_url_callback(
 
 
 /*
- * End of "$Id: dirsvc.c 5008 2006-01-27 19:30:34Z mike $".
+ * End of "$Id: dirsvc.c 5023 2006-01-29 14:39:44Z mike $".
  */
index b9da4e34e17b7a91e8730be5899707174ce5a847..ff659e5806f3f3a8434c86d3074dc6883d915545 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: dirsvc.h 4822 2005-11-04 21:13:20Z mike $"
+ * "$Id: dirsvc.h 5020 2006-01-28 13:36:15Z mike $"
  *
  *   Directory services definitions for the Common UNIX Printing System
  *   (CUPS) scheduler.
@@ -39,7 +39,8 @@
 #define BROWSE_CUPS    1               /* CUPS */
 #define        BROWSE_SLP      2               /* SLPv2 */
 #define BROWSE_LDAP    4               /* LDAP (not supported yet) */
-#define BROWSE_ALL     7               /* All protocols */
+#define BROWSE_DNSSD   8               /* DNS Service Discovery aka Bonjour */
+#define BROWSE_ALL     15              /* All protocols */
 
 
 /*
@@ -158,5 +159,5 @@ extern void cupsdUpdateSLPBrowse(void);
 
 
 /*
- * End of "$Id: dirsvc.h 4822 2005-11-04 21:13:20Z mike $".
+ * End of "$Id: dirsvc.h 5020 2006-01-28 13:36:15Z mike $".
  */
index f5b69ac4e587fd1f0f9661ad90437025ed171588..8dccbcfa1846423125dd8039a1afca18a7895e21 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $"
+ * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   IPP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -682,9 +682,9 @@ accept_jobs(cupsd_client_t  *con,   /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -762,9 +762,9 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
   * Do we have a valid URI?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
 
   if (strncmp(resource, "/classes/", 9) || strlen(resource) == 9)
@@ -1065,9 +1065,9 @@ add_class(cupsd_client_t  *con,           /* I - Client connection */
       * Search for the printer or class URI...
       */
 
-      httpSeparateURI(attr->values[i].string.text, method, sizeof(method),
-                      username, sizeof(username), host, sizeof(host), &port,
-                     resource, sizeof(resource));
+      httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, method,
+                      sizeof(method), username, sizeof(username), host,
+                     sizeof(host), &port, resource, sizeof(resource));
 
       if ((dest = cupsdValidateDest(host, resource, &dtype, &member)) == NULL)
       {
@@ -1452,9 +1452,9 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
   * Do we have a valid URI?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if (strncmp(resource, "/printers/", 10) || strlen(resource) == 10)
   {
@@ -1587,9 +1587,9 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
     * Do we have a valid device URI?
     */
 
-    httpSeparateURI(attr->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (!strcmp(method, "file"))
     {
@@ -2125,9 +2125,9 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
  
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -2301,9 +2301,9 @@ cancel_all_jobs(cupsd_client_t  *con,     /* I - Client connection */
   * And if the destination is valid...
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  userpass, sizeof(userpass), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), userpass, sizeof(userpass), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -2419,9 +2419,9 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
       * Find the current job on the specified printer...
       */
 
-      httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                      username, sizeof(username), host, sizeof(host), &port,
-                     resource, sizeof(resource));
+      httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                      sizeof(method), username, sizeof(username), host,
+                     sizeof(host), &port, resource, sizeof(resource));
 
       if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
       {
@@ -2470,9 +2470,9 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
  
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -3615,7 +3615,7 @@ copy_job_attrs(cupsd_client_t *con,       /* I - Client connection */
   * Send the requested attributes for each job...
   */
 
-  httpAssembleURIf(job_uri, sizeof(job_uri), "ipp", NULL,
+  httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
                    con->servername, con->serverport, "/jobs/%d",
                   job->id);
 
@@ -3734,9 +3734,9 @@ copy_printer_attrs(
       !ippFindAttribute(printer->attrs, "printer-uri-supported",
                         IPP_TAG_URI))
   {
-    httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
-                     con->servername, con->serverport, "/printers/%s",
-                    printer->name);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+                     "ipp", NULL, con->servername, con->serverport,
+                    "/printers/%s", printer->name);
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
                 "printer-uri-supported", NULL, printer_uri);
     cupsdLogMessage(CUPSD_LOG_DEBUG2, "printer-uri-supported=\"%s\"",
@@ -3821,9 +3821,9 @@ copy_subscription_attrs(
 
   if (sub->dest && (!ra || cupsArrayFind(ra, "notify-printer-uri")))
   {
-    httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
-                     con->servername, con->serverport, "/printers/%s",
-                    sub->dest->name);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+                     "ipp", NULL, con->servername, con->serverport,
+                    "/printers/%s", sub->dest->name);
     ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
                 "notify-printer-uri", NULL, printer_uri);
   }
@@ -3887,9 +3887,9 @@ create_job(cupsd_client_t  *con,  /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -4593,9 +4593,9 @@ create_subscription(
                   "cupsdCreateSubscription(con=%p(%d), uri=\"%s\")",
                   con, con->http.fd, uri->values[0].string.text);
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  userpass, sizeof(userpass), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), userpass, sizeof(userpass), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if (!strcmp(resource, "/"))
   {
@@ -4862,9 +4862,9 @@ delete_printer(cupsd_client_t  *con,      /* I - Client connection */
   * Do we have a valid URI?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -5132,9 +5132,9 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -5222,9 +5222,9 @@ get_jobs(cupsd_client_t  *con,            /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if (!strcmp(resource, "/") ||
       (!strncmp(resource, "/jobs", 5) && strlen(resource) <= 6))
@@ -5533,9 +5533,9 @@ get_printer_attrs(cupsd_client_t  *con,   /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -5821,9 +5821,9 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if (!strcmp(resource, "/") ||
       (!strncmp(resource, "/jobs", 5) && strlen(resource) <= 6) ||
@@ -5985,9 +5985,9 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -6120,9 +6120,9 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
     return;
   }
     
-  httpSeparateURI(attr->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((dest = cupsdValidateDest(host, resource, &dtype, &dprinter)) == NULL)
   {
@@ -6149,9 +6149,9 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
   * See if we have a job URI or a printer URI...
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if (!strcmp(uri->name, "printer-uri"))
   {
@@ -6664,9 +6664,9 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -7372,9 +7372,9 @@ reject_jobs(cupsd_client_t  *con, /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -7482,9 +7482,9 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -7629,9 +7629,9 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -7869,9 +7869,9 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -8258,9 +8258,9 @@ set_default(cupsd_client_t  *con, /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -8364,9 +8364,9 @@ set_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                    username, sizeof(username), host, sizeof(host), &port,
-                   resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                    sizeof(method), username, sizeof(username), host,
+                   sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
     {
@@ -8669,9 +8669,9 @@ start_printer(cupsd_client_t  *con,       /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -8749,9 +8749,9 @@ stop_printer(cupsd_client_t  *con,        /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
   {
@@ -8924,9 +8924,9 @@ validate_job(cupsd_client_t  *con,        /* I - Client connection */
   * Is the destination valid?
   */
 
-  httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
-                  username, sizeof(username), host, sizeof(host), &port,
-                 resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+                  sizeof(method), username, sizeof(username), host,
+                 sizeof(host), &port, resource, sizeof(resource));
 
   if (cupsdValidateDest(host, resource, &dtype, &printer) == NULL)
   {
@@ -9038,5 +9038,5 @@ validate_user(cupsd_job_t    *job,        /* I - Job */
 
 
 /*
- * End of "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $".
+ * End of "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $".
  */
index fe7ce5e307a5d4c2b29af538ef0e8aad344afa94..13c1260dd32cec064f9496c4b980a69a7414dc74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: job.c 5007 2006-01-27 18:25:42Z mike $"
+ * "$Id: job.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Job management routines for the Common UNIX Printing System (CUPS).
  *
@@ -874,9 +874,9 @@ cupsdLoadAllJobs(void)
        continue;
       }
 
-      httpSeparateURI(attr->values[0].string.text, method, sizeof(method),
-                      username, sizeof(username), host, sizeof(host), &port,
-                     resource, sizeof(resource));
+      httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+                      sizeof(method), username, sizeof(username), host,
+                     sizeof(host), &port, resource, sizeof(resource));
 
       if ((dest = cupsdValidateDest(host, resource, &(job->dtype),
                                     NULL)) == NULL)
@@ -2686,5 +2686,5 @@ set_hold_until(cupsd_job_t *job,  /* I - Job to update */
 
 
 /*
- * End of "$Id: job.c 5007 2006-01-27 18:25:42Z mike $".
+ * End of "$Id: job.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 176251cdcd820de2fc48884b2e96ed05b4aa5287..6c25221486f94bec8cfce66905ddd83f9a33cce3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: listen.c 4780 2005-10-13 00:38:28Z mike $"
+ * "$Id: listen.c 5020 2006-01-28 13:36:15Z mike $"
  *
  *   Server listening routines for the Common UNIX Printing System (CUPS)
  *   scheduler.
@@ -169,116 +169,124 @@ cupsdStartListening(void)
     p = ntohs(lis->address.ipv4.sin_port);
 
    /*
-    * Create a socket for listening...
+    * If needed, create a socket for listening...
     */
 
-    lis->fd = socket(lis->address.addr.sa_family, SOCK_STREAM, 0);
-
     if (lis->fd == -1)
     {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.",
-                      s, p, strerror(errno));
-      continue;
-    }
-
-    fcntl(lis->fd, F_SETFD, fcntl(lis->fd, F_GETFD) | FD_CLOEXEC);
-
-   /*
-    * Set things up to reuse the local address for this port.
-    */
-
-    val = 1;
-#ifdef __sun
-    setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
-#else
-    setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
-#endif /* __sun */
-
-   /*
-    * Bind to the port we found...
-    */
-
-#ifdef AF_INET6
-    if (lis->address.addr.sa_family == AF_INET6)
-    {
-#  ifdef IPV6_V6ONLY
-     /*
-      * Accept only IPv6 connections on this socket, to avoid
-      * potential security issues and to make all platforms behave
-      * the same.
-      */
-
-      val = 1;
-#    ifdef __sun
-      setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&val, sizeof(val));
-#    else
-      setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));
-#    endif /* __sun */
-#  endif /* IPV6_V6ONLY */
-
-      status = bind(lis->fd, (struct sockaddr *)&(lis->address),
-                   httpAddrLength(&(lis->address)));
-    }
-    else
-#endif /* AF_INET6 */
-#ifdef AF_LOCAL
-    if (lis->address.addr.sa_family == AF_LOCAL)
-    {
-      mode_t   mask;                   /* Umask setting */
-
-
      /*
-      * Remove any existing domain socket file...
+      * Create a socket for listening...
       */
-
-      unlink(lis->address.un.sun_path);
-
+  
+      lis->fd = socket(lis->address.addr.sa_family, SOCK_STREAM, 0);
+  
+      if (lis->fd == -1)
+      {
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.",
+                       s, p, strerror(errno));
+       continue;
+      }
+  
      /*
-      * Save the curent umask and set it to 0...
+      * Set things up to reuse the local address for this port.
       */
-
-      mask = umask(0);
-
+  
+      val = 1;
+  #ifdef __sun
+      setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
+  #else
+      setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+  #endif /* __sun */
+  
      /*
-      * Bind the domain socket...
+      * Bind to the port we found...
       */
-
+  
+  #ifdef AF_INET6
+      if (lis->address.addr.sa_family == AF_INET6)
+      {
+  #  ifdef IPV6_V6ONLY
+       /*
+       * Accept only IPv6 connections on this socket, to avoid
+       * potential security issues and to make all platforms behave
+       * the same.
+       */
+  
+       val = 1;
+  #    ifdef __sun
+       setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&val, sizeof(val));
+  #    else
+       setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));
+  #    endif /* __sun */
+  #  endif /* IPV6_V6ONLY */
+  
+       status = bind(lis->fd, (struct sockaddr *)&(lis->address),
+                     httpAddrLength(&(lis->address)));
+      }
+      else
+  #endif /* AF_INET6 */
+  #ifdef AF_LOCAL
+      if (lis->address.addr.sa_family == AF_LOCAL)
+      {
+       mode_t  mask;                   /* Umask setting */
+  
+  
+       /*
+       * Remove any existing domain socket file...
+       */
+  
+       unlink(lis->address.un.sun_path);
+  
+       /*
+       * Save the curent umask and set it to 0...
+       */
+  
+       mask = umask(0);
+  
+       /*
+       * Bind the domain socket...
+       */
+  
+       status = bind(lis->fd, (struct sockaddr *)&(lis->address),
+                     httpAddrLength(&(lis->address)));
+  
+       /*
+       * Restore the umask...
+       */
+  
+       umask(mask);
+      }
+      else
+  #endif /* AF_LOCAL */
       status = bind(lis->fd, (struct sockaddr *)&(lis->address),
-                   httpAddrLength(&(lis->address)));
-
+                   sizeof(lis->address.ipv4));
+  
+      if (status < 0)
+      {
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "cupsdStartListening: Unable to bind socket for address %s:%d - %s.",
+                       s, p, strerror(errno));
+       close(lis->fd);
+       lis->fd = -1;
+       continue;
+      }
+  
      /*
-      * Restore the umask...
+      * Listen for new clients.
       */
-
-      umask(mask);
+  
+      if (listen(lis->fd, ListenBackLog) < 0)
+      {
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.",
+                       s, p, strerror(errno));
+       exit(errno);
+      }
     }
-    else
-#endif /* AF_LOCAL */
-    status = bind(lis->fd, (struct sockaddr *)&(lis->address),
-                  sizeof(lis->address.ipv4));
 
-    if (status < 0)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "cupsdStartListening: Unable to bind socket for address %s:%d - %s.",
-                      s, p, strerror(errno));
-      close(lis->fd);
-      lis->fd = -1;
-      continue;
-    }
-
-   /*
-    * Listen for new clients.
-    */
-
-    if (listen(lis->fd, ListenBackLog) < 0)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.",
-                      s, p, strerror(errno));
-      exit(errno);
-    }
+    fcntl(lis->fd, F_SETFD, fcntl(lis->fd, F_GETFD) | FD_CLOEXEC);
+  
 
     if (p)
       cupsdLogMessage(CUPSD_LOG_INFO,
@@ -375,10 +383,12 @@ cupsdStopListening(void)
 
   for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
   {
+    if (lis->fd != -1)
+    {
 #ifdef WIN32
-    closesocket(lis->fd);
+      closesocket(lis->fd);
 #else
-    close(lis->fd);
+      close(lis->fd);
 #endif /* WIN32 */
 
 #ifdef AF_LOCAL
@@ -386,13 +396,14 @@ cupsdStopListening(void)
     * Remove domain sockets...
     */
 
-    if (lis->address.addr.sa_family == AF_LOCAL)
-      unlink(lis->address.un.sun_path);
+      if (lis->address.addr.sa_family == AF_LOCAL)
+       unlink(lis->address.un.sun_path);
 #endif /* AF_LOCAL */
+    }
   }
 }
 
 
 /*
- * End of "$Id: listen.c 4780 2005-10-13 00:38:28Z mike $".
+ * End of "$Id: listen.c 5020 2006-01-28 13:36:15Z mike $".
  */
index cb14f2b3769b958e7530d2f7200c25f0d228f5fc..365453657dc320950bb372a850255629bd2e1702 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: main.c 5007 2006-01-27 18:25:42Z mike $"
+ * "$Id: main.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   Scheduler main loop for the Common UNIX Printing System (CUPS).
  *
  *   cupsdReleaseSignals()     - Release signals for delivery.
  *   cupsdSetString()          - Set a string value.
  *   cupsdSetStringf()         - Set a formatted string value.
+ *   launchd_checkin()         - Check-in with launchd and collect the
+ *                               listening fds.
+ *   launchd_reload()          - Tell launchd to reload the configuration
+ *                               file to pick up the new listening directives.
+ *   launchd_sync_conf()       - Re-write the launchd(8) config file 
+ *                              com.easysw.cupsd.plist based on cupsd.conf.
  *   parent_handler()          - Catch USR1/CHLD signals...
  *   process_children()        - Process all dead children...
  *   sigchld_handler()         - Handle 'child' signals from old processes.
 #include <syslog.h>
 #include <grp.h>
 
+#ifdef HAVE_LAUNCH_H
+#  include <launch.h>
+#  include <libgen.h>
+#endif /* HAVE_LAUNCH_H */
+
 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
 #  include <malloc.h>
 #endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
  * Local functions...
  */
 
+#ifdef HAVE_LAUNCHD
+static void    launchd_checkin(void);
+static void    launchd_reload(void);
+static int     launchd_sync_conf(void);
+#endif /* HAVE_LAUNCHD */
+
 static void    parent_handler(int sig);
 static void    process_children(void);
 static void    sigchld_handler(int sig);
 static void    sighup_handler(int sig);
 static void    sigterm_handler(int sig);
 static long    select_timeout(int fds);
-static void    usage(void);
+static void    usage(int status);
 
 
 /*
@@ -105,7 +122,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
   cupsd_job_t          *job;           /* Current job */
   cupsd_listener_t     *lis;           /* Current listener */
   time_t               current_time,   /* Current time */
-                       activity,       /* Activity timer */
+                       activity,       /* Client activity timer */
                        browse_time,    /* Next browse send time */
                        senddoc_time,   /* Send-Document time */
                        expire_time;    /* Subscription expire time */
@@ -121,13 +138,21 @@ main(int  argc,                           /* I - Number of command-line arguments */
   cups_file_t          *fp;            /* Fake lpsched lock file */
   struct stat          statbuf;        /* Needed for checking lpsched FIFO */
 #endif /* __sgi */
+#if HAVE_LAUNCHD
+  int                  launchd,        /* Started with the -l option? */
+                       launchd_idle_exit;
+                                       /* Idle exit on select timeout? */
+#endif /* HAVE_LAUNCHD */
 
 
  /*
   * Check for command-line arguments...
   */
 
-  fg = 0;
+  fg      = 0;
+#if HAVE_LAUNCHD
+  launchd = 0;
+#endif /* HAVE_LAUNCHD */
 
   for (i = 1; i < argc; i ++)
     if (argv[i][0] == '-')
@@ -137,7 +162,11 @@ main(int  argc,                            /* I - Number of command-line arguments */
          case 'c' : /* Configuration file */
              i ++;
              if (i >= argc)
-               usage();
+             {
+               _cupsLangPuts(stderr, _("cupsd: Expected config filename "
+                                       "after \"-c\" option!\n"));
+               usage(1);
+             }
 
               if (argv[i][0] == '/')
              {
@@ -180,16 +209,32 @@ main(int  argc,                           /* I - Number of command-line arguments */
              fg = -1;
              break;
 
+          case 'h' : /* Show usage/help */
+             usage(0);
+             break;
+
+          case 'l' : /* Started by launchd... */
+#ifdef HAVE_LAUNCHD
+             launchd = 1;
+             fg      = 1;
+#else
+             _cupsLangPuts(stderr, _("cupsd: launchd(8) support not compiled "
+                                     "in, running in normal mode.\n"));
+              fg = 0;
+#endif /* HAVE_LAUNCHD */
+             break;
+
          default : /* Unknown option */
-              fprintf(stderr, "cupsd: Unknown option \'%c\' - aborting!\n",
-                     *opt);
-             usage();
+              _cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
+                                       "aborting!\n"), *opt);
+             usage(1);
              break;
        }
     else
     {
-      fprintf(stderr, "cupsd: Unknown argument \'%s\' - aborting!\n", argv[i]);
-      usage();
+      _cupsLangPrintf(stderr, _("cupsd: Unknown argument \"%s\" - aborting!\n"),
+                      argv[i]);
+      usage(1);
     }
 
   if (!ConfigurationFile)
@@ -349,6 +394,37 @@ main(int  argc,                            /* I - Number of command-line arguments */
     return (1);
   }
 
+#if HAVE_LAUNCHD
+  if (launchd)
+  {
+   /*
+    * If we were started by launchd make sure the cupsd plist file contains the
+    * same listeners as cupsd.conf; If it didn't then reload it before getting
+    * the list of listening file descriptors...
+    */
+
+    if (launchd_sync_conf())
+    {
+      launchd_reload();
+
+     /*
+      * Until rdar://3854821 is fixed we have to exit after the reload...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_DEBUG2, "Exiting on launchd_reload");
+      exit(0);
+    }
+
+    launchd_checkin();
+  }
+#endif /* HAVE_LAUNCHD */
+
+ /*
+  * Startup the server...
+  */
+
+  cupsdStartServer();
+
  /*
   * Catch hangup and child signals and ignore broken pipes...
   */
@@ -539,12 +615,48 @@ main(int  argc,                           /* I - Number of command-line arguments */
       if ((NumClients == 0 && (!job || NeedReload != RELOAD_ALL)) ||
           (time(NULL) - ReloadTime) >= ReloadTimeout)
       {
+       /*
+       * Shutdown the server...
+       */
+
+       cupsdStopServer();
+
+       /*
+       * Read configuration...
+       */
+
         if (!cupsdReadConfiguration())
         {
           syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!",
                 ConfigurationFile);
           break;
        }
+
+#if HAVE_LAUNCHD
+       if (launchd)
+       {
+         if (launchd_sync_conf())
+         {
+           launchd_reload();
+
+          /*
+           * Until rdar://3854821 is fixed we have to exit after the reload...
+           */
+
+           cupsdLogMessage(CUPSD_LOG_DEBUG2, "Exiting on launchd_reload");
+           stop_scheduler = 1;
+           break;
+         }
+
+         launchd_checkin();
+       }
+#endif /* HAVE_LAUNCHD */
+
+       /*
+        * Startup the server...
+        */
+
+        cupsdStartServer();
       }
     }
 
@@ -562,6 +674,24 @@ main(int  argc,                            /* I - Number of command-line arguments */
     timeout.tv_sec  = select_timeout(fds);
     timeout.tv_usec = 0;
 
+#if HAVE_LAUNCHD
+   /*
+    * If no other work is scheduled and we're being controlled by
+    * launchd(8) then timeout after 'LaunchdTimeout' seconds of
+    * inactivity...
+    */
+
+    if (timeout.tv_sec == 86400 && launchd && LaunchdTimeout && 
+       (!Browsing || !(BrowseLocalProtocols & BROWSE_DNSSD) ||
+        cupsArrayCount(Printers) == 0))
+    {
+      timeout.tv_sec    = LaunchdTimeout;
+      launchd_idle_exit = 1;
+    }
+    else
+      launchd_idle_exit = 0;
+#endif /* HAVE_LAUNCHD */
+
     if (timeout.tv_sec < 86400)                /* Only use timeout for < 1 day */
       fds = select(MaxFDs, input, output, NULL, &timeout);
     else
@@ -646,6 +776,22 @@ main(int  argc,                            /* I - Number of command-line arguments */
 
     current_time = time(NULL);
 
+#if HAVE_LAUNCHD
+   /*
+    * If no other work was scheduled and we're being controlled by launchd(8)
+    * then timeout after 'LaunchdTimeout' seconds of inactivity...
+    */
+
+    if (!fds && launchd_idle_exit)
+    {
+      cupsdLogMessage(CUPSD_LOG_INFO,
+                      "Printer sharing is off and there are no jobs pending, "
+                     "will restart on demand.");
+      stop_scheduler = 1;
+      break;
+    }
+#endif /* HAVE_LAUNCHD */
+
    /*
     * Check for status info from job filters...
     */
@@ -926,6 +1072,14 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
   cupsdStopSystemMonitor();
 
+#ifdef HAVE_LAUNCHD
+ /*
+  * Update the launchd config file as needed...
+  */
+
+  launchd_sync_conf();
+#endif /* HAVE_LAUNCHD */
+
 #ifdef __sgi
  /*
   * Remove the fake IRIX lpsched lock file, but only if the existing
@@ -1193,6 +1347,553 @@ cupsdSetStringf(char       **s,         /* O - New string */
 }
 
 
+#ifdef HAVE_LAUNCHD
+/*
+ * 'launchd_checkin()' - Check-in with launchd and collect the listening fds.
+ */
+
+static void
+launchd_checkin(void)
+{
+  int                  i,              /* Looping var */
+                       portnum;        /* Port number */
+  launch_data_t                ld_msg,         /* Launch data message */
+                       ld_resp,        /* Launch data response */
+                       ld_array,       /* Launch data array */
+                       ld_sockets,     /* Launch data sockets dictionary */
+                       ld_runatload,   /* Run-at-load setting */
+                       tmp;            /* Launch data */
+  cupsd_listener_t     *lis;           /* Listeners array */
+  http_addr_t          addr;           /* Address variable */
+  socklen_t            addrlen;        /* Length of address */
+  bool                 runatload;      /* Run-at-load setting value */
+
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: pid=%d", (int)getpid());
+
+ /*
+  * Check-in with launchd...
+  */
+
+  ld_msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
+  if ((ld_resp = launch_msg(ld_msg)) == NULL)
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR, 
+                   "launchd_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
+                   "\") IPC failure");
+    exit(EXIT_FAILURE);
+  }
+  
+  if (launch_data_get_type(ld_resp) == LAUNCH_DATA_ERRNO)
+  {
+    errno = launch_data_get_errno(ld_resp);
+    cupsdLogMessage(CUPSD_LOG_ERROR, "launchd_checkin: Check-in failed: %s",
+                    strerror(errno));
+    exit(EXIT_FAILURE);
+  }
+
+ /*
+  * Get the "run-at-load" setting...
+  */
+
+  if ((ld_runatload = launch_data_dict_lookup(ld_resp,
+                                              LAUNCH_JOBKEY_RUNATLOAD)) != NULL &&
+      launch_data_get_type(ld_runatload) == LAUNCH_DATA_BOOL)
+    runatload = launch_data_get_bool(ld_runatload);
+  else
+  {
+    errno = launch_data_get_errno(ld_resp);
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "launchd_checkin: Unable to find Run-at-load setting: %s",
+                    strerror(errno));
+    exit(EXIT_FAILURE);
+  }
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: Run-at-load=%s",
+                  runatload ? "true" : "false");
+
+ /*
+  * Get the sockets dictionary...
+  */
+
+  if (!(ld_sockets = launch_data_dict_lookup(ld_resp, LAUNCH_JOBKEY_SOCKETS)))
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "launchd_checkin: No sockets found to answer requests on!");
+    exit(EXIT_FAILURE);
+  }
+  
+ /*
+  * Get the array of listener sockets...
+  */
+
+  if (!(ld_array = launch_data_dict_lookup(ld_sockets, "Listeners")))
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "launchd_checkin: No sockets found to answer requests on!");
+    exit(EXIT_FAILURE);
+  }
+
+ /*
+  * Add listening fd(s) to the Listener array...
+  */
+
+  if (launch_data_get_type(ld_array) == LAUNCH_DATA_ARRAY)
+  {
+   /*
+    * Free the listeners array built from cupsd.conf...
+    */
+  
+    if (NumListeners > 0)
+      free(Listeners);
+  
+    NumListeners = launch_data_array_get_count(ld_array);
+    Listeners    = calloc(NumListeners, sizeof(cupsd_listener_t));
+
+    if (!Listeners)
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "launchd_checkin: Unable to allocate new Listeners - %s.",
+                      strerror(errno));
+      exit(EXIT_FAILURE);
+    }
+
+   /*
+    * Note: launchd wants us to access the array in ascending order,
+    * thus "i" counts up and not down as we normally do elsewhere...
+    */
+
+    for (i = 0, lis = Listeners; i < NumListeners; i ++, lis ++)
+    {
+     /*
+      * Copy the current address and log it...
+      */
+  
+      tmp     = launch_data_array_get_index(ld_array, i);
+      lis->fd = launch_data_get_fd(tmp);
+      addrlen = sizeof(lis->address);
+
+      if (getsockname(lis->fd, (struct sockaddr *)&(lis->address), &addrlen))
+      {
+       cupsdLogMessage(CUPSD_LOG_ERROR,
+                       "launchd_checkin: Unable to get local address - %s",
+                       strerror(errno));
+      }
+    
+#  ifdef HAVE_SSL
+      portnum = 0;
+  
+#    ifdef AF_INET6
+      if (addr.addr.sa_family == AF_INET6)
+       portnum = ntohs(addr.ipv6.sin6_port);
+      else
+#    endif /* AF_INET6 */
+#    ifdef AF_LOCAL
+      if (addr.addr.sa_family == AF_LOCAL)
+      {
+       /*
+       * Make sure the domain socket is accessible to all...
+       */
+
+       fchmod(lis->fd, 0140777);
+      }
+      else
+#    endif /* AF_LOCAL */
+      if (addr.addr.sa_family == AF_INET)
+       portnum = ntohs(addr.ipv4.sin_port);
+
+      if (portnum == 443)
+       lis->encryption = HTTP_ENCRYPT_ALWAYS;
+#  endif /* HAVE_SSL */
+    }
+  }
+
+ /*
+  * Collect the browse socket (if there is one)...
+  */
+
+  if ((ld_array = launch_data_dict_lookup(ld_sockets, "BrowseSockets")))
+  {
+    if (launch_data_get_type(ld_array) == LAUNCH_DATA_ARRAY)
+    {
+      tmp = launch_data_array_get_index(ld_array, 0);
+
+      if (launch_data_get_type(tmp) == LAUNCH_DATA_FD)
+      {
+        if (BrowseSocket != -1)
+         close(BrowseSocket);
+
+       BrowseSocket = launch_data_get_fd(tmp);
+      }
+      else
+       cupsdLogMessage(CUPSD_LOG_WARN,
+                       "launchd_checkin: BrowseSocket not a fd!");
+   }
+   else
+     cupsdLogMessage(CUPSD_LOG_WARN,
+                     "launchd_checkin: BrowseSockets is not an array!");
+  }
+  else
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: No BrowseSockets");
+
+  launch_data_free(ld_msg);
+  launch_data_free(ld_resp);
+}
+
+
+/*
+ * 'launchd_reload()' - Tell launchd to reload the configuration file to pick
+ *                      up the new listening directives.
+ */
+
+static void
+launchd_reload(void)
+{
+  int          child_status;           /* Exit status of child process */
+  pid_t                child_pid,              /* Child PID */
+               waitpid_status;         /* Child process exit status */
+  char         *argv[4];               /* Argument strings */
+
+
+ /*
+  * The current launchd doesn't support a reload option (rdar://3854821).
+  * Until this is fixed we need to reload the config file by execing launchctl
+  * twice (to unload then load). NOTE: This will cause us to exit on SIGTERM
+  * which will cancel all client & job activity.
+  *
+  * After this is fixed we'll be able to tell launchd to reload the file
+  * and pick up the new listening descriptors without disrupting current
+  * activity.
+  */
+
+ /*
+  * Unloading the current configuration will cause launchd to send us a SIGTERM;
+  * block it for now so we can get our work done...
+  */
+
+  cupsdHoldSignals();
+
+ /*
+  * Set up the unload arguments to launchctl...
+  */
+
+  argv[0] = "/bin/launchctl";
+  argv[1] = "unload";
+  argv[2] = LaunchdConf;
+  argv[3] = NULL;
+
+  if (cupsdStartProcess(argv[0], argv, NULL, -1, -1, -1, -1, 1, &child_pid) < 0)
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "launchd_reload: Unable to execute %s - %s", argv[0],
+                    strerror(errno));
+  else
+  {
+    do
+    {
+      waitpid_status = waitpid(child_pid, &child_status, 0);
+    }
+    while (waitpid_status == (pid_t)-1 && errno == EINTR);
+
+    if (WIFSIGNALED(child_status))
+      cupsdLogMessage(CUPSD_LOG_DEBUG,
+                      "launchd_reload: %s pid %d crashed on signal %d!", 
+                     basename(argv[0]), child_pid, WTERMSIG(child_status));
+    else
+      cupsdLogMessage(CUPSD_LOG_DEBUG,
+                      "launchd_reload: %s pid %d stopped with status %d!", 
+                     basename(argv[0]), child_pid, WEXITSTATUS(child_status));
+
+   /*
+    * Do it again with the load command...
+    */
+  
+    argv[1] = "load";
+
+    if (cupsdStartProcess(argv[0], argv, NULL, -1, -1, -1, -1, 1,
+                          &child_pid) < 0)
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                      "launchd_reload: Unable to fork for %s - %s", argv[0],
+                      strerror(errno));
+    }
+    else
+    {
+      do
+      {
+       waitpid_status = waitpid(child_pid, &child_status, 0);
+      } while (waitpid_status == (pid_t)-1 && errno == EINTR);
+
+      if (WIFSIGNALED(child_status))
+       cupsdLogMessage(CUPSD_LOG_DEBUG,
+                       "launchd_reload: %s pid %d crashed on signal %d!",
+                       basename(argv[0]), child_pid, WTERMSIG(child_status));
+      else
+       cupsdLogMessage(CUPSD_LOG_DEBUG,
+                       "launchd_reload: %s pid %d stopped with status %d",
+                       basename(argv[0]), child_pid,
+                       WEXITSTATUS(child_status));
+    }
+  }
+
+ /*
+  * Leave signals blocked since exit() will be called momentarily anyways...
+  */
+}
+
+
+/*
+ * 'launchd_sync_conf()' - Re-write the launchd(8) config file 
+ *                        org.cups.cupsd.plist based on cupsd.conf.
+ */
+
+static int                             /* O - 1 if the file was updated */
+launchd_sync_conf(void)
+{
+  int                    i,            /* Looping var */
+                         portnum;      /* Port number */
+  CFMutableDictionaryRef  cupsd_dict,  /* com.easysw.cupsd.plist dictionary */
+                         sockets,      /* Sockets dictionary */
+                         listener;     /* Listener dictionary */
+  CFDataRef              resourceData; /* XML representation of the property list */
+  CFMutableArrayRef      array;        /* Array */
+  CFNumberRef            socket_mode;  /* Domain socket mode bits */
+  CFStringRef            socket_path;  /* Domain socket path */
+  CFTypeRef              value;        /* CF value */
+  CFURLRef               fileURL;      /* File URL */
+  SInt32                 errorCode;    /* Error code */
+  cupsd_listener_t       *lis;         /* Current listening socket */
+  struct servent         *service;     /* Services data base entry */
+  char                   temp[1024];   /* Temporary buffer for value */
+  struct stat            cupsd_sb,     /* File info for cupsd.conf */
+                         launchd_sb;   /* File info for com.easysw.cupsd.plist */
+
+
+ /*
+  * If the launchd conf file modification time is newer than the cupsd.conf
+  * time then there's nothing to do...
+  */
+
+  if (!stat(ConfigurationFile, &cupsd_sb) && 
+      !stat(LaunchdConf, &launchd_sb) && 
+      launchd_sb.st_mtimespec.tv_sec >= cupsd_sb.st_mtimespec.tv_sec)
+  {
+    cupsdLogMessage(CUPSD_LOG_DEBUG,
+                    "launchd_sync_conf: Nothing to do, pid=%d.", 
+                   (int)getpid());
+    return (0);
+  }
+
+ /*
+  * Time to write a new 'com.easysw.cupsd.plist' file.
+  * Create the new dictionary and populate it with values...
+  */
+
+  if ((cupsd_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+                               &kCFTypeDictionaryKeyCallBacks,
+                               &kCFTypeDictionaryValueCallBacks)) != NULL)
+  {
+    CFDictionaryAddValue(cupsd_dict, CFSTR("Label"), CFSTR("org.cups.cupsd"));
+    CFDictionaryAddValue(cupsd_dict, CFSTR("Enabled"), kCFBooleanTrue);
+    CFDictionaryAddValue(cupsd_dict, CFSTR("OnDemand"), kCFBooleanTrue);
+
+    if ((Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)) ||
+        cupsArrayCount(ActiveJobs))
+      CFDictionaryAddValue(cupsd_dict, CFSTR("RunAtLoad"), kCFBooleanTrue);
+    else
+      CFDictionaryAddValue(cupsd_dict, CFSTR("RunAtLoad"), kCFBooleanFalse);
+
+    CFDictionaryAddValue(cupsd_dict, CFSTR("ServiceIPC"), kCFBooleanTrue);
+
+    if ((array = CFArrayCreateMutable(kCFAllocatorDefault, 2,
+                                      &kCFTypeArrayCallBacks)) != NULL)
+    {
+      CFDictionaryAddValue(cupsd_dict, CFSTR("ProgramArguments"), array);
+      CFArrayAppendValue(array, CFSTR("/usr/sbin/cupsd"));
+      CFArrayAppendValue(array, CFSTR("-l"));
+      CFRelease(array);
+    }
+
+   /*
+    * Add a sockets dictionary...
+    */
+  
+    if ((sockets = (CFMutableDictionaryRef)CFDictionaryCreateMutable(
+                               kCFAllocatorDefault, 0,
+                               &kCFTypeDictionaryKeyCallBacks,
+                               &kCFTypeDictionaryValueCallBacks)) != NULL)
+    {
+      CFDictionaryAddValue(cupsd_dict, CFSTR("Sockets"), sockets);
+
+     /*
+      * Add a Listeners array to the sockets dictionary...
+      */
+    
+      if ((array = CFArrayCreateMutable(kCFAllocatorDefault, 0,
+                                        &kCFTypeArrayCallBacks)) != NULL)
+      {
+       CFDictionaryAddValue(sockets, CFSTR("Listeners"), array);
+
+       /*
+       * For each listener add a dictionary to the listeners array...
+       */
+      
+        for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
+       {
+         if ((listener = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+                               &kCFTypeDictionaryKeyCallBacks,
+                               &kCFTypeDictionaryValueCallBacks)) != NULL)
+         {
+           CFArrayAppendValue(array, listener);
+
+#  ifdef AF_LOCAL
+           if (lis->address.addr.sa_family == AF_LOCAL)
+           {
+             if ((socket_path = CFStringCreateWithCString(kCFAllocatorDefault, 
+                                       lis->address.un.sun_path, 
+                                       kCFStringEncodingUTF8)))
+             {
+               CFDictionaryAddValue(listener, CFSTR("SockPathName"),
+                                    socket_path);
+               CFRelease(socket_path);
+             }
+             portnum = 0140777; /* (S_IFSOCK|S_IRWXU|S_IRWXG|S_IRWXO) or *
+                                 * 49663d decimal                        */
+             if ((socket_mode = CFNumberCreate(kCFAllocatorDefault,
+                                               kCFNumberIntType, &portnum)))
+             {
+               CFDictionaryAddValue(listener, CFSTR("SockPathMode"),
+                                    socket_mode);
+               CFRelease(socket_mode);
+             }
+           }
+           else
+#  endif /* AF_LOCAL */
+           {
+#  ifdef AF_INET6
+             if (lis->address.addr.sa_family == AF_INET6)
+             {
+               CFDictionaryAddValue(listener, CFSTR("SockFamily"),
+                                    CFSTR("IPv6"));
+               portnum = lis->address.ipv6.sin6_port;
+             }
+             else
+#  endif /* AF_INET6 */
+             {
+               CFDictionaryAddValue(listener, CFSTR("SockFamily"),
+                                    CFSTR("IPv4"));
+               portnum = lis->address.ipv4.sin_port;
+             }
+
+             if ((service = getservbyport(portnum, NULL)))
+               value = CFStringCreateWithCString(kCFAllocatorDefault, 
+                                                 service->s_name, 
+                                                 kCFStringEncodingUTF8);
+             else
+               value = CFNumberCreate(kCFAllocatorDefault, 
+                                      kCFNumberIntType, &portnum);
+
+             if (value)
+             {
+               CFDictionaryAddValue(listener, CFSTR("SockServiceName"), value);
+               CFRelease(value);
+             } 
+
+             httpAddrString(&lis->address, temp, sizeof(temp));
+             if ((value = CFStringCreateWithCString(kCFAllocatorDefault, temp, 
+                                                    kCFStringEncodingUTF8)))
+             {
+               CFDictionaryAddValue(listener, CFSTR("SockNodeName"), value);
+               CFRelease(value);
+             }
+           }
+
+           CFRelease(listener);
+         }
+       }
+
+       CFRelease(array);
+      }
+
+     /*
+      * Add the BrowseSocket to the sockets dictionary...
+      */
+      
+      if (Browsing && (BrowseRemoteProtocols & BROWSE_CUPS))
+      {
+       if ((array = CFArrayCreateMutable(kCFAllocatorDefault, 0, 
+                                         &kCFTypeArrayCallBacks)) != NULL)
+       {
+         CFDictionaryAddValue(sockets, CFSTR("BrowseSockets"), array);
+
+         if ((listener = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+                                 &kCFTypeDictionaryKeyCallBacks,
+                                 &kCFTypeDictionaryValueCallBacks)) != NULL)
+         {
+           CFArrayAppendValue(array, listener);
+
+           CFDictionaryAddValue(listener, CFSTR("SockFamily"), CFSTR("IPv4"));
+           CFDictionaryAddValue(listener, CFSTR("SockType"), CFSTR("dgram"));
+
+           if ((service = getservbyport(BrowsePort, NULL)))
+             value = CFStringCreateWithCString(kCFAllocatorDefault, 
+                                               service->s_name, 
+                                               kCFStringEncodingUTF8);
+           else
+             value = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, 
+                                    &BrowsePort);
+
+           CFDictionaryAddValue(listener, CFSTR("SockServiceName"), value);
+           CFRelease(value);
+
+           CFRelease(listener);
+         }
+
+         CFRelease(array);
+       }
+      }
+
+      CFRelease(sockets);
+    }
+
+    cupsdLogMessage(CUPSD_LOG_DEBUG,
+                    "launchd_sync_conf: Updating \"%s\", pid=%d\n", 
+                   LaunchdConf, (int)getpid());
+  
+    if ((fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, 
+                               (const unsigned char *)LaunchdConf, 
+                               strlen(LaunchdConf), false)))
+    {
+      if ((resourceData = CFPropertyListCreateXMLData(kCFAllocatorDefault,
+                                                      cupsd_dict)))
+      {
+       if (!CFURLWriteDataAndPropertiesToResource(fileURL, resourceData,
+                                                  NULL, &errorCode))
+       {
+         cupsdLogMessage(CUPSD_LOG_WARN,
+                         "launchd_sync_conf: "
+                         "CFURLWriteDataAndPropertiesToResource(\"%s\") "
+                         "failed: %d\n", 
+                         LaunchdConf, (int)errorCode);
+        }
+
+       CFRelease(resourceData);
+      }
+
+      CFRelease(fileURL);
+    }
+
+    CFRelease(cupsd_dict);
+  }
+
+ /*
+  * Let the caller know we updated the file...
+  */
+
+  return (1);
+}
+#endif /* HAVE_LAUNCHD */
+
+
 /*
  * 'parent_handler()' - Catch USR1/CHLD signals...
  */
@@ -1576,13 +2277,20 @@ select_timeout(int fds)                 /* I - Number of ready descriptors select returned */
  */
 
 static void
-usage(void)
+usage(int status)                      /* O - Exit status */
 {
-  fputs("Usage: cupsd [-c config-file] [-f] [-F]\n", stderr);
-  exit(1);
+  _cupsLangPuts(status ? stderr : stdout,
+                _("Usage: cupsd [-c config-file] [-f] [-F] [-h] [-l]\n"
+                 "\n"
+                 "-c config-file      Load alternate configuration file\n"
+                 "-f                  Run in the foreground\n"
+                 "-F                  Run in the foreground but detach\n"
+                 "-h                  Show this usage message\n"
+                 "-l                  Run cupsd from launchd(8)\n"));
+  exit(status);
 }
 
 
 /*
- * End of "$Id: main.c 5007 2006-01-27 18:25:42Z mike $".
+ * End of "$Id: main.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 7718cb3850472e928f9bfc433019b98ec9214752..de312d3138e1facba4f124a7ae33ee437ac896ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: sysman.c 5007 2006-01-27 18:25:42Z mike $"
+ * "$Id: sysman.c 5018 2006-01-28 06:06:55Z mike $"
  *
  *   System management definitions for the Common UNIX Printing System (CUPS).
  *
@@ -106,11 +106,11 @@ cupsdUpdateSystemMonitor(void)
  * Constants...
  */
 
-#define SYSEVENT_CANSLEEP      0x1     /* Decide whether to allow sleep or not */
-#define SYSEVENT_WILLSLEEP     0x2     /* Computer will go to sleep */
-#define SYSEVENT_WOKE          0x4     /* Computer woke from sleep */
-#define SYSEVENT_NETCHANGED    0x8     /* Network changed */
-#define SYSEVENT_NAMECHANGED   0x10    /* Computer name changed */
+#  define SYSEVENT_CANSLEEP    0x1     /* Decide whether to allow sleep or not */
+#  define SYSEVENT_WILLSLEEP   0x2     /* Computer will go to sleep */
+#  define SYSEVENT_WOKE                0x4     /* Computer woke from sleep */
+#  define SYSEVENT_NETCHANGED  0x8     /* Network changed */
+#  define SYSEVENT_NAMECHANGED 0x10    /* Computer name changed */
 
 
 /* 
@@ -167,7 +167,6 @@ static void sysEventConfigurationNotifier(SCDynamicStoreRef store,
                                              CFArrayRef changedKeys,
                                              void *context);
 static void    sysEventTimerNotifier(CFRunLoopTimerRef timer, void *context);
-#endif /* __APPLE__ */
 
 
 /*
@@ -741,8 +740,9 @@ sysEventTimerNotifier(
     threadData->sysevent.event = 0;
   }
 }
+#endif /* __APPLE__ */
 
 
 /*
- * End of "$Id: sysman.c 5007 2006-01-27 18:25:42Z mike $".
+ * End of "$Id: sysman.c 5018 2006-01-28 06:06:55Z mike $".
  */
index e0cc817d1d2283e683de678033e20e35cfe1b6cf..6ffbfb167ec28fda559db4e5a67b995c4d8eba46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: accept.c 4990 2006-01-26 02:21:45Z mike $"
+ * "$Id: accept.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "accept", "disable", "enable", and "reject" commands for the Common
  *   UNIX Printing System (CUPS).
@@ -206,8 +206,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
       request = ippNewRequest(op);
 
-      httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                       "/printers/%s", argv[i]);
+      httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                       "localhost", 0, "/printers/%s", argv[i]);
       ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                    "printer-uri", NULL, uri);
 
@@ -286,5 +286,5 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: accept.c 4990 2006-01-26 02:21:45Z mike $".
+ * End of "$Id: accept.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 66394b9a380cfff6238231937ad6c753998c128d..f0539d9734d9723095d0933948fec0b797c015b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cancel.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: cancel.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "cancel" command for the Common UNIX Printing System (CUPS).
  *
@@ -266,8 +266,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
       if (dest)
       {
-       httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                        "/printers/%s", dest);
+       httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                        "localhost", 0, "/printers/%s", dest);
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                     "printer-uri", NULL, uri);
        ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
@@ -388,5 +388,5 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
 
 /*
- * End of "$Id: cancel.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: cancel.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 77aa46c3f4dd879d622379ad7f116140980669d2..b1cad6572c1050ca9fbbe0f6c7507b6814b14b46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cupsaddsmb.c 4933 2006-01-16 00:26:57Z mike $"
+ * "$Id: cupsaddsmb.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "cupsaddsmb" command for the Common UNIX Printing System (CUPS).
  *
@@ -576,8 +576,8 @@ export_dest(const char *dest)               /* I - Destination to export */
 
   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", dest);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", dest);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1026,5 +1026,5 @@ write_option(FILE            *dstfp,      /* I - PPD file */
 
 
 /*
- * End of "$Id: cupsaddsmb.c 4933 2006-01-16 00:26:57Z mike $".
+ * End of "$Id: cupsaddsmb.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 02b441f43dfa830ff36828b805b1abad3875fd71..2cfe3281919a63f9d1022b0152d8c46837d20a4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpadmin.c 4925 2006-01-13 02:52:47Z mike $"
+ * "$Id: lpadmin.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "lpadmin" command for the Common UNIX Printing System (CUPS).
  *
@@ -842,8 +842,8 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
 
   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/classes/%s", pclass);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/classes/%s", pclass);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -889,8 +889,8 @@ add_printer_to_class(http_t *http,  /* I - Server connection */
   * OK, the printer isn't part of the class, so add it...
   */
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
 
   if (response != NULL &&
       (members = ippFindAttribute(response, "member-uris", IPP_TAG_URI)) != NULL)
@@ -962,8 +962,8 @@ default_printer(http_t *http,               /* I - Server connection */
   *    printer-uri
   */
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
 
   request = ippNewRequest(CUPS_SET_DEFAULT);
 
@@ -1023,8 +1023,8 @@ delete_printer(http_t *http,              /* I - Server connection */
 
   request = ippNewRequest(CUPS_DELETE_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1087,8 +1087,8 @@ delete_printer_from_class(
 
   request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/classes/%s", pclass);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/classes/%s", pclass);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1237,8 +1237,8 @@ enable_printer(http_t *http,              /* I - Server connection */
 
   request = ippNewRequest(CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1350,8 +1350,8 @@ set_printer_device(http_t *http,  /* I - Server connection */
 
   request = ippNewRequest(CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1473,8 +1473,8 @@ set_printer_file(http_t *http,            /* I - Server connection */
 
   request = ippNewRequest(CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1533,8 +1533,8 @@ set_printer_info(http_t *http,            /* I - Server connection */
 
   request = ippNewRequest(CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1599,8 +1599,8 @@ set_printer_location(http_t *http,        /* I - Server connection */
 
   request = ippNewRequest(CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1664,8 +1664,8 @@ set_printer_model(http_t *http,           /* I - Server connection */
 
   request = ippNewRequest(CUPS_ADD_PRINTER);
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                "printer-uri", NULL, uri);
 
@@ -1730,8 +1730,8 @@ set_printer_options(
   DEBUG_printf(("set_printer_options(%p, \"%s\", %d, %p)\n", http, printer,
                 num_options, options));
 
-  httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", printer);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                   "localhost", 0, "/printers/%s", printer);
 
  /*
   * Build a GET_PRINTER_ATTRIBUTES request, which requires the following
@@ -1768,8 +1768,8 @@ set_printer_options(
       if (attr->values[0].integer & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
       {
         op = CUPS_ADD_CLASS;
-       httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
-                        "/classes/%s", printer);
+       httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                        "localhost", 0, "/classes/%s", printer);
       }
     }
 
@@ -1947,5 +1947,5 @@ validate_name(const char *name)           /* I - Name to check */
 
 
 /*
- * End of "$Id: lpadmin.c 4925 2006-01-13 02:52:47Z mike $".
+ * End of "$Id: lpadmin.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 27889fbd0bb87e3722975c8ee8e8f66f95c90924..8f9fdefbfc6484115ce87eaa1d882e0f8dc592c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpmove.c 4945 2006-01-18 21:41:17Z mike $"
+ * "$Id: lpmove.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "lpmove" command for the Common UNIX Printing System (CUPS).
  *
@@ -202,8 +202,8 @@ move_job(http_t     *http,          /* I - HTTP connection to server */
   }
   else
   {
-    httpAssembleURIf(job_uri, sizeof(job_uri), "ipp", NULL, "localhost", 0,
-                     "/printers/%s", src);
+    httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+                     "localhost", 0, "/printers/%s", src);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
                 job_uri);
   }
@@ -211,8 +211,8 @@ move_job(http_t     *http,          /* I - HTTP connection to server */
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
                NULL, cupsUser());
 
-  httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL, "localhost", 0,
-                   "/printers/%s", dest);
+  httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+                   "ipp", NULL, "localhost", 0, "/printers/%s", dest);
   ippAddString(request, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri",
                NULL, printer_uri);
 
@@ -233,5 +233,5 @@ move_job(http_t     *http,          /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: lpmove.c 4945 2006-01-18 21:41:17Z mike $".
+ * End of "$Id: lpmove.c 5023 2006-01-29 14:39:44Z mike $".
  */
index ca02571eb4a89fc8e5f7889646baa5b280ef3200..b0aaa43f39fa6c4094fe72cd23cae5fae3f97173 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpstat.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: lpstat.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   "lpstat" command for the Common UNIX Printing System (CUPS).
  *
@@ -928,7 +928,7 @@ show_classes(http_t     *http,              /* I - HTTP connection to server */
       response2 = NULL;
       if (members == NULL && printer_uri != NULL)
       {
-        httpSeparateURI(printer_uri, method, sizeof(method),
+        httpSeparateURI(HTTP_URI_CODING_ALL, printer_uri, method, sizeof(method),
                        username, sizeof(username), server, sizeof(server),
                        &port, resource, sizeof(resource));
 
@@ -1304,7 +1304,9 @@ show_devices(http_t      *http,           /* I - HTTP connection to server */
 
         if (device == NULL)
        {
-         httpSeparate(uri, method, username, hostname, &port, resource);
+         httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method),
+                         username, sizeof(username), hostname,
+                         sizeof(hostname), &port, resource, sizeof(resource));
           _cupsLangPrintf(stdout,
                          _("Output for printer %s is sent to remote "
                            "printer %s on %s\n"),
@@ -1954,8 +1956,8 @@ show_printers(http_t      *http,  /* I - HTTP connection to server */
                        "requested-attributes",
                        sizeof(jattrs) / sizeof(jattrs[0]), NULL, jattrs);
 
-         httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
-                          "localhost", 0, "/printers/%s", printer);
+         httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+                          "ipp", NULL, "localhost", 0, "/printers/%s", printer);
          ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                       "printer-uri", NULL, printer_uri);
 
@@ -2244,5 +2246,5 @@ show_scheduler(http_t *http)      /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: lpstat.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: lpstat.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 4bddc10ac94f211cd21a9d854a4a4c72b36d005b..fa73d0fcc5cc53fc16aa5fd34399c72911d30842 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipptest.c 4973 2006-01-25 02:36:02Z mike $"
+ * "$Id: ipptest.c 5023 2006-01-29 14:39:44Z mike $"
  *
  *   IPP test command for the Common UNIX Printing System (CUPS).
  *
@@ -151,8 +151,9 @@ do_tests(const char *uri,           /* I - URI to connect on */
   * Connect to the server...
   */
 
-  httpSeparateURI(uri, method, sizeof(method), userpass, sizeof(userpass),
-                  server, sizeof(server), &port, resource, sizeof(resource));
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,
+                  sizeof(userpass), server, sizeof(server), &port, resource,
+                 sizeof(resource));
   if ((http = httpConnect(server, port)) == NULL)
   {
     printf("Unable to connect to %s on port %d - %s\n", server, port,
@@ -189,8 +190,9 @@ do_tests(const char *uri,           /* I - URI to connect on */
     * Initialize things...
     */
 
-    httpSeparateURI(uri, method, sizeof(method), userpass, sizeof(userpass),
-                   server, sizeof(server), &port, resource, sizeof(resource));
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,
+                    sizeof(userpass), server, sizeof(server), &port, resource,
+                   sizeof(resource));
 
     request       = ippNew();
     op            = (ipp_op_t)0;
@@ -784,5 +786,5 @@ print_attr(ipp_attribute_t *attr)   /* I - Attribute to print */
 
 
 /*
- * End of "$Id: ipptest.c 4973 2006-01-25 02:36:02Z mike $".
+ * End of "$Id: ipptest.c 5023 2006-01-29 14:39:44Z mike $".
  */
index 8729d53cf9d75840b8e5bb3662747921bc30e267..af37a09750b75554b4e5c36ca25bd73fe9fb7532 100755 (executable)
@@ -8,12 +8,8 @@ if test ! -f tools/testosx; then
        exit 1
 fi
 
-# Update the current working copy...
-svn up
-rev=`svnversion . | sed -e '1,$s/[a-zA-Z]//g'`
-
-# Make everything...
-make all
+# Get the current working copy version...
+rev=`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[a-zA-Z]*//g'`
 
 # Setup an install directory...
 user=`whoami`
@@ -33,13 +29,19 @@ cp packaging/installer.tif $pkgdir/Resources/background.tif
 
 cat >$pkgdir/Resources/preflight <<EOF
 #!/bin/sh
+# Stop any running cupsd processes...
 killall cupsd || exit 0
 EOF
 chmod 755 $pkgdir/Resources/preflight
 
 cat >$pkgdir/Resources/postflight <<EOF
 #!/bin/sh
-/usr/sbin/cupsd
+launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist || exit 0
+launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist
+sleep 1
+if test -e /private/var/run/cupsd; then
+        chmod g+w,o+w /private/var/run/cupsd
+fi
 EOF
 chmod 755 $pkgdir/Resources/postflight