Skip to content

Commit

Permalink
Fix CUPS 2.5.x compatibility layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Feb 27, 2025
1 parent 060d5fe commit 889a099
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pappl/base-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern char **environ;
# define CUPS_ENCODING_ISO8859_1 CUPS_ISO8859_1
# define CUPS_ENCODING_JIS_X0213 CUPS_JIS_X0213
# define cups_len_t int
# define cups_utf8_src_t char
# define cups_page_header_t cups_page_header2_t
# define cupsArrayNew cupsArrayNew3
# define cupsLangGetName(lang) lang->language
Expand All @@ -58,6 +59,7 @@ extern char **environ;
# else
# define cups_len_t size_t
# define cups_utf8_t char
# define cups_utf8_src_t char
# define IPP_NUM_CAST (size_t)
# endif // CUPS_VERSION_MAJOR < 3

Expand Down
13 changes: 6 additions & 7 deletions pappl/device-network.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Network device support code for the Printer Application Framework
//
// Copyright © 2019-2024 by Michael R Sweet.
// Copyright © 2019-2025 by Michael R Sweet.
// Copyright © 2007-2019 by Apple Inc.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
Expand Down Expand Up @@ -1448,19 +1448,19 @@ pappl_snmp_walk_cb(

case _PAPPL_TC_csISOLatin1 :
case _PAPPL_TC_csUnicodeLatin1 :
cupsCharsetToUTF8((cups_utf8_t *)sock->supplies[i].description, (cups_utf8_t *)packet->object_value.string.bytes, (size_t)sizeof(sock->supplies[i].description), CUPS_ENCODING_ISO8859_1);
cupsCharsetToUTF8((cups_utf8_t *)sock->supplies[i].description, (cups_utf8_src_t *)packet->object_value.string.bytes, (cups_len_t)sizeof(sock->supplies[i].description), CUPS_ENCODING_ISO8859_1);
break;

case _PAPPL_TC_csShiftJIS :
case _PAPPL_TC_csWindows31J : /* Close enough for our purposes */
cupsCharsetToUTF8((cups_utf8_t *)sock->supplies[i].description, (cups_utf8_t *)packet->object_value.string.bytes, (size_t)sizeof(sock->supplies[i].description), CUPS_ENCODING_JIS_X0213);
cupsCharsetToUTF8((cups_utf8_t *)sock->supplies[i].description, (cups_utf8_src_t *)packet->object_value.string.bytes, (cups_len_t)sizeof(sock->supplies[i].description), CUPS_ENCODING_JIS_X0213);
break;

case _PAPPL_TC_csUCS4 :
case _PAPPL_TC_csUTF32 :
case _PAPPL_TC_csUTF32BE :
case _PAPPL_TC_csUTF32LE :
cupsUTF32ToUTF8((cups_utf8_t *)sock->supplies[i].description, (cups_utf32_t *)packet->object_value.string.bytes, (size_t)sizeof(sock->supplies[i].description));
cupsUTF32ToUTF8((cups_utf8_t *)sock->supplies[i].description, (cups_utf32_t *)packet->object_value.string.bytes, (cups_len_t)sizeof(sock->supplies[i].description));
break;

case _PAPPL_TC_csUnicode :
Expand All @@ -1475,8 +1475,7 @@ pappl_snmp_walk_cb(
{
char *src, *dst, *dstend; // Pointers into strings

for (src = (char *)packet->object_value.string.bytes,
dst = sock->supplies[i].description, dstend = dst + sizeof(sock->supplies[i].description) - 1; *src && dst < dstend; src ++)
for (src = (char *)packet->object_value.string.bytes, dst = sock->supplies[i].description, dstend = dst + sizeof(sock->supplies[i].description) - 1; *src && dst < dstend; src ++)
{
if ((*src & 0x80) || *src < ' ' || *src == 0x7f)
*dst++ = '?';
Expand Down Expand Up @@ -2030,5 +2029,5 @@ utf16_to_utf8(

*ptr = '\0';

cupsUTF32ToUTF8(dst, temp, (size_t)dstsize);
cupsUTF32ToUTF8((cups_utf8_t *)dst, temp, (size_t)dstsize);
}
8 changes: 4 additions & 4 deletions pappl/printer-ipp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Printer IPP processing for the Printer Application Framework
//
// Copyright © 2019-2024 by Michael R Sweet.
// Copyright © 2019-2025 by Michael R Sweet.
// Copyright © 2010-2019 by Apple Inc.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
Expand Down Expand Up @@ -1452,7 +1452,7 @@ _papplPrinterSetAttributes(
else if (!strcmp(name, "printer-wifi-password"))
{
void *data; // Password
size_t datalen; // Length of password
cups_len_t datalen; // Length of password

data = ippGetOctetString(rattr, 0, &datalen);
if (datalen > (sizeof(wifi_password) - 1))
Expand Down Expand Up @@ -2641,7 +2641,7 @@ ipp_update_output_device_attributes(
case IPP_TAG_STRING :
for (i = old_count - 1; i >= (size_t)end; i --)
{
size_t datalen;// Length of string
cups_len_t datalen;// Length of string
void *data = ippGetOctetString(old_attr, i, &datalen);
// String

Expand Down Expand Up @@ -2718,7 +2718,7 @@ ipp_update_output_device_attributes(
case IPP_TAG_STRING :
for (i = (size_t)end; i >= (size_t)start; i --)
{
size_t datalen; // Length of string
cups_len_t datalen; // Length of string
void *data = ippGetOctetString(attr, i - (size_t)start, &datalen);
// String

Expand Down
4 changes: 2 additions & 2 deletions pappl/subscription-ipp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// IPP subscription processing for the Printer Application Framework
//
// Copyright © 2022-2024 by Michael R Sweet.
// Copyright © 2022-2025 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
Expand Down Expand Up @@ -136,7 +136,7 @@ _papplSubscriptionIPPCreate(
pappl_event_t events = PAPPL_EVENT_NONE;
// "notify-events" bit field
const void *data = NULL; // "notify-user-data" value, if any
size_t datalen = 0; // "notify-user-data" value length
cups_len_t datalen = 0; // "notify-user-data" value length
int interval = 0, // "notify-time-interval" value
lease = PAPPL_LEASE_DEFAULT;
// "notify-lease-duration" value
Expand Down
2 changes: 1 addition & 1 deletion testsuite/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Test suite makefile for the Printer Application Framework
#
# Copyright © 2020-2024 by Michael R Sweet
# Copyright © 2020-2025 by Michael R Sweet
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
Expand Down

0 comments on commit 889a099

Please sign in to comment.