]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge changes from CUPS 1.6svn-r10127.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 28 Nov 2011 17:26:29 +0000 (17:26 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 28 Nov 2011 17:26:29 +0000 (17:26 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@3518 a1ca3aef-8c08-0410-bb20-df032aa958be

18 files changed:
cups/cups.h
cups/dest.c
cups/ipp-support.c
cups/ipp.c
cups/ipp.h
cups/language.c
cups/libcups2.def
cups/libcups_s.exp
cups/ppd-private.h
cups/ppd.c
cups/ppd.h
cups/testppd.c
cups/versioning.h
scheduler/Makefile
scheduler/conf.c
scheduler/cupsfilter.c
scheduler/ipp.c
scheduler/printers.c

index cb82ddfc0b1d487b8beb789314d1b20163af22c5..bdfd3aeef924593ccb289467ad9a767ba1ba9ccd 100644 (file)
 typedef off_t ssize_t;                 /* @private@ */
 #  endif /* WIN32 && !__CUPS_SSIZE_T_DEFINED */
 
+#  ifdef __BLOCKS__
+#    include <dispatch/dispatch.h>
+#  endif /* __BLOCKS__ */
+
 #  include "file.h"
 #  include "ipp.h"
 #  include "language.h"
@@ -111,22 +115,6 @@ enum cups_ptype_e                  /**** Printer type/capability bit constants ****/
   CUPS_PRINTER_OPTIONS = 0x6fffc       /* ~(CLASS | REMOTE | IMPLICIT | DEFAULT | FAX | REJECTING | DELETE | NOT_SHARED | AUTHENTICATED | COMMANDS | DISCOVERED) @private@ */
 };
 
-typedef const char *(*cups_password_cb_t)(const char *prompt);
-                                       /**** Password callback ****/
-
-typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http,
-                                          const char *method,
-                                          const char *resource,
-                                          void *user_data);
-                                       /**** New password callback @since CUPS 1.4/Mac OS X 10.6@ ****/
-
-typedef void (*cups_device_cb_t)(const char *device_class,
-                                 const char *device_id, const char *device_info,
-                                 const char *device_make_and_model,
-                                 const char *device_uri,
-                                const char *device_location, void *user_data);
-                                       /**** Device callback @since CUPS 1.4/Mac OS X 10.6@ ****/
-
 typedef struct cups_option_s           /**** Printer Options ****/
 {
   char         *name;                  /* Name of option */
@@ -162,6 +150,32 @@ typedef int (*cups_client_cert_cb_t)(http_t *http, void *tls,
                                     void *user_data);
                                        /**** Client credentials callback @since CUPS 1.5/Mac OS X 10.7@ ****/
 
+typedef int (*cups_dest_cb_t)(void *user_data, const char *name, const char *instance,
+                             int num_options, cups_option_t *options);
+                                       /**** Destination enumeration callback @since CUPS 1.6@ ****/
+
+#  ifdef __BLOCKS__
+typedef int (^cups_dest_block_t)(const char *name, const char *instance, int num_options,
+                                cups_option_t *options);
+                                       /**** Destination enumeration block @since CUPS 1.6@ ****/
+#  endif /* __BLOCKS__ */
+
+typedef void (*cups_device_cb_t)(const char *device_class,
+                                 const char *device_id, const char *device_info,
+                                 const char *device_make_and_model,
+                                 const char *device_uri,
+                                const char *device_location, void *user_data);
+                                       /**** Device callback @since CUPS 1.4/Mac OS X 10.6@ ****/
+
+typedef const char *(*cups_password_cb_t)(const char *prompt);
+                                       /**** Password callback ****/
+
+typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http,
+                                          const char *method,
+                                          const char *resource,
+                                          void *user_data);
+                                       /**** New password callback @since CUPS 1.4/Mac OS X 10.6@ ****/
+
 typedef int (*cups_server_cert_cb_t)(http_t *http, void *tls,
                                     cups_array_t *certs, void *user_data);
                                        /**** Server credentials callback @since CUPS 1.5/Mac OS X 10.7@ ****/
@@ -321,6 +335,12 @@ extern int         cupsSetCredentials(cups_array_t *certs) _CUPS_API_1_5;
 extern void            cupsSetServerCertCB(cups_server_cert_cb_t cb,
                                            void *user_data) _CUPS_API_1_5;
 
+/**** New in CUPS 1.6 ****/
+extern http_t          *cupsConnectDest(cups_dest_t *dest);
+extern int             cupsEnumDests(cups_dest_cb_t cb, void *user_data) _CUPS_API_1_6;
+#  ifdef __BLOCKS__
+extern int             cupsEnumDestsBlock(cups_dest_block_t block) _CUPS_API_1_6;
+#  endif /* __BLOCKS__ */
 
 #  ifdef __cplusplus
 }
index 7ef6306634c3fd044e5944c7fe11ae69aa763796..4ba18f41b8377490a3befe7790828dbe16dcb282 100644 (file)
  *
  * Contents:
  *
- *   cupsAddDest()                  - Add a destination to the list of
- *                                    destinations.
+ *   cupsdDeregisterPrinter() - Stop sending broadcast information for a local
+ *                             printer and remove any pending references to
+ *                             remote printers.
+ *   cupsdRegisterPrinter()   - Start sending broadcast information for a
+ *                             printer or update the broadcast contents.
+ *   cupsdStartBrowsing()     - Start sending and receiving broadcast
+ *                             information.
+ *   cupsdStopBrowsing()      - Stop sending and receiving broadcast
+ *                             information.
+ *   cupsdUpdateDNSSDName()   - Update the computer name we use for browsing...
+ *   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
+ *                             printer.
+ *   dnssdPackTxtRecord()     - Pack an array of key/value pairs into the TXT
+ *                             record format.
+ *   dnssdRegisterCallback()  - DNSServiceRegister callback.
+ *   dnssdRegisterPrinter()   - Start sending broadcast information for a
+ *                             printer or update the broadcast contents.
+ *   dnssdStop()             - Stop all DNS-SD registrations.
+ *   dnssdUpdate()           - Handle DNS-SD queries.
+ *   get_auth_info_required() - Get the auth-info-required value to advertise.
+ *   get_hostconfig()        - Get an /etc/hostconfig service setting.
+ *   update_lpd()            - Update the LPD configuration as needed.
+ *   update_smb()            - Update the SMB configuration as needed.
+ *   cupsAddDest()                 - Add a destination to the list of
+ *                                   destinations.
  *   _cupsAppleCopyDefaultPaperID() - Get the default paper ID.
  *   _cupsAppleCopyDefaultPrinter() - Get the default printer at this location.
  *   _cupsAppleGetUseLastPrinter()  - Get whether to use the last used printer.
  *   _cupsAppleSetDefaultPaperID()  - Set the default paper id.
- *   _cupsAppleSetDefaultPrinter()  - Set the default printer for this location.
+ *   _cupsAppleSetDefaultPrinter()  - Set the default printer for this
+ *                                   location.
  *   _cupsAppleSetUseLastPrinter()  - Set whether to use the last used printer.
- *   cupsFreeDests()                - Free the memory used by the list of
- *                                    destinations.
- *   cupsGetDest()                  - Get the named destination from the list.
- *   _cupsGetDests()                - Get destinations from a server.
- *   cupsGetDests()                 - Get the list of destinations from the
- *                                    default server.
- *   cupsGetDests2()                - Get the list of destinations from the
- *                                    specified server.
- *   cupsGetNamedDest()             - Get options for the named destination.
- *   cupsRemoveDest()               - Remove a destination from the destination
- *                                    list.
- *   cupsSetDefaultDest()           - Set the default destination.
- *   cupsSetDests()                 - Save the list of destinations for the
- *                                    default server.
- *   cupsSetDests2()                - Save the list of destinations for the
- *                                    specified server.
- *   _cupsUserDefault()             - Get the user default printer from
- *                                    environment variables and location
- *                                    information.
- *   appleCopyLocations()           - Copy the location history array.
- *   appleCopyNetwork()             - Get the network ID for the current
- *                                    location.
- *   appleGetPaperSize()            - Get the default paper size.
- *   appleGetPrinter()              - Get a printer from the history array.
- *   cups_add_dest()                - Add a destination to the array.
- *   cups_compare_dests()           - Compare two destinations.
- *   cups_find_dest()               - Find a destination using a binary search.
- *   cups_get_default()             - Get the default destination from an
- *                                    lpoptions file.
- *   cups_get_dests()               - Get destinations from a file.
- *   cups_make_string()             - Make a comma-separated string of values
- *                                    from an IPP attribute.
+ *   cupsConnectDest()             - Connect to the server for a destination.
+ *   cupsEnumDests()               - Enumerate available destinations with a
+ *                                   callback function.
+ *   cupsEnumDestsBlock()          - Enumerate available destinations with a
+ *                                   block.
+ *   cupsFreeDests()               - Free the memory used by the list of
+ *                                   destinations.
+ *   cupsGetDest()                 - Get the named destination from the list.
+ *   _cupsGetDests()               - Get destinations from a server.
+ *   cupsGetDests()                - Get the list of destinations from the
+ *                                   default server.
+ *   cupsGetDests2()               - Get the list of destinations from the
+ *                                   specified server.
+ *   cupsGetNamedDest()            - Get options for the named destination.
+ *   cupsRemoveDest()              - Remove a destination from the destination
+ *                                   list.
+ *   cupsSetDefaultDest()          - Set the default destination.
+ *   cupsSetDests()                - Save the list of destinations for the
+ *                                   default server.
+ *   cupsSetDests2()               - Save the list of destinations for the
+ *                                   specified server.
+ *   _cupsUserDefault()            - Get the user default printer from
+ *                                   environment variables and location
+ *                                   information.
+ *   appleCopyLocations()          - Copy the location history array.
+ *   appleCopyNetwork()            - Get the network ID for the current
+ *                                   location.
+ *   appleGetPaperSize()           - Get the default paper size.
+ *   appleGetPrinter()             - Get a printer from the history array.
+ *   cups_add_dest()               - Add a destination to the array.
+ *   cups_block_cb()               - Enumeration callback for block API.
+ *   cups_compare_dests()          - Compare two destinations.
+ *   cups_find_dest()              - Find a destination using a binary search.
+ *   cups_get_default()            - Get the default destination from an
+ *                                   lpoptions file.
+ *   cups_get_dests()              - Get destinations from a file.
+ *   cups_make_string()            - Make a comma-separated string of values
+ *                                   from an IPP attribute.
  */
 
 /*
  */
 
 #ifdef __APPLE__
