From c65e1c4ffd23d3f891c45207cd472f650880cebd Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 22 Feb 2018 14:16:46 -0500 Subject: [PATCH] Add public cupsEncodeOption API --- CHANGES.md | 2 ++ cups/cups.h | 3 ++- cups/encode.c | 27 ++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 94ec6a5b4..0b440ab46 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,8 @@ Changes in CUPS v2.3rc1 (rdar://37789645) - The ipptool `--ippserver` option did not encode out-of-band attributes correctly. +- Added public `cupsEncodeOption` API for encoding a single option as an IPP + attribute. - Documentation fixes (Issue #5252) diff --git a/cups/cups.h b/cups/cups.h index 225e6ca74..1a0b34a3d 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -601,7 +601,8 @@ extern int cupsAddIntegerOption(const char *name, int value, int num_options, c extern int cupsGetIntegerOption(const char *name, int num_options, cups_option_t *options) _CUPS_API_2_2_4; /* New in CUPS 2.3 */ -extern int cupsAddDestMediaOptions(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size, int num_options, cups_option_t **options); +extern int cupsAddDestMediaOptions(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size, int num_options, cups_option_t **options) _CUPS_API_2_3; +extern ipp_attribute_t *cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, const char *name, const char *value) _CUPS_API_2_3; extern const char *cupsHashString(const unsigned char *hash, size_t hashsize, char *buffer, size_t bufsize) _CUPS_API_2_3; # ifdef __cplusplus diff --git a/cups/encode.c b/cups/encode.c index 927b4a2ed..316ff2490 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -1,10 +1,11 @@ /* * Option encoding routines for CUPS. * - * Copyright 2007-2017 by Apple Inc. - * Copyright 1997-2007 by Easy Software Products. + * Copyright © 2007-2018 by Apple Inc. + * Copyright © 1997-2007 by Easy Software Products. * - * Licensed under Apache License v2.0. See the file "LICENSE" for more information. + * Licensed under Apache License v2.0. See the file "LICENSE" for more + * information. */ /* @@ -626,6 +627,22 @@ _cupsEncodeOption( } +/* + * 'cupsEncodeOption()' - Encode a single option into an IPP attribute. + * + * @since CUPS 2.3@ + */ + +ipp_attribute_t * /* O - New attribute or @code NULL@ on error */ +cupsEncodeOption(ipp_t *ipp, /* I - IPP request/response */ + ipp_tag_t group_tag, /* I - Attribute group */ + const char *name, /* I - Option name */ + const char *value) /* I - Option string value */ +{ + return (_cupsEncodeOption(ipp, group_tag, _ippFindOption(name), name, value)); +} + + /* * 'cupsEncodeOptions()' - Encode printer options into IPP attributes. * @@ -635,7 +652,7 @@ _cupsEncodeOption( */ void -cupsEncodeOptions(ipp_t *ipp, /* I - Request to add to */ +cupsEncodeOptions(ipp_t *ipp, /* I - IPP request/response */ int num_options, /* I - Number of options */ cups_option_t *options) /* I - Options */ { @@ -663,7 +680,7 @@ cupsEncodeOptions(ipp_t *ipp, /* I - Request to add to */ void cupsEncodeOptions2( - ipp_t *ipp, /* I - Request to add to */ + ipp_t *ipp, /* I - IPP request/response */ int num_options, /* I - Number of options */ cups_option_t *options, /* I - Options */ ipp_tag_t group_tag) /* I - Group to encode */ -- 2.39.2