]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge changes from CUPS 1.4svn-r8540.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 22 Apr 2009 17:28:12 +0000 (17:28 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 22 Apr 2009 17:28:12 +0000 (17:28 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1432 a1ca3aef-8c08-0410-bb20-df032aa958be

102 files changed:
CHANGES-1.3.txt
CHANGES.txt
INSTALL.txt
Makedefs.in
backend/dnssd.c
backend/ipp.c
backend/lpd.c
backend/snmp-supplies.c
backend/testbackend.c
berkeley/Makefile
conf/Makefile
config-scripts/cups-common.m4
config-scripts/cups-directories.m4
config-scripts/cups-gssapi.m4
config-scripts/cups-pap.m4
config.h.in
cups/adminutil.c
cups/array.c
cups/attr.c
cups/auth.c
cups/backchannel.c
cups/conflicts.c
cups/debug.c
cups/debug.h
cups/dest.c
cups/dir.c
cups/emit.c
cups/encode.c
cups/file.c
cups/getdevices.c
cups/getputfile.c
cups/globals.h
cups/http-addr.c
cups/http-addrlist.c
cups/http-support.c
cups/http.c
cups/ipp-support.c
cups/ipp.c
cups/language.c
cups/localize.c
cups/mark.c
cups/options.c
cups/page.c
cups/ppd.c
cups/request.c
cups/sidechannel.c
cups/snmp.c
cups/string.c
cups/string.h
cups/testarray.c
cups/transcode.c
cups/usersys.c
cups/util.c
doc/de/index.html.in
doc/es/index.html.in
doc/help/ref-cupsd-conf.html.in
doc/index.html.in
doc/ja/index.html.in
doc/pl/index.html.in
doc/ru/index.html.in
filter/image-private.h
filter/pstops.c
install-sh
man/cupsd.conf.man.in
notifier/Makefile
scheduler/Makefile
scheduler/auth.c
scheduler/auth.h
scheduler/client.c
scheduler/client.h
scheduler/conf.c
scheduler/conf.h
scheduler/dirsvc.c
scheduler/dirsvc.h
scheduler/ipp.c
scheduler/job.c
scheduler/job.h
scheduler/log.c
scheduler/main.c
scheduler/network.c
scheduler/network.h
scheduler/printers.c
scheduler/printers.h
scheduler/process.c
scheduler/sysman.c
systemv/Makefile
templates/de/header.tmpl.in
templates/de/help-printable.tmpl
templates/es/header.tmpl.in
templates/es/help-printable.tmpl
templates/header.tmpl.in
templates/help-printable.tmpl
templates/ja/header.tmpl.in
templates/ja/help-printable.tmpl
templates/pl/header.tmpl.in
templates/pl/help-printable.tmpl
templates/ru/header.tmpl.in
templates/ru/help-printable.tmpl
test/4.2-cups-printer-ops.test
test/5.4-lpstat.sh
test/ipp-backend.test [new file with mode: 0644]
test/run-stp-tests.sh

index dd58bdff4f00e2d8693aacda95a12d5e62f6fdda..644ff8b33d46c333f1f2e212437988542b6d059e 100644 (file)
@@ -1,12 +1,24 @@
 CHANGES-1.3.txt
 ---------------
 
+CHANGES IN CUPS V1.3.11
+
+       - "lpstat -h server" showed non-shared printers (STR #3147)
+       - "make check" did not work on Linux (STR #3161)
+
+
 CHANGES IN CUPS V1.3.10
 
        - Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056,
          STR #3057)
+       - SECURITY: The scheduler now protects against DNS rebinding attacks
+         (STR #3118)
+       - SECURITY: Fixed TIFF integer overflow in image filters (STR #3031)
        - The scheduler did not support the job-hold-until attribute with the
          Restart-Job operation (STR #3130)
+       - SECURITY: The PNG image reading code did not validate the
+         image size properly, leading to a potential buffer overflow
+         (STR #2974)
        - The rastertohp driver did not set the 1-sided printing mode when
          needed (STR #3131)
        - Now use a wrapper program instead of our fork of the Xpdf code to
@@ -81,11 +93,6 @@ CHANGES IN CUPS V1.3.10
        - The scheduler now rejects ATTR: messages with empty values.
        - The scheduler could consume all CPU handling closed connections
          (STR #2988)
-       - The scheduler now protects against DNS rebinding attacks on
-         localhost.
-       - SECURITY: The PNG image reading code did not validate the
-         image size properly, leading to a potential buffer overflow
-         (STR #2974)
        - Fixed some configure script bugs with rc/xinetd directories
          (STR #2970)
        - The Epson sample driver PPDs contained errors (STR #2979)
index ff69828d00f558dba607650e978398e2bf02bee6..93a428e1fa791a24a8b1d2458c656c0f97c66850 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES.txt - 2009-04-03
+CHANGES.txt - 2009-04-21
 ------------------------
 
 CHANGES IN CUPS V1.4b3
@@ -8,6 +8,17 @@ CHANGES IN CUPS V1.4b3
          Russian and partial localizations for Chinese, Danish, Finnish,
          French, Italian, Korean, Norwegian, Portuguese, and Swedish
          (STR #3096, STR #3098, STR #3109, STR #3111, STR #3141)
+       - Make some fairly substantial changes to the Kerberos support code so
+         that CUPS can work in multi-realm environments and does not require
+         delegatable credentials.  Shared printing still requires delegation,
+         however "delegation by policy" can be enabled in the KDC to make this
+         all work.
+       - "AccessLogLevel actions" did not hide client-error-not-found errors.
+       - AP_FIRST_InputSlot did not work with number-up.
+       - cupsBackChannelRead() and cupsBackChannelWrite() could fail due to a
+         lack of kernel buffers.
+       - The IPP and LPD backends did not respond to side-channel requests
+         while copying print data to a temporary file.
        - cupsWriteRequestData() flushed the output buffer unnecessarily,
          causing reduced performance in some situations.
        - If a CGI process died before sending its MIME headers, the request
@@ -43,9 +54,9 @@ CHANGES IN CUPS V1.4b3
          status operations.
        - ppdOpen*() incorrectly loaded PPDs with multiple JobPatchFile
          keywords.
-       - The network backends no longer report the SNMP "offline" status bit
-         since some printers report this status when the printer is busy
-         printing, warming up, etc.
+       - The network backends no longer report the SNMP "offline" or
+         maintenance status bits since they are inconsistently implemented and
+         often unreliable.
        - The scheduler no longer logs child processes killed via SIGKILL as
          "crashed".
        - The printer link shown on the "job moved" template was bad (STR #3085)
index c3c9088c9ef819a3f5dd24fbbbf16c7620479d0d..fbc2b3c393e91878ee9fee04fe81e5999572ecc7 100644 (file)
@@ -1,4 +1,4 @@
-INSTALL - CUPS v1.4b2 - 2008-12-15
+INSTALL - CUPS v1.4b3 - 2009-04-20
 ----------------------------------
 
 This file describes how to compile and install CUPS from source code. For more
@@ -179,9 +179,15 @@ GETTING DEBUG LOGGING FROM CUPS
 
     When configured with the "--enable-debug-printfs" option, CUPS compiles in
     additional debug logging support in the scheduler, CUPS API, and CUPS
-    Imaging API.  Set the CUPS_DEBUG_LOG environment variable to a filename to
-    append logging information at run-time.  Use the name "-" to send the
-    messages to stderr.
+    Imaging API.  The following environment variables are used to enable and
+    control debug logging:
+
+        CUPS_DEBUG_FILTER  Specifies a POSIX regular expression to control
+                          which messages are logged.
+       CUPS_DEBUG_LEVEL   Specifies a number from 0 to 9 to control the
+                          verbosity of the logging. The default level is 1.
+        CUPS_DEBUG_LOG     Specifies a log file to append to; use the name "-"
+                          to send the messages to stderr.
 
 
 REPORTING PROBLEMS
index 1c182ed0b7fd10eab2fe1796c1a1f851cd4d5e68..a816ec274e57e8ede324059da1d3e40ff6b3064d 100644 (file)
@@ -36,18 +36,17 @@ RMDIR               =       @RMDIR@
 SED            =       @SED@
 SHELL          =       /bin/sh
 
-
 #
 # Installation programs...
 #
 
-INSTALL_BIN    =       $(LIBTOOL) $(INSTALL) -m 755 @INSTALL_STRIP@
-INSTALL_CONFIG =       $(INSTALL) -m @CUPS_CONFIG_FILE_PERM@
-INSTALL_DATA   =       $(INSTALL) -m 644
+INSTALL_BIN    =       $(LIBTOOL) $(INSTALL) -c -m 555 @INSTALL_STRIP@
+INSTALL_CONFIG =       $(INSTALL) -c -m @CUPS_CONFIG_FILE_PERM@
+INSTALL_DATA   =       $(INSTALL) -c -m 444
 INSTALL_DIR    =       $(INSTALL) -d
-INSTALL_LIB    =       $(LIBTOOL) $(INSTALL) -m 755 @INSTALL_STRIP@
-INSTALL_MAN    =       $(INSTALL) -m 644
-INSTALL_SCRIPT =       $(INSTALL) -m 755
+INSTALL_LIB    =       $(LIBTOOL) $(INSTALL) -c -m 555 @INSTALL_STRIP@
+INSTALL_MAN    =       $(INSTALL) -c -m 444
+INSTALL_SCRIPT =       $(INSTALL) -c -m 555
 
 #
 # Default user, group, and system groups for the scheduler...
index be08ddd7a1feb80cc1fb662a6a69417adcccda6c..5cdf160833760a9a6cbf8212af135f1fb7212ac8 100644 (file)
@@ -489,13 +489,10 @@ exec_backend(char **argv)         /* I - Command-line arguments */
   * Resolve the device URI...
   */
 
+  job_canceled = -1;
+
   if ((resolved_uri = cupsBackendDeviceURI(argv)) == NULL)
-  {
-    if (job_canceled)
-      exit(CUPS_BACKEND_OK);
-    else
-      exit(CUPS_BACKEND_FAILED);
-  }
+    exit(CUPS_BACKEND_FAILED);
 
  /*
   * Extract the scheme from the URI...
@@ -869,7 +866,10 @@ query_callback(
 static void
 sigterm_handler(int sig)               /* I - Signal number (unused) */
 {
-  job_canceled = 1;
+  if (job_canceled)
+    exit(CUPS_BACKEND_OK);
+  else
+    job_canceled = 1;
 }
 
 
index fa0694c0307ddd6199b1254e310d85d06674aada..f71d6186cd28e2d6d9bf8214961df8bc1e2fac1f 100644 (file)
@@ -412,12 +412,22 @@ main(int  argc,                           /* I - Number of command-line args */
     * Copy stdin to a temporary file...
     */
 
-    int                fd;                     /* File descriptor */
-    char       buffer[8192];           /* Buffer for copying */
-    int                bytes;                  /* Number of bytes read */
-    off_t      tbytes;                 /* Total bytes copied */
+    int                        fd;             /* File descriptor */
+    http_addrlist_t    *addrlist;      /* Address list */
+    char               buffer[8192];   /* Buffer for copying */
+    int                        bytes;          /* Number of bytes read */
+    off_t              tbytes;         /* Total bytes copied */
 
 
+    if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, "1")) == NULL)
+    {
+      _cupsLangPrintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"),
+                     hostname);
+      return (CUPS_BACKEND_STOP);
+    }
+
+    snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);
+
     if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0)
     {
       _cupsLangPrintError(_("ERROR: Unable to create temporary file"));
@@ -429,6 +439,7 @@ main(int  argc,                             /* I - Number of command-line args */
     tbytes = 0;
 
     while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
+    {
       if (write(fd, buffer, bytes) < bytes)
       {
         _cupsLangPrintError(_("ERROR: Unable to write to temporary file"));
@@ -439,6 +450,15 @@ main(int  argc,                            /* I - Number of command-line args */
       else
         tbytes += bytes;
 
+      if (snmp_fd >= 0)
+       backendCheckSideChannel(snmp_fd, &(addrlist->addr));
+    }
+
+    if (snmp_fd >= 0)
+      _cupsSNMPClose(snmp_fd);
+
+    httpAddrFreeList(addrlist);
+
     close(fd);
 
    /*
index beebc7c37347b2530468ae7ab32e683103cb3bdd..b15f21581a2295961415f7c29b276ae44f59af1f 100644 (file)
@@ -424,10 +424,21 @@ main(int  argc,                           /* I - Number of command-line arguments (6 or 7) */
     * Copy stdin to a temporary file...
     */
 
-    char buffer[8192]; /* Buffer for copying */
-    int  bytes;                /* Number of bytes read */
+    http_addrlist_t    *addrlist;      /* Address list */
+    int                        snmp_fd;        /* SNMP socket */
+    char               buffer[8192];   /* Buffer for copying */
+    int                        bytes;          /* Number of bytes read */
 
 
+    if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, "1")) == NULL)
+    {
+      _cupsLangPrintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"),
+                     hostname);
+      return (CUPS_BACKEND_STOP);
+    }
+
+    snmp_fd = _cupsSNMPOpen(addrlist->addr.addr.sa_family);
+
     if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0)
     {
       _cupsLangPrintError(_("ERROR: Unable to create temporary file"));
@@ -437,6 +448,7 @@ main(int  argc,                             /* I - Number of command-line arguments (6 or 7) */
     _cupsLangPuts(stderr, _("INFO: Copying print data...\n"));
 
     while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
+    {
       if (write(fd, buffer, bytes) < bytes)
       {
         _cupsLangPrintError(_("ERROR: Unable to write to temporary file"));
@@ -444,6 +456,15 @@ main(int  argc,                            /* I - Number of command-line arguments (6 or 7) */
        unlink(tmpfilename);
        return (CUPS_BACKEND_FAILED);
       }
+
+      if (snmp_fd >= 0)
+       backendCheckSideChannel(snmp_fd, &(addrlist->addr));
+    }
+
+    if (snmp_fd >= 0)
+      _cupsSNMPClose(snmp_fd);
+
+    httpAddrFreeList(addrlist);
   }
   else if (argc == 6)
   {
index 50e363ed00e530f6308d1201938a55f151574460..8a0d09f5a31da7fe486dc570f7a1d0a719ad4f99 100644 (file)
@@ -135,7 +135,7 @@ static const backend_state_t const printer_states[] =
                          { CUPS_TC_doorOpen, "door-open-report" },
                          { CUPS_TC_jammed, "media-jam-warning" },
                          /* { CUPS_TC_offline, "offline-report" }, */ /* unreliable */
-                         { CUPS_TC_serviceRequested | CUPS_TC_overduePreventMaint, "service-needed-warning" },
+                         /* { CUPS_TC_serviceRequested | CUPS_TC_overduePreventMaint, "service-needed-warning" }, */ /* unreliable */
                          { CUPS_TC_inputTrayMissing, "input-tray-missing-warning" },
                          { CUPS_TC_outputTrayMissing, "output-tray-missing-warning" },
                          { CUPS_TC_markerSupplyMissing, "marker-supply-missing-warning" },
index 74a0f1e5a776ab508d873eaf1e1d7c3a6eadc534..2c364f533550c1806e608fc4b33df52f00fff066 100644 (file)
@@ -58,7 +58,8 @@ main(int  argc,                               /* I - Number of command-line args */
      char *argv[])                     /* I - Command-line arguments */
 {
   int          first_arg,              /* First argument for backend */
-               do_query = 0,           /* Do PostScript query? */
+               do_ps = 0,              /* Do PostScript query+test? */
+               do_pcl = 0,             /* Do PCL query+test? */
                do_side_tests = 0,      /* Test side-channel ops? */
                do_trickle = 0,         /* Trickle data to backend */
                do_walk = 0,            /* Do OID lookup (0) or walking (1) */
@@ -84,8 +85,10 @@ main(int  argc,                              /* I - Number of command-line args */
        first_arg ++)
     if (!strcmp(argv[first_arg], "-d"))
       show_log = 1;
+    else if (!strcmp(argv[first_arg], "-pcl"))
+      do_pcl = 1;
     else if (!strcmp(argv[first_arg], "-ps"))
-      do_query = 1;
+      do_ps = 1;
     else if (!strcmp(argv[first_arg], "-s"))
       do_side_tests = 1;
     else if (!strcmp(argv[first_arg], "-t"))
@@ -157,15 +160,15 @@ main(int  argc,                           /* I - Number of command-line args */
   * Execute the trickle process as needed...
   */
 
-  if (do_trickle || do_query)
+  if (do_trickle || do_pcl || do_ps)
   {
     pipe(data_fds);
 
     if ((pid = fork()) == 0)
     {
      /*
-      * Trickle/query child comes here...  Rearrange file descriptors so that
-      * FD 
+      * Trickle/query child comes here.  Rearrange file descriptors so that
+      * FD 1, 3, and 4 point to the backend...
       */
 
       close(0);
@@ -203,12 +206,25 @@ main(int  argc,                           /* I - Number of command-line args */
       else
       {
        /*
-        * Do a simple PostScript query job to get the default page size.
+        * Do PS or PCL query + test pages.
        */
 
-        char   buffer[1024];           /* Buffer for response data */
-       ssize_t bytes;                  /* Number of bytes of response data */
-        static const char *ps_query =  /* PostScript query file */
+        char           buffer[1024];   /* Buffer for response data */
+       ssize_t         bytes;          /* Number of bytes of response data */
+       double          timeout;        /* Timeout */
+       const char      *data;          /* Data to send */
+        static const char *pcl_data =  /* PCL data */
+               "\033%-12345X@PJL\r\n"
+               "@PJL JOB NAME = \"Hello, World!\"\r\n"
+               "@PJL INFO USTATUS\r\n"
+               "@PJL ENTER LANGUAGE = PCL\r\n"
+               "\033E"
+               "Hello, World!\n"
+               "\014"
+               "\033%-12345X@PJL\r\n"
+               "@PJL EOJ NAME=\"Hello, World!\"\r\n"
+               "\033%-12345X";
+        static const char *ps_data =   /* PostScript data */
                "%!\n"
                "save\n"
                "product = flush\n"
@@ -240,14 +256,27 @@ main(int  argc,                           /* I - Number of command-line args */
                "  {exch pop exit} {pop} ifelse\n"
                "} bind forall\n"
                "= flush pop pop\n"
+               "/Courier findfont 12 scalefont setfont\n"
+               "0 setgray 36 720 moveto (Hello, ) show product show (!) show\n"
+               "showpage\n"
                "restore\n"
                "\004";
 
 
-        write(1, ps_query, strlen(ps_query));
+       if (do_pcl)
+         data = pcl_data;
+       else
+         data = ps_data;
+
+        write(1, data, strlen(data));
        write(2, "DEBUG: START\n", 13);
-        while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 60.0)) > 0)
+       timeout = 60.0;
+        while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
+                                           timeout)) > 0)
+       {
          write(2, buffer, bytes);
+         timeout = 5.0;
+       }
        write(2, "\nDEBUG: END\n", 12);
       }
 
@@ -272,7 +301,7 @@ main(int  argc,                             /* I - Number of command-line args */
     * Child comes here...
     */
 
-    if (do_trickle || do_query)
+    if (do_trickle || do_ps)
     {
       close(0);
       dup(data_fds[0]);
@@ -311,7 +340,7 @@ main(int  argc,                             /* I - Number of command-line args */
   * Parent comes here, setup back and side channel file descriptors...
   */
 
-  if (do_trickle || do_query)
+  if (do_trickle || do_ps)
   {
     close(data_fds[0]);
     close(data_fds[1]);
@@ -438,7 +467,8 @@ usage(void)
   puts("  -d          Show log messages from backend.");
   puts("  -oid OID    Lookup the specified SNMP OID.");
   puts("              (.1.3.6.1.2.1.43.10.2.1.4.1.1 is a good one for printers)");
-  puts("  -ps         Send PostScript query code to backend.");
+  puts("  -pcl        Send PCL+PJL query and test page to backend.");
+  puts("  -ps         Send PostScript query and test page to backend.");
   puts("  -s          Do side-channel + SNMP tests.");
   puts("  -t          Send spaces slowly to backend ('trickle').");
   puts("  -walk OID   Walk the specified SNMP OID.");
index 346bc17fde714eda259334568a7a78aa0254a9a4..d294e6d0c2da4188d95ea92e9ea63d52cfdc41a3 100644 (file)
@@ -3,7 +3,7 @@
 #
 #   Berkeley commands makefile for the Common UNIX Printing System (CUPS).
 #
-#   Copyright 2007-2008 by Apple Inc.
+#   Copyright 2007-2009 by Apple Inc.
 #   Copyright 1997-2006 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -76,10 +76,12 @@ install-data:
 #
 
 install-exec:
+       echo Installing Berkeley user printing commands in $(BINDIR)...
        $(INSTALL_DIR) -m 755 $(BINDIR)
        $(INSTALL_BIN) lpq $(BINDIR)
        $(INSTALL_BIN) lpr $(BINDIR)
        $(INSTALL_BIN) lprm $(BINDIR)
+       echo Installing Berkeley admin printing commands in $(BINDIR)...
        $(INSTALL_DIR) -m 755 $(SBINDIR)
        $(INSTALL_BIN) lpc $(SBINDIR)
        if test "x$(SYMROOT)" != "x"; then \
index e9ef1f4897875bc2718a0529edcac93443c6eda2..e8cdbfc1099afb50a7b28caa766a891e93a171d8 100644 (file)
@@ -72,15 +72,12 @@ install:    all install-data install-headers install-libs install-exec
 install-data:
        for file in $(KEEP); do \
                if test -r $(SERVERROOT)/$$file ; then \
-                       $(INSTALL_CONFIG) $$file $(SERVERROOT)/$$file.N ; \
-                       chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file.N || true; \
+                       $(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT)/$$file.N ; \
                else \
-                       $(INSTALL_CONFIG) $$file $(SERVERROOT) ; \
-                       chgrp $(CUPS_GROUP) $(SERVERROOT)/$$file || true; \
+                       $(INSTALL_CONFIG) -g $(CUPS_GROUP) $$file $(SERVERROOT) ; \
                fi ; \
        done
-       $(INSTALL_CONFIG) cupsd.conf $(SERVERROOT)/cupsd.conf.default
-       -chgrp $(CUPS_GROUP) $(SERVERROOT)/cupsd.conf.default
+       $(INSTALL_CONFIG) -g $(CUPS_GROUP) cupsd.conf $(SERVERROOT)/cupsd.conf.default
        $(INSTALL_DIR) -m 755 $(DATADIR)/mime
        for file in $(REPLACE); do \
                if test -r $(DATADIR)/mime/$$file ; then \
index bd763894ea9d0333df95944af1b2dc6876aca42a..7ab5f0ebffe2b0d4a4469b04e3b84fd31b26edbd 100644 (file)
@@ -65,7 +65,7 @@ fi
 AC_SUBST(CUPS_HTMLVIEW)
 
 AC_MSG_CHECKING(for install-sh script)
-INSTALL="`pwd`/install-sh -c"
+INSTALL="`pwd`/install-sh"
 AC_SUBST(INSTALL)
 AC_MSG_RESULT(using $INSTALL)
 
index 78a4c96d385094c9744269ec3bc6631aba9fcbd9..6f969aae272f0d943b3623bfe34073d747bf6dfc 100644 (file)
@@ -411,8 +411,17 @@ AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$sysconfdir/cups")
 AC_SUBST(CUPS_SERVERROOT)
 
 # Transient run-time state
-CUPS_STATEDIR="$localstatedir/run/cups"
-AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$localstatedir/run/cups")
+case "$uname" in
+       Darwin*)
+               # Darwin (Mac OS X)
+               CUPS_STATEDIR="$CUPS_SERVERROOT"
+               ;;
+       *)
+               # All others
+               CUPS_STATEDIR="$localstatedir/run/cups"
+               ;;
+esac
+AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$CUPS_STATEDIR")
 AC_SUBST(CUPS_STATEDIR)
 
 dnl
index 0a3458b0325af9aba46bda9c493a172589a79e7c..daa8db66858873d6aa6361d05f5cdb42e6d52d91 100644 (file)
@@ -19,6 +19,7 @@ dnl
 AC_ARG_ENABLE(gssapi, [  --disable-gssapi        disable GSSAPI support])
 
 LIBGSSAPI=""
+AC_SUBST(LIBGSSAPI)
 
 if test x$enable_gssapi != xno; then
        AC_PATH_PROG(KRB5CONFIG, krb5-config)
@@ -73,6 +74,7 @@ if test x$enable_gssapi != xno; then
                AC_CHECK_FUNC(gsskrb5_register_acceptor_identity, 
                              AC_DEFINE(HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY))
                AC_CHECK_FUNC(krb5_cc_new_unique, AC_DEFINE(HAVE_KRB5_CC_NEW_UNIQUE))
+               AC_CHECK_FUNC(krb5_ipc_client_set_target_uid, AC_DEFINE(HAVE_KRB5_IPC_CLIENT_SET_TARGET_UID))
 
                AC_MSG_CHECKING(for GSS_C_NT_HOSTBASED_SERVICE)
                if test $ac_cv_header_gssapi_gssapi_h = yes; then
@@ -115,7 +117,6 @@ else
        CUPS_DEFAULT_GSSSERVICENAME=""
 fi
 
-AC_SUBST(LIBGSSAPI)
 AC_DEFINE_UNQUOTED(CUPS_DEFAULT_GSSSERVICENAME, "$CUPS_DEFAULT_GSSSERVICENAME")
 
 dnl
index e3509011ad80629408f5cd2429d7ba70cd6f7e59..b532e0370330f76236a891b8b8d398c3f7773302 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $"
+dnl "$Id$"
 dnl
 dnl   PAP (AppleTalk) stuff for the Common UNIX Printing System (CUPS).
 dnl
@@ -27,5 +27,5 @@ if test x$enable_pap = xyes -a $uname = Darwin; then
 fi
 
 dnl
-dnl End of "$Id: cups-pam.m4 5466 2006-04-26 19:52:27Z mike $".
+dnl End of "$Id$".
 dnl
index f577eb285f07655ded0be09c2d888edd29ab46a9..b17968927f298b1d68b1e9dfa27e1c5014f4e5c1 100644 (file)
 #undef HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY
 #undef HAVE_GSS_C_NT_HOSTBASED_SERVICE
 #undef HAVE_KRB5_CC_NEW_UNIQUE
+#undef HAVE_KRB5_IPC_CLIENT_SET_TARGET_UID
 #undef HAVE_KRB5_H
 #undef HAVE_HEIMDAL
 
index 318fb730e8b9329aeac4fa4e45c1422aa1515226..a46d34f691ca906d28c75269b0a9d3271bed6350 100644 (file)
@@ -2208,7 +2208,7 @@ do_samba_command(const char *command,     /* I - Command to run */
   if (logfile)
     _cupsLangPuts(logfile, "\n");
 
-  DEBUG_printf(("status=%d\n", status));
+  DEBUG_printf(("9do_samba_command: status=%d", status));
 
   if (WIFEXITED(status))
     return (WEXITSTATUS(status));
index 4f40d7f4a30b85e74fca6fc228b9abdf7a710f28..957ed913b4cb4313c975689f3b1df57c2171bcec 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Sorted array routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -109,7 +109,7 @@ int                                 /* O - 1 on success, 0 on failure */
 cupsArrayAdd(cups_array_t *a,          /* I - Array */
              void         *e)          /* I - Element */
 {
-  DEBUG_printf(("cupsArrayAdd(a=%p, e=%p)\n", a, e));
+  DEBUG_printf(("2cupsArrayAdd(a=%p, e=%p)", a, e));
 
  /*
   * Range check input...
@@ -117,7 +117,7 @@ cupsArrayAdd(cups_array_t *a,               /* I - Array */
 
   if (!a || !e)
   {
-    DEBUG_puts("cupsArrayAdd: returning 0");
+    DEBUG_puts("3cupsArrayAdd: returning 0");
     return (0);
   }
 
@@ -505,7 +505,7 @@ int                                 /* O - 0 on failure, 1 on success */
 cupsArrayInsert(cups_array_t *a,       /* I - Array */
                void         *e)        /* I - Element */
 {
-  DEBUG_printf(("cupsArrayInsert(a=%p, e=%p)\n", a, e));
+  DEBUG_printf(("2cupsArrayInsert(a=%p, e=%p)", a, e));
 
  /*
   * Range check input...
@@ -513,7 +513,7 @@ cupsArrayInsert(cups_array_t *a,    /* I - Array */
 
   if (!a || !e)
   {
-    DEBUG_puts("cupsArrayInsert: returning 0");
+    DEBUG_puts("3cupsArrayInsert: returning 0");
     return (0);
   }
 
@@ -846,7 +846,7 @@ cups_array_add(cups_array_t *a,             /* I - Array */
        diff;                           /* Comparison with current element */
 
 
-  DEBUG_printf(("cups_array_add(a=%p, e=%p, insert=%d)\n", a, e, insert));
+  DEBUG_printf(("7cups_array_add(a=%p, e=%p, insert=%d)", a, e, insert));
 
  /*
   * Verify we have room for the new element...
@@ -879,11 +879,11 @@ cups_array_add(cups_array_t *a,           /* I - Array */
       temp = realloc(a->elements, count * sizeof(void *));
     }
 
-    DEBUG_printf(("cups_array_add: count=%d\n", count));
+    DEBUG_printf(("9cups_array_add: count=%d", count));
 
     if (!temp)
     {
-      DEBUG_puts("cupsAddAdd: allocation failed, returning 0");
+      DEBUG_puts("9cups_array_add: allocation failed, returning 0");
       return (0);
     }
 
@@ -978,11 +978,11 @@ cups_array_add(cups_array_t *a,           /* I - Array */
       if (a->saved[i] >= current)
        a->saved[i] ++;
 
-    DEBUG_printf(("cups_array_add: insert element at index %d...\n", current));
+    DEBUG_printf(("9cups_array_add: insert element at index %d...", current));
   }
 #ifdef DEBUG
   else
-    DEBUG_printf(("cups_array_add: append element at %d...\n", current));
+    DEBUG_printf(("9cups_array_add: append element at %d...", current));
 #endif /* DEBUG */
 
   a->elements[current] = e;
@@ -991,11 +991,11 @@ cups_array_add(cups_array_t *a,           /* I - Array */
 
 #ifdef DEBUG
   for (current = 0; current < a->num_elements; current ++)
-    DEBUG_printf(("cups_array_add: a->elements[%d]=%p\n", current,
+    DEBUG_printf(("9cups_array_add: a->elements[%d]=%p", current,
                   a->elements[current]));
 #endif /* DEBUG */
 
-  DEBUG_puts("cups_array_add: returning 1");
+  DEBUG_puts("9cups_array_add: returning 1");
 
   return (1);
 }
@@ -1017,7 +1017,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
        diff;                           /* Comparison with current element */
 
 
-  DEBUG_printf(("cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)\n", a, e, prev,
+  DEBUG_printf(("7cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)", a, e, prev,
                 rdiff));
 
   if (a->compare)
@@ -1026,7 +1026,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
     * Do a binary search for the element...
     */
 
-    DEBUG_puts("cups_array_find: binary search");
+    DEBUG_puts("9cups_array_find: binary search");
 
     if (prev >= 0 && prev < a->num_elements)
     {
@@ -1042,7 +1042,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
         * Exact or edge match, return it!
        */
 
-        DEBUG_printf(("cups_array_find: Returning %d, diff=%d\n", prev, diff));
+        DEBUG_printf(("9cups_array_find: Returning %d, diff=%d", prev, diff));
 
        *rdiff = diff;
 
@@ -1082,7 +1082,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
       current = (left + right) / 2;
       diff    = (*(a->compare))(e, a->elements[current], a->data);
 
-      DEBUG_printf(("cups_array_find: left=%d, right=%d, current=%d, diff=%d\n",
+      DEBUG_printf(("9cups_array_find: left=%d, right=%d, current=%d, diff=%d",
                     left, right, current, diff));
 
       if (diff == 0)
@@ -1115,7 +1115,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
     * Do a linear pointer search...
     */
 
-    DEBUG_puts("cups_array_find: linear search");
+    DEBUG_puts("9cups_array_find: linear search");
 
     diff = 1;
 
@@ -1131,7 +1131,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
   * Return the closest element and the difference...
   */
 
-  DEBUG_printf(("cups_array_find: Returning %d, diff=%d\n", current, diff));
+  DEBUG_printf(("8cups_array_find: Returning %d, diff=%d", current, diff));
 
   *rdiff = diff;
 
index f7b1a76b82c6e946fc9f8a761880c15666f97506..c2c6eb5128e91a17b827e99a7e86a53795457200 100644 (file)
@@ -4,7 +4,7 @@
  *   PPD model-specific attribute routines for the Common UNIX Printing System
  *   (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -44,8 +44,8 @@ ppdFindAttr(ppd_file_t *ppd,          /* I - PPD file data */
                *attr;                  /* Current attribute */
 
 
-  DEBUG_printf(("ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")\n", ppd,
-                name ? name : "(null)", spec ? spec : "(null)"));
+  DEBUG_printf(("2ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")", ppd, name,
+                spec));
 
  /*
   * Range check input...
index 332301c8169b1ed4e9df250b239bd6812cafa487..da37c0bfc7247fd669fa0b31b4409b9604f074e6 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Authentication functions for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   This file contains Kerberos support code, copyright 2006 by
@@ -20,8 +20,8 @@
  * Contents:
  *
  *   cupsDoAuthentication() - Authenticate a request.
- *   DEBUG_gss_printf()     - Show debug error messages from GSSAPI...
- *   cups_get_gss_creds()   - Get CUPS service credentials for authentication.
+ *   cups_get_gssname()     - Get GSSAPI name for authentication.
+ *   cups_gss_printf()      - Show error messages from GSSAPI...
  *   cups_local_auth()      - Get the local authorization certificate if
  *                            available/applicable...
  */
@@ -62,13 +62,13 @@ extern const char *cssmErrorString(int error);
  */
 
 #ifdef HAVE_GSSAPI
+static gss_name_t cups_get_gssname(http_t *http, const char *service_name);
 #  ifdef DEBUG
-static void    DEBUG_gss_printf(OM_uint32 major_status, OM_uint32 minor_status,
-                                const char *message);
+static void    cups_gss_printf(OM_uint32 major_status, OM_uint32 minor_status,
+                               const char *message);
 #  else
-#    define DEBUG_gss_printf(major, minor, message)
-#  endif /* DEBUG  */
-static gss_name_t cups_get_gss_creds(http_t *http, const char *service_name);
+#    define    cups_gss_printf(major, minor, message)
+#  endif /* DEBUG */
 #endif /* HAVE_GSSAPI */
 static int     cups_local_auth(http_t *http);
 
@@ -96,11 +96,11 @@ cupsDoAuthentication(http_t     *http,      /* I - Connection to server or @code CUPS
   _cups_globals_t *cg;                 /* Global data */
 
 
-  DEBUG_printf(("cupsDoAuthentication(http=%p, method=\"%s\", resource=\"%s\")\n",
+  DEBUG_printf(("cupsDoAuthentication(http=%p, method=\"%s\", resource=\"%s\")",
                 http, method, resource));
-  DEBUG_printf(("cupsDoAuthentication: digest_tries=%d, userpass=\"%s\"\n",
+  DEBUG_printf(("2cupsDoAuthentication: digest_tries=%d, userpass=\"%s\"",
                 http->digest_tries, http->userpass));
-  DEBUG_printf(("cupsDoAuthentication: WWW-Authenticate=\"%s\"\n",
+  DEBUG_printf(("2cupsDoAuthentication: WWW-Authenticate=\"%s\"",
                 httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE)));
 
  /*
@@ -117,7 +117,7 @@ cupsDoAuthentication(http_t     *http,      /* I - Connection to server or @code CUPS
   {
     if ((localauth = cups_local_auth(http)) == 0)
     {
-      DEBUG_printf(("cupsDoAuthentication: authstring=\"%s\"\n",
+      DEBUG_printf(("2cupsDoAuthentication: authstring=\"%s\"",
                     http->authstring));
   
       if (http->status == HTTP_UNAUTHORIZED)
@@ -199,7 +199,7 @@ cupsDoAuthentication(http_t     *http,      /* I - Connection to server or @code CUPS
 
     if (gss_init_sec_context == NULL)
     {
-      DEBUG_puts("cupsDoAuthentication: Weak-linked GSSAPI/Kerberos framework "
+      DEBUG_puts("1cupsDoAuthentication: Weak-linked GSSAPI/Kerberos framework "
                  "is not present");
       return (-1);
     }
@@ -207,7 +207,7 @@ cupsDoAuthentication(http_t     *http,      /* I - Connection to server or @code CUPS
 
     if (http->status == HTTP_UNAUTHORIZED && http->digest_tries >= 3)
     {
-      DEBUG_printf(("cupsDoAuthentication: too many Negotiate tries (%d)\n",
+      DEBUG_printf(("1cupsDoAuthentication: too many Negotiate tries (%d)",
                     http->digest_tries));
   
       return (-1);
@@ -218,9 +218,10 @@ cupsDoAuthentication(http_t     *http,     /* I - Connection to server or @code CUPS
       if ((gss_service_name = getenv("CUPS_GSSSERVICENAME")) == NULL)
        gss_service_name = CUPS_DEFAULT_GSSSERVICENAME;
       else
-       DEBUG_puts("cupsDoAuthentication: GSS service name set via environment");
+       DEBUG_puts("2cupsDoAuthentication: GSS service name set via "
+                  "environment variable");
 
-      http->gssname = cups_get_gss_creds(http, gss_service_name);
+      http->gssname = cups_get_gssname(http, gss_service_name);
     }
 
 #  ifdef USE_SPNEGO /* We don't implement SPNEGO just yet... */
@@ -277,8 +278,10 @@ cupsDoAuthentication(http_t     *http,     /* I - Connection to server or @code CUPS
     major_status  = gss_init_sec_context(&minor_status, GSS_C_NO_CREDENTIAL,
                                         &http->gssctx,
                                         http->gssname, http->gssmech,
-                                        GSS_C_DELEG_FLAG | GSS_C_MUTUAL_FLAG |
-                                            GSS_C_INTEG_FLAG,
+#ifdef GSS_C_DELEG_POLICY_FLAG
+                                        GSS_C_DELEG_POLICY_FLAG |
+#endif /* GSS_C_DELEG_POLICY_FLAG */
+                                        GSS_C_MUTUAL_FLAG | GSS_C_INTEG_FLAG,
                                         GSS_C_INDEFINITE,
                                         GSS_C_NO_CHANNEL_BINDINGS,
                                         &input_token, &http->gssmech,
@@ -289,15 +292,15 @@ cupsDoAuthentication(http_t     *http,    /* I - Connection to server or @code CUPS
 
     if (GSS_ERROR(major_status))
     {
-#  ifdef DEBUG
-      DEBUG_gss_printf(major_status, minor_status,
-                      "Unable to initialize security context");
-#  endif /* DEBUG */
+      cups_gss_printf(major_status, minor_status,
+                     "cupsDoAuthentication: Unable to initialize security "
+                     "context");
       return (-1);
     }
 
     if (major_status == GSS_S_CONTINUE_NEEDED)
-      DEBUG_gss_printf(major_status, minor_status, "Continuation needed!");
+      cups_gss_printf(major_status, minor_status,
+                     "cupsDoAuthentication: Continuation needed!");
 
     if (output_token.length > 0 && output_token.length <= 65536)
     {
@@ -326,8 +329,8 @@ cupsDoAuthentication(http_t     *http,      /* I - Connection to server or @code CUPS
     }
     else
     {
-      DEBUG_printf(("cupsDoAuthentication: Kerberos credentials too large - "
-                    "%d bytes!\n", (int)output_token.length));
+      DEBUG_printf(("1cupsDoAuthentication: Kerberos credentials too large - "
+                    "%d bytes!", (int)output_token.length));
 
       gss_release_buffer(&minor_status, &output_token);
 
@@ -369,59 +372,19 @@ cupsDoAuthentication(http_t     *http,    /* I - Connection to server or @code CUPS
     httpSetAuthString(http, "Digest", digest);
   }
 
-  DEBUG_printf(("cupsDoAuthentication: authstring=\"%s\"\n", http->authstring));
+  DEBUG_printf(("1cupsDoAuthentication: authstring=\"%s\"", http->authstring));
 
   return (0);
 }
 
 
 #ifdef HAVE_GSSAPI
-#  ifdef DEBUG
 /*
- * 'DEBUG_gss_printf()' - Show debug error messages from GSSAPI...
- */
-
-static void
-DEBUG_gss_printf(OM_uint32 major_status,/* I - Major status code */
-                 OM_uint32 minor_status,/* I - Minor status code */
-                const char *message)   /* I - Prefix for error message */
-{
-  OM_uint32    err_major_status,       /* Major status code for display */
-               err_minor_status;       /* Minor status code for display */
-  OM_uint32    msg_ctx;                /* Message context */
-  gss_buffer_desc major_status_string = GSS_C_EMPTY_BUFFER,
-                                       /* Major status message */
-               minor_status_string = GSS_C_EMPTY_BUFFER;
-                                       /* Minor status message */
-
-
-  msg_ctx          = 0;
-  err_major_status = gss_display_status(&err_minor_status,
-                                       major_status,
-                                       GSS_C_GSS_CODE,
-                                       GSS_C_NO_OID,
-                                       &msg_ctx,
-                                       &major_status_string);
-
-  if (!GSS_ERROR(err_major_status))
-    gss_display_status(&err_minor_status, minor_status, GSS_C_MECH_CODE,
-                      GSS_C_NULL_OID, &msg_ctx, &minor_status_string);
-
-  printf("%s: %s, %s\n", message, (char *)major_status_string.value,
-        (char *)minor_status_string.value);
-
-  gss_release_buffer(&err_minor_status, &major_status_string);
-  gss_release_buffer(&err_minor_status, &minor_status_string);
-}
-#  endif /* DEBUG */
-
-
-/*
- * 'cups_get_gss_creds()' - Get CUPS service credentials for authentication.
+ * 'cups_get_gssname()' - Get CUPS service credentials for authentication.
  */
 
 static gss_name_t                      /* O - Server name */
-cups_get_gss_creds(
+cups_get_gssname(
     http_t     *http,                  /* I - Connection to server */
     const char *service_name)          /* I - Service name */
 {
@@ -434,6 +397,10 @@ cups_get_gss_creds(
                  fqdn[HTTP_MAX_URI];   /* Server name buffer */
 
 
+  DEBUG_printf(("7cups_get_gssname(http=%p, service_name=\"%s\")", http,
+                service_name));
+
+
  /*
   * Get the hostname...
   */
@@ -449,7 +416,7 @@ cups_get_gss_creds(
 
   snprintf(buf, sizeof(buf), "%s@%s", service_name, fqdn);
 
-  DEBUG_printf(("cups_get_gss_creds: Looking up %s...\n", buf));
+  DEBUG_printf(("9cups_get_gssname: Looking up %s...", buf));
 
   token.value  = buf;
   token.length = strlen(buf);
@@ -460,15 +427,53 @@ cups_get_gss_creds(
 
   if (GSS_ERROR(major_status))
   {
-#  ifdef DEBUG
-    DEBUG_gss_printf(major_status, minor_status, "gss_import_name() failed");
-#  endif /* DEBUG */
-
+    cups_gss_printf(major_status, minor_status,
+                    "cups_get_gssname: gss_import_name() failed");
     return (NULL);
   }
 
   return (server_name);
 }
+
+
+#  ifdef DEBUG
+/*
+ * 'cups_gss_printf()' - Show debug error messages from GSSAPI...
+ */
+
+static void
+cups_gss_printf(OM_uint32  major_status,/* I - Major status code */
+               OM_uint32  minor_status,/* I - Minor status code */
+               const char *message)    /* I - Prefix for error message */
+{
+  OM_uint32    err_major_status,       /* Major status code for display */
+               err_minor_status;       /* Minor status code for display */
+  OM_uint32    msg_ctx;                /* Message context */
+  gss_buffer_desc major_status_string = GSS_C_EMPTY_BUFFER,
+                                       /* Major status message */
+               minor_status_string = GSS_C_EMPTY_BUFFER;
+                                       /* Minor status message */
+
+
+  msg_ctx          = 0;
+  err_major_status = gss_display_status(&err_minor_status,
+                                       major_status,
+                                       GSS_C_GSS_CODE,
+                                       GSS_C_NO_OID,
+                                       &msg_ctx,
+                                       &major_status_string);
+
+  if (!GSS_ERROR(err_major_status))
+    gss_display_status(&err_minor_status, minor_status, GSS_C_MECH_CODE,
+                      GSS_C_NULL_OID, &msg_ctx, &minor_status_string);
+
+  DEBUG_printf(("8%s: %s, %s", message, (char *)major_status_string.value,
+               (char *)minor_status_string.value));
+
+  gss_release_buffer(&err_minor_status, &major_status_string);
+  gss_release_buffer(&err_minor_status, &minor_status_string);
+}
+#  endif /* DEBUG */
 #endif /* HAVE_GSSAPI */
 
 
@@ -491,7 +496,8 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
 #else
   int                  pid;            /* Current process ID */
   FILE                 *fp;            /* Certificate file */
-  char                 filename[1024], /* Certificate filename */
+  char                 trc[16],        /* Try Root Certificate parameter */
+                       filename[1024], /* Certificate filename */
                        certificate[33];/* Certificate string */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 #  if defined(HAVE_AUTHORIZATION_H)
@@ -505,7 +511,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
 #  endif /* HAVE_AUTHORIZATION_H */
 
 
-  DEBUG_printf(("cups_local_auth(http=%p) hostaddr=%s, hostname=\"%s\"\n",
+  DEBUG_printf(("7cups_local_auth(http=%p) hostaddr=%s, hostname=\"%s\"",
                 http, httpAddrString(http->hostaddr, filename, sizeof(filename)), http->hostname));
 
  /*
@@ -515,7 +521,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
   if (!httpAddrLocalhost(http->hostaddr) &&
       strcasecmp(http->hostname, "localhost") != 0)
   {
-    DEBUG_puts("cups_local_auth: Not a local connection!");
+    DEBUG_puts("8cups_local_auth: Not a local connection!");
     return (1);
   }
 
@@ -538,7 +544,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
                                 kAuthorizationFlagDefaults, &http->auth_ref);
     if (status != errAuthorizationSuccess)
     {
-      DEBUG_printf(("cups_local_auth: AuthorizationCreate() returned %d (%s)\n",
+      DEBUG_printf(("8cups_local_auth: AuthorizationCreate() returned %d (%s)",
                    (int)status, cssmErrorString(status)));
       return (-1);
     }
@@ -573,14 +579,14 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
 
       httpSetAuthString(http, "AuthRef", buffer);
 
-      DEBUG_printf(("cups_local_auth: Returning authstring = \"%s\"\n",
+      DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"",
                    http->authstring));
       return (0);
     }
     else if (status == errAuthorizationCanceled)
       return (-1);
 
-    DEBUG_printf(("cups_local_auth: AuthorizationCopyRights() returned %d (%s)\n",
+    DEBUG_printf(("9cups_local_auth: AuthorizationCopyRights() returned %d (%s)",
                  (int)status, cssmErrorString(status)));
 
   /*
@@ -598,25 +604,34 @@ cups_local_auth(http_t *http)             /* I - HTTP connection to server */
   snprintf(filename, sizeof(filename), "%s/certs/%d", cg->cups_statedir, pid);
   if ((fp = fopen(filename, "r")) == NULL && pid > 0)
   {
-    DEBUG_printf(("cups_local_auth: Unable to open file %s: %s\n",
-                  filename, strerror(errno)));
-
-#ifdef HAVE_GSSAPI
    /*
-    * If local certificate authentication isn't available for this PID,
-    * check if we need Kerberos authentication...
+    * No certificate for this PID; see if we can get the root certificate...
     */
 
+    DEBUG_printf(("9cups_local_auth: Unable to open file %s: %s",
+                  filename, strerror(errno)));
+
+#ifdef HAVE_GSSAPI
     if (!strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Negotiate", 9))
     {
      /*
-      * Yes, don't try the root certificate...
+      * Kerberos required, don't try the root certificate...
       */
 
       return (1);
     }
 #endif /* HAVE_GSSAPI */
 
+    if (!httpGetSubField2(http, HTTP_FIELD_WWW_AUTHENTICATE, "trc", trc,
+                         sizeof(trc)))
+    {
+     /*
+      * Scheduler doesn't want us to use the root certificate...
+      */
+
+      return (1);
+    }
+
     snprintf(filename, sizeof(filename), "%s/certs/0", cg->cups_statedir);
     fp = fopen(filename, "r");
   }
@@ -636,7 +651,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
 
     httpSetAuthString(http, "Local", certificate);
 
-    DEBUG_printf(("cups_local_auth: Returning authstring = \"%s\"\n",
+    DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"",
                  http->authstring));
 
     return (0);
@@ -665,7 +680,7 @@ cups_local_auth(http_t *http)               /* I - HTTP connection to server */
     {
       httpSetAuthString(http, "PeerCred", username);
 
-      DEBUG_printf(("cups_local_auth: Returning authstring = \"%s\"\n",
+      DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"",
                    http->authstring));
 
       return (0);
index 23caace80808d0df76a27526de666ae11ead9933..b264b5c89365b8e2789b8126fd4def7b1993d51a 100644 (file)
@@ -76,7 +76,7 @@ cupsBackChannelRead(char   *buffer,   /* I - Buffer to read into */
     else
       status = select(4, &input, NULL, NULL, &tval);
   }
-  while (status < 0 && errno != EINTR);
+  while (status < 0 && errno != EINTR && errno != EAGAIN);
 
   if (status < 0)
     return (-1);                       /* Timeout! */
@@ -138,9 +138,9 @@ cupsBackChannelWrite(
       else
        status = select(4, NULL, &output, NULL, &tval);
     }
-    while (status < 0 && errno != EINTR);
+    while (status < 0 && errno != EINTR && errno != EAGAIN);
 
-    if (status < 0)
+    if (status <= 0)
       return (-1);                     /* Timeout! */
 
    /*
@@ -159,7 +159,7 @@ cupsBackChannelWrite(
       * Write error - abort on fatal errors...
       */
 
-      if (errno != EINTR)
+      if (errno != EINTR && errno != EAGAIN)
         return (-1);
     }
     else
index 254138a49a95b6d8c8fb7ebebb182342172c77f1..d6de5a39b520de3ba2a51735117d10661d9d8981 100644 (file)
@@ -47,6 +47,7 @@
 enum
 {
   _PPD_NORMAL_CONSTRAINTS,
+  _PPD_OPTION_CONSTRAINTS,
   _PPD_INSTALLABLE_CONSTRAINTS,
   _PPD_ALL_CONSTRAINTS
 };
@@ -255,7 +256,7 @@ cupsResolveConflicts(
          * Resolver loop!
          */
 
-         DEBUG_printf(("ppdResolveConflicts: Resolver loop with %s!\n",
+         DEBUG_printf(("1ppdResolveConflicts: Resolver loop with %s!",
                        consts->resolver));
           goto error;
        }
@@ -263,14 +264,14 @@ cupsResolveConflicts(
         if ((resolver = ppdFindAttr(ppd, "cupsUIResolver",
                                    consts->resolver)) == NULL)
         {
-         DEBUG_printf(("ppdResolveConflicts: Resolver %s not found!\n",
+         DEBUG_printf(("1ppdResolveConflicts: Resolver %s not found!",
                        consts->resolver));
          goto error;
        }
 
         if (!resolver->value)
        {
-         DEBUG_printf(("ppdResolveConflicts: Resolver %s has no value!\n",
+         DEBUG_printf(("1ppdResolveConflicts: Resolver %s has no value!",
                        consts->resolver));
          goto error;
        }
@@ -428,7 +429,7 @@ cupsResolveConflicts(
              (test = ppd_test_constraints(ppd, constptr->option->keyword,
                                           constptr->option->defchoice,
                                           num_newopts, newopts,
-                                          _PPD_ALL_CONSTRAINTS)) == NULL)
+                                          _PPD_OPTION_CONSTRAINTS)) == NULL)
          {
           /*
            * That worked...
@@ -459,7 +460,7 @@ cupsResolveConflicts(
                  (test = ppd_test_constraints(ppd, constptr->option->keyword,
                                               cptr->choice, num_newopts,
                                               newopts,
-                                              _PPD_ALL_CONSTRAINTS)) == NULL)
+                                              _PPD_OPTION_CONSTRAINTS)) == NULL)
              {
               /*
                * This choice works...
@@ -480,7 +481,7 @@ cupsResolveConflicts(
 
       if (!changed)
       {
-       DEBUG_puts("ppdResolveConflicts: Unable to automatically resolve "
+       DEBUG_puts("1ppdResolveConflicts: Unable to automatically resolve "
                   "constraint!");
        goto error;
       }
@@ -519,10 +520,10 @@ cupsResolveConflicts(
 
   cupsArrayRestore(ppd->sorted_attrs);
 
-  DEBUG_printf(("cupsResolveConflicts: Returning %d options:", num_newopts));
+  DEBUG_printf(("1cupsResolveConflicts: Returning %d options:", num_newopts));
 #ifdef DEBUG
   for (i = 0; i < num_newopts; i ++)
-    DEBUG_printf(("cupsResolveConflicts: options[%d]: %s=%s", i,
+    DEBUG_printf(("1cupsResolveConflicts: options[%d]: %s=%s", i,
                   newopts[i].name, newopts[i].value));
 #endif /* DEBUG */
 
@@ -542,7 +543,7 @@ cupsResolveConflicts(
 
   cupsArrayRestore(ppd->sorted_attrs);
 
-  DEBUG_puts("cupsResolveConflicts: Unable to resolve conflicts!");
+  DEBUG_puts("1cupsResolveConflicts: Unable to resolve conflicts!");
 
   return (0);
 }
@@ -628,6 +629,9 @@ ppdInstallableConflict(
   cups_array_t *active;                /* Active conflicts */
 
 
+  DEBUG_printf(("2ppdInstallableConflict(ppd=%p, option=\"%s\", choice=\"%s\")",
+                ppd, option, choice));
+
  /* 
   * Range check input...
   */
@@ -694,6 +698,8 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
                *ptr;                   /* Pointer into option or choice */
 
 
+  DEBUG_printf(("7ppd_load_constraints(ppd=%p)", ppd));
+
  /*
   * Create an array to hold the constraint data...
   */
@@ -737,7 +743,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
 
     if ((consts = calloc(1, sizeof(_ppd_cups_uiconsts_t))) == NULL)
     {
-      DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
+      DEBUG_puts("8ppd_load_constraints: Unable to allocate memory for "
                 "UIConstraints!");
       return;
     }
@@ -745,7 +751,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
     if ((constptr = calloc(2, sizeof(_ppd_cups_uiconst_t))) == NULL)
     {
       free(consts);
-      DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
+      DEBUG_puts("8ppd_load_constraints: Unable to allocate memory for "
                 "UIConstraints!");
       return;
     }
@@ -775,7 +781,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
 
     if (!constptr[0].option || (!constptr[0].choice && oldconst->choice1[0]))
     {
-      DEBUG_printf(("ppd_load_constraints: Unknown option *%s %s!\n",
+      DEBUG_printf(("8ppd_load_constraints: Unknown option *%s %s!",
                    oldconst->option1, oldconst->choice1));
       free(consts->constraints);
       free(consts);
@@ -800,7 +806,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
 
     if (!constptr[1].option || (!constptr[1].choice && oldconst->choice2[0]))
     {
-      DEBUG_printf(("ppd_load_constraints: Unknown option *%s %s!\n",
+      DEBUG_printf(("8ppd_load_constraints: Unknown option *%s %s!",
                    oldconst->option2, oldconst->choice2));
       free(consts->constraints);
       free(consts);
@@ -826,7 +832,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
   {
     if (!constattr->value)
     {
-      DEBUG_puts("ppd_load_constraints: Bad cupsUIConstraints value!");
+      DEBUG_puts("8ppd_load_constraints: Bad cupsUIConstraints value!");
       continue;
     }
 
@@ -836,13 +842,13 @@ ppd_load_constraints(ppd_file_t *ppd)     /* I - PPD file */
 
     if (i == 0)
     {
-      DEBUG_puts("ppd_load_constraints: Bad cupsUIConstraints value!");
+      DEBUG_puts("8ppd_load_constraints: Bad cupsUIConstraints value!");
       continue;
     }
 
     if ((consts = calloc(1, sizeof(_ppd_cups_uiconsts_t))) == NULL)
     {
-      DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
+      DEBUG_puts("8ppd_load_constraints: Unable to allocate memory for "
                 "cupsUIConstraints!");
       return;
     }
@@ -850,7 +856,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
     if ((constptr = calloc(i, sizeof(_ppd_cups_uiconst_t))) == NULL)
     {
       free(consts);
-      DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
+      DEBUG_puts("8ppd_load_constraints: Unable to allocate memory for "
                 "cupsUIConstraints!");
       return;
     }
@@ -901,7 +907,7 @@ ppd_load_constraints(ppd_file_t *ppd)       /* I - PPD file */
 
       if (!constptr->option || (!constptr->choice && choice[0]))
       {
-       DEBUG_printf(("ppd_load_constraints: Unknown option *%s %s!\n",
+       DEBUG_printf(("8ppd_load_constraints: Unknown option *%s %s!",
                      option, choice));
        break;
       }
@@ -940,13 +946,14 @@ ppd_test_constraints(
   const char           *value;         /* Current value */
 
 
-  DEBUG_printf(("ppd_test_constraints(ppd=%p, num_options=%d, options=%p, "
-                "which=%d)\n", ppd, num_options, options, which));
+  DEBUG_printf(("7ppd_test_constraints(ppd=%p, option=\"%s\", choice=\"%s\", "
+                "num_options=%d, options=%p, which=%d)", ppd, option, choice,
+               num_options, options, which));
 
   if (!ppd->cups_uiconstraints)
     ppd_load_constraints(ppd);
 
-  DEBUG_printf(("ppd_test_constraints: %d constraints!\n",
+  DEBUG_printf(("9ppd_test_constraints: %d constraints!",
                cupsArrayCount(ppd->cups_uiconstraints)));
 
   cupsArraySave(ppd->marked);
@@ -955,9 +962,9 @@ ppd_test_constraints(
        consts;
        consts = (_ppd_cups_uiconsts_t *)cupsArrayNext(ppd->cups_uiconstraints))
   {
-    DEBUG_printf(("ppd_test_constraints: installable=%d, resolver=\"%s\", "
+    DEBUG_printf(("9ppd_test_constraints: installable=%d, resolver=\"%s\", "
                   "num_constraints=%d option1=\"%s\", choice1=\"%s\", "
-                 "option2=\"%s\", choice2=\"%s\", ...\n",
+                 "option2=\"%s\", choice2=\"%s\", ...",
                  consts->installable, consts->resolver, consts->num_constraints,
                  consts->constraints[0].option->keyword,
                  consts->constraints[0].choice ?
@@ -966,16 +973,35 @@ ppd_test_constraints(
                  consts->constraints[1].choice ?
                      consts->constraints[1].choice->choice : ""));
 
-    if (which != _PPD_ALL_CONSTRAINTS && which != consts->installable)
-      continue;
+    if (consts->installable && which < _PPD_INSTALLABLE_CONSTRAINTS)
+      continue;                                /* Skip installable option constraint */
+
+    if (!consts->installable && which == _PPD_INSTALLABLE_CONSTRAINTS)
+      continue;                                /* Skip non-installable option constraint */
+
+    if (which == _PPD_OPTION_CONSTRAINTS && option)
+    {
+     /*
+      * Skip constraints that do not involve the current option...
+      */
+
+      for (i = consts->num_constraints, constptr = consts->constraints;
+          i > 0;
+          i --, constptr ++)
+        if (!strcasecmp(constptr->option->keyword, option))
+         break;
+
+      if (!i)
+        continue;
+    }
 
-    DEBUG_puts("ppd_test_constraints: Testing...");
+    DEBUG_puts("9ppd_test_constraints: Testing...");
 
     for (i = consts->num_constraints, constptr = consts->constraints;
          i > 0;
         i --, constptr ++)
     {
-      DEBUG_printf(("ppd_test_constraints: %s=%s?\n", constptr->option->keyword,
+      DEBUG_printf(("9ppd_test_constraints: %s=%s?", constptr->option->keyword,
                    constptr->choice ? constptr->choice->choice : ""));
 
       if (constptr->choice &&
@@ -1011,7 +1037,7 @@ ppd_test_constraints(
 
         if (!value || strcasecmp(value, constptr->choice->choice))
        {
-         DEBUG_puts("ppd_test_constraints: NO");
+         DEBUG_puts("9ppd_test_constraints: NO");
          break;
        }
       }
@@ -1026,7 +1052,7 @@ ppd_test_constraints(
 
          if (strcasecmp(value, constptr->choice->choice))
          {
-           DEBUG_puts("ppd_test_constraints: NO");
+           DEBUG_puts("9ppd_test_constraints: NO");
            break;
          }
        }
@@ -1038,13 +1064,13 @@ ppd_test_constraints(
 
          if (strcasecmp(value, constptr->choice->choice))
          {
-           DEBUG_puts("ppd_test_constraints: NO");
+           DEBUG_puts("9ppd_test_constraints: NO");
            break;
          }
        }
         else if (!constptr->choice->marked)
        {
-         DEBUG_puts("ppd_test_constraints: NO");
+         DEBUG_puts("9ppd_test_constraints: NO");
          break;
        }
       }
@@ -1054,7 +1080,7 @@ ppd_test_constraints(
        if (!strcasecmp(choice, "None") || !strcasecmp(choice, "Off") ||
            !strcasecmp(choice, "False"))
        {
-         DEBUG_puts("ppd_test_constraints: NO");
+         DEBUG_puts("9ppd_test_constraints: NO");
           break;
        }
       }
@@ -1064,7 +1090,7 @@ ppd_test_constraints(
        if (!strcasecmp(value, "None") || !strcasecmp(value, "Off") ||
            !strcasecmp(value, "False"))
        {
-         DEBUG_puts("ppd_test_constraints: NO");
+         DEBUG_puts("9ppd_test_constraints: NO");
          break;
        }
       }
@@ -1078,7 +1104,7 @@ ppd_test_constraints(
             !strcasecmp(marked->choice, "Off") ||
             !strcasecmp(marked->choice, "False")))
        {
-         DEBUG_puts("ppd_test_constraints: NO");
+         DEBUG_puts("9ppd_test_constraints: NO");
          break;
        }
       }
@@ -1090,13 +1116,13 @@ ppd_test_constraints(
         active = cupsArrayNew(NULL, NULL);
 
       cupsArrayAdd(active, consts);
-      DEBUG_puts("ppd_test_constraints: Added...");
+      DEBUG_puts("9ppd_test_constraints: Added...");
     }
   }
 
   cupsArrayRestore(ppd->marked);
 
-  DEBUG_printf(("ppd_test_constraints: Found %d active constraints!\n",
+  DEBUG_printf(("8ppd_test_constraints: Found %d active constraints!",
                 cupsArrayCount(active)));
 
   return (active);
index 80f28f1c21faec8eee50ca8a2e6adeed8e978ac9..cd622c961512471cb9338b186d8e10b7fc3e3899 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Debugging functions for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2008 by Apple Inc.
+ *   Copyright 2008-2009 by Apple Inc.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Apple Inc. and are protected by Federal copyright
@@ -29,6 +29,7 @@
 #include <sys/time.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <regex.h>
 
 
 /*
@@ -44,8 +45,11 @@ int                  _cups_debug_fd = -1;
  * Local globals...
  */
 
-static int             debug_init = 0; /* Did we initialize debugging? */
+static regex_t         *debug_filter = NULL;
+                                       /* Filter expression for messages */
+static int             debug_init = 1; /* Did we initialize debugging? */
 #  ifdef HAVE_PTHREAD_H
+static int             debug_level = 0;/* Log level (0 to 9) */
 static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER;
                                        /* Mutex to control initialization */
 #  endif /* HAVE_PTHREAD_H */
@@ -393,8 +397,13 @@ _cups_debug_printf(const char *format,     /* I - Printf-style format string */
   struct timeval       curtime;        /* Current time */
   char                 buffer[2048];   /* Output buffer */
   size_t               bytes;          /* Number of bytes in buffer */
-  const char           *cups_debug_log;/* CUPS_DEBUG_LOG environment variable */
-
+  int                  level;          /* Log level in message */
+  const char           *cups_debug_filter,
+                                       /* CUPS_DEBUG_FILTER environment variable */
+                       *cups_debug_level,
+                                       /* CUPS_DEBUG_LEVEL environment variable */
+                       *cups_debug_log;/* CUPS_DEBUG_LOG environment variable */
+                       
 
  /*
   * See if we need to do any logging...
@@ -422,6 +431,23 @@ _cups_debug_printf(const char *format,     /* I - Printf-style format string */
        snprintf(buffer, sizeof(buffer), cups_debug_log, getpid());
        _cups_debug_fd = open(buffer, O_WRONLY | O_APPEND | O_CREAT, 0644);
       }
+
+      if ((cups_debug_level = getenv("CUPS_DEBUG_LEVEL")) != NULL)
+       debug_level = atoi(cups_debug_level);
+
+      if ((cups_debug_filter = getenv("CUPS_DEBUG_FILTER")) != NULL)
+      {
+        if ((debug_filter = (regex_t *)calloc(1, sizeof(regex_t))) == NULL)
+         fputs("Unable to allocate memory for CUPS_DEBUG_FILTER - results not "
+               "filtered!\n", stderr);
+       else if (regcomp(debug_filter, cups_debug_filter, REG_EXTENDED))
+       {
+         fputs("Bad regular expression in CUPS_DEBUG_FILTER - results not "
+               "filtered!\n", stderr);
+         free(debug_filter);
+         debug_filter = NULL;
+       }
+      }
     }
 
     pthread_mutex_unlock(&debug_mutex);
@@ -430,6 +456,30 @@ _cups_debug_printf(const char *format,     /* I - Printf-style format string */
   if (_cups_debug_fd < 0)
     return;
 
+ /*
+  * Filter as needed...
+  */
+
+  if (isdigit(format[0]))
+    level = *format++ - '0';
+  else
+    level = 0;
+
+  if (level > debug_level)
+    return;
+
+  if (debug_filter)
+  {
+    int        result;                         /* Filter result */
+
+    pthread_mutex_lock(&debug_mutex);
+    result = regexec(debug_filter, format, 0, NULL, 0);
+    pthread_mutex_unlock(&debug_mutex);
+
+    if (result)
+      return;
+  }
+
  /*
   * Format the message...
   */
@@ -467,7 +517,14 @@ _cups_debug_printf(const char *format,     /* I - Printf-style format string */
 void
 _cups_debug_puts(const char *s)                /* I - String to output */
 {
-  _cups_debug_printf("%s\n", s);
+  char format[4];                      /* C%s */
+
+  format[0] = *s++;
+  format[1] = '%';
+  format[2] = 's';
+  format[3] = '\0';
+
+  _cups_debug_printf(format, s);
 }
 
 
index 0d81b46cb12a89f1155f2ee39a0b0b52b9718993..e13335bfce523267748582bfa276511356ce9ee7 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Debugging macros for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2005 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -36,6 +36,24 @@ extern "C" {
  *   DEBUG_printf(("format string", arg, arg, ...));
  *
  * Note the extra parenthesis around the DEBUG_printf macro...
+ *
+ * Newlines are not required on the end of messages, as both add one when
+ * writing the output.
+ *
+ * If the first character is a digit, then it represents the "log level" of the
+ * message from 0 to 9.  The default level is 1.  The following defines the
+ * current levels we use:
+ *
+ * 0 = public APIs, other than value accessor functions
+ * 1 = return values for public APIs
+ * 2 = public value accessor APIs, progress for public APIs
+ * 3 = return values for value accessor APIs
+ * 4 = private APIs, progress for value accessor APIs
+ * 5 = return values for private APIs
+ * 6 = progress for private APIs
+ * 7 = static functions
+ * 8 = return values for static functions
+ * 9 = progress for static functions
  */
 
 #  ifdef DEBUG
index 2886a047878b278bc0bf19fb23ac9fd35f96c4b5..f65e3152d1ba38f4864cf5b630a470939a92292b 100644 (file)
@@ -969,7 +969,7 @@ _cupsUserDefault(char   *name,              /* I - Name buffer */
 
   if (!appleUseLastPrinter())
   {
-    DEBUG_puts("_cupsUserDefault: Not using last printer as default...");
+    DEBUG_puts("1_cupsUserDefault: Not using last printer as default...");
     name[0] = '\0';
     return (NULL);
   }
@@ -980,14 +980,14 @@ _cupsUserDefault(char   *name,            /* I - Name buffer */
 
   if ((network = appleCopyNetwork()) == NULL)
   {
-    DEBUG_puts("_cupsUserDefault: Unable to get current network...");
+    DEBUG_puts("1_cupsUserDefault: Unable to get current network...");
     name[0] = '\0';
     return (NULL);
   }
 
 #  ifdef DEBUG
   CFStringGetCString(network, name, namesize, kCFStringEncodingUTF8);
-  DEBUG_printf(("_cupsUserDefault: network=\"%s\"\n", name));
+  DEBUG_printf(("2_cupsUserDefault: network=\"%s\"", name));
 #  endif /* DEBUG */
 
  /*
@@ -1000,7 +1000,7 @@ _cupsUserDefault(char   *name,            /* I - Name buffer */
     * Missing or bad location array, so no location-based default...
     */
 
-    DEBUG_puts("_cupsUserDefault: Missing or bad location history array...");
+    DEBUG_puts("1_cupsUserDefault: Missing or bad location history array...");
 
     CFRelease(network);
 
@@ -1008,7 +1008,7 @@ _cupsUserDefault(char   *name,            /* I - Name buffer */
     return (NULL);
   }
   
-  DEBUG_printf(("_cupsUserDefault: Got location, %d entries...\n",
+  DEBUG_printf(("2_cupsUserDefault: Got location, %d entries...",
                 (int)CFArrayGetCount(locations)));
 
   if ((locprinter = appleGetPrinter(locations, network, NULL)) != NULL)
@@ -1019,7 +1019,7 @@ _cupsUserDefault(char   *name,            /* I - Name buffer */
   CFRelease(network);
   CFRelease(locations);
 
-  DEBUG_printf(("_cupsUserDefault: Returning \"%s\"...\n", name));
+  DEBUG_printf(("1_cupsUserDefault: Returning \"%s\"...", name));
 
   return (*name ? name : NULL);
 
@@ -1191,7 +1191,7 @@ appleSetDefault(const char *name) /* I - Default printer/class name */
 
   if ((network = appleCopyNetwork()) == NULL)
   {
-    DEBUG_puts("appleSetDefault: Unable to get current network...");
+    DEBUG_puts("1appleSetDefault: Unable to get current network...");
     return;
   }
 
@@ -1568,9 +1568,9 @@ cups_get_dests(
   int          linenum;                /* Current line number */
 
 
-  DEBUG_printf(("cups_get_dests(filename=\"%s\", match_name=\"%s\", "
+  DEBUG_printf(("7cups_get_dests(filename=\"%s\", match_name=\"%s\", "
                 "match_inst=\"%s\", user_default_set=%d, num_dests=%d, "
-               "dests=%p)\n", filename, match_name, match_inst,
+               "dests=%p)", filename, match_name, match_inst,
                user_default_set, num_dests, dests));
 
  /*
@@ -1595,12 +1595,12 @@ cups_get_dests(
     * See what type of line it is...
     */
 
-    DEBUG_printf(("cups_get_dests: linenum=%d line=\"%s\" lineptr=\"%s\"\n",
+    DEBUG_printf(("9cups_get_dests: linenum=%d line=\"%s\" lineptr=\"%s\"",
                   linenum, line, lineptr));
 
     if ((strcasecmp(line, "dest") && strcasecmp(line, "default")) || !lineptr)
     {
-      DEBUG_puts("cups_get_dests: Not a dest or default line...");
+      DEBUG_puts("9cups_get_dests: Not a dest or default line...");
       continue;
     }
 
@@ -1635,7 +1635,7 @@ cups_get_dests(
     if (*lineptr)
       *lineptr++ = '\0';
 
-    DEBUG_printf(("cups_get_dests: name=\"%s\", instance=\"%s\"\n", name,
+    DEBUG_printf(("9cups_get_dests: name=\"%s\", instance=\"%s\"", name,
                   instance));
 
    /*
@@ -1655,7 +1655,7 @@ cups_get_dests(
     }
     else if (cupsGetDest(name, NULL, num_dests, *dests) == NULL)
     {
-      DEBUG_puts("cups_get_dests: Not found!");
+      DEBUG_puts("9cups_get_dests: Not found!");
       continue;
     }
     else
@@ -1672,7 +1672,7 @@ cups_get_dests(
        * Out of memory!
        */
 
-        DEBUG_puts("cups_get_dests: Out of memory!");
+        DEBUG_puts("9cups_get_dests: Out of memory!");
         break;
       }
     }
@@ -1697,7 +1697,7 @@ cups_get_dests(
 
     if (!user_default_set && !strcasecmp(line, "default"))
     {
-      DEBUG_puts("cups_get_dests: Setting as default...");
+      DEBUG_puts("9cups_get_dests: Setting as default...");
 
       for (i = 0; i < num_dests; i ++)
         (*dests)[i].is_default = 0;
index 319908f1f5115470924681c793996e3086752326..5cb4d060e5d008c3272e661855e4d2b698d57861 100644 (file)
@@ -5,7 +5,7 @@
  *
  *   This set of APIs abstracts enumeration of directory entries.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2005 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -271,7 +271,7 @@ struct _cups_dir_s                  /**** Directory data structure ****/
 void
 cupsDirClose(cups_dir_t *dp)           /* I - Directory pointer */
 {
-  DEBUG_printf(("cupsDirClose(dp=%p)\n", dp));
+  DEBUG_printf(("cupsDirClose(dp=%p)", dp));
 
  /*
   * Range check input...
@@ -301,7 +301,7 @@ cupsDirOpen(const char *directory)  /* I - Directory name */
   cups_dir_t   *dp;                    /* Directory */
 
 
-  DEBUG_printf(("cupsDirOpen(directory=\"%s\")\n", directory));
+  DEBUG_printf(("cupsDirOpen(directory=\"%s\")", directory));
 
  /*
   * Range check input...
@@ -360,7 +360,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
 #  endif /* HAVE_PTHREAD_H */
 
 
-  DEBUG_printf(("cupsDirRead(dp=%p)\n", dp));
+  DEBUG_printf(("2cupsDirRead(dp=%p)", dp));
 
  /*
   * Range check input...
@@ -382,17 +382,18 @@ cupsDirRead(cups_dir_t *dp)               /* I - Directory pointer */
 
     if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
     {
-      DEBUG_printf(("    readdir_r() failed - %s\n", strerror(errno)));
+      DEBUG_printf(("3cupsDirRead: readdir_r() failed - %s\n", strerror(errno)));
       return (NULL);
     }
 
     if (!entry)
     {
-      DEBUG_puts("    readdir_r() returned a NULL pointer!");
+      DEBUG_puts("3cupsDirRead: readdir_r() returned a NULL pointer!");
       return (NULL);
     }
 
-    DEBUG_printf(("    readdir_r() returned \"%s\"...\n", entry->d_name));
+    DEBUG_printf(("4cupsDirRead: readdir_r() returned \"%s\"...",
+                  entry->d_name));
 
 #  else
    /*
@@ -401,11 +402,11 @@ cupsDirRead(cups_dir_t *dp)               /* I - Directory pointer */
 
     if ((entry = readdir(dp->dir)) == NULL)
     {
-      DEBUG_puts("    readdir() returned a NULL pointer!");
+      DEBUG_puts("3cupsDirRead: readdir() returned a NULL pointer!");
       return (NULL);
     }
 
-    DEBUG_printf(("    readdir() returned \"%s\"...\n", entry->d_name));
+    DEBUG_printf(("4cupsDirRead: readdir() returned \"%s\"...", entry->d_name));
 
 #  endif /* HAVE_PTHREAD_H */
 
@@ -426,7 +427,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
 
     if (stat(filename, &(dp->entry.fileinfo)))
     {
-      DEBUG_printf(("    stat() failed for \"%s\" - %s...\n", filename,
+      DEBUG_printf(("3cupsDirRead: stat() failed for \"%s\" - %s...", filename,
                     strerror(errno)));
       continue;
     }
@@ -449,7 +450,7 @@ cupsDirRead(cups_dir_t *dp)         /* I - Directory pointer */
 void
 cupsDirRewind(cups_dir_t *dp)          /* I - Directory pointer */
 {
-  DEBUG_printf(("cupsDirRewind(dp=%p)\n", dp));
+  DEBUG_printf(("cupsDirRewind(dp=%p)", dp));
 
  /*
   * Range check input...
index 3389607f95f7652e349350c418c57d1a336db0cd..922c8b917e9eccb4e3ffe15dbc08db554f0668a2 100644 (file)
@@ -109,7 +109,7 @@ ppdCollect2(ppd_file_t    *ppd,             /* I - PPD file data */
   float                *orders;                /* Collected order values */
 
 
-  DEBUG_printf(("ppdCollect2(ppd=%p, section=%d, min_order=%f, choices=%p)\n",
+  DEBUG_printf(("ppdCollect2(ppd=%p, section=%d, min_order=%f, choices=%p)",
                 ppd, section, min_order, choices));
 
   if (!ppd || !choices)
@@ -223,7 +223,7 @@ ppdCollect2(ppd_file_t    *ppd,             /* I - PPD file data */
 
   free(orders);
 
-  DEBUG_printf(("ppdCollect2: %d marked choices...\n", count));
+  DEBUG_printf(("2ppdCollect2: %d marked choices...", count));
 
  /*
   * Return the array and number of choices; if 0, free the array since
@@ -626,7 +626,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
   struct lconv *loc;                   /* Locale data */
 
 
-  DEBUG_printf(("ppdEmitString(ppd=%p, section=%d, min_order=%f)\n",
+  DEBUG_printf(("ppdEmitString(ppd=%p, section=%d, min_order=%f)",
                 ppd, section, min_order));
 
  /*
@@ -697,7 +697,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
            !strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
           !strcasecmp(choices[i]->choice, "Custom"))
       {
-        DEBUG_puts("ppdEmitString: Custom size set!");
+        DEBUG_puts("2ppdEmitString: Custom size set!");
 
         bufsize += 37;                 /* %%BeginFeature: *CustomPageSize True\n */
         bufsize += 50;                 /* Five 9-digit numbers + newline */
@@ -752,7 +752,7 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
   * Allocate memory...
   */
 
-  DEBUG_printf(("ppdEmitString: Allocating %d bytes for string...\n",
+  DEBUG_printf(("2ppdEmitString: Allocating %d bytes for string...",
                 (int)bufsize));
 
   if ((buffer = calloc(1, bufsize)) == NULL)
@@ -865,8 +865,8 @@ ppdEmitString(ppd_file_t    *ppd,   /* I - PPD file record */
       * Send DSC comments with option...
       */
 
-      DEBUG_printf(("Adding code for %s=%s...\n", choices[i]->option->keyword,
-                    choices[i]->choice));
+      DEBUG_printf(("2ppdEmitString: Adding code for %s=%s...",
+                   choices[i]->option->keyword, choices[i]->choice));
 
       if ((!strcasecmp(choices[i]->option->keyword, "PageSize") ||
            !strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
@@ -1070,7 +1070,7 @@ ppdEmitString(ppd_file_t    *ppd, /* I - PPD file record */
                      "} stopped cleartomark\n", bufend - bufptr + 1);
       bufptr += strlen(bufptr);
 
-      DEBUG_printf(("ppdEmitString: Offset in string is %d...\n",
+      DEBUG_printf(("2ppdEmitString: Offset in string is %d...",
                     (int)(bufptr - buffer)));
     }
     else
index 7ef63c9158796820ff8445401edc723037250f5e..3bdcbba052b4dff7b46b56d7d3b75fec51d08ff7 100644 (file)
@@ -187,7 +187,7 @@ cupsEncodeOptions(ipp_t         *ipp,               /* I - Request to add to */
                  int           num_options,    /* I - Number of options */
                  cups_option_t *options)       /* I - Options */
 {
-  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)\n", ipp, num_options, options));
+  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)", ipp, num_options, options));
 
  /*
   * Add the options in the proper groups & order...
@@ -232,7 +232,7 @@ cupsEncodeOptions2(
 
 
   DEBUG_printf(("cupsEncodeOptions2(ipp=%p, num_options=%d, options=%p, "
-                "group_tag=%x)\n", ipp, num_options, options, group_tag));
+                "group_tag=%x)", ipp, num_options, options, group_tag));
 
  /*
   * Range check input...
@@ -340,7 +340,7 @@ cupsEncodeOptions2(
     else
       count = 1;
 
-    DEBUG_printf(("cupsEncodeOptions2: option = \'%s\', count = %d\n",
+    DEBUG_printf(("2cupsEncodeOptions2: option=\"%s\", count=%d",
                   option->name, count));
 
    /*
@@ -353,7 +353,7 @@ cupsEncodeOptions2(
       * Ran out of memory!
       */
 
-      DEBUG_puts("cupsEncodeOptions2: Ran out of memory for attributes!");
+      DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for attributes!");
       return;
     }
 
@@ -382,7 +382,7 @@ cupsEncodeOptions2(
        * Ran out of memory!
        */
 
-       DEBUG_puts("cupsEncodeOptions2: Ran out of memory for value copy!");
+       DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for value copy!");
        ippDeleteAttribute(ipp, attr);
        return;
       }
@@ -459,8 +459,8 @@ cupsEncodeOptions2(
 
             attr->values[j].integer = strtol(val, &s, 10);
 
-            DEBUG_printf(("cupsEncodeOptions2: Added integer option value %d...\n",
-                         attr->values[j].integer));
+            DEBUG_printf(("2cupsEncodeOptions2: Added integer option value "
+                         "%d...", attr->values[j].integer));
             break;
 
        case IPP_TAG_BOOLEAN :
@@ -474,7 +474,7 @@ cupsEncodeOptions2(
 
              attr->values[j].boolean = 1;
 
-              DEBUG_puts("cupsEncodeOptions2: Added boolean true value...");
+              DEBUG_puts("2cupsEncodeOptions2: Added boolean true value...");
            }
            else
            {
@@ -484,7 +484,7 @@ cupsEncodeOptions2(
 
              attr->values[j].boolean = 0;
 
-              DEBUG_puts("cupsEncodeOptions2: Added boolean false value...");
+              DEBUG_puts("2cupsEncodeOptions2: Added boolean false value...");
            }
             break;
 
@@ -511,8 +511,8 @@ cupsEncodeOptions2(
            else
              attr->values[j].range.upper = attr->values[j].range.lower;
 
-           DEBUG_printf(("cupsEncodeOptions2: Added range option value %d-%d...\n",
-                         attr->values[j].range.lower,
+           DEBUG_printf(("2cupsEncodeOptions2: Added range option value "
+                         "%d-%d...", attr->values[j].range.lower,
                          attr->values[j].range.upper));
             break;
 
@@ -533,8 +533,8 @@ cupsEncodeOptions2(
             else
               attr->values[j].resolution.units = IPP_RES_PER_INCH;
 
-           DEBUG_printf(("cupsEncodeOptions2: Added resolution option value %s...\n",
-                         val));
+           DEBUG_printf(("2cupsEncodeOptions2: Added resolution option value "
+                         "%s...", val));
             break;
 
        case IPP_TAG_STRING :
@@ -545,8 +545,8 @@ cupsEncodeOptions2(
             attr->values[j].unknown.length = (int)strlen(val);
            attr->values[j].unknown.data   = strdup(val);
 
-            DEBUG_printf(("cupsEncodeOptions2: Added octet-string value "
-                         "\"%s\"...\n", (char *)attr->values[j].unknown.data));
+            DEBUG_printf(("2cupsEncodeOptions2: Added octet-string value "
+                         "\"%s\"...", (char *)attr->values[j].unknown.data));
             break;
 
         case IPP_TAG_BEGIN_COLLECTION :
@@ -578,7 +578,7 @@ cupsEncodeOptions2(
              * Ran out of memory!
              */
 
-             DEBUG_puts("cupsEncodeOptions2: Ran out of memory for string!");
+             DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for string!");
 
              if (copy)
                free(copy);
@@ -587,7 +587,7 @@ cupsEncodeOptions2(
              return;
            }
 
-           DEBUG_printf(("cupsEncodeOptions2: Added string value \"%s\"...\n",
+           DEBUG_printf(("2cupsEncodeOptions2: Added string value \"%s\"...",
                          val));
             break;
       }
index ed54f22fc8ca560011bb1065d183edea81f85cf8..4b9d65e79ffc03976558ac8233c3c7f6e26cc1cb 100644 (file)
@@ -88,7 +88,7 @@ cupsFileClose(cups_file_t *fp)                /* I - CUPS file */
   int  is_stdio;                       /* Is a stdio file? */
 
 
-  DEBUG_printf(("cupsFileClose(fp=%p)\n", fp));
+  DEBUG_printf(("cupsFileClose(fp=%p)", fp));
 
  /*
   * Range check...
@@ -258,6 +258,10 @@ cupsFileFind(const char *filename, /* I - File to find */
   * Range check input...
   */
 
+  DEBUG_printf(("cupsFileFind(filename=\"%s\", path=\"%s\", executable=%d, "
+                "buffer=%p, bufsize=%d)", filename, path, executable, buffer,
+               bufsize));
+
   if (!filename || !buffer || bufsize < 2)
     return (NULL);
 
@@ -302,7 +306,7 @@ cupsFileFind(const char *filename,  /* I - File to find */
       if (!access(buffer, executable ? X_OK : 0))
 #endif /* WIN32 */
       {
-        DEBUG_printf(("cupsFileFind: Returning \"%s\"\n", buffer));
+        DEBUG_printf(("1cupsFileFind: Returning \"%s\"", buffer));
         return (buffer);
       }
 
@@ -325,12 +329,12 @@ cupsFileFind(const char *filename,        /* I - File to find */
 
   if (!access(buffer, 0))
   {
-    DEBUG_printf(("cupsFileFind: Returning \"%s\"\n", buffer));
+    DEBUG_printf(("1cupsFileFind: Returning \"%s\"", buffer));
     return (buffer);
   }
   else
   {
-    DEBUG_puts("cupsFileFind: Returning NULL");
+    DEBUG_puts("1cupsFileFind: Returning NULL");
     return (NULL);
   }
 }
@@ -348,7 +352,7 @@ cupsFileFlush(cups_file_t *fp)              /* I - CUPS file */
   ssize_t      bytes;                  /* Bytes to write */
 
 
-  DEBUG_printf(("cupsFileFlush(fp=%p)\n", fp));
+  DEBUG_printf(("cupsFileFlush(fp=%p)", fp));
 
  /*
   * Range check input...
@@ -356,13 +360,13 @@ cupsFileFlush(cups_file_t *fp)            /* I - CUPS file */
 
   if (!fp || fp->mode != 'w')
   {
-    DEBUG_puts("cupsFileFlush: Attempt to flush a read-only file...");
+    DEBUG_puts("1cupsFileFlush: Attempt to flush a read-only file...");
     return (-1);
   }
 
   bytes = (ssize_t)(fp->ptr - fp->buf);
 
-  DEBUG_printf(("cupsFileFlush: Flushing " CUPS_LLFMT " bytes...\n",
+  DEBUG_printf(("2cupsFileFlush: Flushing " CUPS_LLFMT " bytes...",
                 CUPS_LLCAST bytes));
 
   if (bytes > 0)
@@ -397,11 +401,9 @@ cupsFileGetChar(cups_file_t *fp)   /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileGetChar(fp=%p)\n", fp));
-
   if (!fp || (fp->mode != 'r' && fp->mode != 's'))
   {
-    DEBUG_puts("cupsFileGetChar: Bad arguments!");
+    DEBUG_puts("3cupsFileGetChar: Bad arguments!");
     return (-1);
   }
 
@@ -412,7 +414,7 @@ cupsFileGetChar(cups_file_t *fp)    /* I - CUPS file */
   if (fp->ptr >= fp->end)
     if (cups_fill(fp) < 0)
     {
-      DEBUG_puts("cupsFileGetChar: Unable to fill buffer!");
+      DEBUG_puts("3cupsFileGetChar: Unable to fill buffer!");
       return (-1);
     }
 
@@ -420,11 +422,11 @@ cupsFileGetChar(cups_file_t *fp)  /* I - CUPS file */
   * Return the next character in the buffer...
   */
 
-  DEBUG_printf(("cupsFileGetChar: Returning %d...\n", *(fp->ptr) & 255));
+  DEBUG_printf(("3cupsFileGetChar: Returning %d...", *(fp->ptr) & 255));
 
   fp->pos ++;
 
-  DEBUG_printf(("cupsFileGetChar: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFileGetChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   return (*(fp->ptr)++ & 255);
 }
@@ -450,8 +452,8 @@ cupsFileGetConf(cups_file_t *fp,    /* I  - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileGetConf(fp=%p, buf=%p, buflen=" CUPS_LLFMT
-                ", value=%p, linenum=%p)\n", fp, buf, CUPS_LLCAST buflen,
+  DEBUG_printf(("2cupsFileGetConf(fp=%p, buf=%p, buflen=" CUPS_LLFMT
+                ", value=%p, linenum=%p)", fp, buf, CUPS_LLCAST buflen,
                value, linenum));
 
   if (!fp || (fp->mode != 'r' && fp->mode != 's') ||
@@ -594,7 +596,7 @@ cupsFileGetLine(cups_file_t *fp,    /* I - File to read from */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")\n",
+  DEBUG_printf(("2cupsFileGetLine(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")",
                 fp, buf, CUPS_LLCAST buflen));
 
   if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 3)
@@ -643,7 +645,7 @@ cupsFileGetLine(cups_file_t *fp,    /* I - File to read from */
 
   *ptr = '\0';
 
-  DEBUG_printf(("cupsFileGetLine: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFileGetLine: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   return (ptr - buf);
 }
@@ -669,7 +671,7 @@ cupsFileGets(cups_file_t *fp,               /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")\n", fp, buf,
+  DEBUG_printf(("2cupsFileGets(fp=%p, buf=%p, buflen=" CUPS_LLFMT ")", fp, buf,
                 CUPS_LLCAST buflen));
 
   if (!fp || (fp->mode != 'r' && fp->mode != 's') || !buf || buflen < 2)
@@ -725,7 +727,7 @@ cupsFileGets(cups_file_t *fp,               /* I - CUPS file */
 
   *ptr = '\0';
 
-  DEBUG_printf(("cupsFileGets: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFileGets: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   return (buf);
 }
@@ -806,7 +808,7 @@ cupsFileOpen(const char *filename,  /* I - Name of file */
   http_addrlist_t *addrlist;           /* Host address list */
 
 
-  DEBUG_printf(("cupsFileOpen(filename=\"%s\", mode=\"%s\")\n", filename,
+  DEBUG_printf(("cupsFileOpen(filename=\"%s\", mode=\"%s\")", filename,
                 mode));
 
  /*
@@ -909,7 +911,7 @@ cupsFileOpenFd(int        fd,               /* I - File descriptor */
   cups_file_t  *fp;                    /* New CUPS file */
 
 
-  DEBUG_printf(("cupsFileOpenFd(fd=%d, mode=\"%s\")\n", fd, mode));
+  DEBUG_printf(("cupsFileOpenFd(fd=%d, mode=\"%s\")", fd, mode));
 
  /*
   * Range check input...
@@ -1055,7 +1057,7 @@ cupsFilePrintf(cups_file_t *fp,           /* I - CUPS file */
   ssize_t      bytes;                  /* Formatted size */
 
 
-  DEBUG_printf(("cupsFilePrintf(fp=%p, format=\"%s\", ...)\n", fp, format));
+  DEBUG_printf(("2cupsFilePrintf(fp=%p, format=\"%s\", ...)", fp, format));
 
   if (!fp || !format || (fp->mode != 'w' && fp->mode != 's'))
     return (-1);
@@ -1106,7 +1108,7 @@ cupsFilePrintf(cups_file_t *fp,           /* I - CUPS file */
 
     fp->pos += bytes;
 
-    DEBUG_printf(("cupsFilePrintf: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+    DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
     return (bytes);
   }
@@ -1117,7 +1119,7 @@ cupsFilePrintf(cups_file_t *fp,           /* I - CUPS file */
 
   fp->pos += bytes;
 
-  DEBUG_printf(("cupsFilePrintf: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFilePrintf: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   if (bytes > sizeof(fp->buf))
   {
@@ -1183,7 +1185,7 @@ cupsFilePutChar(cups_file_t *fp,  /* I - CUPS file */
 
   fp->pos ++;
 
-  DEBUG_printf(("cupsFilePutChar: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFilePutChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   return (0);
 }
@@ -1285,7 +1287,7 @@ cupsFilePuts(cups_file_t *fp,             /* I - CUPS file */
 
     fp->pos += bytes;
 
-    DEBUG_printf(("cupsFilePuts: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+    DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
     return (bytes);
   }
@@ -1296,7 +1298,7 @@ cupsFilePuts(cups_file_t *fp,             /* I - CUPS file */
 
   fp->pos += bytes;
 
-  DEBUG_printf(("cupsFilePuts: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFilePuts: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   if (bytes > sizeof(fp->buf))
   {
@@ -1331,7 +1333,7 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
   ssize_t      count;                  /* Bytes read */
 
 
-  DEBUG_printf(("cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf,
+  DEBUG_printf(("2cupsFileRead(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", fp, buf,
                 CUPS_LLCAST bytes));
 
  /*
@@ -1354,8 +1356,8 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
     if (fp->ptr >= fp->end)
       if (cups_fill(fp) <= 0)
       {
-        DEBUG_printf(("cupsFileRead: cups_fill() returned -1, total=" CUPS_LLFMT "\n",
-                     CUPS_LLCAST total));
+        DEBUG_printf(("4cupsFileRead: cups_fill() returned -1, total="
+                     CUPS_LLFMT, CUPS_LLCAST total));
 
         if (total > 0)
           return ((ssize_t)total);
@@ -1371,7 +1373,7 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
     fp->ptr += count;
     fp->pos += count;
 
-    DEBUG_printf(("cupsFileRead: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+    DEBUG_printf(("4cupsFileRead: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
    /*
     * Update the counts for the last read...
@@ -1386,7 +1388,7 @@ cupsFileRead(cups_file_t *fp,             /* I - CUPS file */
   * Return the total number of bytes read...
   */
 
-  DEBUG_printf(("cupsFileRead: total=%d\n", (int)total));
+  DEBUG_printf(("3cupsFileRead: total=" CUPS_LLFMT, CUPS_LLCAST total));
 
   return ((ssize_t)total);
 }
@@ -1406,8 +1408,8 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileRewind(fp=%p)\n", fp));
-  DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("cupsFileRewind(fp=%p)", fp));
+  DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   if (!fp || fp->mode != 'r')
     return (-1);
@@ -1430,7 +1432,7 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
       fp->eof = 0;
     }
 
-    DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+    DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
     return (0);
   }
@@ -1449,7 +1451,7 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
 
   if (lseek(fp->fd, 0, SEEK_SET))
   {
-    DEBUG_printf(("cupsFileRewind: lseek failed: %s\n", strerror(errno)));
+    DEBUG_printf(("1cupsFileRewind: lseek failed: %s", strerror(errno)));
     return (-1);
   }
 
@@ -1459,7 +1461,7 @@ cupsFileRewind(cups_file_t *fp)           /* I - CUPS file */
   fp->end    = NULL;
   fp->eof    = 0;
 
-  DEBUG_printf(("cupsFileRewind: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("2cupsFileRewind: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   return (0);
 }
@@ -1478,10 +1480,10 @@ cupsFileSeek(cups_file_t *fp,           /* I - CUPS file */
   ssize_t      bytes;                  /* Number bytes in buffer */
 
 
-  DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")\n", fp,
+  DEBUG_printf(("cupsFileSeek(fp=%p, pos=" CUPS_LLFMT ")", fp,
                 CUPS_LLCAST pos));
-  DEBUG_printf(("cupsFileSeek: fp->pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
-  DEBUG_printf(("cupsFileSeek: fp->ptr=%p, fp->end=%p\n", fp->ptr, fp->end));
+  DEBUG_printf(("2cupsFileSeek: fp->pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
+  DEBUG_printf(("2cupsFileSeek: fp->ptr=%p, fp->end=%p", fp->ptr, fp->end));
 
  /*
   * Range check input...
@@ -1501,7 +1503,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
   {
     bytes = (ssize_t)(fp->end - fp->buf);
 
-    DEBUG_printf(("cupsFileSeek: bytes=" CUPS_LLFMT "\n", CUPS_LLCAST bytes));
+    DEBUG_printf(("2cupsFileSeek: bytes=" CUPS_LLFMT, CUPS_LLCAST bytes));
 
     if (pos >= fp->bufpos && pos < (fp->bufpos + bytes))
     {
@@ -1541,7 +1543,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
     * Need to seek backwards...
     */
 
-    DEBUG_puts("cupsFileSeek: SEEK BACKWARDS");
+    DEBUG_puts("2cupsFileSeek: SEEK BACKWARDS");
 
 #ifdef HAVE_LIBZ
     if (fp->compressed)
@@ -1572,7 +1574,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
       fp->ptr    = NULL;
       fp->end    = NULL;
 
-      DEBUG_printf(("cupsFileSeek: lseek() returned " CUPS_LLFMT "...\n",
+      DEBUG_printf(("2cupsFileSeek: lseek() returned " CUPS_LLFMT,
                     CUPS_LLCAST fp->pos));
     }
   }
@@ -1582,7 +1584,7 @@ cupsFileSeek(cups_file_t *fp,             /* I - CUPS file */
     * Need to seek forwards...
     */
 
-    DEBUG_puts("cupsFileSeek: SEEK FORWARDS");
+    DEBUG_puts("2cupsFileSeek: SEEK FORWARDS");
 
 #ifdef HAVE_LIBZ
     if (fp->compressed)
@@ -1607,12 +1609,12 @@ cupsFileSeek(cups_file_t *fp,           /* I - CUPS file */
       fp->ptr    = NULL;
       fp->end    = NULL;
 
-      DEBUG_printf(("cupsFileSeek: lseek() returned " CUPS_LLFMT "...\n",
+      DEBUG_printf(("2cupsFileSeek: lseek() returned " CUPS_LLFMT,
                     CUPS_LLCAST fp->pos));
     }
   }
 
-  DEBUG_printf(("cupsFileSeek: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("2cupsFileSeek: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   return (fp->pos);
 }
@@ -1729,8 +1731,9 @@ cupsFileStdout(void)
 off_t                                  /* O - File position */
 cupsFileTell(cups_file_t *fp)          /* I - CUPS file */
 {
-  DEBUG_printf(("cupsFileTell(fp=%p)\n", fp));
-  DEBUG_printf(("cupsFileTell: pos=" CUPS_LLFMT "\n", CUPS_LLCAST (fp ? fp->pos : -1)));
+  DEBUG_printf(("2cupsFileTell(fp=%p)", fp));
+  DEBUG_printf(("3cupsFileTell: pos=" CUPS_LLFMT,
+               CUPS_LLCAST (fp ? fp->pos : -1)));
 
   return (fp ? fp->pos : 0);
 }
@@ -1749,7 +1752,7 @@ cupsFileUnlock(cups_file_t *fp)           /* I - CUPS file */
   * Range check...
   */
 
-  DEBUG_printf(("cupsFileUnlock(fp=%p)\n", fp));
+  DEBUG_printf(("cupsFileUnlock(fp=%p)", fp));
 
   if (!fp || fp->mode == 's')
     return (-1);
@@ -1781,7 +1784,7 @@ cupsFileWrite(cups_file_t *fp,            /* I - CUPS file */
   * Range check input...
   */
 
-  DEBUG_printf(("cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n",
+  DEBUG_printf(("2cupsFileWrite(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")",
                 fp, buf, CUPS_LLCAST bytes));
 
   if (!fp || !buf || bytes < 0 || (fp->mode != 'w' && fp->mode != 's'))
@@ -1801,7 +1804,7 @@ cupsFileWrite(cups_file_t *fp,            /* I - CUPS file */
 
     fp->pos += (off_t)bytes;
 
-    DEBUG_printf(("cupsFileWrite: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+    DEBUG_printf(("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
     return ((ssize_t)bytes);
   }
@@ -1812,7 +1815,7 @@ cupsFileWrite(cups_file_t *fp,            /* I - CUPS file */
 
   fp->pos += (off_t)bytes;
 
-  DEBUG_printf(("cupsFileWrite: pos=" CUPS_LLFMT "\n", CUPS_LLCAST fp->pos));
+  DEBUG_printf(("4cupsFileWrite: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos));
 
   if (bytes > sizeof(fp->buf))
   {
@@ -1842,7 +1845,7 @@ cups_compress(cups_file_t *fp,            /* I - CUPS file */
               const char  *buf,                /* I - Buffer */
              size_t      bytes)        /* I - Number bytes */
 {
-  DEBUG_printf(("cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT "\n", fp, buf,
+  DEBUG_printf(("7cups_compress(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", fp, buf,
                 CUPS_LLCAST bytes));
 
  /*
@@ -1864,7 +1867,7 @@ cups_compress(cups_file_t *fp,            /* I - CUPS file */
     * Flush the current buffer...
     */
 
-    DEBUG_printf(("cups_compress: avail_in=%d, avail_out=%d\n",
+    DEBUG_printf(("9cups_compress: avail_in=%d, avail_out=%d",
                   fp->stream.avail_in, fp->stream.avail_out));
 
     if (fp->stream.avail_out < (int)(sizeof(fp->cbuf) / 8))
@@ -1899,16 +1902,16 @@ cups_fill(cups_file_t *fp)              /* I - CUPS file */
 #endif /* HAVE_LIBZ */
 
 
-  DEBUG_printf(("cups_fill(fp=%p)\n", fp));
-  DEBUG_printf(("cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, "
-                "fp->bufpos=" CUPS_LLFMT ", fp->eof=%d\n",
+  DEBUG_printf(("7cups_fill(fp=%p)", fp));
+  DEBUG_printf(("9cups_fill: fp->ptr=%p, fp->end=%p, fp->buf=%p, "
+                "fp->bufpos=" CUPS_LLFMT ", fp->eof=%d",
                 fp->ptr, fp->end, fp->buf, CUPS_LLCAST fp->bufpos, fp->eof));
 
   if (fp->ptr && fp->end)
     fp->bufpos += fp->end - fp->buf;
 
 #ifdef HAVE_LIBZ
-  DEBUG_printf(("cups_fill: fp->compressed=%d\n", fp->compressed));
+  DEBUG_printf(("9cups_fill: fp->compressed=%d", fp->compressed));
 
   while (!fp->ptr || fp->compressed)
   {
@@ -1936,7 +1939,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
        * Can't read from file!
        */
 
-        DEBUG_printf(("cups_fill: cups_read() returned " CUPS_LLFMT "!\n",
+        DEBUG_printf(("9cups_fill: cups_read() returned " CUPS_LLFMT,
                      CUPS_LLCAST bytes));
 
        return (-1);
@@ -1953,7 +1956,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
        fp->ptr = fp->buf;
        fp->end = fp->buf + bytes;
 
-        DEBUG_printf(("cups_fill: Returning " CUPS_LLFMT "!\n",
+        DEBUG_printf(("9cups_fill: Returning " CUPS_LLFMT,
                      CUPS_LLCAST bytes));
 
        return (bytes);
@@ -2144,7 +2147,7 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
             * Bad CRC, mark end-of-file...
            */
 
-            DEBUG_printf(("cups_fill: tcrc=%08x, fp->crc=%08x\n",
+            DEBUG_printf(("9cups_fill: tcrc=%08x, fp->crc=%08x",
                          (unsigned int)tcrc, (unsigned int)fp->crc));
 
            fp->eof = 1;
@@ -2217,7 +2220,7 @@ cups_read(cups_file_t *fp,                /* I - CUPS file */
   ssize_t      total;                  /* Total bytes read */
 
 
-  DEBUG_printf(("cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf,
+  DEBUG_printf(("7cups_read(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", fp, buf,
                 CUPS_LLCAST bytes));
 
  /*
@@ -2238,7 +2241,7 @@ cups_read(cups_file_t *fp,                /* I - CUPS file */
       total = read(fp->fd, buf, bytes);
 #endif /* WIN32 */
 
-    DEBUG_printf(("cups_read: total=" CUPS_LLFMT "\n", CUPS_LLCAST total));
+    DEBUG_printf(("9cups_read: total=" CUPS_LLFMT, CUPS_LLCAST total));
 
     if (total >= 0)
       break;
@@ -2274,7 +2277,7 @@ cups_write(cups_file_t *fp,               /* I - CUPS file */
   ssize_t      count;                  /* Count this time */
 
 
-  DEBUG_printf(("cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")\n", fp, buf,
+  DEBUG_printf(("7cups_write(fp=%p, buf=%p, bytes=" CUPS_LLFMT ")", fp, buf,
                 CUPS_LLCAST bytes));
 
  /*
@@ -2296,7 +2299,7 @@ cups_write(cups_file_t *fp,               /* I - CUPS file */
       count = write(fp->fd, buf, bytes);
 #endif /* WIN32 */
 
-    DEBUG_printf(("cups_write: count=" CUPS_LLFMT "\n", CUPS_LLCAST count));
+    DEBUG_printf(("9cups_write: count=" CUPS_LLFMT, CUPS_LLCAST count));
 
     if (count < 0)
     {
index 4f5f8d00049f8e2be58cf8167e8a15cd6d169ef9..44500d3fcbb81f6bb9df621612627abe76ac1131 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   cupsGetDevices implementation for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2008 by Apple Inc.
+ *   Copyright 2008-2009 by Apple Inc.
  *
  *   These coded instructions, statements, and computer programs are the
  *   property of Apple Inc. and are protected by Federal copyright
@@ -66,6 +66,11 @@ cupsGetDevices(
   * Range check input...
   */
 
+  DEBUG_printf(("cupsGetDevices(http=%p, timeout=%d, include_schemes=\"%s\", "
+                "exclude_schemes=\"%s\", callback=%p, user_data=%p)", http,
+               timeout, include_schemes, exclude_schemes, callback,
+               user_data));
+
   if (!callback)
     return (IPP_INTERNAL_ERROR);
 
@@ -107,10 +112,10 @@ cupsGetDevices(
 
   do
   {
-    DEBUG_puts("cupsGetDevices: Sending request...");
+    DEBUG_puts("2cupsGetDevices: Sending request...");
     status = cupsSendRequest(http, request, "/", ippLength(request));
 
-    DEBUG_puts("cupsGetDevices: Waiting for response status...");
+    DEBUG_puts("2cupsGetDevices: Waiting for response status...");
     while (status == HTTP_CONTINUE)
       status = httpUpdate(http);
 
@@ -124,14 +129,12 @@ cupsGetDevices(
        * See if we can do authentication...
        */
 
-       int auth_result;
-
-       DEBUG_puts("cupsGetDevices: Need authorization...");
+       DEBUG_puts("2cupsGetDevices: Need authorization...");
 
-       if ((auth_result = cupsDoAuthentication(http, "POST", "/")) == 0)
+       if (!cupsDoAuthentication(http, "POST", "/"))
          httpReconnect(http);
-       else if (auth_result < 0)
-         http->status = status = HTTP_FORBIDDEN;
+       else
+         break;
       }
 
 #ifdef HAVE_SSL
@@ -141,7 +144,7 @@ cupsGetDevices(
        * Force a reconnect with encryption...
        */
 
-       DEBUG_puts("cupsGetDevices: Need encryption...");
+       DEBUG_puts("2cupsGetDevices: Need encryption...");
 
        if (!httpReconnect(http))
          httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
@@ -151,7 +154,7 @@ cupsGetDevices(
   }
   while (status == HTTP_UNAUTHORIZED || status == HTTP_UPGRADE_REQUIRED);
 
-  DEBUG_printf(("cupsGetDevices: status=%d\n", status));
+  DEBUG_printf(("2cupsGetDevices: status=%d", status));
 
   ippDelete(request);
 
@@ -177,14 +180,14 @@ cupsGetDevices(
   device_uri            = NULL;
   attr                  = NULL;
 
-  DEBUG_puts("cupsGetDevices: Reading response...");
+  DEBUG_puts("2cupsGetDevices: Reading response...");
 
   do
   {
     if ((state = ippRead(http, response)) == IPP_ERROR)
       break;
 
-    DEBUG_printf(("cupsGetDevices: state=%d, response->last=%p\n", state,
+    DEBUG_printf(("2cupsGetDevices: state=%d, response->last=%p", state,
                   response->last));
 
     if (!response->attrs)
@@ -197,8 +200,8 @@ cupsGetDevices(
       else
         attr = attr->next;
 
-      DEBUG_printf(("cupsGetDevices: attr->name=\"%s\", attr->value_tag=%d\n",
-                    attr->name ? attr->name : "(null)", attr->value_tag));
+      DEBUG_printf(("2cupsGetDevices: attr->name=\"%s\", attr->value_tag=%d",
+                    attr->name, attr->value_tag));
 
       if (!attr->name)
       {
@@ -237,7 +240,7 @@ cupsGetDevices(
   }
   while (state != IPP_DATA);
 
-  DEBUG_printf(("cupsGetDevices: state=%d, response->last=%p\n", state,
+  DEBUG_printf(("2cupsGetDevices: state=%d, response->last=%p", state,
                response->last));
 
   if (device_class && device_id && device_info && device_make_and_model &&
@@ -258,7 +261,7 @@ cupsGetDevices(
   {
     attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT);
 
-    DEBUG_printf(("cupsGetDevices: status-code=%s, status-message=\"%s\"\n",
+    DEBUG_printf(("cupsGetDevices: status-code=%s, status-message=\"%s\"",
                  ippErrorString(response->request.status.status_code),
                  attr ? attr->values[0].string.text : ""));
 
index c61da916b8b5294c5be704ac340987bd04b11911..43952dc1f647d219f453e5e3842d33d4dcf2ac1f 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Get/put file functions for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -66,7 +66,7 @@ cupsGetFd(http_t     *http,           /* I - Connection to server or @code CUPS_HTTP_DEFA
   * Range check input...
   */
 
-  DEBUG_printf(("cupsGetFd(http=%p, resource=\"%s\", fd=%d)\n", http,
+  DEBUG_printf(("cupsGetFd(http=%p, resource=\"%s\", fd=%d)", http,
                 resource, fd));
 
   if (!resource || fd < 0)
@@ -179,6 +179,8 @@ cupsGetFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
   * Return the request status...
   */
 
+  DEBUG_printf(("1cupsGetFd: Returning %d...", status));
+
   return (status);
 }
 
@@ -274,7 +276,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
   * Range check input...
   */
 
-  DEBUG_printf(("cupsPutFd(http=%p, resource=\"%s\", fd=%d)\n", http,
+  DEBUG_printf(("cupsPutFd(http=%p, resource=\"%s\", fd=%d)", http,
                 resource, fd));
 
   if (!resource || fd < 0)
@@ -297,7 +299,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
 
   do
   {
-    DEBUG_printf(("cupsPutFd: starting attempt, authstring=\"%s\"...\n",
+    DEBUG_printf(("2cupsPutFd: starting attempt, authstring=\"%s\"...",
                   http->authstring));
 
     httpClearFields(http);
@@ -355,7 +357,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
 
     if (status == HTTP_ERROR && !retries)
     {
-      DEBUG_printf(("cupsPutFd: retry on status %d\n", status));
+      DEBUG_printf(("2cupsPutFd: retry on status %d", status));
 
       retries ++;
 
@@ -373,7 +375,7 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
       continue;
     }
 
-    DEBUG_printf(("cupsPutFd: status=%d\n", status));
+    DEBUG_printf(("2cupsPutFd: status=%d", status));
 
     if (status == HTTP_UNAUTHORIZED)
     {
@@ -432,6 +434,8 @@ cupsPutFd(http_t     *http,         /* I - Connection to server or @code CUPS_HTTP_DEFA
     httpFlush(http);
   }
 
+  DEBUG_printf(("1cupsPutFd: Returning %d...", status));
+
   return (status);
 }
 
index cdf4d1fec907a408398ca52e779f5871b247b200..89139367f903422e0810e5920b107968cab8c7f0 100644 (file)
@@ -142,6 +142,7 @@ typedef struct _cups_globals_s              /**** CUPS global state data ****/
 extern http_t          *_cupsConnect(void);
 extern const char      *_cupsGetPassword(const char *prompt);
 extern _cups_globals_t *_cupsGlobals(void);
+extern void            _cupsSetDefaults(void);
 extern void            _cupsSetError(ipp_status_t status, const char *message,
                                      int localize);
 extern void            _cupsSetHTTPError(http_status_t status);
index 52e828525c86ab694bf59e8bc86d5e652535405f..31c8bca891a3d47dcfcfd4d815c02382b9fb8d8d 100644 (file)
@@ -154,7 +154,7 @@ httpAddrLocalhost(
 #endif /* AF_LOCAL */
 
   if (addr->addr.sa_family == AF_INET &&
-      ntohl(addr->ipv4.sin_addr.s_addr) == 0x7f000001)
+      (ntohl(addr->ipv4.sin_addr.s_addr) & 0xff000000) == 0x7f000000)
     return (1);
 
   return (0);
@@ -184,8 +184,8 @@ httpAddrLookup(
                                        /* Global data */
 
 
-  DEBUG_printf(("httpAddrLookup(addr=%p, name=%p, namelen=%d)\n",
-                addr, name, namelen));
+  DEBUG_printf(("httpAddrLookup(addr=%p, name=%p, namelen=%d)", addr, name,
+               namelen));
 
  /*
   * Range check input...
@@ -289,6 +289,8 @@ httpAddrLookup(
   }
 #endif /* HAVE_GETNAMEINFO */
 
+  DEBUG_printf(("1httpAddrLookup: returning \"%s\"...", name));
+
   return (name);
 }
 
@@ -324,8 +326,7 @@ httpAddrString(const http_addr_t *addr,     /* I - Address to convert */
                char              *s,   /* I - String buffer */
               int               slen)  /* I - Length of string */
 {
-  DEBUG_printf(("httpAddrString(addr=%p, s=%p, slen=%d)\n",
-                addr, s, slen));
+  DEBUG_printf(("httpAddrString(addr=%p, s=%p, slen=%d)", addr, s, slen));
 
  /*
   * Range check input...
@@ -452,7 +453,7 @@ httpAddrString(const http_addr_t *addr,     /* I - Address to convert */
   else
     strlcpy(s, "UNKNOWN", slen);
 
-  DEBUG_printf(("httpAddrString: returning \"%s\"...\n", s));
+  DEBUG_printf(("1httpAddrString: returning \"%s\"...", s));
 
   return (s);
 }
@@ -474,7 +475,7 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */
                                        /* Pointer to library globals */
 
 
-  DEBUG_printf(("httpGetHostByName(name=\"%s\")\n", name));
+  DEBUG_printf(("httpGetHostByName(name=\"%s\")", name));
 
  /*
   * Avoid lookup delays and configuration problems when connecting
@@ -512,7 +513,7 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */
     cg->ip_ptrs[0]          = (char *)name;
     cg->ip_ptrs[1]          = NULL;
 
-    DEBUG_puts("httpGetHostByName: returning domain socket address...");
+    DEBUG_puts("1httpGetHostByName: returning domain socket address...");
 
     return (&cg->hostent);
   }
@@ -548,7 +549,7 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */
     cg->ip_ptrs[0]          = (char *)&(cg->ip_addr);
     cg->ip_ptrs[1]          = NULL;
 
-    DEBUG_puts("httpGetHostByName: returning IPv4 address...");
+    DEBUG_puts("1httpGetHostByName: returning IPv4 address...");
 
     return (&cg->hostent);
   }
@@ -559,7 +560,7 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */
     * the name...
     */
 
-    DEBUG_puts("httpGetHostByName: returning domain lookup address(es)...");
+    DEBUG_puts("1httpGetHostByName: returning domain lookup address(es)...");
 
     return (gethostbyname(name));
   }
index a5b2e1f5884117e0351a14a896bbfc37afaf41d9..e8f7c84dc2f1ba22bbbd5788120e2ec64b00443a 100644 (file)
@@ -50,7 +50,7 @@ httpAddrConnect(
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("httpAddrConnect(addrlist=%p, sock=%p)\n", addrlist, sock));
+  DEBUG_printf(("httpAddrConnect(addrlist=%p, sock=%p)", addrlist, sock));
 
   if (!sock)
   {
@@ -68,7 +68,7 @@ httpAddrConnect(
     * Create the socket...
     */
 
-    DEBUG_printf(("httpAddrConnect: Trying %s:%d...\n",
+    DEBUG_printf(("2httpAddrConnect: Trying %s:%d...",
                  httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
                  _httpAddrPort(&(addrlist->addr))));
 
@@ -134,13 +134,13 @@ httpAddrConnect(
     if (!connect(*sock, &(addrlist->addr.addr),
                  httpAddrLength(&(addrlist->addr))))
     {
-      DEBUG_printf(("httpAddrConnect: Connected to %s:%d...\n",
+      DEBUG_printf(("1httpAddrConnect: Connected to %s:%d...",
                    httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
                    _httpAddrPort(&(addrlist->addr))));
       break;
     }
 
-    DEBUG_printf(("httpAddrConnect: Unable to connect to %s:%d: %s\n",
+    DEBUG_printf(("1httpAddrConnect: Unable to connect to %s:%d: %s",
                  httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
                  _httpAddrPort(&(addrlist->addr)), strerror(errno)));
 
index c59ecfb50d7339107ff4feff6734093e2f23e6db..baa45c1220e4a3b4d5920bef397f74505e6da1cc 100644 (file)
@@ -727,7 +727,7 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
                { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
 
 
-  DEBUG_printf(("httpGetDateTime(s=\"%s\")\n", s));
+  DEBUG_printf(("2httpGetDateTime(s=\"%s\")", s));
 
  /*
   * Extract the date and time from the formatted string...
@@ -736,8 +736,8 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
   if (sscanf(s, "%*s%d%15s%d%d:%d:%d", &day, mon, &year, &hour, &min, &sec) < 6)
     return (0);
 
-  DEBUG_printf(("    day=%d, mon=\"%s\", year=%d, hour=%d, min=%d, sec=%d\n",
-                day, mon, year, hour, min, sec));
+  DEBUG_printf(("4httpGetDateTime: day=%d, mon=\"%s\", year=%d, hour=%d, "
+                "min=%d, sec=%d", day, mon, year, hour, min, sec));
 
  /*
   * Convert the month name to a number from 0 to 11.
@@ -750,7 +750,7 @@ httpGetDateTime(const char *s)              /* I - Date/time string */
   if (i >= 12)
     return (0);
 
-  DEBUG_printf(("    i=%d\n", i));
+  DEBUG_printf(("4httpGetDateTime: i=%d", i));
 
  /*
   * Now convert the date and time to a UNIX time value in seconds since
@@ -763,14 +763,14 @@ httpGetDateTime(const char *s)            /* I - Date/time string */
   else
     days = normal_days[i] + day - 1;
 
-  DEBUG_printf(("    days=%d\n", days));
+  DEBUG_printf(("4httpGetDateTime: days=%d", days));
 
   days += (year - 1970) * 365 +                /* 365 days per year (normally) */
           ((year - 1) / 4 - 492) -     /* + leap days */
          ((year - 1) / 100 - 19) +     /* - 100 year days */
           ((year - 1) / 400 - 4);      /* + 400 year days */
 
-  DEBUG_printf(("    days=%d\n", days));
+  DEBUG_printf(("4httpGetDateTime: days=%d\n", days));
 
   return (days * 86400 + hour * 3600 + min * 60 + sec);
 }
@@ -1313,8 +1313,8 @@ _httpResolveURI(
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("_httpResolveURI(uri=\"%s\", resolved_uri=%p, "
-                "resolved_size=" CUPS_LLFMT ")\n", uri, resolved_uri,
+  DEBUG_printf(("4_httpResolveURI(uri=\"%s\", resolved_uri=%p, "
+                "resolved_size=" CUPS_LLFMT ")", uri, resolved_uri,
                CUPS_LLCAST resolved_size));
 
  /*
@@ -1336,8 +1336,8 @@ _httpResolveURI(
     if (logit)
       _cupsLangPrintf(stderr, _("Bad device URI \"%s\"!\n"), uri);
 
-    DEBUG_printf(("_httpResolveURI: httpSeparateURI returned %d!\n", status));
-    DEBUG_puts("_httpResolveURI: Returning NULL");
+    DEBUG_printf(("6_httpResolveURI: httpSeparateURI returned %d!", status));
+    DEBUG_puts("5_httpResolveURI: Returning NULL");
     return (NULL);
   }
 
@@ -1380,7 +1380,7 @@ _httpResolveURI(
 
     if (regtype <= hostname)
     {
-      DEBUG_puts("_httpResolveURI: Bad hostname, returning NULL");
+      DEBUG_puts("5_httpResolveURI: Bad hostname, returning NULL");
       return (NULL);
     }
 
@@ -1398,7 +1398,7 @@ _httpResolveURI(
 
     resolved_uri[0] = '\0';
 
-    DEBUG_printf(("_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
+    DEBUG_printf(("6_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
                   "domain=\"%s\"\n", hostname, regtype, domain));
     if (logit)
     {
@@ -1479,7 +1479,7 @@ _httpResolveURI(
       _cupsLangPuts(stderr, _("Unable to find printer!\n"));
   }
 
-  DEBUG_printf(("_httpResolveURI: Returning \"%s\"\n", uri));
+  DEBUG_printf(("5_httpResolveURI: Returning \"%s\"", uri));
 
   return (uri);
 }
@@ -1627,9 +1627,9 @@ resolve_callback(
   _http_uribuf_t       *uribuf;        /* URI buffer */
 
 
-  DEBUG_printf(("resolve_callback(sdRef=%p, flags=%x, interfaceIndex=%u, "
+  DEBUG_printf(("7resolve_callback(sdRef=%p, flags=%x, interfaceIndex=%u, "
                "errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, "
-               "txtLen=%u, txtRecord=%p, context=%p)\n", sdRef, flags,
+               "txtLen=%u, txtRecord=%p, context=%p)", sdRef, flags,
                interfaceIndex, errorCode, fullName, hostTarget, port, txtLen,
                txtRecord, context));
 
@@ -1673,7 +1673,7 @@ resolve_callback(
   httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme,
                   NULL, hostTarget, ntohs(port), rp);
 
-  DEBUG_printf(("resolve_callback: Resolved URI is \"%s\"...\n",
+  DEBUG_printf(("8resolve_callback: Resolved URI is \"%s\"...",
                 uribuf->buffer));
 }
 #endif /* HAVE_DNSSD */
index eef9973b841cc967d3c2d5385144da2fab7edd5a..e5920fa3f965c4459409d8873ec276803f74d2a2 100644 (file)
@@ -304,7 +304,7 @@ httpClose(http_t *http)                     /* I - Connection to server */
 #endif /* HAVE_GSSAPI */
 
 
-  DEBUG_printf(("httpClose(http=%p)\n", http));
+  DEBUG_printf(("httpClose(http=%p)", http));
 
   if (!http)
     return;
@@ -376,7 +376,7 @@ httpConnectEncrypt(
   http_t       *http;                  /* New HTTP connection */
 
 
-  DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)\n",
+  DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)",
                 host, port, encryption));
 
  /*
@@ -420,7 +420,7 @@ _httpCreate(
   char                 service[255];   /* Service name */
 
 
-  DEBUG_printf(("_httpCreate(host=\"%s\", port=%d, encryption=%d)\n",
+  DEBUG_printf(("4_httpCreate(host=\"%s\", port=%d, encryption=%d)",
                 host, port, encryption));
 
   if (!host)
@@ -496,7 +496,7 @@ int                                 /* O - -1 on error, 0 on success */
 httpEncryption(http_t            *http,        /* I - Connection to server */
                http_encryption_t e)    /* I - New encryption preference */
 {
-  DEBUG_printf(("httpEncryption(http=%p, e=%d)\n", http, e));
+  DEBUG_printf(("httpEncryption(http=%p, e=%d)", http, e));
 
 #ifdef HAVE_SSL
   if (!http)
@@ -545,7 +545,7 @@ httpFlush(http_t *http)                     /* I - Connection to server */
   int  blocking;                       /* To block or not to block */
 
 
-  DEBUG_printf(("httpFlush(http=%p), state=%d\n", http, http->state));
+  DEBUG_printf(("httpFlush(http=%p), state=%d", http, http->state));
 
  /*
   * Temporarily set non-blocking mode so we don't get stuck in httpRead()...
@@ -603,7 +603,7 @@ httpFlushWrite(http_t *http)                /* I - Connection to server */
   int  bytes;                          /* Bytes written */
 
 
-  DEBUG_printf(("httpFlushWrite(http=%p)\n", http));
+  DEBUG_printf(("httpFlushWrite(http=%p)", http));
 
   if (!http || !http->wused)
     return (0);
@@ -757,14 +757,14 @@ httpGetLength(http_t *http)               /* I - Connection to server */
 off_t                                  /* O - Content length */
 httpGetLength2(http_t *http)           /* I - Connection to server */
 {
-  DEBUG_printf(("httpGetLength2(http=%p), state=%d\n", http, http->state));
+  DEBUG_printf(("2httpGetLength2(http=%p), state=%d", http, http->state));
 
   if (!http)
     return (-1);
 
   if (!strcasecmp(http->fields[HTTP_FIELD_TRANSFER_ENCODING], "chunked"))
   {
-    DEBUG_puts("httpGetLength2: chunked request!");
+    DEBUG_puts("4httpGetLength2: chunked request!");
 
     http->data_encoding  = HTTP_ENCODE_CHUNKED;
     http->data_remaining = 0;
@@ -797,7 +797,7 @@ httpGetLength2(http_t *http)                /* I - Connection to server */
       http->data_remaining = strtoll(http->fields[HTTP_FIELD_CONTENT_LENGTH],
                                      NULL, 10);
 
-    DEBUG_printf(("httpGetLength2: content_length=" CUPS_LLFMT "\n",
+    DEBUG_printf(("4httpGetLength2: content_length=" CUPS_LLFMT,
                   CUPS_LLCAST http->data_remaining));
   }
 
@@ -857,8 +857,8 @@ httpGetSubField2(http_t       *http,        /* I - Connection to server */
                *ptr,                   /* Pointer into string buffer */
                *end;                   /* End of value buffer */
 
-  DEBUG_printf(("httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, valuelen=%d)\n",
-                http, field, name, value, valuelen));
+  DEBUG_printf(("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, "
+                "valuelen=%d)", http, field, name, value, valuelen));
 
   if (!http || !name || !value || valuelen < 2 ||
       field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX)
@@ -892,7 +892,7 @@ httpGetSubField2(http_t       *http,        /* I - Connection to server */
 
     *ptr = '\0';
 
-    DEBUG_printf(("httpGetSubField: name=\"%s\"\n", temp));
+    DEBUG_printf(("4httpGetSubField2: name=\"%s\"", temp));
 
    /*
     * Skip trailing chars up to the '='...
@@ -950,18 +950,23 @@ httpGetSubField2(http_t       *http,      /* I - Connection to server */
         fptr ++;
     }
 
-    DEBUG_printf(("httpGetSubField: value=\"%s\"\n", value));
+    DEBUG_printf(("4httpGetSubField2: value=\"%s\"", value));
 
    /*
     * See if this is the one...
     */
 
     if (!strcmp(name, temp))
+    {
+      DEBUG_printf(("3httpGetSubField2: Returning \"%s\"", value));
       return (value);
+    }
   }
 
   value[0] = '\0';
 
+  DEBUG_puts("3httpGetSubField2: Returning NULL");
+
   return (NULL);
 }
 
@@ -983,7 +988,7 @@ httpGets(char   *line,                      /* I - Line to read into */
        eol;                            /* End-of-line? */
 
 
-  DEBUG_printf(("httpGets(line=%p, length=%d, http=%p)\n", line, length, http));
+  DEBUG_printf(("2httpGets(line=%p, length=%d, http=%p)", line, length, http));
 
   if (http == NULL || line == NULL)
     return (NULL);
@@ -1016,7 +1021,7 @@ httpGets(char   *line,                    /* I - Line to read into */
 
       if (!http->blocking && !_httpWait(http, 10000, 1))
       {
-        DEBUG_puts("httpGets: Timed out!");
+        DEBUG_puts("3httpGets: Timed out!");
 #ifdef WIN32
         http->error = WSAETIMEDOUT;
 #else
@@ -1034,7 +1039,7 @@ httpGets(char   *line,                    /* I - Line to read into */
         bytes = recv(http->fd, http->buffer + http->used,
                     HTTP_MAX_BUFFER - http->used, 0);
 
-      DEBUG_printf(("httpGets: read %d bytes...\n", bytes));
+      DEBUG_printf(("4httpGets: read %d bytes...", bytes));
 
       if (bytes < 0)
       {
@@ -1049,11 +1054,11 @@ httpGets(char   *line,                  /* I - Line to read into */
          continue;
        }
 
-        DEBUG_printf(("httpGets: recv() error %d!\n", WSAGetLastError()));
+        DEBUG_printf(("3httpGets: recv() error %d!", WSAGetLastError()));
 #else
-        DEBUG_printf(("httpGets: recv() error %d!\n", errno));
+        DEBUG_printf(("3httpGets: recv() error %d!", errno));
 
-        if (errno == EINTR)
+        if (errno == EINTR || errno == EAGAIN)
          continue;
        else if (errno != http->error)
        {
@@ -1111,13 +1116,13 @@ httpGets(char   *line,                  /* I - Line to read into */
 
       *lineptr = '\0';
       
-      DEBUG_printf(("httpGets: Returning \"%s\"\n", line));
+      DEBUG_printf(("3httpGets: Returning \"%s\"", line));
 
       return (line);
     }
   }
 
-  DEBUG_puts("httpGets: No new line available!");
+  DEBUG_puts("3httpGets: No new line available!");
 
   return (NULL);
 }
@@ -1131,6 +1136,7 @@ int                                       /* O - Status of call (0 = success) */
 httpHead(http_t     *http,             /* I - Connection to server */
          const char *uri)              /* I - URI for head */
 {
+  DEBUG_printf(("httpHead(http=%p, uri=\"%s\")", http, uri));
   return (http_send(http, HTTP_HEAD, uri));
 }
 
@@ -1244,13 +1250,13 @@ httpPrintf(http_t     *http,            /* I - Connection to server */
   va_list      ap;                     /* Variable argument pointer */
 
 
-  DEBUG_printf(("httpPrintf(http=%p, format=\"%s\", ...)\n", http, format));
+  DEBUG_printf(("2httpPrintf(http=%p, format=\"%s\", ...)", http, format));
 
   va_start(ap, format);
   bytes = vsnprintf(buf, sizeof(buf), format, ap);
   va_end(ap);
 
-  DEBUG_printf(("httpPrintf: %s", buf));
+  DEBUG_printf(("3httpPrintf: %s", buf));
 
   if (http->data_encoding == HTTP_ENCODE_FIELDS)
     return (httpWrite2(http, buf, bytes));
@@ -1258,7 +1264,7 @@ httpPrintf(http_t     *http,              /* I - Connection to server */
   {
     if (http->wused)
     {
-      DEBUG_puts("    flushing existing data...");
+      DEBUG_puts("4httpPrintf: flushing existing data...");
 
       if (httpFlushWrite(http) < 0)
        return (-1);
@@ -1277,6 +1283,7 @@ int                                       /* O - Status of call (0 = success) */
 httpPut(http_t     *http,              /* I - Connection to server */
         const char *uri)               /* I - URI to put */
 {
+  DEBUG_printf(("httpPut(http=%p, uri=\"%s\")", http, uri));
   return (http_send(http, HTTP_PUT, uri));
 }
 
@@ -1314,7 +1321,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
   char         len[32];                /* Length string */
 
 
-  DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ")\n",
+  DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ")",
                 http, buffer, CUPS_LLCAST length));
 
   if (http == NULL || buffer == NULL)
@@ -1328,23 +1335,23 @@ httpRead2(http_t *http,                 /* I - Connection to server */
   if (http->data_encoding == HTTP_ENCODE_CHUNKED &&
       http->data_remaining <= 0)
   {
-    DEBUG_puts("httpRead2: Getting chunk length...");
+    DEBUG_puts("2httpRead2: Getting chunk length...");
 
     if (httpGets(len, sizeof(len), http) == NULL)
     {
-      DEBUG_puts("httpRead2: Could not get length!");
+      DEBUG_puts("1httpRead2: Could not get length!");
       return (0);
     }
 
     http->data_remaining = strtoll(len, NULL, 16);
     if (http->data_remaining < 0)
     {
-      DEBUG_puts("httpRead2: Negative chunk length!");
+      DEBUG_puts("1httpRead2: Negative chunk length!");
       return (0);
     }
   }
 
-  DEBUG_printf(("httpRead2: data_remaining=" CUPS_LLFMT "\n",
+  DEBUG_printf(("2httpRead2: data_remaining=" CUPS_LLFMT,
                 CUPS_LLCAST http->data_remaining));
 
   if (http->data_remaining <= 0)
@@ -1393,12 +1400,12 @@ httpRead2(http_t *http,                 /* I - Connection to server */
     else
 #endif /* HAVE_SSL */
     {
-      DEBUG_printf(("httpRead2: reading %d bytes from socket into buffer...\n",
+      DEBUG_printf(("2httpRead2: reading %d bytes from socket into buffer...",
                     (int)bytes));
 
       bytes = recv(http->fd, http->buffer, bytes, 0);
 
-      DEBUG_printf(("httpRead2: read %d bytes from socket into buffer...\n",
+      DEBUG_printf(("2httpRead2: read %d bytes from socket into buffer...",
                     (int)bytes));
     }
 
@@ -1410,7 +1417,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
       http->error = WSAGetLastError();
       return (-1);
 #else
-      if (errno != EINTR)
+      if (errno != EINTR && errno != EAGAIN)
       {
         http->error = errno;
         return (-1);
@@ -1431,7 +1438,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
 
     bytes = (ssize_t)length;
 
-    DEBUG_printf(("httpRead2: grabbing %d bytes from input buffer...\n",
+    DEBUG_printf(("2httpRead2: grabbing %d bytes from input buffer...",
                   (int)bytes));
 
     memcpy(buffer, http->buffer, length);
@@ -1454,7 +1461,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
     if (!http->blocking && !httpWait(http, 10000))
       return (0);
 
-    DEBUG_printf(("httpRead2: reading " CUPS_LLFMT " bytes from socket...\n",
+    DEBUG_printf(("2httpRead2: reading " CUPS_LLFMT " bytes from socket...",
                   CUPS_LLCAST length));
 
 #ifdef WIN32
@@ -1465,7 +1472,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
         break;
 #endif /* WIN32 */
 
-    DEBUG_printf(("httpRead2: read " CUPS_LLFMT " bytes from socket...\n",
+    DEBUG_printf(("2httpRead2: read " CUPS_LLFMT " bytes from socket...",
                   CUPS_LLCAST bytes));
   }
 
@@ -1552,7 +1559,7 @@ _httpReadCDSA(
   {
     bytes = recv(http->fd, data, *dataLength, 0);
   }
-  while (bytes == -1 && errno == EINTR);
+  while (bytes == -1 && (errno == EINTR || errno == EAGAIN));
 
   if (bytes == *dataLength)
   {
@@ -1628,7 +1635,7 @@ httpReconnect(http_t *http)               /* I - Connection to server */
 #endif /* DEBUG */
 
 
-  DEBUG_printf(("httpReconnect(http=%p)\n", http));
+  DEBUG_printf(("httpReconnect(http=%p)", http));
 
   if (!http)
     return (-1);
@@ -1636,7 +1643,7 @@ httpReconnect(http_t *http)               /* I - Connection to server */
 #ifdef HAVE_SSL
   if (http->tls)
   {
-    DEBUG_puts("httpReconnect: Shutting down SSL/TLS...");
+    DEBUG_puts("2httpReconnect: Shutting down SSL/TLS...");
     http_shutdown_ssl(http);
   }
 #endif /* HAVE_SSL */
@@ -1647,7 +1654,7 @@ httpReconnect(http_t *http)               /* I - Connection to server */
 
   if (http->fd >= 0)
   {
-    DEBUG_printf(("httpReconnect: Closing socket %d...\n", http->fd));
+    DEBUG_printf(("2httpReconnect: Closing socket %d...", http->fd));
 
 #ifdef WIN32
     closesocket(http->fd);
@@ -1666,7 +1673,7 @@ httpReconnect(http_t *http)               /* I - Connection to server */
 
 #ifdef DEBUG
   for (current = http->addrlist; current; current = current->next)
-    DEBUG_printf(("httpReconnect: Address %s:%d\n",
+    DEBUG_printf(("2httpReconnect: Address %s:%d",
                   httpAddrString(&(current->addr), temp, sizeof(temp)),
                   _httpAddrPort(&(current->addr))));
 #endif /* DEBUG */
@@ -1684,13 +1691,13 @@ httpReconnect(http_t *http)             /* I - Connection to server */
 #endif /* WIN32 */
     http->status = HTTP_ERROR;
 
-    DEBUG_printf(("httpReconnect: httpAddrConnect failed: %s\n",
+    DEBUG_printf(("1httpReconnect: httpAddrConnect failed: %s",
                   strerror(http->error)));
 
     return (-1);
   }
 
-  DEBUG_printf(("httpReconnect: New socket=%d\n", http->fd));
+  DEBUG_printf(("2httpReconnect: New socket=%d", http->fd));
 
   http->hostaddr = &(addr->addr);
   http->error    = 0;
@@ -1718,7 +1725,7 @@ httpReconnect(http_t *http)               /* I - Connection to server */
     return (http_upgrade(http));
 #endif /* HAVE_SSL */
 
-  DEBUG_printf(("httpReconnect: Connected to %s:%d...\n",
+  DEBUG_printf(("1httpReconnect: Connected to %s:%d...",
                httpAddrString(http->hostaddr, temp, sizeof(temp)),
                _httpAddrPort(http->hostaddr)));
 
@@ -1844,18 +1851,35 @@ httpSetField(http_t       *http,        /* I - Connection to server */
 
   strlcpy(http->fields[field], value, HTTP_MAX_VALUE);
 
- /*
-  * Special case for Authorization: as its contents can be
-  * longer than HTTP_MAX_VALUE
-  */
-
   if (field == HTTP_FIELD_AUTHORIZATION)
   {
+   /*
+    * Special case for Authorization: as its contents can be
+    * longer than HTTP_MAX_VALUE
+    */
+
     if (http->field_authorization)
       free(http->field_authorization);
 
     http->field_authorization = strdup(value);
   }
+  else if (field == HTTP_FIELD_HOST)
+  {
+   /*
+    * Special-case for Host: as we don't want a trailing "." on the hostname.
+    */
+
+    char *ptr = http->fields[HTTP_FIELD_HOST];
+                                       /* Pointer into Host: field */
+
+    if (*ptr)
+    {
+      ptr += strlen(ptr) - 1;
+
+      if (*ptr == '.')
+        *ptr = '\0';
+    }
+  }
 }
 
 
@@ -1912,7 +1936,7 @@ httpUpdate(http_t *http)          /* I - Connection to server */
                status;                 /* Request status */
 
 
-  DEBUG_printf(("httpUpdate(http=%p), state=%d\n", http, http->state));
+  DEBUG_printf(("httpUpdate(http=%p), state=%d", http, http->state));
 
  /*
   * Flush pending data, if any...
@@ -1920,7 +1944,7 @@ httpUpdate(http_t *http)          /* I - Connection to server */
 
   if (http->wused)
   {
-    DEBUG_puts("    flushing buffer...");
+    DEBUG_puts("2httpUpdate: flushing buffer...");
 
     if (httpFlushWrite(http) < 0)
       return (HTTP_ERROR);
@@ -1939,7 +1963,7 @@ httpUpdate(http_t *http)          /* I - Connection to server */
 
   while (httpGets(line, sizeof(line), http) != NULL)
   {
-    DEBUG_printf(("httpUpdate: Got \"%s\"\n", line));
+    DEBUG_printf(("2httpUpdate: Got \"%s\"", line));
 
     if (line[0] == '\0')
     {
@@ -1996,7 +2020,7 @@ httpUpdate(http_t *http)          /* I - Connection to server */
 
       return (http->status);
     }
-    else if (strncmp(line, "HTTP/", 5) == 0)
+    else if (!strncmp(line, "HTTP/", 5))
     {
      /*
       * Got the beginning of a response...
@@ -2040,7 +2064,7 @@ httpUpdate(http_t *http)          /* I - Connection to server */
       }
       else if ((field = http_field(line)) == HTTP_FIELD_UNKNOWN)
       {
-        DEBUG_printf(("httpUpdate: unknown field %s seen!\n", line));
+        DEBUG_printf(("1httpUpdate: unknown field %s seen!", line));
         continue;
       }
       else
@@ -2048,6 +2072,7 @@ httpUpdate(http_t *http)          /* I - Connection to server */
     }
     else
     {
+      DEBUG_printf(("1httpUpdate: Bad response line \"%s\"!", line));
       http->status = HTTP_ERROR;
       return (HTTP_ERROR);
     }
@@ -2058,11 +2083,14 @@ httpUpdate(http_t *http)                /* I - Connection to server */
   */
 
   if (http->error == EPIPE && http->status > HTTP_CONTINUE)
+  {
+    DEBUG_printf(("1httpUpdate: Returning status %d...", http->status));
     return (http->status);
+  }
 
   if (http->error)
   {
-    DEBUG_printf(("httpUpdate: socket error %d - %s\n", http->error,
+    DEBUG_printf(("1httpUpdate: socket error %d - %s", http->error,
                   strerror(http->error)));
     http->status = HTTP_ERROR;
     return (HTTP_ERROR);
@@ -2094,7 +2122,7 @@ _httpWait(http_t *http,                   /* I - Connection to server */
   int                  nfds;           /* Result from select()/poll() */
 
 
-  DEBUG_printf(("_httpWait(http=%p, msec=%d, usessl=%d)\n", http, msec, usessl));
+  DEBUG_printf(("4_httpWait(http=%p, msec=%d, usessl=%d)", http, msec, usessl));
 
   if (http->fd < 0)
     return (0);
@@ -2130,7 +2158,8 @@ _httpWait(http_t *http,                   /* I - Connection to server */
   pfd.fd     = http->fd;
   pfd.events = POLLIN;
 
-  while ((nfds = poll(&pfd, 1, msec)) < 0 && errno == EINTR);
+  while ((nfds = poll(&pfd, 1, msec)) < 0 &&
+         (errno == EINTR || errno == EAGAIN));
 
 #else
   do
@@ -2138,7 +2167,7 @@ _httpWait(http_t *http,                   /* I - Connection to server */
     FD_ZERO(&input_set);
     FD_SET(http->fd, &input_set);
 
-    DEBUG_printf(("_httpWait: msec=%d, http->fd=%d\n", msec, http->fd));
+    DEBUG_printf(("6_httpWait: msec=%d, http->fd=%d", msec, http->fd));
 
     if (msec >= 0)
     {
@@ -2150,16 +2179,16 @@ _httpWait(http_t *http,                 /* I - Connection to server */
     else
       nfds = select(http->fd + 1, &input_set, NULL, NULL, NULL);
 
-    DEBUG_printf(("_httpWait: select() returned %d...\n", nfds));
+    DEBUG_printf(("6_httpWait: select() returned %d...", nfds));
   }
 #  ifdef WIN32
   while (nfds < 0 && WSAGetLastError() == WSAEINTR);
 #  else
-  while (nfds < 0 && errno == EINTR);
+  while (nfds < 0 && (errno == EINTR || errno == EAGAIN));
 #  endif /* WIN32 */
 #endif /* HAVE_POLL */
 
-  DEBUG_printf(("_httpWait: returning with nfds=%d...\n", nfds));
+  DEBUG_printf(("5_httpWait: returning with nfds=%d...", nfds));
 
   return (nfds > 0);
 }
@@ -2235,7 +2264,7 @@ httpWrite2(http_t     *http,              /* I - Connection to server */
   ssize_t      bytes;                  /* Bytes written */
 
 
-  DEBUG_printf(("httpWrite2(http=%p, buffer=%p, length=" CUPS_LLFMT ")\n", http,
+  DEBUG_printf(("httpWrite2(http=%p, buffer=%p, length=" CUPS_LLFMT ")", http,
                 buffer, CUPS_LLCAST length));
 
  /*
@@ -2259,8 +2288,8 @@ httpWrite2(http_t     *http,              /* I - Connection to server */
   {
     if (http->wused && (length + http->wused) > sizeof(http->wbuffer))
     {
-      DEBUG_printf(("httpWrite2: Flushing buffer (wused=%d, length="
-                    CUPS_LLFMT ")\n", http->wused, CUPS_LLCAST length));
+      DEBUG_printf(("2httpWrite2: Flushing buffer (wused=%d, length="
+                    CUPS_LLFMT ")", http->wused, CUPS_LLCAST length));
 
       httpFlushWrite(http);
     }
@@ -2272,7 +2301,7 @@ httpWrite2(http_t     *http,              /* I - Connection to server */
       * Write to buffer...
       */
 
-      DEBUG_printf(("httpWrite2: Copying " CUPS_LLFMT " bytes to wbuffer...\n",
+      DEBUG_printf(("2httpWrite2: Copying " CUPS_LLFMT " bytes to wbuffer...",
                     CUPS_LLCAST length));
 
       memcpy(http->wbuffer + http->wused, buffer, length);
@@ -2285,7 +2314,7 @@ httpWrite2(http_t     *http,              /* I - Connection to server */
       * Otherwise write the data directly...
       */
 
-      DEBUG_printf(("httpWrite2: Writing " CUPS_LLFMT " bytes to socket...\n",
+      DEBUG_printf(("2httpWrite2: Writing " CUPS_LLFMT " bytes to socket...",
                     CUPS_LLCAST length));
 
       if (http->data_encoding == HTTP_ENCODE_CHUNKED)
@@ -2293,7 +2322,7 @@ httpWrite2(http_t     *http,              /* I - Connection to server */
       else
        bytes = (ssize_t)http_write(http, buffer, (int)length);
 
-      DEBUG_printf(("httpWrite2: Wrote " CUPS_LLFMT " bytes...\n",
+      DEBUG_printf(("2httpWrite2: Wrote " CUPS_LLFMT " bytes...",
                     CUPS_LLCAST bytes));
     }
 
@@ -2315,7 +2344,7 @@ httpWrite2(http_t     *http,              /* I - Connection to server */
     * data, go idle...
     */
 
-    DEBUG_puts("httpWrite: changing states...");
+    DEBUG_puts("2httpWrite: changing states...");
 
     if (http->wused)
       httpFlushWrite(http);
@@ -2370,7 +2399,7 @@ _httpWriteCDSA(
   {
     bytes = write(http->fd, data, *dataLength);
   }
-  while (bytes == -1 && errno == EINTR);
+  while (bytes == -1 && (errno == EINTR || errno == EAGAIN));
 
   if (bytes == *dataLength)
   {
@@ -2578,7 +2607,7 @@ http_debug_hex(const char *prefix,        /* I - Prefix for line */
   if (_cups_debug_fd < 0)
     return;
 
-  DEBUG_printf(("%s: %d bytes:\n", prefix, bytes));
+  DEBUG_printf(("6%s: %d bytes:\n", prefix, bytes));
 
   snprintf(line, sizeof(line), "%s: ", prefix);
   start = line + strlen(line);
@@ -2715,7 +2744,7 @@ http_send(http_t       *http,     /* I - Connection to server */
                };
 
 
-  DEBUG_printf(("http_send(http=%p, request=HTTP_%s, uri=\"%s\")\n",
+  DEBUG_printf(("7http_send(http=%p, request=HTTP_%s, uri=\"%s\")",
                 http, codes[request], uri));
 
   if (http == NULL || uri == NULL)
@@ -2778,7 +2807,7 @@ http_send(http_t       *http,     /* I - Connection to server */
   for (i = 0; i < HTTP_FIELD_MAX; i ++)
     if (http->fields[i][0] != '\0')
     {
-      DEBUG_printf(("http_send: %s: %s\n", http_fields[i],
+      DEBUG_printf(("9http_send: %s: %s", http_fields[i],
                     httpGetField(http, i)));
 
       if (httpPrintf(http, "%s: %s\r\n", http_fields[i], 
@@ -2856,7 +2885,7 @@ http_setup_ssl(http_t *http)              /* I - Connection to server */
 #  endif /* HAVE_LIBSSL */
 
 
-  DEBUG_printf(("http_setup_ssl(http=%p)\n", http));
+  DEBUG_printf(("7http_setup_ssl(http=%p)", http));
 
 #  ifdef HAVE_LIBSSL
   context = SSL_CTX_new(SSLv23_client_method());
@@ -2875,7 +2904,7 @@ http_setup_ssl(http_t *http)              /* I - Connection to server */
     unsigned long      error;  /* Error code */
 
     while ((error = ERR_get_error()) != 0)
-      printf("http_setup_ssl: %s\n", ERR_error_string(error, NULL));
+      DEBUG_printf(("8http_setup_ssl: %s", ERR_error_string(error, NULL)));
 #    endif /* DEBUG */
 
     SSL_CTX_free(context);
@@ -3058,7 +3087,7 @@ http_upgrade(http_t *http)                /* I - Connection to server */
   http_t       myhttp;                 /* Local copy of HTTP data */
 
 
-  DEBUG_printf(("http_upgrade(%p)\n", http));
+  DEBUG_printf(("7http_upgrade(%p)", http));
 
  /*
   * Copy the HTTP data to a local variable so we can do the OPTIONS
@@ -3111,7 +3140,7 @@ http_upgrade(http_t *http)                /* I - Connection to server */
     * Server does not support HTTP upgrade...
     */
 
-    DEBUG_puts("Server does not support HTTP upgrade!");
+    DEBUG_puts("8http_upgrade: Server does not support HTTP upgrade!");
 
 #  ifdef WIN32
     closesocket(http->fd);
@@ -3162,7 +3191,7 @@ http_write(http_t     *http,              /* I - Connection to server */
        continue;
       }
 #else
-      if (errno == EINTR)
+      if (errno == EINTR || errno == EAGAIN)
         continue;
       else if (errno != http->error && errno != ECONNRESET)
       {
@@ -3171,7 +3200,7 @@ http_write(http_t     *http,              /* I - Connection to server */
       }
 #endif /* WIN32 */
 
-      DEBUG_puts("http_write: error writing data...\n");
+      DEBUG_puts("8http_write: error writing data...");
 
       return (-1);
     }
@@ -3201,7 +3230,7 @@ http_write_chunk(http_t     *http,        /* I - Connection to server */
   char header[255];                    /* Chunk header */
   int  bytes;                          /* Bytes written */
 
-  DEBUG_printf(("http_write_chunk(http=%p, buffer=%p, length=%d)\n",
+  DEBUG_printf(("7http_write_chunk(http=%p, buffer=%p, length=%d)",
                 http, buffer, length));
 
  /*
@@ -3211,19 +3240,19 @@ http_write_chunk(http_t     *http,      /* I - Connection to server */
   sprintf(header, "%x\r\n", length);
   if (http_write(http, header, (int)strlen(header)) < 0)
   {
-    DEBUG_puts("    http_write of length failed!");
+    DEBUG_puts("8http_write_chunk: http_write of length failed!");
     return (-1);
   }
 
   if ((bytes = http_write(http, buffer, length)) < 0)
   {
-    DEBUG_puts("    http_write of buffer failed!");
+    DEBUG_puts("8http_write_chunk: http_write of buffer failed!");
     return (-1);
   }
 
   if (http_write(http, "\r\n", 2) < 0)
   {
-    DEBUG_puts("    http_write of CR LF failed!");
+    DEBUG_puts("8http_write_chunk: http_write of CR LF failed!");
     return (-1);
   }
 
index 8553a488e2c2d988d14ea72fd98eca5d7ead0704..c8c239c0f957c73f0a01ba0a3d67ad82676e5a27 100644 (file)
@@ -4,7 +4,7 @@
  *   Internet Printing Protocol support functions for the Common UNIX
  *   Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -391,53 +391,15 @@ ippOpValue(const char *name)              /* I - Textual name */
 int                                    /* O - Port number */
 ippPort(void)
 {
-  const char   *ipp_port;              /* IPP_PORT environment variable */
-  struct servent *port;                        /* Port number info */  
-  int          portnum;                /* Port number */
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
   DEBUG_puts("ippPort()");
 
   if (!cg->ipp_port)
-  {
-   /*
-    * See if the server definition includes the port number...
-    */
+    _cupsSetDefaults();
 
-    DEBUG_puts("ippPort: Not initialized...");
-
-    cupsServer();
-
-#ifdef DEBUG
-    if (cg->ipp_port)
-      DEBUG_puts(("ippPort: Set via cupsServer()..."));
-#endif /* DEBUG */
-  }
-
-  if (!cg->ipp_port)
-  {
-    if ((ipp_port = getenv("IPP_PORT")) != NULL)
-    {
-      DEBUG_puts("ippPort: Set via IPP_PORT...");
-      portnum = atoi(ipp_port);
-    }
-    else if ((port = getservbyname("ipp", NULL)) == NULL)
-    {
-      DEBUG_puts("ippPort: Set via CUPS_DEFAULT_IPP_PORT...");
-      portnum = CUPS_DEFAULT_IPP_PORT;
-    }
-    else
-    {
-      DEBUG_puts("ippPort: Set via ipp service entry...");
-      portnum = ntohs(port->s_port);
-    }
-
-    if (portnum > 0)
-      cg->ipp_port = portnum;
-  }
-
-  DEBUG_printf(("ippPort: Returning %d...\n", cg->ipp_port));
+  DEBUG_printf(("1ippPort: Returning %d...", cg->ipp_port));
 
   return (cg->ipp_port);
 }
@@ -450,7 +412,7 @@ ippPort(void)
 void
 ippSetPort(int p)                      /* I - Port number to use */
 {
-  DEBUG_printf(("ippSetPort(p=%d)\n", p));
+  DEBUG_printf(("ippSetPort(p=%d)", p));
 
   _cupsGlobals()->ipp_port = p;
 }
index a6c640856e44cdf4c5a0146ec8346a52f9719466..021a56e11bb79f694d133510d566bbd9bc24f5a9 100644 (file)
@@ -99,7 +99,7 @@ ippAddBoolean(ipp_t      *ipp,                /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)\n",
+  DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)",
                 ipp, group, ippTagString(group), name, value));
 
   if (!ipp || !name)
@@ -134,7 +134,7 @@ ippAddBooleans(ipp_t      *ipp,             /* I - IPP message */
 
 
   DEBUG_printf(("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", "
-                "num_values=%d, values=%p)\n", ipp, group, ippTagString(group),
+                "num_values=%d, values=%p)", ipp, group, ippTagString(group),
                 name, num_values, values));
 
   if (!ipp || !name || num_values < 1)
@@ -173,7 +173,7 @@ ippAddCollection(ipp_t      *ipp,   /* I - IPP message */
 
 
   DEBUG_printf(("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", "
-                "value=%p)\n", ipp, group, ippTagString(group), name, value));
+                "value=%p)", ipp, group, ippTagString(group), name, value));
 
   if (!ipp || !name)
     return (NULL);
@@ -210,7 +210,7 @@ ippAddCollections(
 
 
   DEBUG_printf(("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", "
-                "num_values=%d, values=%p)\n", ipp, group, ippTagString(group),
+                "num_values=%d, values=%p)", ipp, group, ippTagString(group),
                 name, num_values, values));
 
   if (!ipp || !name || num_values < 1)
@@ -246,7 +246,7 @@ ippAddDate(ipp_t             *ipp,  /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)\n",
+  DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)",
                 ipp, group, ippTagString(group), name, value));
 
   if (!ipp || !name || !value)
@@ -279,7 +279,7 @@ ippAddInteger(ipp_t      *ipp,              /* I - IPP message */
 
 
   DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), "
-                "name=\"%s\", value=%d)\n", ipp, group, ippTagString(group),
+                "name=\"%s\", value=%d)", ipp, group, ippTagString(group),
                type, ippTagString(type), name, value));
 
   if (!ipp || !name)
@@ -315,7 +315,7 @@ ippAddIntegers(ipp_t      *ipp,             /* I - IPP message */
 
 
   DEBUG_printf(("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), "
-                "name=\"%s\", num_values=%d, values=%p)\n", ipp,
+                "name=\"%s\", num_values=%d, values=%p)", ipp,
                group, ippTagString(group), type, ippTagString(type), name,
                num_values, values));
 
@@ -407,7 +407,7 @@ ippAddString(ipp_t      *ipp,               /* I - IPP message */
 
 
   DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), type=%02x(%s), "
-                "name=\"%s\", charset=\"%s\", value=\"%s\")\n", ipp,
+                "name=\"%s\", charset=\"%s\", value=\"%s\")", ipp,
                group, ippTagString(group), type, ippTagString(type), name,
                charset, value));
 
@@ -476,7 +476,7 @@ ippAddStrings(
 
 
   DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), type=%02x(%s), "
-                "name=\"%s\", num_values=%d, charset=\"%s\", values=%p)\n", ipp,
+                "name=\"%s\", num_values=%d, charset=\"%s\", values=%p)", ipp,
                group, ippTagString(group), type, ippTagString(type), name,
                num_values, charset, values));
 
@@ -538,7 +538,7 @@ ippAddRange(ipp_t      *ipp,                /* I - IPP message */
 
 
   DEBUG_printf(("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, "
-                "upper=%d)\n", ipp, group, ippTagString(group), name, lower,
+                "upper=%d)", ipp, group, ippTagString(group), name, lower,
                upper));
 
   if (!ipp || !name)
@@ -575,7 +575,7 @@ ippAddRanges(ipp_t      *ipp,               /* I - IPP message */
 
 
   DEBUG_printf(("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", "
-                "num_values=%d, lower=%p, upper=%p)\n", ipp, group,
+                "num_values=%d, lower=%p, upper=%p)", ipp, group,
                ippTagString(group), name, num_values, lower, upper));
 
   if (!ipp || !name || num_values < 1)
@@ -617,7 +617,7 @@ ippAddResolution(ipp_t      *ipp,   /* I - IPP message */
 
 
   DEBUG_printf(("ippAddResolution(ipp=%p, group=%02x(%s), name=\"%s\", "
-                "units=%d, xres=%d, yres=%d)\n", ipp, group,
+                "units=%d, xres=%d, yres=%d)", ipp, group,
                ippTagString(group), name, units, xres, yres));
 
   if (!ipp || !name)
@@ -656,7 +656,7 @@ ippAddResolutions(ipp_t      *ipp,  /* I - IPP message */
 
 
   DEBUG_printf(("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", "
-                "num_value=%d, units=%d, xres=%p, yres=%p)\n", ipp, group,
+                "num_value=%d, units=%d, xres=%p, yres=%p)", ipp, group,
                ippTagString(group), name, num_values, units, xres, yres));
 
   if (!ipp || !name || num_values < 1)
@@ -693,7 +693,7 @@ ippAddSeparator(ipp_t *ipp)         /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("ippAddSeparator(ipp=%p)\n", ipp));
+  DEBUG_printf(("ippAddSeparator(ipp=%p)", ipp));
 
   if (!ipp)
     return (NULL);
@@ -771,7 +771,7 @@ ippDelete(ipp_t *ipp)                       /* I - IPP message */
                        *next;          /* Next attribute */
 
 
-  DEBUG_printf(("ippDelete(ipp=%p)\n", ipp));
+  DEBUG_printf(("ippDelete(ipp=%p)", ipp));
 
   if (!ipp)
     return;
@@ -801,7 +801,8 @@ ippDeleteAttribute(
                        *prev;          /* Previous attribute */
 
 
-  DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p)\n", ipp, attr));
+  DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p(%s))", ipp, attr,
+                attr ? attr->name : "(null)"));
 
  /*
   * Find the attribute in the list...
@@ -843,7 +844,7 @@ ippFindAttribute(ipp_t      *ipp,   /* I - IPP message */
                  const char *name,     /* I - Name of attribute */
                 ipp_tag_t  type)       /* I - Type of attribute */
 {
-  DEBUG_printf(("ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))\n", ipp,
+  DEBUG_printf(("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", ipp,
                 name, type, ippTagString(type)));
 
   if (!ipp || !name)
@@ -876,7 +877,7 @@ ippFindNextAttribute(ipp_t      *ipp,       /* I - IPP message */
   ipp_tag_t            value_tag;      /* Value tag */
 
 
-  DEBUG_printf(("ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))\n",
+  DEBUG_printf(("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))",
                 ipp, name, type, ippTagString(type)));
 
   if (!ipp || !name)
@@ -895,7 +896,7 @@ ippFindNextAttribute(ipp_t      *ipp,       /* I - IPP message */
 
   for (; attr != NULL; ipp->prev = attr, attr = attr->next)
   {
-    DEBUG_printf(("ippFindAttribute: attr=%p, name=\"%s\"\n", attr,
+    DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", attr,
                   attr->name));
 
     value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
@@ -951,7 +952,7 @@ ippNew(void)
     temp->request.any.version[1] = 1;
   }
 
-  DEBUG_printf(("ippNew: %p\n", temp));
+  DEBUG_printf(("1ippNew: Returning %p", temp));
 
   return (temp);
 }
@@ -974,7 +975,7 @@ ippNewRequest(ipp_op_t op)          /* I - Operation code */
   cups_lang_t  *language;              /* Current language localization */
 
 
-  DEBUG_printf(("ippNewRequest(op=%02x(%s))\n", op, ippOpString(op)));
+  DEBUG_printf(("ippNewRequest(op=%02x(%s))", op, ippOpString(op)));
 
  /*
   * Create a new IPP message...
@@ -1022,13 +1023,13 @@ ipp_state_t                             /* O - Current state */
 ippRead(http_t *http,                  /* I - HTTP connection */
         ipp_t  *ipp)                   /* I - IPP data */
 {
-  DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT "\n",
+  DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT,
                 http, ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
 
   if (!http)
     return (IPP_ERROR);
 
-  DEBUG_printf(("ippRead: http->state=%d, http->used=%d\n", http->state,
+  DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state,
                 http->used));
 
   return (ippReadIO(http, (ipp_iocb_t)ipp_read_http, http->blocking, NULL,
@@ -1046,7 +1047,7 @@ ipp_state_t                               /* O - Current state */
 ippReadFile(int   fd,                  /* I - HTTP data */
             ipp_t *ipp)                        /* I - IPP data */
 {
-  DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)\n", fd, ipp));
+  DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)", fd, ipp));
 
   return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
 }
@@ -1076,16 +1077,16 @@ ippReadIO(void       *src,              /* I - Data source */
   ipp_value_t          *value;         /* Current value */
 
 
-  DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)\n",
+  DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)",
                 src, cb, blocking, parent, ipp));
-  DEBUG_printf(("ippReadIO: ipp->state=%d\n", ipp->state));
+  DEBUG_printf(("2ippReadIO: ipp->state=%d", ipp->state));
 
   if (!src || !ipp)
     return (IPP_ERROR);
 
   if ((buffer = ipp_buffer_get()) == NULL)
   {
-    DEBUG_puts("ippReadIO: Unable to get read buffer!");
+    DEBUG_puts("1ippReadIO: Unable to get read buffer!");
     return (IPP_ERROR);
   }
 
@@ -1103,7 +1104,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
           if ((*cb)(src, buffer, 8) < 8)
          {
-           DEBUG_puts("ippReadIO: Unable to read header!");
+           DEBUG_puts("1ippReadIO: Unable to read header!");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
@@ -1118,10 +1119,10 @@ ippReadIO(void       *src,              /* I - Data source */
           ipp->request.any.request_id  = (((((buffer[4] << 8) | buffer[5]) << 8) |
                                         buffer[6]) << 8) | buffer[7];
 
-          DEBUG_printf(("ippReadIO: version=%d.%d\n", buffer[0], buffer[1]));
-         DEBUG_printf(("ippReadIO: op_status=%04x\n",
+          DEBUG_printf(("2ippReadIO: version=%d.%d", buffer[0], buffer[1]));
+         DEBUG_printf(("2ippReadIO: op_status=%04x",
                        ipp->request.any.op_status));
-         DEBUG_printf(("ippReadIO: request_id=%d\n",
+         DEBUG_printf(("2ippReadIO: request_id=%d",
                        ipp->request.any.request_id));
         }
 
@@ -1142,12 +1143,12 @@ ippReadIO(void       *src,              /* I - Data source */
        {
          if ((*cb)(src, buffer, 1) < 1)
          {
-           DEBUG_puts("ippReadIO: Callback returned EOF/error");
+           DEBUG_puts("1ippReadIO: Callback returned EOF/error");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
 
-         DEBUG_printf(("ippReadIO: ipp->current=%p, ipp->prev=%p\n",
+         DEBUG_printf(("1ippReadIO: ipp->current=%p, ipp->prev=%p",
                        ipp->current, ipp->prev));
 
         /*
@@ -1162,7 +1163,7 @@ ippReadIO(void       *src,                /* I - Data source */
            * No more attributes left...
            */
 
-            DEBUG_puts("ippReadIO: IPP_TAG_END!");
+            DEBUG_puts("2ippReadIO: IPP_TAG_END!");
 
            ipp->state = IPP_DATA;
            break;
@@ -1180,12 +1181,12 @@ ippReadIO(void       *src,              /* I - Data source */
 
            ipp->curtag  = tag;
            ipp->current = NULL;
-           DEBUG_printf(("ippReadIO: group tag=%x(%s), ipp->prev=%p\n", tag,
+           DEBUG_printf(("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag,
                          ippTagString(tag), ipp->prev));
            continue;
          }
 
-          DEBUG_printf(("ippReadIO: value tag=%x(%s)\n", tag,
+          DEBUG_printf(("2ippReadIO: value tag=%x(%s)", tag,
                        ippTagString(tag)));
 
          /*
@@ -1194,7 +1195,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
           if ((*cb)(src, buffer, 2) < 2)
          {
-           DEBUG_puts("ippReadIO: unable to read name length!");
+           DEBUG_puts("1ippReadIO: unable to read name length!");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
@@ -1203,12 +1204,12 @@ ippReadIO(void       *src,              /* I - Data source */
 
           if (n >= IPP_BUF_SIZE)
          {
-           DEBUG_printf(("ippReadIO: bad name length %d!\n", n));
+           DEBUG_printf(("1ippReadIO: bad name length %d!", n));
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
 
-          DEBUG_printf(("ippReadIO: name length=%d\n", n));
+          DEBUG_printf(("2ippReadIO: name length=%d", n));
 
           if (n == 0 && tag != IPP_TAG_MEMBERNAME &&
              tag != IPP_TAG_END_COLLECTION)
@@ -1219,7 +1220,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
             if (ipp->current == NULL)
            {
-             DEBUG_puts("ippReadIO: Attribute without name and no current");
+             DEBUG_puts("1ippReadIO: Attribute without name and no current");
              ipp_buffer_release(buffer);
              return (IPP_ERROR);
            }
@@ -1251,7 +1252,7 @@ ippReadIO(void       *src,                /* I - Data source */
              if ((tag < IPP_TAG_TEXTLANG || tag > IPP_TAG_MIMETYPE) &&
                  tag != IPP_TAG_NOVALUE)
              {
-               DEBUG_printf(("ippReadIO: 1setOf value tag %x(%s) != %x(%s)\n",
+               DEBUG_printf(("1ippReadIO: 1setOf value tag %x(%s) != %x(%s)",
                              value_tag, ippTagString(value_tag), tag,
                              ippTagString(tag)));
                ipp_buffer_release(buffer);
@@ -1260,7 +1261,7 @@ ippReadIO(void       *src,                /* I - Data source */
             }
            else if (value_tag != tag)
            {
-             DEBUG_printf(("ippReadIO: value tag %x(%s) != %x(%s)\n",
+             DEBUG_printf(("1ippReadIO: value tag %x(%s) != %x(%s)",
                            value_tag, ippTagString(value_tag), tag,
                            ippTagString(tag)));
              ipp_buffer_release(buffer);
@@ -1278,7 +1279,7 @@ ippReadIO(void       *src,                /* I - Data source */
              ipp_attribute_t   *temp;  /* Pointer to new buffer */
 
 
-              DEBUG_printf(("ippReadIO: reallocating for up to %d values...\n",
+              DEBUG_printf(("2ippReadIO: reallocating for up to %d values...",
                            attr->num_values + IPP_MAX_VALUES));
 
              /*
@@ -1289,7 +1290,7 @@ ippReadIO(void       *src,                /* I - Data source */
                                        (attr->num_values + IPP_MAX_VALUES - 1) *
                                        sizeof(ipp_value_t))) == NULL)
              {
-               DEBUG_puts("ippReadIO: Unable to resize attribute");
+               DEBUG_puts("1ippReadIO: Unable to resize attribute");
                ipp_buffer_release(buffer);
                return (IPP_ERROR);
              }
@@ -1317,7 +1318,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
            if (n)
            {
-             DEBUG_puts("ippReadIO: member name not empty!");
+             DEBUG_puts("1ippReadIO: member name not empty!");
              ipp_buffer_release(buffer);
              return (IPP_ERROR);
            }
@@ -1327,8 +1328,8 @@ ippReadIO(void       *src,                /* I - Data source */
 
            attr = ipp->current = _ippAddAttr(ipp, 1);
 
-           DEBUG_printf(("ippReadIO: membername, ipp->current=%p, "
-                         "ipp->prev=%p\n", ipp->current, ipp->prev));
+           DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, "
+                         "ipp->prev=%p", ipp->current, ipp->prev));
 
            attr->group_tag  = ipp->curtag;
            attr->value_tag  = IPP_TAG_ZERO;
@@ -1342,7 +1343,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
            if ((*cb)(src, buffer, n) < n)
            {
-             DEBUG_puts("ippReadIO: unable to read name!");
+             DEBUG_puts("1ippReadIO: unable to read name!");
              ipp_buffer_release(buffer);
              return (IPP_ERROR);
            }
@@ -1354,13 +1355,13 @@ ippReadIO(void       *src,              /* I - Data source */
 
            if ((attr = ipp->current = _ippAddAttr(ipp, 1)) == NULL)
            {
-             DEBUG_puts("ippReadIO: unable to allocate attribute!");
+             DEBUG_puts("1ippReadIO: unable to allocate attribute!");
              ipp_buffer_release(buffer);
              return (IPP_ERROR);
            }
 
-           DEBUG_printf(("ippReadIO: name=\"%s\", ipp->current=%p, "
-                         "ipp->prev=%p\n", buffer, ipp->current, ipp->prev));
+           DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, "
+                         "ipp->prev=%p", buffer, ipp->current, ipp->prev));
 
            attr->group_tag  = ipp->curtag;
            attr->value_tag  = tag;
@@ -1377,13 +1378,13 @@ ippReadIO(void       *src,              /* I - Data source */
 
          if ((*cb)(src, buffer, 2) < 2)
          {
-           DEBUG_puts("ippReadIO: unable to read value length!");
+           DEBUG_puts("1ippReadIO: unable to read value length!");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
 
          n = (buffer[0] << 8) | buffer[1];
-          DEBUG_printf(("ippReadIO: value length=%d\n", n));
+          DEBUG_printf(("2ippReadIO: value length=%d", n));
 
          switch (tag)
          {
@@ -1391,14 +1392,14 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_ENUM :
                if (n != 4)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, 4) < 4)
                {
-                 DEBUG_puts("ippReadIO: Unable to read integer value!");
+                 DEBUG_puts("1ippReadIO: Unable to read integer value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1412,14 +1413,14 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_BOOLEAN :
                if (n != 1)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, 1) < 1)
                {
-                 DEBUG_puts("ippReadIO: Unable to read boolean value!");
+                 DEBUG_puts("1ippReadIO: Unable to read boolean value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1449,35 +1450,34 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_MIMETYPE :
                if (n >= IPP_BUF_SIZE)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, n) < n)
                {
-                 DEBUG_puts("ippReadIO: unable to read name!");
+                 DEBUG_puts("1ippReadIO: unable to read name!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                buffer[n] = '\0';
                value->string.text = _cupsStrAlloc((char *)buffer);
-               DEBUG_printf(("ippReadIO: value=\"%s\"\n",
-                             value->string.text));
+               DEBUG_printf(("2ippReadIO: value=\"%s\"", value->string.text));
                break;
 
            case IPP_TAG_DATE :
                if (n != 11)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, value->date, 11) < 11)
                {
-                 DEBUG_puts("ippReadIO: Unable to date integer value!");
+                 DEBUG_puts("1ippReadIO: Unable to read date value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1486,14 +1486,14 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_RESOLUTION :
                if (n != 9)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, 9) < 9)
                {
-                 DEBUG_puts("ippReadIO: Unable to read resolution value!");
+                 DEBUG_puts("1ippReadIO: Unable to read resolution value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1511,14 +1511,14 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_RANGE :
                if (n != 8)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, 8) < 8)
                {
-                 DEBUG_puts("ippReadIO: Unable to read range value!");
+                 DEBUG_puts("1ippReadIO: Unable to read range value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1535,14 +1535,15 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_NAMELANG :
                if (n >= IPP_BUF_SIZE || n < 4)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, n) < n)
                {
-                 DEBUG_puts("ippReadIO: Unable to read string w/language value!");
+                 DEBUG_puts("1ippReadIO: Unable to read string w/language "
+                            "value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1564,7 +1565,7 @@ ippReadIO(void       *src,                /* I - Data source */
                if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) ||
                    n >= sizeof(string))
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1579,7 +1580,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
                if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE))
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1597,7 +1598,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
                 if (n > 0)
                {
-                 DEBUG_puts("ippReadIO: begCollection tag with value length "
+                 DEBUG_puts("1ippReadIO: begCollection tag with value length "
                             "> 0!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
@@ -1605,7 +1606,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
                if (ippReadIO(src, cb, 1, ipp, value->collection) == IPP_ERROR)
                {
-                 DEBUG_puts("ippReadIO: Unable to read collection value!");
+                 DEBUG_puts("1ippReadIO: Unable to read collection value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1616,12 +1617,12 @@ ippReadIO(void       *src,              /* I - Data source */
 
                 if (n > 0)
                {
-                 DEBUG_puts("ippReadIO: endCollection tag with value length "
+                 DEBUG_puts("1ippReadIO: endCollection tag with value length "
                             "> 0!");
                  return (IPP_ERROR);
                }
 
-               DEBUG_puts("ippReadIO: endCollection tag...");
+               DEBUG_puts("1ippReadIO: endCollection tag...");
                return (ipp->state = IPP_DATA);
 
             case IPP_TAG_MEMBERNAME :
@@ -1632,14 +1633,14 @@ ippReadIO(void       *src,              /* I - Data source */
 
                if (n >= IPP_BUF_SIZE)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if ((*cb)(src, buffer, n) < n)
                {
-                 DEBUG_puts("ippReadIO: Unable to read member name value!");
+                 DEBUG_puts("1ippReadIO: Unable to read member name value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1655,20 +1656,20 @@ ippReadIO(void       *src,              /* I - Data source */
 
                 attr->num_values --;
 
-               DEBUG_printf(("ippReadIO: member name=\"%s\"\n", attr->name));
+               DEBUG_printf(("2ippReadIO: member name=\"%s\"", attr->name));
                break;
 
             default : /* Other unsupported values */
                if (n > IPP_MAX_LENGTH)
                {
-                 DEBUG_printf(("ippReadIO: bad value length %d!\n", n));
+                 DEBUG_printf(("1ippReadIO: bad value length %d!", n));
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
 
                if (!value)
                {
-                 DEBUG_puts("ippReadIO: NULL value!");
+                 DEBUG_puts("1ippReadIO: NULL value!");
                  ipp_buffer_release(buffer);
                  return (IPP_ERROR);
                }
@@ -1678,14 +1679,14 @@ ippReadIO(void       *src,              /* I - Data source */
                {
                  if ((value->unknown.data = malloc(n)) == NULL)
                  {
-                   DEBUG_puts("ippReadIO: Unable to allocate value");
+                   DEBUG_puts("1ippReadIO: Unable to allocate value");
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
                  }
 
                  if ((*cb)(src, value->unknown.data, n) < n)
                  {
-                   DEBUG_puts("ippReadIO: Unable to read unsupported value!");
+                   DEBUG_puts("1ippReadIO: Unable to read unsupported value!");
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
                  }
@@ -1713,7 +1714,7 @@ ippReadIO(void       *src,                /* I - Data source */
         break; /* anti-compiler-warning-code */
   }
 
-  DEBUG_printf(("ippReadIO: returning ipp->state=%d!\n", ipp->state));
+  DEBUG_printf(("1ippReadIO: returning ipp->state=%d!", ipp->state));
   ipp_buffer_release(buffer);
 
   return (ipp->state);
@@ -1776,13 +1777,12 @@ ipp_state_t                             /* O - Current state */
 ippWrite(http_t *http,                 /* I - HTTP connection */
          ipp_t  *ipp)                  /* I - IPP data */
 {
-  DEBUG_printf(("ippWrite(http=%p, ipp=%p)\n", http, ipp));
+  DEBUG_printf(("ippWrite(http=%p, ipp=%p)", http, ipp));
 
   if (!http)
     return (IPP_ERROR);
 
-  return (ippWriteIO(http, (ipp_iocb_t)httpWrite2,
-                     http->blocking, NULL, ipp));
+  return (ippWriteIO(http, (ipp_iocb_t)httpWrite2, http->blocking, NULL, ipp));
 }
 
 
@@ -1796,7 +1796,7 @@ ipp_state_t                               /* O - Current state */
 ippWriteFile(int   fd,                 /* I - HTTP data */
              ipp_t *ipp)               /* I - IPP data */
 {
-  DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)\n", fd, ipp));
+  DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)", fd, ipp));
 
   ipp->state = IPP_IDLE;
 
@@ -1825,7 +1825,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
   ipp_value_t          *value;         /* Current value */
 
 
-  DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)\n",
+  DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)",
                 dst, cb, blocking, parent, ipp));
 
   if (!dst || !ipp)
@@ -1833,7 +1833,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
   if ((buffer = ipp_buffer_get()) == NULL)
   {
-    DEBUG_puts("ippWriteIO: Unable to get write buffer");
+    DEBUG_puts("1ippWriteIO: Unable to get write buffer");
     return (IPP_ERROR);
   }
 
@@ -1867,7 +1867,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
           if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
          {
-           DEBUG_puts("ippWriteIO: Could not write IPP header...");
+           DEBUG_puts("1ippWriteIO: Could not write IPP header...");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
@@ -1882,10 +1882,10 @@ ippWriteIO(void       *dst,             /* I - Destination */
        ipp->current = ipp->attrs;
        ipp->curtag  = IPP_TAG_ZERO;
 
-        DEBUG_printf(("ippWriteIO: version=%d.%d\n", buffer[0], buffer[1]));
-       DEBUG_printf(("ippWriteIO: op_status=%04x\n",
+        DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]));
+       DEBUG_printf(("2ippWriteIO: op_status=%04x",
                      ipp->request.any.op_status));
-       DEBUG_printf(("ippWriteIO: request_id=%d\n",
+       DEBUG_printf(("2ippWriteIO: request_id=%d",
                      ipp->request.any.request_id));
 
        /*
@@ -1918,7 +1918,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
             if (attr->group_tag == IPP_TAG_ZERO)
              continue;
 
-            DEBUG_printf(("ippWriteIO: wrote group tag=%x(%s)\n",
+            DEBUG_printf(("2ippWriteIO: wrote group tag=%x(%s)",
                          attr->group_tag, ippTagString(attr->group_tag)));
            *bufptr++ = attr->group_tag;
          }
@@ -1945,7 +1945,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
             if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 4))
            {
-             DEBUG_printf(("ippWriteIO: Attribute name too long (%d)\n", n));
+             DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
              ipp_buffer_release(buffer);
              return (IPP_ERROR);
            }
@@ -1954,9 +1954,9 @@ ippWriteIO(void       *dst,               /* I - Destination */
            * Write the value tag, name length, and name string...
            */
 
-            DEBUG_printf(("ippWriteIO: writing value tag=%x(%s)\n",
+            DEBUG_printf(("2ippWriteIO: writing value tag=%x(%s)",
                          attr->value_tag, ippTagString(attr->value_tag)));
-            DEBUG_printf(("ippWriteIO: writing name=%d,\"%s\"\n", n,
+            DEBUG_printf(("2ippWriteIO: writing name=%d,\"%s\"", n,
                          attr->name));
 
             *bufptr++ = attr->value_tag;
@@ -1974,7 +1974,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
             if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 7))
            {
-             DEBUG_printf(("ippWriteIO: Attribute name too long (%d)\n", n));
+             DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
              ipp_buffer_release(buffer);
              return (IPP_ERROR);
            }
@@ -1984,13 +1984,13 @@ ippWriteIO(void       *dst,             /* I - Destination */
            * and empty name for the collection member attribute...
            */
 
-            DEBUG_printf(("ippWriteIO: writing value tag=%x(memberName)\n",
+            DEBUG_printf(("2ippWriteIO: writing value tag=%x(memberName)",
                          IPP_TAG_MEMBERNAME));
-            DEBUG_printf(("ippWriteIO: writing name=%d,\"%s\"\n", n,
+            DEBUG_printf(("2ippWriteIO: writing name=%d,\"%s\"", n,
                          attr->name));
-            DEBUG_printf(("ippWriteIO: writing value tag=%x(%s)\n",
+            DEBUG_printf(("2ippWriteIO: writing value tag=%x(%s)",
                          attr->value_tag, ippTagString(attr->value_tag)));
-            DEBUG_puts("ippWriteIO: writing name=0,\"\"\n");
+            DEBUG_puts("2ippWriteIO: writing name=0,\"\"");
 
             *bufptr++ = IPP_TAG_MEMBERNAME;
            *bufptr++ = 0;
@@ -2021,7 +2021,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2067,7 +2067,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2119,16 +2119,16 @@ ippWriteIO(void       *dst,             /* I - Destination */
                    * values with a zero-length name...
                    */
 
-                   DEBUG_printf(("ippWriteIO: writing value tag=%x(%s)\n",
+                   DEBUG_printf(("2ippWriteIO: writing value tag=%x(%s)",
                                  attr->value_tag,
                                  ippTagString(attr->value_tag)));
-                   DEBUG_printf(("ippWriteIO: writing name=0,\"\"\n"));
+                   DEBUG_printf(("2ippWriteIO: writing name=0,\"\""));
 
                     if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
                    {
                       if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                      {
-                       DEBUG_puts("ippWriteIO: Could not write IPP "
+                       DEBUG_puts("1ippWriteIO: Could not write IPP "
                                   "attribute...");
                        ipp_buffer_release(buffer);
                        return (IPP_ERROR);
@@ -2149,19 +2149,19 @@ ippWriteIO(void       *dst,             /* I - Destination */
 
                   if (n > (IPP_BUF_SIZE - 2))
                  {
-                   DEBUG_printf(("ippWriteIO: String too long (%d)\n", n));
+                   DEBUG_printf(("1ippWriteIO: String too long (%d)", n));
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
                  }
 
-                  DEBUG_printf(("ippWriteIO: writing string=%d,\"%s\"\n", n,
+                  DEBUG_printf(("2ippWriteIO: writing string=%d,\"%s\"", n,
                                value->string.text));
 
                   if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2200,7 +2200,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2245,7 +2245,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2298,7 +2298,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2357,7 +2357,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    {
                       if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                      {
-                       DEBUG_puts("ippWriteIO: Could not write IPP "
+                       DEBUG_puts("1ippWriteIO: Could not write IPP "
                                   "attribute...");
                        ipp_buffer_release(buffer);
                        return (IPP_ERROR);
@@ -2391,8 +2391,8 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
                   if (n > (IPP_BUF_SIZE - 2))
                  {
-                   DEBUG_printf(("ippWriteIO: text/nameWithLanguage value "
-                                 "too long (%d)\n", n));
+                   DEBUG_printf(("1ippWriteIO: text/nameWithLanguage value "
+                                 "too long (%d)", n));
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
                   }
@@ -2401,7 +2401,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2464,7 +2464,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2494,7 +2494,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
                   if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                  {
-                   DEBUG_puts("ippWriteIO: Could not write IPP "
+                   DEBUG_puts("1ippWriteIO: Could not write IPP "
                               "attribute...");
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
@@ -2511,7 +2511,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  if (ippWriteIO(dst, cb, 1, ipp,
                                 value->collection) == IPP_ERROR)
                  {
-                   DEBUG_puts("ippWriteIO: Unable to write collection value");
+                   DEBUG_puts("1ippWriteIO: Unable to write collection value");
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
                  }
@@ -2534,7 +2534,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    {
                       if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                      {
-                       DEBUG_puts("ippWriteIO: Could not write IPP "
+                       DEBUG_puts("1ippWriteIO: Could not write IPP "
                                   "attribute...");
                        ipp_buffer_release(buffer);
                        return (IPP_ERROR);
@@ -2559,7 +2559,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
                   if (n > (IPP_BUF_SIZE - 2))
                  {
-                   DEBUG_printf(("ippWriteIO: Data length too long (%d)\n",
+                   DEBUG_printf(("1ippWriteIO: Data length too long (%d)",
                                  n));
                    ipp_buffer_release(buffer);
                    return (IPP_ERROR);
@@ -2569,7 +2569,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWriteIO: Could not write IPP "
+                     DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      ipp_buffer_release(buffer);
                      return (IPP_ERROR);
@@ -2598,12 +2598,12 @@ ippWriteIO(void       *dst,             /* I - Destination */
 
           if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
          {
-           DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+           DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
 
-          DEBUG_printf(("ippWriteIO: wrote %d bytes\n",
+          DEBUG_printf(("2ippWriteIO: wrote %d bytes",
                        (int)(bufptr - buffer)));
 
         /*
@@ -2638,7 +2638,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
          if ((*cb)(dst, buffer, n) < 0)
          {
-           DEBUG_puts("ippWriteIO: Could not write IPP end-tag...");
+           DEBUG_puts("1ippWriteIO: Could not write IPP end-tag...");
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
@@ -2671,7 +2671,7 @@ _ippAddAttr(ipp_t *ipp,                   /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("_ippAddAttr(ipp=%p, num_values=%d)\n", ipp, num_values));
+  DEBUG_printf(("4_ippAddAttr(ipp=%p, num_values=%d)", ipp, num_values));
 
   if (!ipp || num_values < 0)
     return (NULL);
@@ -2691,7 +2691,7 @@ _ippAddAttr(ipp_t *ipp,                   /* I - IPP message */
     ipp->last = attr;
   }
 
-  DEBUG_printf(("_ippAddAttr(): %p\n", attr));
+  DEBUG_printf(("5_ippAddAttr: Returning %p", attr));
 
   return (attr);
 }
@@ -2708,7 +2708,7 @@ _ippFreeAttr(ipp_attribute_t *attr)       /* I - Attribute to free */
   ipp_value_t  *value;                 /* Current value */
 
 
-  DEBUG_printf(("_ippFreeAttr(attr=%p)\n", attr));
+  DEBUG_printf(("4_ippFreeAttr(attr=%p)", attr));
 
   switch (attr->value_tag)
   {
@@ -2864,8 +2864,8 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
     if (!attr->name)
       continue;
 
-    DEBUG_printf(("ipp_length: attr->name=\"%s\", attr->num_values=%d, "
-                  "bytes=%d\n", attr->name, attr->num_values, bytes));
+    DEBUG_printf(("9ipp_length: attr->name=\"%s\", attr->num_values=%d, "
+                  "bytes=%d", attr->name, attr->num_values, bytes));
 
     bytes += (int)strlen(attr->name);  /* Name */
     bytes += attr->num_values;         /* Value tag for each value */
@@ -2955,7 +2955,7 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
   else
     bytes ++;
 
-  DEBUG_printf(("ipp_length: bytes=%d\n", bytes));
+  DEBUG_printf(("8ipp_length: Returning %d bytes", bytes));
 
   return (bytes);
 }
@@ -2975,7 +2975,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
   char         len[32];                /* Length string */
   
 
-  DEBUG_printf(("ipp_read_http(http=%p, buffer=%p, length=%d)\n",
+  DEBUG_printf(("7ipp_read_http(http=%p, buffer=%p, length=%d)",
                 http, buffer, (int)length));
 
  /*
@@ -2986,7 +2986,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
        tbytes < (int)length;
        tbytes += bytes, buffer += bytes)
   {
-    DEBUG_printf(("ipp_read_http: tbytes=%d, http->state=%d\n", tbytes,
+    DEBUG_printf(("9ipp_read_http: tbytes=%d, http->state=%d", tbytes,
                   http->state));
 
     if (http->state == HTTP_WAITING)
@@ -3086,7 +3086,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
   if (tbytes == 0 && bytes < 0)
     tbytes = -1;
 
-  DEBUG_printf(("ipp_read_http: returning %d bytes...\n", tbytes));
+  DEBUG_printf(("8ipp_read_http: Returning %d bytes", tbytes));
 
   return (tbytes);
 }
index 02efaac0fb19fb547e0ab6518077759f583f776c..39ef4356952e9591b9e396de02a31ce6d0567f3a 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   I18N/language support for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -429,7 +429,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
                };
 
 
-  DEBUG_printf(("cupsLangGet(language=\"%s\")\n", language ? language : "(null)"));
+  DEBUG_printf(("cupsLangGet(language=\"%s\")", language));
 
 #ifdef __APPLE__
  /*
@@ -448,7 +448,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     if ((language = getenv("LANG")) == NULL)
       language = appleLangDefault();
 
-    DEBUG_printf(("cupsLangGet: language=\"%s\"\n", language));
+    DEBUG_printf(("2cupsLangGet: language=\"%s\"", language));
   }
 
 #else
@@ -477,8 +477,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     ptr = setlocale(LC_ALL, NULL);
 #  endif /* LC_MESSAGES */
 
-    DEBUG_printf(("cupsLangGet: current locale is \"%s\"\n",
-                  ptr ? ptr : "(null)"));
+    DEBUG_printf(("2cupsLangGet: current locale is \"%s\"", ptr));
 
     if (!ptr || !strcmp(ptr, "C") || !strcmp(ptr, "POSIX"))
     {
@@ -526,7 +525,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
       if (!strncmp(locale, "nb", 2))
         locale[1] = 'o';
 
-      DEBUG_printf(("cupsLangGet: new language value is \"%s\"\n", language));
+      DEBUG_printf(("2cupsLangGet: new language value is \"%s\"", language));
     }
   }
 #endif /* __APPLE__ */
@@ -563,8 +562,8 @@ cupsLangGet(const char *language)   /* I - Language or locale */
 
     *ptr = '\0';
 
-    DEBUG_printf(("cupsLangGet: charset set to \"%s\" via nl_langinfo(CODESET)...\n",
-                  charset));
+    DEBUG_printf(("2cupsLangGet: charset set to \"%s\" via "
+                  "nl_langinfo(CODESET)...", charset));
   }
 #endif /* CODESET */
 
@@ -643,7 +642,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     }
   }
 
-  DEBUG_printf(("cupsLangGet: langname=\"%s\", country=\"%s\", charset=\"%s\"\n",
+  DEBUG_printf(("2cupsLangGet: langname=\"%s\", country=\"%s\", charset=\"%s\"",
                 langname, country, charset));
 
  /*
@@ -681,7 +680,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     }
   }
 
-  DEBUG_printf(("cupsLangGet: encoding=%d(%s)\n", encoding,
+  DEBUG_printf(("2cupsLangGet: encoding=%d(%s)", encoding,
                 encoding == CUPS_AUTO_ENCODING ? "auto" :
                    lang_encodings[encoding]));
 
@@ -712,7 +711,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     pthread_mutex_unlock(&lang_mutex);
 #endif /* HAVE_PTHREAD_H */
 
-    DEBUG_printf(("cupsLangGet: Using cached copy of \"%s\"...\n", real));
+    DEBUG_printf(("1cupsLangGet: Using cached copy of \"%s\"...", real));
 
     return (lang);
   }
@@ -732,7 +731,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
       * No generic localization, so use POSIX...
       */
 
-      DEBUG_printf(("cupsLangGet: access(\"%s\", 0): %s\n", filename,
+      DEBUG_printf(("2cupsLangGet: access(\"%s\", 0): %s", filename,
                     strerror(errno)));
 
       snprintf(filename, sizeof(filename), "%s/C/cups_C.po", cg->localedir);
@@ -895,7 +894,7 @@ _cupsMessageLoad(const char *filename,      /* I - Message catalog to load */
   int                  length;         /* Length of combined strings */
 
 
-  DEBUG_printf(("_cupsMessageLoad(filename=\"%s\")\n", filename));
+  DEBUG_printf(("4_cupsMessageLoad(filename=\"%s\")", filename));
 
  /*
   * Create an array to hold the messages...
@@ -903,7 +902,7 @@ _cupsMessageLoad(const char *filename,      /* I - Message catalog to load */
 
   if ((a = cupsArrayNew((cups_array_func_t)cups_message_compare, NULL)) == NULL)
   {
-    DEBUG_puts("_cupsMessageLoad: Unable to allocate array!");
+    DEBUG_puts("5_cupsMessageLoad: Unable to allocate array!");
     return (NULL);
   }
 
@@ -913,7 +912,7 @@ _cupsMessageLoad(const char *filename,      /* I - Message catalog to load */
 
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("_cupsMessageLoad: Unable to open file: %s\n",
+    DEBUG_printf(("5_cupsMessageLoad: Unable to open file: %s",
                   strerror(errno)));
     return (a);
   }
@@ -1068,7 +1067,7 @@ _cupsMessageLoad(const char *filename,    /* I - Message catalog to load */
 
   cupsFileClose(fp);
 
-  DEBUG_printf(("_cupsMessageLoad: Returning %d messages...\n",
+  DEBUG_printf(("5_cupsMessageLoad: Returning %d messages...",
                 cupsArrayCount(a)));
 
   return (a);
@@ -1165,7 +1164,7 @@ appleLangDefault(void)
                               kCFStringEncodingASCII);
            CFRelease(localeName);
 
-           DEBUG_printf(("appleLangDefault: cg->language=\"%s\"\n",
+           DEBUG_printf(("9appleLangDefault: cg->language=\"%s\"",
                          cg->language));
 
           /*
@@ -1179,7 +1178,7 @@ appleLangDefault(void)
            {
              if (!strcmp(cg->language, apple_language_locale[i].language))
              {
-               DEBUG_printf(("appleLangDefault: mapping \"%s\" to \"%s\"...\n",
+               DEBUG_printf(("9appleLangDefault: mapping \"%s\" to \"%s\"...",
                              cg->language, apple_language_locale[i].locale));
                strlcpy(cg->language, apple_language_locale[i].locale, 
                        sizeof(cg->language));
@@ -1232,7 +1231,7 @@ cups_cache_lookup(const char      *name,/* I - Name of locale */
   cups_lang_t  *lang;                  /* Current language */
 
 
-  DEBUG_printf(("cups_cache_lookup(name=\"%s\", encoding=%d(%s))\n", name,
+  DEBUG_printf(("7cups_cache_lookup(name=\"%s\", encoding=%d(%s))", name,
                 encoding, encoding == CUPS_AUTO_ENCODING ? "auto" :
                              lang_encodings[encoding]));
 
@@ -1242,8 +1241,8 @@ cups_cache_lookup(const char      *name,/* I - Name of locale */
 
   for (lang = lang_cache; lang != NULL; lang = lang->next)
   {
-    DEBUG_printf(("cups_cache_lookup: lang=%p, language=\"%s\", encoding=%d(%s)\n",
-                  lang, lang->language, lang->encoding,
+    DEBUG_printf(("9cups_cache_lookup: lang=%p, language=\"%s\", "
+                 "encoding=%d(%s)", lang, lang->language, lang->encoding,
                  lang_encodings[lang->encoding]));
 
     if (!strcmp(lang->language, name) &&
@@ -1251,13 +1250,13 @@ cups_cache_lookup(const char      *name,/* I - Name of locale */
     {
       lang->used ++;
 
-      DEBUG_puts("cups_cache_lookup: returning match!");
+      DEBUG_puts("8cups_cache_lookup: returning match!");
 
       return (lang);
     }
   }
 
-  DEBUG_puts("cups_cache_lookup: returning NULL!");
+  DEBUG_puts("8cups_cache_lookup: returning NULL!");
 
   return (NULL);
 }
index 236b8048ef7f5f30835c43b5e08879caeeb47521..07cfe8a557fa7fa39e63707f2fc36dbc45332b26 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PPD localization routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -84,7 +84,7 @@ ppdLocalize(ppd_file_t *ppd)          /* I - PPD file */
   * Range check input...
   */
 
-  DEBUG_printf(("ppdLocalize(ppd=%p)\n", ppd));
+  DEBUG_printf(("ppdLocalize(ppd=%p)", ppd));
 
   if (!ppd)
     return (-1);
@@ -602,8 +602,8 @@ _ppdLocalizedAttr(ppd_file_t *ppd,  /* I - PPD file */
   ppd_attr_t   *attr;                  /* Current attribute */
 
 
-  DEBUG_printf(("_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", "
-                "ll_CC=\"%s\")\n", ppd, keyword, spec, ll_CC));
+  DEBUG_printf(("4_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", "
+                "ll_CC=\"%s\")", ppd, keyword, spec, ll_CC));
 
  /*
   * Look for Keyword.ll_CC, then Keyword.ll...
@@ -645,10 +645,10 @@ _ppdLocalizedAttr(ppd_file_t *ppd,        /* I - PPD file */
 
 #ifdef DEBUG
   if (attr)
-    DEBUG_printf(("_ppdLocalizedAttr: *%s %s/%s: \"%s\"\n", attr->name,
+    DEBUG_printf(("5_ppdLocalizedAttr: *%s %s/%s: \"%s\"\n", attr->name,
                   attr->spec, attr->text, attr->value ? attr->value : ""));
   else
-    DEBUG_puts("_ppdLocalizedAttr: NOT FOUND");
+    DEBUG_puts("5_ppdLocalizedAttr: NOT FOUND");
 #endif /* DEBUG */
 
   return (attr);
@@ -701,7 +701,7 @@ ppd_ll_CC(char *ll_CC,                      /* O - Country-specific locale name */
       strlcpy(ll_CC, "zh_CN", ll_CC_size);
   }
 
-  DEBUG_printf(("ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...\n",
+  DEBUG_printf(("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...",
                 lang->language, ll_CC));
 }
 
index 84836390e95bff1a150d3a16e4fcaf50eb981b83..b14e1da5ecd179f2085b9a33c2626349e313a02a 100644 (file)
@@ -465,17 +465,17 @@ ppdFindMarkedChoice(ppd_file_t *ppd,      /* I - PPD file */
                *marked;                /* Marked choice */
 
 
-  DEBUG_printf(("ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
+  DEBUG_printf(("2ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
 
   if ((key.option = ppdFindOption(ppd, option)) == NULL)
   {
-    DEBUG_puts("ppdFindMarkedChoice: Option not found, returning NULL");
+    DEBUG_puts("3ppdFindMarkedChoice: Option not found, returning NULL");
     return (NULL);
   }
 
   marked = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key);
 
-  DEBUG_printf(("ppdFindMarkedChoice: Returning %p(%s)...", marked,
+  DEBUG_printf(("3ppdFindMarkedChoice: Returning %p(%s)...", marked,
                 marked ? marked->choice : "NULL"));
 
   return (marked);
@@ -602,7 +602,7 @@ ppdMarkOption(ppd_file_t *ppd,              /* I - PPD file record */
               const char *option,      /* I - Keyword */
               const char *choice)      /* I - Option name */
 {
-  DEBUG_printf(("ppdMarkOption(ppd=%p, option=\"%s\", choice=\"%s\")\n",
+  DEBUG_printf(("ppdMarkOption(ppd=%p, option=\"%s\", choice=\"%s\")",
                ppd, option, choice));
 
  /*
@@ -756,12 +756,12 @@ debug_marked(ppd_file_t *ppd,             /* I - PPD file data */
   ppd_choice_t *c;                     /* Current choice */
 
 
-  DEBUG_printf(("cupsMarkOptions: %s\n", title));
+  DEBUG_printf(("2cupsMarkOptions: %s", title));
 
   for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked);
        c;
        c = (ppd_choice_t *)cupsArrayNext(ppd->marked))
-    DEBUG_printf(("cupsMarkOptions: %s=%s\n", c->option->keyword, c->choice));
+    DEBUG_printf(("2cupsMarkOptions: %s=%s", c->option->keyword, c->choice));
 }
 #endif /* DEBUG */
 
@@ -832,7 +832,7 @@ ppd_mark_option(ppd_file_t *ppd,    /* I - PPD file */
   struct lconv *loc;                   /* Locale data */
 
 
-  DEBUG_printf(("ppd_mark_option(ppd=%p, option=\"%s\", choice=\"%s\")\n",
+  DEBUG_printf(("7ppd_mark_option(ppd=%p, option=\"%s\", choice=\"%s\")",
                ppd, option, choice));
 
  /*
index b1476a49aa86a3c83a510a6b89d56c32f6c4214c..ecc210e0ba3b0fb12b1ff46ee17f4137a147d1c0 100644 (file)
@@ -62,11 +62,11 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
 
 
   DEBUG_printf(("cupsAddOption(name=\"%s\", value=\"%s\", num_options=%d, "
-                "options=%p)\n", name, value, num_options, options));
+                "options=%p)", name, value, num_options, options));
  
   if (!name || !name[0] || !value || !options || num_options < 0)
   {
-    DEBUG_printf(("cupsAddOption: Returning %d\n", num_options));
+    DEBUG_printf(("1cupsAddOption: Returning %d", num_options));
     return (num_options);
   }
 
@@ -94,7 +94,7 @@ cupsAddOption(const char    *name,    /* I  - Name of option */
     * No matching option name...
     */
 
-    DEBUG_printf(("cupsAddOption: New option inserted at index %d...\n",
+    DEBUG_printf(("2cupsAddOption: New option inserted at index %d...",
                   insert));
 
     if (num_options == 0)
@@ -105,7 +105,7 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
 
     if (temp == NULL)
     {
-      DEBUG_puts("cupsAddOption: Unable to expand option array, returning 0");
+      DEBUG_puts("1cupsAddOption: Unable to expand option array, returning 0");
       return (0);
     }
 
@@ -113,7 +113,7 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
 
     if (insert < num_options)
     {
-      DEBUG_printf(("cupsAddOption: Shifting %d options...\n",
+      DEBUG_printf(("2cupsAddOption: Shifting %d options...",
                     (int)(num_options - insert)));
       memmove(temp + insert + 1, temp + insert,
              (num_options - insert) * sizeof(cups_option_t));
@@ -129,7 +129,7 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
     * Match found; free the old value...
     */
 
-    DEBUG_printf(("cupsAddOption: Option already exists at index %d...\n",
+    DEBUG_printf(("2cupsAddOption: Option already exists at index %d...",
                   insert));
 
     temp = *options + insert;
@@ -138,7 +138,7 @@ cupsAddOption(const char    *name,  /* I  - Name of option */
 
   temp->value = _cupsStrAlloc(value);
 
-  DEBUG_printf(("cupsAddOption: Returning %d\n", num_options));
+  DEBUG_printf(("1cupsAddOption: Returning %d", num_options));
 
   return (num_options);
 }
@@ -156,7 +156,7 @@ cupsFreeOptions(
   int  i;                              /* Looping var */
 
 
-  DEBUG_printf(("cupsFreeOptions(num_options=%d, options=%p)\n", num_options,
+  DEBUG_printf(("cupsFreeOptions(num_options=%d, options=%p)", num_options,
                 options));
 
   if (num_options <= 0 || !options)
@@ -185,12 +185,12 @@ cupsGetOption(const char    *name,        /* I - Name of option */
        match;                          /* Matching index */
 
 
-  DEBUG_printf(("cupsGetOption(name=\"%s\", num_options=%d, options=%p)\n",
+  DEBUG_printf(("2cupsGetOption(name=\"%s\", num_options=%d, options=%p)",
                 name, num_options, options));
 
   if (!name || num_options <= 0 || !options)
   {
-    DEBUG_puts("cupsGetOption: Returning NULL");
+    DEBUG_puts("3cupsGetOption: Returning NULL");
     return (NULL);
   }
 
@@ -198,11 +198,11 @@ cupsGetOption(const char    *name,        /* I - Name of option */
 
   if (!diff)
   {
-    DEBUG_printf(("cupsGetOption: Returning \"%s\"\n", options[match].value));
+    DEBUG_printf(("3cupsGetOption: Returning \"%s\"", options[match].value));
     return (options[match].value);
   }
 
-  DEBUG_puts("cupsGetOption: Returning NULL");
+  DEBUG_puts("3cupsGetOption: Returning NULL");
   return (NULL);
 }
 
@@ -231,7 +231,7 @@ cupsParseOptions(
        quote;                          /* Quote character */
 
 
-  DEBUG_printf(("cupsParseOptions(arg=\"%s\", num_options=%d, options=%p)\n",
+  DEBUG_printf(("cupsParseOptions(arg=\"%s\", num_options=%d, options=%p)",
                 arg, num_options, options));
 
  /*
@@ -240,13 +240,13 @@ cupsParseOptions(
 
   if (!arg)
   {
-    DEBUG_printf(("cupsParseOptions: Returning %d\n", num_options));
+    DEBUG_printf(("1cupsParseOptions: Returning %d", num_options));
     return (num_options);
   }
 
   if (!options || num_options < 0)
   {
-    DEBUG_puts("cupsParseOptions: Returning 0");
+    DEBUG_puts("1cupsParseOptions: Returning 0");
     return (0);
   }
 
@@ -256,8 +256,8 @@ cupsParseOptions(
 
   if ((copyarg = strdup(arg)) == NULL)
   {
-    DEBUG_puts("cupsParseOptions: Unable to copy arg string");
-    DEBUG_printf(("cupsParseOptions: Returning %d\n", num_options));
+    DEBUG_puts("1cupsParseOptions: Unable to copy arg string");
+    DEBUG_printf(("1cupsParseOptions: Returning %d", num_options));
     return (num_options);
   }
 
@@ -316,7 +316,7 @@ cupsParseOptions(
     if ((sep = *ptr) == '=')
       *ptr++ = '\0';
 
-    DEBUG_printf(("cupsParseOptions: name=\"%s\"\n", name));
+    DEBUG_printf(("2cupsParseOptions: name=\"%s\"", name));
 
     if (sep != '=')
     {
@@ -407,7 +407,7 @@ cupsParseOptions(
     if (*ptr != '\0')
       *ptr++ = '\0';
 
-    DEBUG_printf(("cupsParseOptions: value=\"%s\"\n", value));
+    DEBUG_printf(("2cupsParseOptions: value=\"%s\"", value));
 
    /*
     * Skip trailing whitespace...
@@ -430,7 +430,7 @@ cupsParseOptions(
 
   free(copyarg);
 
-  DEBUG_printf(("cupsParseOptions: Returning %d\n", num_options));
+  DEBUG_printf(("1cupsParseOptions: Returning %d", num_options));
 
   return (num_options);
 }
@@ -452,7 +452,7 @@ cupsRemoveOption(
   cups_option_t        *option;                /* Current option */
 
 
-  DEBUG_printf(("cupsRemoveOption(name=\"%s\", num_options=%d, options=%p)\n",
+  DEBUG_printf(("cupsRemoveOption(name=\"%s\", num_options=%d, options=%p)",
                 name, num_options, options));
 
  /*
@@ -461,7 +461,7 @@ cupsRemoveOption(
 
   if (!name || num_options < 1 || !options)
   {
-    DEBUG_printf(("cupsRemoveOption: Returning %d\n", num_options));
+    DEBUG_printf(("1cupsRemoveOption: Returning %d", num_options));
     return (num_options);
   }
 
@@ -479,7 +479,7 @@ cupsRemoveOption(
     * Remove this option from the array...
     */
 
-    DEBUG_puts("cupsRemoveOption: Found option, removing it...");
+    DEBUG_puts("2cupsRemoveOption: Found option, removing it...");
 
     num_options --;
     i --;
@@ -495,7 +495,7 @@ cupsRemoveOption(
   * Return the new number of options...
   */
 
-  DEBUG_printf(("cupsRemoveOption: Returning %d\n", num_options));
+  DEBUG_printf(("1cupsRemoveOption: Returning %d", num_options));
   return (num_options);
 }
 
@@ -531,13 +531,13 @@ cups_find_option(
   cups_option_t        key;                    /* Search key */
 
 
-  DEBUG_printf(("cups_find_option(name=\"%s\", num_options=%d, options=%p, "
-               "prev=%d, rdiff=%p)\n", name, num_options, options, prev,
+  DEBUG_printf(("7cups_find_option(name=\"%s\", num_options=%d, options=%p, "
+               "prev=%d, rdiff=%p)", name, num_options, options, prev,
                rdiff));
 
 #ifdef DEBUG
   for (left = 0; left < num_options; left ++)
-    DEBUG_printf(("cups_find_option: options[%d].name=\"%s\", .value=\"%s\"\n",
+    DEBUG_printf(("9cups_find_option: options[%d].name=\"%s\", .value=\"%s\"",
                   left, options[left].name, options[left].value));
 #endif /* DEBUG */
 
index b99b54a1e0e502082fce618418323041db0e143c..21ee3ab250eaece35e01f2d8641cb2de37203720 100644 (file)
@@ -54,7 +54,7 @@ ppdPageSize(ppd_file_t *ppd,          /* I - PPD file record */
 
   if (!ppd)
   {
-    DEBUG_puts("ppdPageSize: Bad PPD pointer, returning NULL...");
+    DEBUG_puts("1ppdPageSize: Bad PPD pointer, returning NULL...");
     return (NULL);
   }
 
@@ -72,7 +72,7 @@ ppdPageSize(ppd_file_t *ppd,          /* I - PPD file record */
 
       if (!i)
       {
-       DEBUG_puts("ppdPageSize: No custom sizes, returning NULL...");
+       DEBUG_puts("1ppdPageSize: No custom sizes, returning NULL...");
         return (NULL);
       }
 
@@ -144,7 +144,7 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       * Return the page size...
       */
 
-      DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+      DEBUG_printf(("1ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
                     size->name, size->width, size->length));
 
       return (size);
@@ -158,7 +158,7 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
        if (!strcasecmp(name, size->name))
        {
-         DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+         DEBUG_printf(("1ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
                        size->name, size->width, size->length));
 
           return (size);
@@ -174,14 +174,14 @@ ppdPageSize(ppd_file_t *ppd,              /* I - PPD file record */
     for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
       if (size->marked)
       {
-       DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+       DEBUG_printf(("1ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
                      size->name, size->width, size->length));
 
         return (size);
       }
   }
 
-  DEBUG_puts("ppdPageSize: Size not found, returning NULL");
+  DEBUG_puts("1ppdPageSize: Size not found, returning NULL");
 
   return (NULL);
 }
index c42d36d48f5cfb8008e48bfb7fc6eee7e06e76be..4018d803b094e9c7765c8d87014dc316a5194283 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PPD file routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -549,6 +549,8 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
                        };
 
 
+  DEBUG_printf(("ppdOpen2(fp=%p)", fp));
+
  /*
   * Default to "OK" status...
   */
@@ -575,7 +577,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
 
   mask = ppd_read(fp, &line, keyword, name, text, &string, 0, cg);
 
-  DEBUG_printf(("mask=%x, keyword=\"%s\"...\n", mask, keyword));
+  DEBUG_printf(("2ppdOpen2: mask=%x, keyword=\"%s\"...", mask, keyword));
 
   if (mask == 0 ||
       strcmp(keyword, "PPD-Adobe") ||
@@ -594,7 +596,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
     return (NULL);
   }
 
-  DEBUG_printf(("ppdOpen: keyword = %s, string = %p\n", keyword, string));
+  DEBUG_printf(("2ppdOpen2: keyword=%s, string=%p", keyword, string));
 
   _cupsStrFree(string);
 
@@ -639,8 +641,8 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
 
   while ((mask = ppd_read(fp, &line, keyword, name, text, &string, 1, cg)) != 0)
   {
-    DEBUG_printf(("mask=%x, keyword=\"%s\", name=\"%s\", text=\"%s\", "
-                  "string=%d chars...", mask, keyword, name, text,
+    DEBUG_printf(("2ppdOpen2: mask=%x, keyword=\"%s\", name=\"%s\", "
+                  "text=\"%s\", string=%d chars...", mask, keyword, name, text,
                  string ? (int)strlen(string) : 0));
 
     if (strncmp(keyword, "Default", 7) && !string &&
@@ -690,7 +692,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
 
         ui_keyword = 1;
 
-        DEBUG_printf(("**** FOUND ADOBE UI KEYWORD %s WITHOUT OPENUI!\n",
+        DEBUG_printf(("2ppdOpen2: FOUND ADOBE UI KEYWORD %s WITHOUT OPENUI!",
                      keyword));
 
         if (!group)
@@ -699,7 +701,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
                                     encoding)) == NULL)
            goto error;
 
-          DEBUG_printf(("Adding to group %s...\n", group->text));
+          DEBUG_printf(("2ppdOpen2: Adding to group %s...", group->text));
           option = ppd_get_option(group, keyword);
          group  = NULL;
        }
@@ -734,7 +736,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
              !strcmp(ppd->attrs[j]->name + 7, keyword) &&
              ppd->attrs[j]->value)
          {
-           DEBUG_printf(("Setting Default%s to %s via attribute...\n",
+           DEBUG_printf(("2ppdOpen2: Setting Default%s to %s via attribute...",
                          option->keyword, ppd->attrs[j]->value));
            strlcpy(option->defchoice, ppd->attrs[j]->value,
                    sizeof(option->defchoice));
@@ -1032,7 +1034,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
     {
       ppd_option_t     *custom_option; /* Custom option */
 
-      DEBUG_puts("Processing Custom option...");
+      DEBUG_puts("2ppdOpen2: Processing Custom option...");
 
      /*
       * Get the option and custom option...
@@ -1059,7 +1061,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
         if ((choice = ppdFindChoice(custom_option, "Custom")) == NULL)
          if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
          {
-           DEBUG_puts("Unable to add Custom choice!");
+           DEBUG_puts("1ppdOpen2: Unable to add Custom choice!");
 
            cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1099,7 +1101,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
          if ((choice = ppdFindChoice(custom_option, "Custom")) == NULL)
            if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
            {
-             DEBUG_puts("Unable to add Custom choice!");
+             DEBUG_puts("1ppdOpen2: Unable to add Custom choice!");
 
              cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1209,7 +1211,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
       * Add an option record to the current sub-group, group, or file...
       */
 
-      DEBUG_printf(("name=\"%s\" (%d)\n", name, (int)strlen(name)));
+      DEBUG_printf(("2ppdOpen2: name=\"%s\" (%d)", name, (int)strlen(name)));
 
       if (name[0] == '*')
         _cups_strcpy(name, name + 1); /* Eliminate leading asterisk */
@@ -1217,7 +1219,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
       for (i = (int)strlen(name) - 1; i > 0 && isspace(name[i] & 255); i --)
         name[i] = '\0'; /* Eliminate trailing spaces */
 
-      DEBUG_printf(("OpenUI of %s in group %s...\n", name,
+      DEBUG_printf(("2ppdOpen2: OpenUI of %s in group %s...", name,
                     group ? group->text : "(null)"));
 
       if (subgroup != NULL)
@@ -1228,7 +1230,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
                                   encoding)) == NULL)
          goto error;
 
-        DEBUG_printf(("Adding to group %s...\n", group->text));
+        DEBUG_printf(("2ppdOpen2: Adding to group %s...", group->text));
         option = ppd_get_option(group, name);
        group  = NULL;
       }
@@ -1266,7 +1268,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
            !strcmp(ppd->attrs[j]->name + 7, name) &&
            ppd->attrs[j]->value)
        {
-         DEBUG_printf(("Setting Default%s to %s via attribute...\n",
+         DEBUG_printf(("2ppdOpen2: Setting Default%s to %s via attribute...",
                        option->keyword, ppd->attrs[j]->value));
          strlcpy(option->defchoice, ppd->attrs[j]->value,
                  sizeof(option->defchoice));
@@ -1312,7 +1314,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
         if ((choice = ppdFindChoice(option, "Custom")) == NULL)
          if ((choice = ppd_add_choice(option, "Custom")) == NULL)
          {
-           DEBUG_puts("Unable to add Custom choice!");
+           DEBUG_puts("1ppdOpen2: Unable to add Custom choice!");
 
            cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1385,7 +1387,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
            !strcmp(ppd->attrs[j]->name + 7, name) &&
            ppd->attrs[j]->value)
        {
-         DEBUG_printf(("Setting Default%s to %s via attribute...\n",
+         DEBUG_printf(("2ppdOpen2: Setting Default%s to %s via attribute...",
                        option->keyword, ppd->attrs[j]->value));
          strlcpy(option->defchoice, ppd->attrs[j]->value,
                  sizeof(option->defchoice));
@@ -1415,7 +1417,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
       {
        if ((choice = ppd_add_choice(option, "Custom")) == NULL)
        {
-         DEBUG_puts("Unable to add Custom choice!");
+         DEBUG_puts("1ppdOpen2: Unable to add Custom choice!");
 
          cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1588,11 +1590,11 @@ ppdOpen2(cups_file_t *fp)               /* I - File to read from */
         * Set the default as part of the current option...
        */
 
-        DEBUG_printf(("Setting %s to %s...\n", keyword, string));
+        DEBUG_printf(("2ppdOpen2: Setting %s to %s...", keyword, string));
 
         strlcpy(option->defchoice, string, sizeof(option->defchoice));
 
-        DEBUG_printf(("%s is now %s...\n", keyword, option->defchoice));
+        DEBUG_printf(("2ppdOpen2: %s is now %s...", keyword, option->defchoice));
       }
       else
       {
@@ -1605,7 +1607,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
 
         if ((toption = ppdFindOption(ppd, keyword + 7)) != NULL)
        {
-         DEBUG_printf(("Setting %s to %s...\n", keyword, string));
+         DEBUG_printf(("2ppdOpen2: Setting %s to %s...", keyword, string));
          strlcpy(toption->defchoice, string, sizeof(toption->defchoice));
        }
       }
@@ -1836,7 +1838,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
                 (PPD_KEYWORD | PPD_OPTION | PPD_STRING) &&
             !strcmp(keyword, option->keyword))
     {
-      DEBUG_printf(("group = %p, subgroup = %p\n", group, subgroup));
+      DEBUG_printf(("2ppdOpen2: group=%p, subgroup=%p", group, subgroup));
 
       if (!strcmp(keyword, "PageSize"))
       {
@@ -1897,7 +1899,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
 
 #ifdef DEBUG
   if (!cupsFileEOF(fp))
-    DEBUG_printf(("Premature EOF at %lu...\n",
+    DEBUG_printf(("1ppdOpen2: Premature EOF at %lu...\n",
                   (unsigned long)cupsFileTell(fp)));
 #endif /* DEBUG */
 
@@ -2497,7 +2499,7 @@ ppd_get_group(ppd_file_t      *ppd,       /* I - PPD file */
   ppd_group_t  *group;                 /* Group */
 
 
-  DEBUG_printf(("ppd_get_group(ppd=%p, name=\"%s\", text=\"%s\", cg=%p)\n",
+  DEBUG_printf(("7ppd_get_group(ppd=%p, name=\"%s\", text=\"%s\", cg=%p)",
                 ppd, name, text, cg));
 
   for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
@@ -2506,7 +2508,7 @@ ppd_get_group(ppd_file_t      *ppd,       /* I - PPD file */
 
   if (i == 0)
   {
-    DEBUG_printf(("Adding group %s...\n", name));
+    DEBUG_printf(("8ppd_get_group: Adding group %s...", name));
 
     if (cg->ppd_conform == PPD_CONFORM_STRICT && strlen(text) >= sizeof(group->text))
     {
@@ -2555,7 +2557,7 @@ ppd_get_option(ppd_group_t *group,        /* I - Group */
   ppd_option_t *option;                /* Option */
 
 
-  DEBUG_printf(("ppd_get_option(group=%p(\"%s\"), name=\"%s\")\n",
+  DEBUG_printf(("7ppd_get_option(group=%p(\"%s\"), name=\"%s\")",
                 group, group->name, name));
 
   for (i = group->num_options, option = group->options; i > 0; i --, option ++)
@@ -2890,7 +2892,7 @@ ppd_read(cups_file_t    *fp,              /* I - File to read from */
 
     *lineptr = '\0';
 
-    DEBUG_printf(("LINE=\"%s\"\n", line->buffer));
+    DEBUG_printf(("9ppd_read: LINE=\"%s\"", line->buffer));
 
    /*
     * The dynamically created PPDs for older style Mac OS X
@@ -2988,8 +2990,6 @@ ppd_read(cups_file_t    *fp,              /* I - File to read from */
 
     mask |= PPD_KEYWORD;
 
-/*    DEBUG_printf(("keyword = \"%s\", lineptr = \"%s\"\n", keyword, lineptr));*/
-
     if (isspace(*lineptr & 255))
     {
      /*
@@ -3027,8 +3027,6 @@ ppd_read(cups_file_t    *fp,              /* I - File to read from */
 
       mask |= PPD_OPTION;
 
-/*      DEBUG_printf(("option = \"%s\", lineptr = \"%s\"\n", option, lineptr));*/
-
       if (*lineptr == '/')
       {
        /*
@@ -3062,8 +3060,6 @@ ppd_read(cups_file_t    *fp,              /* I - File to read from */
            
        mask |= PPD_TEXT;
       }
-
-/*      DEBUG_printf(("text = \"%s\", lineptr = \"%s\"\n", text, lineptr));*/
     }
 
     if (isspace(*lineptr & 255) && cg->ppd_conform == PPD_CONFORM_STRICT)
@@ -3101,8 +3097,6 @@ ppd_read(cups_file_t    *fp,              /* I - File to read from */
 
       *string = _cupsStrAlloc(lineptr);
 
-/*      DEBUG_printf(("string = \"%s\", lineptr = \"%s\"\n", *string, lineptr));*/
-
       mask |= PPD_STRING;
     }
   }
index 8179e51cbbd33d3a02775d9e3e7e35e4e9ee79f8..68b35c645dd52810e971082789d66db3c374216a 100644 (file)
@@ -66,10 +66,9 @@ cupsDoFileRequest(http_t     *http,  /* I - Connection to server or @code CUPS_HT
 
 
   DEBUG_printf(("cupsDoFileRequest(http=%p, request=%p(%s), resource=\"%s\", "
-                "filename=\"%s\")\n", http, request,
+                "filename=\"%s\")", http, request,
                request ? ippOpString(request->request.op.operation_id) : "?",
-               resource ? resource : "(null)",
-               filename ? filename : "(null)"));
+               resource, filename));
 
   if (filename)
   {
@@ -131,9 +130,9 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
 
   DEBUG_printf(("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", "
-                "infile=%d, outfile=%d)\n", http, request,
+                "infile=%d, outfile=%d)", http, request,
                request ? ippOpString(request->request.op.operation_id) : "?",
-               resource ? resource : "(null)", infile, outfile));
+               resource, infile, outfile));
 
  /*
   * Range check input...
@@ -203,7 +202,7 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   else
     length = ippLength(request);
 
-  DEBUG_printf(("cupsDoIORequest: Request length=%ld, total length=%ld",
+  DEBUG_printf(("2cupsDoIORequest: Request length=%ld, total length=%ld",
                 (long)ippLength(request), (long)length));
 
  /*
@@ -219,7 +218,7 @@ cupsDoIORequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
   while (response == NULL)
   {
-    DEBUG_puts("cupsDoIORequest: setup...");
+    DEBUG_puts("2cupsDoIORequest: setup...");
 
    /*
     * Send the request...
@@ -227,11 +226,11 @@ cupsDoIORequest(http_t     *http, /* I - Connection to server or @code CUPS_HTTP
 
     status = cupsSendRequest(http, request, resource, length);
 
-    DEBUG_printf(("cupsDoIORequest: status=%d\n", status));
+    DEBUG_printf(("2cupsDoIORequest: status=%d", status));
 
     if (status == HTTP_CONTINUE && request->state == IPP_DATA && infile >= 0)
     {
-      DEBUG_puts("cupsDoIORequest: file write...");
+      DEBUG_puts("2cupsDoIORequest: file write...");
 
      /*
       * Send the file with the request...
@@ -318,10 +317,10 @@ cupsDoRequest(http_t     *http,           /* I - Connection to server or @code CUPS_HTTP_
               ipp_t      *request,     /* I - IPP request */
               const char *resource)    /* I - HTTP resource for POST */
 {
-  DEBUG_printf(("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")\n",
+  DEBUG_printf(("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")",
                 http, request,
                request ? ippOpString(request->request.op.operation_id) : "?",
-               resource ? resource : "(null)"));
+               resource));
 
   return (cupsDoIORequest(http, request, resource, -1, -1));
 }
@@ -346,8 +345,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
   ipp_t                *response = NULL;       /* IPP response */
 
 
-  DEBUG_printf(("cupsGetReponse(http=%p, resource=\"%s\")\n", http,
-                resource ? resource : "(null)"));
+  DEBUG_printf(("cupsGetResponse(http=%p, resource=\"%s\")", http, resource));
 
  /*
   * Connect to the default server as needed...
@@ -369,7 +367,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
     * Send a 0-length chunk to finish off the request...
     */
 
-    DEBUG_puts("cupsGetResponse: Finishing chunked POST...");
+    DEBUG_puts("2cupsGetResponse: Finishing chunked POST...");
 
     if (httpWrite2(http, "", 0) < 0)
       return (NULL);
@@ -379,14 +377,14 @@ cupsGetResponse(http_t     *http, /* I - Connection to server or @code CUPS_HTTP
   * Wait for a response from the server...
   */
 
-  DEBUG_printf(("cupsGetResponse: Update loop, http->status=%d...\n",
+  DEBUG_printf(("2cupsGetResponse: Update loop, http->status=%d...",
                 http->status));
 
   status = http->status;
   while (status == HTTP_CONTINUE)
     status = httpUpdate(http);
 
-  DEBUG_printf(("cupsGetResponse: status=%d\n", status));
+  DEBUG_printf(("2cupsGetResponse: status=%d", status));
 
   if (status == HTTP_OK)
   {
@@ -406,7 +404,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
       * Delete the response...
       */
 
-      DEBUG_puts("cupsGetResponse: IPP read error!");
+      DEBUG_puts("1cupsGetResponse: IPP read error!");
 
       ippDelete(response);
       response = NULL;
@@ -432,14 +430,10 @@ cupsGetResponse(http_t     *http, /* I - Connection to server or @code CUPS_HTTP
       * See if we can do authentication...
       */
 
-      int auth_result;
+      DEBUG_puts("2cupsGetResponse: Need authorization...");
 
-      DEBUG_puts("cupsGetResponse: Need authorization...");
-
-      if ((auth_result = cupsDoAuthentication(http, "POST", resource)) == 0)
+      if (!cupsDoAuthentication(http, "POST", resource))
        httpReconnect(http);
-      else if (auth_result < 0)
-        http->status = status = HTTP_FORBIDDEN;
     }
 
 #ifdef HAVE_SSL
@@ -449,7 +443,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
       * Force a reconnect with encryption...
       */
 
-      DEBUG_puts("cupsGetResponse: Need encryption...");
+      DEBUG_puts("2cupsGetResponse: Need encryption...");
 
       if (!httpReconnect(http))
         httpEncryption(http, HTTP_ENCRYPT_REQUIRED);
@@ -464,7 +458,7 @@ cupsGetResponse(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
     attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT);
 
-    DEBUG_printf(("cupsGetResponse: status-code=%s, status-message=\"%s\"\n",
+    DEBUG_printf(("1cupsGetResponse: status-code=%s, status-message=\"%s\"",
                   ippErrorString(response->request.status.status_code),
                   attr ? attr->values[0].string.text : ""));
 
@@ -499,7 +493,7 @@ cupsReadResponseData(
   */
 
   DEBUG_printf(("cupsReadResponseData(http=%p, buffer=%p, "
-                "length=" CUPS_LLFMT ")\n", http, buffer, CUPS_LLCAST length));
+                "length=" CUPS_LLFMT ")", http, buffer, CUPS_LLCAST length));
 
   if (!http)
   {
@@ -548,9 +542,9 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
 
   DEBUG_printf(("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", "
-                "length=" CUPS_LLFMT ")\n", http, request,
+                "length=" CUPS_LLFMT ")", http, request,
                request ? ippOpString(request->request.op.operation_id) : "?",
-               resource ? resource : "(null)", CUPS_LLCAST length));
+               resource, CUPS_LLCAST length));
 
  /*
   * Range check input...
@@ -606,7 +600,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
   for (;;)
   {
-    DEBUG_puts("cupsSendRequest: Setup...");
+    DEBUG_puts("2cupsSendRequest: Setup...");
 
    /*
     * Setup the HTTP variables needed...
@@ -618,13 +612,13 @@ cupsSendRequest(http_t     *http, /* I - Connection to server or @code CUPS_HTTP
     httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring);
     httpSetExpect(http, expect);
 
-    DEBUG_printf(("cupsSendRequest: authstring=\"%s\"\n", http->authstring));
+    DEBUG_printf(("2cupsSendRequest: authstring=\"%s\"", http->authstring));
 
    /*
     * Try the request...
     */
 
-    DEBUG_puts("cupsSendRequest: Sending HTTP POST...");
+    DEBUG_puts("2cupsSendRequest: Sending HTTP POST...");
 
     if (httpPost(http, resource))
     {
@@ -641,7 +635,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
     * Send the IPP data...
     */
 
-    DEBUG_puts("cupsSendRequest: Writing IPP request...");
+    DEBUG_puts("2cupsSendRequest: Writing IPP request...");
 
     request->state = IPP_IDLE;
     status         = HTTP_CONTINUE;
@@ -664,7 +658,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
 
     if (!got_status && expect == HTTP_CONTINUE)
     {
-      DEBUG_puts("cupsSendRequest: Waiting for 100-continue...");
+      DEBUG_puts("2cupsSendRequest: Waiting for 100-continue...");
 
       if (httpWait(http, 1000))
         status = httpUpdate(http);
@@ -672,7 +666,7 @@ cupsSendRequest(http_t     *http,   /* I - Connection to server or @code CUPS_HTTP
     else if (httpCheck(http))
       status = httpUpdate(http);
 
-    DEBUG_printf(("cupsSendRequest: status=%d\n", status));
+    DEBUG_printf(("2cupsSendRequest: status=%d", status));
 
    /*
     * Process the current HTTP status...
@@ -761,7 +755,7 @@ cupsWriteRequestData(
   */
 
   DEBUG_printf(("cupsWriteRequestData(http=%p, buffer=%p, "
-                "length=" CUPS_LLFMT ")\n", http, buffer, CUPS_LLCAST length));
+                "length=" CUPS_LLFMT ")", http, buffer, CUPS_LLCAST length));
 
   if (!http)
   {
@@ -850,9 +844,8 @@ _cupsSetError(ipp_status_t status,  /* I - IPP status code */
       cg->last_status_message = _cupsStrAlloc(message);
   }
 
-  DEBUG_printf(("_cupsSetError: last_error=%s, last_status_message=\"%s\"\n",
-                ippErrorString(cg->last_error),
-               cg->last_status_message ? cg->last_status_message : ""));
+  DEBUG_printf(("4_cupsSetError: last_error=%s, last_status_message=\"%s\"",
+                ippErrorString(cg->last_error), cg->last_status_message));
 }
 
 
@@ -894,8 +887,8 @@ _cupsSetHTTPError(http_status_t status)     /* I - HTTP status code */
        break;
 
     default :
-       DEBUG_printf(("HTTP error %d mapped to IPP_SERVICE_UNAVAILABLE!\n",
-                     status));
+       DEBUG_printf(("4_cupsSetHTTPError: HTTP error %d mapped to "
+                     "IPP_SERVICE_UNAVAILABLE!", status));
        _cupsSetError(IPP_SERVICE_UNAVAILABLE, httpStatus(status), 0);
        break;
   }
index a59f5c305a0d560fb62571db7604f73c08b6be28..41db25e67de9b6698435d08b204ca2db3096cb15 100644 (file)
@@ -121,7 +121,7 @@ cupsSideChannelRead(
 
 
   DEBUG_printf(("cupsSideChannelRead(command=%p, status=%p, data=%p, "
-                "datalen=%p(%d), timeout=%.3f)\n", command, status, data,
+                "datalen=%p(%d), timeout=%.3f)", command, status, data,
                datalen, datalen ? *datalen : -1, timeout));
 
  /*
@@ -155,7 +155,7 @@ cupsSideChannelRead(
   {
     if (select(CUPS_SC_FD + 1, &input_set, NULL, NULL, NULL) < 1)
     {
-      DEBUG_printf(("cupsSideChannelRead: Select error: %s\n", strerror(errno)));
+      DEBUG_printf(("1cupsSideChannelRead: Select error: %s", strerror(errno)));
       return (-1);
     }
   }
@@ -166,7 +166,7 @@ cupsSideChannelRead(
 
     if (select(CUPS_SC_FD + 1, &input_set, NULL, NULL, &stimeout) < 1)
     {
-      DEBUG_puts("cupsSideChannelRead: Select timeout");
+      DEBUG_puts("1cupsSideChannelRead: Select timeout");
       return (-1);
     }
   }
@@ -186,7 +186,7 @@ cupsSideChannelRead(
   while ((bytes = read(CUPS_SC_FD, buffer, sizeof(buffer))) < 0)
     if (errno != EINTR && errno != EAGAIN)
     {
-      DEBUG_printf(("cupsSideChannelRead: Read error: %s\n", strerror(errno)));
+      DEBUG_printf(("1cupsSideChannelRead: Read error: %s", strerror(errno)));
       return (-1);
     }
 
@@ -197,7 +197,7 @@ cupsSideChannelRead(
   if (buffer[0] < CUPS_SC_CMD_SOFT_RESET ||
       buffer[0] > CUPS_SC_CMD_SNMP_GET_NEXT)
   {
-    DEBUG_printf(("cupsSideChannelRead: Bad command %d!\n", buffer[0]));
+    DEBUG_printf(("1cupsSideChannelRead: Bad command %d!", buffer[0]));
     return (-1);
   }
 
@@ -240,7 +240,7 @@ cupsSideChannelRead(
     memcpy(data, buffer + 4, templen);
   }
 
-  DEBUG_printf(("cupsSideChannelRead: Returning status=%d\n", *status));
+  DEBUG_printf(("1cupsSideChannelRead: Returning status=%d", *status));
 
   return (0);
 }
@@ -284,7 +284,7 @@ cupsSideChannelSNMPGet(
 
 
   DEBUG_printf(("cupsSideChannelSNMPGet(oid=\"%s\", data=%p, datalen=%p(%d), "
-                "timeout=%.3f)\n", oid, data, datalen, datalen ? *datalen : -1,
+                "timeout=%.3f)", oid, data, datalen, datalen ? *datalen : -1,
                timeout));
 
  /*
@@ -378,7 +378,7 @@ cupsSideChannelSNMPWalk(
 
 
   DEBUG_printf(("cupsSideChannelSNMPWalk(oid=\"%s\", timeout=%.3f, cb=%p, "
-                "context=%p)\n", oid, timeout, cb, context));
+                "context=%p)", oid, timeout, cb, context));
 
  /*
   * Range check input...
index 847f7c0d839bebef8eeb13916de9c88da457ef4e..43722ba7dbb8bbbc6114ec30bc299d2ee61fcc23 100644 (file)
@@ -116,7 +116,7 @@ static void         snmp_set_error(cups_snmp_t *packet,
 void
 _cupsSNMPClose(int fd)                 /* I - SNMP socket file descriptor */
 {
-  DEBUG_printf(("_cupsSNMPClose(fd=%d)\n", fd));
+  DEBUG_printf(("4_cupsSNMPClose(fd=%d)", fd));
 
 #ifdef WIN32
   closesocket(fd);
@@ -140,7 +140,7 @@ _cupsSNMPCopyOID(int       *dst,    /* I - Destination OID */
   int  i;                              /* Looping var */
 
 
-  DEBUG_printf(("_cupsSNMPCopyOID(dst=%p, src=%p, dstsize=%d)\n", dst, src,
+  DEBUG_printf(("4_cupsSNMPCopyOID(dst=%p, src=%p, dstsize=%d)", dst, src,
                 dstsize));
 
   for (i = 0, dstsize --; src[i] >= 0 && i < dstsize; i ++)
@@ -169,7 +169,7 @@ _cupsSNMPDefaultCommunity(void)
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
-  DEBUG_puts("_cupsSNMPDefaultCommunity()");
+  DEBUG_puts("4_cupsSNMPDefaultCommunity()");
 
   if (!cg->snmp_community[0])
   {
@@ -190,7 +190,7 @@ _cupsSNMPDefaultCommunity(void)
     }
   }
 
-  DEBUG_printf(("_cupsSNMPDefaultCommunity: Returning \"%s\"\n",
+  DEBUG_printf(("5_cupsSNMPDefaultCommunity: Returning \"%s\"",
                 cg->snmp_community));
 
   return (cg->snmp_community);
@@ -214,11 +214,11 @@ _cupsSNMPIsOID(cups_snmp_t *packet,       /* I - Response packet */
   * Range check input...
   */
 
-  DEBUG_printf(("_cupsSNMPIsOID(packet=%p, oid=%p)\n", packet, oid));
+  DEBUG_printf(("4_cupsSNMPIsOID(packet=%p, oid=%p)", packet, oid));
 
   if (!packet || !oid)
   {
-    DEBUG_puts("_cupsSNMPIsOID: Returning 0");
+    DEBUG_puts("5_cupsSNMPIsOID: Returning 0");
 
     return (0);
   }
@@ -232,12 +232,12 @@ _cupsSNMPIsOID(cups_snmp_t *packet,       /* I - Response packet */
        i ++)
     if (oid[i] != packet->object_name[i])
     {
-      DEBUG_puts("_cupsSNMPIsOID: Returning 0");
+      DEBUG_puts("5_cupsSNMPIsOID: Returning 0");
 
       return (0);
     }
 
-  DEBUG_printf(("_cupsSNMPIsOID: Returning %d\n",
+  DEBUG_printf(("5_cupsSNMPIsOID: Returning %d",
                 i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]));
 
   return (i < CUPS_SNMP_MAX_OID && oid[i] == packet->object_name[i]);
@@ -263,12 +263,12 @@ _cupsSNMPIsOIDPrefixed(
   * Range check input...
   */
 
-  DEBUG_printf(("_cupsSNMPIsOIDPrefixed(packet=%p, prefix=%p)\n", packet,
+  DEBUG_printf(("4_cupsSNMPIsOIDPrefixed(packet=%p, prefix=%p)", packet,
                 prefix));
 
   if (!packet || !prefix)
   {
-    DEBUG_puts("_cupsSNMPIsOIDPrefixed: Returning 0");
+    DEBUG_puts("5_cupsSNMPIsOIDPrefixed: Returning 0");
 
     return (0);
   }
@@ -282,12 +282,12 @@ _cupsSNMPIsOIDPrefixed(
        i ++)
     if (prefix[i] != packet->object_name[i])
     {
-      DEBUG_puts("_cupsSNMPIsOIDPrefixed: Returning 0");
+      DEBUG_puts("5_cupsSNMPIsOIDPrefixed: Returning 0");
 
       return (0);
     }
 
-  DEBUG_printf(("_cupsSNMPIsOIDPrefixed: Returning %d\n",
+  DEBUG_printf(("5_cupsSNMPIsOIDPrefixed: Returning %d",
                 i < CUPS_SNMP_MAX_OID));
 
   return (i < CUPS_SNMP_MAX_OID);
@@ -308,7 +308,7 @@ _cupsSNMPOIDToString(const int *src,        /* I - OID */
        *dstend;                        /* End of string buffer */
 
 
-  DEBUG_printf(("_cupsSNMPOIDToString(src=%p, dst=%p, dstsize=" CUPS_LLFMT ")\n",
+  DEBUG_printf(("4_cupsSNMPOIDToString(src=%p, dst=%p, dstsize=" CUPS_LLFMT ")",
                 src, dst, CUPS_LLCAST dstsize));
 
  /*
@@ -349,11 +349,11 @@ _cupsSNMPOpen(int family)         /* I - Address family - @code AF_INET@ or @code AF_IN
   * Create the SNMP socket...
   */
 
-  DEBUG_printf(("_cupsSNMPOpen(family=%d)\n", family));
+  DEBUG_printf(("4_cupsSNMPOpen(family=%d)", family));
 
   if ((fd = socket(family, SOCK_DGRAM, 0)) < 0)
   {
-    DEBUG_printf(("_cupsSNMPOpen: Returning -1 (%s)\n", strerror(errno)));
+    DEBUG_printf(("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno)));
 
     return (-1);
   }
@@ -366,14 +366,14 @@ _cupsSNMPOpen(int family)         /* I - Address family - @code AF_INET@ or @code AF_IN
 
   if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val)))
   {
-    DEBUG_printf(("_cupsSNMPOpen: Returning -1 (%s)\n", strerror(errno)));
+    DEBUG_printf(("5_cupsSNMPOpen: Returning -1 (%s)", strerror(errno)));
 
     close(fd);
 
     return (-1);
   }
 
-  DEBUG_printf(("_cupsSNMPOpen: Returning %d\n", fd));
+  DEBUG_printf(("5_cupsSNMPOpen: Returning %d", fd));
 
   return (fd);
 }
@@ -402,12 +402,12 @@ _cupsSNMPRead(int         fd,             /* I - SNMP socket file descriptor */
   * Range check input...
   */
 
-  DEBUG_printf(("_cupsSNMPRead(fd=%d, packet=%p, timeout=%.1f)\n", fd, packet,
+  DEBUG_printf(("4_cupsSNMPRead(fd=%d, packet=%p, timeout=%.1f)", fd, packet,
                 timeout));
 
   if (fd < 0 || !packet)
   {
-    DEBUG_puts("_cupsSNMPRead: Returning NULL");
+    DEBUG_puts("5_cupsSNMPRead: Returning NULL");
 
     return (NULL);
   }
@@ -426,7 +426,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
     pfd.events = POLLIN;
 
     while ((ready = poll(&pfd, 1, (int)(timeout * 1000.0))) < 0 &&
-           errno == EINTR);
+           (errno == EINTR || errno == EAGAIN));
 
 #else
     fd_set             input_set;      /* select() input set */
@@ -445,7 +445,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
 #  ifdef WIN32
     while (ready < 0 && WSAGetLastError() == WSAEINTR);
 #  else
-    while (ready < 0 && errno == EINTR);
+    while (ready < 0 && (errno == EINTR || errno == EAGAIN));
 #  endif /* WIN32 */
 #endif /* HAVE_POLL */
 
@@ -455,7 +455,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
 
     if (ready <= 0)
     {
-      DEBUG_puts("_cupsSNMPRead: Returning NULL (timeout)");
+      DEBUG_puts("5_cupsSNMPRead: Returning NULL (timeout)");
 
       return (NULL);
     }
@@ -470,7 +470,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
   if ((bytes = recvfrom(fd, buffer, sizeof(buffer), 0, (void *)&address,
                         &addrlen)) < 0)
   {
-    DEBUG_printf(("_cupsSNMPRead: Returning NULL (%s)\n", strerror(errno)));
+    DEBUG_printf(("5_cupsSNMPRead: Returning NULL (%s)", strerror(errno)));
 
     return (NULL);
   }
@@ -489,7 +489,7 @@ _cupsSNMPRead(int         fd,               /* I - SNMP socket file descriptor */
   * Return decoded data packet...
   */
 
-  DEBUG_puts("_cupsSNMPRead: Returning packet");
+  DEBUG_puts("5_cupsSNMPRead: Returning packet");
 
   return (packet);
 }
@@ -505,7 +505,7 @@ _cupsSNMPSetDebug(int level)                /* I - 1 to enable debug output, 0 otherwise */
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
-  DEBUG_printf(("_cupsSNMPSetDebug(level=%d)\n", level));
+  DEBUG_printf(("4_cupsSNMPSetDebug(level=%d)", level));
 
   cg->snmp_debug = level;
 }
@@ -530,7 +530,7 @@ _cupsSNMPStringToOID(const char *src,       /* I - OID string */
        *dstend;                        /* End of OID array */
 
 
-  DEBUG_printf(("_cupsSNMPStringToOID(src=\"%s\", dst=%p, dstsize=%d)\n",
+  DEBUG_printf(("4_cupsSNMPStringToOID(src=\"%s\", dst=%p, dstsize=%d)",
                 src, dst, dstsize));
 
  /*
@@ -610,15 +610,14 @@ _cupsSNMPWalk(int            fd,  /* I - SNMP socket */
   * Range check input...
   */
 
-  DEBUG_printf(("_cupsSNMPWalk(fd=%d, address=%p, version=%d, "
-                "community=\"%s\", prefix=%p, timeout=%.1f, cb=%p, data=%p)\n",
-               fd, address, version, community ? community : "(null)",
-               prefix, timeout, cb, data));
+  DEBUG_printf(("4_cupsSNMPWalk(fd=%d, address=%p, version=%d, "
+                "community=\"%s\", prefix=%p, timeout=%.1f, cb=%p, data=%p)",
+               fd, address, version, community, prefix, timeout, cb, data));
 
   if (fd < 0 || !address || version != CUPS_SNMP_VERSION_1 || !community ||
       !prefix || !cb)
   {
-    DEBUG_puts("_cupsSNMPWalk: Returning -1");
+    DEBUG_puts("5_cupsSNMPWalk: Returning -1");
 
     return (-1);
   }
@@ -637,28 +636,28 @@ _cupsSNMPWalk(int            fd,  /* I - SNMP socket */
                        CUPS_ASN1_GET_NEXT_REQUEST, request_id,
                       packet.object_name))
     {
-      DEBUG_puts("_cupsSNMPWalk: Returning -1");
+      DEBUG_puts("5_cupsSNMPWalk: Returning -1");
 
       return (-1);
     }
 
     if (!_cupsSNMPRead(fd, &packet, timeout))
     {
-      DEBUG_puts("_cupsSNMPWalk: Returning -1");
+      DEBUG_puts("5_cupsSNMPWalk: Returning -1");
 
       return (-1);
     }
 
     if (!_cupsSNMPIsOIDPrefixed(&packet, prefix))
     {
-      DEBUG_printf(("_cupsSNMPWalk: Returning %d\n", count));
+      DEBUG_printf(("5_cupsSNMPWalk: Returning %d", count));
 
       return (count);
     }
 
     if (packet.error || packet.error_status)
     {
-      DEBUG_printf(("_cupsSNMPWalk: Returning %d\n", count > 0 ? count : -1));
+      DEBUG_printf(("5_cupsSNMPWalk: Returning %d", count > 0 ? count : -1));
 
       return (count > 0 ? count : -1);
     }
@@ -698,16 +697,15 @@ _cupsSNMPWrite(
   * Range check input...
   */
 
-  DEBUG_printf(("_cupsSNMPWrite(fd=%d, address=%p, version=%d, "
-                "community=\"%s\", request_type=%d, request_id=%u, oid=%p)\n",
-               fd, address, version, community ? community : "(null)",
-               request_type, request_id, oid));
+  DEBUG_printf(("4_cupsSNMPWrite(fd=%d, address=%p, version=%d, "
+                "community=\"%s\", request_type=%d, request_id=%u, oid=%p)",
+               fd, address, version, community, request_type, request_id, oid));
 
   if (fd < 0 || !address || version != CUPS_SNMP_VERSION_1 || !community ||
       (request_type != CUPS_ASN1_GET_REQUEST &&
        request_type != CUPS_ASN1_GET_NEXT_REQUEST) || request_id < 1 || !oid)
   {
-    DEBUG_puts("_cupsSNMPWrite: Returning 0 (bad arguments)");
+    DEBUG_puts("5_cupsSNMPWrite: Returning 0 (bad arguments)");
 
     return (0);
   }
@@ -731,7 +729,7 @@ _cupsSNMPWrite(
 
   if (oid[i] >= 0)
   {
-    DEBUG_puts("_cupsSNMPWrite: Returning 0 (OID too big)");
+    DEBUG_puts("5_cupsSNMPWrite: Returning 0 (OID too big)");
 
     errno = E2BIG;
     return (0);
@@ -741,7 +739,7 @@ _cupsSNMPWrite(
 
   if (bytes < 0)
   {
-    DEBUG_puts("_cupsSNMPWrite: Returning 0 (request too big)");
+    DEBUG_puts("5_cupsSNMPWrite: Returning 0 (request too big)");
 
     errno = E2BIG;
     return (0);
index 9b185f9cbb765f89a4a3830271f4b4ae64ee5fba..2d93eb8f301924dc0178398c96966063e6c85680 100644 (file)
@@ -119,8 +119,8 @@ _cupsStrAlloc(const char *s)                /* I - String */
     item->ref_count ++;
 
 #ifdef DEBUG_GUARDS
-    DEBUG_printf(("_cupsStrAlloc: Using string %p(%s) for \"%s\", guard=%08x, "
-                  "ref_count=%d\n", item, item->str, s, item->guard,
+    DEBUG_printf(("5_cupsStrAlloc: Using string %p(%s) for \"%s\", guard=%08x, "
+                  "ref_count=%d", item, item->str, s, item->guard,
                  item->ref_count));
 
     if (item->guard != _CUPS_STR_GUARD)
@@ -154,8 +154,8 @@ _cupsStrAlloc(const char *s)                /* I - String */
 #ifdef DEBUG_GUARDS
   item->guard = _CUPS_STR_GUARD;
 
-  DEBUG_printf(("_cupsStrAlloc: Created string %p(%s) for \"%s\", guard=%08x, "
-               "ref_count=%d\n", item, item->str, s, item->guard,
+  DEBUG_printf(("5_cupsStrAlloc: Created string %p(%s) for \"%s\", guard=%08x, "
+               "ref_count=%d", item, item->str, s, item->guard,
                item->ref_count));
 #endif /* DEBUG_GUARDS */
 
@@ -183,7 +183,7 @@ _cupsStrFlush(void)
   _cups_sp_item_t      *item;          /* Current item */
 
 
-  DEBUG_printf(("_cupsStrFlush: %d strings in array\n",
+  DEBUG_printf(("4_cupsStrFlush: %d strings in array",
                 cupsArrayCount(stringpool)));
 
 #ifdef HAVE_PTHREAD_H
@@ -326,8 +326,8 @@ _cupsStrFree(const char *s)         /* I - String to free */
 #ifdef DEBUG_GUARDS
   if (key->guard != _CUPS_STR_GUARD)
   {
-    DEBUG_printf(("_cupsStrFree: Freeing string %p(%s), guard=%08x, "
-                  "ref_count=%d\n", key, key->str, key->guard, key->ref_count));
+    DEBUG_printf(("5_cupsStrFree: Freeing string %p(%s), guard=%08x, "
+                  "ref_count=%d", key, key->str, key->guard, key->ref_count));
     abort();
   }
 #endif /* DEBUG_GUARDS */
@@ -368,7 +368,7 @@ _cupsStrFree(const char *s)         /* I - String to free */
  */
 
 char *                                 /* O - Pointer to string */
-_cupsStrRetain(char *s)                        /* I - String to retain */
+_cupsStrRetain(const char *s)          /* I - String to retain */
 {
   _cups_sp_item_t      *item;          /* Pointer to string pool item */
 
@@ -380,8 +380,8 @@ _cupsStrRetain(char *s)                     /* I - String to retain */
 #ifdef DEBUG_GUARDS
     if (item->guard != _CUPS_STR_GUARD)
     {
-      DEBUG_printf(("_cupsStrRetain: Retaining string %p(%s), guard=%08x, "
-                    "ref_count=%d\n", item, s, item->guard, item->ref_count));
+      DEBUG_printf(("5_cupsStrRetain: Retaining string %p(%s), guard=%08x, "
+                    "ref_count=%d", item, s, item->guard, item->ref_count));
       abort();
     }
 #endif /* DEBUG_GUARDS */
@@ -397,7 +397,7 @@ _cupsStrRetain(char *s)                     /* I - String to retain */
 #endif /* HAVE_PTHREAD_H */
   }
 
-  return (s);
+  return ((char *)s);
 }
 
 
index 99e3d5855e7db562671c3cd66d817a3664aed9cc..ac236a2b99ffcf2692acd792bc6a3a3eed36e0b4 100644 (file)
@@ -130,7 +130,7 @@ extern int  _cups_vsnprintf(char *, size_t, const char *, va_list);
 extern char    *_cupsStrAlloc(const char *s);
 extern void    _cupsStrFlush(void);
 extern void    _cupsStrFree(const char *s);
-extern char    *_cupsStrRetain(char *s);
+extern char    *_cupsStrRetain(const char *s);
 extern size_t  _cupsStrStatistics(size_t *alloc_bytes, size_t *total_bytes);
 
 
index 064ec892f468d2a963bf1fe6c0dfeb11eba2c67f..52aedff509e891bc80312dafd6f46b8fa1c4d741 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Array test program for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -114,14 +114,6 @@ main(int  argc,                            /* I - Number of command-line arguments */
   }
   else
   {
-#ifdef DEBUG
-    putchar('\n');
-    for (text = (char *)cupsArrayFirst(array), i = 0;
-         text;
-        text = (char *)cupsArrayNext(array), i ++)
-      printf("    #1  array[%d]=\"%s\"\n", i, text);
-#endif /* DEBUG */
-
     if (!cupsArrayAdd(array, strdup("Two Fish")))
     {
       puts("FAIL (\"Two Fish\")");
@@ -129,13 +121,6 @@ main(int  argc,                            /* I - Number of command-line arguments */
     }
     else
     {
-#ifdef DEBUG
-      for (text = (char *)cupsArrayFirst(array), i = 0;
-           text;
-          text = (char *)cupsArrayNext(array), i ++)
-       printf("    #2  array[%d]=\"%s\"\n", i, text);
-#endif /* DEBUG */
-
       if (!cupsArrayAdd(array, strdup("Red Fish")))
       {
        puts("FAIL (\"Red Fish\")");
@@ -143,29 +128,13 @@ main(int  argc,                           /* I - Number of command-line arguments */
       }
       else
       {
-#ifdef DEBUG
-       for (text = (char *)cupsArrayFirst(array), i = 0;
-             text;
-            text = (char *)cupsArrayNext(array), i ++)
-         printf("    #3  array[%d]=\"%s\"\n", i, text);
-#endif /* DEBUG */
-
         if (!cupsArrayAdd(array, strdup("Blue Fish")))
        {
          puts("FAIL (\"Blue Fish\")");
          status ++;
        }
        else
-       {
-#ifdef DEBUG
-         for (text = (char *)cupsArrayFirst(array), i = 0;
-               text;
-              text = (char *)cupsArrayNext(array), i ++)
-           printf("    #4  array[%d]=\"%s\"\n", i, text);
-#endif /* DEBUG */
-
          puts("PASS");
-       }
       }
     }
   }
@@ -491,8 +460,6 @@ load_words(const char   *filename,  /* I - File to load */
   char         word[256];              /* Word from file */
 
 
-  DEBUG_printf(("    Loading \"%s\"...\n", filename));
-
   if ((fp = fopen(filename, "r")) == NULL)
   {
     perror(filename);
@@ -502,11 +469,7 @@ load_words(const char   *filename, /* I - File to load */
   while (fscanf(fp, "%255s", word) == 1)
   {
     if (!cupsArrayFind(array, word))
-    {
-      DEBUG_printf(("    Adding \"%s\"...\n", word));
-
       cupsArrayAdd(array, strdup(word));
-    }
   }
 
   fclose(fp);
index c04f0a71d03cdce46598f240a6e38dc49244b032..afeb2de4ab0894ef302bd0b47e774661dbbd5967 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Transcoding support for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -210,7 +210,7 @@ _cupsCharmapGet(
   void *charmap;                       /* Charset map pointer */
 
 
-  DEBUG_printf(("_cupsCharmapGet(encoding=%d)\n", encoding));
+  DEBUG_printf(("7_cupsCharmapGet(encoding=%d)", encoding));
 
  /*
   * Check for valid arguments...
@@ -218,7 +218,7 @@ _cupsCharmapGet(
 
   if (encoding < 0 || encoding >= CUPS_ENCODING_VBCS_END)
   {
-    DEBUG_puts("    Bad encoding, returning NULL!");
+    DEBUG_puts("8_cupsCharmapGet: Bad encoding, returning NULL!");
     return (NULL);
   }
 
@@ -263,7 +263,7 @@ cupsCharsetToUTF8(
   * Check for valid arguments...
   */
 
-  DEBUG_printf(("cupsCharsetToUTF8(dest=%p, src=\"%s\", maxout=%d, encoding=%d)\n",
+  DEBUG_printf(("cupsCharsetToUTF8(dest=%p, src=\"%s\", maxout=%d, encoding=%d)",
                dest, src, maxout, encoding));
 
   if (dest)
@@ -271,7 +271,7 @@ cupsCharsetToUTF8(
 
   if (!dest || !src || maxout < 1 || maxout > CUPS_MAX_USTRING)
   {
-    DEBUG_puts("    Bad arguments, returning -1");
+    DEBUG_puts("1cupsCharsetToUTF8: Bad arguments, returning -1");
     return (-1);
   }
 
@@ -473,15 +473,15 @@ cupsUTF8ToUTF32(
   * Check for valid arguments and clear output...
   */
 
-  DEBUG_printf(("cupsUTF8ToUTF32(dest=%p, src=\"%s\", maxout=%d)\n", dest,
-                src ? (const char *)src : "(null)", maxout));
+  DEBUG_printf(("2cupsUTF8ToUTF32(dest=%p, src=\"%s\", maxout=%d)", dest,
+                src, maxout));
 
   if (dest)
     *dest = 0;
 
   if (!dest || !src || maxout < 1 || maxout > CUPS_MAX_USTRING)
   {
-    DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad arguments)");
+    DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad arguments)");
 
     return (-1);
   }
@@ -506,7 +506,7 @@ cupsUTF8ToUTF32(
 
       *dest++ = ch;
 
-      DEBUG_printf(("cupsUTF8ToUTF32: %02x => %08X\n", src[-1], ch));
+      DEBUG_printf(("4cupsUTF8ToUTF32: %02x => %08X", src[-1], ch));
       continue;
     }
     else if ((ch & 0xe0) == 0xc0)
@@ -518,7 +518,7 @@ cupsUTF8ToUTF32(
       next = *src++;
       if ((next & 0xc0) != 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
@@ -531,14 +531,14 @@ cupsUTF8ToUTF32(
 
       if (ch32 < 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
 
       *dest++ = ch32;
 
-      DEBUG_printf(("cupsUTF8ToUTF32: %02x %02x => %08X\n",
+      DEBUG_printf(("4cupsUTF8ToUTF32: %02x %02x => %08X",
                     src[-2], src[-1], (unsigned)ch32));
     }
     else if ((ch & 0xf0) == 0xe0)
@@ -550,7 +550,7 @@ cupsUTF8ToUTF32(
       next = *src++;
       if ((next & 0xc0) != 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
@@ -560,7 +560,7 @@ cupsUTF8ToUTF32(
       next = *src++;
       if ((next & 0xc0) != 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
@@ -573,14 +573,14 @@ cupsUTF8ToUTF32(
 
       if (ch32 < 0x800)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
 
       *dest++ = ch32;
 
-      DEBUG_printf(("cupsUTF8ToUTF32: %02x %02x %02x => %08X\n",
+      DEBUG_printf(("4cupsUTF8ToUTF32: %02x %02x %02x => %08X",
                     src[-3], src[-2], src[-1], (unsigned)ch32));
     }
     else if ((ch & 0xf8) == 0xf0)
@@ -592,7 +592,7 @@ cupsUTF8ToUTF32(
       next = *src++;
       if ((next & 0xc0) != 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
@@ -602,7 +602,7 @@ cupsUTF8ToUTF32(
       next = *src++;
       if ((next & 0xc0) != 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
@@ -612,7 +612,7 @@ cupsUTF8ToUTF32(
       next = *src++;
       if ((next & 0xc0) != 0x80)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
@@ -625,14 +625,14 @@ cupsUTF8ToUTF32(
 
       if (ch32 < 0x10000)
       {
-        DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+        DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
        return (-1);
       }
 
       *dest++ = ch32;
 
-      DEBUG_printf(("cupsUTF8ToUTF32: %02x %02x %02x %02x => %08X\n",
+      DEBUG_printf(("4cupsUTF8ToUTF32: %02x %02x %02x %02x => %08X",
                     src[-4], src[-3], src[-2], src[-1], (unsigned)ch32));
     }
     else
@@ -641,7 +641,7 @@ cupsUTF8ToUTF32(
       * More than 4-octet (invalid UTF-8 sequence)...
       */
 
-      DEBUG_puts("cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
+      DEBUG_puts("3cupsUTF8ToUTF32: Returning -1 (bad UTF-8 sequence)");
 
       return (-1);
     }
@@ -656,7 +656,7 @@ cupsUTF8ToUTF32(
 
   *dest = 0;
 
-  DEBUG_printf(("cupsUTF8ToUTF32: Returning %d characters\n", maxout - 1 - i));
+  DEBUG_printf(("3cupsUTF8ToUTF32: Returning %d characters", maxout - 1 - i));
 
   return (maxout - 1 - i);
 }
@@ -694,7 +694,7 @@ cupsUTF32ToUTF8(
   * Check for valid arguments and clear output...
   */
 
-  DEBUG_printf(("cupsUTF32ToUTF8(dest=%p, src=%p, maxout=%d)\n", dest, src,
+  DEBUG_printf(("2cupsUTF32ToUTF8(dest=%p, src=%p, maxout=%d)", dest, src,
                 maxout));
 
   if (dest)
@@ -702,7 +702,7 @@ cupsUTF32ToUTF8(
 
   if (!dest || !src || maxout < 1)
   {
-    DEBUG_puts("cupsUTF32ToUTF8: Returning -1 (bad args)");
+    DEBUG_puts("3cupsUTF32ToUTF8: Returning -1 (bad args)");
 
     return (-1);
   }
@@ -714,7 +714,7 @@ cupsUTF32ToUTF8(
   start = dest;
   swap  = *src == 0xfffe0000;
 
-  DEBUG_printf(("cupsUTF32ToUTF8: swap=%d\n", swap));
+  DEBUG_printf(("4cupsUTF32ToUTF8: swap=%d", swap));
 
   if (*src == 0xfffe0000 || *src == 0xfeff)
     src ++;
@@ -741,7 +741,7 @@ cupsUTF32ToUTF8(
 
     if (ch > 0x10ffff)
     {
-      DEBUG_puts("cupsUTF32ToUTF8: Returning -1 (character out of range)");
+      DEBUG_puts("3cupsUTF32ToUTF8: Returning -1 (character out of range)");
 
       return (-1);
     }
@@ -759,7 +759,7 @@ cupsUTF32ToUTF8(
       *dest++ = (cups_utf8_t)ch;
       i --;
 
-      DEBUG_printf(("cupsUTF32ToUTF8: %08x => %02x\n", (unsigned)ch, dest[-1]));
+      DEBUG_printf(("4cupsUTF32ToUTF8: %08x => %02x", (unsigned)ch, dest[-1]));
     }
     else if (ch < 0x800)
     {
@@ -769,7 +769,7 @@ cupsUTF32ToUTF8(
 
       if (i < 2)
       {
-        DEBUG_puts("cupsUTF32ToUTF8: Returning -1 (too long 2)");
+        DEBUG_puts("3cupsUTF32ToUTF8: Returning -1 (too long 2)");
 
         return (-1);
       }
@@ -778,7 +778,7 @@ cupsUTF32ToUTF8(
       *dest++ = (cups_utf8_t)(0x80 | (ch & 0x3f));
       i -= 2;
 
-      DEBUG_printf(("cupsUTF32ToUTF8: %08x => %02x %02x\n", (unsigned)ch,
+      DEBUG_printf(("4cupsUTF32ToUTF8: %08x => %02x %02x", (unsigned)ch,
                     dest[-2], dest[-1]));
     }
     else if (ch < 0x10000)
@@ -789,7 +789,7 @@ cupsUTF32ToUTF8(
 
       if (i < 3)
       {
-        DEBUG_puts("cupsUTF32ToUTF8: Returning -1 (too long 3)");
+        DEBUG_puts("3cupsUTF32ToUTF8: Returning -1 (too long 3)");
 
         return (-1);
       }
@@ -799,7 +799,7 @@ cupsUTF32ToUTF8(
       *dest++ = (cups_utf8_t)(0x80 | (ch & 0x3f));
       i -= 3;
 
-      DEBUG_printf(("cupsUTF32ToUTF8: %08x => %02x %02x %02x\n", (unsigned)ch,
+      DEBUG_printf(("4cupsUTF32ToUTF8: %08x => %02x %02x %02x", (unsigned)ch,
                     dest[-3], dest[-2], dest[-1]));
     }
     else
@@ -809,7 +809,11 @@ cupsUTF32ToUTF8(
       */
 
       if (i < 4)
+      {
+        DEBUG_puts("3cupsUTF32ToUTF8: Returning -1 (too long 4)");
+
         return (-1);
+      }
 
       *dest++ = (cups_utf8_t)(0xf0 | ((ch >> 18) & 0x07));
       *dest++ = (cups_utf8_t)(0x80 | ((ch >> 12) & 0x3f));
@@ -817,14 +821,14 @@ cupsUTF32ToUTF8(
       *dest++ = (cups_utf8_t)(0x80 | (ch & 0x3f));
       i -= 4;
 
-      DEBUG_printf(("cupsUTF32ToUTF8: %08x => %02x %02x %02x %02x\n",
+      DEBUG_printf(("4cupsUTF32ToUTF8: %08x => %02x %02x %02x %02x",
                     (unsigned)ch, dest[-4], dest[-3], dest[-2], dest[-1]));
     }
   }
 
   *dest = '\0';
 
-  DEBUG_printf(("cupsUTF32ToUTF8: Returning %d\n", (int)(dest - start)));
+  DEBUG_printf(("3cupsUTF32ToUTF8: Returning %d", (int)(dest - start)));
 
   return ((int)(dest - start));
 }
@@ -1012,8 +1016,8 @@ conv_utf8_to_vbcs(
                *workptr;               /* Pointer into string */
 
 
-  DEBUG_printf(("conv_utf8_to_vbcs(dest=%p, src=\"%s\", maxout=%d, "
-                "encoding=%d)\n", dest, src, maxout, encoding));
+  DEBUG_printf(("7conv_utf8_to_vbcs(dest=%p, src=\"%s\", maxout=%d, "
+                "encoding=%d)", dest, src, maxout, encoding));
 
  /*
   * Find legacy charset map in cache...
@@ -1021,7 +1025,7 @@ conv_utf8_to_vbcs(
 
   if ((vmap = (_cups_vmap_t *)get_charmap(encoding)) == NULL)
   {
-    DEBUG_puts("conv_utf8_to_vbcs: Returning -1 (no charmap)");
+    DEBUG_puts("8conv_utf8_to_vbcs: Returning -1 (no charmap)");
 
     return (-1);
   }
@@ -1032,7 +1036,7 @@ conv_utf8_to_vbcs(
 
   if (cupsUTF8ToUTF32(work, src, CUPS_MAX_USTRING) < 0)
   {
-    DEBUG_puts("conv_utf8_to_vbcs: Returning -1 (Unable to convert to UTF-32)");
+    DEBUG_puts("8conv_utf8_to_vbcs: Returning -1 (Unable to convert to UTF-32)");
 
     return (-1);
   }
@@ -1053,7 +1057,7 @@ conv_utf8_to_vbcs(
     {
       *dest++ = (cups_sbcs_t)unichar;
 
-      DEBUG_printf(("conv_utf8_to_vbcs: %08x => %02X\n", (unsigned)unichar,
+      DEBUG_printf(("9conv_utf8_to_vbcs: %08x => %02X", (unsigned)unichar,
                     dest[-1]));
 
       continue;
@@ -1081,7 +1085,7 @@ conv_utf8_to_vbcs(
     {
       if (maxout < 5)
       {
-        DEBUG_puts("conv_utf8_to_vbcs: Returning -1 (out of space)");
+        DEBUG_puts("8conv_utf8_to_vbcs: Returning -1 (out of space)");
 
         return (-1);
       }
@@ -1093,14 +1097,14 @@ conv_utf8_to_vbcs(
 
       maxout -= 3;
 
-      DEBUG_printf(("conv_utf8_to_vbcs: %08x => %02X %02X %02X %02X\n",
+      DEBUG_printf(("9conv_utf8_to_vbcs: %08x => %02X %02X %02X %02X",
                     (unsigned)unichar, dest[-4], dest[-3], dest[-2], dest[-1]));
     }
     else if (legchar > 0xffff)
     {
       if (maxout < 4)
       {
-        DEBUG_puts("conv_utf8_to_vbcs: Returning -1 (out of space)");
+        DEBUG_puts("8conv_utf8_to_vbcs: Returning -1 (out of space)");
 
         return (-1);
       }
@@ -1111,7 +1115,7 @@ conv_utf8_to_vbcs(
 
       maxout -= 2;
 
-      DEBUG_printf(("conv_utf8_to_vbcs: %08x => %02X %02X %02X\n",
+      DEBUG_printf(("9conv_utf8_to_vbcs: %08x => %02X %02X %02X",
                     (unsigned)unichar, dest[-3], dest[-2], dest[-1]));
     }
     else if (legchar > 0xff)
@@ -1121,14 +1125,14 @@ conv_utf8_to_vbcs(
 
       maxout --;
 
-      DEBUG_printf(("conv_utf8_to_vbcs: %08x => %02X %02X\n",
+      DEBUG_printf(("9conv_utf8_to_vbcs: %08x => %02X %02X",
                     (unsigned)unichar, dest[-2], dest[-1]));
     }
     else
     {
       *dest++ = legchar;
 
-      DEBUG_printf(("conv_utf8_to_vbcs: %08x => %02X\n",
+      DEBUG_printf(("9conv_utf8_to_vbcs: %08x => %02X",
                     (unsigned)unichar, dest[-1]));
     }
   }
@@ -1137,7 +1141,7 @@ conv_utf8_to_vbcs(
 
   vmap->used --;
 
-  DEBUG_printf(("conv_utf8_to_vbcs: Returning %d characters\n",
+  DEBUG_printf(("8conv_utf8_to_vbcs: Returning %d characters",
                 (int)(dest - start)));
 
   return ((int)(dest - start));
@@ -1168,12 +1172,12 @@ conv_vbcs_to_utf8(
   * Find legacy charset map in cache...
   */
 
-  DEBUG_printf(("conv_vbcs_to_utf8(dest=%p, src=%p, maxout=%d, encoding=%d)\n",
+  DEBUG_printf(("7conv_vbcs_to_utf8(dest=%p, src=%p, maxout=%d, encoding=%d)",
                 dest, src, maxout, encoding));
 
   if ((vmap = (_cups_vmap_t *)get_charmap(encoding)) == NULL)
   {
-    DEBUG_puts("conv_vbcs_to_utf8: Returning -1 (NULL vmap)");
+    DEBUG_puts("8conv_vbcs_to_utf8: Returning -1 (NULL vmap)");
 
     return (-1);
   }
@@ -1196,7 +1200,7 @@ conv_vbcs_to_utf8(
     {
       *workptr++ = (cups_utf32_t)legchar;
 
-      DEBUG_printf(("conv_vbcs_to_utf8: %02X => %08X\n", src[-1],
+      DEBUG_printf(("9conv_vbcs_to_utf8: %02X => %08X", src[-1],
                     (unsigned)legchar));
       continue;
     }
@@ -1209,7 +1213,7 @@ conv_vbcs_to_utf8(
     {
       if (!*src)
       {
-        DEBUG_puts("conv_vbcs_to_utf8: Returning -1 (short string)");
+        DEBUG_puts("8conv_vbcs_to_utf8: Returning -1 (short string)");
 
        return (-1);
       }
@@ -1229,7 +1233,7 @@ conv_vbcs_to_utf8(
       else
        *workptr++ = (cups_utf32_t)*crow;
 
-      DEBUG_printf(("conv_vbcs_to_utf8: %02X %02X => %08X\n",
+      DEBUG_printf(("9conv_vbcs_to_utf8: %02X %02X => %08X",
                     src[-2], src[-1], (unsigned)workptr[-1]));
       continue;
     }
@@ -1242,7 +1246,7 @@ conv_vbcs_to_utf8(
     {
       if (!*src || !src[1])
       {
-        DEBUG_puts("conv_vbcs_to_utf8: Returning -1 (short string 2)");
+        DEBUG_puts("8conv_vbcs_to_utf8: Returning -1 (short string 2)");
 
        return (-1);
       }
@@ -1254,7 +1258,7 @@ conv_vbcs_to_utf8(
     {
       if (!*src || !src[1] || !src[2])
       {
-        DEBUG_puts("conv_vbcs_to_utf8: Returning -1 (short string 3)");
+        DEBUG_puts("8conv_vbcs_to_utf8: Returning -1 (short string 3)");
 
        return (-1);
       }
@@ -1265,7 +1269,7 @@ conv_vbcs_to_utf8(
     }
     else
     {
-      DEBUG_puts("conv_vbcs_to_utf8: Returning -1 (bad character)");
+      DEBUG_puts("8conv_vbcs_to_utf8: Returning -1 (bad character)");
 
       return (-1);
     }
@@ -1290,10 +1294,10 @@ conv_vbcs_to_utf8(
       *workptr++ = wide2uni->unichar;
 
     if (vmap->lead3char[(int)leadchar] == leadchar)
-      DEBUG_printf(("conv_vbcs_to_utf8: %02X %02X %02X => %08X\n",
+      DEBUG_printf(("9conv_vbcs_to_utf8: %02X %02X %02X => %08X",
                    src[-3], src[-2], src[-1], (unsigned)workptr[-1]));
     else
-      DEBUG_printf(("conv_vbcs_to_utf8: %02X %02X %02X %02X => %08X\n",
+      DEBUG_printf(("9conv_vbcs_to_utf8: %02X %02X %02X %02X => %08X",
                    src[-4], src[-3], src[-2], src[-1], (unsigned)workptr[-1]));
   }
 
@@ -1301,7 +1305,7 @@ conv_vbcs_to_utf8(
 
   vmap->used --;
 
-  DEBUG_printf(("conv_vbcs_to_utf8: Converting %d UTF-32 characters to UTF-8\n",
+  DEBUG_printf(("9conv_vbcs_to_utf8: Converting %d UTF-32 characters to UTF-8",
                 (int)(workptr - work)));
 
  /*
@@ -1373,7 +1377,7 @@ get_charmap(
   _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 
 
-  DEBUG_printf(("get_charmap(encoding=%d)\n", encoding));
+  DEBUG_printf(("7get_charmap(encoding=%d)", encoding));
 
  /*
   * Get the data directory and charset map name...
@@ -1382,7 +1386,7 @@ get_charmap(
   snprintf(filename, sizeof(filename), "%s/charmaps/%s.txt",
           cg->cups_datadir, _cupsEncodingName(encoding));
 
-  DEBUG_printf(("get_charmap: filename=\"%s\"\n", filename));
+  DEBUG_printf(("9get_charmap: filename=\"%s\"", filename));
 
  /*
   * Read charset map input file into cache...
@@ -1452,7 +1456,7 @@ get_sbcs_charmap(
   * See if we already have this SBCS charset map loaded...
   */
 
-  DEBUG_printf(("get_sbcs_charmap(encoding=%d, filename=\"%s\")\n", encoding,
+  DEBUG_printf(("7get_sbcs_charmap(encoding=%d, filename=\"%s\")", encoding,
                 filename));
 
   for (cmap = cmap_cache; cmap; cmap = cmap->next)
@@ -1460,7 +1464,7 @@ get_sbcs_charmap(
     if (cmap->encoding == encoding)
     {
       cmap->used ++;
-      DEBUG_printf(("get_sbcs_charmap: Returning existing cmap=%p\n", cmap));
+      DEBUG_printf(("8get_sbcs_charmap: Returning existing cmap=%p", cmap));
 
       return ((void *)cmap);
     }
@@ -1472,7 +1476,7 @@ get_sbcs_charmap(
 
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("get_sbcs_charmap: Returning NULL (%s)\n", strerror(errno)));
+    DEBUG_printf(("8get_sbcs_charmap: Returning NULL (%s)", strerror(errno)));
 
     return (NULL);
   }
@@ -1484,7 +1488,7 @@ get_sbcs_charmap(
   if ((cmap = (_cups_cmap_t *)calloc(1, sizeof(_cups_cmap_t))) == NULL)
   {
     cupsFileClose(fp);
-    DEBUG_puts("get_sbcs_charmap: Returning NULL (Unable to allocate memory)");
+    DEBUG_puts("8get_sbcs_charmap: Returning NULL (Unable to allocate memory)");
 
     return (NULL);
   }
@@ -1556,7 +1560,7 @@ get_sbcs_charmap(
   cmap->next = cmap_cache;
   cmap_cache = cmap;
 
-  DEBUG_printf(("get_sbcs_charmap: Returning new cmap=%p\n", cmap));
+  DEBUG_printf(("8get_sbcs_charmap: Returning new cmap=%p", cmap));
 
   return (cmap);
 
@@ -1570,7 +1574,7 @@ get_sbcs_charmap(
 
   cupsFileClose(fp);
 
-  DEBUG_puts("get_sbcs_charmap: Returning NULL (Read/format error)");
+  DEBUG_puts("8get_sbcs_charmap: Returning NULL (Read/format error)");
 
   return (NULL);
 }
@@ -1600,7 +1604,7 @@ get_vbcs_charmap(
   int          legacy;                 /* 32-bit legacy char */
 
 
-  DEBUG_printf(("get_vbcs_charmap(encoding=%d, filename=\"%s\")\n",
+  DEBUG_printf(("7get_vbcs_charmap(encoding=%d, filename=\"%s\")\n",
                 encoding, filename));
 
  /*
@@ -1612,7 +1616,7 @@ get_vbcs_charmap(
     if (vmap->encoding == encoding)
     {
       vmap->used ++;
-      DEBUG_printf(("get_vbcs_charmap: Returning existing vmap=%p\n", vmap));
+      DEBUG_printf(("8get_vbcs_charmap: Returning existing vmap=%p", vmap));
 
       return ((void *)vmap);
     }
@@ -1624,7 +1628,7 @@ get_vbcs_charmap(
 
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
   {
-    DEBUG_printf(("get_vbcs_charmap: Returning NULL (%s)\n", strerror(errno)));
+    DEBUG_printf(("8get_vbcs_charmap: Returning NULL (%s)", strerror(errno)));
 
     return (NULL);
   }
@@ -1635,14 +1639,14 @@ get_vbcs_charmap(
 
   if ((mapcount = get_charmap_count(fp)) <= 0)
   {
-    DEBUG_puts("get_vbcs_charmap: Unable to get charmap count!");
+    DEBUG_puts("8get_vbcs_charmap: Unable to get charmap count!");
 
     cupsFileClose(fp);
 
     return (NULL);
   }
 
-  DEBUG_printf(("get_vbcs_charmap: mapcount=%d\n", mapcount));
+  DEBUG_printf(("8get_vbcs_charmap: mapcount=%d", mapcount));
 
  /*
   * Allocate memory for DBCS/VBCS charset map...
@@ -1650,7 +1654,7 @@ get_vbcs_charmap(
 
   if ((vmap = (_cups_vmap_t *)calloc(1, sizeof(_cups_vmap_t))) == NULL)
   {
-    DEBUG_puts("get_vbcs_charmap: Unable to allocate memory!");
+    DEBUG_puts("8get_vbcs_charmap: Unable to allocate memory!");
 
     cupsFileClose(fp);
 
@@ -1686,8 +1690,8 @@ get_vbcs_charmap(
 
     i ++;
 
-/*    DEBUG_printf(("    i=%d, legchar=0x%08lx, unichar=0x%04x\n", i,
-                  legchar, (unsigned)unichar)); */
+    DEBUG_printf(("9get_vbcs_charmap: i=%d, legchar=0x%08lx, unichar=0x%04x", i,
+                  legchar, (unsigned)unichar));
 
    /*
     * Save lead char of 2/3/4-byte legacy char...
@@ -1796,7 +1800,7 @@ get_vbcs_charmap(
   vmap->next = vmap_cache;
   vmap_cache = vmap;
 
-  DEBUG_printf(("get_vbcs_charmap: Returning new vmap=%p\n", vmap));
+  DEBUG_printf(("8get_vbcs_charmap: Returning new vmap=%p", vmap));
 
   return (vmap);
 
@@ -1810,7 +1814,7 @@ get_vbcs_charmap(
 
   cupsFileClose(fp);
 
-  DEBUG_puts("get_vbcs_charmap: Returning NULL (Read/format error)");
+  DEBUG_puts("8get_vbcs_charmap: Returning NULL (Read/format error)");
 
   return (NULL);
 }
index 8e4be955992cf682c97220a3b5050b140027968d..1ec589da95a9d30d69c746fb32a8879363fd85b0 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * "$Id: usersys.c 7337 2008-02-22 04:44:04Z mike $"
+ * "$Id: usersys.c 8498 2009-04-13 17:03:15Z mike $"
  *
  *   User, system, and password routines for the Common UNIX Printing
  *   System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  *
  *   cupsEncryption()        - Get the default encryption settings.
  *   cupsGetPassword()       - Get a password from the user.
- *   cupsServer()            - Return the hostname of the default server.
+ *   cupsServer()            - Return the hostname/address of the default
+ *                             server.
  *   cupsSetEncryption()     - Set the encryption preference.
  *   cupsSetPasswordCB()     - Set the password callback for CUPS.
  *   cupsSetServer()         - Set the default server name.
  *   cupsSetUser()           - Set the default user name.
- *   cupsUser()              - Return the current users name.
+ *   cupsUser()              - Return the current user's name.
  *   _cupsGetPassword()      - Get a password from the user.
- *   cups_open_client_conf() - Open the client.conf file.
+ *   _cupsSetDefaults()      - Set the default server, port, and encryption.
+ *   cups_read_client_conf() - Read a client.conf file.
  */
 
 /*
  * Local functions...
  */
 
-static cups_file_t     *cups_open_client_conf(void);
+static void    cups_read_client_conf(cups_file_t *fp,
+                                     _cups_globals_t *cg,
+                                     const char *cups_encryption,
+                                     const char *cups_server);
 
 
 /*
@@ -62,69 +67,11 @@ static cups_file_t  *cups_open_client_conf(void);
 http_encryption_t                      /* O - Encryption settings */
 cupsEncryption(void)
 {
-  cups_file_t  *fp;                    /* client.conf file */
-  char         *encryption;            /* CUPS_ENCRYPTION variable */
-  char         line[1024],             /* Line from file */
-               *value;                 /* Value on line */
-  int          linenum;                /* Line number */
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
- /*
-  * First see if we have already set the encryption stuff...
-  */
-
   if (cg->encryption == (http_encryption_t)-1)
-  {
-   /*
-    * Then see if the CUPS_ENCRYPTION environment variable is set...
-    */
-
-    if ((encryption = getenv("CUPS_ENCRYPTION")) == NULL)
-    {
-     /*
-      * No, open the client.conf file...
-      */
-
-      fp         = cups_open_client_conf();
-      encryption = "IfRequested";
-
-      if (fp)
-      {
-       /*
-       * Read the config file and look for an Encryption line...
-       */
-
-        linenum = 0;
-
-       while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum) != NULL)
-         if (!strcasecmp(line, "Encryption") && value)
-         {
-          /*
-           * Got it!
-           */
-
-           encryption = value;
-           break;
-         }
-
-       cupsFileClose(fp);
-      }
-    }
-
-   /*
-    * Set the encryption preference...
-    */
-
-    if (!strcasecmp(encryption, "never"))
-      cg->encryption = HTTP_ENCRYPT_NEVER;
-    else if (!strcasecmp(encryption, "always"))
-      cg->encryption = HTTP_ENCRYPT_ALWAYS;
-    else if (!strcasecmp(encryption, "required"))
-      cg->encryption = HTTP_ENCRYPT_REQUIRED;
-    else
-      cg->encryption = HTTP_ENCRYPT_IF_REQUESTED;
-  }
+    _cupsSetDefaults();
 
   return (cg->encryption);
 }
@@ -144,23 +91,6 @@ cupsGetPassword(const char *prompt) /* I - Prompt string */
 }
 
 
-/*
- * 'cupsSetEncryption()' - Set the encryption preference.
- */
-
-void
-cupsSetEncryption(http_encryption_t e) /* I - New encryption preference */
-{
-  _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
-
-
-  cg->encryption = e;
-
-  if (cg->http)
-    httpEncryption(cg->http, e);
-}
-
-
 /*
  * 'cupsServer()' - Return the hostname/address of the default server.
  *
@@ -171,101 +101,30 @@ cupsSetEncryption(http_encryption_t e)   /* I - New encryption preference */
 const char *                           /* O - Server name */
 cupsServer(void)
 {
-  cups_file_t  *fp;                    /* client.conf file */
-  char         *server;                /* Pointer to server name */
-  char         *port;                  /* Port number */
-  char         line[1024],             /* Line from file */
-               *value;                 /* Value on line */
-  int          linenum;                /* Line number in file */
-#ifdef CUPS_DEFAULT_DOMAINSOCKET
-  struct stat  sockinfo;               /* Domain socket information */
-#endif /* CUPS_DEFAULT_DOMAINSOCKET */
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
- /*
-  * First see if we have already set the server name...
-  */
-
   if (!cg->server[0])
-  {
-   /*
-    * Then see if the CUPS_SERVER environment variable is set...
-    */
+    _cupsSetDefaults();
 
-    if ((server = getenv("CUPS_SERVER")) == NULL)
-    {
-     /*
-      * No environment variable, try the client.conf file...
-      */
-
-      fp = cups_open_client_conf();
-
-#ifdef CUPS_DEFAULT_DOMAINSOCKET
-     /*
-      * If we are compiled with domain socket support, only use the
-      * domain socket if it exists and has the right permissions...
-      */
-
-      if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
-          (sockinfo.st_mode & S_IRWXO) == S_IRWXO)
-        server = CUPS_DEFAULT_DOMAINSOCKET;
-      else
-#endif /* CUPS_DEFAULT_DOMAINSOCKET */
-      server = "localhost";
-
-      if (fp)
-      {
-       /*
-       * Read the config file and look for a ServerName line...
-       */
-
-        linenum = 0;
-       while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum) != NULL)
-        {
-          DEBUG_printf(("cupsServer: %d: %s %s\n", linenum, line,
-                       value ? value : "(null)"));
-
-         if (!strcasecmp(line, "ServerName") && value)
-         {
-          /*
-           * Got it!
-           */
-
-            DEBUG_puts("cupsServer: Got a ServerName line!");
-           server = value;
-           break;
-         }
-        }
-
-       cupsFileClose(fp);
-      }
-    }
-
-   /*
-    * Copy the server name over and set the port number, if any...
-    */
+  return (cg->server);
+}
 
-    DEBUG_printf(("cupsServer: Using server \"%s\"...\n", server));
 
-    strlcpy(cg->server, server, sizeof(cg->server));
+/*
+ * 'cupsSetEncryption()' - Set the encryption preference.
+ */
 
-    if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL &&
-        !strchr(port, ']') && isdigit(port[1] & 255))
-    {
-      *port++ = '\0';
+void
+cupsSetEncryption(http_encryption_t e) /* I - New encryption preference */
+{
+  _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
-      DEBUG_printf(("cupsServer: Using port %d...\n", atoi(port)));
-      ippSetPort(atoi(port));
-    }
 
-    if (cg->server[0] == '/')
-      strcpy(cg->servername, "localhost");
-    else
-      strlcpy(cg->servername, cg->server, sizeof(cg->servername));
-  }
+  cg->encryption = e;
 
-  return (cg->server);
+  if (cg->http)
+    httpEncryption(cg->http, e);
 }
 
 
@@ -312,7 +171,7 @@ cupsSetServer(const char *server)   /* I - Server name */
     {
       *port++ = '\0';
 
-      ippSetPort(atoi(port));
+      cg->ipp_port = atoi(port);
     }
 
     if (cg->server[0] == '/')
@@ -464,44 +323,209 @@ _cupsGetPassword(const char *prompt)     /* I - Prompt string */
 
 
 /*
- * 'cups_open_client_conf()' - Open the client.conf file.
+ * '_cupsSetDefaults()' - Set the default server, port, and encryption.
  */
 
-static cups_file_t *                   /* O - File or NULL */
-cups_open_client_conf(void)
+void
+_cupsSetDefaults(void)
 {
   cups_file_t  *fp;                    /* File */
-  const char   *home;                  /* Home directory of user */
+  const char   *home,                  /* Home directory of user */
+               *cups_encryption,       /* CUPS_ENCRYPTION env var */
+               *cups_server;           /* CUPS_SERVER env var */
   char         filename[1024];         /* Filename */
   _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
 
 
-  if ((home = getenv("HOME")) != NULL)
+  DEBUG_puts("_cupsSetDefaults()");
+
+ /*
+  * First collect environment variables...
+  */
+
+  cups_encryption = getenv("CUPS_ENCRYPTION");
+  cups_server     = getenv("CUPS_SERVER");
+
+ /*
+  * Then, if needed, the .cups/client.conf or .cupsrc file in the home
+  * directory...
+  */
+
+  if ((cg->encryption == (http_encryption_t)-1 || !cg->server[0] ||
+       !cg->ipp_port) && (home = getenv("HOME")) != NULL)
   {
    /*
     * Look for ~/.cups/client.conf or ~/.cupsrc...
     */
 
     snprintf(filename, sizeof(filename), "%s/.cups/client.conf", home);
-    if ((fp = cupsFileOpen(filename, "r")) != NULL)
+    if ((fp = cupsFileOpen(filename, "r")) == NULL)
     {
-      DEBUG_printf(("cups_open_client_conf: Using \"%s\"...\n", filename));
-      return (fp);
+      snprintf(filename, sizeof(filename), "%s/.cupsrc", home);
+      fp = cupsFileOpen(filename, "r");
     }
 
-    snprintf(filename, sizeof(filename), "%s/.cupsrc", home);
+    if (fp)
+    {
+      cups_read_client_conf(fp, cg, cups_encryption, cups_server);
+      cupsFileClose(fp);
+    }
+  }
+
+  if (cg->encryption == (http_encryption_t)-1 || !cg->server[0] ||
+      !cg->ipp_port)
+  {
+   /*
+    * Look for CUPS_SERVERROOT/client.conf...
+    */
+
+    snprintf(filename, sizeof(filename), "%s/client.conf", cg->cups_serverroot);
     if ((fp = cupsFileOpen(filename, "r")) != NULL)
     {
-      DEBUG_printf(("cups_open_client_conf: Using \"%s\"...\n", filename));
-      return (fp);
+      cups_read_client_conf(fp, cg, cups_encryption, cups_server);
+      cupsFileClose(fp);
+    }
+  }
+
+ /*
+  * If we still have things that aren't set, use the compiled in defaults...
+  */
+
+  if (cg->encryption == (http_encryption_t)-1)
+    cg->encryption = HTTP_ENCRYPT_IF_REQUESTED;
+
+  if (!cg->server[0])
+  {
+    if (!cups_server)
+    {
+#ifdef CUPS_DEFAULT_DOMAINSOCKET
+     /*
+      * If we are compiled with domain socket support, only use the
+      * domain socket if it exists and has the right permissions...
+      */
+
+      struct stat      sockinfo;       /* Domain socket information */
+
+      if (!stat(CUPS_DEFAULT_DOMAINSOCKET, &sockinfo) &&
+         (sockinfo.st_mode & S_IRWXO) == S_IRWXO)
+       cups_server = CUPS_DEFAULT_DOMAINSOCKET;
+      else
+#endif /* CUPS_DEFAULT_DOMAINSOCKET */
+      cups_server = "localhost";
+    }
+
+    cupsSetServer(cups_server);
+  }
+
+  if (!cg->ipp_port)
+  {
+    const char         *ipp_port;      /* IPP_PORT environment variable */
+    struct servent     *service;       /* Port number info */  
+
+
+    if ((ipp_port = getenv("IPP_PORT")) != NULL)
+    {
+      if ((cg->ipp_port = atoi(ipp_port)) <= 0)
+        cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
     }
+    else if ((service = getservbyname("ipp", NULL)) == NULL ||
+             service->s_port <= 0)
+      cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
+    else
+      cg->ipp_port = ntohs(service->s_port);
+  }
+}
+
+
+/*
+ * 'cups_read_client_conf()' - Read a client.conf file.
+ */
+
+static void
+cups_read_client_conf(
+    cups_file_t     *fp,               /* I - File to read */
+    _cups_globals_t *cg,               /* I - Global data */
+    const char      *cups_encryption,  /* I - CUPS_ENCRYPTION env var */
+    const char      *cups_server)      /* I - CUPS_SERVER env var */
+{
+  int  linenum;                        /* Current line number */
+  char line[1024],                     /* Line from file */
+        *value,                                /* Pointer into line */
+       encryption[1024],               /* Encryption value */
+       server_name[1024];              /* ServerName value */
+
+
+ /*
+  * Read from the file...
+  */
+
+  linenum = 0;
+  while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
+  {
+    if (!cups_encryption && cg->encryption == (http_encryption_t)-1 &&
+        !strcasecmp(line, "Encryption") && value)
+    {
+      strlcpy(encryption, value, sizeof(encryption));
+      cups_encryption = encryption;
+    }
+    else if (!cups_server && (!cg->server[0] || !cg->ipp_port) &&
+             !strcasecmp(line, "ServerName") && value)
+    {
+      strlcpy(server_name, value, sizeof(server_name));
+      cups_server = server_name;
+    }
+  }
+
+ /*
+  * Set values...
+  */
+
+  if (cg->encryption == (http_encryption_t)-1 && cups_encryption)
+  {
+    if (!strcasecmp(cups_encryption, "never"))
+      cg->encryption = HTTP_ENCRYPT_NEVER;
+    else if (!strcasecmp(cups_encryption, "always"))
+      cg->encryption = HTTP_ENCRYPT_ALWAYS;
+    else if (!strcasecmp(cups_encryption, "required"))
+      cg->encryption = HTTP_ENCRYPT_REQUIRED;
+    else
+      cg->encryption = HTTP_ENCRYPT_IF_REQUESTED;
   }
 
-  snprintf(filename, sizeof(filename), "%s/client.conf", cg->cups_serverroot);
-  return (cupsFileOpen(filename, "r"));
+  if ((!cg->server[0] || !cg->ipp_port) && cups_server)
+  {
+    if (!cg->server[0])
+    {
+     /*
+      * Copy server name...
+      */
+
+      strlcpy(cg->server, cups_server, sizeof(cg->server));
+
+      if (cg->server[0] != '/' && (value = strrchr(cg->server, ':')) != NULL &&
+         !strchr(value, ']') && isdigit(value[1] & 255))
+        *value++ = '\0';
+      else
+        value = NULL;
+
+      if (cg->server[0] == '/')
+       strcpy(cg->servername, "localhost");
+      else
+       strlcpy(cg->servername, cg->server, sizeof(cg->servername));
+    }
+    else if (cups_server[0] != '/' &&
+             (value = strrchr(cups_server, ':')) != NULL &&
+            !strchr(value, ']') && isdigit(value[1] & 255))
+      value ++;
+    else
+      value = NULL;
+
+    if (!cg->ipp_port && value)
+      cg->ipp_port = atoi(value);
+  }
 }
 
 
 /*
- * End of "$Id: usersys.c 7337 2008-02-22 04:44:04Z mike $".
+ * End of "$Id: usersys.c 8498 2009-04-13 17:03:15Z mike $".
  */
index ee1cdf3725e71cd8e63c00b35b5938740e47d378..b3a51af1b9744136d1603ca1923ba9855a3d285f 100644 (file)
@@ -220,7 +220,7 @@ cupsCreateJob(
 
 
   DEBUG_printf(("cupsCreateJob(http=%p, name=\"%s\", title=\"%s\", "
-                "num_options=%d, options=%p)\n",
+                "num_options=%d, options=%p)",
                 http, name, title, num_options, options));
 
  /*
@@ -910,7 +910,7 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   */
 
   DEBUG_printf(("cupsGetPPD3(http=%p, name=\"%s\", modtime=%p(%d), buffer=%p, "
-                "bufsize=%d)\n", http, name ? name : "(null)", modtime,
+                "bufsize=%d)", http, name, modtime,
                modtime ? (int)*modtime : 0, buffer, (int)bufsize));
 
   if (!name)
@@ -1048,7 +1048,7 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
                             resource, sizeof(resource), 0))
     return (HTTP_NOT_FOUND);
 
-  DEBUG_printf(("cupsGetPPD3: Printer hostname=\"%s\", port=%d\n", hostname,
+  DEBUG_printf(("2cupsGetPPD3: Printer hostname=\"%s\", port=%d", hostname,
                 port));
 
  /*
@@ -1057,7 +1057,7 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
 
   httpGetHostname(NULL, localhost, sizeof(localhost));
 
-  DEBUG_printf(("cupsGetPPD3: Local hostname=\"%s\"\n", localhost));
+  DEBUG_printf(("2cupsGetPPD3: Local hostname=\"%s\"", localhost));
 
   if (!strcasecmp(localhost, hostname))
     strcpy(hostname, "localhost");
@@ -1069,7 +1069,7 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   httpGetHostname(http, http_hostname, sizeof(http_hostname));
   http_port = _httpAddrPort(http->hostaddr);
 
-  DEBUG_printf(("cupsGetPPD3: Connection hostname=\"%s\", port=%d\n",
+  DEBUG_printf(("2cupsGetPPD3: Connection hostname=\"%s\", port=%d",
                 http_hostname, http_port));
 
  /*
@@ -1081,7 +1081,7 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   else if ((http2 = httpConnectEncrypt(hostname, port,
                                        cupsEncryption())) == NULL)
   {
-    DEBUG_puts("cupsGetPPD3: Unable to connect to server!");
+    DEBUG_puts("1cupsGetPPD3: Unable to connect to server!");
 
     return (HTTP_SERVICE_UNAVAILABLE);
   }
@@ -1131,22 +1131,7 @@ cupsGetPPD3(http_t     *http,            /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
     *modtime = httpGetDateTime(httpGetField(http2, HTTP_FIELD_DATE));
   else if (status != HTTP_NOT_MODIFIED)
   {
-    switch (status)
-    {
-      case HTTP_NOT_FOUND :
-          _cupsSetError(IPP_NOT_FOUND, httpStatus(status), 0);
-         break;
-
-      case HTTP_UNAUTHORIZED :
-          _cupsSetError(IPP_NOT_AUTHORIZED, httpStatus(status), 0);
-         break;
-
-      default :
-         DEBUG_printf(("cupsGetPPD3: HTTP error %d mapped to "
-                       "IPP_SERVICE_UNAVAILABLE!\n", status));
-         _cupsSetError(IPP_SERVICE_UNAVAILABLE, httpStatus(status), 0);
-         break;
-    }
+    _cupsSetHTTPError(status);
 
     unlink(cg->ppd_filename);
   }
@@ -1158,6 +1143,8 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
   * Return the PPD file...
   */
 
+  DEBUG_printf(("1cupsGetPPD3: Returning status %d", status));
+
   return (status);
 }
 
@@ -1381,7 +1368,7 @@ cupsPrintFile(const char    *name,        /* I - Destination name */
              cups_option_t *options)   /* I - Options */
 {
   DEBUG_printf(("cupsPrintFile(name=\"%s\", filename=\"%s\", "
-                "title=\"%s\", num_options=%d, options=%p)\n",
+                "title=\"%s\", num_options=%d, options=%p)",
                 name, filename, title, num_options, options));
 
   return (cupsPrintFiles2(CUPS_HTTP_DEFAULT, name, 1, &filename, title,
@@ -1406,7 +1393,7 @@ cupsPrintFile2(
     cups_option_t *options)            /* I - Options */
 {
   DEBUG_printf(("cupsPrintFile2(http=%p, name=\"%s\", filename=\"%s\", "
-                "title=\"%s\", num_options=%d, options=%p)\n",
+                "title=\"%s\", num_options=%d, options=%p)",
                 http, name, filename, title, num_options, options));
 
   return (cupsPrintFiles2(http, name, 1, &filename, title, num_options,
@@ -1429,10 +1416,9 @@ cupsPrintFiles(
     cups_option_t *options)            /* I - Options */
 {
   DEBUG_printf(("cupsPrintFiles(name=\"%s\", num_files=%d, "
-                "files=%p, title=\"%s\", num_options=%d, options=%p)\n",
+                "files=%p, title=\"%s\", num_options=%d, options=%p)",
                 name, num_files, files, title, num_options, options));
 
-
  /*
   * Print the file(s)...
   */
@@ -1470,7 +1456,7 @@ cupsPrintFiles2(
 
 
   DEBUG_printf(("cupsPrintFiles2(http=%p, name=\"%s\", num_files=%d, "
-                "files=%p, title=\"%s\", num_options=%d, options=%p)\n",
+                "files=%p, title=\"%s\", num_options=%d, options=%p)",
                 http, name, num_files, files, title, num_options, options));
 
  /*
@@ -1711,10 +1697,9 @@ cups_get_printer_uri(
                };
 
 
-  DEBUG_printf(("cups_get_printer_uri(http=%p, name=\"%s\", host=%p, "
-                "hostsize=%d, resource=%p, resourcesize=%d, depth=%d)\n",
-               http, name ? name : "(null)", host, hostsize,
-               resource, resourcesize, depth));
+  DEBUG_printf(("7cups_get_printer_uri(http=%p, name=\"%s\", host=%p, "
+                "hostsize=%d, resource=%p, resourcesize=%d, depth=%d)",
+               http, name, host, hostsize, resource, resourcesize, depth));
 
  /*
   * Setup the printer URI...
@@ -1731,7 +1716,7 @@ cups_get_printer_uri(
     return (0);
   }
 
-  DEBUG_printf(("cups_get_printer_uri: printer-uri=\"%s\"\n", uri));
+  DEBUG_printf(("9cups_get_printer_uri: printer-uri=\"%s\"", uri));
 
  /*
   * Get the hostname and port number we are connected to...
@@ -1812,7 +1797,7 @@ cups_get_printer_uri(
            else if ((http2 = httpConnectEncrypt(host, *port,
                                                 cupsEncryption())) == NULL)
            {
-             DEBUG_puts("Unable to connect to server!");
+             DEBUG_puts("8cups_get_printer_uri: Unable to connect to server!");
 
              continue;
            }
index dade62df51dae93c8191f34f146b97ff5f6990d1..4a49f507e5d34372f62b7128e2536a6943e8ad23 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>Home - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 <TABLE CLASS="page" SUMMARY="{title}">
index f142743ad2533b151ec45f1f07af15fff1fc8a0f..23251add10fc60f44951c113598d596a227f264d 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>Inicio - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 <TABLE CLASS="page" SUMMARY="{title}">
index 28d16de4a0febd722cbf00dbcf46e8ed34c6a22a..64029b94cb984329cea896b7adf8948f0a88a7db 100644 (file)
@@ -1380,20 +1380,6 @@ system-specific but is usually <CODE>lp</CODE> or
 <CODE>nobody</CODE>.</P>
 
 
-<H2 CLASS="title"><SPAN CLASS="info">CUPS 1.3</SPAN><A NAME="GSSServiceName">GSSServiceName</A></H2>
-
-<H3>Examples</H3>
-
-<PRE CLASS="command">
-GSSServiceName IPP
-GSSServiceName HTTP
-</PRE>
-
-<H3>Description</H3>
-
-<P>The <CODE>GSSServiceName</CODE> directive specifies the Kerberos service name that is used when passing authorization tickets. The default name is <CODE>IPP</CODE>.</P>
-
-
 <H2 CLASS="title"><SPAN CLASS="info">CUPS 1.1.10</SPAN><A NAME="HideImplicitMembers">HideImplicitMembers</A></H2>
 
 <H3>Examples</H3>
index 4f81c01fd74a85910d8cadea881b5de0584b1901..03aa76c20d03c5ed610c688512d04d4e33fdb525 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>Home - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 <TABLE CLASS="page" SUMMARY="{title}">
index 21aaa94618de8b14688b76aa6cea4ec379a2db9f..03cea0a4c06b41e439e0c4d7f537984ec76281a4 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>ホーム - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 <TABLE CLASS="page" SUMMARY="{title}">
index 933ab882959772ec907deb4be68f2a7947e1d843..9aadf0df0cd835c9747c05d1c7e22ff94ab53919 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>Strona domowa - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 <TABLE CLASS="page" SUMMARY="{title}">
index ddd29c43ca84b94e176e7c4d32d222f64e61d299..ce5c1d782fede93a437542e1030e8547e2b377ef 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>Начало — CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 <TABLE CLASS="page" SUMMARY="{title}">
index 9ce1dd254df0d7514b9d56ab7d90835a97f1b412..79d440a80eccbed2fe7d68c222487b34b41741dd 100644 (file)
@@ -40,8 +40,8 @@
 
 #  define CUPS_IMAGE_MAX_WIDTH 0x07ffffff
                                        /* 2^27-1 to allow for 15-channel data */
-#  define CUPS_IMAGE_MAX_HEIGHT        0x7fffffff
-                                       /* 2^31-1 */
+#  define CUPS_IMAGE_MAX_HEIGHT        0x3fffffff
+                                       /* 2^30-1 */
 
 #  define CUPS_TILE_SIZE       256     /* 256x256 pixel tiles */
 #  define CUPS_TILE_MINIMUM    10      /* Minimum number of tiles */
index e7ca92de318cf7ad5fe0532f7172be52997cbd08..42732c980c1079b5ab12df83bbc966605cf66339 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PostScript filter for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1993-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -2003,7 +2003,10 @@ do_setup(pstops_doc_t *doc,              /* I - Document information */
   */
 
   if (doc->number_up > 1)
+  {
+    doc_puts(doc, "userdict/CUPSsetpagedevice/setpagedevice load put\n");
     doc_puts(doc, "userdict/setpagedevice{pop}bind put\n");
+  }
 
  /*
   * Changes to the transfer function must be made AFTER any
@@ -3436,6 +3439,15 @@ write_options(
   * Then send them out...
   */
 
+  if (doc->number_up > 1)
+  {
+   /*
+    * Temporarily restore setpagedevice so we can set the options...
+    */
+
+    doc_puts(doc, "userdict/setpagedevice/CUPSsetpagedevice load put\n");
+  }
+
   if (doc_setup)
   {
     doc_puts(doc, doc_setup);
@@ -3447,6 +3459,15 @@ write_options(
     doc_puts(doc, any_setup);
     free(any_setup);
   }
+
+  if (doc->number_up > 1)
+  {
+   /*
+    * Disable setpagedevice again...
+    */
+
+    doc_puts(doc, "userdict/setpagedevice{pop}bind put\n");
+  }
 }
 
 
index 2c4a67c2d5ddd59cc0aeb91871bea81b4873ebb8..be1adf563285169065ede971f2d1a71ea2299f1c 100755 (executable)
@@ -1,9 +1,19 @@
 #!/bin/sh
 #
-# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
+# "$Id$"
 #
-# Library stripping changes Copyright 2008 by Apple Inc.
+# Install a program, script, or datafile.
+#
+# Copyright 2008-2009 by Apple Inc.
+#
+# This script is not compatible with BSD (or any other) install program, as it
+# allows owner and group changes to fail with a warning and makes sure that the
+# destination directory permissions are as specified - BSD install and the
+# original X11 install script did not change permissions of existing
+# directories.  It also does not support the transform options since CUPS does
+# not use them...
+#
+# Original script from X11R5 (mit/util/scripts/install.sh)
 # Copyright 1991 by the Massachusetts Institute of Technology
 #
 # Permission to use, copy, modify, distribute, and sell this software and its
 # Calling this script install-sh is preferred over install.sh, to prevent
 # `make' implicit rules from creating a file called install from it
 # when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
 
 # set DOITPROG to echo to test this script
-
 # Don't use :- since 4.3BSD and earlier shells don't like it.
 doit="${DOITPROG-}"
 
+# Force umask to 022...
+umask 022
 
 # put in absolute paths if you don't have them in your path; or use env. vars.
-
 mvprog="${MVPROG-mv}"
 cpprog="${CPPROG-cp}"
 chmodprog="${CHMODPROG-chmod}"
@@ -56,172 +61,136 @@ dst=""
 dir_arg=""
 
 while [ x"$1" != x ]; do
-    case $1 in
-       -c) instcmd="$cpprog"
-           shift
-           continue;;
-
-       -d) dir_arg=true
-           shift
-           continue;;
-
-       -m) chmodcmd="$chmodprog $2"
-           shift
-           shift
-           continue;;
-
-       -o) chowncmd="$chownprog $2"
-           shift
-           shift
-           continue;;
-
-       -g) chgrpcmd="$chgrpprog $2"
-           shift
-           shift
-           continue;;
+       case $1 in
+               -c)
+               instcmd="$cpprog"
+               shift
+               continue
+               ;;
+
+               -d)
+               dir_arg=true
+               shift
+               continue
+               ;;
+
+               -m)
+               chmodcmd="$chmodprog $2"
+               shift
+               shift
+               continue
+               ;;
+
+               -o)
+               chowncmd="$chownprog $2"
+               shift
+               shift
+               continue
+               ;;
+
+               -g)
+               chgrpcmd="$chgrpprog $2"
+               shift
+               shift
+               continue
+               ;;
+
+               -s)
+               stripcmd="$stripprog"
+               shift
+               continue
+               ;;
 
-       -s) stripcmd="$stripprog"
-           shift
-           continue;;
-
-       -t=*) transformarg=`echo $1 | sed 's/-t=//'`
-           shift
-           continue;;
-
-       -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
-           shift
-           continue;;
-
-       *)  if [ x"$src" = x ]
-           then
-               src=$1
-           else
-               # this colon is to work around a 386BSD /bin/sh bug
-               :
-               dst=$1
-           fi
-           shift
-           continue;;
-    esac
+               *)
+               if [ x"$src" = x ]; then
+                       src="$1"
+               else
+                       dst="$1"
+               fi
+               shift
+               continue
+               ;;
+       esac
 done
 
-if [ x"$src" = x ]
-then
-       echo "install:  no input file specified"
+if [ x"$src" = x ]; then
+       echo "install-sh: No input file specified"
        exit 1
-else
-       :
 fi
 
 if [ x"$dir_arg" != x ]; then
-       dst=$src
+       dst="$src"
        src=""
        
-       if [ -d $dst ]; then
+       if [ -d "$dst" ]; then
                instcmd=:
-               chmodcmd=""
        else
                instcmd=$mkdirprog
        fi
 else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad 
-# if $src (and thus $dsttmp) contains '*'.
-
-       if [ -f $src -o -d $src ]
-       then
-               :
-       else
-               echo "install:  $src does not exist"
+       # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+       # might cause directories to be created, which would be especially bad 
+       # if $src (and thus $dsttmp) contains '*'.
+       if [ ! -f "$src" -a ! -d "$src" ]; then
+               echo "install: $src does not exist"
                exit 1
        fi
        
-       if [ x"$dst" = x ]
-       then
-               echo "install:  no destination specified"
+       if [ x"$dst" = x ]; then
+               echo "install: No destination specified"
                exit 1
-       else
-               :
        fi
 
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
-       if [ -d $dst ]
-       then
-               dst="$dst"/`basename $src`
-       else
-               :
+       # If destination is a directory, append the input filename.
+       if [ -d "$dst" ]; then
+               dst="$dst/`basename $src`"
        fi
 fi
 
 ## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+dstdir="`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`"
 
 # Make sure that the destination directory exists.
-#  this part is taken from Noah Friedman's mkinstalldirs script
+# This part is taken from Noah Friedman's mkinstalldirs script
 
 # Skip lots of stat calls in the usual case.
 if [ ! -d "$dstdir" ]; then
-defaultIFS='
+       defaultIFS='
        '
-IFS="${IFS-${defaultIFS}}"
+       IFS="${IFS-${defaultIFS}}"
 
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
+       oIFS="${IFS}"
+       # Some sh's can't handle IFS=/ for some reason.
+       IFS='%'
+       set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+       IFS="${oIFS}"
 
-pathcomp=''
+       pathcomp=''
 
-while [ $# -ne 0 ] ; do
-       pathcomp="${pathcomp}${1}"
-       shift
+       while [ $# -ne 0 ] ; do
+               pathcomp="${pathcomp}${1}"
+               shift
 
-       if [ ! -d "${pathcomp}" ] ;
-        then
-               $mkdirprog "${pathcomp}" &&
-               if [ x"$chowncmd" != x ]; then $doit $chowncmd "$pathcomp"; else : ; fi &&
-               if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$pathcomp"; else : ; fi
-       else
-               :
-       fi
+               if [ ! -d "${pathcomp}" ]; then $doit $mkdirprog "${pathcomp}"; fi
 
-       pathcomp="${pathcomp}/"
-done
+               pathcomp="${pathcomp}/"
+       done
 fi
 
-if [ x"$dir_arg" != x ]
-then
-       $doit $instcmd $dst &&
+if [ x"$dir_arg" != x ]; then
+       # Make a directory...
+       $doit $instcmd $dst || exit 1
 
-       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
-       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
-       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
+       # Allow chown/chgrp to fail, but log a warning
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst || echo "warning: Unable to change owner of $dst!"; fi
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst || echo "warning: Unable to change group of $dst!"; fi
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst || exit 1; fi
 else
+       # Install a file...
+       dstfile="`basename $dst`"
 
-# If we're going to rename the final executable, determine the name now.
-
-       if [ x"$transformarg" = x ] 
-       then
-               dstfile=`basename $dst`
-       else
-               dstfile=`basename $dst $transformbasename | 
-                       sed $transformarg`$transformbasename
-       fi
-
-# don't allow the sed command to completely eliminate the filename
-
-       if [ x"$dstfile" = x ] 
-       then
-               dstfile=`basename $dst`
-       else
-               :
-       fi
-
-# Check the destination file - for libraries just use the "-x" option to strip
+       # Check the destination file - for libraries just use the "-x" option
+       # to strip...
        case "$dstfile" in
                *.a | *.dylib | *.sl | *.sl.* | *.so | *.so.*)
                        stripopt="-x"
@@ -231,33 +200,23 @@ else
                        ;;
        esac
 
-# Make a temp file name in the proper directory.
-
-       dsttmp=$dstdir/#inst.$$#
+       # Make a temp file name in the proper directory.
+       dsttmp="$dstdir/#inst.$$#"
 
-# Move or copy the file name to the temp name
+       # Move or copy the file name to the temp name
+       $doit $instcmd $src $dsttmp || exit 1
 
-       $doit $instcmd $src $dsttmp &&
+       # Update permissions and strip as needed, then move to the final name.
+       # If the chmod, strip, rm, or mv commands fail, remove the installed
+       # file...
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp" || echo "warning: Unable to change owner of $dst!"; fi
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp" || echo "warning: Unable to change group of $dst!"; fi
 
        trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing.  If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
-       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
-       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
-       if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripopt $dsttmp; else :;fi &&
-       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
-
-# Now rename the file to the real destination.
-
-       $doit $rmcmd -f $dstdir/$dstfile &&
-       $doit $mvcmd $dsttmp $dstdir/$dstfile 
-
-fi &&
-
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripopt "$dsttmp"; fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; fi &&
+       $doit $rmcmd -f "$dstdir/$dstfile" &&
+       $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+fi
 
 exit 0
index e2e0351836a9679a8b92b3cd0162f410f4e5edbf..a2153b9a67dd244ef04ced17a3cf481e332c0c88 100644 (file)
@@ -12,7 +12,7 @@
 .\"   which should have been included with this file.  If this file is
 .\"   file is missing or damaged, see the license at "http://www.cups.org/".
 .\"
-.TH cupsd.conf 5 "CUPS" "16 March 2009" "Apple Inc."
+.TH cupsd.conf 5 "CUPS" "19 April 2009" "Apple Inc."
 .SH NAME
 cupsd.conf \- server configuration file for cups
 .SH DESCRIPTION
@@ -416,10 +416,6 @@ KeepAliveTimeout seconds
 .br
 Specifies the amount of time that connections are kept alive.
 .TP 5
-Krb5Keytab filename
-.br
-Overrides the Kerberos key tab location.
-.TP 5
 <Limit operations> ... </Limit>
 .br
 Specifies the IPP operations that are being limited inside a policy.
@@ -622,6 +618,11 @@ ServerAdmin user@domain.com
 .br
 Specifies the email address of the server administrator.
 .TP 5
+ServerAlias hostname
+.br
+Specifies an alternate name that the server is known by. The special name "*"
+allows any name to be used.
+.TP 5
 ServerBin directory
 .br
 Specifies the directory where backends, CGIs, daemons, and filters may
index 2dc2c96829c35309bbed4e943a2d1d1bb4ef6a52..252e5085a22dc90af9b7694c5e4d46050b7a4710 100644 (file)
@@ -62,8 +62,7 @@ install:      all install-data install-headers install-libs install-exec
 #
 
 install-data:
-       $(INSTALL_DIR) -m 775 $(CACHEDIR)/rss
-       -chgrp $(CUPS_GROUP) $(CACHEDIR)/rss
+       $(INSTALL_DIR) -m 775 -g $(CUPS_GROUP) $(CACHEDIR)/rss
 
 
 #
index 596547f5e3507da95089c1ad912777d5018348b8..9479c7af561f9e19088475d77e757c39157b3326 100644 (file)
@@ -138,38 +138,29 @@ install-data:
        echo Creating $(SERVERBIN)/driver...
        $(INSTALL_DIR) -m 755 $(SERVERBIN)/driver
        echo Creating $(SERVERROOT)...
-       $(INSTALL_DIR) -m 755 $(SERVERROOT)
-       -chgrp $(CUPS_GROUP) $(SERVERROOT)
+       $(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)
        echo Creating $(SERVERROOT)/interfaces...
-       $(INSTALL_DIR) -m 755 $(SERVERROOT)/interfaces
-       -chgrp $(CUPS_GROUP) $(SERVERROOT)/interfaces
+       $(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)/interfaces
        echo Creating $(SERVERROOT)/ppd...
-       $(INSTALL_DIR) -m 755 $(SERVERROOT)/ppd
-       -chgrp $(CUPS_GROUP) $(SERVERROOT)/ppd
-       -if test "x`uname`" != xDarwin; then \
+       $(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)/ppd
+       if test "x`uname`" != xDarwin; then \
                echo Creating $(SERVERROOT)/ssl...; \
-               $(INSTALL_DIR) -m 700 $(SERVERROOT)/ssl; \
-               chgrp $(CUPS_GROUP) $(SERVERROOT)/ssl || true; \
+               $(INSTALL_DIR) -m 700 -g $(CUPS_GROUP) $(SERVERROOT)/ssl; \
+       fi
+       if test "$(STATEDIR)" != "$(SERVERROOT)"; then \
                echo Creating $(STATEDIR)...; \
                $(INSTALL_DIR) -m 755 $(STATEDIR); \
-               echo Creating $(STATEDIR)/certs...; \
-               $(INSTALL_DIR) -m 511 $(STATEDIR)/certs; \
-               chgrp $(CUPS_PRIMARY_SYSTEM_GROUP) $(STATEDIR)/certs || true; \
        fi
+       echo Creating $(STATEDIR)/certs...
+       $(INSTALL_DIR) -m 511 -g $(CUPS_PRIMARY_SYSTEM_GROUP) $(STATEDIR)/certs
        echo Creating $(LOGDIR)...
        $(INSTALL_DIR) -m 755 $(LOGDIR)
        echo Creating $(REQUESTS)...
-       $(INSTALL_DIR) -m 710 $(REQUESTS)
-       -chgrp $(CUPS_GROUP) $(REQUESTS)
+       $(INSTALL_DIR) -m 710 -g $(CUPS_GROUP) $(REQUESTS)
        echo Creating $(REQUESTS)/tmp...
-       $(INSTALL_DIR) -m 1770 $(REQUESTS)/tmp
-       -chgrp $(CUPS_GROUP) $(REQUESTS)/tmp
+       $(INSTALL_DIR) -m 1770 -g $(CUPS_GROUP) $(REQUESTS)/tmp
        echo Creating $(CACHEDIR)...
-       $(INSTALL_DIR) -m 775 $(CACHEDIR)
-       -chgrp $(CUPS_GROUP) $(CACHEDIR)
-#      echo Creating $(CACHEDIR)/ppd...
-#      $(INSTALL_DIR) -m 755 $(CACHEDIR)/ppd
-#      -chgrp $(CUPS_GROUP) $(CACHEDIR)/ppd
+       $(INSTALL_DIR) -m 775 -g $(CUPS_GROUP) $(CACHEDIR)
 
 
 #
@@ -179,7 +170,7 @@ install-data:
 install-exec:
        echo Installing programs in $(SBINDIR)...
        $(INSTALL_DIR) -m 755 $(SBINDIR)
-       $(INSTALL_BIN) cupsd $(SBINDIR)
+       $(INSTALL_BIN) -m 500 cupsd $(SBINDIR)
        $(INSTALL_BIN) cupsfilter $(SBINDIR)
        -if test "x`uname`" = xDarwin; then \
                $(INSTALL_DIR) $(BUILDROOT)/System/Library/Printers/Libraries; \
index abf55e3e2069c319f655c2293bbe130640f3ee2f..7316c8feb66572493ad6aae30392c0e1c8e253d9 100644 (file)
@@ -28,6 +28,7 @@
  *                               access a location.
  *   cupsdCheckAuth()          - Check authorization masks.
  *   cupsdCheckGroup()         - Check for a user's group membership.
+ *   cupsdCopyKrb5Creds()      - Get a copy of the Kerberos credentials.
  *   cupsdCopyLocation()       - Make a copy of a location...
  *   cupsdDeleteAllLocations() - Free all memory used for location
  *                               authorization.
@@ -47,7 +48,6 @@
  *   compare_locations()       - Compare two locations.
  *   cups_crypt()              - Encrypt the password using the DES or MD5
  *                               algorithms, as needed.
- *   get_gss_creds()           - Obtain GSS credentials.
  *   get_md5_password()        - Get an MD5 password.
  *   pam_func()                - PAM conversation function.
  *   to64()                    - Base64-encode an integer value...
@@ -97,6 +97,11 @@ typedef struct xucred cupsd_ucred_t;
 typedef struct ucred cupsd_ucred_t;
 #  define CUPSD_UCRED_UID(c) (c).uid
 #endif /* HAVE_SYS_UCRED_H */
+#ifdef HAVE_KRB5_IPC_CLIENT_SET_TARGET_UID
+/* Not in public headers... */
+extern void    krb5_ipc_client_set_target_uid(uid_t);
+extern void    krb5_ipc_client_clear_target(void);
+#endif /* HAVE_KRB5_IPC_CLIENT_SET_TARGET_UID */
 
 
 /*
@@ -113,10 +118,6 @@ static int         compare_locations(cupsd_location_t *a,
 #if !HAVE_LIBPAM && !defined(HAVE_USERSEC_H)
 static char            *cups_crypt(const char *pw, const char *salt);
 #endif /* !HAVE_LIBPAM && !HAVE_USERSEC_H */
-#ifdef HAVE_GSSAPI
-static gss_cred_id_t   get_gss_creds(const char *service_name,
-                                     const char *con_server_name);
-#endif /* HAVE_GSSAPI */
 static char            *get_md5_password(const char *username,
                                          const char *group, char passwd[33]);
 #if HAVE_LIBPAM
@@ -960,7 +961,6 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
   else if (!strncmp(authorization, "Negotiate", 9)) 
   {
     int                        len;            /* Length of authorization string */
-    gss_cred_id_t      server_creds;   /* Server credentials */
     gss_ctx_id_t       context;        /* Authorization context */
     OM_uint32          major_status,   /* Major status code */
                        minor_status;   /* Minor status code */
@@ -969,7 +969,6 @@ cupsdAuthorize(cupsd_client_t *con) /* I - Client connection */
                        output_token = GSS_C_EMPTY_BUFFER;
                                        /* Output token for username */
     gss_name_t         client_name;    /* Client name */
-    unsigned int       ret_flags;      /* Credential flags */
 
 
 #  ifdef __APPLE__
@@ -1004,13 +1003,6 @@ cupsdAuthorize(cupsd_client_t *con)      /* I - Client connection */
       return;
     }
 
-   /*
-    * Get the server credentials...
-    */
-
-    if ((server_creds = get_gss_creds(GSSServiceName, con->servername)) == NULL)
-      return;  
-
    /*
     * Decode the authorization string to get the input token...
     */
@@ -1029,15 +1021,15 @@ cupsdAuthorize(cupsd_client_t *con)     /* I - Client connection */
     client_name  = GSS_C_NO_NAME;
     major_status = gss_accept_sec_context(&minor_status,
                                          &context,
-                                         server_creds
+                                         GSS_C_NO_CREDENTIAL
                                          &input_token,
                                          GSS_C_NO_CHANNEL_BINDINGS,
                                          &client_name,
                                          NULL,
                                          &con->gss_output_token,
-                                         &ret_flags,
+                                         &con->gss_flags,
                                          NULL,
-                                         &con->gss_delegated_cred);
+                                         &con->gss_creds);
 
     if (GSS_ERROR(major_status))
     {
@@ -1047,28 +1039,20 @@ cupsdAuthorize(cupsd_client_t *con)     /* I - Client connection */
 
       if (context != GSS_C_NO_CONTEXT)
        gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
-
-      gss_release_cred(&minor_status, &server_creds);
       return;
     }
 
-   /*
-    * Release our credentials...
-    */
-
-    gss_release_cred(&minor_status, &server_creds);
-
    /*
     * Get the username associated with the client's credentials...
     */
 
-    if (!con->gss_delegated_cred)
+    if (!con->gss_creds)
       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                      "cupsdAuthorize: No delegated credentials!");
+                      "cupsdAuthorize: No credentials!");
 
     if (major_status == GSS_S_CONTINUE_NEEDED)
       cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
-                         "cupsdAuthorize: Credentials not complete");
+                        "cupsdAuthorize: Credentials not complete");
     else if (major_status == GSS_S_COMPLETE)
     {
       major_status = gss_display_name(&minor_status, client_name, 
@@ -1078,27 +1062,27 @@ cupsdAuthorize(cupsd_client_t *con)     /* I - Client connection */
       {
        cupsdLogGSSMessage(CUPSD_LOG_DEBUG, major_status, minor_status,
                            "cupsdAuthorize: Error getting username");
+       gss_release_cred(&minor_status, &con->gss_creds);
        gss_release_name(&minor_status, &client_name);
        gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
        return;
       }
 
-      gss_release_name(&minor_status, &client_name);
       strlcpy(username, output_token.value, sizeof(username));
 
       cupsdLogMessage(CUPSD_LOG_DEBUG,
                      "cupsdAuthorize: Authorized as %s using Negotiate",
                      username);
 
+      gss_release_name(&minor_status, &client_name);
       gss_release_buffer(&minor_status, &output_token);
-      gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
-
-      con->gss_have_creds = 1;
 
       con->type = CUPSD_AUTH_NEGOTIATE;
     }
     else
-      gss_release_name(&minor_status, &client_name);
+      gss_release_cred(&minor_status, &con->gss_creds);
+
+    gss_delete_sec_context(&minor_status, &context, GSS_C_NO_BUFFER);
   }
 #endif /* HAVE_GSSAPI */
   else
@@ -1205,6 +1189,7 @@ cupsdCheckAuth(
   unsigned     netip6[4];              /* IPv6 network address */
 #endif /* AF_INET6 */
 
+
   while (num_masks > 0)
   {
     switch (masks->type)
@@ -1225,6 +1210,15 @@ cupsdCheckAuth(
 
           if (!strcmp(masks->mask.name.name, "*"))
          {
+#ifdef __APPLE__
+           /*
+           * Allow Back-to-My-Mac addresses...
+           */
+
+           if ((ip[0] & 0xff000000) == 0xfd000000)
+             return (1);
+#endif /* __APPLE__ */
+
           /*
            * Check against all local interfaces...
            */
@@ -1474,6 +1468,170 @@ cupsdCheckGroup(
 }
 
 
+#ifdef HAVE_GSSAPI
+/*
+ * 'cupsdCopyKrb5Creds()' - Get a copy of the Kerberos credentials.
+ */
+
+krb5_ccache                            /* O - Credentials or NULL */
+cupsdCopyKrb5Creds(cupsd_client_t *con)        /* I - Client connection */
+{
+#  if !defined(HAVE_KRB5_CC_NEW_UNIQUE) && !defined(HAVE_HEIMDAL)
+  cupsdLogMessage(CUPSD_LOG_INFO,
+                  "Sorry, your version of Kerberos does not support delegated "
+                 "credentials!");
+  return (NULL);
+
+#  else
+  krb5_ccache          ccache = NULL;  /* Credentials */
+  krb5_error_code      error;          /* Kerberos error code */
+  OM_uint32            major_status,   /* Major status code */
+                       minor_status;   /* Minor status code */
+  krb5_principal       principal;      /* Kerberos principal */
+
+
+#    ifdef __APPLE__
+ /*
+  * If the weak-linked GSSAPI/Kerberos library is not present, don't try
+  * to use it...
+  */
+
+  if (krb5_init_context == NULL)
+    return (NULL);
+#    endif /* __APPLE__ */
+
+  if (!KerberosInitialized)
+  {
+   /*
+    * Setup a Kerberos context for the scheduler to use...
+    */
+
+    KerberosInitialized = 1;
+
+    if (krb5_init_context(&KerberosContext))
+    {
+      KerberosContext = NULL;
+
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to initialize Kerberos context");
+      return (NULL);
+    }
+  }
+
+ /*
+  * We MUST create a file-based cache because memory-based caches are
+  * only valid for the current process/address space.
+  *
+  * Due to various bugs/features in different versions of Kerberos, we
+  * need either the krb5_cc_new_unique() function or Heimdal's version
+  * of krb5_cc_gen_new() to create a new FILE: credential cache that
+  * can be passed to the backend.  These functions create a temporary
+  * file (typically in /tmp) containing the cached credentials, which
+  * are removed when we have successfully printed a job.
+  */
+
+#    ifdef HAVE_KRB5_CC_NEW_UNIQUE
+  if ((error = krb5_cc_new_unique(KerberosContext, "FILE", NULL, &ccache)) != 0)
+#    else /* HAVE_HEIMDAL */
+  if ((error = krb5_cc_gen_new(KerberosContext, &krb5_fcc_ops, &ccache)) != 0)
+#    endif /* HAVE_KRB5_CC_NEW_UNIQUE */
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "Unable to create new credentials cache (%d/%s)",
+                    error, strerror(errno));
+    return (NULL);
+  }
+
+  if ((error = krb5_parse_name(KerberosContext, con->username, &principal)) != 0)
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "Unable to parse kerberos username (%d/%s)", error,
+                    strerror(errno));
+    krb5_cc_destroy(KerberosContext, ccache);
+    return (NULL);
+  }
+
+  if ((error = krb5_cc_initialize(KerberosContext, ccache, principal)))
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "Unable to initialize credentials cache (%d/%s)", error,
+                   strerror(errno));
+    krb5_cc_destroy(KerberosContext, ccache);
+    krb5_free_principal(KerberosContext, principal);
+    return (NULL);
+  }
+
+  krb5_free_principal(KerberosContext, principal);
+
+ /*
+  * Copy the user's credentials to the new cache file...
+  */
+
+#    ifdef HAVE_KRB5_IPC_CLIENT_SET_TARGET_UID
+  if (con->http.hostaddr->addr.sa_family == AF_LOCAL &&
+      !(con->gss_flags & GSS_C_DELEG_FLAG))
+  {
+   /*
+    * Pull the credentials directly from the user...
+    */
+
+    cupsd_ucred_t      peercred;       /* Peer credentials */
+    socklen_t          peersize;       /* Size of peer credentials */
+    krb5_ccache                peerccache;     /* Peer Kerberos credentials */
+
+    peersize = sizeof(peercred);
+
+    if (getsockopt(con->http.fd, SOL_SOCKET, SO_PEERCRED, &peercred, &peersize))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get peer credentials - %s",
+                      strerror(errno));
+      krb5_cc_destroy(KerberosContext, ccache);
+      return (NULL);
+    }
+
+    krb5_ipc_client_set_target_uid(CUPSD_UCRED_UID(peercred));
+
+    if ((error = krb5_cc_default(KerberosContext, &peerccache)) != 0)
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                     "Unable to get credentials cache for UID %d (%d/%s)",
+                     (int)CUPSD_UCRED_UID(peercred), error, strerror(errno));
+      krb5_cc_destroy(KerberosContext, ccache);
+      return (NULL);
+    }
+
+    error = krb5_cc_copy_creds(KerberosContext, peerccache, ccache);
+    krb5_cc_close(KerberosContext, peerccache);
+    krb5_ipc_client_clear_target();
+
+    if (error)
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                     "Unable to copy credentials cache for UID %d (%d/%s)",
+                     (int)CUPSD_UCRED_UID(peercred), error, strerror(errno));
+      krb5_cc_destroy(KerberosContext, ccache);
+      return (NULL);
+    }
+  }
+  else
+#    endif /* HAVE_KRB5_IPC_CLIENT_SET_TARGET_UID */
+  {
+    major_status = gss_krb5_copy_ccache(&minor_status, con->gss_creds, ccache);
+
+    if (GSS_ERROR(major_status))
+    {
+      cupsdLogGSSMessage(CUPSD_LOG_ERROR, major_status, minor_status,
+                        "Unable to copy client credentials cache");
+      krb5_cc_destroy(KerberosContext, ccache);
+      return (NULL);
+    }
+  }
+
+  return (ccache);
+#  endif /* !HAVE_KRB5_CC_NEW_UNIQUE && !HAVE_HEIMDAL */
+}
+#endif /* HAVE_GSSAPI */
+
+
 /*
  * 'cupsdCopyLocation()' - Make a copy of a location...
  */
@@ -2508,81 +2666,6 @@ cups_crypt(const char *pw,               /* I - Password string */
 #endif /* !HAVE_LIBPAM && !HAVE_USERSEC_H */
 
 
-#ifdef HAVE_GSSAPI
-/*
- * 'get_gss_creds()' - Obtain GSS credentials.
- */
-
-static gss_cred_id_t                   /* O - Server credentials */
-get_gss_creds(
-    const char *service_name,          /* I - Service name */
-    const char *con_server_name)       /* I - Hostname of server */
-{
-  OM_uint32    major_status,           /* Major status code */
-               minor_status;           /* Minor status code */
-  gss_name_t   server_name;            /* Server name */
-  gss_cred_id_t        server_creds;           /* Server credentials */
-  gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
-                                       /* Service name token */
-  char         buf[1024];              /* Service name buffer */
-
-
-  snprintf(buf, sizeof(buf), "%s@%s", service_name, con_server_name);
-
-  token.value  = buf;
-  token.length = strlen(buf);
-  server_name  = GSS_C_NO_NAME;
-  major_status = gss_import_name(&minor_status, &token,
-                                GSS_C_NT_HOSTBASED_SERVICE,
-                                &server_name);
-
-  memset(&token, 0, sizeof(token));
-
-  if (GSS_ERROR(major_status))
-  {
-    cupsdLogGSSMessage(CUPSD_LOG_WARN, major_status, minor_status, 
-                      "gss_import_name() failed");
-    return (NULL);
-  }
-
-  major_status = gss_display_name(&minor_status, server_name, &token, NULL);
-
-  if (GSS_ERROR(major_status))
-  {
-    cupsdLogGSSMessage(CUPSD_LOG_WARN, major_status, minor_status,
-                       "gss_display_name() failed"); 
-    return (NULL);
-  }
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG,
-                  "get_gss_creds: Attempting to acquire credentials for %s...", 
-                  (char *)token.value);
-
-  server_creds = GSS_C_NO_CREDENTIAL;
-  major_status = gss_acquire_cred(&minor_status, server_name, GSS_C_INDEFINITE,
-                                 GSS_C_NO_OID_SET, GSS_C_ACCEPT,
-                                 &server_creds, NULL, NULL);
-  if (GSS_ERROR(major_status))
-  {
-    cupsdLogGSSMessage(CUPSD_LOG_WARN, major_status, minor_status,
-                       "gss_acquire_cred() failed"); 
-    gss_release_name(&minor_status, &server_name);
-    gss_release_buffer(&minor_status, &token);
-    return (NULL);
-  }
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG,
-                  "get_gss_creds: Credentials acquired successfully for %s.", 
-                  (char *)token.value);
-
-  gss_release_name(&minor_status, &server_name);
-  gss_release_buffer(&minor_status, &token);
-
-  return (server_creds);
-}
-#endif /* HAVE_GSSAPI */
-
-
 /*
  * 'get_md5_password()' - Get an MD5 password.
  */
index b5bb653629e27e341f72882c75b442779f10b15c..189ca2997af45a316a350d5952b9754710a87292 100644 (file)
@@ -4,7 +4,7 @@
  *   Authorization definitions for the Common UNIX Printing System (CUPS)
  *   scheduler.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -142,6 +142,9 @@ extern int          cupsdCheckAuth(unsigned ip[4], char *name, int namelen,
 extern int             cupsdCheckGroup(const char *username,
                                        struct passwd *user,
                                        const char *groupname);
+#ifdef HAVE_GSSAPI
+extern krb5_ccache     cupsdCopyKrb5Creds(cupsd_client_t *con);
+#endif /* HAVE_GSSAPI */
 extern cupsd_location_t        *cupsdCopyLocation(cupsd_location_t **loc);
 extern void            cupsdDeleteAllLocations(void);
 extern void            cupsdDeleteLocation(cupsd_location_t *loc);
index c3ed3ca088c18e236e5a5c800c96877b31077023..b5a59ae8878f1a1222762f6e0a9b02d97cdb3c11 100644 (file)
@@ -41,6 +41,7 @@
  *                            (i.e. "..").
  *   make_certificate()     - Make a self-signed SSL/TLS certificate.
  *   pipe_command()         - Pipe the output of a command to the remote client.
+ *   valid_host()           - Is the Host: field valid?
  *   write_file()           - Send a file via HTTP.
  *   write_pipe()           - Flag that data is available on the CGI pipe.
  */
@@ -110,6 +111,7 @@ static int          make_certificate(cupsd_client_t *con);
 #endif /* HAVE_SSL */
 static int             pipe_command(cupsd_client_t *con, int infile, int *outfile,
                                     char *command, char *options, int root);
+static int             valid_host(cupsd_client_t *con);
 static int             write_file(cupsd_client_t *con, http_status_t code,
                                   char *filename, char *type,
                                   struct stat *filestats);
@@ -418,10 +420,10 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 #ifdef AF_INET6
     if (temp.addr.sa_family == AF_INET6)
     {
-      if (HostNameLookups)
-        httpAddrLookup(&temp, con->servername, sizeof(con->servername));
-      else if (httpAddrLocalhost(&temp))
+      if (httpAddrLocalhost(&temp))
         strlcpy(con->servername, "localhost", sizeof(con->servername));
+      else if (HostNameLookups || RemoteAccessEnabled)
+        httpAddrLookup(&temp, con->servername, sizeof(con->servername));
       else
         httpAddrString(&temp, con->servername, sizeof(con->servername));
 
@@ -431,10 +433,10 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 #endif /* AF_INET6 */
     if (temp.addr.sa_family == AF_INET)
     {
-      if (HostNameLookups)
-        httpAddrLookup(&temp, con->servername, sizeof(con->servername));
-      else if (httpAddrLocalhost(&temp))
+      if (httpAddrLocalhost(&temp))
         strlcpy(con->servername, "localhost", sizeof(con->servername));
+      else if (HostNameLookups || RemoteAccessEnabled)
+        httpAddrLookup(&temp, con->servername, sizeof(con->servername));
       else
         httpAddrString(&temp, con->servername, sizeof(con->servername));
 
@@ -890,7 +892,10 @@ cupsdReadClient(cupsd_client_t *con)       /* I - Client to read from */
        }
 
 #ifdef HAVE_GSSAPI
-        con->gss_have_creds = 0;
+       {
+         OM_uint32 minor_status;
+         gss_release_cred(&minor_status, &con->gss_creds);
+       }
 #endif /* HAVE_GSSAPI */
 
        /*
@@ -1131,13 +1136,7 @@ cupsdReadClient(cupsd_client_t *con)     /* I - Client to read from */
        return;
       }
     }
-    else if (httpAddrLocalhost(con->http.hostaddr) &&
-             strcasecmp(con->http.fields[HTTP_FIELD_HOST], "localhost") &&
-            strncasecmp(con->http.fields[HTTP_FIELD_HOST], "localhost:", 10) &&
-            strcmp(con->http.fields[HTTP_FIELD_HOST], "127.0.0.1") &&
-            strncmp(con->http.fields[HTTP_FIELD_HOST], "127.0.0.1:", 10) &&
-            strcmp(con->http.fields[HTTP_FIELD_HOST], "[::1]") &&
-            strncmp(con->http.fields[HTTP_FIELD_HOST], "[::1]:", 6))
+    else if (!valid_host(con))
     {
      /*
       * Access to localhost must use "localhost" or the corresponding IPv4
@@ -2468,19 +2467,28 @@ cupsdSendHeader(
       strlcpy(auth_str, "Negotiate", sizeof(auth_str));
 #endif /* HAVE_GSSAPI */
 
-#ifdef HAVE_AUTHORIZATION_H
-    if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE)
+    if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE &&
+        !strcasecmp(con->http.hostname, "localhost"))
     {
-      int       i;                     /* Looping var */
+     /*
+      * Add a "trc" (try root certification) parameter for local non-Kerberos
+      * requests when the request requires system group membership - then the
+      * client knows the root certificate can/should be used.
+      *
+      * Also, for Mac OS X we also look for @AUTHKEY and add an "authkey"
+      * parameter as needed...
+      */
+
+      int      i;                      /* Looping var */
       char     *auth_key;              /* Auth key buffer */
       size_t   auth_size;              /* Size of remaining buffer */
 
-
       auth_key  = auth_str + strlen(auth_str);
       auth_size = sizeof(auth_str) - (auth_key - auth_str);
 
       for (i = 0; i < con->best->num_names; i ++)
       {
+#ifdef HAVE_AUTHORIZATION_H
        if (!strncasecmp(con->best->names[i], "@AUTHKEY(", 9))
        {
          snprintf(auth_key, auth_size, ", authkey=\"%s\"",
@@ -2488,15 +2496,23 @@ cupsdSendHeader(
          /* end parenthesis is stripped in conf.c */
          break;
         }
-       else if (!strcasecmp(con->best->names[i], "@SYSTEM") &&
-                SystemGroupAuthKey)
+       else
+#endif /* HAVE_AUTHORIZATION_H */
+       if (!strcasecmp(con->best->names[i], "@SYSTEM"))
        {
-         snprintf(auth_key, auth_size, ", authkey=\"%s\"", SystemGroupAuthKey);
+#ifdef HAVE_AUTHORIZATION_H
+         if (SystemGroupAuthKey)
+           snprintf(auth_key, auth_size,
+                    ", authkey=\"%s\", trc=\"y\"",
+                    SystemGroupAuthKey);
+          else
+#else
+         strlcpy(auth_key, ", trc=\"y\"", auth_size));
+#endif /* HAVE_AUTHORIZATION_H */
          break;
        }
       }
     }
-#endif /* HAVE_AUTHORIZATION_H */
 
     if (auth_str[0])
     {
@@ -3294,6 +3310,14 @@ get_cdsa_certificate(cupsd_client_t *con)        /* I - Client connection */
   ssl_options.ServerName = con->servername;
   ssl_options.ServerNameLen = strlen(con->servername);
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG,
+                  "get_cdsa_certificate: Looking for certs for \"%s\"...",
+                 con->servername);
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG,
+                  "get_cdsa_certificate: Looking for certs for \"%s\"...",
+                 con->servername);
+
   options.Data = (uint8 *)&ssl_options;
   options.Length = sizeof(ssl_options);
 
@@ -3985,7 +4009,7 @@ make_certificate(cupsd_client_t *con)     /* I - Client connection */
     envp[envc++] = home;
     envp[envc]   = NULL;
 
-    if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, -1, 1, NULL,
+    if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, -1, 1, NULL, 0,
                            NULL, &pid))
     {
       unlink(seedfile);
@@ -4385,12 +4409,7 @@ pipe_command(cupsd_client_t *con,        /* I - Client connection */
                server_name[1024],      /* SERVER_NAME environment variable */
                server_port[1024];      /* SERVER_PORT environment variable */
   ipp_attribute_t *attr;               /* attributes-natural-language attribute */
-#ifdef HAVE_GSSAPI
-  krb5_ccache  ccache = NULL;          /* Kerberos credentials */
-#  if defined(HAVE_KRB5_CC_NEW_UNIQUE) || defined(HAVE_HEIMDAL)
-  char         krb5ccname[1024];       /* KRB5CCNAME environment variable */
-#  endif /* HAVE_KRB5_CC_NEW_UNIQUE || HAVE_HEIMDAL */
-#endif /* HAVE_GSSAPI */
+  void         *ccache = NULL;         /* Kerberos credentials */
 
 
  /*
@@ -4618,133 +4637,8 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
     */
 
 #ifdef HAVE_GSSAPI
-    if (con->gss_have_creds)
-    {
-#  if !defined(HAVE_KRB5_CC_NEW_UNIQUE) && !defined(HAVE_HEIMDAL)
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                     "[CGI] Sorry, your version of Kerberos does not support "
-                     "delegated credentials!");
-
-#  else
-      krb5_error_code  error;          /* Kerberos error code */
-      OM_uint32                major_status,   /* Major status code */
-                       minor_status;   /* Minor status code */
-      krb5_principal   principal;      /* Kerberos principal */
-
-
-#   ifdef __APPLE__
-     /*
-      * If the weak-linked GSSAPI/Kerberos library is not present, don't try
-      * to use it...
-      */
-
-      if (krb5_init_context != NULL)
-      {
-#    endif /* __APPLE__ */
-
-      if (!KerberosInitialized)
-      {
-       /*
-       * Setup a Kerberos context for the scheduler to use...
-       */
-
-        KerberosInitialized = 1;
-
-       if (krb5_init_context(&KerberosContext))
-       {
-         KerberosContext = NULL;
-
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "[CGI] Unable to initialize Kerberos context");
-       }
-      }
-
-     /*
-      * We MUST create a file-based cache because memory-based caches are
-      * only valid for the current process/address space.
-      *
-      * Due to various bugs/features in different versions of Kerberos, we
-      * need either the krb5_cc_new_unique() function or Heimdal's version
-      * of krb5_cc_gen_new() to create a new FILE: credential cache that
-      * can be passed to the backend.  These functions create a temporary
-      * file (typically in /tmp) containing the cached credentials, which
-      * are removed when we have successfully printed a job.
-      */
-
-      if (KerberosContext)
-      {
-#    ifdef HAVE_KRB5_CC_NEW_UNIQUE
-       if ((error = krb5_cc_new_unique(KerberosContext, "FILE", NULL,
-                                       &ccache)) != 0)
-#    else /* HAVE_HEIMDAL */
-       if ((error = krb5_cc_gen_new(KerberosContext, &krb5_fcc_ops,
-                                    &ccache)) != 0)
-#    endif /* HAVE_KRB5_CC_NEW_UNIQUE */
-       {
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "[CGI] Unable to create new credentials cache (%d/%s)",
-                         error, strerror(errno));
-         ccache = NULL;
-       }
-       else if ((error = krb5_parse_name(KerberosContext, con->username,
-                                         &principal)) != 0)
-       {
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "[CGI] Unable to parse kerberos username (%d/%s)",
-                         error, strerror(errno));
-         krb5_cc_destroy(KerberosContext, ccache);
-         ccache = NULL;
-       }
-       else if ((error = krb5_cc_initialize(KerberosContext, ccache,
-                                            principal)))
-       {
-         cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "[CGI] Unable to initialize credentials cache (%d/%s)",
-                         error, strerror(errno));
-         krb5_cc_destroy(KerberosContext, ccache);
-         krb5_free_principal(KerberosContext, principal);
-         ccache = NULL;
-       }
-       else
-       {
-         krb5_free_principal(KerberosContext, principal);
-
-        /*
-         * Copy the user's credentials to the new cache file...
-         */
-
-         major_status = gss_krb5_copy_ccache(&minor_status,
-                                             con->gss_delegated_cred, ccache);
-
-         if (GSS_ERROR(major_status))
-         {
-           cupsdLogGSSMessage(CUPSD_LOG_ERROR, major_status, minor_status,
-                              "[CGI] Unable to import client credentials "
-                              "cache");
-           krb5_cc_destroy(KerberosContext, ccache);
-           ccache = NULL;
-         }
-         else
-         {
-          /*
-           * Add the KRB5CCNAME environment variable to the job so that the
-           * backend can use the credentials when printing.
-           */
-
-           snprintf(krb5ccname, sizeof(krb5ccname), "KRB5CCNAME=FILE:%s",
-                    krb5_cc_get_name(KerberosContext, ccache));
-           envp[envc++] = krb5ccname;
-
-           if (!RunUser)
-             chown(krb5_cc_get_name(KerberosContext, ccache), User, Group);
-         }
-       }
-     }
-#    ifdef __APPLE__
-     }
-#    endif /* __APPLE__ */
-#  endif /* HAVE_KRB5_CC_NEW_UNIQUE || HAVE_HEIMDAL */
-    }
+    if (con->gss_creds)
+      ccache = cupsdCopyKrb5Creds(con);
 #endif /* HAVE_GSSAPI */
   }
 
@@ -4861,11 +4755,7 @@ pipe_command(cupsd_client_t *con,        /* I - Client connection */
     */
 
     if (con->username[0])
-#ifdef HAVE_GSSAPI
       cupsdAddCert(pid, con->username, ccache);
-#else
-      cupsdAddCert(pid, con->username, NULL);
-#endif /* HAVE_GSSAPI */
 
     cupsdLogMessage(CUPSD_LOG_DEBUG, "[CGI] Started %s (PID %d)", command, pid);
 
@@ -4877,6 +4767,165 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
 }
 
 
+/*
+ * 'valid_host()' - Is the Host: field valid?
+ */
+
+static int                             /* O - 1 if valid, 0 if not */
+valid_host(cupsd_client_t *con)                /* I - Client connection */
+{
+  cupsd_alias_t        *a;                     /* Current alias */
+  cupsd_netif_t        *netif;                 /* Current network interface */
+  const char   *host,                  /* Host field */
+               *end;                   /* End character */
+
+
+  host = con->http.fields[HTTP_FIELD_HOST];
+
+  if (httpAddrLocalhost(con->http.hostaddr))
+  {
+   /*
+    * Only allow "localhost" or the equivalent IPv4 or IPv6 numerical
+    * addresses when accessing CUPS via the loopback interface...
+    */
+
+    return (!strcasecmp(host, "localhost") ||
+            !strncasecmp(host, "localhost:", 10) ||
+           !strcasecmp(host, "localhost.") ||
+            !strncasecmp(host, "localhost.:", 11) ||
+#ifdef __linux
+           !strcasecmp(host, "localhost.localdomain") ||
+            !strncasecmp(host, "localhost.localdomain:", 22) ||
+#endif /* __linux */
+            !strcmp(host, "127.0.0.1") ||
+           !strncmp(host, "127.0.0.1:", 10) ||
+           !strcmp(host, "[::1]") ||
+           !strncmp(host, "[::1]:", 6));
+  }
+
+#ifdef HAVE_DNSSD
+ /*
+  * Check if the hostname is something.local (Bonjour); if so, allow it.
+  */
+
+  if ((end = strrchr(host, '.')) != NULL &&
+      (!strcasecmp(end, ".local") || !strncasecmp(end, ".local:", 7) ||
+       !strcasecmp(end, ".local.") || !strncasecmp(end, ".local.:", 8)))
+    return (1);
+#endif /* HAVE_DNSSD */
+
+ /*
+  * Check if the hostname is an IP address...
+  */
+
+  if (isdigit(*host & 255) || *host == '[')
+  {
+   /*
+    * Possible IPv4/IPv6 address...
+    */
+
+    char       temp[1024],             /* Temporary string */
+               *ptr;                   /* Pointer into temporary string */
+    http_addrlist_t *addrlist;         /* List of addresses */
+
+
+    strlcpy(temp, host, sizeof(temp));
+    if ((ptr = strrchr(temp, ':')) != NULL && !strchr(ptr, ']'))
+      *ptr = '\0';                     /* Strip :port from host value */
+
+    if ((addrlist = httpAddrGetList(temp, AF_UNSPEC, NULL)) != NULL)
+    {
+     /*
+      * Good IPv4/IPv6 address...
+      */
+
+      httpAddrFreeList(addrlist);
+      return (1);
+    }
+  }
+
+ /*
+  * Check for (alias) name matches...
+  */
+
+  for (a = (cupsd_alias_t *)cupsArrayFirst(ServerAlias);
+       a;
+       a = (cupsd_alias_t *)cupsArrayNext(ServerAlias))
+  {
+   /*
+    * "ServerAlias *" allows all host values through...
+    */
+
+    if (!strcmp(a->name, "*"))
+      return (1);
+
+    if (!strncasecmp(host, a->name, a->namelen))
+    {
+     /*
+      * Prefix matches; check the character at the end - it must be ":", ".",
+      * ".:", or nul...
+      */
+
+      end = host + a->namelen;
+
+      if (!*end || *end == ':' || (*end == '.' && (!end[1] || end[1] == ':')))
+        return (1);
+    }
+  }
+
+#ifdef HAVE_DNSSD
+  for (a = (cupsd_alias_t *)cupsArrayFirst(DNSSDAlias);
+       a;
+       a = (cupsd_alias_t *)cupsArrayNext(DNSSDAlias))
+  {
+   /*
+    * "ServerAlias *" allows all host values through...
+    */
+
+    if (!strcmp(a->name, "*"))
+      return (1);
+
+    if (!strncasecmp(host, a->name, a->namelen))
+    {
+     /*
+      * Prefix matches; check the character at the end - it must be ":", ".",
+      * ".:", or nul...
+      */
+
+      end = host + a->namelen;
+
+      if (!*end || *end == ':' || (*end == '.' && (!end[1] || end[1] == ':')))
+        return (1);
+    }
+  }
+#endif /* HAVE_DNSSD */
+
+ /*
+  * Check for interface hostname matches...
+  */
+
+  for (netif = (cupsd_netif_t *)cupsArrayFirst(NetIFList);
+       netif;
+       netif = (cupsd_netif_t *)cupsArrayNext(NetIFList))
+  {
+    if (!strncasecmp(host, netif->hostname, netif->hostlen))
+    {
+     /*
+      * Prefix matches; check the character at the end - it must be ":", ".",
+      * ".:", or nul...
+      */
+
+      end = host + netif->hostlen;
+
+      if (!*end || *end == ':' || (*end == '.' && (!end[1] || end[1] == ':')))
+        return (1);
+    }
+  }
+
+  return (0);
+}
+
+
 /*
  * 'write_file()' - Send a file via HTTP.
  */
index 0ad9b1d19b2f046554c037240ddbf0edafdc82ce..f807e9c109a8d6db1f10aaea236b69d45c6aae0c 100644 (file)
@@ -54,11 +54,10 @@ struct cupsd_client_s
   char                 servername[256];/* Server name for connection */
   int                  serverport;     /* Server port for connection */
 #ifdef HAVE_GSSAPI
-  int                  gss_have_creds; /* Have authenticated credentials */
+  gss_cred_id_t        gss_creds;      /* Credentials from client header */
+  unsigned             gss_flags;      /* Credential flags */
   gss_buffer_desc      gss_output_token;
                                        /* Output token for Negotiate header */
-  gss_cred_id_t        gss_delegated_cred;
-                                       /* Credentials from client header */
 #endif /* HAVE_GSSAPI */
 #ifdef HAVE_AUTHORIZATION_H
   AuthorizationRef     authref;        /* Authorization ref */
index 617291a7c993b52d1ad1fb1126af878b601055a8..a020fa610ab0c48b3f6a8e4fbb8523b2897e218a 100644 (file)
  *
  * Contents:
  *
+ *   cupsdAddAlias()          - Add a host alias.
  *   cupsdCheckPermissions()  - Fix the mode and ownership of a file or
  *                              directory.
+ *   cupsdFreeAliases()       - Free all of the alias entries.
  *   cupsdReadConfiguration() - Read the cupsd.conf file.
  *   get_address()            - Get an address + port number from a line.
  *   get_addr_and_mask()      - Get an IP address and netmask.
- *   parse_aaa()              - Parse authentication, authorization, and
- *                              access control lines.
+ *   parse_aaa()              - Parse authentication, authorization, and access
+ *                              control lines.
  *   parse_fatal_errors()     - Parse FatalErrors values in a string.
  *   parse_groups()           - Parse system group names in a string.
  *   parse_protocols()        - Parse browse protocols in a string.
@@ -116,9 +118,6 @@ static const cupsd_var_t    variables[] =
   { "FilterLimit",             &FilterLimit,           CUPSD_VARTYPE_INTEGER },
   { "FilterNice",              &FilterNice,            CUPSD_VARTYPE_INTEGER },
   { "FontPath",                        &FontPath,              CUPSD_VARTYPE_STRING },
-#ifdef HAVE_GSSAPI
-  { "GSSServiceName",          &GSSServiceName,        CUPSD_VARTYPE_STRING },
-#endif /* HAVE_GSSAPI */
   { "HideImplicitMembers",     &HideImplicitMembers,   CUPSD_VARTYPE_BOOLEAN },
   { "ImplicitClasses",         &ImplicitClasses,       CUPSD_VARTYPE_BOOLEAN },
   { "ImplicitAnyClasses",      &ImplicitAnyClasses,    CUPSD_VARTYPE_BOOLEAN },
@@ -198,6 +197,7 @@ static const unsigned       zeros[4] =
 /*
  * Local functions...
  */
+
 static http_addrlist_t *get_address(const char *value, int defport);
 static int             get_addr_and_mask(const char *value, unsigned *ip,
                                          unsigned *mask);
@@ -211,6 +211,30 @@ static int         read_location(cups_file_t *fp, char *name, int linenum);
 static int             read_policy(cups_file_t *fp, char *name, int linenum);
 
 
+/*
+ * 'cupsdAddAlias()' - Add a host alias.
+ */
+
+void
+cupsdAddAlias(cups_array_t *aliases,   /* I - Array of aliases */
+              const char   *name)      /* I - Name to add */
+{
+  cupsd_alias_t        *a;                     /*  New alias */
+  size_t       namelen;                /* Length of name */
+
+
+  namelen = strlen(name);
+
+  if ((a = (cupsd_alias_t *)malloc(sizeof(cupsd_alias_t) + namelen)) == NULL)
+    return;
+
+  a->namelen = namelen;
+  strcpy(a->name, name);               /* OK since a->name is allocated */
+
+  cupsArrayAdd(aliases, a);
+}
+
+
 /*
  * 'cupsdCheckPermissions()' - Fix the mode and ownership of a file or directory.
  */
@@ -362,6 +386,25 @@ cupsdCheckPermissions(
 }
 
 
+/*
+ * 'cupsdFreeAliases()' - Free all of the alias entries.
+ */
+
+void
+cupsdFreeAliases(cups_array_t *aliases)        /* I - Array of aliases */
+{
+  cupsd_alias_t        *a;                     /* Current alias */
+
+
+  for (a = (cupsd_alias_t *)cupsArrayFirst(aliases);
+       a;
+       a = (cupsd_alias_t *)cupsArrayNext(aliases))
+    free(a);
+
+  cupsArrayDelete(aliases);
+}
+
+
 /*
  * 'cupsdReadConfiguration()' - Read the cupsd.conf file.
  */
@@ -434,6 +477,9 @@ cupsdReadConfiguration(void)
   * String options...
   */
 
+  cupsdFreeAliases(ServerAlias);
+  ServerAlias = NULL;
+
   cupsdClearString(&ServerName);
   cupsdClearString(&ServerAdmin);
   cupsdSetString(&ServerBin, CUPS_SERVERBIN);
@@ -453,9 +499,6 @@ cupsdReadConfiguration(void)
   cupsdSetString(&RemoteRoot, "remroot");
   cupsdSetString(&ServerHeader, "CUPS/1.4");
   cupsdSetString(&StateDir, CUPS_STATEDIR);
-#ifdef HAVE_GSSAPI
-  cupsdSetString(&GSSServiceName, CUPS_DEFAULT_GSSSERVICENAME);
-#endif /* HAVE_GSSAPI */
 
   if (!strcmp(CUPS_DEFAULT_PRINTCAP, "/etc/printers.conf"))
     PrintcapFormat = PRINTCAP_SOLARIS;
@@ -673,9 +716,7 @@ cupsdReadConfiguration(void)
 
   if (!ServerName)
   {
-    if (HostNameLookups || RemoteAccessEnabled)
-      httpGetHostname(NULL, temp, sizeof(temp));
-    else if (gethostname(temp, sizeof(temp)))
+    if (gethostname(temp, sizeof(temp)))
     {
       cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",
                       strerror(errno));
@@ -683,6 +724,50 @@ cupsdReadConfiguration(void)
     }
 
     cupsdSetString(&ServerName, temp);
+
+    if (!ServerAlias)
+      ServerAlias = cupsArrayNew(NULL, NULL);
+
+    cupsdAddAlias(ServerAlias, temp);
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", temp);
+
+    if (HostNameLookups || RemoteAccessEnabled)
+    {
+      struct hostent   *host;          /* Host entry to get FQDN */
+
+      if ((host = gethostbyname(temp)) != NULL)
+      {
+        if (strcasecmp(temp, host->h_name))
+        {
+         cupsdSetString(&ServerName, host->h_name);
+         cupsdAddAlias(ServerAlias, host->h_name);
+          cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
+                         host->h_name);
+       }
+
+        if (host->h_aliases)
+       {
+          for (i = 0; host->h_aliases[i]; i ++)
+           if (strcasecmp(temp, host->h_aliases[i]))
+           {
+             cupsdAddAlias(ServerAlias, host->h_aliases[i]);
+             cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s",
+                             host->h_aliases[i]);
+           }
+       }
+      }
+    }
+
+   /*
+    * Make sure we have the base hostname added as an alias, too!
+    */
+
+    if ((slash = strchr(temp, '.')) != NULL)
+    {
+      *slash = '\0';
+      cupsdAddAlias(ServerAlias, temp);
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", temp);
+    }
   }
 
   for (slash = ServerName; isdigit(*slash & 255) || *slash == '.'; slash ++);
@@ -3035,19 +3120,6 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
       }
     }
 #endif /* HAVE_SSL */
-#ifdef HAVE_GSSAPI
-    else if (!strcasecmp(line, "Krb5Keytab") && value)
-    {
-      cupsdSetStringf(&Krb5Keytab, "KRB5_KTNAME=%s", value);
-      putenv(Krb5Keytab);
-
-#  ifdef HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY
-      gsskrb5_register_acceptor_identity(value);
-#  else
-      cupsdSetEnv("KRB5_KTNAME", value);
-#  endif /* HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY */
-    }
-#endif /* HAVE_GSSAPI */
     else if (!strcasecmp(line, "User") && value)
     {
      /*
@@ -3272,6 +3344,13 @@ read_configuration(cups_file_t *fp)      /* I - File to read from */
            break;
       }
     }
+    else if (!strcasecmp(line, "ServerAlias") && value)
+    {
+      if (!ServerAlias)
+        ServerAlias = cupsArrayNew(NULL, NULL);
+
+      cupsdAddAlias(ServerAlias, value);
+    }
     else if (!strcasecmp(line, "SetEnv") && value)
     {
      /*
index 8139c8b4801d886de75019bf1b5099aa7c313036..d91bca359c7f2b259cade45e460ae26ea66e07dd 100644 (file)
@@ -81,6 +81,17 @@ typedef enum
 #define CUPSD_SSL_NOEMPTY      1       /* Do not insert empty fragments */
 
 
+/*
+ * ServerAlias data...
+ */
+
+typedef struct
+{
+  size_t       namelen;                /* Length of alias name */
+  char         name[1];                /* Alias name */
+} cupsd_alias_t;
+
+
 /*
  * Globals...
  */
@@ -101,6 +112,8 @@ VAR char            *ConfigurationFile      VALUE(NULL),
                                        /* Directory for request files */
                        *DocumentRoot           VALUE(NULL);
                                        /* Root directory for documents */
+VAR cups_array_t       *ServerAlias            VALUE(NULL);
+                                       /* Alias names for server */
 VAR int                        RemoteAccessEnabled     VALUE(0),
                                        /* Are we listening on non-local addresses? */
                        ServerNameIsIP          VALUE(0);
@@ -147,12 +160,6 @@ VAR char           *AccessLog              VALUE(NULL),
                                        /* Remote root user */
                        *Classification         VALUE(NULL);
                                        /* Classification of system */
-#ifdef HAVE_GSSAPI
-VAR char               *GSSServiceName         VALUE(NULL);
-                                       /* GSS service name */
-VAR char               *Krb5Keytab             VALUE(NULL);
-                                       /* Kerberos Keytab */
-#endif /* HAVE_GSSAPI */
 VAR uid_t              User                    VALUE(1);
                                        /* User ID for server */
 VAR gid_t              Group                   VALUE(0);
@@ -265,10 +272,12 @@ VAR char          *SystemGroupAuthKey     VALUE(NULL);
  * Prototypes...
  */
 
+extern void    cupsdAddAlias(cups_array_t *aliases, const char *name);
 extern int     cupsdCheckPermissions(const char *filename,
                                      const char *suffix, int mode,
                                      int user, int group, int is_dir,
                                      int create_dir);
+extern void    cupsdFreeAliases(cups_array_t *aliases);
 extern char    *cupsdGetDateTime(struct timeval *t, cupsd_time_t format);
 #ifdef HAVE_GSSAPI
 extern int     cupsdLogGSSMessage(int level, int major_status,
index c73e99a1486be558569f3723ce69ab31453d0ffa..c9bad58ec9f08ffd83a2162953eeba1e89e0d77b 100644 (file)
@@ -38,6 +38,7 @@
  *   cupsdUpdateLDAPBrowse()    - Scan for new printers via LDAP...
  *   cupsdUpdateSLPBrowse()     - Get browsing information via SLP.
  *   dequote()                  - Remote quotes from a string.
+ *   dnssdAddAlias()            - Add a DNS-SD alias name.
  *   dnssdBuildTxtRecord()      - Build a TXT record from printer info.
  *   dnssdComparePrinters()     - Compare the registered names of two printers.
  *   dnssdDeregisterPrinter()   - Stop sending broadcast information for a
@@ -155,6 +156,10 @@ static void        update_smb(int onoff);
 
 
 #ifdef HAVE_DNSSD
+#  ifdef HAVE_COREFOUNDATION
+static void    dnssdAddAlias(const void *key, const void *value,
+                             void *context);
+#  endif /* HAVE_COREFOUNDATION */
 static char    *dnssdBuildTxtRecord(int *txt_len, cupsd_printer_t *p,
                                     int for_lpd);
 static int     dnssdComparePrinters(cupsd_printer_t *a, cupsd_printer_t *b);
@@ -1896,6 +1901,7 @@ cupsdUpdateDNSSDName(void)
   char         webif[1024];            /* Web interface share name */
 #ifdef HAVE_COREFOUNDATION_H
   SCDynamicStoreRef sc;                        /* Context for dynamic store */
+  CFDictionaryRef btmm;                        /* Back-to-My-Mac domains */
   CFStringRef  nameRef;                /* Computer name CFString */
   char         nameBuffer[1024];       /* C-string buffer */
   CFStringEncoding nameEncoding;       /* Computer name encoding */
@@ -1907,6 +1913,7 @@ cupsdUpdateDNSSDName(void)
   * enabled...
   */
 
+
   if (!DNSSDPort)
     return;
 
@@ -1919,17 +1926,59 @@ cupsdUpdateDNSSDName(void)
 
   if (sc)
   {
+   /*
+    * Get the computer name from the dynamic store...
+    */
+
+    cupsdClearString(&DNSSDName);
+
     if ((nameRef = SCDynamicStoreCopyComputerName(sc,
                                                  &nameEncoding)) != NULL)
     {
       if (CFStringGetCString(nameRef, nameBuffer, sizeof(nameBuffer),
                             kCFStringEncodingUTF8))
+      {
+        cupsdLogMessage(CUPSD_LOG_DEBUG,
+                       "Dynamic store computer name is \"%s\".", nameBuffer);
        cupsdSetString(&DNSSDName, nameBuffer);
+      }
 
       CFRelease(nameRef);
     }
-    else
+
+    if (!DNSSDName)
+    {
+     /*
+      * Use the ServerName instead...
+      */
+
+      cupsdLogMessage(CUPSD_LOG_DEBUG,
+                      "Using ServerName \"%s\" as computer name.", ServerName);
       cupsdSetString(&DNSSDName, ServerName);
+    }
+
+   /*
+    * Get any Back-to-My-Mac domains and add them as aliases...
+    */
+
+    cupsdFreeAliases(DNSSDAlias);
+    DNSSDAlias = NULL;
+
+    btmm = SCDynamicStoreCopyValue(sc, CFSTR("Setup:/Network/BackToMyMac"));
+    if (btmm && CFGetTypeID(btmm) == CFDictionaryGetTypeID())
+    {
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "%d Back to My Mac aliases to add.",
+                     (int)CFDictionaryGetCount(btmm));
+      CFDictionaryApplyFunction(btmm, dnssdAddAlias, NULL);
+    }
+    else if (btmm)
+      cupsdLogMessage(CUPSD_LOG_ERROR,
+                     "Bad Back to My Mac data in dynamic store!");
+    else
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "No Back to My Mac aliases to add.");
+
+    if (btmm)
+      CFRelease(btmm);
 
     CFRelease(sc);
   }
@@ -2206,6 +2255,41 @@ dequote(char       *d,                   /* I - Destination string */
 
 
 #ifdef HAVE_DNSSD
+#  ifdef HAVE_COREFOUNDATION
+/*
+ * 'dnssdAddAlias()' - Add a DNS-SD alias name.
+ */
+
+static void
+dnssdAddAlias(const void *key,         /* I - Key */
+              const void *value,       /* I - Value (domain) */
+             void       *context)      /* I - Unused */
+{
+  char valueStr[1024],                 /* Domain string */
+       hostname[1024];                 /* Complete hostname */
+
+
+  (void)context;
+
+  if (CFGetTypeID((CFStringRef)value) == CFStringGetTypeID() &&
+      CFStringGetCString((CFStringRef)value, valueStr, sizeof(valueStr),
+                         kCFStringEncodingUTF8))
+  {
+    snprintf(hostname, sizeof(hostname), "%s.%s", DNSSDName, valueStr);
+    if (!DNSSDAlias)
+      DNSSDAlias = cupsArrayNew(NULL, NULL);
+
+    cupsdAddAlias(DNSSDAlias, hostname);
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "Added Back to My Mac ServerAlias %s",
+                   hostname);
+  }
+  else
+    cupsdLogMessage(CUPSD_LOG_ERROR,
+                    "Bad Back to My Mac domain in dynamic store!");
+}
+#  endif /* HAVE_COREFOUNDATION */
+
+
 /*
  * 'dnssdBuildTxtRecord()' - Build a TXT record from printer info.
  */
index 8dfc2d585bb20c225b6893d0a78a772c0f205418..1fae4d3cc6d41b4abdd2727acb09dace7a759ac2 100644 (file)
@@ -4,7 +4,7 @@
  *   Directory services definitions for the Common UNIX Printing System
  *   (CUPS) scheduler.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -135,6 +135,8 @@ VAR cupsd_statbuf_t *PollStatusBuffer VALUE(NULL);
 #ifdef HAVE_DNSSD
 VAR char               *DNSSDName      VALUE(NULL);
                                        /* Computer/server name */
+VAR cups_array_t       *DNSSDAlias     VALUE(NULL);
+                                       /* List of dynamic ServerAlias's */
 VAR int                        DNSSDPort       VALUE(0);
                                        /* Port number to register */
 VAR cups_array_t       *DNSSDPrinters  VALUE(NULL);
index d2ece64c42456aa016bfc71fdd0d2105bb48ea05..536430140e367bfd3aeb7aece2f375c41c17ae4f 100644 (file)
@@ -7615,6 +7615,7 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
   const char   *username;              /* Current user */
   char         *first_printer_name;    /* first-printer-name attribute */
   cups_array_t *ra;                    /* Requested attributes array */
+  int          local;                  /* Local connection? */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printers(%p[%d], %x)", con,
@@ -7672,6 +7673,8 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
   else
     printer_mask = 0;
 
+  local = httpAddrLocalhost(&(con->clientaddr));
+
   if ((attr = ippFindAttribute(con->request, "printer-location",
                                IPP_TAG_TEXT)) != NULL)
     location = attr->values[0].string.text;
@@ -7704,6 +7707,9 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
        count < limit && printer;
        printer = (cupsd_printer_t *)cupsArrayNext(Printers))
   {
+    if (!local && !printer->shared)
+      continue;
+
     if ((!type || (printer->type & CUPS_PRINTER_CLASS) == type) &&
         (printer->type & printer_mask) == printer_type &&
        (!location ||
@@ -9582,7 +9588,7 @@ save_auth_info(
   cupsFileClose(fp);
 
 #if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
-  if (con->gss_have_creds)
+  if (con->gss_creds)
     save_krb5_creds(con, job);
   else if (job->ccname)
     cupsdClearString(&(job->ccname));
@@ -9599,121 +9605,26 @@ static void
 save_krb5_creds(cupsd_client_t *con,   /* I - Client connection */
                 cupsd_job_t    *job)   /* I - Job */
 {
-#  if !defined(HAVE_KRB5_CC_NEW_UNIQUE) && !defined(HAVE_HEIMDAL)
-  cupsdLogMessage(CUPSD_LOG_INFO,
-                  "Sorry, your version of Kerberos does not support delegated "
-                 "credentials!");
-  return;
-
-#  else
-  krb5_error_code      error;          /* Kerberos error code */
-  OM_uint32            major_status,   /* Major status code */
-                       minor_status;   /* Minor status code */
-  krb5_principal       principal;      /* Kerberos principal */
-
-
-#   ifdef __APPLE__
  /*
-  * If the weak-linked GSSAPI/Kerberos library is not present, don't try
-  * to use it...
+  * Get the credentials...
   */
 
-  if (krb5_init_context == NULL)
-    return;
-#    endif /* __APPLE__ */
-
-  if (!KerberosInitialized)
-  {
-   /*
-    * Setup a Kerberos context for the scheduler to use...
-    */
-
-    KerberosInitialized = 1;
-
-    if (krb5_init_context(&KerberosContext))
-    {
-      KerberosContext = NULL;
-
-      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to initialize Kerberos context");
-      return;
-    }
-  }
-
- /*
-  * We MUST create a file-based cache because memory-based caches are
-  * only valid for the current process/address space.
-  *
-  * Due to various bugs/features in different versions of Kerberos, we
-  * need either the krb5_cc_new_unique() function or Heimdal's version
-  * of krb5_cc_gen_new() to create a new FILE: credential cache that
-  * can be passed to the backend.  These functions create a temporary
-  * file (typically in /tmp) containing the cached credentials, which
-  * are removed when we have successfully printed a job.
-  */
-
-#    ifdef HAVE_KRB5_CC_NEW_UNIQUE
-  if ((error = krb5_cc_new_unique(KerberosContext, "FILE", NULL,
-                                  &(job->ccache))) != 0)
-#    else /* HAVE_HEIMDAL */
-  if ((error = krb5_cc_gen_new(KerberosContext, &krb5_fcc_ops,
-                               &(job->ccache))) != 0)
-#    endif /* HAVE_KRB5_CC_NEW_UNIQUE */
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "Unable to create new credentials cache (%d/%s)",
-                    error, strerror(errno));
-    job->ccache = NULL;
-    return;
-  }
-
-  if ((error = krb5_parse_name(KerberosContext, con->username, &principal)) != 0)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to parse kerberos username (%d/%s)",
-                    error, strerror(errno));
-    krb5_cc_destroy(KerberosContext, job->ccache);
-    job->ccache = NULL;
-    return;
-  }
-
-  if ((error = krb5_cc_initialize(KerberosContext, job->ccache, principal)))
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "Unable to initialize credentials cache (%d/%s)", error,
-                   strerror(errno));
-    krb5_cc_destroy(KerberosContext, job->ccache);
-    krb5_free_principal(KerberosContext, principal);
-    job->ccache = NULL;
-    return;
-  }
-
-  krb5_free_principal(KerberosContext, principal);
-
- /*
-  * Copy the user's credentials to the new cache file...
-  */
-
-  major_status = gss_krb5_copy_ccache(&minor_status, con->gss_delegated_cred,
-                                     job->ccache);
-
-  if (GSS_ERROR(major_status))
-  {
-    cupsdLogGSSMessage(CUPSD_LOG_ERROR, major_status, minor_status,
-                       "Unable to import client credentials cache");
-    krb5_cc_destroy(KerberosContext, job->ccache);
-    job->ccache = NULL;
-    return;
-  }
+  job->ccache = cupsdCopyKrb5Creds(con);
 
  /*
   * Add the KRB5CCNAME environment variable to the job so that the
   * backend can use the credentials when printing.
   */
 
-  cupsdSetStringf(&(job->ccname), "KRB5CCNAME=FILE:%s",
-                  krb5_cc_get_name(KerberosContext, job->ccache));
+  if (job->ccache)
+  {
+    cupsdSetStringf(&(job->ccname), "KRB5CCNAME=FILE:%s",
+                   krb5_cc_get_name(KerberosContext, job->ccache));
 
-  cupsdLogJob(job, CUPSD_LOG_DEBUG2, "save_krb5_creds: %s", job->ccname);
-#  endif /* HAVE_KRB5_CC_NEW_UNIQUE || HAVE_HEIMDAL */
+    cupsdLogJob(job, CUPSD_LOG_DEBUG2, "save_krb5_creds: %s", job->ccname);
+  }
+  else
+    cupsdClearString(&(job->ccname));
 }
 #endif /* HAVE_GSSAPI && HAVE_KRB5_H */
 
index d1be75f697ea9a561da028b7104e55e7d9cd0a58..c0aa5b0d610c2aece718d9434608ff69f0d1d83a 100644 (file)
@@ -331,6 +331,14 @@ cupsdCheckJobs(void)
                        "Job submission timed out.");
     }
 
+   /*
+    * Continue jobs that are waiting on the FilterLimit...
+    */
+
+    if (job->pending_cost > 0 &&
+       ((FilterLevel + job->pending_cost) < FilterLimit || FilterLevel == 0))
+      cupsdContinueJob(job);
+
    /*
     * Start pending jobs if the destination is available...
     */
@@ -441,7 +449,7 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
 {
   int                  i;              /* Looping var */
   int                  slot;           /* Pipe slot */
-  cups_array_t         *filters,       /* Filters for job */
+  cups_array_t         *filters = NULL,/* Filters for job */
                        *prefilters;    /* Filters with prefilters */
   mime_filter_t                *filter,        /* Current filter */
                        *prefilter,     /* Prefilter */
@@ -450,13 +458,16 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
   ipp_attribute_t      *attr;          /* Current attribute */
   const char           *ptr,           /* Pointer into value */
                        *abort_message; /* Abort message */
+  ipp_jstate_t         abort_state = IPP_JOB_ABORTED;
+                                       /* New job state on abort */
   struct stat          backinfo;       /* Backend file information */
   int                  backroot;       /* Run backend as root? */
   int                  pid;            /* Process ID of new filter process */
   int                  banner_page;    /* 1 if banner page, 0 otherwise */
-  int                  filterfds[2][2];/* Pipes used between filters */
+  int                  filterfds[2][2] = { { -1, -1 }, { -1, -1 } };
+                                       /* Pipes used between filters */
   int                  envc;           /* Number of environment variables */
-  char                 **argv,         /* Filter command-line arguments */
+  char                 **argv = NULL,  /* Filter command-line arguments */
                        filename[1024], /* Job filename */
                        command[1024],  /* Full path to command */
                        jobid[255],     /* Job ID string */
@@ -503,7 +514,11 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
 
   FilterLevel -= job->cost;
 
-  filters = NULL;
+  job->cost         = 0;
+  job->pending_cost = 0;
+
+  memset(job->filters, 0, sizeof(job->filters));
+
 
   if (job->printer->raw)
   {
@@ -513,8 +528,6 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
     */
 
     cupsdLogJob(job, CUPSD_LOG_DEBUG, "Sending job to queue tagged as raw...");
-
-    filters = NULL;
   }
   else
   {
@@ -531,13 +544,8 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
                  "Unable to convert file %d to printable format!",
                  job->current_file);
 
-      job->current_file ++;
-
-      if (job->current_file == job->num_files)
-        cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT,
-                        "Aborting job because it cannot be printed.");
-
-      return;
+      abort_message = "Aborting job because it cannot be printed.";
+      goto abort_job;
     }
 
    /*
@@ -611,6 +619,9 @@ cupsdContinueJob(cupsd_job_t *job)  /* I - Job */
                "cupsdContinueJob: file=%d, cost=%d, level=%d, limit=%d",
                job->current_file, job->cost, FilterLevel,
                FilterLimit);
+
+    job->pending_cost = job->cost;
+    job->cost         = 0;
     return;
   }
 
@@ -638,12 +649,10 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
 
       cupsArrayDelete(filters);
 
-      cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
-                      "Stopping job because the scheduler ran out of "
-                      "memory.");
+      abort_state = IPP_JOB_STOPPED;
+      abort_message = "Stopping job because the scheduler ran out of memory.";
 
-      FilterLevel -= job->cost;
-      return;
+      goto abort_job;
     }
   }
 
@@ -672,14 +681,10 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
       cupsdLogJob(job, CUPSD_LOG_DEBUG,
                  "Unable to add port monitor - %s", strerror(errno));
 
-      cupsArrayDelete(filters);
-
-      cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
-                      "Stopping job because the scheduler ran out of "
-                      "memory.");
+      abort_state   = IPP_JOB_STOPPED;
+      abort_message = "Stopping job because the scheduler ran out of memory.";
 
-      FilterLevel -= job->cost;
-      return;
+      goto abort_job;
     }
   }
 
@@ -693,13 +698,8 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
                "Too many filters (%d > %d), unable to print!",
                cupsArrayCount(filters), MAX_FILTERS);
 
-    cupsArrayDelete(filters);
-    cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
-                    "Stopping job because it needs too many filters to "
-                    "print.");
-
-    FilterLevel -= job->cost;
-    return;
+    abort_message = "Aborting job because it needs too many filters to print.";
+    goto abort_job;
   }
 
  /*
@@ -739,12 +739,10 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
   if ((options = get_options(job, banner_page, copies, sizeof(copies), title,
                              sizeof(title))) == NULL)
   {
-    cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
-                    "Stopping job because the scheduler ran out of memory.");
-    cupsArrayDelete(filters);
+    abort_state   = IPP_JOB_STOPPED;
+    abort_message = "Stopping job because the scheduler ran out of memory.";
 
-    FilterLevel -= job->cost;
-    return;
+    goto abort_job;
   }
 
  /*
@@ -774,12 +772,11 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
   {
     cupsdLogMessage(CUPSD_LOG_DEBUG, "Unable to allocate argument array - %s",
                     strerror(errno));
-    cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
-                    "Stopping job because the scheduler ran out of memory.");
-    cupsArrayDelete(filters);
 
-    FilterLevel -= job->cost;
-    return;
+    abort_state   = IPP_JOB_STOPPED;
+    abort_message = "Stopping job because the scheduler ran out of memory.";
+
+    goto abort_job;
   }
 
   sprintf(jobid, "%d", job->id);
@@ -966,13 +963,6 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
   * Now create processes for all of the filters...
   */
 
-  filterfds[0][0] = -1;
-  filterfds[0][1] = -1;
-  filterfds[1][0] = -1;
-  filterfds[1][1] = -1;
-
-  memset(job->filters, 0, sizeof(job->filters));
-
   for (i = 0, slot = 0, filter = (mime_filter_t *)cupsArrayFirst(filters);
        filter;
        i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
@@ -1165,8 +1155,10 @@ cupsdContinueJob(cupsd_job_t *job)       /* I - Job */
   * the missing and insecure warnings...
   */
 
-  cupsdSetPrinterReasons(job->printer, "-cups-missing-filter-warning,"
-                                      "cups-insecure-filter-warning");
+  if (cupsdSetPrinterReasons(job->printer, "-cups-missing-filter-warning,"
+                                          "cups-insecure-filter-warning"))
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, job->printer, NULL,
+                  "Printer drivers now functional.");
 
   return;
 
@@ -1178,25 +1170,50 @@ cupsdContinueJob(cupsd_job_t *job)      /* I - Job */
 
   abort_job:
 
+  FilterLevel -= job->cost;
+  job->cost = 0;
+
   for (slot = 0; slot < 2; slot ++)
     cupsdClosePipe(filterfds[slot]);
 
+  cupsArrayDelete(filters);
+
+  if (argv)
+  {
+    if (job->printer->remote && job->num_files > 1)
+    {
+      for (i = 0; i < job->num_files; i ++)
+       free(argv[i + 6]);
+    }
+
+    free(argv);
+  }
+
+  cupsdClosePipe(job->print_pipes);
+  cupsdClosePipe(job->back_pipes);
+  cupsdClosePipe(job->side_pipes);
+
+  cupsdRemoveSelect(job->status_pipes[0]);
   cupsdClosePipe(job->status_pipes);
   cupsdStatBufDelete(job->status_buffer);
   job->status_buffer = NULL;
 
-  cupsArrayDelete(filters);
+ /*
+  * Update the printer and job state.
+  */
 
-  if (job->printer->remote && job->num_files > 1)
-  {
-    for (i = 0; i < job->num_files; i ++)
-      free(argv[i + 6]);
-  }
+  cupsdSetJobState(job, abort_state, CUPSD_JOB_DEFAULT, "%s", abort_message);
+  cupsdSetPrinterState(job->printer, IPP_PRINTER_IDLE, 0);
+  update_job_attrs(job, 0);
 
-  free(argv);
+  cupsArrayRemove(PrintingJobs, job);
 
-  cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT, "%s",
-                   abort_message);
+ /*
+  * Clear the printer <-> job association...
+  */
+
+  job->printer->job = NULL;
+  job->printer      = NULL;
 }
 
 
@@ -2359,6 +2376,13 @@ cupsdSetJobState(
        break;
   }
 
+ /*
+  * Finalize the job immediately if we forced things...
+  */
+
+  if (action == CUPSD_JOB_FORCE)
+    finalize_job(job);
+
  /*
   * Update the server "busy" state...
   */
@@ -2494,13 +2518,12 @@ finalize_job(cupsd_job_t *job)          /* I - Job */
   * Close pipes and status buffer...
   */
 
-  cupsdRemoveSelect(job->status_buffer->fd);
-
   cupsdClosePipe(job->print_pipes);
   cupsdClosePipe(job->back_pipes);
   cupsdClosePipe(job->side_pipes);
-  cupsdClosePipe(job->status_pipes);
 
+  cupsdRemoveSelect(job->status_pipes[0]);
+  cupsdClosePipe(job->status_pipes);
   cupsdStatBufDelete(job->status_buffer);
   job->status_buffer = NULL;
 
index 498cddb09522ecb0f14bd4cdf96390f5a324f79d..92a4b26acf6320874e80b9973c64bbe0e5bba5a3 100644 (file)
@@ -63,6 +63,7 @@ typedef struct cupsd_job_s
   int                  status_level;   /* Highest log level in a status
                                         * message */
   int                  cost;           /* Filtering cost */
+  int                  pending_cost;   /* Waiting for FilterLimit */
   int                  filters[MAX_FILTERS + 1];
                                        /* Filter process IDs, 0 terminated */
   int                  backend;        /* Backend process ID */
index f3bfd08bd977dd4ceea76fdac24ff11eebaff054..a6ac179aa680389490429fd16ebe4035612754f7 100644 (file)
@@ -525,7 +525,8 @@ cupsdLogRequest(cupsd_client_t *con,        /* I - Request to log */
       return (1);
 
     if (con->request && con->response &&
-        con->response->request.status.status_code < IPP_REDIRECTION_OTHER_SITE)
+        (con->response->request.status.status_code < IPP_REDIRECTION_OTHER_SITE ||
+        con->response->request.status.status_code == IPP_NOT_FOUND))
     {
      /*
       * Check successful requests...
index 9d6b8f8d61aceb847673dce6bfeaa2deb821d1d4..f90e74545c3e50684ce0cf2b11e5f7e9f905f6a4 100644 (file)
@@ -1718,16 +1718,21 @@ process_children(void)
          else
            job->status = -status;      /* Backend failed */
 
-         if ((!(job->printer->type & CUPS_PRINTER_FAX) || job->filters[i]) &&
-             job->status_level > CUPSD_LOG_ERROR)
+         if (job->status_level > CUPSD_LOG_ERROR)
          {
            job->status_level = CUPSD_LOG_ERROR;
 
-           snprintf(job->printer->state_message,
-                    sizeof(job->printer->state_message), "%s failed", name);
-           cupsdAddPrinterHistory(job->printer);
+            if (job->printer)
+           {
+             snprintf(job->printer->state_message,
+                      sizeof(job->printer->state_message), "%s failed", name);
+             cupsdAddPrinterHistory(job->printer);
+           }
+
+           if (!job->attrs)
+             cupsdLoadJob(job);
 
-           if (!job->printer_message)
+           if (!job->printer_message && job->attrs)
            {
              if ((job->printer_message =
                       ippFindAttribute(job->attrs, "job-printer-state-message",
@@ -1738,8 +1743,9 @@ process_children(void)
                                                    NULL, "");
            }
 
-           cupsdSetString(&(job->printer_message->values[0].string.text),
-                          job->printer->state_message);
+           if (job->printer_message)
+             cupsdSetString(&(job->printer_message->values[0].string.text),
+                            job->printer->state_message);
          }
        }
 
index e35c2f0fc8ea64067f6650462be5927cfc785edc..22634d3433cbae82b77ba276288e13bf2f792d07 100644 (file)
@@ -101,6 +101,7 @@ cupsdNetIFUpdate(void)
   struct ifaddrs       *addrs,         /* Interface address list */
                        *addr;          /* Current interface address */
   char                 hostname[1024]; /* Hostname for address */
+  size_t               hostlen;        /* Length of hostname */
 
 
  /*
@@ -176,8 +177,8 @@ cupsdNetIFUpdate(void)
     * Create a new address element...
     */
 
-    if ((temp = calloc(1, sizeof(cupsd_netif_t) +
-                          strlen(hostname))) == NULL)
+    hostlen = strlen(hostname);
+    if ((temp = calloc(1, sizeof(cupsd_netif_t) + hostlen)) == NULL)
       break;
 
    /*
@@ -185,6 +186,7 @@ cupsdNetIFUpdate(void)
     */
 
     strlcpy(temp->name, addr->ifa_name, sizeof(temp->name));
+    temp->hostlen = hostlen;
     strcpy(temp->hostname, hostname);  /* Safe because hostname is allocated */
 
     if (addr->ifa_addr->sa_family == AF_INET)
index dd38e211481fa2ae14eea13c46e372aa468979ec..bbb081ade257dc38da89d3b571fcaf9f27f1cba1 100644 (file)
@@ -4,7 +4,7 @@
  *   Network interface definitions for the Common UNIX Printing System
  *   (CUPS) scheduler.
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -25,6 +25,7 @@ typedef struct cupsd_netif_s          /**** Network interface data ****/
   http_addr_t          address,        /* Network address */
                        mask,           /* Network mask */
                        broadcast;      /* Broadcast address */
+  size_t               hostlen;        /* Length of hostname */
   char                 name[32],       /* Network interface name */
                        hostname[1];    /* Hostname associated with interface */
 } cupsd_netif_t;
index b8cef369f8bd1c656ac0c9b8b1d4acfdf4cd82ee..6b5a70533892b9a561e7aa0542a0b22cc36078bf 100644 (file)
@@ -692,7 +692,12 @@ cupsdDeletePrinter(
   * Stop printing on this printer...
   */
 
-  cupsdStopPrinter(p, update);
+  cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update);
+
+  if (p->job)
+    cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+                     update ? "Job stopped due to printer being deleted." :
+                             "Job stopped.");
 
  /*
   * If this printer is the next for browsing, point to the next one...
@@ -2663,12 +2668,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
  * 'cupsdSetPrinterReasons()' - Set/update the reasons strings.
  */
 
-void
+int                                    /* O - 1 if something changed, 0 otherwise */
 cupsdSetPrinterReasons(
     cupsd_printer_t  *p,               /* I - Printer */
     const char *s)                     /* I - Reasons strings */
 {
-  int          i;                      /* Looping var */
+  int          i,                      /* Looping var */
+               changed = 0;            /* Did something change? */
   const char   *sptr;                  /* Pointer into reasons */
   char         reason[255],            /* Reason string */
                *rptr;                  /* Pointer into reason */
@@ -2697,6 +2703,7 @@ cupsdSetPrinterReasons(
       _cupsStrFree(p->reasons[i]);
 
     p->num_reasons = 0;
+    changed        = 1;
 
     cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
 
@@ -2705,7 +2712,7 @@ cupsdSetPrinterReasons(
   }
 
   if (!strcmp(s, "none"))
-    return;
+    return (changed);
 
  /*
   * Loop through all of the reasons...
@@ -2743,6 +2750,7 @@ cupsdSetPrinterReasons(
          */
 
          p->num_reasons --;
+          changed = 1;
          _cupsStrFree(p->reasons[i]);
 
          if (i < p->num_reasons)
@@ -2778,11 +2786,12 @@ cupsdSetPrinterReasons(
          cupsdLogMessage(CUPSD_LOG_ALERT,
                          "Too many printer-state-reasons values for %s (%d)",
                          p->name, i + 1);
-          return;
+          return (changed);
         }
 
         p->reasons[i] = _cupsStrAlloc(reason);
        p->num_reasons ++;
+        changed = 1;
 
        if (!strcmp(reason, "paused") && p->state != IPP_PRINTER_STOPPED)
          cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, 1);
@@ -2795,6 +2804,8 @@ cupsdSetPrinterReasons(
       }
     }
   }
+
+  return (changed);
 }
 
 
@@ -3578,6 +3589,8 @@ add_printer_filter(
 
     if (stat(filename, &fileinfo))
     {
+      memset(&fileinfo, 0, sizeof(fileinfo));
+
       snprintf(p->state_message, sizeof(p->state_message),
                "Filter \"%s\" for printer \"%s\" not available: %s",
               filename, p->name, strerror(errno));
@@ -3585,8 +3598,6 @@ add_printer_filter(
 
       cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
     }
-    else
-      memset(&fileinfo, 0, sizeof(fileinfo));
 
    /*
     * When running as root, do additional security checks...
@@ -4170,8 +4181,8 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
          val->string.text = _cupsStrAlloc(output_bin->choices[i].choice);
       }
 
-      attr = ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
-                         "output-bin-default", NULL, output_bin->defchoice);
+      ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                  "output-bin-default", NULL, output_bin->defchoice);
     }
 
    /*
index c7b26ee8c445b84fd0d59f14e6718a219950389d..127f9aa41b532a9e757b4dd652da0e38191b2df5 100644 (file)
@@ -160,7 +160,7 @@ extern void         cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri);
 extern void            cupsdSetPrinterAttr(cupsd_printer_t *p,
                                            const char *name, char *value);
 extern void            cupsdSetPrinterAttrs(cupsd_printer_t *p);
-extern void            cupsdSetPrinterReasons(cupsd_printer_t *p,
+extern int             cupsdSetPrinterReasons(cupsd_printer_t *p,
                                               const char *s);
 extern void            cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s,
                                             int update);
index 1b587ca318da04d1fbedd7fb31cfa19577a3c169..53767053fb14acbba758353cd542b76a25cef2a3 100644 (file)
@@ -287,11 +287,16 @@ cupsdStartProcess(
                     strerror(errno));
 
     if (job && job->printer)
-      cupsdSetPrinterReasons(job->printer, "+cups-missing-filter-warning");
+    {
+      if (cupsdSetPrinterReasons(job->printer, "+cups-missing-filter-warning"))
+       cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, job->printer, NULL,
+                     "Printer driver %s is missing.", command);
+    }
 
     return (0);
   }
-  else if (commandinfo.st_mode & (S_ISUID | S_IWOTH))
+  else if ((commandinfo.st_mode & (S_ISUID | S_IWOTH)) ||
+           (!RunUser && commandinfo.st_uid))
   {
     *pid = 0;
 
@@ -306,7 +311,12 @@ cupsdStartProcess(
                    command, commandinfo.st_mode);
 
     if (job && job->printer)
-      cupsdSetPrinterReasons(job->printer, "+cups-insecure-filter-warning");
+    {
+      if (cupsdSetPrinterReasons(job->printer, "+cups-insecure-filter-warning"))
+       cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, job->printer, NULL,
+                     "Printer driver %s has insecure file permissions (0%o).",
+                     command, commandinfo.st_mode);
+    }
 
     errno = EPERM;
 
index be21df3d06dcb7f11e58905fa48cd086019c1692..74f1a034279aed658b905daaf4081b02592e2788 100644 (file)
@@ -216,6 +216,7 @@ static CFRunLoopRef SysEventRunloop = NULL;
                                        /* The runloop. Access must be protected! */
 static CFStringRef     ComputerNameKey = NULL,
                                        /* Computer name key */
+                       BTMMKey = NULL, /* Back to My Mac key */
                        NetworkGlobalKeyIPv4 = NULL,
                                        /* Network global IPv4 key */
                        NetworkGlobalKeyIPv6 = NULL,
@@ -355,7 +356,7 @@ sysEventThreadEntry(void)
   SCDynamicStoreRef    store    = NULL;/* System Config dynamic store */
   CFRunLoopSourceRef   powerRLS = NULL,/* Power runloop source */
                        storeRLS = NULL;/* System Config runloop source */
-  CFStringRef          key[5],         /* System Config keys */
+  CFStringRef          key[6],         /* System Config keys */
                        pattern[2];     /* System Config patterns */
   CFArrayRef           keys = NULL,    /* System Config key array*/
                        patterns = NULL;/* System Config pattern array */
@@ -391,43 +392,47 @@ sysEventThreadEntry(void)
   bzero(&storeContext, sizeof(storeContext));
   storeContext.info = &threadData;
 
-  store = SCDynamicStoreCreate(NULL, CFSTR("cupsd"),
+  store = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("cupsd"),
                                sysEventConfigurationNotifier, &storeContext);
 
   if (!ComputerNameKey)
-    ComputerNameKey = SCDynamicStoreKeyCreateComputerName(NULL);
+    ComputerNameKey = SCDynamicStoreKeyCreateComputerName(kCFAllocatorDefault);
+
+  if (!BTMMKey)
+    BTMMKey = SCDynamicStoreKeyCreate(kCFAllocatorDefault,
+                                      CFSTR("Setup:/Network/BackToMyMac"));
 
   if (!NetworkGlobalKeyIPv4)
     NetworkGlobalKeyIPv4 =
-        SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
+        SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault,
                                                    kSCDynamicStoreDomainState,
                                                   kSCEntNetIPv4);
 
   if (!NetworkGlobalKeyIPv6)
     NetworkGlobalKeyIPv6 =
-        SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
+        SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault,
                                                    kSCDynamicStoreDomainState,
                                                   kSCEntNetIPv6);
 
   if (!NetworkGlobalKeyDNS)
     NetworkGlobalKeyDNS = 
-       SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL
+       SCDynamicStoreKeyCreateNetworkGlobalEntity(kCFAllocatorDefault
                                                   kSCDynamicStoreDomainState,
                                                   kSCEntNetDNS);
 
   if (!HostNamesKey)
-    HostNamesKey = SCDynamicStoreKeyCreateHostNames(NULL);
+    HostNamesKey = SCDynamicStoreKeyCreateHostNames(kCFAllocatorDefault);
 
   if (!NetworkInterfaceKeyIPv4)
     NetworkInterfaceKeyIPv4 =
-        SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
+        SCDynamicStoreKeyCreateNetworkInterfaceEntity(kCFAllocatorDefault,
                                                      kSCDynamicStoreDomainState,
                                                      kSCCompAnyRegex,
                                                      kSCEntNetIPv4);
 
   if (!NetworkInterfaceKeyIPv6)
     NetworkInterfaceKeyIPv6 =
-        SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL,
+        SCDynamicStoreKeyCreateNetworkInterfaceEntity(kCFAllocatorDefault,
                                                      kSCDynamicStoreDomainState,
                                                      kSCCompAnyRegex,
                                                      kSCEntNetIPv6);
@@ -437,27 +442,28 @@ sysEventThreadEntry(void)
       NetworkInterfaceKeyIPv4 && NetworkInterfaceKeyIPv6)
   {
     key[0]     = ComputerNameKey;
-    key[1]     = NetworkGlobalKeyIPv4;
-    key[2]     = NetworkGlobalKeyIPv6;
-    key[3]     = NetworkGlobalKeyDNS;
-    key[4]     = HostNamesKey;
+    key[1]     = BTMMKey;
+    key[2]     = NetworkGlobalKeyIPv4;
+    key[3]     = NetworkGlobalKeyIPv6;
+    key[4]     = NetworkGlobalKeyDNS;
+    key[5]     = HostNamesKey;
 
     pattern[0] = NetworkInterfaceKeyIPv4;
     pattern[1] = NetworkInterfaceKeyIPv6;
 
-    keys     = CFArrayCreate(NULL, (const void **)key,
-                                    sizeof(key) / sizeof(key[0]),
-                                   &kCFTypeArrayCallBacks);
+    keys     = CFArrayCreate(kCFAllocatorDefault, (const void **)key,
+                            sizeof(key) / sizeof(key[0]),
+                            &kCFTypeArrayCallBacks);
 
-    patterns = CFArrayCreate(NULL, (const void **)pattern,
+    patterns = CFArrayCreate(kCFAllocatorDefault, (const void **)pattern,
                              sizeof(pattern) / sizeof(pattern[0]),
                             &kCFTypeArrayCallBacks);
 
     if (keys && patterns &&
         SCDynamicStoreSetNotificationKeys(store, keys, patterns))
     {
-      if ((storeRLS = SCDynamicStoreCreateRunLoopSource(NULL, store, 0))
-              != NULL)
+      if ((storeRLS = SCDynamicStoreCreateRunLoopSource(kCFAllocatorDefault,
+                                                        store, 0)) != NULL)
       {
        CFRunLoopAddSource(CFRunLoopGetCurrent(), storeRLS,
                           kCFRunLoopDefaultMode);
@@ -491,7 +497,7 @@ sysEventThreadEntry(void)
   timerContext.info = &threadData;
 
   threadData.timerRef =
-      CFRunLoopTimerCreate(NULL,
+      CFRunLoopTimerCreate(kCFAllocatorDefault,
                            CFAbsoluteTimeGetCurrent() + (86400L * 365L * 10L), 
                           86400L * 365L * 10L, 0, 0, sysEventTimerNotifier,
                           &timerContext);
@@ -595,9 +601,9 @@ sysEventPowerNotifier(
 
     case kIOMessageSystemWillNotPowerOff:
     case kIOMessageSystemWillNotSleep:
-#ifdef kIOMessageSystemWillPowerOn
+#  ifdef kIOMessageSystemWillPowerOn
     case kIOMessageSystemWillPowerOn:
-#endif /* kIOMessageSystemWillPowerOn */
+#  endif /* kIOMessageSystemWillPowerOn */
     default:
        sendit = 0;
        break;
@@ -634,7 +640,7 @@ sysEventPowerNotifier(
 
 
 /*
- * 'sysEventConfigurationNotifier()' - Computer name changed notification
+ * 'sysEventConfigurationNotifier()' - Network configuration change notification
  *                                     callback.
  */
 
@@ -653,7 +659,8 @@ sysEventConfigurationNotifier(
 
   CFRange range = CFRangeMake(0, CFArrayGetCount(changedKeys));
 
-  if (CFArrayContainsValue(changedKeys, range, ComputerNameKey))
+  if (CFArrayContainsValue(changedKeys, range, ComputerNameKey) ||
+      CFArrayContainsValue(changedKeys, range, BTMMKey))
     threadData->sysevent.event |= SYSEVENT_NAMECHANGED;
   else
   {
@@ -845,7 +852,8 @@ sysUpdate(void)
     {
       if (!Sleeping)
       {
-        cupsdLogMessage(CUPSD_LOG_DEBUG, "Computer name changed");
+        cupsdLogMessage(CUPSD_LOG_DEBUG,
+                       "Computer name or BTMM domains changed");
 
        /*
        * De-register the individual printers...
@@ -857,7 +865,7 @@ sysUpdate(void)
          cupsdDeregisterPrinter(p, 1);
 
        /*
-        * Update the computer name...
+        * Update the computer name and BTMM domain list...
        */
 
        cupsdUpdateDNSSDName();
@@ -876,7 +884,8 @@ sysUpdate(void)
       }
       else
         cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "Computer name changed; ignored while sleeping");
+                       "Computer name or BTMM domains changed; ignored while "
+                       "sleeping");
     }
   }
 }
index 58cc4ffa00873b2aa6a2a4c1e669fbc377ddac95..67cb557e15da5fd2efd5bc95468eae914acd4dd0 100644 (file)
@@ -3,7 +3,7 @@
 #
 #   System V commands makefile for the Common UNIX Printing System (CUPS).
 #
-#   Copyright 2007-2008 by Apple Inc.
+#   Copyright 2007-2009 by Apple Inc.
 #   Copyright 1997-2006 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -49,7 +49,7 @@ unittests:
 
 clean:
        $(RM) $(OBJS) $(TARGETS)
-       $(RM) accept cupsdisable cupsenable cupsreject reject
+       $(RM) accept cupsdisable cupsenable cupsreject disable enable reject
 
 
 #
@@ -79,27 +79,33 @@ install-data:
 #
 
 install-exec:
+       echo Installing System V admin printing commands in $(SBINDIR)
        $(INSTALL_DIR) -m 755 $(SBINDIR)
-       $(INSTALL_BIN) accept $(SBINDIR)
-       $(RM) $(SBINDIR)/reject
-       $(LN) accept $(SBINDIR)/reject
+       $(INSTALL_BIN) cupsaccept $(SBINDIR)
        $(INSTALL_BIN) cupsaddsmb $(SBINDIR)
        $(INSTALL_BIN) cupsctl $(SBINDIR)
        $(INSTALL_BIN) lpadmin $(SBINDIR)
        $(INSTALL_BIN) lpinfo $(SBINDIR)
        $(INSTALL_BIN) lpmove $(SBINDIR)
+       $(RM) $(SBINDIR)/accept
+       $(LN) cupsaccept $(SBINDIR)/accept
+       $(RM) $(SBINDIR)/cupsdisable
+       $(LN) cupsaccept $(SBINDIR)/cupsdisable
+       $(RM) $(SBINDIR)/cupsenable
+       $(LN) cupsaccept $(SBINDIR)/cupsenable
+       $(RM) $(SBINDIR)/cupsreject
+       $(LN) cupsaccept $(SBINDIR)/cupsreject
+       $(RM) $(SBINDIR)/reject
+       $(LN) cupsaccept $(SBINDIR)/reject
+       echo Installing System V user printing commands in $(BINDIR)
        $(INSTALL_DIR) -m 755 $(BINDIR)
        $(INSTALL_BIN) cancel $(BINDIR)
        $(INSTALL_BIN) cupstestdsc $(BINDIR)
        $(INSTALL_BIN) cupstestppd $(BINDIR)
-       $(RM) $(SBINDIR)/cupsaccept
-       $(LN) accept $(SBINDIR)/cupsaccept
-       $(RM) $(SBINDIR)/cupsdisable
-       $(LN) accept $(SBINDIR)/cupsdisable
-       $(RM) $(SBINDIR)/cupsenable
-       $(LN) accept $(SBINDIR)/cupsenable
-       $(RM) $(SBINDIR)/cupsreject
-       $(LN) accept $(SBINDIR)/cupsreject
+       $(RM) $(BINDIR)/disable
+       $(LN) cupsaccept $(BINDIR)/disable
+       $(RM) $(BINDIR)/enable
+       $(LN) cupsaccept $(BINDIR)/enable
        $(INSTALL_BIN) lp $(BINDIR)
        $(INSTALL_BIN) lpoptions $(BINDIR)
        $(INSTALL_BIN) lpstat $(BINDIR)
@@ -134,12 +140,15 @@ uninstall:
        $(RM) $(BINDIR)/cancel
        $(RM) $(BINDIR)/cupstestdsc
        $(RM) $(BINDIR)/cupstestppd
+       $(RM) $(BINDIR)/disable
+       $(RM) $(BINDIR)/enable
        $(RM) $(BINDIR)/lp
        $(RM) $(BINDIR)/lpoptions
        $(RM) $(BINDIR)/lppasswd
        $(RM) $(BINDIR)/lpstat
        -$(RMDIR) $(BINDIR)
        $(RM) $(SBINDIR)/accept
+       $(RM) $(SBINDIR)/cupsaccept
        $(RM) $(SBINDIR)/cupsaddsmb
        $(RM) $(SBINDIR)/cupsaccept
        $(RM) $(SBINDIR)/cupsdisable
@@ -168,7 +177,7 @@ cancel:     cancel.o ../cups/$(LIBCUPS)
 cupsaccept:    cupsaccept.o ../cups/$(LIBCUPS)
        echo Linking $@...
        $(CC) $(LDFLAGS) -o cupsaccept cupsaccept.o $(LIBS)
-       for file in accept cupsenable cupsdisable cupsreject reject; do \
+       for file in accept cupsenable cupsdisable cupsreject disable enable reject; do \
                $(RM) $$file; \
                $(LN) cupsaccept $$file; \
        done
index fffe7aaa8988268cb76a04d4ed7ce3fa37bac392..238f28dca351e3877bfab49f4292a0e997ac204a 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{title} - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
        {refresh_page?<META HTTP-EQUIV="Refresh" CONTENT="{refresh_page}">:}
 </HEAD>
 <BODY>
index a326d9762453c73749f981891eb184f8d4048241..08fff9ecdd2e8f5abc731753418b8ef03902d5d8 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{HELPTITLE}</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.ico" TYPE="image/x-icon">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 
index 65013ebbbd54c3efbb5834ab28c02e950352b438..b6c63b431549c2743c94ca08d94eda316014878c 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{title} - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
        {refresh_page?<META HTTP-EQUIV="Refresh" CONTENT="{refresh_page}">:}
 </HEAD>
 <BODY>
index a326d9762453c73749f981891eb184f8d4048241..08fff9ecdd2e8f5abc731753418b8ef03902d5d8 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{HELPTITLE}</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.ico" TYPE="image/x-icon">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 
index f4214caedde5b837e4b9fbfaa2492c4c9f361209..a383725c511212d7d88cf1811b95ab1f652937cf 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{title} - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
        {refresh_page?<META HTTP-EQUIV="Refresh" CONTENT="{refresh_page}">:}
 </HEAD>
 <BODY>
index a326d9762453c73749f981891eb184f8d4048241..08fff9ecdd2e8f5abc731753418b8ef03902d5d8 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{HELPTITLE}</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.ico" TYPE="image/x-icon">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 
index cf6cb468b7531e457e7f130271084422c43aae92..ec64a744d376113e3a98600df5ac2cb4bd35d110 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{title} - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
        {refresh_page?<META HTTP-EQUIV="Refresh" CONTENT="{refresh_page}">:}
 </HEAD>
 <BODY>
index a326d9762453c73749f981891eb184f8d4048241..08fff9ecdd2e8f5abc731753418b8ef03902d5d8 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{HELPTITLE}</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.ico" TYPE="image/x-icon">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 
index 1ee544fbf7b72539bdefce0134db01f0db0a1ae4..ca1774b89e4650c75f2062a691f3f3c62b17d833 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{title} - CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
        {refresh_page?<META HTTP-EQUIV="Refresh" CONTENT="{refresh_page}">:}
 </HEAD>
 <BODY>
index a326d9762453c73749f981891eb184f8d4048241..08fff9ecdd2e8f5abc731753418b8ef03902d5d8 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{HELPTITLE}</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.ico" TYPE="image/x-icon">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 
index 9859144aa296e84982fc4349f2cd77c561e8e917..4fbdbe0335d1e3af1af22ce9dde78cb2f4583384 100644 (file)
@@ -4,7 +4,7 @@
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{title} — CUPS @CUPS_VERSION@@CUPS_REVISION@</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.png" TYPE="image/png">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
        {refresh_page?<META HTTP-EQUIV="Refresh" CONTENT="{refresh_page}">:}
 </HEAD>
 <BODY>
index 305112a337342ad30986de08a061772354400bdd..08fff9ecdd2e8f5abc731753418b8ef03902d5d8 100644 (file)
@@ -1,10 +1,10 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <HTML>
 <HEAD>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
        <TITLE>{HELPTITLE}</TITLE>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="/cups-printable.css">
-       <LINK REL="SHORTCUT ICON" HREF="/favicon.ico" TYPE="image/x-icon">
+       <LINK REL="SHORTCUT ICON" HREF="/images/cups-icon.png" TYPE="image/png">
 </HEAD>
 <BODY>
 
index 26035bcfbc7ec3eafbf916a86a222d1c1d91ea2a..67c515dfe9132383fecdcffb64b3a5ec9601f943 100644 (file)
        EXPECT attributes-charset
        EXPECT attributes-natural-language
 }
+{
+       # The name of the test...
+       NAME "Get Default Printer with no default set"
+
+       # The operation to use
+       OPERATION cups-get-default
+       RESOURCE /
+
+       # The attributes to send
+       GROUP operation
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+
+       # What statuses are OK?
+       STATUS client-error-not-found
+
+       # What attributes do we expect?
+       EXPECT attributes-charset
+       EXPECT attributes-natural-language
+}
 {
        # The name of the test...
        NAME "Set Default Printer to Test1"
        EXPECT attributes-charset
        EXPECT attributes-natural-language
 }
+{
+       # The name of the test...
+       NAME "Get Default Printer"
+
+       # The operation to use
+       OPERATION cups-get-default
+       RESOURCE /
+
+       # The attributes to send
+       GROUP operation
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+
+       # What statuses are OK?
+       STATUS successful-ok
+
+       # What attributes do we expect?
+       EXPECT attributes-charset
+       EXPECT attributes-natural-language
+       EXPECT printer-name
+       EXPECT printer-uri-supported
+}
 {
        # The name of the test...
        NAME "Get IPP/2.x Attributes for Printer Test1"
index 29b651ee7ef832a48dcafd861359057acfc096b6..4b34d11ddc69a68aa5f8ca4a736663919b015351 100644 (file)
@@ -4,7 +4,7 @@
 #
 #   Test the lpstat command.
 #
-#   Copyright 2007 by Apple Inc.
+#   Copyright 2007-2009 by Apple Inc.
 #   Copyright 1997-2005 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -26,6 +26,18 @@ else
 fi
 echo ""
 
+echo "LPSTAT Test"
+echo ""
+echo "    lpstat -H"
+server="`../systemv/lpstat -H 2>&1`"
+if test $? != 0 -o "x$server" != xlocalhost:8631; then
+       echo "    FAILED ($server)"
+       exit 1
+else
+       echo "    PASSED ($server)"
+fi
+echo ""
+
 #
 # End of "$Id: 5.4-lpstat.sh 6649 2007-07-11 21:46:42Z mike $".
 #
diff --git a/test/ipp-backend.test b/test/ipp-backend.test
new file mode 100644 (file)
index 0000000..c2642d3
--- /dev/null
@@ -0,0 +1,22 @@
+# Get printer attributes using get-printer-attributes
+{
+       # The name of the test...
+       NAME "Get printer attributes using get-printer-attributes"
+
+       # The resource to use for the POST
+       # RESOURCE /admin
+
+       # The operation to use
+       OPERATION get-printer-attributes
+
+       # Attributes, starting in the operation group...
+       GROUP operation
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+       ATTR keyword requested-attributes com.apple.print.recoverable-message,copies-supported,document-format-supported,marker-colors,marker-levels,marker-message,marker-names,marker-types,printer-is-accepting-jobs,printer-state,printer-state-message,printer-state-reasons
+
+       # What statuses are OK?
+       STATUS successful-ok
+       STATUS successful-ok-ignored-or-substituted-attributes
+}
index 64e1b792f032f45eb4dce9914c254b819c4e7789..9e27ba1fdf71d49bf86f92aed0e503d184eda6b4 100755 (executable)
@@ -339,6 +339,7 @@ MaxLogSize 0
 AccessLog /tmp/cups-$user/log/access_log
 ErrorLog /tmp/cups-$user/log/error_log
 PageLog /tmp/cups-$user/log/page_log
+AccessLogLevel actions
 LogLevel debug2
 LogTimeFormat usecs
 PreserveJobHistory Yes
@@ -636,10 +637,30 @@ else
        echo "<P>PASS: Printer 'Test2' correctly produced $count page(s).</P>" >>$strfile
 fi
 
-# Requested processed
+# Requests logged
 count=`wc -l /tmp/cups-$user/log/access_log | awk '{print $1}'`
-echo "PASS: $count requests processed."
-echo "<P>PASS: $count requests processed.</P>" >>$strfile
+expected=`expr 39 + 18 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
+if test $count != $expected; then
+       echo "FAIL: $count requests logged, expected $expected."
+       echo "<P>FAIL: $count requests logged, expected $expected.</P>" >>$strfile
+       fail=`expr $fail + 1`
+else
+       echo "PASS: $count requests logged."
+       echo "<P>PASS: $count requests logged.</P>" >>$strfile
+fi
+
+# Did CUPS-Get-Default get logged?
+if grep -q CUPS-Get-Default /tmp/cups-$user/log/access_log; then
+       echo "FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'"
+       echo "<P>FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'</P>" >>$strfile
+       echo "<PRE>" >>$strfile
+       grep CUPS-Get-Default /tmp/cups-$user/log/access_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
+       echo "</PRE>" >>$strfile
+       fail=`expr $fail + 1`
+else
+       echo "PASS: CUPS-Get-Default not logged."
+       echo "<P>PASS: CUPS-Get-Default not logged.</P>" >>$strfile
+fi
 
 # Emergency log messages
 count=`grep '^X ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`