-static CFArrayRef appleCopyLocations(void);
-static CFStringRef appleCopyNetwork(void);
-static char    *appleGetPaperSize(char *name, int namesize);
-static CFStringRef appleGetPrinter(CFArrayRef locations, CFStringRef network,
-                                  CFIndex *locindex);
+static CFArrayRef      appleCopyLocations(void);
+static CFStringRef     appleCopyNetwork(void);
+static char            *appleGetPaperSize(char *name, int namesize);
+static CFStringRef     appleGetPrinter(CFArrayRef locations, CFStringRef network,
+                                       CFIndex *locindex);
 #endif /* __APPLE__ */
-static cups_dest_t *cups_add_dest(const char *name, const char *instance,
-                                 int *num_dests, cups_dest_t **dests);
-static int     cups_compare_dests(cups_dest_t *a, cups_dest_t *b);
-static int     cups_find_dest(const char *name, const char *instance,
-                              int num_dests, cups_dest_t *dests, int prev,
-                              int *rdiff);
-static char    *cups_get_default(const char *filename, char *namebuf,
-                                 size_t namesize, const char **instance);
-static int     cups_get_dests(const char *filename, const char *match_name,
-                              const char *match_inst, int user_default_set,
-                              int num_dests, cups_dest_t **dests);
-static char    *cups_make_string(ipp_attribute_t *attr, char *buffer,
-                                 size_t bufsize);
+static cups_dest_t     *cups_add_dest(const char *name, const char *instance,
+                                      int *num_dests, cups_dest_t **dests);
+#ifdef __BLOCKS__
+static int             cups_block_cb(cups_dest_block_t block, const char *name,
+                                     const char *instance, int num_options,
+                                     cups_option_t *options);
+#endif /* __BLOCKS__ */
+static int             cups_compare_dests(cups_dest_t *a, cups_dest_t *b);
+static int             cups_find_dest(const char *name, const char *instance,
+                                      int num_dests, cups_dest_t *dests, int prev,
+                                      int *rdiff);
+static char            *cups_get_default(const char *filename, char *namebuf,
+                                         size_t namesize, const char **instance);
+static int             cups_get_dests(const char *filename, const char *match_name,
+                                      const char *match_inst, int user_default_set,
+                                      int num_dests, cups_dest_t **dests);
+static char            *cups_make_string(ipp_attribute_t *attr, char *buffer,
+                                         size_t bufsize);
 
 
 /*
@@ -418,6 +457,65 @@ _cupsAppleSetUseLastPrinter(
 #endif /* __APPLE__ */
 
 
+/*
+ * 'cupsConnectDest()' - Connect to the server for a destination.
+ *
+ * @since CUPS 1.6@
+ */
+
+http_t *                               /* O - Connection to server or @code NULL@ */
+cupsConnectDest(cups_dest_t *dest)     /* I - Destination */
+{
+  return (NULL);
+}
+
+
+/*
+ * 'cupsEnumDests()' - Enumerate available destinations with a callback function.
+ *
+ * Destinations are enumerated from one or more sources. The callback function receives
+ * the @code user_data@ pointer, destination name, instance, number of options, and
+ * options which can be used as input to the @link cupsAddDest@ function.  The function
+ * must return 1 to continue enumeration or 0 to stop.
+ *
+ * Enumeration happens on the current thread and does not return until all destinations
+ * have been enumerated or the callback function returns 0.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+cupsEnumDests(cups_dest_cb_t cb,       /* I - Callback function */
+              void           *user_data)/* I - User data */
+{
+  return (0);
+}
+
+
+#  ifdef __BLOCKS__
+/*
+ * 'cupsEnumDestsBlock()' - Enumerate available destinations with a block.
+ *
+ * Destinations are enumerated from one or more sources. The block receives the
+ * destination name, instance, number of options, and options which can be used as input
+ * to the @link cupsAddDest@ function.  The block must return 1 to continue enumeration or
+ * 0 to stop.
+ *
+ * Enumeration happens on the current thread and does not return until all destinations
+ * have been enumerated or the block returns 0.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+cupsEnumDestsBlock(
+    cups_dest_block_t block)           /* I - Block */
+{
+  return (cupsEnumDests((cups_dest_cb_t)cups_block_cb, (void *)block));
+}
+#  endif /* __BLOCKS__ */
+
+
 /*
  * 'cupsFreeDests()' - Free the memory used by the list of destinations.
  */
@@ -1731,6 +1829,24 @@ cups_add_dest(const char  *name, /* I  - Name of destination */
 }
 
 
+#  ifdef __BLOCKS__
+/*
+ * 'cups_block_cb()' - Enumeration callback for block API.
+ */
+
+static int                             /* O - 1 to continue, 0 to stop */
+cups_block_cb(
+    cups_dest_block_t block,           /* I - Block */
+    const char        *name,           /* I - Destination name */
+    const char        *instance,       /* I - Instance or @code NULL@ */
+    int               num_options,     /* I - Number of options */
+    cups_option_t     *options)                /* I - Options */
+{
+  return ((block)(name, instance, num_options, options));
+}
+#  endif /* __BLOCKS__ */
+
+
 /*
  * 'cups_compare_dests()' - Compare two destinations.
  */
