]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge changes from CUPS 1.4svn-r8290.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 23 Jan 2009 22:36:42 +0000 (22:36 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 23 Jan 2009 22:36:42 +0000 (22:36 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1144 a1ca3aef-8c08-0410-bb20-df032aa958be

43 files changed:
CHANGES-1.3.txt
CHANGES.txt
backend/ipp.c
backend/network.c
backend/snmp-supplies.c
backend/snmp.c
cgi-bin/html.c
config-scripts/cups-dnssd.m4
config-scripts/cups-pam.m4
cups/conflicts.c
cups/dest.c
cups/encode.c
cups/http.c
cups/ipp.c
cups/mark.c
cups/page.c
cups/sidechannel.c
cups/snmp-private.h
cups/snmp.c
cups/testconflicts.c
cups/testppd.c
cups/testsnmp.c
cups/util.c
filter/pdftops.c
ppdc/ppdc-driver.cxx
scheduler/classes.c
scheduler/client.c
scheduler/client.h
scheduler/conf.c
scheduler/conf.h
scheduler/cups-driverd.cxx
scheduler/dirsvc.c
scheduler/ipp.c
scheduler/listen.c
scheduler/network.c
scheduler/printers.c
scheduler/printers.h
templates/choose-uri.tmpl
templates/es/choose-uri.tmpl
test/5.1-lpadmin.sh
test/create-printer-subscription.test [new file with mode: 0644]
test/get-subscriptions.test [new file with mode: 0644]
test/run-stp-tests.sh

index b57dbf20cbb6b809a2d2fa9b7b8a9acc24938ed9..84ea4a62c185fd4f8558e9564c817667bb6a77fd 100644 (file)
@@ -5,6 +5,18 @@ CHANGES IN CUPS V1.3.10
 
        - Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056,
          STR #3057)
+       - Fixed a Valgrind-detected initialization error when creating a
+         missing directory on startup.
+       - The scheduler did not always read all of the HTTP headers from a
+         CGI script/program.
+        - The scheduler did not always set the "air" property in Bonjour/DNS-SD
+          registrations.
+       - The scheduler incorrectly compared Mac OS X UUIDs for access
+         control, preventing access in certain configurations.
+        - The IPP backend incorrectly reset the required authentication
+         to Kerberos when authentication failed.
+       - The scheduler no longer looks up the local hostname by default;
+         turn on hostname lookups to restore the previous behavior.
        - The scheduler did not always load MIME type rules correctly
          (STR #3059)
        - The test page did not format correctly on A4 paper (STR #3060)
index 262c7e471b0a9fb3a25206b127d2022b3111429d..cdf0e7445d14939762c2895f57dca1fd4baef18b 100644 (file)
@@ -1,9 +1,22 @@
-CHANGES.txt - 2009-01-14
+CHANGES.txt - 2009-01-23
 ------------------------
 
 CHANGES IN CUPS V1.4b3
 
        - Documentation fixes (STR #3044, STR #3057)
+       - The configure script incorrectly allowed Avahi to be used for DNS-SD
+         printer discovery (STR #3065)
+       - The web interface and scheduler did not support URIs up to 1024 bytes
+         in length (STR #3072)
+       - Fixed pdftops issues with page sizes (STR #3063)
+       - Fixed pdftops issues with Ghostscript (STR #3062)
+       - The scheduler incorrectly registered default profiles for PostScript
+         printers with no specified colorspace.
+       - The scheduler incorrectly created an empty org.cups.printers.plist
+         file on Mac OS X.
+       - cupsGetPPD3() did not look for local PPDs in the right directory.
+       - SNMP lookups via side-channel did not work for NULL-VALUE and
+         and OCTET-STRING OIDs containing nul characters.
        - The libusb-based USB backend did not work.
        - The scheduler did not set the printer-commands attribute correctly
          for some PPDs.
index d2f1d570e19ef49a76403d44d253ad4af61f5722..1829809132a8bdba24571398a7cc2ae9a69cd5ef 100644 (file)
@@ -1262,6 +1262,19 @@ main(int  argc,                          /* I - Number of command-line args */
       page_count > start_count)
     fprintf(stderr, "PAGE: total %d\n", page_count - start_count);
 
+ /*
+  * Update auth-info-required as needed...
+  */
+
+  if (ipp_status == IPP_NOT_AUTHORIZED)
+  {
+    if (!strncmp(httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE),
+                 "Negotiate", 9))
+      fputs("ATTR: auth-info-required=negotiate\n", stderr);
+    else
+      fputs("ATTR: auth-info-required=username,password\n", stderr);
+  }
+
  /*
   * Free memory...
   */
@@ -1295,15 +1308,7 @@ main(int  argc,                          /* I - Number of command-line args */
   */
 
   if (ipp_status == IPP_NOT_AUTHORIZED)
-  {
-   /*
-    * Authorization failures here mean that we need Kerberos.  Username +
-    * password authentication is handled in the password_cb function.
-    */
-
-    fputs("ATTR: auth-info-required=negotiate\n", stderr);
     return (CUPS_BACKEND_AUTH_REQUIRED);
-  }
   else if (ipp_status > IPP_OK_CONFLICT)
     return (CUPS_BACKEND_FAILED);
   else
index 58f9503d998ffaf970102817a39ce9e48eac2984..06ffc04675ae23ac528950a2ae8245888f373117 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Common network APIs for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 2006-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -162,58 +162,72 @@ backendNetworkSideCB(
                case CUPS_ASN1_BOOLEAN :
                    snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
                             packet.object_value.boolean);
+                   datalen += (int)strlen(dataptr);
                    break;
 
                case CUPS_ASN1_INTEGER :
                    snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
                             packet.object_value.integer);
+                   datalen += (int)strlen(dataptr);
                    break;
 
                case CUPS_ASN1_BIT_STRING :
                case CUPS_ASN1_OCTET_STRING :
-                   strlcpy(dataptr, packet.object_value.string,
-                           sizeof(data) - (dataptr - data));
+                   i = (int)(sizeof(data) - (dataptr - data));
+                   if (packet.object_value.string.num_bytes < i)
+                     i = packet.object_value.string.num_bytes;
+
+                   memcpy(dataptr, packet.object_value.string.bytes, i);
+
+                    datalen += i;
                    break;
 
                case CUPS_ASN1_OID :
                    _cupsSNMPOIDToString(packet.object_value.oid, dataptr,
                                         sizeof(data) - (dataptr - data));
+                   datalen += (int)strlen(dataptr);
                    break;
 
                 case CUPS_ASN1_HEX_STRING :
                    for (i = 0;
-                        i < packet.object_value.hex_string.num_bytes &&
+                        i < packet.object_value.string.num_bytes &&
                             dataptr < (data + sizeof(data) - 3);
                         i ++, dataptr += 2)
                      sprintf(dataptr, "%02X",
-                             packet.object_value.hex_string.bytes[i]);
+                             packet.object_value.string.bytes[i]);
+                   datalen += (int)strlen(dataptr);
                    break;
 
                 case CUPS_ASN1_COUNTER :
                    snprintf(dataptr, sizeof(data) - (dataptr - data), "%d",
                             packet.object_value.counter);
+                   datalen += (int)strlen(dataptr);
                    break;
 
                 case CUPS_ASN1_GAUGE :
                    snprintf(dataptr, sizeof(data) - (dataptr - data), "%u",
                             packet.object_value.gauge);
+                   datalen += (int)strlen(dataptr);
                    break;
 
                 case CUPS_ASN1_TIMETICKS :
                    snprintf(dataptr, sizeof(data) - (dataptr - data), "%u",
                             packet.object_value.timeticks);
+                   datalen += (int)strlen(dataptr);
                    break;
 
                 default :
                    fprintf(stderr, "DEBUG: Unknown OID value type %02X!\n",
                            packet.object_type);
+
+               case CUPS_ASN1_NULL_VALUE :
+                   dataptr[0] = '\0';
                    break;
               }
 
              fprintf(stderr, "DEBUG: Returning %s %s\n", data, data + datalen);
 
-             status  = CUPS_SC_STATUS_OK;
-             datalen += (int)strlen(data + datalen);
+             status = CUPS_SC_STATUS_OK;
            }
            else
              fputs("DEBUG: SNMP read error...\n", stderr);
@@ -246,7 +260,8 @@ backendNetworkSideCB(
            if (_cupsSNMPRead(snmp_fd, &packet, 1.0) &&
                packet.object_type == CUPS_ASN1_OCTET_STRING)
            {
-             strlcpy(data, packet.object_value.string, sizeof(data));
+             strlcpy(data, (char *)packet.object_value.string.bytes,
+                     sizeof(data));
              datalen = (int)strlen(data);
              status  = CUPS_SC_STATUS_OK;
            }
@@ -259,6 +274,7 @@ backendNetworkSideCB(
        {
          strlcpy(data, device_id, sizeof(data));
          datalen = (int)strlen(data);
+         status  = CUPS_SC_STATUS_OK;
          break;
        }
 
index b63ed85c329217d0464a4abc1def97bbef6948a2..009c00602f780c65377e9888ac806898e99816e0 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   SNMP supplies 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
@@ -190,8 +190,8 @@ backendSNMPSupplies(
         packet.object_type != CUPS_ASN1_OCTET_STRING)
       return (-1);
 
-    i = ((packet.object_value.string[0] & 255) << 8) |
-        (packet.object_value.string[1] & 255);
+    i = (packet.object_value.string.bytes[0] << 8) |
+        packet.object_value.string.bytes[1];
 
     if (i & CUPS_TC_lowPaper)
       fputs("STATE: +media-low-report\n", stderr);
@@ -403,7 +403,8 @@ backend_init_supplies(
     num_supplies = 0;
   }
   else
-    strlcpy(description, packet.object_value.string, sizeof(description));
+    strlcpy(description, (char *)packet.object_value.string.bytes,
+            sizeof(description));
 
  /*
   * See if we have already queried this device...
@@ -590,13 +591,13 @@ backend_walk_cb(cups_snmp_t *packet,      /* I - SNMP packet */
     i = packet->object_name[prtMarkerColorantValueOffset];
 
     fprintf(stderr, "DEBUG2: prtMarkerColorantValue.1.%d = \"%s\"\n", i,
-            packet->object_value.string);
+            (char *)packet->object_value.string.bytes);
 
     for (j = 0; j < num_supplies; j ++)
       if (supplies[j].colorant == i)
       {
        for (k = 0; k < (int)(sizeof(colors) / sizeof(colors[0])); k ++)
-         if (!strcmp(colors[k][0], packet->object_value.string))
+         if (!strcmp(colors[k][0], (char *)packet->object_value.string.bytes))
          {
            strcpy(supplies[j].color, colors[k][1]);
            break;
@@ -634,12 +635,12 @@ backend_walk_cb(cups_snmp_t *packet,      /* I - SNMP packet */
       return;
 
     fprintf(stderr, "DEBUG2: prtMarkerSuppliesDescription.1.%d = \"%s\"\n", i,
-            packet->object_value.string);
+            (char *)packet->object_value.string.bytes);
 
     if (i > num_supplies)
       num_supplies = i;
 
-    strlcpy(supplies[i - 1].name, packet->object_value.string,
+    strlcpy(supplies[i - 1].name, (char *)packet->object_value.string.bytes,
             sizeof(supplies[0].name));
   }
   else if (_cupsSNMPIsOIDPrefixed(packet, prtMarkerSuppliesLevel))
index 692272474e748444a7b99eae939d75f97fb50353..0b7513d5b3faca5d4a5469d63848dcb214e46789 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   SNMP discovery backend for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 2006-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -1015,18 +1015,18 @@ read_snmp_response(int fd)              /* I - SNMP socket file descriptor */
          char  make_model[256];        /* Make and model */
 
 
-         if (strchr(packet.object_value.string, ':') &&
-             strchr(packet.object_value.string, ';'))
+         if (strchr((char *)packet.object_value.string.bytes, ':') &&
+             strchr((char *)packet.object_value.string.bytes, ';'))
          {
           /*
            * Description is the IEEE-1284 device ID...
            */
 
            if (!device->id)
-             device->id = strdup(packet.object_value.string);
+             device->id = strdup((char *)packet.object_value.string.bytes);
 
-           backendGetMakeModel(packet.object_value.string, make_model,
-                               sizeof(make_model));
+           backendGetMakeModel((char *)packet.object_value.string.bytes,
+                               make_model, sizeof(make_model));
 
             if (device->info)
              free(device->info);
@@ -1039,13 +1039,13 @@ read_snmp_response(int fd)              /* I - SNMP socket file descriptor */
            * Description is plain text...
            */
 
-           fix_make_model(make_model, packet.object_value.string,
+           fix_make_model(make_model, (char *)packet.object_value.string.bytes,
                           sizeof(make_model));
 
             if (device->info)
              free(device->info);
 
-           device->info = strdup(packet.object_value.string);
+           device->info = strdup((char *)packet.object_value.string.bytes);
          }
 
          if (!device->make_and_model)
@@ -1066,14 +1066,14 @@ read_snmp_response(int fd)              /* I - SNMP socket file descriptor */
          if (device->id)
            free(device->id);
 
-         device->id = strdup(packet.object_value.string);
+         device->id = strdup((char *)packet.object_value.string.bytes);
 
         /*
          * Convert the ID to a make and model string...
          */
 
-         backendGetMakeModel(packet.object_value.string, make_model,
-                             sizeof(make_model));
+         backendGetMakeModel((char *)packet.object_value.string.bytes,
+                             make_model, sizeof(make_model));
          if (device->make_and_model)
            free(device->make_and_model);
 
@@ -1084,7 +1084,7 @@ read_snmp_response(int fd)                /* I - SNMP socket file descriptor */
     case DEVICE_LOCATION :
        if (device && packet.object_type == CUPS_ASN1_OCTET_STRING &&
            !device->location)
-         device->location = strdup(packet.object_value.string);
+         device->location = strdup((char *)packet.object_value.string.bytes);
        break;
 
     case DEVICE_PRODUCT :
@@ -1096,12 +1096,12 @@ read_snmp_response(int fd)              /* I - SNMP socket file descriptor */
          */
 
           if (!device->info)
-           device->info = strdup(packet.object_value.string);
+           device->info = strdup((char *)packet.object_value.string.bytes);
 
           if (device->make_and_model)
            free(device->make_and_model);
 
-         device->make_and_model = strdup(packet.object_value.string);
+         device->make_and_model = strdup((char *)packet.object_value.string.bytes);
        }
        break;
 
@@ -1113,16 +1113,16 @@ read_snmp_response(int fd)              /* I - SNMP socket file descriptor */
          * Update an existing cache entry...
          */
 
-         if (!strncmp(packet.object_value.string, "lpr:", 4))
+         if (!strncmp((char *)packet.object_value.string.bytes, "lpr:", 4))
          {
           /*
            * We want "lpd://..." for the URI...
            */
 
-           packet.object_value.string[2] = 'd';
+           packet.object_value.string.bytes[2] = 'd';
          }
 
-         device->uri = strdup(packet.object_value.string);
+         device->uri = strdup((char *)packet.object_value.string.bytes);
        }
        break;
   }
index 2db9bdd25344daaa07177dc9216e71cb6f1a117d..5d0a39fdd0c563c2bc04d97763643194af4e7285 100644 (file)
@@ -68,7 +68,10 @@ void
 cgiEndMultipart(void)
 {
   if (cgi_multipart)
+  {
     printf("\n%s--\n", cgi_multipart);
+    fflush(stdout);
+  }
 }
 
 
@@ -190,8 +193,10 @@ cgiStartHTML(const char *title)            /* I - Title of page */
 void
 cgiStartMultipart(void)
 {
-  puts("MIME-Version: 1.0");
-  puts("Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n");
+  puts("MIME-Version: 1.0\n"
+       "Content-Type: multipart/x-mixed-replace; boundary=\"CUPS-MULTIPART\"\n");
+  fflush(stdout);
+
   cgi_multipart = "--CUPS-MULTIPART";
 }
 
index a13006015af352058faf7418c681c4f535edb262..d35eb316c11844e6996c37388f86922dc47745ce 100644 (file)
@@ -32,17 +32,29 @@ if test x$enable_dnssd != xno; then
                case "$uname" in
                        Darwin*)
                                # Darwin and MacOS X...
-                               DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration"
                                AC_DEFINE(HAVE_DNSSD)
                                AC_DEFINE(HAVE_COREFOUNDATION)
                                AC_DEFINE(HAVE_SYSTEMCONFIGURATION)
+                               DNSSDLIBS="-framework CoreFoundation -framework SystemConfiguration"
                                DNSSD_BACKEND="dnssd"
                                ;;
                        *)
                                # All others...
-                               AC_CHECK_LIB(dns_sd,TXTRecordGetValuePtr,
+                               AC_MSG_CHECKING(for current version of dns_sd library)
+                               SAVELIBS="$LIBS"
+                               LIBS="$LIBS -ldns_sd"
+                               AC_TRY_COMPILE([#include <dns_sd.h],
+                                       [int constant = kDNSServiceFlagsShareConnection;
+                                       unsigned char txtRecord[100];
+                                       uint8_t valueLen;
+                                       TXTRecordGetValuePtr(sizeof(txtRecord),
+                                           txtRecord, "value", &valueLen);],
+                                       AC_MSG_RESULT(yes)
                                        AC_DEFINE(HAVE_DNSSD)
-                                       DNSSDLIBS="-ldns_sd")
+                                       DNSSDLIBS="-ldns_sd"
+                                       DNSSD_BACKEND="dnssd",
+                                       AC_MSG_RESULT(no))
+                               LIBS="$SAVELIBS"
                                ;;
                esac
        ])
index 865f97f7b51033d3aba158b96c628856992d5027..ef2e9c3ec849e3c36590914a60b5ff2e2601daad 100644 (file)
@@ -63,7 +63,7 @@ if test x$enable_pam != xno; then
                        # Darwin, MacOS X
                        if test "x$with_pam_module" != x; then
                                PAMFILE="pam.$with_pam_module"
-                       elif test -f /usr/lib/pam/pam_opendirectory.so; then
+                       elif test -f /usr/lib/pam/pam_opendirectory.so.2; then
                                PAMFILE="pam.opendirectory"
                        else
                                PAMFILE="pam.securityserver"
index 6376f69ef8b2732c517d0c5f908614214c7a97aa..4c90f169e4106fff7bc46b987696a81dc6d9eeb3 100644 (file)
@@ -307,6 +307,7 @@ cupsResolveConflicts(
         int            j;              /* Looping var */
        ppd_choice_t    *cptr;          /* Current choice */
         cups_array_t   *test;          /* Test array for conflicts */
+        ppd_size_t     *size;          /* Current page size */
 
 
         for (i = consts->num_constraints, constptr = consts->constraints;
@@ -324,7 +325,12 @@ cupsResolveConflicts(
          * Is this the option we are changing?
          */
 
-         if (option && !strcasecmp(constptr->option->keyword, option))
+         if (option &&
+             (!strcasecmp(constptr->option->keyword, option) ||
+              (!strcasecmp(option, "PageSize") &&
+               !strcasecmp(constptr->option->keyword, "PageRegion")) ||
+              (!strcasecmp(option, "PageRegion") &&
+               !strcasecmp(constptr->option->keyword, "PageSize"))))
            continue;
 
          /*
@@ -334,10 +340,31 @@ cupsResolveConflicts(
           if ((value = cupsGetOption(constptr->option->keyword, num_newopts,
                                     newopts)) == NULL)
           {
-           marked = ppdFindMarkedChoice(ppd, constptr->option->keyword);
-           value  = marked ? marked->choice : "";
+           if (!strcasecmp(constptr->option->keyword, "PageSize") ||
+               !strcasecmp(constptr->option->keyword, "PageRegion"))
+           {
+             if ((value = cupsGetOption("PageSize", num_newopts,
+                                        newopts)) == NULL)
+                value = cupsGetOption("PageRegion", num_newopts, newopts);
+
+              if (!value)
+             {
+               if ((size = ppdPageSize(ppd, NULL)) != NULL)
+                 value = size->name;
+               else
+                 value = "";
+             }
+           }
+           else
+           {
+             marked = ppdFindMarkedChoice(ppd, constptr->option->keyword);
+             value  = marked ? marked->choice : "";
+           }
          }
 
+         if (!strncasecmp(value, "Custom.", 7))
+           value = "Custom";
+
          /*
          * Try the default choice...
          */
@@ -375,6 +402,7 @@ cupsResolveConflicts(
 
              if (strcasecmp(value, cptr->choice) &&
                  strcasecmp(constptr->option->defchoice, cptr->choice) &&
+                 strcasecmp("Custom", cptr->choice) &&
                  (test = ppd_test_constraints(ppd, constptr->option->keyword,
                                               cptr->choice, num_newopts,
                                               newopts,
@@ -438,6 +466,13 @@ cupsResolveConflicts(
 
   cupsArrayRestore(ppd->sorted_attrs);
 
+  DEBUG_printf(("cupsResolveConflicts: Returning %d options:", num_newopts));
+#ifdef DEBUG
+  for (i = 0; i < num_newopts; i ++)
+    DEBUG_printf(("cupsResolveConflicts: options[%d]: %s=%s", i,
+                  newopts[i].name, newopts[i].value));
+#endif /* DEBUG */
+
   return (1);
 
  /*
@@ -453,6 +488,8 @@ cupsResolveConflicts(
 
   cupsArrayRestore(ppd->sorted_attrs);
 
+  DEBUG_puts("cupsResolveConflicts: Unable to resolve conflicts!");
+
   return (0);
 }
 
@@ -847,7 +884,6 @@ ppd_test_constraints(
                        *marked;        /* Marked choice */
   cups_array_t         *active = NULL; /* Active constraints */
   const char           *value;         /* Current value */
-  int                  option_conflict;/* Conflict with current option? */
 
 
   DEBUG_printf(("ppd_test_constraints(ppd=%p, num_options=%d, options=%p, "
@@ -881,8 +917,7 @@ ppd_test_constraints(
 
     DEBUG_puts("ppd_test_constraints: Testing...");
 
-    for (i = consts->num_constraints, constptr = consts->constraints,
-             option_conflict = 0;
+    for (i = consts->num_constraints, constptr = consts->constraints;
          i > 0;
         i --, constptr ++)
     {
@@ -904,9 +939,6 @@ ppd_test_constraints(
             !strcasecmp(option, "PageRegion")))
        {
          value = choice;
-
-         if (!strcasecmp(value, constptr->choice->choice))
-           option_conflict = 1;
         }
        else if ((value = cupsGetOption("PageSize", num_options,
                                        options)) == NULL)
@@ -920,6 +952,9 @@ ppd_test_constraints(
                value = size->name;
            }
 
+        if (value && !strncasecmp(value, "Custom.", 7))
+         value = "Custom";
+
         if (!value || strcasecmp(value, constptr->choice->choice))
        {
          DEBUG_puts("ppd_test_constraints: NO");
@@ -930,14 +965,23 @@ ppd_test_constraints(
       {
         if (option && choice && !strcasecmp(option, constptr->option->keyword))
        {
-         if (strcasecmp(choice, constptr->choice->choice))
-           break;
+         if (!strncasecmp(choice, "Custom.", 7))
+           value = "Custom";
+         else
+           value = choice;
 
-         option_conflict = 1;
+         if (strcasecmp(value, constptr->choice->choice))
+         {
+           DEBUG_puts("ppd_test_constraints: NO");
+           break;
+         }
        }
         else if ((value = cupsGetOption(constptr->option->keyword, num_options,
                                        options)) != NULL)
         {
+         if (!strncasecmp(value, "Custom.", 7))
+           value = "Custom";
+
          if (strcasecmp(value, constptr->choice->choice))
          {
            DEBUG_puts("ppd_test_constraints: NO");
@@ -955,9 +999,10 @@ ppd_test_constraints(
       {
        if (!strcasecmp(choice, "None") || !strcasecmp(choice, "Off") ||
            !strcasecmp(choice, "False"))
+       {
+         DEBUG_puts("ppd_test_constraints: NO");
           break;
-
-       option_conflict = 1;
+       }
       }
       else if ((value = cupsGetOption(constptr->option->keyword, num_options,
                                      options)) != NULL)
@@ -985,7 +1030,7 @@ ppd_test_constraints(
       }
     }
 
-    if (i <= 0 && (!option || option_conflict))
+    if (i <= 0)
     {
       if (!active)
         active = cupsArrayNew(NULL, NULL);
index eab2eb5872c58ecabc9b7e0841cbe4af49d03442..f2dde4ddab5b2ef187562dd4f8d0a8eea7397473 100644 (file)
@@ -1703,7 +1703,6 @@ cups_get_sdests(http_t      *http,        /* I - Connection to server or CUPS_HTTP_DEFA
                 int         num_dests, /* I - Number of destinations */
                 cups_dest_t **dests)   /* IO - Destinations */
 {
-  int          i;                      /* Looping var */
   cups_dest_t  *dest;                  /* Current destination */
   ipp_t                *request,               /* IPP Request */
                *response;              /* IPP Response */
@@ -1721,6 +1720,7 @@ cups_get_sdests(http_t      *http,        /* I - Connection to server or CUPS_HTTP_DEFA
   static const char * const pattrs[] = /* Attributes we're interested in */
                {
                  "auth-info-required",
+                 "device-uri",
                  "job-sheets-default",
                  "marker-change-time",
                  "marker-colors",
@@ -1734,6 +1734,7 @@ cups_get_sdests(http_t      *http,        /* I - Connection to server or CUPS_HTTP_DEFA
                  "media-supported",
 #endif /* __APPLE__ */
                  "printer-commands",
+                 "printer-defaults",
                  "printer-info",
                  "printer-is-accepting-jobs",
                  "printer-is-shared",
@@ -1744,7 +1745,7 @@ cups_get_sdests(http_t      *http,        /* I - Connection to server or CUPS_HTTP_DEFA
                  "printer-state-change-time",
                  "printer-state-reasons",
                  "printer-type",
-                 "printer-defaults"
+                 "printer-uri-supported"
                };
 
 
@@ -1819,10 +1820,12 @@ cups_get_sdests(http_t      *http,      /* I - Connection to server or CUPS_HTTP_DEFA
            attr->value_tag != IPP_TAG_NAME &&
            attr->value_tag != IPP_TAG_NAMELANG &&
            attr->value_tag != IPP_TAG_KEYWORD &&
-           attr->value_tag != IPP_TAG_RANGE)
+           attr->value_tag != IPP_TAG_RANGE &&
+           attr->value_tag != IPP_TAG_URI)
           continue;
 
         if (!strcmp(attr->name, "auth-info-required") ||
+           !strcmp(attr->name, "device-uri") ||
            !strcmp(attr->name, "marker-change-time") ||
            !strcmp(attr->name, "marker-colors") ||
            !strcmp(attr->name, "marker-high-levels") ||
@@ -1840,7 +1843,8 @@ cups_get_sdests(http_t      *http,        /* I - Connection to server or CUPS_HTTP_DEFA
            !strcmp(attr->name, "printer-type") ||
             !strcmp(attr->name, "printer-is-accepting-jobs") ||
             !strcmp(attr->name, "printer-location") ||
-            !strcmp(attr->name, "printer-state-reasons"))
+            !strcmp(attr->name, "printer-state-reasons") ||
+           !strcmp(attr->name, "printer-uri-supported"))
         {
         /*
          * Add a printer description attribute...
@@ -1858,6 +1862,8 @@ cups_get_sdests(http_t      *http,        /* I - Connection to server or CUPS_HTTP_DEFA
          * See if we can set a default media size...
          */
 
+          int  i;                      /* Looping var */
+
          for (i = 0; i < attr->num_values; i ++)
            if (!strcasecmp(media_default, attr->values[i].string.text))
            {
index 16762aa0c4cf27b0c8219a51549806e849abe1de..f098844e6a8e89c55f3332cc04c8d0633434f3d4 100644 (file)
@@ -54,6 +54,7 @@ static const _ipp_option_t ipp_options[] =
   { 0, "compression",          IPP_TAG_KEYWORD,        IPP_TAG_OPERATION },
   { 0, "copies",               IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { 0, "copies-default",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "device-uri",           IPP_TAG_URI,            IPP_TAG_PRINTER },
   { 0, "document-format",      IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
   { 0, "document-format-default", IPP_TAG_MIMETYPE,    IPP_TAG_PRINTER },
   { 1, "exclude-schemes",      IPP_TAG_NAME,           IPP_TAG_OPERATION },
@@ -145,6 +146,7 @@ static const _ipp_option_t ipp_options[] =
   { 1, "printer-state-reasons",        IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 0, "printer-type",         IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { 0, "printer-uri",          IPP_TAG_URI,            IPP_TAG_OPERATION },
+  { 1, "printer-uri-supported",        IPP_TAG_URI,            IPP_TAG_PRINTER },
   { 0, "queued-job-count",     IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 0, "raw",                  IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
   { 1, "requested-attributes", IPP_TAG_NAME,           IPP_TAG_OPERATION },
index 439f180f30a48c078fd5e76a41a86b30826b92d5..459730ef9b0f099a753e37d1b27b0afda90210e6 100644 (file)
@@ -1459,7 +1459,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
     bytes = (ssize_t)recv(http->fd, buffer, (int)length, 0);
 #else
     while ((bytes = recv(http->fd, buffer, length, 0)) < 0)
-      if (errno != EINTR)
+      if (errno != EINTR && errno != EAGAIN)
         break;
 #endif /* WIN32 */
 
@@ -1481,7 +1481,7 @@ httpRead2(http_t *http,                   /* I - Connection to server */
 #ifdef WIN32
     http->error = WSAGetLastError();
 #else
-    if (errno == EINTR)
+    if (errno == EINTR || errno == EAGAIN)
       bytes = 0;
     else
       http->error = errno;
index f8e7dafa6136ce6580471d28fe4be392f5e85d59..a6c640856e44cdf4c5a0146ec8346a52f9719466 100644 (file)
@@ -3063,7 +3063,18 @@ ipp_read_http(http_t      *http, /* I - Client connection */
        }
       }
 
-      if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) <= 0)
+      if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) < 0)
+      {
+#ifdef WIN32
+        break;
+#else
+        if (errno != EAGAIN && errno != EINTR)
+         break;
+
+       bytes = 0;
+#endif /* WIN32 */
+      }
+      else if (bytes == 0)
         break;
     }
   }
index b2cef1f2d522ece1b1099ee64bf52e9352758889..84836390e95bff1a150d3a16e4fcaf50eb981b83 100644 (file)
@@ -461,13 +461,24 @@ ppd_choice_t *                            /* O - Pointer to choice or @code NULL@ */
 ppdFindMarkedChoice(ppd_file_t *ppd,   /* I - PPD file */
                     const char *option)        /* I - Keyword/option name */
 {
-  ppd_choice_t key;                    /* Search key for choice */
+  ppd_choice_t key,                    /* Search key for choice */
+               *marked;                /* Marked choice */
 
 
+  DEBUG_printf(("ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
+
   if ((key.option = ppdFindOption(ppd, option)) == NULL)
+  {
+    DEBUG_puts("ppdFindMarkedChoice: Option not found, returning NULL");
     return (NULL);
+  }
+
+  marked = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key);
+
+  DEBUG_printf(("ppdFindMarkedChoice: Returning %p(%s)...", marked,
+                marked ? marked->choice : "NULL"));
 
-  return ((ppd_choice_t *)cupsArrayFind(ppd->marked, &key));
+  return (marked);
 }
 
 
index 2b59c1e7282709c960ab24451c6eba73ecda01dd..b99b54a1e0e502082fce618418323041db0e143c 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Page size 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
@@ -30,6 +30,7 @@
 #include "ppd.h"
 #include "string.h"
 #include <ctype.h>
+#include "debug.h"
 
 
 /*
@@ -49,8 +50,13 @@ ppdPageSize(ppd_file_t *ppd,         /* I - PPD file record */
   ppd_cparam_t *cparam;                /* Custom option parameter */
 
 
+  DEBUG_printf(("ppdPageSize(ppd=%p, name=\"%s\")", ppd, name));
+
   if (!ppd)
+  {
+    DEBUG_puts("ppdPageSize: Bad PPD pointer, returning NULL...");
     return (NULL);
+  }
 
   if (name)
   {
@@ -65,7 +71,10 @@ ppdPageSize(ppd_file_t *ppd,         /* I - PPD file record */
           break;
 
       if (!i)
+      {
+       DEBUG_puts("ppdPageSize: No custom sizes, returning NULL...");
         return (NULL);
+      }
 
      /*
       * Variable size; size name can be one of the following:
@@ -135,6 +144,9 @@ ppdPageSize(ppd_file_t *ppd,                /* I - PPD file record */
       * Return the page size...
       */
 
+      DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+                    size->name, size->width, size->length));
+
       return (size);
     }
     else
@@ -144,8 +156,13 @@ ppdPageSize(ppd_file_t *ppd,               /* I - PPD file record */
       */
 
       for (i = ppd->num_sizes, size = ppd->sizes; i > 0; i --, size ++)
-       if (!strcmp(name, size->name))
+       if (!strcasecmp(name, size->name))
+       {
+         DEBUG_printf(("ppdPageSize: Returning %p (\"%s\", %gx%g)", size,
+                       size->name, size->width, size->length));
+
           return (size);
+       }
     }
   }
   else
@@ -156,9 +173,16 @@ 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,
+                     size->name, size->width, size->length));
+
         return (size);
+      }
   }
 
+  DEBUG_puts("ppdPageSize: Size not found, returning NULL");
+
   return (NULL);
 }
 
index ccf1d190456a77e967f91422b12968f8c3bafe37..585d6cbc788bdac584a822cfcba86de2eb189402 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Side-channel API code for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -427,6 +427,9 @@ cupsSideChannelSNMPWalk(
         return (CUPS_SC_STATUS_OK);
       }
 
+      if (real_datalen < sizeof(real_data))
+        real_data[real_datalen] = '\0';
+
       real_oidlen  = strlen(real_data) + 1;
       real_datalen -= real_oidlen;
 
index de6d0f6f3e39f97de78c6c9a1a1fd095027142a3..1745b92593e48a1c1184b6d76248ecec7d36f5a3 100644 (file)
@@ -6,7 +6,7 @@
  *   This API is PRIVATE and subject to change.  No third-party applications
  *   should use the SNMP API defined in this file.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 2006-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -64,12 +64,12 @@ enum cups_asn1_e                    /**** ASN1 request/object types ****/
 };
 typedef enum cups_asn1_e cups_asn1_t;  /**** ASN1 request/object types ****/
 
-struct cups_snmp_hexstring_s           /**** Hex-STRING value ****/
+typedef struct cups_snmp_string_s      /**** String value ****/
 {
   unsigned char        bytes[CUPS_SNMP_MAX_STRING];
                                        /* Bytes in string */
   int          num_bytes;              /* Number of bytes */
-};
+} cups_snmp_string_t;
 
 union cups_snmp_value_u                        /**** Object value ****/
 {
@@ -79,10 +79,7 @@ union cups_snmp_value_u                      /**** Object value ****/
   unsigned     gauge;                  /* Gauge value */
   unsigned     timeticks;              /* Timeticks  value */
   int          oid[CUPS_SNMP_MAX_OID]; /* OID value */
-  char         string[CUPS_SNMP_MAX_STRING];
-                                       /* String value */
-  struct cups_snmp_hexstring_s hex_string;
-                                       /* Hex string value */
+  cups_snmp_string_t string;           /* String value */
 };
 
 typedef struct cups_snmp_s             /**** SNMP data packet ****/
index 69a91ac51e57fba351d1c8c1f6a7489575f92a41..847f7c0d839bebef8eeb13916de9c88da457ef4e 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   SNMP functions for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 2006-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -1079,8 +1079,11 @@ asn1_decode_snmp(unsigned char *buffer,  /* I - Buffer */
                    break;
 
                case CUPS_ASN1_OCTET_STRING :
+               case CUPS_ASN1_BIT_STRING :
+               case CUPS_ASN1_HEX_STRING :
+                   packet->object_value.string.num_bytes = length;
                    asn1_get_string(&bufptr, bufend, length,
-                                   packet->object_value.string,
+                                   (char *)packet->object_value.string.bytes,
                                    CUPS_SNMP_MAX_STRING);
                    break;
 
@@ -1089,14 +1092,6 @@ asn1_decode_snmp(unsigned char *buffer,  /* I - Buffer */
                                 packet->object_value.oid, CUPS_SNMP_MAX_OID);
                    break;
 
-               case CUPS_ASN1_HEX_STRING :
-                   packet->object_value.hex_string.num_bytes = length;
-
-                   asn1_get_string(&bufptr, bufend, length,
-                                   (char *)packet->object_value.hex_string.bytes,
-                                   CUPS_SNMP_MAX_STRING);
-                   break;
-
                case CUPS_ASN1_COUNTER :
                    packet->object_value.counter =
                        asn1_get_integer(&bufptr, bufend, length);
@@ -1169,7 +1164,7 @@ asn1_encode_snmp(unsigned char *buffer,   /* I - Buffer */
        break;
 
     case CUPS_ASN1_OCTET_STRING :
-        valuelen = strlen(packet->object_value.string);
+        valuelen = packet->object_value.string.num_bytes;
        break;
 
     case CUPS_ASN1_OID :
@@ -1254,7 +1249,7 @@ asn1_encode_snmp(unsigned char *buffer,   /* I - Buffer */
     case CUPS_ASN1_OCTET_STRING :
         *bufptr++ = CUPS_ASN1_OCTET_STRING;
        asn1_set_length(&bufptr, valuelen);
-       memcpy(bufptr, packet->object_value.string, valuelen);
+       memcpy(bufptr, packet->object_value.string.bytes, valuelen);
        bufptr += valuelen;
        break;
 
index 291739a2684a69908259dc5eefdea8a962ff954d..0d7531bdbb8e82038a615a66a560d7bc0804130e 100644 (file)
@@ -36,7 +36,10 @@ main(int  argc,                              /* I - Number of command-line arguments */
 {
   int          i;                      /* Looping var */
   ppd_file_t   *ppd;                   /* PPD file loaded from disk */
-  char         line[256];              /* Input buffer */
+  char         line[256],              /* Input buffer */
+               *ptr,                   /* Pointer into buffer */
+               *optr,                  /* Pointer to first option name */
+               *cptr;                  /* Pointer to first choice */
   int          num_options;            /* Number of options */
   cups_option_t        *options;               /* Options */
   char         *option,                /* Current option */
@@ -73,11 +76,12 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     if (!cupsResolveConflicts(ppd, option, choice, &num_options, &options))
       puts("Unable to resolve conflicts!");
-    else if (num_options > 0)
+    else if ((!option && num_options > 0) || (option && num_options > 1))
     {
       fputs("Resolved conflicts with the following options:\n   ", stdout);
       for (i = 0; i < num_options; i ++)
-       printf(" %s=%s", options[i].name, options[i].value);
+        if (!option || strcasecmp(option, options[i].name))
+         printf(" %s=%s", options[i].name, options[i].value);
       putchar('\n');
 
       cupsFreeOptions(num_options, options);
@@ -94,13 +98,20 @@ main(int  argc,                             /* I - Number of command-line arguments */
     if (!fgets(line, sizeof(line), stdin) || line[0] == '\n')
       break;
 
-    num_options = cupsParseOptions(line, 0, &options);
-    if (num_options > 0)
-    {
-      option = strdup(options[0].name);
-      choice = strdup(options[0].value);
-    }
+    for (ptr = line; isspace(*ptr & 255); ptr ++);
+    for (optr = ptr; *ptr && *ptr != '='; ptr ++);
+    if (!*ptr)
+      break;
+    for (*ptr++ = '\0', cptr = ptr; *ptr && !isspace(*ptr & 255); ptr ++);
+    if (!*ptr)
+      break;
+    *ptr++ = '\0';
+
+    option      = strdup(optr);
+    choice      = strdup(cptr);
+    num_options = cupsParseOptions(ptr, 0, &options);
 
+    ppdMarkOption(ppd, option, choice);
     if (cupsMarkOptions(ppd, num_options, options))
       puts("Options Conflict!");
     cupsFreeOptions(num_options, options);
index 44c43b55b7a1651f6e02b2d146d03e03c83af55b..9af38ee0a3ce0016681d69b228149da343d5e635 100644 (file)
@@ -774,6 +774,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
   else
   {
     const char *filename;              /* PPD filename */
+    struct stat        fileinfo;               /* File information */
 
 
     if (!strncmp(argv[1], "-d", 2))
@@ -788,6 +789,33 @@ main(int  argc,                            /* I - Number of command-line arguments */
     else
       filename = argv[1];
 
+    if (lstat(filename, &fileinfo))
+    {
+      printf("%s: %s\n", filename, strerror(errno));
+      return (1);
+    }
+
+    if (S_ISLNK(fileinfo.st_mode))
+    {
+      char     realfile[1024];         /* Real file path */
+      ssize_t  realsize;               /* Size of real file path */
+
+
+      if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0)
+        strcpy(realfile, "Unknown");
+      else
+        realfile[realsize] = '\0';
+
+      if (stat(realfile, &fileinfo))
+       printf("%s: symlink to \"%s\", %s\n", filename, realfile,
+              strerror(errno));
+      else
+       printf("%s: symlink to \"%s\", %ld bytes\n", filename, realfile,
+              (long)fileinfo.st_size);
+    }
+    else
+      printf("%s: regular file, %ld bytes\n", filename, (long)fileinfo.st_size);
+
     if ((ppd = ppdOpenFile(filename)) == NULL)
     {
       ppd_status_t     err;            /* Last error in file */
index fbbc309293c2bff76d35ceeed65ceef27ba58e25..52983a9684a3a1674cad625a9a2a86cfab2f8616 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   SNMP test program 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
@@ -155,11 +155,13 @@ print_packet(cups_snmp_t *packet, /* I - SNMP response packet */
        break;
 
     case CUPS_ASN1_BIT_STRING :
-       printf("BIT-STRING \"%s\"\n", packet->object_value.string);
+       printf("BIT-STRING \"%s\"\n",
+              (char *)packet->object_value.string.bytes);
        break;
 
     case CUPS_ASN1_OCTET_STRING :
-       printf("OCTET-STRING \"%s\"\n", packet->object_value.string);
+       printf("OCTET-STRING \"%s\"\n",
+              (char *)packet->object_value.string.bytes);
        break;
 
     case CUPS_ASN1_NULL_VALUE :
@@ -173,8 +175,8 @@ print_packet(cups_snmp_t *packet,   /* I - SNMP response packet */
 
     case CUPS_ASN1_HEX_STRING :
        fputs("Hex-STRING", stdout);
-       for (i = 0; i < packet->object_value.hex_string.num_bytes; i ++)
-         printf(" %02X", packet->object_value.hex_string.bytes[i]);
+       for (i = 0; i < packet->object_value.string.num_bytes; i ++)
+         printf(" %02X", packet->object_value.string.bytes[i]);
        putchar('\n');
        break;
 
index 30c0f54906e79a52ee3038b61408876a535ab4de..57340e6a9c38bc59e1334f0dab189965dcd7f0e0 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Printing utilities 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
@@ -951,7 +951,8 @@ cupsGetPPD3(http_t     *http,               /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
     struct stat        ppdinfo;                /* PPD file information */
 
 
-    snprintf(ppdname, sizeof(ppdname), "%s/%s.ppd", cg->cups_serverroot, name);
+    snprintf(ppdname, sizeof(ppdname), "%s/ppd/%s.ppd", cg->cups_serverroot,
+             name);
     if (!stat(ppdname, &ppdinfo))
     {
      /*
@@ -1030,7 +1031,7 @@ cupsGetPPD3(http_t     *http,             /* I  - HTTP connection or @code CUPS_HTTP_DEFAUL
        }
       }
 
-      if (*modtime <= ppdinfo.st_mtime)
+      if (*modtime >= ppdinfo.st_mtime)
         return (HTTP_NOT_MODIFIED);
       else
       {
index 69ed05ab60aa9e6df80545d27693f7289a03c53b..7e67895bad2555d4a3b50c859538f38a210786f3 100644 (file)
@@ -4,7 +4,7 @@
  *   PDF to PostScript filter front-end 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
@@ -69,12 +69,8 @@ main(int  argc,                              /* I - Number of command-line args */
                pdfstatus,              /* Status from pdftops */
                pdfargc;                /* Number of args for pdftops */
   char         *pdfargv[100],          /* Arguments for pdftops/gs */
-#ifdef HAVE_PDFTOPS
                pdfwidth[255],          /* Paper width */
                pdfheight[255];         /* Paper height */
-#else
-               pdfgeometry[255];       /* Paper width and height */
-#endif /* HAVE_PDFTOPS */
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Actions for POSIX signals */
 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
@@ -215,7 +211,11 @@ main(int  argc,                            /* I - Number of command-line args */
     */
 
     size = ppdPageSize(ppd, NULL);
-    if (size)
+    if (size &&
+        (cupsGetOption("media", num_options, options) ||
+        cupsGetOption("media-col", num_options, options) ||
+        cupsGetOption("PageRegion", num_options, options) ||
+        cupsGetOption("PageSize", num_options, options))
     {
      /*
       * Got the size, now get the orientation...
@@ -261,25 +261,35 @@ main(int  argc,                           /* I - Number of command-line args */
       pdfargv[pdfargc++] = pdfwidth;
       pdfargv[pdfargc++] = (char *)"-paperh";
       pdfargv[pdfargc++] = pdfheight;
+
+      if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+         strcasecmp(val, "no") && strcasecmp(val, "off") &&
+         strcasecmp(val, "false"))
+       pdfargv[pdfargc++] = (char *)"-expand";
+
 #else
       if (orientation & 1)
-       snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->length,
+      {
+       snprintf(pdfwidth, sizeof(pdfwidth), "-dDEVICEWIDTHPOINTS=%.0f",
+                size->length);
+       snprintf(pdfheight, sizeof(pdfheight), "-dDEVICEHEIGHTPOINTS=%.0f",
                 size->width);
+      }
       else
-       snprintf(pdfgeometry, sizeof(pdfgeometry), "-g%.0fx%.0f", size->width,
+      {
+       snprintf(pdfwidth, sizeof(pdfwidth), "-dDEVICEWIDTHPOINTS=%.0f",
+                size->width);
+       snprintf(pdfheight, sizeof(pdfheight), "-dDEVICEHEIGHTPOINTS=%.0f",
                 size->length);
+      }
 
-      pdfargv[pdfargc++] = pdfgeometry;
+      pdfargv[pdfargc++] = pdfwidth;
+      pdfargv[pdfargc++] = pdfheight;
 #endif /* HAVE_PDFTOPS */
     }
   }
 
 #ifdef HAVE_PDFTOPS
-  if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
-      strcasecmp(val, "no") && strcasecmp(val, "off") &&
-      strcasecmp(val, "false"))
-    pdfargv[pdfargc++] = (char *)"-expand";
-
   pdfargv[pdfargc++] = filename;
   pdfargv[pdfargc++] = (char *)"-";
 #else
index 31c857f060cc43677f0a983c19d41b57d15e7faa..2321000a2ea71974cf31204cea4231e536b1892e 100644 (file)
@@ -945,7 +945,7 @@ ppdcDriver::write_ppd_file(
         continue;
 
       if (!o->text->value || !strcmp(o->name->value, o->text->value))
-       cupsFilePrintf(fp, "*OpenUI *%s: ", o->name->value,
+       cupsFilePrintf(fp, "*OpenUI *%s/%s: ", o->name->value,
                       catalog->find_message(o->name->value));
       else
        cupsFilePrintf(fp, "*OpenUI *%s/%s: ", o->name->value,
index 5e53c85778445cff5f7421172d02812410164730..87a55f15747c441f5b2bcabf8b2506627095b67a 100644 (file)
@@ -287,7 +287,7 @@ cupsdLoadAllClasses(void)
 {
   cups_file_t          *fp;            /* classes.conf file */
   int                  linenum;        /* Current line number */
-  char                 line[1024],     /* Line from file */
+  char                 line[4096],     /* Line from file */
                        *value,         /* Pointer to value */
                        *valueptr;      /* Pointer into value */
   cupsd_printer_t      *p,             /* Current printer class */
index f49ce453354ecae7a6887c698e8a05d0a27ddee4..a00ee62f7dd109a6d1d3252f3e8c1c7766b2e2db 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Client routines 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.
  *
  *   This file contains Kerberos support code, copyright 2006 by
@@ -283,16 +283,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
     * Map accesses from the same host to the server name.
     */
 
-    for (addr = ServerAddrs; addr; addr = addr->next)
-      if (httpAddrEqual(con->http.hostaddr, &(addr->addr)))
-        break;
-
-    if (addr)
-    {
-      strlcpy(con->http.hostname, ServerName, sizeof(con->http.hostname));
-      hostname = con->http.hostname;
-    }
-    else if (HostNameLookups)
+    if (HostNameLookups)
       hostname = httpAddrLookup(con->http.hostaddr, con->http.hostname,
                                 sizeof(con->http.hostname));
     else
@@ -2778,6 +2769,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
       buf[bytes] = '\0';
 
       for (bufptr = buf; !con->got_fields && *bufptr; bufptr ++)
+      {
         if (*bufptr == '\n')
        {
         /*
@@ -2788,7 +2780,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
            bufptr[-1] = '\0';
          *bufptr++ = '\0';
 
-          cupsdLogMessage(CUPSD_LOG_DEBUG2, "Script header: %s", buf);
+          cupsdLogMessage(CUPSD_LOG_DEBUG, "Script header: %s", buf);
 
           if (!con->sent_header)
          {
@@ -2833,7 +2825,12 @@ cupsdWriteClient(cupsd_client_t *con)    /* I - Client connection */
          */
 
          bytes -= (bufptr - buf);
-         memmove(buf, bufptr, bytes + 1);
+
+         if (bytes > 0)
+           memmove(buf, bufptr, bytes + 1);
+         else
+           buf[0] = '\0';
+
          bufptr = buf - 1;
 
          /*
@@ -2858,6 +2855,7 @@ cupsdWriteClient(cupsd_client_t *con)     /* I - Client connection */
        }
        else if (*bufptr != '\r')
          con->field_col ++;
+      }
 
       cupsdLogMessage(CUPSD_LOG_DEBUG2,
                       "cupsdWriteClient: %d bytes=%d, got_fields=%d",
index 6ea7208890aa84ece980b945fca1287a4f3058e4..3e447aeb0d290255c147e1a8dfb6b4d9f5db72fc 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Client definitions for the Common UNIX Printing System (CUPS) scheduler.
  *
- *   Copyright 2007 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
@@ -98,8 +98,6 @@ VAR cups_array_t      *Clients        VALUE(NULL),
                                        /* HTTP clients */
                        *ActiveClients  VALUE(NULL);
                                        /* Active HTTP clients */
-VAR http_addrlist_t    *ServerAddrs    VALUE(NULL);
-                                       /* Server address(es) */
 VAR char               *ServerHeader   VALUE(NULL);
                                        /* Server header in requests */
 VAR int                        CGIPipes[2]     VALUE2(-1,-1);
index 1f44e61af1fc675f4b27c591e53a701adadbd6b6..3d8b14b0718eeb0fbbf7293d5bb26ffbf896475d 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Configuration 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
@@ -264,7 +264,8 @@ cupsdCheckPermissions(
         return (-1);
       }
 
-      dir_created = 1;
+      dir_created      = 1;
+      fileinfo.st_mode = mode | S_IFDIR;
     }
     else
       return (create_dir ? -1 : 1);
@@ -425,12 +426,14 @@ cupsdReadConfiguration(void)
 
   cupsdDeleteAllListeners();
 
+  RemoteAccessEnabled = 0;
+
  /*
   * String options...
   */
 
-  cupsdSetString(&ServerName, httpGetHostname(NULL, temp, sizeof(temp)));
-  cupsdSetStringf(&ServerAdmin, "root@%s", temp);
+  cupsdClearString(&ServerName);
+  cupsdClearString(&ServerAdmin);
   cupsdSetString(&ServerBin, CUPS_SERVERBIN);
   cupsdSetString(&RequestRoot, CUPS_REQUESTS);
   cupsdSetString(&CacheDir, CUPS_CACHEDIR);
@@ -656,14 +659,38 @@ cupsdReadConfiguration(void)
 
   RunUser = getuid();
 
+  cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.",
+                  RemoteAccessEnabled ? "enabled" : "disabled");
+
  /*
   * See if the ServerName is an IP address...
   */
 
+  if (!ServerName)
+  {
+    if (HostNameLookups || RemoteAccessEnabled)
+      httpGetHostname(NULL, temp, sizeof(temp));
+    else if (gethostname(temp, sizeof(temp)))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",
+                      strerror(errno));
+      strlcpy(temp, "localhost", sizeof(temp));
+    }
+
+    cupsdSetString(&ServerName, temp);
+  }
+
   for (slash = ServerName; isdigit(*slash & 255) || *slash == '.'; slash ++);
 
   ServerNameIsIP = !*slash;
 
+ /*
+  * Make sure ServerAdmin is initialized...
+  */
+
+  if (!ServerAdmin)
+    cupsdSetStringf(&ServerAdmin, "root@%s", ServerName);
+
  /*
   * Use the default system group if none was supplied in cupsd.conf...
   */
@@ -2451,6 +2478,9 @@ read_configuration(cups_file_t *fp)       /* I - File to read from */
 #endif /* AF_LOCAL */
        cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv4)", temp,
                         ntohs(lis->address.ipv4.sin_port));
+
+        if (!httpAddrLocalhost(&(lis->address)))
+         RemoteAccessEnabled = 1;
       }
 
      /*
index 1d534fbcaf396a56bc8554467132b4312759d341..025f6a91565cdf0ed6d97d92b55a333bc2612d20 100644 (file)
@@ -95,7 +95,10 @@ VAR char             *ConfigurationFile      VALUE(NULL),
                                        /* Directory for request files */
                        *DocumentRoot           VALUE(NULL);
                                        /* Root directory for documents */
-VAR int                        ServerNameIsIP          VALUE(0);
+VAR int                        RemoteAccessEnabled     VALUE(0),
+                                       /* Are we listening on non-local addresses? */
+                       ServerNameIsIP          VALUE(0);
+                                       /* Is the ServerName an IP address? */
 VAR int                        NumSystemGroups         VALUE(0);
                                        /* Number of system group names */
 VAR char               *SystemGroups[MAX_SYSTEM_GROUPS]
@@ -160,7 +163,7 @@ VAR int                     AccessLogLevel          VALUE(CUPSD_ACCESSLOG_ACTIONS),
                                        /* Permissions for log files */
                        LogLevel                VALUE(CUPSD_LOG_WARN),
                                        /* Error log level */
-                       MaxClients              VALUE(0),
+                       MaxClients              VALUE(100),
                                        /* Maximum number of clients */
                        MaxClientsPerHost       VALUE(0),
                                        /* Maximum number of clients per host */
index 1b551c09e078134857c778df051423d6044dfd25..4cc80c7061f76c8faeb9f34cd2e6775c371b1523 100644 (file)
@@ -331,8 +331,8 @@ cat_drv(const char *name,           /* I - PPD name */
   for (d = (ppdcDriver *)src->drivers->first();
        d;
        d = (ppdcDriver *)src->drivers->next())
-    if (!strcasecmp(pc_file_name, d->pc_file_name->value) ||
-        (d->file_name && !strcasecmp(pc_file_name, d->file_name->value)))
+    if (!strcmp(pc_file_name, d->pc_file_name->value) ||
+        (d->file_name && !strcmp(pc_file_name, d->file_name->value)))
       break;
 
   if (d)
@@ -678,10 +678,10 @@ compare_names(const ppd_info_t *p0,       /* I - First PPD file */
   int  diff;                           /* Difference between strings */
 
 
-  if ((diff = strcasecmp(p0->record.filename, p1->record.filename)) != 0)
+  if ((diff = strcmp(p0->record.filename, p1->record.filename)) != 0)
     return (diff);
   else
-    return (strcasecmp(p0->record.name, p1->record.name));
+    return (strcmp(p0->record.name, p1->record.name));
 }
 
 
@@ -706,8 +706,7 @@ compare_ppds(const ppd_info_t *p0,  /* I - First PPD file */
                                      p1->record.make_and_model)) != 0)
     return (diff);
   else
-    return (strcasecmp(p0->record.languages[0],
-                       p1->record.languages[0]));
+    return (strcmp(p0->record.languages[0], p1->record.languages[0]));
 }
 
 
@@ -1111,7 +1110,7 @@ list_ppds(int        request_id,  /* I - Request ID */
       {
        for (i = 0; i < PPD_MAX_LANG; i ++)
          if (!ppd->record.languages[i][0] ||
-             !strcasecmp(ppd->record.languages[i], language))
+             !strcmp(ppd->record.languages[i], language))
          {
            ppd->matches ++;
            break;
@@ -1453,7 +1452,7 @@ load_ppds(const char *d,          /* I - Actual directory */
         ppd->found = 1;
       }
       while ((ppd = (ppd_info_t *)cupsArrayNext(PPDsByName)) != NULL &&
-            !strcasecmp(ppd->record.filename, name));
+            !strcmp(ppd->record.filename, name));
 
       continue;
     }
@@ -1725,7 +1724,7 @@ load_ppds(const char *d,          /* I - Actual directory */
     }
 
     for (i = 0; i < (int)(sizeof(languages) / sizeof(languages[0])); i ++)
-      if (!strcasecmp(languages[i].version, lang_version))
+      if (!strcmp(languages[i].version, lang_version))
         break;
 
     if (i < (int)(sizeof(languages) / sizeof(languages[0])))
index d51f54630f614e0a8206b1bbf2a2d191a3a39979..54749128a86b0652fe4bcdd9d83c68baefc0257d 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Directory services 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
@@ -283,7 +283,7 @@ cupsdLoadRemoteCache(void)
 {
   cups_file_t          *fp;            /* remote.cache file */
   int                  linenum;        /* Current line number */
-  char                 line[1024],     /* Line from file */
+  char                 line[4096],     /* Line from file */
                        *value,         /* Pointer to value */
                        *valueptr,      /* Pointer into value */
                        scheme[32],     /* Scheme portion of URI */
@@ -2217,6 +2217,7 @@ dnssdBuildTxtRecord(
                rp_str[1024],           /* Queue name string buffer */
                air_str[1024],          /* auth-info-required string buffer */
                *keyvalue[32][2];       /* Table of key/value pairs */
+  ipp_attribute_t *air_attr;           /* auth-info-required attribute */
 
 
  /*
@@ -2326,12 +2327,14 @@ dnssdBuildTxtRecord(
   keyvalue[i  ][0] = "pdl";
   keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
 
-  if (p->num_auth_info_required)
+  if ((air_attr = ippFindAttribute(p->attrs, "auth-info-required",
+                                   IPP_TAG_KEYWORD)) != NULL &&
+      strcmp(air_attr->values[0].string.text, "none"))
   {
     char       *air = air_str;         /* Pointer into string */
 
 
-    for (j = 0; j < p->num_auth_info_required; j ++)
+    for (j = 0; j < air_attr->num_values; j ++)
     {
       if (air >= (air_str + sizeof(air_str) - 2))
         break;
@@ -2339,7 +2342,8 @@ dnssdBuildTxtRecord(
       if (j)
         *air++ = ',';
 
-      strlcpy(air, p->auth_info_required[j], sizeof(air_str) - (air - air_str));
+      strlcpy(air, air_attr->values[j].string.text,
+              sizeof(air_str) - (air - air_str));
       air += strlen(air);
     }
 
index e9e3e73f49ba6942011ebe93c0d69151b507b442..a867cbbc8e31b2fc8fcfc1f24fb29c8ad2b3d979 100644 (file)
@@ -711,6 +711,11 @@ cupsdProcessIPPRequest(
                    uri ? uri->values[0].string.text : "no URI",
                    con->http.hostname);
 
+    if (LogLevel == CUPSD_LOG_DEBUG2)
+      cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                     "cupsdProcessIPPRequest: ippLength(response)=%ld",
+                     (long)ippLength(con->response));
+
     if (cupsdSendHeader(con, HTTP_OK, "application/ipp", CUPSD_AUTH_NONE))
     {
 #ifdef CUPSD_USE_CHUNKING
@@ -3413,8 +3418,8 @@ apple_register_profiles(
     * Use the default colorspace...
     */
 
-    num_profiles = 1 + ppd->colorspace != PPD_CS_GRAY;
-    
+    num_profiles = 2;
+
     if ((profiles = calloc(num_profiles, sizeof(CMDeviceProfileArray))) == NULL)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
@@ -3443,13 +3448,11 @@ apple_register_profiles(
           break;
 
       case PPD_CS_N :
+      default :
           apple_init_profile(ppd, NULL, profiles->profiles + 1,
                             _ppdHashName("DeviceN.."), "DeviceN", "DeviceN",
                             NULL);
           break;
-
-      default :
-         break;
     }
   }
 
@@ -4378,16 +4381,7 @@ check_quotas(cupsd_client_t  *con,       /* I - Client connection */
                          "entry ignored", p->users[i]);
        }
 
-       if ((mbr_err = mbr_check_membership(usr_uuid, usr2_uuid,
-                                           &is_member)) != 0)
-       {
-         cupsdLogMessage(CUPSD_LOG_DEBUG,
-                         "check_quotas: User \"%s\" identity check failed "
-                         "(err=%d)", p->users[i], mbr_err);
-         is_member = 0;
-       }
-
-       if (is_member)
+       if (!uuid_compare(usr_uuid, usr2_uuid))
          break;
       }
 #else
@@ -6928,7 +6922,7 @@ get_jobs(cupsd_client_t  *con,            /* I - Client connection */
     completed = 0;
     list      = Jobs;
   }
-  else if (attr && !strcmp(attr->values[0].string.text, "printing"))
+  else if (attr && !strcmp(attr->values[0].string.text, "processing"))
   {
     completed = 0;
     list      = PrintingJobs;
@@ -6980,7 +6974,10 @@ get_jobs(cupsd_client_t  *con,           /* I - Client connection */
     * Filter out jobs that don't match...
     */
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: job->id = %d", job->id);
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                    "get_jobs: job->id=%d, dest=\"%s\", username=\"%s\", "
+                   "state_value=%d, attrs=%p", job->id, job->dest,
+                   job->username, job->state_value, job->attrs);
 
     if (!job->dest || !job->username)
       cupsdLoadJob(job);
@@ -7003,7 +7000,11 @@ get_jobs(cupsd_client_t  *con,           /* I - Client connection */
     cupsdLoadJob(job);
 
     if (!job->attrs)
+    {
+      cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d!",
+                      job->id);
       continue;
+    }
 
     if (username[0] && strcasecmp(username, job->username))
       continue;
@@ -7013,11 +7014,11 @@ get_jobs(cupsd_client_t  *con,          /* I - Client connection */
 
     count ++;
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count = %d", count);
-
     copy_job_attrs(con, job, ra);
   }
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count=%d", count);
+
   cupsArrayDelete(ra);
 
   con->response->request.status.status_code = IPP_OK;
index 2ab8798d8d9f84f88459705ca3fe143d4f50bbec..2b4f9e0fdea16c868d29185ad8dd6fdaf064398e 100644 (file)
@@ -4,7 +4,7 @@
  *   Server listening routines 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,23 +142,6 @@ cupsdStartListening(void)
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdStartListening: %d Listeners",
                   cupsArrayCount(Listeners));
 
- /*
-  * Get the server's IP address...
-  */
-
-  if (ServerAddrs)
-    httpAddrFreeList(ServerAddrs);
-
-  if ((ServerAddrs = httpAddrGetList(ServerName, AF_UNSPEC, NULL)) == NULL)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "Unable to find IP address for server name \"%s\"!",
-                   ServerName);
-
-    if (FatalErrors & CUPSD_FATAL_LISTEN)
-      cupsdEndProcess(getpid(), 0);
-  }
-
  /*
   * Setup socket listeners...
   */
index 6e15655afd994c9a7e203f43a75cb2aa3d75fefd..e35c2f0fc8ea64067f6650462be5927cfc785edc 100644 (file)
@@ -4,7 +4,7 @@
  *   Network interface functions 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
@@ -100,7 +100,6 @@ cupsdNetIFUpdate(void)
   cupsd_netif_t                *temp;          /* New interface */
   struct ifaddrs       *addrs,         /* Interface address list */
                        *addr;          /* Current interface address */
-  http_addrlist_t      *saddr;         /* Current server address */
   char                 hostname[1024]; /* Hostname for address */
 
 
@@ -155,7 +154,7 @@ cupsdNetIFUpdate(void)
     * Try looking up the hostname for the address as needed...
     */
 
-    if (HostNameLookups)
+    if (HostNameLookups || RemoteAccessEnabled)
       httpAddrLookup((http_addr_t *)(addr->ifa_addr), hostname,
                      sizeof(hostname));
     else
@@ -169,17 +168,8 @@ cupsdNetIFUpdate(void)
       if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))
         strcpy(hostname, "localhost");
       else
-      {
-        for (saddr = ServerAddrs; saddr; saddr = saddr->next)
-         if (httpAddrEqual((http_addr_t *)(addr->ifa_addr), &(saddr->addr)))
-           break;
-
-       if (saddr)
-          strlcpy(hostname, ServerName, sizeof(hostname));
-       else
-          httpAddrString((http_addr_t *)(addr->ifa_addr), hostname,
-                        sizeof(hostname));
-      }
+       httpAddrString((http_addr_t *)(addr->ifa_addr), hostname,
+                      sizeof(hostname));
     }
 
    /*
index d32a09b8f7939d70ef16fb46e32f34ca14bfa17b..7c57f0761f37d39fa8416e787f191be4010ae82f 100644 (file)
@@ -929,7 +929,7 @@ cupsdLoadAllPrinters(void)
 {
   cups_file_t          *fp;            /* printers.conf file */
   int                  linenum;        /* Current line number */
-  char                 line[1024],     /* Line from file */
+  char                 line[4096],     /* Line from file */
                        *value,         /* Pointer to value */
                        *valueptr;      /* Pointer into value */
   cupsd_printer_t      *p;             /* Current printer */
@@ -2625,6 +2625,25 @@ cupsdSetPrinterReasons(
                *rptr;                  /* Pointer into reason */
 
 
+  if (!p || !s)
+  {
+    cupsdLogMessage(CUPSD_LOG_EMERG,
+                    "cupsdSetPrinterReasons called with p=%p and s=%p!", p, s);
+    return;
+  }
+
+  if (LogLevel == CUPSD_LOG_DEBUG2)
+  {
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                   "cupsdSetPrinterReasons(p=%p(%s),s=\"%s\"", p, p->name, s);
+    cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSetPrinterReasons: num_reasons=%d",
+                    p->num_reasons);
+    for (i = 0; i < p->num_reasons; i ++)
+      cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                      "cupsdSetPrinterReasons: reasons[%d]=%p(\"%s\")", i,
+                     p->reasons[i], p->reasons[i]);
+  }
+
   if (s[0] == '-' || s[0] == '+')
   {
    /*
@@ -2684,12 +2703,16 @@ cupsdSetPrinterReasons(
       */
 
       for (i = 0; i < p->num_reasons; i ++)
-        if (!strcasecmp(reason, p->reasons[i]))
+        if (!strcmp(reason, p->reasons[i]))
        {
         /*
          * Found a match, so remove it...
          */
 
+         cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                         "cupsdSetPrinterReasons: Removing \"%s\" at index %d",
+                         reason, i);
+
          p->num_reasons --;
          _cupsStrFree(p->reasons[i]);
 
@@ -2697,8 +2720,6 @@ cupsdSetPrinterReasons(
            memmove(p->reasons + i, p->reasons + i + 1,
                    (p->num_reasons - i) * sizeof(char *));
 
-         i --;
-
           if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED)
            cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
 
@@ -2707,6 +2728,8 @@ cupsdSetPrinterReasons(
 
          if (PrintcapFormat == PRINTCAP_PLIST)
            cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+
+         break;
        }
     }
     else if (p->num_reasons < (int)(sizeof(p->reasons) / sizeof(p->reasons[0])))
@@ -2716,11 +2739,23 @@ cupsdSetPrinterReasons(
       */
 
       for (i = 0; i < p->num_reasons; i ++)
-        if (!strcasecmp(reason, p->reasons[i]))
+        if (!strcmp(reason, p->reasons[i]))
          break;
 
       if (i >= p->num_reasons)
       {
+        if (i >= (int)(sizeof(p->reasons) / sizeof(p->reasons[0])))
+       {
+         cupsdLogMessage(CUPSD_LOG_ALERT,
+                         "Too many printer-state-reasons values for %s (%d)",
+                         p->name, i + 1);
+          return;
+        }
+
+       cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                       "cupsdSetPrinterReasons: Adding \"%s\" at index %d",
+                       reason, i);
+
         p->reasons[i] = _cupsStrAlloc(reason);
        p->num_reasons ++;
 
@@ -2735,6 +2770,17 @@ cupsdSetPrinterReasons(
       }
     }
   }
+
+  if (LogLevel == CUPSD_LOG_DEBUG2)
+  {
+    cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                    "cupsdSetPrinterReasons: NEW num_reasons=%d",
+                    p->num_reasons);
+    for (i = 0; i < p->num_reasons; i ++)
+      cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                      "cupsdSetPrinterReasons: NEW reasons[%d]=%p(\"%s\")", i,
+                     p->reasons[i], p->reasons[i]);
+  }
 }
 
 
@@ -3236,140 +3282,137 @@ cupsdWritePrintcap(void)
                        "# %s/printers.conf file.  All changes to this file\n"
                       "# will be lost.\n", ServerRoot);
 
-  if (Printers)
+ /*
+  * Write a new printcap with the current list of printers.
+  */
+
+  switch (PrintcapFormat)
   {
-   /*
-    * Write a new printcap with the current list of printers.
-    */
+    case PRINTCAP_BSD :
+       /*
+       * Each printer is put in the file as:
+       *
+       *    Printer1:
+       *    Printer2:
+       *    Printer3:
+       *    ...
+       *    PrinterN:
+       */
 
-    switch (PrintcapFormat)
-    {
-      case PRINTCAP_BSD :
-        /*
-          * Each printer is put in the file as:
-         *
-         *    Printer1:
-         *    Printer2:
-         *    Printer3:
-         *    ...
-         *    PrinterN:
-         */
+       if (DefaultPrinter)
+         cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name,
+                        DefaultPrinter->info, ServerName,
+                        DefaultPrinter->name);
+
+       for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+            p;
+            p = (cupsd_printer_t *)cupsArrayNext(Printers))
+         if (p != DefaultPrinter)
+           cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info,
+                          ServerName, p->name);
+       break;
 
-          if (DefaultPrinter)
-           cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", DefaultPrinter->name,
-                          DefaultPrinter->info, ServerName,
-                          DefaultPrinter->name);
-
-         for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
-              p;
-              p = (cupsd_printer_t *)cupsArrayNext(Printers))
-           if (p != DefaultPrinter)
-             cupsFilePrintf(fp, "%s|%s:rm=%s:rp=%s:\n", p->name, p->info,
-                            ServerName, p->name);
-          break;
-
-      case PRINTCAP_PLIST :
-         /*
-         * Each printer is written as a dictionary in a plist file.
-         * Currently the printer-name, printer-info, printer-is-accepting-jobs,
-         * printer-location, printer-make-and-model, printer-state,
-         * printer-state-reasons, printer-type, and (sanitized) device-uri.
-         */
+    case PRINTCAP_PLIST :
+       /*
+       * Each printer is written as a dictionary in a plist file.
+       * Currently the printer-name, printer-info, printer-is-accepting-jobs,
+       * printer-location, printer-make-and-model, printer-state,
+       * printer-state-reasons, printer-type, and (sanitized) device-uri.
+       */
 
-          cupsFilePuts(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-                          "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD "
-                          "PLIST 1.0//EN\" \"http://www.apple.com/DTDs/"
-                          "PropertyList-1.0.dtd\">\n"
-                          "<plist version=\"1.0\">\n"
-                          "<array>\n");
-
-         for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
-              p;
-              p = (cupsd_printer_t *)cupsArrayNext(Printers))
-          {
-           cupsFilePuts(fp, "\t<dict>\n"
-                            "\t\t<key>printer-name</key>\n"
-                            "\t\t<string>");
-            write_xml_string(fp, p->name);
-           cupsFilePuts(fp, "</string>\n"
-                            "\t\t<key>printer-info</key>\n"
-                            "\t\t<string>");
-            write_xml_string(fp, p->info);
-           cupsFilePrintf(fp, "</string>\n"
-                              "\t\t<key>printer-is-accepting-jobs</key>\n"
-                              "\t\t<%s/>\n"
-                              "\t\t<key>printer-location</key>\n"
-                              "\t\t<string>", p->accepting ? "true" : "false");
-            write_xml_string(fp, p->location);
-           cupsFilePuts(fp, "</string>\n"
-                            "\t\t<key>printer-make-and-model</key>\n"
-                            "\t\t<string>");
-            write_xml_string(fp, p->make_model);
-           cupsFilePrintf(fp, "</string>\n"
-                              "\t\t<key>printer-state</key>\n"
-                              "\t\t<integer>%d</integer>\n"
-                              "\t\t<key>printer-state-reasons</key>\n"
-                              "\t\t<array>\n", p->state);
-            for (i = 0; i < p->num_reasons; i ++)
-           {
-             cupsFilePuts(fp, "\t\t\t<string>");
-             write_xml_string(fp, p->reasons[i]);
-             cupsFilePuts(fp, "</string>\n");
-           }
-           cupsFilePrintf(fp, "\t\t</array>\n"
-                              "\t\t<key>printer-type</key>\n"
-                              "\t\t<integer>%d</integer>\n"
-                              "\t\t<key>device-uri</key>\n"
-                              "\t\t<string>", p->type);
-            write_xml_string(fp, p->sanitized_device_uri);
-           cupsFilePuts(fp, "</string>\n"
-                            "\t</dict>\n");
-          }
-         cupsFilePuts(fp, "</array>\n"
-                          "</plist>\n");
-         break;
+       cupsFilePuts(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+                        "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD "
+                        "PLIST 1.0//EN\" \"http://www.apple.com/DTDs/"
+                        "PropertyList-1.0.dtd\">\n"
+                        "<plist version=\"1.0\">\n"
+                        "<array>\n");
 
-      case PRINTCAP_SOLARIS :
-        /*
-          * Each printer is put in the file as:
-         *
-         *    _all:all=Printer1,Printer2,Printer3,...,PrinterN
-         *    _default:use=DefaultPrinter
-         *    Printer1:\
-         *            :bsdaddr=ServerName,Printer1:\
-         *            :description=Description:
-         *    Printer2:
-         *            :bsdaddr=ServerName,Printer2:\
-         *            :description=Description:
-         *    Printer3:
-         *            :bsdaddr=ServerName,Printer3:\
-         *            :description=Description:
-         *    ...
-         *    PrinterN:
-         *            :bsdaddr=ServerName,PrinterN:\
-         *            :description=Description:
-         */
+       for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+            p;
+            p = (cupsd_printer_t *)cupsArrayNext(Printers))
+       {
+         cupsFilePuts(fp, "\t<dict>\n"
+                          "\t\t<key>printer-name</key>\n"
+                          "\t\t<string>");
+         write_xml_string(fp, p->name);
+         cupsFilePuts(fp, "</string>\n"
+                          "\t\t<key>printer-info</key>\n"
+                          "\t\t<string>");
+         write_xml_string(fp, p->info);
+         cupsFilePrintf(fp, "</string>\n"
+                            "\t\t<key>printer-is-accepting-jobs</key>\n"
+                            "\t\t<%s/>\n"
+                            "\t\t<key>printer-location</key>\n"
+                            "\t\t<string>", p->accepting ? "true" : "false");
+         write_xml_string(fp, p->location);
+         cupsFilePuts(fp, "</string>\n"
+                          "\t\t<key>printer-make-and-model</key>\n"
+                          "\t\t<string>");
+         write_xml_string(fp, p->make_model);
+         cupsFilePrintf(fp, "</string>\n"
+                            "\t\t<key>printer-state</key>\n"
+                            "\t\t<integer>%d</integer>\n"
+                            "\t\t<key>printer-state-reasons</key>\n"
+                            "\t\t<array>\n", p->state);
+         for (i = 0; i < p->num_reasons; i ++)
+         {
+           cupsFilePuts(fp, "\t\t\t<string>");
+           write_xml_string(fp, p->reasons[i]);
+           cupsFilePuts(fp, "</string>\n");
+         }
+         cupsFilePrintf(fp, "\t\t</array>\n"
+                            "\t\t<key>printer-type</key>\n"
+                            "\t\t<integer>%d</integer>\n"
+                            "\t\t<key>device-uri</key>\n"
+                            "\t\t<string>", p->type);
+         write_xml_string(fp, p->sanitized_device_uri);
+         cupsFilePuts(fp, "</string>\n"
+                          "\t</dict>\n");
+       }
+       cupsFilePuts(fp, "</array>\n"
+                        "</plist>\n");
+       break;
 
-          cupsFilePuts(fp, "_all:all=");
-         for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
-              p;
-              p = (cupsd_printer_t *)cupsArrayCurrent(Printers))
-           cupsFilePrintf(fp, "%s%c", p->name,
-                          cupsArrayNext(Printers) ? ',' : '\n');
-
-          if (DefaultPrinter)
-           cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name);
-
-         for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
-              p;
-              p = (cupsd_printer_t *)cupsArrayNext(Printers))
-           cupsFilePrintf(fp, "%s:\\\n"
-                              "\t:bsdaddr=%s,%s:\\\n"
-                              "\t:description=%s:\n",
-                          p->name, ServerName, p->name,
-                          p->info ? p->info : "");
-          break;
-    }
+    case PRINTCAP_SOLARIS :
+       /*
+       * Each printer is put in the file as:
+       *
+       *    _all:all=Printer1,Printer2,Printer3,...,PrinterN
+       *    _default:use=DefaultPrinter
+       *    Printer1:\
+       *            :bsdaddr=ServerName,Printer1:\
+       *            :description=Description:
+       *    Printer2:
+       *            :bsdaddr=ServerName,Printer2:\
+       *            :description=Description:
+       *    Printer3:
+       *            :bsdaddr=ServerName,Printer3:\
+       *            :description=Description:
+       *    ...
+       *    PrinterN:
+       *            :bsdaddr=ServerName,PrinterN:\
+       *            :description=Description:
+       */
+
+       cupsFilePuts(fp, "_all:all=");
+       for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+            p;
+            p = (cupsd_printer_t *)cupsArrayCurrent(Printers))
+         cupsFilePrintf(fp, "%s%c", p->name,
+                        cupsArrayNext(Printers) ? ',' : '\n');
+
+       if (DefaultPrinter)
+         cupsFilePrintf(fp, "_default:use=%s\n", DefaultPrinter->name);
+
+       for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+            p;
+            p = (cupsd_printer_t *)cupsArrayNext(Printers))
+         cupsFilePrintf(fp, "%s:\\\n"
+                            "\t:bsdaddr=%s,%s:\\\n"
+                            "\t:description=%s:\n",
+                        p->name, ServerName, p->name,
+                        p->info ? p->info : "");
+       break;
   }
 
  /*
index fac12b2455eadafdd15318883e2254946e8cb383..c7b26ee8c445b84fd0d59f14e6718a219950389d 100644 (file)
@@ -52,7 +52,7 @@ typedef struct cupsd_printer_s
   ipp_pstate_t state;                  /* Printer state */
   char         state_message[1024];    /* Printer state message */
   int          num_reasons;            /* Number of printer-state-reasons */
-  char         *reasons[16];           /* printer-state-reasons strings */
+  char         *reasons[64];           /* printer-state-reasons strings */
   time_t       state_time;             /* Time at this state */
   char         *job_sheets[2];         /* Banners/job sheets */
   cups_ptype_t type;                   /* Printer type (color, small, etc.) */
index 8b4f4a85182c6ea8d1bfe5656ef92d36314ad071..907c02acab0dd4f9b8d97fcea2730c8a337a0429 100644 (file)
@@ -10,7 +10,7 @@
 <TABLE>
 <TR>
 <TH CLASS="label">Connection:</TH>
-<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1024" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
+<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1023" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
 </TR>
 <TR>
 <TD></TD>
index eddf2815056299261b128dd8063c27cdbae5cbd1..a7ff12d2cee16108a7b053723ab532440f7d9287 100644 (file)
@@ -10,7 +10,7 @@
 <TABLE>
 <TR>
 <TH CLASS="label">Conexi&oacute;n:</TH>
-<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1024" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
+<TD><INPUT TYPE="TEXT" SIZE="60" MAXLENGTH="1023" NAME="DEVICE_URI" VALUE="{current_device_uri?{current_device_uri}:{device_uri}}"></TD>
 </TR>
 <TR>
 <TD></TD>
index 30bda2d46fe3b1964970aba6bc3bab35865f92a8..a21980ea6a4553a0d1182df178df6cc308df8d42 100644 (file)
@@ -4,7 +4,7 @@
 #
 #   Test the lpadmin 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
@@ -16,8 +16,8 @@
 
 echo "Add Printer Test"
 echo ""
-echo "    lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/DESKJET.PPD"
-../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/DESKJET.PPD 2>&1
+echo "    lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd"
+../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
diff --git a/test/create-printer-subscription.test b/test/create-printer-subscription.test
new file mode 100644 (file)
index 0000000..c6427ef
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $"
+#
+#   Verify that the CUPS subscription operations work.
+#
+{
+       # The name of the test...
+       NAME "Add Printer Subscription w/Lease"
+
+       # The operation to use
+       OPERATION Create-Printer-Subscription
+       RESOURCE /
+
+       # The attributes to send
+       GROUP operation
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+
+        GROUP subscription
+       ATTR uri notify-recipient testnotify://nowait
+       ATTR keyword notify-events printer-state-changed
+
+       # What statuses are OK?
+       STATUS successful-ok
+
+       # What attributes do we expect?
+       EXPECT attributes-charset
+       EXPECT attributes-natural-language
+       EXPECT notify-subscription-id
+       DISPLAY notify-subscription-id
+}
+
+#
+# End of "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $"
+#
diff --git a/test/get-subscriptions.test b/test/get-subscriptions.test
new file mode 100644 (file)
index 0000000..686059d
--- /dev/null
@@ -0,0 +1,21 @@
+# Get subscriptions using Get-Subscriptions
+{
+       # The name of the test...
+       NAME "Get subscriptions using Get-Subscriptions"
+
+       # The resource to use for the POST
+       # RESOURCE /admin
+
+       # The operation to use
+       OPERATION Get-Subscriptions
+
+       # 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
+
+       # What statuses are OK?
+       STATUS ok
+       STATUS ok-subst
+}
index 7a6cdc6a66d0b487be264e45400615715693beff..c36c9bb2e4fb72497cc8b2ccd6d9b77c951bf27f 100755 (executable)
@@ -5,7 +5,7 @@
 #   Perform the complete set of IPP compliance tests specified in the
 #   CUPS Software Test Plan.
 #
-#   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
@@ -188,7 +188,7 @@ echo ""
 
 case "$usevalgrind" in
        Y* | y*)
-               valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes"
+               valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes --read-var-info=yes"
                echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
                ;;