From 34843590b7bd0befc21816ee917aae3f4d31ad8c Mon Sep 17 00:00:00 2001 From: Adesh Deshmukh Date: Tue, 24 Nov 2026 00:10:59 +0530 Subject: [PATCH] fix: support both CUPS 2.x and CUPS 3.x in cupsArrayNew (fixes #30) --- ghostscript-printer-app.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ghostscript-printer-app.c b/ghostscript-printer-app.c index 0006be79..cd512858 100644 --- a/ghostscript-printer-app.c +++ b/ghostscript-printer-app.c @@ -149,7 +149,11 @@ main(int argc, // I - Number of command-line arguments // Keeping vector formats (like PS -> PDF) is usually more desirable // but as many printers have buggy PS interpreters we prefer converting // PDF to Raster and not to PS +#if CUPS_VERSION_MAJOR >= 3 spooling_conversions = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); +#else + spooling_conversions = cupsArrayNew(NULL, NULL); +#endif // Special conversion rule for fxlinuxprint driver (Fuji Xerox // non-IPP-driverless PDF printers) @@ -168,14 +172,22 @@ main(int argc, // I - Number of command-line arguments // PDF comes last because it is generally not streamable. // PostScript comes second as it is Ghostscript's streamable // input format. +#if CUPS_VERSION_MAJOR >= 3 stream_formats = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); +#else + stream_formats = cupsArrayNew(NULL, NULL); +#endif cupsArrayAdd(stream_formats, (void *)&PR_STREAM_CUPS_RASTER); cupsArrayAdd(stream_formats, (void *)&PR_STREAM_POSTSCRIPT); cupsArrayAdd(stream_formats, (void *)&PR_STREAM_PDF); // Array of regular expressions for driver priorization // For some printers the "(recommended)" is missing ... +#if CUPS_VERSION_MAJOR >= 3 driver_selection_regex_list = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); +#else + driver_selection_regex_list = cupsArrayNew(NULL, NULL); +#endif cupsArrayAdd(driver_selection_regex_list, "-recommended-"); cupsArrayAdd(driver_selection_regex_list, "-pdf-"); cupsArrayAdd(driver_selection_regex_list, "-postscript-");