index 030eece1e4e86fe1c141d7c5885442c878d977ff..ec4c2c9980523e383f443c15d46b668af13bf2b8 100644 (file)
@@ -1036,6 +1036,7 @@ ipp_col_string(ipp_t  *col,               /* I - Collection attribute */
 {
   char                 *bufptr,        /* Position in buffer */
                        *bufend,        /* End of buffer */
+                       prefix = '{',   /* Prefix character */
                        temp[256];      /* Temporary string */
   ipp_attribute_t      *attr;          /* Current member attribute */
 
@@ -1043,15 +1044,16 @@ ipp_col_string(ipp_t  *col,             /* I - Collection attribute */
   bufptr = buffer;
   bufend = buffer + bufsize - 1;
 
-  if (buffer && bufptr < bufend)
-    *bufptr = '{';
-  bufptr ++;
-
   for (attr = col->attrs; attr; attr = attr->next)
   {
     if (!attr->name)
       continue;
 
+    if (buffer && bufptr < bufend)
+      *bufptr = prefix;
+    bufptr ++;
+    prefix = ' ';
+
     if (buffer && bufptr < bufend)
       bufptr += snprintf(bufptr, bufend - bufptr + 1, "%s=", attr->name);
     else
@@ -1063,6 +1065,13 @@ ipp_col_string(ipp_t  *col,              /* I - Collection attribute */
       bufptr += ippAttributeString(attr, temp, sizeof(temp));
   }
 
+  if (prefix == '{')
+  {
+    if (buffer && bufptr < bufend)
+      *bufptr = prefix;
+    bufptr ++;
+  }
+
   if (buffer && bufptr < bufend)
     *bufptr = '}';
   bufptr ++;
index 0e22b49ff8299289996773626de4690ecd871017..36f8a53bfa8589ccd4bf9d996818ed1c1fe609d5 100644 (file)
  *   ippDelete()           - Delete an IPP message.
  *   ippDeleteAttribute()   - Delete a single attribute in an IPP message.
  *   ippDeleteValues()     - Delete values in an attribute.
- *   ippFindAttribute()     - Find a named attribute in a request...
- *   ippFindNextAttribute() - Find the next named attribute in a request...
+ *   ippFindAttribute()     - Find a named attribute in a request.
+ *   ippFindNextAttribute() - Find the next named attribute in a request.
  *   ippFirstAttribute()    - Return the first attribute in the message.
  *   ippGetBoolean()       - Get a boolean value for an attribute.
  *   ippGetCollection()     - Get a collection value for an attribute.
  *   ippGetCount()         - Get the number of values in an attribute.
+ *   ippGetDate()           - Get a date value for an attribute.
  *   ippGetGroupTag()      - Get the group associated with an attribute.
  *   ippGetInteger()       - Get the integer/enum value for an attribute.
  *   ippGetName()          - Get the attribute name.
  *   ippGetOperation()     - Get the operation ID in an IPP message.
+ *   ippGetRange()          - Get a rangeOfInteger value from an attribute.
  *   ippGetRequestId()     - Get the request ID from an IPP message.
  *   ippGetResolution()     - Get a resolution value for an attribute.
  *   ippGetStatusCode()     - Get the status code from an IPP response or event
@@ -68,6 +70,7 @@
  *   ippReadIO()           - Read data for an IPP message.
  *   ippSetBoolean()       - Set a boolean value in an attribute.
  *   ippSetCollection()     - Set a collection value in an attribute.
+ *   ippSetDate()           - Set a date value in an attribute.
  *   ippSetGroupTag()      - Set the group tag of an attribute.
  *   ippSetInteger()       - Set an integer or enum value in an attribute.
  *   ippSetName()          - Set the name of an attribute.
@@ -75,6 +78,7 @@
  *   ippSetRange()         - Set a rangeOfInteger value in an attribute.
  *   ippSetRequestId()     - Set the request ID in an IPP message.
  *   ippSetResolution()     - Set a resolution value in an attribute.
+ *   ippSetState()          - Set the current state of the IPP message.
  *   ippSetStatusCode()     - Set the status code in an IPP response or event
  *                           message.
  *   ippSetString()        - Set a string value in an attribute.
@@ -280,7 +284,8 @@ ippAddCollection(ipp_t      *ipp,   /* I - IPP message */
 
   attr->values[0].collection = value;
 
-  value->use ++;
+  if (value)
+    value->use ++;
 
   return (attr);
 }
@@ -1614,36 +1619,40 @@ ippDeleteAttribute(
 /*
  * 'ippDeleteValues()' - Delete values in an attribute.
  *
- * The @code element@ parameter specifies the first value to delete, starting at 0. It
- * must be less than the number of values returned by @link ippGetCount@.
+ * The @code element@ parameter specifies the first value to delete, starting at
+ * 0. It must be less than the number of values returned by @link ippGetCount@.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
  *
  * Deleting all values in an attribute deletes the attribute.
  *
  * @since CUPS 1.6@
  */
 
-int                                    /* O - 1 on success, 0 on failure */
+int                                    /* O  - 1 on success, 0 on failure */
 ippDeleteValues(
-    ipp_t           *ipp,              /* I - IPP message */
-    ipp_attribute_t *attr,             /* I - Attribute */
-    int             element,           /* I - Index of first value to delete (0-based) */
-    int             count)             /* I - Number of values to delete */
+    ipp_t           *ipp,              /* I  - IPP message */
+    ipp_attribute_t **attr,            /* IO - Attribute */
+    int             element,           /* I  - Index of first value to delete (0-based) */
+    int             count)             /* I  - Number of values to delete */
 {
  /*
   * Range check input...
   */
 
-  if (!ipp || !attr || element < 0 || element >= attr->num_values || count <= 0 ||
-      (element + count) >= attr->num_values)
+  if (!ipp || !attr || !*attr ||
+      element < 0 || element >= (*attr)->num_values || count <= 0 ||
+      (element + count) >= (*attr)->num_values)
     return (0);
 
  /*
   * If we are deleting all values, just delete the attribute entirely.
   */
 
-  if (count == attr->num_values)
+  if (count == (*attr)->num_values)
   {
-    ippDeleteAttribute(ipp, attr);
+    ippDeleteAttribute(ipp, *attr);
+    *attr = NULL;
     return (1);
   }
 
@@ -1651,14 +1660,14 @@ ippDeleteValues(
   * Otherwise free the values in question and return.
   */
 
-  ipp_free_values(attr, element, count);
+  ipp_free_values(*attr, element, count);
 
   return (1);
 }
 
 
 /*
- * 'ippFindAttribute()' - Find a named attribute in a request...
+ * 'ippFindAttribute()' - Find a named attribute in a request.
  */
 
 ipp_attribute_t        *                       /* O - Matching attribute */
@@ -1687,7 +1696,7 @@ ippFindAttribute(ipp_t      *ipp, /* I - IPP message */
 
 
 /*
- * 'ippFindNextAttribute()' - Find the next named attribute in a request...
+ * 'ippFindNextAttribute()' - Find the next named attribute in a request.
  */
 
 ipp_attribute_t        *                       /* O - Matching attribute */
@@ -1848,6 +1857,35 @@ ippGetCount(ipp_attribute_t *attr)       /* I - IPP attribute */
 }
 
 
+/*
+ * 'ippGetDate()' - Get a date value for an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+const ipp_uchar_t *                    /* O - Date value or @code NULL@ */
+ippGetDate(ipp_attribute_t *attr,      /* I - IPP attribute */
+           int             element)    /* I - Value number (0-based) */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || attr->value_tag != IPP_TAG_DATE ||
+      element < 0 || element >= attr->num_values)
+    return (NULL);
+
+ /*
+  * Return the value...
+  */
+
+  return (attr->values[element].date);
+}
+
+
 /*
  * 'ippGetGroupTag()' - Get the group associated with an attribute.
  *
@@ -1949,6 +1987,44 @@ ippGetOperation(ipp_t *ipp)              /* I - IPP request message */
 }
 
 
+/*
+ * 'ippGetRange()' - Get a rangeOfInteger value from an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Lower value of range or -1 */
+ippGetRange(ipp_attribute_t *attr,     /* I - IPP attribute */
+           int             element,    /* I - Value number (0-based) */
+           int             *uppervalue)/* O - Upper value of range */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || attr->value_tag != IPP_TAG_RANGE ||
+      element < 0 || element >= attr->num_values)
+  {
+    if (uppervalue)
+      *uppervalue = -1;
+
+    return (-1);
+  }
+
+ /*
+  * Return the values...
+  */
+
+  if (uppervalue)
+    *uppervalue = attr->values[element].range.upper;
+
+  return (attr->values[element].range.lower);
+}
+
+
 /*
  * 'ippGetRequestId()' - Get the request ID from an IPP message.
  *
@@ -2011,6 +2087,30 @@ ippGetResolution(
 }
 
 
+/*
+ * 'ippGetState()' - Get the IPP message state.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_state_t                            /* O - IPP message state value */
+ippGetState(ipp_t *ipp)                        /* I - IPP message */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return (IPP_IDLE);
+
+ /*
+  * Return the value...
+  */
+
+  return (ipp->state);
+}
+
+
 /*
  * 'ippGetStatusCode()' - Get the status code from an IPP response or event message.
  *
@@ -2616,8 +2716,7 @@ ippReadIO(void       *src,                /* I - Data source */
            DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p",
                          ipp->current, ipp->prev));
 
-           attr->num_values = 0;
-           value            = attr->values;
+           value = attr->values;
          }
          else if (tag != IPP_TAG_END_COLLECTION)
          {
@@ -2649,8 +2748,7 @@ ippReadIO(void       *src,                /* I - Data source */
            DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, "
                          "ipp->prev=%p", buffer, ipp->current, ipp->prev));
 
