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"
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 */
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@ ****/
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
}
*
* 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);
/*
#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.
*/
}
+# 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.
*/
{
char *bufptr, /* Position in buffer */
*bufend, /* End of buffer */
+ prefix = '{', /* Prefix character */
temp[256]; /* Temporary string */
ipp_attribute_t *attr; /* Current member 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
bufptr += ippAttributeString(attr, temp, sizeof(temp));
}
+ if (prefix == '{')
+ {
+ if (buffer && bufptr < bufend)
+ *bufptr = prefix;
+ bufptr ++;
+ }
+
if (buffer && bufptr < bufend)
*bufptr = '}';
bufptr ++;
* 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
* 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.
* 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.
attr->values[0].collection = value;
- value->use ++;
+ if (value)
+ value->use ++;
return (attr);
}
/*
* '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);
}
* 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 */
/*
- * 'ippFindNextAttribute()' - Find the next named attribute in a request...
+ * 'ippFindNextAttribute()' - Find the next named attribute in a request.
*/
ipp_attribute_t * /* O - Matching 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.
*
}
+/*
+ * '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.
*
}
+/*
+ * '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.
*
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)
{
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
{
break;
}
- attr->num_values ++;
-
/*
* If blocking is disabled, stop here...
*/
*/
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 */
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 */
}
+/*
+ * '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.
*
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 */
{
*/
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 */
*/
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 */
{
*/
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 */
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 */
}
+/*
+ * '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.
*
ipp->request.status.status_code = status;
return (1);
-
}
*/
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 */
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 */
{
*/
if (num_values <= 1)
- alloc_values = num_values;
+ alloc_values = 1;
else
alloc_values = (num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
/*
- * '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) */
{
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)
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.");
*/
*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);
}
* Return the value element...
*/
+ if (element >= temp->num_values)
+ temp->num_values = element + 1;
+
return (temp->values + element);
}
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;
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;
/*
* 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...
*/
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);
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",
*/
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);
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...
*/
_cupsMessageFree(lang->strings);
+ lang->strings = NULL;
}
/*
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...
*/
_cupsMutexLock(&lang_mutex);
+ /*
+ * Load the message catalog if needed...
+ */
+
+ if (!lang->strings)
+ cups_message_load(lang);
+
s = _cupsMessageLookup(lang->strings, message);
_cupsMutexUnlock(&lang_mutex);
}
+/*
+ * '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...
*/
_ppdHashName\r
_ppdLocalizedAttr\r
_ppdNormalizeMakeAndModel\r
+_ppdOpen\r
+_ppdOpenFile\r
_ppdParseOptions\r
_pwgGenerateSize\r
_pwgInitSize\r
_ppdHashName
_ppdLocalizedAttr
_ppdNormalizeMakeAndModel
+_ppdOpen
+_ppdOpenFile
_ppdParseOptions
_pwgCreateWithFile
_pwgDestroy
* 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 */
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);
* 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.
/*
- * '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 */
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
"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...
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"'...
*/
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") ||
return (NULL);
}
- DEBUG_printf(("2ppdOpen2: keyword=%s, string=%p", keyword, string));
+ DEBUG_printf(("2_ppdOpen: keyword=%s, string=%p", keyword, string));
_cupsStrFree(string);
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));
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))
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)
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;
}
!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));
{
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...
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;
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;
* 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 */
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)
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;
}
!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));
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;
!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));
{
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;
* 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
{
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));
}
}
(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"))
{
#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 */
}
+/*
+ * '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.
*/
/*
- * '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 */
if ((fp = cupsFileOpen(filename, "r")) != NULL)
{
- ppd = ppdOpen2(fp);
+ ppd = _ppdOpen(fp, localization);
cupsFileClose(fp);
}
}
+/*
+ * '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.
*
* 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.
fputs("ppdOpenFile(test.ppd): ", stdout);
- if ((ppd = ppdOpenFile("test.ppd")) != NULL)
+ if ((ppd = _ppdOpenFile("test.ppd", _PPD_LOCALIZATION_ALL)) != NULL)
puts("PASS");
else
{
# 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
$(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 \
$(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)
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}'
#
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...
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 */
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;
*/
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;
/*
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);
}
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...
*/
* Copy the source file to the destination...
*/
+ cupsFileRewind(src);
+
while (cupsFileGets(src, buffer, sizeof(buffer)))
{
if (!strncmp(buffer, "*Default", 8))
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...