-           attr->num_values = 0;
-           value            = attr->values;
+           value = attr->values;
          }
          else
          {
@@ -2998,8 +3096,6 @@ ippReadIO(void       *src,                /* I - Data source */
                break;
          }
 
-          attr->num_values ++;
-
         /*
           * If blocking is disabled, stop here...
          */
@@ -3038,7 +3134,7 @@ ippReadIO(void       *src,                /* I - Data source */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetBoolean(ipp_t           *ipp,    /* I  - IPP message */
+ippSetBoolean(ipp_t           *ipp,    /* IO - IPP message */
               ipp_attribute_t **attr,  /* IO - IPP attribute */
               int             element, /* I  - Value number (0-based) */
               int             boolvalue)/* I  - Boolean value */
@@ -3081,7 +3177,7 @@ ippSetBoolean(ipp_t           *ipp,       /* I  - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetCollection(
-    ipp_t           *ipp,              /* I  - IPP message */
+    ipp_t           *ipp,              /* IO - IPP message */
     ipp_attribute_t **attr,            /* IO - IPP attribute */
     int             element,           /* I  - Value number (0-based) */
     ipp_t           *colvalue)         /* I  - Collection value */
@@ -3114,6 +3210,48 @@ ippSetCollection(
 }
 
 
+/*
+ * 'ippSetDate()' - Set a date value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
+ *
+ * The @code element@ parameter specifies which value to set from 0 to
+ * @link ippGetCount(attr)@.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetDate(ipp_t             *ipp,     /* IO - IPP message */
+           ipp_attribute_t   **attr,   /* IO - IPP attribute */
+           int               element,  /* I  - Value number (0-based) */
+           const ipp_uchar_t *datevalue)/* I  - Date value */
+{
+  _ipp_value_t *value;                 /* Current value */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_DATE ||
+      element < 0 || element > (*attr)->num_values || !datevalue)
+    return (0);
+
+ /*
+  * Set the value and return...
+  */
+
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+    memcpy(value->date, datevalue, sizeof(value->date));
+
+  return (value != NULL);
+}
+
+
 /*
  * 'ippSetGroupTag()' - Set the group tag of an attribute.
  *
@@ -3133,7 +3271,7 @@ ippSetCollection(
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetGroupTag(
-    ipp_t           *ipp,              /* I  - IPP message */
+    ipp_t           *ipp,              /* IO - IPP message */
     ipp_attribute_t **attr,            /* IO - Attribute */
     ipp_tag_t       group_tag)         /* I  - Group tag */
 {
@@ -3170,7 +3308,7 @@ ippSetGroupTag(
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetInteger(ipp_t           *ipp,    /* I  - IPP message */
+ippSetInteger(ipp_t           *ipp,    /* IO - IPP message */
               ipp_attribute_t **attr,  /* IO - IPP attribute */
               int             element, /* I  - Value number (0-based) */
               int             intvalue)        /* I  - Integer/enum value */
@@ -3210,7 +3348,7 @@ ippSetInteger(ipp_t           *ipp,       /* I  - IPP message */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetName(ipp_t           *ipp,       /* I  - IPP message */
+ippSetName(ipp_t           *ipp,       /* IO - IPP message */
           ipp_attribute_t **attr,      /* IO - IPP attribute */
           const char      *name)       /* I  - Attribute name */
 {
@@ -3285,7 +3423,7 @@ ippSetOperation(ipp_t    *ipp,            /* I - IPP request message */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetRange(ipp_t           *ipp,      /* I  - IPP message */
+ippSetRange(ipp_t           *ipp,      /* IO - IPP message */
             ipp_attribute_t **attr,    /* IO - IPP attribute */
             int             element,   /* I  - Value number (0-based) */
            int             lowervalue, /* I  - Lower bound for range */
@@ -3366,7 +3504,7 @@ ippSetRequestId(ipp_t *ipp,               /* I - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetResolution(
-    ipp_t           *ipp,              /* I  - IPP message */
+    ipp_t           *ipp,              /* IO - IPP message */
     ipp_attribute_t **attr,            /* IO - IPP attribute */
     int             element,           /* I  - Value number (0-based) */
     ipp_res_t       unitsvalue,                /* I  - Resolution units */
@@ -3400,6 +3538,34 @@ ippSetResolution(
 }
 
 
+/*
+ * 'ippSetState()' - Set the current state of the IPP message.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+ippSetState(ipp_t       *ipp,          /* I - IPP message */
+            ipp_state_t state)         /* I - IPP state value */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return (0);
+
+ /*
+  * Set the state and return...
+  */
+
+  ipp->state   = state;
+  ipp->current = NULL;
+
+  return (1);
+}
+
+
 /*
  * 'ippSetStatusCode()' - Set the status code in an IPP response or event message.
  *
@@ -3427,7 +3593,6 @@ ippSetStatusCode(ipp_t        *ipp,       /* I - IPP response or event message */
   ipp->request.status.status_code = status;
 
   return (1);
-
 }
 
 
@@ -3446,7 +3611,7 @@ ippSetStatusCode(ipp_t        *ipp,       /* I - IPP response or event message */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetString(ipp_t           *ipp,     /* I  - IPP message */
+ippSetString(ipp_t           *ipp,     /* IO - IPP message */
              ipp_attribute_t **attr,   /* IO - IPP attribute */
              int             element,  /* I  - Value number (0-based) */
             const char      *strvalue) /* I  - String value */
@@ -3514,7 +3679,7 @@ ippSetString(ipp_t           *ipp,        /* I  - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetValueTag(
-    ipp_t          *ipp,               /* I  - IPP message */
+    ipp_t          *ipp,               /* IO - IPP message */
     ipp_attribute_t **attr,            /* IO - IPP attribute */
     ipp_tag_t       value_tag)         /* I  - Value tag */
 {
@@ -4702,7 +4867,7 @@ ipp_add_attr(ipp_t      *ipp,             /* I - IPP message */
   */
 
   if (num_values <= 1)
-    alloc_values = num_values;
+    alloc_values = 1;
   else
     alloc_values = (num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
 
@@ -5240,11 +5405,12 @@ ipp_read_file(int         *fd,          /* I - File descriptor */
 
 
 /*
- * 'ipp_set_value()' - Get the value element from an attribute, expanding it as needed.
+ * 'ipp_set_value()' - Get the value element from an attribute, expanding it as
+ *                     needed.
  */
 
 static _ipp_value_t *                  /* O  - IPP value element or NULL on error */
-ipp_set_value(ipp_t           *ipp,    /* I  - IPP message */
+ipp_set_value(ipp_t           *ipp,    /* IO - IPP message */
               ipp_attribute_t **attr,  /* IO - IPP attribute */
               int             element) /* I  - Value number (0-based) */
 {
@@ -5261,16 +5427,22 @@ ipp_set_value(ipp_t           *ipp,     /* I  - IPP message */
   temp = *attr;
 
   if (temp->num_values <= 1)
-    alloc_values = temp->num_values;
+    alloc_values = 1;
   else
-    alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
+    alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) &
+                   ~(IPP_MAX_VALUES - 1);
 
   if (element < alloc_values)
+  {
+    if (element >= temp->num_values)
+      temp->num_values = element + 1;
+
     return (temp->values + element);
+  }
 
  /*
-  * Otherwise re-allocate the attribute - we allocate in groups of IPP_MAX_VALUE values
-  * when num_values > 1.
+  * Otherwise re-allocate the attribute - we allocate in groups of IPP_MAX_VALUE
+  * values when num_values > 1.
   */
 
   if (alloc_values < IPP_MAX_VALUES)
@@ -5278,15 +5450,15 @@ ipp_set_value(ipp_t           *ipp,     /* I  - IPP message */
   else
     alloc_values += IPP_MAX_VALUES;
 
-  DEBUG_printf(("4ipp_set_value: Reallocating for up to %d values.", alloc_values));
+  DEBUG_printf(("4ipp_set_value: Reallocating for up to %d values.",
+                alloc_values));
 
  /*
   * Reallocate memory...
   */
 
   if ((temp = realloc(temp, sizeof(ipp_attribute_t) +
-                           (temp->num_values + IPP_MAX_VALUES - 1) *
-                           sizeof(_ipp_value_t))) == NULL)
+                           (alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
   {
     _cupsSetHTTPError(HTTP_ERROR);
     DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
@@ -5331,7 +5503,8 @@ ipp_set_value(ipp_t           *ipp,       /* I  - IPP message */
        */
 
        *attr = temp;
-       _cupsSetError(IPP_ERROR, _("IPP attribute is not a member of the message."), 1);
+       _cupsSetError(IPP_ERROR,
+                     _("IPP attribute is not a member of the message."), 1);
        DEBUG_puts("4ipp_set_value: Unable to find attribute in message.");
        return (NULL);
       }
@@ -5355,6 +5528,9 @@ ipp_set_value(ipp_t           *ipp,       /* I  - IPP message */
   * Return the value element...
   */
 
+  if (element >= temp->num_values)
+    temp->num_values = element + 1;
+
   return (temp->values + element);
 }
 
index 2f29d59dc035d58408b948b3f17ae9743166badb..c35ee79a805d2bfbd85f12421800a2bb7f61abd0 100644 (file)
@@ -450,34 +450,42 @@ extern const char *ippTagString(ipp_tag_t tag) _CUPS_API_1_4;
 extern ipp_tag_t       ippTagValue(const char *name) _CUPS_API_1_4;
 
 /**** New in CUPS 1.6 ****/
-extern ipp_attribute_t *ippAddOutOfBand(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag,
-                                        const char *name);
+extern ipp_attribute_t *ippAddOutOfBand(ipp_t *ipp, ipp_tag_t group,
+                                        ipp_tag_t value_tag, const char *name)
+                                        _CUPS_API_1_6;
 extern size_t          ippAttributeString(ipp_attribute_t *attr, char *buffer,
                                           size_t bufsize) _CUPS_API_1_6;
 extern ipp_attribute_t *ippCopyAttribute(ipp_t *dst, ipp_attribute_t *attr,
                                         int quickcopy) _CUPS_API_1_6;
 extern int             ippCopyAttributes(ipp_t *dst, ipp_t *src,
-                                         int quickcopy, ipp_copycb_t cb, void *context)
-                                         _CUPS_API_1_6;
-extern int             ippDeleteValues(ipp_t *ipp, ipp_attribute_t *attr, int element,
-                                       int count) _CUPS_API_1_6;
-extern const char      *ippEnumString(const char *attrname, int enumvalue) _CUPS_API_1_6;
-extern int             ippEnumValue(const char *attrname, const char *enumstring)
-                                    _CUPS_API_1_6;
+                                         int quickcopy, ipp_copycb_t cb,
+                                         void *context) _CUPS_API_1_6;
+extern int             ippDeleteValues(ipp_t *ipp, ipp_attribute_t **attr,
+                                       int element, int count) _CUPS_API_1_6;
+extern const char      *ippEnumString(const char *attrname, int enumvalue)
+                                      _CUPS_API_1_6;
+extern int             ippEnumValue(const char *attrname,
+                                    const char *enumstring) _CUPS_API_1_6;
 extern ipp_attribute_t *ippFirstAttribute(ipp_t *ipp) _CUPS_API_1_6;
 extern int             ippGetBoolean(ipp_attribute_t *attr, int element)
                                      _CUPS_API_1_6;
 extern ipp_t           *ippGetCollection(ipp_attribute_t *attr,
                                          int element) _CUPS_API_1_6;
 extern int             ippGetCount(ipp_attribute_t *attr) _CUPS_API_1_6;
+extern const ipp_uchar_t *ippGetDate(ipp_attribute_t *attr, int element)
+                                    _CUPS_API_1_6;
 extern ipp_tag_t       ippGetGroupTag(ipp_attribute_t *attr) _CUPS_API_1_6;
 extern int             ippGetInteger(ipp_attribute_t *attr, int element)
                                      _CUPS_API_1_6;
 extern const char      *ippGetName(ipp_attribute_t *attr) _CUPS_API_1_6;
 extern ipp_op_t                ippGetOperation(ipp_t *ipp) _CUPS_API_1_6;
+extern int             ippGetRange(ipp_attribute_t *attr, int element,
+                                   int *upper) _CUPS_API_1_6;
 extern int             ippGetRequestId(ipp_t *ipp) _CUPS_API_1_6;
 extern int             ippGetResolution(ipp_attribute_t *attr, int element,
-                                        int *yres, ipp_res_t *units) _CUPS_API_1_6;
+                                        int *yres, ipp_res_t *units)
+                                        _CUPS_API_1_6;
+extern ipp_state_t     ippGetState(ipp_t *ipp) _CUPS_API_1_6;
 extern ipp_status_t    ippGetStatusCode(ipp_t *ipp) _CUPS_API_1_6;
 extern const char      *ippGetString(ipp_attribute_t *attr, int element,
                                      const char **language) _CUPS_API_1_6;
@@ -487,27 +495,38 @@ extern ipp_attribute_t    *ippNextAttribute(ipp_t *ipp) _CUPS_API_1_6;
 extern int             ippSetBoolean(ipp_t *ipp, ipp_attribute_t **attr,
                                      int element, int boolvalue) _CUPS_API_1_6;
 extern int             ippSetCollection(ipp_t *ipp, ipp_attribute_t **attr,
-                                        int element, ipp_t *colvalue) _CUPS_API_1_6;
+                                        int element, ipp_t *colvalue)
+                                        _CUPS_API_1_6;
+extern int             ippSetDate(ipp_t *ipp, ipp_attribute_t **attr,
+                                   int element, const ipp_uchar_t *datevalue)
+                                   _CUPS_API_1_6;
 extern int             ippSetGroupTag(ipp_t *ipp, ipp_attribute_t **attr,
                                       ipp_tag_t group_tag) _CUPS_API_1_6;
 extern int             ippSetInteger(ipp_t *ipp, ipp_attribute_t **attr,
                                      int element, int intvalue) _CUPS_API_1_6;
-extern int             ippSetName(ipp_t *ipp, ipp_attribute_t **attr, const char *name)
-                                  _CUPS_API_1_6;
+extern int             ippSetName(ipp_t *ipp, ipp_attribute_t **attr,
+                                   const char *name) _CUPS_API_1_6;
 extern int             ippSetOperation(ipp_t *ipp, ipp_op_t op) _CUPS_API_1_6;
-extern int             ippSetRange(ipp_t *ipp, ipp_attribute_t **attr, int element,
-                                   int lowervalue, int uppervalue) _CUPS_API_1_6;
+extern int             ippSetRange(ipp_t *ipp, ipp_attribute_t **attr,
+                                   int element, int lowervalue, int uppervalue)
+                                   _CUPS_API_1_6;
 extern int             ippSetRequestId(ipp_t *ipp, int request_id)
                                        _CUPS_API_1_6;
 extern int             ippSetResolution(ipp_t *ipp, ipp_attribute_t **attr,
                                         int element, ipp_res_t unitsvalue,
-                                        int xresvalue, int yresvalue) _CUPS_API_1_6;
-extern int             ippSetStatusCode(ipp_t *ipp, ipp_status_t status) _CUPS_API_1_6;
+                                        int xresvalue, int yresvalue)
+                                        _CUPS_API_1_6;
+extern int             ippSetState(ipp_t *ipp, ipp_state_t state)
+                                   _CUPS_API_1_6;
+extern int             ippSetStatusCode(ipp_t *ipp, ipp_status_t status)
+                                        _CUPS_API_1_6;
 extern int             ippSetString(ipp_t *ipp, ipp_attribute_t **attr,
-                                    int element, const char *strvalue) _CUPS_API_1_6;
+                                    int element, const char *strvalue)
+                                    _CUPS_API_1_6;
 extern int             ippSetValueTag(ipp_t *ipp, ipp_attribute_t **attr,
                                       ipp_tag_t value_tag) _CUPS_API_1_6;
-extern int             ippSetVersion(ipp_t *ipp, int major, int minor) _CUPS_API_1_6;
+extern int             ippSetVersion(ipp_t *ipp, int major, int minor)
+                                     _CUPS_API_1_6;
 
 
 /*
index e0188c6cbda73fe6fbf391eb5def54b36c2e70dd..2e91ad9d4a16535bdccd7122befb570442f56b60 100644 (file)
@@ -35,6 +35,7 @@
  *   cups_cache_lookup()    - Lookup a language in the cache...
  *   cups_message_compare() - Compare two messages.
  *   cups_message_free()    - Free a message.
+ *   cups_message_load()    - Load the message catalog for a language.
  *   cups_unquote()         - Unquote characters in strings...
  */
 
@@ -176,6 +177,7 @@ static cups_lang_t  *cups_cache_lookup(const char *name,
 static int             cups_message_compare(_cups_message_t *m1,
                                             _cups_message_t *m2);
 static void            cups_message_free(_cups_message_t *m);
+static void            cups_message_load(cups_lang_t *lang);
 static void            cups_unquote(char *d, const char *s);
 
 
@@ -393,11 +395,6 @@ cupsLangGet(const char *language)  /* I - Language or locale */
                        real[48];       /* Real language name */
   cups_encoding_t      encoding;       /* Encoding to use */
   cups_lang_t          *lang;          /* Current language... */
-#if !defined(__APPLE__) || !defined(CUPS_BUNDLEDIR)
-  char                 filename[1024]; /* Filename for language locale file */
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Pointer to library globals */
-#endif /* !__APPLE__ || !CUPS_BUNDLEDIR */
   static const char * const locale_encodings[] =
                {                       /* Locale charset names */
                  "ASCII",      "ISO88591",     "ISO88592",     "ISO88593",
@@ -701,21 +698,9 @@ cupsLangGet(const char *language)  /* I - Language or locale */
   */
 
   if (country[0])
-  {
     snprintf(real, sizeof(real), "%s_%s", langname, country);
-
-#if !defined(__APPLE__) || !defined(CUPS_BUNDLEDIR)
-    snprintf(filename, sizeof(filename), "%s/%s/cups_%s.po", cg->localedir,
-             real, real);
-#endif /* !__APPLE__ || !CUPS_BUNDLEDIR */
-  }
   else
-  {
     strcpy(real, langname);
-#if !defined(__APPLE__) || !defined(CUPS_BUNDLEDIR)
-    filename[0] = '\0';                        /* anti-compiler-warning-code */
-#endif /* !__APPLE__ || !CUPS_BUNDLEDIR */
-  }
 
   _cupsMutexLock(&lang_mutex);
 
@@ -728,30 +713,6 @@ cupsLangGet(const char *language)  /* I - Language or locale */
     return (lang);
   }
 
-#if !defined(__APPLE__) || !defined(CUPS_BUNDLEDIR)
-  if (!country[0] || access(filename, 0))
-  {
-   /*
-    * Country localization not available, look for generic localization...
-    */
-
-    snprintf(filename, sizeof(filename), "%s/%s/cups_%s.po", cg->localedir,
-             langname, langname);
-
-    if (access(filename, 0))
-    {
-     /*
-      * No generic localization, so use POSIX...
-      */
-
-      DEBUG_printf(("4cupsLangGet: access(\"%s\", 0): %s", filename,
-                    strerror(errno)));
-
-      snprintf(filename, sizeof(filename), "%s/C/cups_C.po", cg->localedir);
-    }
-  }
-#endif /* !__APPLE__ || !CUPS_BUNDLEDIR */
-
  /*
   * See if there is a free language available; if so, use that
   * record...
@@ -784,6 +745,7 @@ cupsLangGet(const char *language)   /* I - Language or locale */
     */
 
     _cupsMessageFree(lang->strings);
+    lang->strings = NULL;
   }
 
  /*
@@ -798,16 +760,6 @@ cupsLangGet(const char *language)  /* I - Language or locale */
   else
     lang->encoding = CUPS_UTF8;
 
- /*
-  * Read the strings from the file...
-  */
-
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
-  lang->strings = appleMessageLoad(lang->language);
-#else
-  lang->strings = _cupsMessageLoad(filename, 1);
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
-
  /*
   * Return...
   */
@@ -840,6 +792,13 @@ _cupsLangString(cups_lang_t *lang, /* I - Language */
 
   _cupsMutexLock(&lang_mutex);
 
+ /*
+  * Load the message catalog if needed...
+  */
+
+  if (!lang->strings)
+    cups_message_load(lang);
+
   s = _cupsMessageLookup(lang->strings, message);
 
   _cupsMutexUnlock(&lang_mutex);
@@ -1457,6 +1416,56 @@ cups_message_free(_cups_message_t *m)    /* I - Message */
 }
 
 
+/*
+ * 'cups_message_load()' - Load the message catalog for a language.
+ */
+
+static void
+cups_message_load(cups_lang_t *lang)   /* I - Language */
+{
+#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
+  lang->strings = appleMessageLoad(lang->language);
+
+#else
+  char                 filename[1024]; /* Filename for language locale file */
+  _cups_globals_t      *cg = _cupsGlobals();
+                                       /* Pointer to library globals */
+
+
+  snprintf(filename, sizeof(filename), "%s/%s/cups_%s.po", cg->localedir,
+          lang->language, lang->language);
+
+  if (strchr(lang->language, '_') && access(filename, 0))
+  {
+   /*
+    * Country localization not available, look for generic localization...
+    */
+
+    snprintf(filename, sizeof(filename), "%s/%.2s/cups_%.2s.po", cg->localedir,
+             lang->language, lang->language);
+
+    if (access(filename, 0))
+    {
+     /*
+      * No generic localization, so use POSIX...
+      */
+
+      DEBUG_printf(("4cups_message_load: access(\"%s\", 0): %s", filename,
+                    strerror(errno)));
+
+      snprintf(filename, sizeof(filename), "%s/C/cups_C.po", cg->localedir);
+    }
+  }
+
+ /*
+  * Read the strings from the file...
+  */
+
+  lang->strings = _cupsMessageLoad(filename, 1);
+#endif /* __APPLE__ && CUPS_BUNDLEDIR */
+}
+
+
 /*
  * 'cups_unquote()' - Unquote characters in strings...
  */
index 1576fffdd023c8574c97ac3bdd7c52ad532fd340..7b1dbe4e467a3992a77062c02decee6fdd634d91 100644 (file)
@@ -60,6 +60,8 @@ _ppdGetLanguages
 _ppdHashName\r
 _ppdLocalizedAttr\r
 _ppdNormalizeMakeAndModel\r
+_ppdOpen\r
+_ppdOpenFile\r
 _ppdParseOptions\r
 _pwgGenerateSize\r
 _pwgInitSize\r
index f500e771207c4ca568ce80da7eb298315cf7d699..f7a5c3f0ff57c451e4dfb92b7766f20eb935e87e 100644 (file)
@@ -57,6 +57,8 @@ _ppdGetLanguages
 _ppdHashName
 _ppdLocalizedAttr
 _ppdNormalizeMakeAndModel
+_ppdOpen
+_ppdOpenFile
 _ppdParseOptions
 _pwgCreateWithFile
 _pwgDestroy
index baf7fd1697898743c459f9fbd2c197e869f2a92a..038190cf443254b61e402302035696698af8961f 100644 (file)
@@ -56,6 +56,14 @@ extern "C" {
  * Types and structures...
  */
 
+typedef enum _ppd_localization_e       /**** Selector for _ppdOpen ****/
+{
+  _PPD_LOCALIZATION_DEFAULT,           /* Load only the default localization */
+  _PPD_LOCALIZATION_ICC_PROFILES,      /* Load only the color profile localization */
+  _PPD_LOCALIZATION_NONE,              /* Load no localizations */
+  _PPD_LOCALIZATION_ALL                        /* Load all localizations */
+} _ppd_localization_t;
+
 typedef enum _ppd_parse_e              /**** Selector for _ppdParseOptions ****/
 {
   _PPD_PARSE_OPTIONS,                  /* Parse only the options */
@@ -163,6 +171,10 @@ extern ppd_attr_t  *_ppdLocalizedAttr(ppd_file_t *ppd, const char *keyword,
 extern char            *_ppdNormalizeMakeAndModel(const char *make_and_model,
                                                   char *buffer,
                                                   size_t bufsize);
+extern ppd_file_t      *_ppdOpen(cups_file_t *fp,
+                                 _ppd_localization_t localization);
+extern ppd_file_t      *_ppdOpenFile(const char *filename,
+                                     _ppd_localization_t localization);
 extern int             _ppdParseOptions(const char *s, int num_options,
                                         cups_option_t **options,
                                         _ppd_parse_t which);
index 325c4de5a09bb0c1f59aee6a97f9a2a7ed876c40..b3d4baeb8c6f0575641ca74832bd06be23e292f4 100644 (file)
  *                            LanguageEncoding.
  *   ppdLastError()         - Return the status from the last ppdOpen*().
  *   ppdOpen()              - Read a PPD file into memory.
+ *   _ppdOpen()             - Read a PPD file into memory.
  *   ppdOpen2()             - Read a PPD file into memory.
  *   ppdOpenFd()            - Read a PPD file into memory.
+ *   _ppdOpenFile()         - Read a PPD file into memory.
  *   ppdOpenFile()          - Read a PPD file into memory.
  *   ppdSetConformance()    - Set the conformance level for PPD files.
  *   ppd_add_attr()         - Add an attribute to the PPD data.
@@ -413,47 +415,15 @@ ppdLastError(int *line)                   /* O - Line number */
 
 
 /*
- * 'ppdOpen()' - Read a PPD file into memory.
- */
-
-ppd_file_t *                           /* O - PPD file record */
-ppdOpen(FILE *fp)                      /* I - File to read from */
-{
-  ppd_file_t   *ppd;                   /* PPD file record */
-  cups_file_t  *cf;                    /* CUPS file */
-
-
- /*
-  * Reopen the stdio file as a CUPS file...
-  */
-
-  if ((cf = cupsFileOpenFd(fileno(fp), "r")) == NULL)
-    return (NULL);
-
- /*
-  * Load the PPD file using the newer API...
-  */
-
-  ppd = ppdOpen2(cf);
-
- /*
-  * Close the CUPS file and return the PPD...
-  */
-
-  cupsFileClose(cf);
-
-  return (ppd);
-}
-
-
-/*
- * 'ppdOpen2()' - Read a PPD file into memory.
+ * '_ppdOpen()' - Read a PPD file into memory.
  *
  * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 ppd_file_t *                           /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
-ppdOpen2(cups_file_t *fp)              /* I - File to read from */
+_ppdOpen(
+    cups_file_t                *fp,            /* I - File to read from */
+    _ppd_localization_t        localization)   /* I - Localization to load */
 {
   int                  i, j, k;        /* Looping vars */
   int                  count;          /* Temporary count */
@@ -483,12 +453,17 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
   char                 **filter;       /* Pointer to filter */
   struct lconv         *loc;           /* Locale data */
   int                  ui_keyword;     /* Is this line a UI keyword? */
+  cups_lang_t          *lang;          /* Language data */
   cups_encoding_t      encoding;       /* Encoding of PPD file */
   _cups_globals_t      *cg = _cupsGlobals();
                                        /* Global data */
   char                 custom_name[PPD_MAX_NAME];
                                        /* CustomFoo attribute name */
   ppd_attr_t           *custom_attr;   /* CustomFoo attribute */
+  char                 ll[4],          /* Language + '.' */
+                       ll_CC[7];       /* Language + country + '.' */
+  size_t               ll_len,         /* Language length */
+                       ll_CC_len;      /* Language + country length */
   static const char * const ui_keywords[] =
                        {
 #ifdef CUPS_USE_FULL_UI_KEYWORDS_LIST
@@ -550,9 +525,14 @@ ppdOpen2(cups_file_t *fp)          /* I - File to read from */
                          "PageSize"
 #endif /* CUPS_USE_FULL_UI_KEYWORDS_LIST */
                        };
+  static const char * const color_keywords[] = /* Keywords associated with color profiles */
+                       {
+                         ".cupsICCProfile",
+                         ".ColorModel",
+                       };
 
 
-  DEBUG_printf(("ppdOpen2(fp=%p)", fp));
+  DEBUG_printf(("_ppdOpen(fp=%p)", fp));
 
  /*
   * Default to "OK" status...
@@ -571,6 +551,25 @@ ppdOpen2(cups_file_t *fp)          /* I - File to read from */
     return (NULL);
   }
 
+ /*
+  * If only loading a single localization set up the strings to match...
+  */
+
+  if (localization == _PPD_LOCALIZATION_DEFAULT)
+  {
+    if ((lang = cupsLangDefault()) == NULL)
+      return (NULL);
+
+    snprintf(ll_CC, sizeof(ll_CC), "%s.", lang->language);
+    snprintf(ll, sizeof(ll), "%2.2s.", lang->language);
+
+    ll_CC_len = strlen(ll_CC);
+    ll_len    = strlen(ll);
+
+    DEBUG_printf(("2_ppdOpen: Loading localizations matching \"%s\" and \"%s\"",
+                  ll_CC, ll));
+  }
+
  /*
   * Grab the first line and make sure it reads '*PPD-Adobe: "major.minor"'...
   */
@@ -580,7 +579,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
 
   mask = ppd_read(fp, &line, keyword, name, text, &string, 0, cg);
 
-  DEBUG_printf(("2ppdOpen2: mask=%x, keyword=\"%s\"...", mask, keyword));
+  DEBUG_printf(("2_ppdOpen: mask=%x, keyword=\"%s\"...", mask, keyword));
 
   if (mask == 0 ||
       strcmp(keyword, "PPD-Adobe") ||
@@ -599,7 +598,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
     return (NULL);
   }
 
-  DEBUG_printf(("2ppdOpen2: keyword=%s, string=%p", keyword, string));
+  DEBUG_printf(("2_ppdOpen: keyword=%s, string=%p", keyword, string));
 
   _cupsStrFree(string);
 
@@ -638,7 +637,7 @@ 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(("2ppdOpen2: mask=%x, keyword=\"%s\", name=\"%s\", "
+    DEBUG_printf(("2_ppdOpen: mask=%x, keyword=\"%s\", name=\"%s\", "
                   "text=\"%s\", string=%d chars...", mask, keyword, name, text,
                  string ? (int)strlen(string) : 0));
 
@@ -675,6 +674,50 @@ ppdOpen2(cups_file_t *fp)          /* I - File to read from */
       ui_keyword = 0;
     }
 
+   /*
+    * If we are filtering out keyword localizations, see if this line needs to
+    * be used...
+    */
+
+    if (localization != _PPD_LOCALIZATION_ALL &&
+        (temp = strchr(keyword, '.')) != NULL &&
+        ((temp - keyword) == 2 || (temp - keyword) == 5) &&
+        _cups_isalpha(keyword[0]) &&
+        _cups_isalpha(keyword[1]) &&
+        (keyword[2] == '.' ||
+         (keyword[2] == '_' && _cups_isalpha(keyword[3]) &&
+          _cups_isalpha(keyword[4]) && keyword[5] == '.')))
+    {
+      if (localization == _PPD_LOCALIZATION_NONE ||
+         (localization == _PPD_LOCALIZATION_DEFAULT &&
+          strncmp(ll_CC, keyword, ll_CC_len) &&
+          strncmp(ll, keyword, ll_len)))
+      {
+       DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword));
+       continue;
+      }
+      else if (localization == _PPD_LOCALIZATION_ICC_PROFILES)
+      {
+       /*
+        * Only load localizations for the color profile related keywords...
+        */
+
+       for (i = 0;
+            i < (int)(sizeof(color_keywords) / sizeof(color_keywords[0]));
+            i ++)
+       {
+         if (!_cups_strcasecmp(temp, color_keywords[i]))
+           break;
+       }
+
+       if (i >= (int)(sizeof(color_keywords) / sizeof(color_keywords[0])))
+       {
+         DEBUG_printf(("2_ppdOpen: Ignoring localization: \"%s\"\n", keyword));
+         continue;
+       }
+      }
+    }
+
     if (option == NULL &&
         (mask & (PPD_KEYWORD | PPD_OPTION | PPD_STRING)) ==
            (PPD_KEYWORD | PPD_OPTION | PPD_STRING))
@@ -691,7 +734,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
 
         ui_keyword = 1;
 
-        DEBUG_printf(("2ppdOpen2: FOUND ADOBE UI KEYWORD %s WITHOUT OPENUI!",
+        DEBUG_printf(("2_ppdOpen: FOUND ADOBE UI KEYWORD %s WITHOUT OPENUI!",
                      keyword));
 
         if (!group)
@@ -700,7 +743,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
                                     encoding)) == NULL)
            goto error;
 
-          DEBUG_printf(("2ppdOpen2: Adding to group %s...", group->text));
+          DEBUG_printf(("2_ppdOpen: Adding to group %s...", group->text));
           option = ppd_get_option(group, keyword);
          group  = NULL;
        }
@@ -735,7 +778,7 @@ ppdOpen2(cups_file_t *fp)           /* I - File to read from */
              !strcmp(ppd->attrs[j]->name + 7, keyword) &&
              ppd->attrs[j]->value)
          {
-           DEBUG_printf(("2ppdOpen2: Setting Default%s to %s via attribute...",
+           DEBUG_printf(("2_ppdOpen: Setting Default%s to %s via attribute...",
                          option->keyword, ppd->attrs[j]->value));
            strlcpy(option->defchoice, ppd->attrs[j]->value,
                    sizeof(option->defchoice));
@@ -1033,7 +1076,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
     {
       ppd_option_t     *custom_option; /* Custom option */
 
-      DEBUG_puts("2ppdOpen2: Processing Custom option...");
+      DEBUG_puts("2_ppdOpen: Processing Custom option...");
 
      /*
       * Get the option and custom option...
@@ -1060,7 +1103,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("1ppdOpen2: Unable to add Custom choice!");
+           DEBUG_puts("1_ppdOpen: Unable to add Custom choice!");
 
            cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1100,7 +1143,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("1ppdOpen2: Unable to add Custom choice!");
+             DEBUG_puts("1_ppdOpen: Unable to add Custom choice!");
 
              cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1241,7 +1284,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(("2ppdOpen2: name=\"%s\" (%d)", name, (int)strlen(name)));
+      DEBUG_printf(("2_ppdOpen: name=\"%s\" (%d)", name, (int)strlen(name)));
 
       if (name[0] == '*')
         _cups_strcpy(name, name + 1); /* Eliminate leading asterisk */
@@ -1249,7 +1292,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
       for (i = (int)strlen(name) - 1; i > 0 && _cups_isspace(name[i]); i --)
         name[i] = '\0'; /* Eliminate trailing spaces */
 
-      DEBUG_printf(("2ppdOpen2: OpenUI of %s in group %s...", name,
+      DEBUG_printf(("2_ppdOpen: OpenUI of %s in group %s...", name,
                     group ? group->text : "(null)"));
 
       if (subgroup != NULL)
@@ -1260,7 +1303,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
                                   encoding)) == NULL)
          goto error;
 
-        DEBUG_printf(("2ppdOpen2: Adding to group %s...", group->text));
+        DEBUG_printf(("2_ppdOpen: Adding to group %s...", group->text));
         option = ppd_get_option(group, name);
        group  = NULL;
       }
@@ -1298,7 +1341,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
            !strcmp(ppd->attrs[j]->name + 7, name) &&
            ppd->attrs[j]->value)
        {
-         DEBUG_printf(("2ppdOpen2: Setting Default%s to %s via attribute...",
+         DEBUG_printf(("2_ppdOpen: Setting Default%s to %s via attribute...",
                        option->keyword, ppd->attrs[j]->value));
          strlcpy(option->defchoice, ppd->attrs[j]->value,
                  sizeof(option->defchoice));
@@ -1344,7 +1387,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("1ppdOpen2: Unable to add Custom choice!");
+           DEBUG_puts("1_ppdOpen: Unable to add Custom choice!");
 
            cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1417,7 +1460,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
            !strcmp(ppd->attrs[j]->name + 7, name) &&
            ppd->attrs[j]->value)
        {
-         DEBUG_printf(("2ppdOpen2: Setting Default%s to %s via attribute...",
+         DEBUG_printf(("2_ppdOpen: Setting Default%s to %s via attribute...",
                        option->keyword, ppd->attrs[j]->value));
          strlcpy(option->defchoice, ppd->attrs[j]->value,
                  sizeof(option->defchoice));
@@ -1447,7 +1490,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
       {
        if ((choice = ppd_add_choice(option, "Custom")) == NULL)
        {
-         DEBUG_puts("1ppdOpen2: Unable to add Custom choice!");
+         DEBUG_puts("1_ppdOpen: Unable to add Custom choice!");
 
          cg->ppd_status = PPD_ALLOC_ERROR;
 
@@ -1620,11 +1663,11 @@ ppdOpen2(cups_file_t *fp)               /* I - File to read from */
         * Set the default as part of the current option...
        */
 
-        DEBUG_printf(("2ppdOpen2: Setting %s to %s...", keyword, string));
+        DEBUG_printf(("2_ppdOpen: Setting %s to %s...", keyword, string));
 
         strlcpy(option->defchoice, string, sizeof(option->defchoice));
 
-        DEBUG_printf(("2ppdOpen2: %s is now %s...", keyword, option->defchoice));
+        DEBUG_printf(("2_ppdOpen: %s is now %s...", keyword, option->defchoice));
       }
       else
       {
@@ -1637,7 +1680,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
 
         if ((toption = ppdFindOption(ppd, keyword + 7)) != NULL)
        {
-         DEBUG_printf(("2ppdOpen2: Setting %s to %s...", keyword, string));
+         DEBUG_printf(("2_ppdOpen: Setting %s to %s...", keyword, string));
          strlcpy(toption->defchoice, string, sizeof(toption->defchoice));
        }
       }
@@ -1874,7 +1917,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
                 (PPD_KEYWORD | PPD_OPTION | PPD_STRING) &&
             !strcmp(keyword, option->keyword))
     {
-      DEBUG_printf(("2ppdOpen2: group=%p, subgroup=%p", group, subgroup));
+      DEBUG_printf(("2_ppdOpen: group=%p, subgroup=%p", group, subgroup));
 
       if (!strcmp(keyword, "PageSize"))
       {
@@ -1943,7 +1986,7 @@ ppdOpen2(cups_file_t *fp)         /* I - File to read from */
 
 #ifdef DEBUG
   if (!cupsFileEOF(fp))
-    DEBUG_printf(("1ppdOpen2: Premature EOF at %lu...\n",
+    DEBUG_printf(("1_ppdOpen: Premature EOF at %lu...\n",
                   (unsigned long)cupsFileTell(fp)));
 #endif /* DEBUG */
 
@@ -2026,6 +2069,53 @@ ppdOpen2(cups_file_t *fp)                /* I - File to read from */
 }
 
 
+/*
+ * 'ppdOpen()' - Read a PPD file into memory.
+ */
+
+ppd_file_t *                           /* O - PPD file record */
+ppdOpen(FILE *fp)                      /* I - File to read from */
+{
+  ppd_file_t   *ppd;                   /* PPD file record */
+  cups_file_t  *cf;                    /* CUPS file */
+
+
+ /*
+  * Reopen the stdio file as a CUPS file...
+  */
+
+  if ((cf = cupsFileOpenFd(fileno(fp), "r")) == NULL)
+    return (NULL);
+
+ /*
+  * Load the PPD file using the newer API...
+  */
+
+  ppd = _ppdOpen(cf, _PPD_LOCALIZATION_DEFAULT);
+
+ /*
+  * Close the CUPS file and return the PPD...
+  */
+
+  cupsFileClose(cf);
+
+  return (ppd);
+}
+
+
+/*
+ * 'ppdOpen2()' - Read a PPD file into memory.
+ *
+ * @since CUPS 1.2/Mac OS X 10.5@
+ */
+
+ppd_file_t *                           /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
+ppdOpen2(cups_file_t *fp)              /* I - File to read from */
+{
+  return _ppdOpen(fp, _PPD_LOCALIZATION_DEFAULT);
+}
+
+
 /*
  * 'ppdOpenFd()' - Read a PPD file into memory.
  */
@@ -2077,11 +2167,12 @@ ppdOpenFd(int fd)                       /* I - File to read from */
 
 
 /*
- * 'ppdOpenFile()' - Read a PPD file into memory.
+ * '_ppdOpenFile()' - Read a PPD file into memory.
  */
 
 ppd_file_t *                           /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
-ppdOpenFile(const char *filename)      /* I - File to read from */
+_ppdOpenFile(const char                  *filename,    /* I - File to read from */
+            _ppd_localization_t  localization) /* I - Localization to load */
 {
   cups_file_t          *fp;            /* File pointer */
   ppd_file_t           *ppd;           /* PPD file record */
@@ -2112,7 +2203,7 @@ ppdOpenFile(const char *filename) /* I - File to read from */
 
   if ((fp = cupsFileOpen(filename, "r")) != NULL)
   {
-    ppd = ppdOpen2(fp);
+    ppd = _ppdOpen(fp, localization);
 
     cupsFileClose(fp);
   }
@@ -2126,6 +2217,17 @@ ppdOpenFile(const char *filename)        /* I - File to read from */
 }
 
 
+/*
+ * 'ppdOpenFile()' - Read a PPD file into memory.
+ */
+
+ppd_file_t *                           /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
+ppdOpenFile(const char *filename)      /* I - File to read from */
+{
+  return _ppdOpenFile(filename, _PPD_LOCALIZATION_DEFAULT);
+}
+
+
 /*
  * 'ppdSetConformance()' - Set the conformance level for PPD files.
  *
index 276b47bd5b2ca30589fd3fcc8169513d20a845ee..2f9390fdda65647d4a43ce67a33af64ac1aca850 100644 (file)
@@ -4,7 +4,7 @@
  *   PostScript Printer Description definitions for CUPS.
  *
  *   THESE APIS ARE DEPRECATED. TO COMPILE WITHOUT WARNINGS ADD
- *   "-D_PPD_DEPRECATED" TO YOUR COMPILE OPTIONS.  THIS HEADER AND THESE
+ *   -D_PPD_DEPRECATED="" TO YOUR COMPILE OPTIONS.  THIS HEADER AND THESE
  *   FUNCTIONS WILL BE REMOVED IN A FUTURE RELEASE OF CUPS.
  *
  *   Copyright 2007-2011 by Apple Inc.
index 0389eb285769c6f7ceb5e76b9c120f6c2dcd1600..31bbb31150a5f69151287172a55055ea05e746a1 100644 (file)
@@ -178,7 +178,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     fputs("ppdOpenFile(test.ppd): ", stdout);
 
-    if ((ppd = ppdOpenFile("test.ppd")) != NULL)
+    if ((ppd = _ppdOpenFile("test.ppd", _PPD_LOCALIZATION_ALL)) != NULL)
       puts("PASS");
     else
     {
index 6881ec79ddef38b63176b4befd5fb25b3f139dd2..2e6447af54670103598e2343a14f25264ecfe2b5 100644 (file)
@@ -58,7 +58,7 @@
 #    define _CUPS_API_1_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
 #    define _CUPS_API_1_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
 #    define _CUPS_API_1_5 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
-#    define _CUPS_API_1_6 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+#    define _CUPS_API_1_6
 #  else
 #    define _CUPS_API_1_1_19
 #    define _CUPS_API_1_1_20
index c8570be6277eaa05db9e3fd4d04bff2e27d56226..cf35b937aa871e89b043d9c511359fd0fb3d5845 100644 (file)
@@ -218,7 +218,6 @@ install-exec:
        $(INSTALL_BIN) cups-driverd $(SERVERBIN)/daemon
        $(INSTALL_BIN) cups-exec $(SERVERBIN)/daemon
        $(INSTALL_BIN) cups-lpd $(SERVERBIN)/daemon
-       $(INSTALL_BIN) cups-polld $(SERVERBIN)/daemon
        if test "x$(SYMROOT)" != "x"; then \
                $(INSTALL_DIR) $(SYMROOT); \
                for file in $(PROGRAMS); do \
@@ -276,7 +275,6 @@ uninstall:
        $(RM) $(SERVERBIN)/daemon/cups-driverd
        $(RM) $(SERVERBIN)/daemon/cups-exec
        $(RM) $(SERVERBIN)/daemon/cups-lpd
-       $(RM) $(SERVERBIN)/daemon/cups-polld
        $(RM) $(BUILDROOT)/System/Library/Printers/Libraries/convert
        -$(RMDIR) $(STATEDIR)/certs
        -$(RMDIR) $(STATEDIR)
@@ -538,7 +536,7 @@ testsub:    testsub.o ../cups/$(LIBCUPSSTATIC)
 
 sloc:
        echo "cupsd: \c"
-       sloccount $(CUPSDOBJS:.o=.c) $(LIBOBJS:.o=.c) cups-driverd.cxx cups-polld.c cups-lpd.c 2>/dev/null | grep "Total Physical" | awk '{print $$9}'
+       sloccount $(CUPSDOBJS:.o=.c) $(LIBOBJS:.o=.c) cups-driverd.cxx cups-lpd.c 2>/dev/null | grep "Total Physical" | awk '{print $$9}'
 
 
 #
index 85dce903501df772844a9fd654fd3205b9e975f6..e6f9e974145967d296bf08b58a00a52803813044 100644 (file)
@@ -945,7 +945,12 @@ cupsdReadConfiguration(void)
 
   if (!TempDir)
   {
+#ifdef __APPLE__
+    if ((tmpdir = getenv("TMPDIR")) != NULL &&
+        strncmp(tmpdir, "/private/tmp", 12))
+#else
     if ((tmpdir = getenv("TMPDIR")) != NULL)
+#endif /* __APPLE__ */
     {
      /*
       * TMPDIR is defined, see if it is OK for us to use...
index a33e0132ca3d6c96e9fff0fdd884e62e35e4863e..e0e1861f36800217508224196efa4976467f5eff 100644 (file)
@@ -659,7 +659,7 @@ add_printer_filters(
   mime_type_t  *printer_type;          /* Printer filter type */
 
 
-  if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+  if ((ppd = _ppdOpenFile(ppdfile, _PPD_LOCALIZATION_NONE)) == NULL)
   {
     ppd_status_t       status;         /* PPD load status */
     int                        linenum;        /* Line number */
index 63e7e70627a7a1e861304dfd8ef021dbe2102c68..190d4fa9a3e73f08b8d95e8751cf9900e48807fc 100644 (file)
@@ -2840,7 +2840,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
 
     snprintf(srcfile, sizeof(srcfile), "%s/ppd/%s.ppd", ServerRoot,
             printer->name);
-    if ((ppd = ppdOpenFile(srcfile)) != NULL)
+    if ((ppd = _ppdOpenFile(srcfile, _PPD_LOCALIZATION_NONE)) != NULL)
     {
       for (ppdattr = ppdFindAttr(ppd, "cupsPortMonitor", NULL);
           ppdattr;
@@ -3153,7 +3153,7 @@ apple_register_profiles(
   */
 
   snprintf(ppdfile, sizeof(ppdfile), "%s/ppd/%s.ppd", ServerRoot, p->name);
-  if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+  if ((ppd = _ppdOpenFile(ppdfile, _PPD_LOCALIZATION_ICC_PROFILES)) == NULL)
     return;
 
  /*
@@ -5490,12 +5490,23 @@ copy_model(cupsd_client_t *con,         /* I - Client connection */
     return (-1);
   }
 
+ /*
+  * Open the source file for a copy...
+  */
+
+  if ((src = cupsFileOpen(tempfile, "rb")) == NULL)
+  {
+    unlink(tempfile);
+    return (-1);
+  }
+
  /*
   * Read the source file and see what page sizes are supported...
   */
 
-  if ((ppd = ppdOpenFile(tempfile)) == NULL)
+  if ((ppd = _ppdOpen(src, _PPD_LOCALIZATION_NONE)) == NULL)
   {
+    cupsFileClose(src);
     unlink(tempfile);
     return (-1);
   }
@@ -5562,17 +5573,6 @@ copy_model(cupsd_client_t *con,          /* I - Client connection */
 
   ppdClose(ppd);
 
- /*
-  * Open the source file for a copy...
-  */
-
-  if ((src = cupsFileOpen(tempfile, "rb")) == NULL)
-  {
-    cupsFreeOptions(num_defaults, defaults);
-    unlink(tempfile);
-    return (-1);
-  }
-
  /*
   * Open the destination file for a copy...
   */
@@ -5589,6 +5589,8 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
   * Copy the source file to the destination...
   */
 
+  cupsFileRewind(src);
+
   while (cupsFileGets(src, buffer, sizeof(buffer)))
   {
     if (!strncmp(buffer, "*Default", 8))
index fd6216ba4d7c1503feaf6ee027085fc1fb5b5199..cef0eff4b5bc6246c42531ce3275b3d895cf0b75 100644 (file)
@@ -3773,7 +3773,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
 
   p->ppd_attrs = ippNew();
 
-  if ((ppd = ppdOpenFile(ppd_name)) != NULL)
+  if ((ppd = _ppdOpenFile(ppd_name, _PPD_LOCALIZATION_NONE)) != NULL)
   {
    /*
     * Add make/model and other various attributes...