diff --git a/Makefile.am b/Makefile.am index aa91455b2..7aed422bb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -84,8 +84,8 @@ libppd_la_SOURCES = \ ppd/file-private.h \ ppd/imagetops-pstops.c \ ppd/ipp-private.h \ - ppd/language.c \ - ppd/language-private.h \ + ppd/libcups2.c \ + ppd/libcups2-private.h \ ppd/pdftops.c \ ppd/raster-interpret.c \ ppd/raster-error.c \ @@ -124,13 +124,19 @@ libppd_la_LIBADD = \ libppd_la_CFLAGS = \ $(LIBCUPSFILTERS_CFLAGS) \ $(CUPS_CFLAGS) +libppd_la_CXXFLAGS = \ + $(libppd_la_CFLAGS) libppd_la_LDFLAGS = \ -no-undefined \ -version-info 2 testppd_SOURCES = ppd/testppd.c -testppd_LDADD = libppd.la \ - -lcups +testppd_LDADD = \ + libppd.la \ + $(CUPS_LIBS) +testppd_CFLAGS = \ + -I$(srcdir)/ppd/ \ + $(CUPS_CFLAGS) EXTRA_DIST += \ $(pkgppdinclude_DATA) \ diff --git a/configure.ac b/configure.ac index da62fa4e7..66927d80a 100644 --- a/configure.ac +++ b/configure.ac @@ -59,49 +59,89 @@ AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET LT_INIT + +# ========== +# pkg-config +# ========== PKG_PROG_PKG_CONFIG([0.20]) +AC_PATH_TOOL([PKGCONFIG], [pkg-config]) AM_GNU_GETTEXT_VERSION([0.18.3]) AM_GNU_GETTEXT([external]) -# ================================ -# Find CUPS internals (no pc file) -# ================================ -AC_ARG_WITH([cups-config], - [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])], - [with_cups_config="$withval"], - [with_cups_config=system] -) - -AS_IF([test "x$with_cups_config" != "xsystem"], [ - CUPSCONFIG=$with_cups_config +# ==== +# CUPS +# ==== +AC_MSG_CHECKING([for CUPS library v3.0 or higher]) +AS_IF([$PKGCONFIG --exists cups3], [ + CUPS_VERSION="$($PKGCONFIG --modversion cups3)" + AC_MSG_RESULT([yes, v$CUPS_VERSION]) + CUPS_CFLAGS="$($PKGCONFIG --cflags cups3)" + CUPS_LIBS="$LIBS $($PKGCONFIG --libs cups3)" + AC_SUBST(CUPS_CFLAGS) + AC_SUBST(CUPS_LIBS) + CUPS_DATADIR="$($PKGCONFIG --variable=prefix cups3)/share/cups" + AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir]) + AC_SUBST(CUPS_DATADIR) + AS_IF([test x$host_os_name = xdarwin], [ + CUPS_SERVERROOT="/private/etc/cups" + ], [ + AS_IF([test "x$($PKGCONFIG --variable=prefix cups3)" = x/usr], [ + CUPS_SERVERROOT="/etc/cups" + ], [ + CUPS_SERVERROOT="$($PKGCONFIG --variable=prefix cups3)/etc/cups" + ]) + ]) + AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$CUPS_SERVERROOT", [CUPS serverroot]) + AC_SUBST(CUPS_SERVERROOT) + CUPS_FONTPATH="$CUPS_DATADIR/fonts" + AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH", + [Path to CUPS fonts dir]) + AC_SUBST(CUPS_FONTPATH) + CUPS_SERVERBIN="$($PKGCONFIG --variable=prefix cups3)/lib/cups" + AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN", + [Path to CUPS binaries dir]) + AC_SUBST(CUPS_SERVERBIN) ], [ + AC_MSG_RESULT(no) + AC_ARG_WITH([cups-config], + [AS_HELP_STRING([--with-cups-config=path], [Specify path to cups-config executable.])], + [with_cups_config="$withval"], + [with_cups_config=system]) + AS_IF([test "x$with_cups_config" != "xsystem"], [ + CUPSCONFIG=$with_cups_config + ], [ AC_PATH_TOOL(CUPSCONFIG, [cups-config]) - AS_IF([test -z "$CUPSCONFIG"], [ - AC_MSG_ERROR([Required cups-config is missing. Please install CUPS developer packages.]) - ]) + ]) + AC_MSG_CHECKING([for CUPS library v2.x]) + AS_IF([test -n "$CUPSCONFIG"], [ + CUPS_VERSION=`$CUPSCONFIG --version` + AC_MSG_RESULT([yes, v$CUPS_VERSION]) + AC_DEFINE([HAVE_LIBCUPS2], [1], [Use libcups2]) + CUPS_CFLAGS=`$CUPSCONFIG --cflags` + CUPS_LIBS=`$CUPSCONFIG --image --libs` + AC_SUBST(CUPS_CFLAGS) + AC_SUBST(CUPS_LIBS) + CUPS_DATADIR="`$CUPSCONFIG --datadir`" + AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir]) + AC_SUBST(CUPS_DATADIR) + CUPS_SERVERROOT="`$CUPSCONFIG --serverroot`" + AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$CUPS_SERVERROOT", + [CUPS serverroot]) + AC_SUBST(CUPS_SERVERROOT) + CUPS_FONTPATH="$CUPS_DATADIR/fonts" + AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH", + [Path to CUPS fonts dir]) + AC_SUBST(CUPS_FONTPATH) + CUPS_SERVERBIN="`$CUPSCONFIG --serverbin`" + AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN", + [Path to CUPS binaries dir]) + AC_SUBST(CUPS_SERVERBIN) + ], [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([Required cups-config is missing. Please install CUPS developer packages.]) + ]) ]) -CUPS_CFLAGS=`$CUPSCONFIG --cflags` -CUPS_LIBS=`$CUPSCONFIG --image --libs` -CUPS_VERSION=`$CUPSCONFIG --version` -AC_SUBST(CUPS_CFLAGS) -AC_SUBST(CUPS_LIBS) - -CUPS_DATADIR="`$CUPSCONFIG --datadir`" -AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir]) -AC_SUBST(CUPS_DATADIR) - -CUPS_SERVERROOT="`$CUPSCONFIG --serverroot`" -AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$CUPS_SERVERROOT", [CUPS serverroot]) -AC_SUBST(CUPS_SERVERROOT) - -CUPS_FONTPATH="$CUPS_DATADIR/fonts" -AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH", [Path to CUPS fonts dir]) -AC_SUBST(CUPS_FONTPATH) - -CUPS_SERVERBIN="`$CUPSCONFIG --serverbin`" -AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN", [Path to CUPS binaries dir]) -AC_SUBST(CUPS_SERVERBIN) # Transient run-time state dir of CUPS CUPS_STATEDIR="" @@ -455,11 +495,12 @@ AC_ARG_ENABLE([werror], ) AS_IF([test x"$enable_werror" = "xyes"], [ CFLAGS="$CFLAGS -Werror" + CXXFLAGS="$CXXFLAGS -Werror" ]) AS_IF([test x"$GCC" = "xyes"], [ # Be tough with warnings and produce less careless code CFLAGS="$CFLAGS -Wall -std=gnu11" - CXXFLAGS="$CXXFLAGS -Wall " # -Weffc++" # TODO: enable when it does not print 1MB of warnings + CXXFLAGS="$CXXFLAGS -Wall -std=c++17" # -Weffc++" # TODO: enable when it does not print 1MB of warnings ]) CFLAGS="$CFLAGS -D_GNU_SOURCE" CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE" @@ -503,6 +544,7 @@ Environment settings: CXXFLAGS: ${CXXFLAGS} LDFLAGS: ${LDFLAGS} Build configuration: + libcups: ${CUPS_VERSION} cups-config: ${with_cups_config} ghostscript: ${enable_ghostscript} gs-path: ${with_gs_path} diff --git a/ppd/array.c b/ppd/array.c index 3c7a48eff..f03dd5524 100644 --- a/ppd/array.c +++ b/ppd/array.c @@ -12,9 +12,10 @@ // Include necessary headers... // -#include "string-private.h" -#include "debug-internal.h" -#include "array-private.h" +#include +#include +#include +#include // @@ -129,9 +130,9 @@ _ppdArrayNewStrings(const char *s, // I - Delimited strings or NULL cups_array_t *a; // Array - if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, - (cups_acopy_func_t)_ppdStrAlloc, - (cups_afree_func_t)_ppdStrFree)) != NULL) + if ((a = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, + (cups_acopy_cb_t)_ppdStrAlloc, + (cups_afree_cb_t )_ppdStrFree)) != NULL) _ppdArrayAddStrings(a, s, delim); return (a); diff --git a/ppd/debug.c b/ppd/debug.c index 4120f5905..c002952e6 100644 --- a/ppd/debug.c +++ b/ppd/debug.c @@ -11,8 +11,8 @@ // Include necessary headers... // -#include "string-private.h" -#include "debug-internal.h" +#include +#include #ifdef _WIN32 # include # include diff --git a/ppd/file.c b/ppd/file.c index 940c7e1d5..19a6476a0 100644 --- a/ppd/file.c +++ b/ppd/file.c @@ -12,9 +12,9 @@ // Include necessary headers... // -#include "file-private.h" -#include "language-private.h" -#include "debug-internal.h" +#include +#include +#include #include #include #include @@ -24,6 +24,13 @@ # endif // HAVE_LIBZ +// +// Macro for localized text... +// + +# define _(x) x + + #ifndef _WIN32 // // '_ppdFileCheck()' - Check the permissions of the given filename. @@ -178,13 +185,13 @@ _ppdFileCheck( loglevel = CF_LOGLEVEL_DEBUG; if (filetype == _PPD_FILE_CHECK_DIRECTORY) snprintf(message, sizeof(message), - _ppdLangString(lang, _("Directory \"%s\" permissions OK " + cupsLangGetString(lang, _("Directory \"%s\" permissions OK " "(0%o/uid=%d/gid=%d).")), filename, fileinfo.st_mode, (int)fileinfo.st_uid, (int)fileinfo.st_gid); else snprintf(message, sizeof(message), - _ppdLangString(lang, _("File \"%s\" permissions OK " + cupsLangGetString(lang, _("File \"%s\" permissions OK " "(0%o/uid=%d/gid=%d).")), filename, fileinfo.st_mode, (int)fileinfo.st_uid, (int)fileinfo.st_gid); @@ -194,12 +201,12 @@ _ppdFileCheck( loglevel = CF_LOGLEVEL_ERROR; if (filetype == _PPD_FILE_CHECK_DIRECTORY) snprintf(message, sizeof(message), - _ppdLangString(lang, _("Directory \"%s\" not available: " + cupsLangGetString(lang, _("Directory \"%s\" not available: " "%s")), filename, strerror(errno)); else snprintf(message, sizeof(message), - _ppdLangString(lang, _("File \"%s\" not available: %s")), + cupsLangGetString(lang, _("File \"%s\" not available: %s")), filename, strerror(errno)); break; @@ -207,14 +214,14 @@ _ppdFileCheck( loglevel = CF_LOGLEVEL_ERROR; if (filetype == _PPD_FILE_CHECK_DIRECTORY) snprintf(message, sizeof(message), - _ppdLangString(lang, _("Directory \"%s\" has insecure " + cupsLangGetString(lang, _("Directory \"%s\" has insecure " "permissions " "(0%o/uid=%d/gid=%d).")), filename, fileinfo.st_mode, (int)fileinfo.st_uid, (int)fileinfo.st_gid); else snprintf(message, sizeof(message), - _ppdLangString(lang, _("File \"%s\" has insecure " + cupsLangGetString(lang, _("File \"%s\" has insecure " "permissions " "(0%o/uid=%d/gid=%d).")), filename, fileinfo.st_mode, (int)fileinfo.st_uid, @@ -225,11 +232,11 @@ _ppdFileCheck( loglevel = CF_LOGLEVEL_ERROR; if (filetype == _PPD_FILE_CHECK_DIRECTORY) snprintf(message, sizeof(message), - _ppdLangString(lang, _("Directory \"%s\" is a file.")), + cupsLangGetString(lang, _("Directory \"%s\" is a file.")), filename); else snprintf(message, sizeof(message), - _ppdLangString(lang, _("File \"%s\" is a directory.")), + cupsLangGetString(lang, _("File \"%s\" is a directory.")), filename); break; @@ -237,11 +244,11 @@ _ppdFileCheck( loglevel = CF_LOGLEVEL_ERROR; if (filetype == _PPD_FILE_CHECK_DIRECTORY) snprintf(message, sizeof(message), - _ppdLangString(lang, _("Directory \"%s\" contains a " + cupsLangGetString(lang, _("Directory \"%s\" contains a " "relative path.")), filename); else snprintf(message, sizeof(message), - _ppdLangString(lang, _("File \"%s\" contains a relative " + cupsLangGetString(lang, _("File \"%s\" contains a relative " "path.")), filename); break; } diff --git a/ppd/imagetops-pstops.c b/ppd/imagetops-pstops.c index aae9e085d..42ff51d3e 100644 --- a/ppd/imagetops-pstops.c +++ b/ppd/imagetops-pstops.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -510,8 +511,8 @@ ppdFilterPSToPS(int inputfd, // I - File descriptor input stream if (doc.pages) { - for (pageinfo = (pstops_page_t *)cupsArrayFirst(doc.pages); - pageinfo; pageinfo = (pstops_page_t *)cupsArrayNext(doc.pages)) + for (pageinfo = (pstops_page_t *)cupsArrayGetFirst(doc.pages); + pageinfo; pageinfo = (pstops_page_t *)cupsArrayGetNext(doc.pages)) { if (pageinfo->label) free(pageinfo->label); @@ -631,7 +632,7 @@ ppdFilterImageToPS(int inputfd, // I - File descriptor input char curdate[255]; // Current date string int fillprint = 0; // print-scaling = fill int cropfit = 0; // -o crop-to-fit = true - cups_page_header2_t h; // CUPS Raster page header, to + cups_page_header_t h; // CUPS Raster page header, to // accommodate results of command // line parsing for PPD-less queue int Flip, // Flip/mirror pages @@ -699,7 +700,7 @@ ppdFilterImageToPS(int inputfd, // I - File descriptor input // if (!inputseekable) { - if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0) + if ((fd = cupsCreateTempFd(NULL, NULL, tempfile, sizeof(tempfile))) < 0) { if (log) log(ld, CF_LOGLEVEL_ERROR, "ppdFilterImageToPS: Unable to copy input: %s", @@ -1912,7 +1913,7 @@ add_page(pstops_doc_t *doc, // I - Document information if (!doc->pages) - doc->pages = cupsArrayNew(NULL, NULL); + doc->pages = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); if (!doc->pages) { @@ -2395,11 +2396,11 @@ copy_dsc(pstops_doc_t *doc, // I - Document info // Finish up the last page(s)... // - if (number && is_not_last_page(number) && cupsArrayLast(doc->pages) && + if (number && is_not_last_page(number) && cupsArrayGetLast(doc->pages) && check_range((number - 1) / doc->number_up + 1, doc->page_ranges, doc->page_set)) { - pageinfo = (pstops_page_t *)cupsArrayLast(doc->pages); + pageinfo = (pstops_page_t *)cupsArrayGetLast(doc->pages); start_nup(doc, doc->number_up, 0, doc->bounding_box); doc_puts(doc, "showpage\n"); @@ -2442,7 +2443,7 @@ copy_dsc(pstops_doc_t *doc, // I - Document info number = doc->slow_order ? 0 : doc->page; if (doc->temp && (!iscanceled || !iscanceled(icd)) && - cupsArrayCount(doc->pages) > 0) + cupsArrayGetCount(doc->pages) > 0) { int copy; // Current copy @@ -2485,7 +2486,8 @@ copy_dsc(pstops_doc_t *doc, // I - Document info // fputs("%%Trailer\n", doc->outputfp); - fprintf(doc->outputfp, "%%%%Pages: %d\n", cupsArrayCount(doc->pages)); + fprintf(doc->outputfp, "%%%%Pages: %d\n", + (int)cupsArrayGetCount(doc->pages)); if (doc->number_up > 1 || doc->fit_to_page) fprintf(doc->outputfp, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n", doc->PageLeft, doc->PageBottom, @@ -2514,7 +2516,7 @@ copy_dsc(pstops_doc_t *doc, // I - Document info if (!number) { - pageinfo = (pstops_page_t *)cupsArrayFirst(doc->pages); + pageinfo = (pstops_page_t *)cupsArrayGetFirst(doc->pages); copy_bytes(doc, 0, (size_t)pageinfo->offset); } @@ -2522,8 +2524,8 @@ copy_dsc(pstops_doc_t *doc, // I - Document info // Then copy all of the pages... // - pageinfo = doc->slow_order ? (pstops_page_t *)cupsArrayLast(doc->pages) : - (pstops_page_t *)cupsArrayFirst(doc->pages); + pageinfo = doc->slow_order ? (pstops_page_t *)cupsArrayGetLast(doc->pages) : + (pstops_page_t *)cupsArrayGetFirst(doc->pages); while (pageinfo) { @@ -2560,8 +2562,8 @@ copy_dsc(pstops_doc_t *doc, // I - Document info copy_bytes(doc, pageinfo->offset, (size_t)pageinfo->length); pageinfo = doc->slow_order ? - (pstops_page_t *)cupsArrayPrev(doc->pages) : - (pstops_page_t *)cupsArrayNext(doc->pages); + (pstops_page_t *)cupsArrayGetPrev(doc->pages) : + (pstops_page_t *)cupsArrayGetNext(doc->pages); } } } @@ -2832,7 +2834,7 @@ copy_page(pstops_doc_t *doc, // I - Document info return (0); } else - pageinfo = (pstops_page_t *)cupsArrayLast(doc->pages); + pageinfo = (pstops_page_t *)cupsArrayGetLast(doc->pages); // // Handle first page override... @@ -4395,8 +4397,8 @@ set_pstops_options( if (doc->slow_order || doc->slow_collate) { - if ((doc->temp = cupsTempFile2(doc->tempfile, - sizeof(doc->tempfile))) == NULL) + if ((doc->temp = cupsCreateTempFile(NULL, NULL, doc->tempfile, + sizeof(doc->tempfile))) == NULL) { if (log) log(ld, CF_LOGLEVEL_ERROR, "ppdFilterPSToPS: Unable to create temporary file: %s", diff --git a/ppd/language-private.h b/ppd/language-private.h deleted file mode 100644 index 5bf96fc93..000000000 --- a/ppd/language-private.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// Private localization support functions for libppd. -// -// Copyright © 2007-2018 by Apple Inc. -// Copyright © 1997-2006 by Easy Software Products. -// -// Licensed under Apache License v2.0. See the file "LICENSE" for more -// information. -// - -#ifndef _PPD_LANGUAGE_PRIVATE_H_ -# define _PPD_LANGUAGE_PRIVATE_H_ - -// -// Include necessary headers... -// - -# include "config.h" -# include -# include -# ifdef __APPLE__ -# include -# endif // __APPLE__ - -# ifdef __cplusplus -extern "C" { -# endif // __cplusplus - - -// -// Macro for localized text... -// - -# define _(x) x - - -// -// Constants... -// - -# define _PPD_MESSAGE_PO 0 // Message file is in GNU .po format -# define _PPD_MESSAGE_UNQUOTE 1 // Unescape \foo in strings? -# define _PPD_MESSAGE_STRINGS 2 // Message file is in Apple .strings - // format -# define _PPD_MESSAGE_EMPTY 4 // Allow empty localized strings - - -// -// Types... -// - -typedef struct _ppd_message_s // **** Message catalog entry **** -{ - char *msg, // Original string - *str; // Localized string -} _ppd_message_t; - - -// -// Prototypes... -// - -extern const char *_ppdLangString(cups_lang_t *lang, const char *message); -extern void _ppdMessageFree(cups_array_t *a); -extern cups_array_t *_ppdMessageLoad(const char *filename, int flags); -extern const char *_ppdMessageLookup(cups_array_t *a, const char *m); -extern cups_array_t *_ppdMessageNew(void *context); - - -# ifdef __cplusplus -} -# endif // __cplusplus - -#endif // !_PPD_LANGUAGE_PRIVATE_H_ diff --git a/ppd/libcups2-private.h b/ppd/libcups2-private.h new file mode 100644 index 000000000..bf2dacbf1 --- /dev/null +++ b/ppd/libcups2-private.h @@ -0,0 +1,108 @@ +// +// Libcups2 header file for libcupsfilters. +// +// Copyright 2020-2022 by Till Kamppeter. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +#ifndef _LIBCUPS2_PRIVATE_H_ +# define _LIBCUPS2_PRIVATE_H_ + +# include + +# ifdef HAVE_LIBCUPS2 + +// These CUPS headers need to get applied before applying the +// renaming "#define"s. Otherwise we get conflicting duplicate +// declarations. + +# include "cups/http.h" +# include "cups/array.h" +# include "cups/cups.h" +# include "cups/ipp.h" +# include "cups/raster.h" +# include "cups/language.h" + +// +// C++ magic... +// + +# ifdef __cplusplus +extern "C" { +# endif // __cplusplus + + +// Constants renamed in libcups3 + +# define CUPS_ENCODING_ISO8859_1 CUPS_ISO8859_1 +# define CUPS_ENCODING_ISO8859_2 CUPS_ISO8859_2 +# define CUPS_ENCODING_ISO8859_5 CUPS_ISO8859_5 +# define CUPS_ENCODING_JIS_X0213 CUPS_JIS_X0213 +# define CUPS_ENCODING_MAC_ROMAN CUPS_MAC_ROMAN +# define CUPS_ENCODING_WINDOWS_1252 CUPS_WINDOWS_1252 +# define CUPS_ENCODING_UTF_8 CUPS_UTF8 + +// Functions renamed in libcups3 + +# define cupsArrayGetCount cupsArrayCount +# define cupsArrayGetFirst cupsArrayFirst +# define cupsArrayGetNext cupsArrayNext +# define cupsArrayGetPrev cupsArrayPrev +# define cupsArrayGetLast cupsArrayLast +# define cupsArrayGetElement cupsArrayIndex +# define cupsArrayNew cupsArrayNew3 +# define cupsGetDests cupsGetDests2 +# define cupsGetError cupsLastError +# define cupsGetErrorString cupsLastErrorString +# define cupsRasterReadHeader cupsRasterReadHeader2 +# define cupsRasterWriteHeader cupsRasterWriteHeader2 +# define httpConnect httpConnect2 +# define httpAddrGetPort httpAddrPort +# define ippGetFirstAttribute ippFirstAttribute +# define ippGetNextAttribute ippNextAttribute +# define ippGetLength ippLength + +// Functions replaced by a different functions in libcups3 + +# define cupsCreateTempFd(prefix,suffix,buffer,bufsize) cupsTempFd(buffer,bufsize) +# define cupsCreateTempFile(prefix,suffix,buffer,bufsize) cupsTempFile2(buffer,bufsize) + +// Data types renamed in libcups3 + +# define cups_acopy_cb_t cups_acopy_func_t +# define cups_ahash_cb_t cups_ahash_func_t +# define cups_afree_cb_t cups_afree_func_t +# define cups_array_cb_t cups_array_func_t +# define ipp_io_cb_t ipp_iocb_t +# define cups_page_header_t cups_page_header2_t + +// For some functions' parameters in libcups3 size_t is used while +// int was used in libcups2. We use this type in such a case. + +# define cups_len_t int + +// For some functions' parameters in libcups3 bool is used while +// int was used in libcups2. We use this type in such a case. + +# define cups_bool_t int + +// Prototypes of functions equivalent to newly introduced ones in libcups3 + +const char *cupsLangGetName(cups_lang_t *lang); +const char *cupsLangGetString(cups_lang_t *lang, const char *message); + +# ifdef __cplusplus +} +# endif // __cplusplus + +# else + +# define cups_len_t size_t +# define cups_utf8_t char +# define cups_bool_t bool + +# endif // HAVE_LIBCUPS2 + +#endif // !_LIBCUPS2_PRIVATE_H_ diff --git a/ppd/language.c b/ppd/libcups2.c similarity index 73% rename from ppd/language.c rename to ppd/libcups2.c index 513ca12e2..63076ad2b 100644 --- a/ppd/language.c +++ b/ppd/libcups2.c @@ -1,19 +1,22 @@ // -// I18N/language support for libppd. +// Wrapper function for ipp.c for libcups2. // -// Copyright 2007-2017 by Apple Inc. -// Copyright 1997-2007 by Easy Software Products. +// Copyright 2020-2022 by Till Kamppeter. // // Licensed under Apache License v2.0. See the file "LICENSE" for more // information. // - // // Include necessary headers... // + +#include + +#ifdef HAVE_LIBCUPS2 + +#include #include "string-private.h" -#include "language-private.h" #include "thread-private.h" #include "debug-internal.h" #ifdef HAVE_LANGINFO_H @@ -28,132 +31,247 @@ # include #endif // HAVE_COREFOUNDATION_H #include +#include +#include +#include +#include +#include // -// Local globals... +// Constants... // -static _ppd_mutex_t lang_mutex = _PPD_MUTEX_INITIALIZER; - // Mutex to control access to cache +# define _PPD_MESSAGE_PO 0 // Message file is in GNU .po format +# define _PPD_MESSAGE_UNQUOTE 1 // Unescape \foo in strings? +# define _PPD_MESSAGE_STRINGS 2 // Message file is in Apple .strings + // format +# define _PPD_MESSAGE_EMPTY 4 // Allow empty localized strings -#ifdef __APPLE__ -typedef struct -{ - const char * const language; // Language ID - const char * const locale; // Locale ID -} _apple_language_locale_t; -static const _apple_language_locale_t apple_language_locale[] = -{ // Language to locale ID LUT - { "en", "en_US" }, - { "nb", "no" }, - { "nb_NO", "no" }, - { "zh-Hans", "zh_CN" }, - { "zh_HANS", "zh_CN" }, - { "zh-Hant", "zh_TW" }, - { "zh_HANT", "zh_TW" }, - { "zh-Hant_CN", "zh_TW" } -}; -#endif // __APPLE__ +// +// Types... +// + +typedef struct _ppd_message_s // **** Message catalog entry **** +{ + char *msg, // Original string + *str; // Localized string +} _ppd_message_t; // -// Local functions... +// Local globals... // -#ifdef __APPLE__ -static const char *appleLangDefault(void); -# ifdef CUPS_BUNDLEDIR -# ifndef CF_RETURNS_RETAINED -# if __has_feature(attribute_cf_returns_retained) -# define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -# else -# define CF_RETURNS_RETAINED -# endif // __has_feature(attribute_cf_returns_retained) -# endif // !CF_RETURNED_RETAINED -static cups_array_t *appleMessageLoad(const char *locale) CF_RETURNS_RETAINED; -# endif // CUPS_BUNDLEDIR -#endif // __APPLE__ -static int ppd_message_compare(_ppd_message_t *m1, _ppd_message_t *m2); -static void ppd_message_free(_ppd_message_t *m); -static void ppd_message_load(cups_lang_t *lang); -static int ppd_read_strings(cups_file_t *fp, int flags, cups_array_t *a); -static void ppd_unquote(char *d, const char *s); +static _ppd_mutex_t lang_mutex = _PPD_MUTEX_INITIALIZER; + // Mutex to control access to cache // -// '_ppdLangString()' - Get a message string. +// Local functions... // -// The returned string is UTF-8 encoded; use cupsUTF8ToCharset() to -// convert the string to the language encoding. + +// +// 'ppd_message_compare()' - Compare two messages. // -const char * // O - Localized message -_ppdLangString(cups_lang_t *lang, // I - Language - const char *message) // I - Message +static int // O - Result of comparison +ppd_message_compare( + _ppd_message_t *m1, // I - First message + _ppd_message_t *m2) // I - Second message { - const char *s; // Localized message + return (strcmp(m1->msg, m2->msg)); +} - DEBUG_printf(("_ppdLangString(lang=%p, message=\"%s\")", - (void *)lang, message)); +// +// 'ppd_message_free()' - Free a message. +// - // - // Range check input... - // +static void +ppd_message_free(_ppd_message_t *m) // I - Message +{ + if (m->msg) + free(m->msg); - if (!lang || !message || !*message) - return (message); + if (m->str) + free(m->str); - _ppdMutexLock(&lang_mutex); + free(m); +} - // - // Load the message catalog if needed... - // - if (!lang->strings) - ppd_message_load(lang); +// +// 'ppd_unquote()' - Unquote characters in strings... +// - s = _ppdMessageLookup(lang->strings, message); +static void +ppd_unquote(char *d, // O - Unquoted string + const char *s) // I - Original string +{ + while (*s) + { + if (*s == '\\') + { + s ++; + if (isdigit(*s)) + { + *d = 0; - _ppdMutexUnlock(&lang_mutex); + while (isdigit(*s)) + { + *d = *d * 8 + *s - '0'; + s ++; + } - return (s); + d ++; + } + else + { + if (*s == 'n') + *d ++ = '\n'; + else if (*s == 'r') + *d ++ = '\r'; + else if (*s == 't') + *d ++ = '\t'; + else + *d++ = *s; + + s ++; + } + } + else + *d++ = *s++; + } + + *d = '\0'; } // -// '_ppdMessageFree()' - Free a messages array. +// 'ppd_read_strings()' - Read a pair of strings from a .strings file. // -void -_ppdMessageFree(cups_array_t *a) // I - Message array +static int // O - 1 on success, 0 on failure +ppd_read_strings(cups_file_t *fp, // I - .strings file + int flags, // I - CUPS_MESSAGE_xxx flags + cups_array_t *a) // I - Message catalog array { -#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR) - // - // Release the cups.strings dictionary as needed... - // + char buffer[8192], // Line buffer + *bufptr, // Pointer into buffer + *msg, // Pointer to start of message + *str; // Pointer to start of translation string + _ppd_message_t *m; // New message - if (cupsArrayUserData(a)) - CFRelease((CFDictionaryRef)cupsArrayUserData(a)); -#endif // __APPLE__ && CUPS_BUNDLEDIR + + while (cupsFileGets(fp, buffer, sizeof(buffer))) + { + // + // Skip any line (comments, blanks, etc.) that isn't: + // + // "message" = "translation"; + // + + for (bufptr = buffer; *bufptr && isspace(*bufptr & 255); bufptr ++); + + if (*bufptr != '\"') + continue; + + // + // Find the end of the message... + // + + bufptr ++; + for (msg = bufptr; *bufptr && *bufptr != '\"'; bufptr ++) + if (*bufptr == '\\' && bufptr[1]) + bufptr ++; + + if (!*bufptr) + continue; + + *bufptr++ = '\0'; + + if (flags & _PPD_MESSAGE_UNQUOTE) + ppd_unquote(msg, msg); + + // + // Find the start of the translation... + // + + while (*bufptr && isspace(*bufptr & 255)) + bufptr ++; + + if (*bufptr != '=') + continue; + + bufptr ++; + while (*bufptr && isspace(*bufptr & 255)) + bufptr ++; + + if (*bufptr != '\"') + continue; + + // + // Find the end of the translation... + // + + bufptr ++; + for (str = bufptr; *bufptr && *bufptr != '\"'; bufptr ++) + if (*bufptr == '\\' && bufptr[1]) + bufptr ++; + + if (!*bufptr) + continue; + + *bufptr++ = '\0'; + + if (flags & _PPD_MESSAGE_UNQUOTE) + ppd_unquote(str, str); + + // + // If we get this far we have a valid pair of strings, add them... + // + + if ((m = malloc(sizeof(_ppd_message_t))) == NULL) + break; + + m->msg = strdup(msg); + m->str = strdup(str); + + if (m->msg && m->str) + cupsArrayAdd(a, m); + else + { + if (m->msg) + free(m->msg); + + if (m->str) + free(m->str); + + free(m); + break; + } + + return (1); + } // - // Free the array... + // No more strings... // - cupsArrayDelete(a); + return (0); } // -// '_ppdMessageLoad()' - Load a .po or .strings file into a messages array. +// 'ppd_message_file_load()' - Load a .po or .strings file into a messages +// array. // -cups_array_t * // O - New message array -_ppdMessageLoad(const char *filename, // I - Message catalog to load - int flags) // I - Load flags +static cups_array_t * // O - New message array +ppd_message_file_load(const char *filename, // I - Message catalog to load + int flags) // I - Load flags { cups_file_t *fp; // Message file cups_array_t *a; // Message array @@ -165,15 +283,18 @@ _ppdMessageLoad(const char *filename, // I - Message catalog to load ptrlen; // Length of string - DEBUG_printf(("4_ppdMessageLoad(filename=\"%s\")", filename)); + DEBUG_printf(("4ppd_message_file_load(filename=\"%s\")", filename)); // // Create an array to hold the messages... // - if ((a = _ppdMessageNew(NULL)) == NULL) + if ((a = cupsArrayNew3((cups_array_func_t)ppd_message_compare, NULL, + (cups_ahash_func_t)NULL, 0, + (cups_acopy_func_t)NULL, + (cups_afree_func_t)ppd_message_free)) == NULL) { - DEBUG_puts("5_ppdMessageLoad: Unable to allocate array!"); + DEBUG_puts("5ppd_message_file_load: Unable to allocate array!"); return (NULL); } @@ -183,7 +304,7 @@ _ppdMessageLoad(const char *filename, // I - Message catalog to load if ((fp = cupsFileOpen(filename, "r")) == NULL) { - DEBUG_printf(("5_ppdMessageLoad: Unable to open file: %s", + DEBUG_printf(("5ppd_message_file_load: Unable to open file: %s", strerror(errno))); return (a); } @@ -377,26 +498,26 @@ _ppdMessageLoad(const char *filename, // I - Message catalog to load cupsFileClose(fp); - DEBUG_printf(("5_ppdMessageLoad: Returning %d messages...", - cupsArrayCount(a))); + DEBUG_printf(("5ppd_message_file_load: Returning %d messages...", + cupsArrayGetCount(a))); return (a); } // -// '_ppdMessageLookup()' - Lookup a message string. +// 'ppd_message_lookup()' - Lookup a message string. // -const char * // O - Localized message -_ppdMessageLookup(cups_array_t *a, // I - Message array +static const char * // O - Localized message +ppd_message_lookup(cups_array_t *a, // I - Message array const char *m) // I - Message { _ppd_message_t key, // Search key *match; // Matching message - DEBUG_printf(("_ppdMessageLookup(a=%p, m=\"%s\")", (void *)a, m)); + DEBUG_printf(("ppd_message_lookup(a=%p, m=\"%s\")", (void *)a, m)); // // Lookup the message string; if it doesn't exist in the catalog, @@ -431,14 +552,14 @@ _ppdMessageLookup(cups_array_t *a, // I - Message array CFStringGetCString(cfstr, buffer, sizeof(buffer), kCFStringEncodingUTF8); match->str = strdup(buffer); - DEBUG_printf(("1_ppdMessageLookup: Found \"%s\" as \"%s\"...", + DEBUG_printf(("1ppd_message_lookup: Found \"%s\" as \"%s\"...", m, buffer)); } else { match->str = strdup(m); - DEBUG_printf(("1_ppdMessageLookup: Did not find \"%s\"...", m)); + DEBUG_printf(("1ppd_message_lookup: Did not find \"%s\"...", m)); } cupsArrayAdd(a, match); @@ -455,50 +576,6 @@ _ppdMessageLookup(cups_array_t *a, // I - Message array } -// -// '_ppdMessageNew()' - Make a new message catalog array. -// - -cups_array_t * // O - Array -_ppdMessageNew(void *context) // I - User data -{ - return (cupsArrayNew3((cups_array_func_t)ppd_message_compare, context, - (cups_ahash_func_t)NULL, 0, - (cups_acopy_func_t)NULL, - (cups_afree_func_t)ppd_message_free)); -} - - -// -// 'ppd_message_compare()' - Compare two messages. -// - -static int // O - Result of comparison -ppd_message_compare( - _ppd_message_t *m1, // I - First message - _ppd_message_t *m2) // I - Second message -{ - return (strcmp(m1->msg, m2->msg)); -} - - -// -// 'ppd_message_free()' - Free a message. -// - -static void -ppd_message_free(_ppd_message_t *m) // I - Message -{ - if (m->msg) - free(m->msg); - - if (m->str) - free(m->str); - - free(m); -} - - // // 'ppd_message_load()' - Load the message catalog for a language. // @@ -506,10 +583,6 @@ ppd_message_free(_ppd_message_t *m) // I - Message static void ppd_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 char localedir[1003];// Filename for language locale dir char *p; @@ -526,16 +599,16 @@ ppd_message_load(cups_lang_t *lang) // I - Language } snprintf(filename, sizeof(filename), "%s/%.5s/cups_%.5s.po", localedir, - lang->language, lang->language); + cupsLangGetName(lang), cupsLangGetName(lang)); - if (strchr(lang->language, '_') && access(filename, 0)) + if (strchr(cupsLangGetName(lang), '_') && access(filename, 0)) { // // Country localization not available, look for generic localization... // snprintf(filename, sizeof(filename), "%s/%.2s/cups_%.2s.po", localedir, - lang->language, lang->language); + cupsLangGetName(lang), cupsLangGetName(lang)); if (access(filename, 0)) { @@ -554,168 +627,65 @@ ppd_message_load(cups_lang_t *lang) // I - Language // Read the strings from the file... // - lang->strings = _ppdMessageLoad(filename, _PPD_MESSAGE_UNQUOTE); -#endif // __APPLE__ && CUPS_BUNDLEDIR + lang->strings = ppd_message_file_load(filename, _PPD_MESSAGE_UNQUOTE); } // -// 'ppd_read_strings()' - Read a pair of strings from a .strings file. +// libcups2 equivalents of libcups3 functions // -static int // O - 1 on success, 0 on failure -ppd_read_strings(cups_file_t *fp, // I - .strings file - int flags, // I - CUPS_MESSAGE_xxx flags - cups_array_t *a) // I - Message catalog array -{ - char buffer[8192], // Line buffer - *bufptr, // Pointer into buffer - *msg, // Pointer to start of message - *str; // Pointer to start of translation string - _ppd_message_t *m; // New message - - - while (cupsFileGets(fp, buffer, sizeof(buffer))) - { - // - // Skip any line (comments, blanks, etc.) that isn't: - // - // "message" = "translation"; - // - - for (bufptr = buffer; *bufptr && isspace(*bufptr & 255); bufptr ++); - - if (*bufptr != '\"') - continue; - - // - // Find the end of the message... - // - - bufptr ++; - for (msg = bufptr; *bufptr && *bufptr != '\"'; bufptr ++) - if (*bufptr == '\\' && bufptr[1]) - bufptr ++; - - if (!*bufptr) - continue; - - *bufptr++ = '\0'; - - if (flags & _PPD_MESSAGE_UNQUOTE) - ppd_unquote(msg, msg); - - // - // Find the start of the translation... - // - - while (*bufptr && isspace(*bufptr & 255)) - bufptr ++; - - if (*bufptr != '=') - continue; - - bufptr ++; - while (*bufptr && isspace(*bufptr & 255)) - bufptr ++; - - if (*bufptr != '\"') - continue; - - // - // Find the end of the translation... - // - - bufptr ++; - for (str = bufptr; *bufptr && *bufptr != '\"'; bufptr ++) - if (*bufptr == '\\' && bufptr[1]) - bufptr ++; - - if (!*bufptr) - continue; - - *bufptr++ = '\0'; +// +// 'cupsLangGetName()' - Get the language name. +// +// Replaces lang->language +// - if (flags & _PPD_MESSAGE_UNQUOTE) - ppd_unquote(str, str); +const char * // O - Language name +cupsLangGetName(cups_lang_t *lang) // I - Language data +{ + return (lang ? lang->language : NULL); +} - // - // If we get this far we have a valid pair of strings, add them... - // +// +// 'cupsLangGetString()' - Get a message string. +// +// The returned string is UTF-8 encoded; use cupsUTF8ToCharset() to +// convert the string to the language encoding. +// - if ((m = malloc(sizeof(_ppd_message_t))) == NULL) - break; +const char * // O - Localized message +cupsLangGetString(cups_lang_t *lang, // I - Language + const char *message) // I - Message +{ + const char *s; // Localized message - m->msg = strdup(msg); - m->str = strdup(str); - if (m->msg && m->str) - cupsArrayAdd(a, m); - else - { - if (m->msg) - free(m->msg); + DEBUG_printf(("cupsLangGetString(lang=%p, message=\"%s\")", + (void *)lang, message)); - if (m->str) - free(m->str); + // + // Range check input... + // - free(m); - break; - } + if (!lang || !message || !*message) + return (message); - return (1); - } + _ppdMutexLock(&lang_mutex); // - // No more strings... + // Load the message catalog if needed... // - return (0); -} - - -// -// 'ppd_unquote()' - Unquote characters in strings... -// + if (!lang->strings) + ppd_message_load(lang); -static void -ppd_unquote(char *d, // O - Unquoted string - const char *s) // I - Original string -{ - while (*s) - { - if (*s == '\\') - { - s ++; - if (isdigit(*s)) - { - *d = 0; + s = ppd_message_lookup(lang->strings, message); - while (isdigit(*s)) - { - *d = *d * 8 + *s - '0'; - s ++; - } + _ppdMutexUnlock(&lang_mutex); - d ++; - } - else - { - if (*s == 'n') - *d ++ = '\n'; - else if (*s == 'r') - *d ++ = '\r'; - else if (*s == 't') - *d ++ = '\t'; - else - *d++ = *s; + return (s); +} - s ++; - } - } - else - *d++ = *s++; - } - *d = '\0'; -} +#endif // HAVE_LIBCUPS2 diff --git a/ppd/pdftops.c b/ppd/pdftops.c index c88d9ad91..17faab0fd 100644 --- a/ppd/pdftops.c +++ b/ppd/pdftops.c @@ -34,8 +34,9 @@ #include #include #include -#include "ppd.h" -#include "ppd-filter.h" +#include +#include +#include #define MAX_CHECK_COMMENT_LINES 20 @@ -312,7 +313,7 @@ ppdFilterPDFToPS(int inputfd, // I - File descriptor input stream numvalues = 0; // Number of values actually read ppd_choice_t *choice; ppd_attr_t *attr; - cups_page_header2_t header; + cups_page_header_t header; cups_file_t *fp; // Post-processing input file int pdf_pid, // Process ID for pdftops/gs pdf_argc = 0, // Number of args for pdftops/gs @@ -369,7 +370,7 @@ ppdFilterPDFToPS(int inputfd, // I - File descriptor input stream // Copy input into temporary file ... // - if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0) + if ((fd = cupsCreateTempFd(NULL, NULL, tempfile, sizeof(tempfile))) < 0) { if (log) log(ld, CF_LOGLEVEL_ERROR, "ppdFilterPDFToPS: Unable to copy PDF file: %s", strerror(errno)); diff --git a/ppd/ppd-attr.c b/ppd/ppd-attr.c index 042304fcc..d1644b251 100644 --- a/ppd/ppd-attr.c +++ b/ppd/ppd-attr.c @@ -12,9 +12,10 @@ // Include necessary headers... // -#include "string-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include // @@ -64,7 +65,7 @@ ppdFindAttr(ppd_file_t *ppd, // I - PPD file data while (attr && _ppd_strcasecmp(spec, attr->spec)) { - if ((attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) != NULL && + if ((attr = (ppd_attr_t *)cupsArrayGetNext(ppd->sorted_attrs)) != NULL && _ppd_strcasecmp(attr->name, name)) attr = NULL; } @@ -101,7 +102,7 @@ ppdFindNextAttr(ppd_file_t *ppd, // I - PPD file data // See if there are more attributes to return... // - while ((attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) != NULL) + while ((attr = (ppd_attr_t *)cupsArrayGetNext(ppd->sorted_attrs)) != NULL) { // // Check the next attribute to see if it is a match... @@ -113,7 +114,7 @@ ppdFindNextAttr(ppd_file_t *ppd, // I - PPD file data // Nope, reset the current pointer to the end of the array... // - cupsArrayIndex(ppd->sorted_attrs, cupsArrayCount(ppd->sorted_attrs)); + cupsArrayGetElement(ppd->sorted_attrs, cupsArrayGetCount(ppd->sorted_attrs)); return (NULL); } diff --git a/ppd/ppd-cache.c b/ppd/ppd-cache.c index 5aa617c1c..93cf06e18 100644 --- a/ppd/ppd-cache.c +++ b/ppd/ppd-cache.c @@ -11,12 +11,12 @@ // Include necessary headers... // -#include "string-private.h" -#include "array-private.h" -#include "ipp-private.h" -#include "language-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include +#include +#include #include #include #include @@ -37,6 +37,24 @@ #define IPP_FINISHINGS_FOLD_ACCORDION IPP_FINISHINGS_FOLD_ACCORDIAN #endif +// +// Macro for localized text... +// + +# define _(x) x + + +// +// Types... +// + +typedef struct _ppd_ui_string_s // **** UI string list entry **** +{ + char *name, // Machine-readable option name/ + // PWG name + *ui_str; // Human-readable UI string +} _ppd_ui_string_t; + // // Local functions... @@ -44,11 +62,14 @@ static const char *ppd_inputslot_for_keyword(ppd_cache_t *pc, const char *keyword); +static void ppd_ui_string_add(cups_array_t *a, const char *msg, + const char *str); +static int ppd_ui_string_compare(_ppd_ui_string_t *m1, _ppd_ui_string_t *m2); +static void ppd_ui_string_free(_ppd_ui_string_t *m); +static cups_array_t *ppd_ui_strings_new(void *context); static void ppd_pwg_add_finishing(cups_array_t *finishings, ipp_finishings_t template, const char *name, const char *value); -static void ppd_pwg_add_message(cups_array_t *a, const char *msg, - const char *str); static int ppd_pwg_compare_finishings(ppd_pwg_finishings_t *a, ppd_pwg_finishings_t *b); static void ppd_pwg_free_finishings(ppd_pwg_finishings_t *f); @@ -86,7 +107,7 @@ set_error(const char *message, // I - status-message value // ppd_cache_status_message = - _ppdStrAlloc(_ppdLangString(cupsLangDefault(), + _ppdStrAlloc(cupsLangGetString(cupsLangDefault(), message)); } else @@ -208,8 +229,8 @@ ppdConvertOptions( "job-accounting-user-id", NULL, keyword); } - for (mandatory = (const char *)cupsArrayFirst(pc->mandatory); mandatory; - mandatory = (const char *)cupsArrayNext(pc->mandatory)) + for (mandatory = (const char *)cupsArrayGetFirst(pc->mandatory); mandatory; + mandatory = (const char *)cupsArrayGetNext(pc->mandatory)) { if (strcmp(mandatory, "copies") && strcmp(mandatory, "destination-uris") && @@ -715,18 +736,18 @@ ppdCacheCreateWithFile( else if (!_ppd_strcasecmp(line, "Filter")) { if (!pc->filters) - pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->filters = cupsArrayNew(NULL, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); cupsArrayAdd(pc->filters, value); } else if (!_ppd_strcasecmp(line, "PreFilter")) { if (!pc->prefilters) - pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->prefilters = cupsArrayNew(NULL, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); cupsArrayAdd(pc->prefilters, value); } @@ -765,7 +786,7 @@ ppdCacheCreateWithFile( *attrs = ippNew(); - if (ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, + if (ippReadIO(fp, (ipp_io_cb_t)cupsFileRead, 1, NULL, *attrs) != IPP_STATE_DATA) { DEBUG_puts("ppdCacheCreateWithFile: Bad IPP data."); @@ -1088,9 +1109,9 @@ ppdCacheCreateWithFile( { if (!pc->finishings) pc->finishings = - cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings, + cupsArrayNew((cups_array_cb_t)ppd_pwg_compare_finishings, NULL, NULL, 0, NULL, - (cups_afree_func_t)ppd_pwg_free_finishings); + (cups_afree_cb_t)ppd_pwg_free_finishings); if ((finishings = calloc(1, sizeof(ppd_pwg_finishings_t))) == NULL) goto create_error; @@ -1104,9 +1125,9 @@ ppdCacheCreateWithFile( else if (!_ppd_strcasecmp(line, "FinishingTemplate")) { if (!pc->templates) - pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->templates = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); cupsArrayAdd(pc->templates, value); } @@ -1130,9 +1151,9 @@ ppdCacheCreateWithFile( else if (!_ppd_strcasecmp(line, "SupportFile")) { if (!pc->support_files) - pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->support_files = cupsArrayNew(NULL, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); cupsArrayAdd(pc->support_files, value); } @@ -1240,7 +1261,7 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file pwg_size_t *new_size; // New size to add, if any const char *filter; // Current filter ppd_pwg_finishings_t *finishings; // Current finishings value - char msg_id[256]; // Message identifier + char id[256]; // UI string Identifier DEBUG_printf(("ppdCacheCreateWithPPD(ppd=%p)", ppd)); @@ -1262,7 +1283,7 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file goto create_error; } - pc->strings = _ppdMessageNew(NULL); + pc->strings = ppd_ui_strings_new(NULL); // // Copy and convert size data... @@ -1535,8 +1556,8 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Add localized text for PWG keyword to message catalog... // - snprintf(msg_id, sizeof(msg_id), "media-source.%s", pwg_name); - ppd_pwg_add_message(pc->strings, msg_id, choice->text); + snprintf(id, sizeof(id), "media-source.%s", pwg_name); + ppd_ui_string_add(pc->strings, id, choice->text); } } @@ -1658,8 +1679,8 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Add localized text for PWG keyword to message catalog... // - snprintf(msg_id, sizeof(msg_id), "media-type.%s", map->pwg); - ppd_pwg_add_message(pc->strings, msg_id, choice->text); + snprintf(id, sizeof(id), "media-type.%s", map->pwg); + ppd_ui_string_add(pc->strings, id, choice->text); } } @@ -1693,8 +1714,8 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Add localized text for PWG keyword to message catalog... // - snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_keyword); - ppd_pwg_add_message(pc->strings, msg_id, choice->text); + snprintf(id, sizeof(id), "output-bin.%s", pwg_keyword); + ppd_ui_string_add(pc->strings, id, choice->text); } } @@ -1723,8 +1744,8 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Add localized text for PWG keyword to message catalog... // - snprintf(msg_id, sizeof(msg_id), "preset-name.%s", ppd_attr->spec); - ppd_pwg_add_message(pc->strings, msg_id, ppd_attr->text); + snprintf(id, sizeof(id), "preset-name.%s", ppd_attr->spec); + ppd_ui_string_add(pc->strings, id, ppd_attr->text); // // Get the options for this preset... @@ -1974,8 +1995,8 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Copy filters and pre-filters... // - pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->filters = cupsArrayNew(NULL, NULL, NULL, 0, (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); cupsArrayAdd(pc->filters, "application/vnd.cups-raw application/octet-stream 0 -"); @@ -2000,9 +2021,9 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // See if we have a command filter... // - for (filter = (const char *)cupsArrayFirst(pc->filters); + for (filter = (const char *)cupsArrayGetFirst(pc->filters); filter; - filter = (const char *)cupsArrayNext(pc->filters)) + filter = (const char *)cupsArrayGetNext(pc->filters)) if (!_ppd_strncasecmp(filter, "application/vnd.cups-command", 28) && _ppd_isspace(filter[28])) break; @@ -2017,9 +2038,9 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // filter... // - for (filter = (const char *)cupsArrayFirst(pc->filters); + for (filter = (const char *)cupsArrayGetFirst(pc->filters); filter; - filter = (const char *)cupsArrayNext(pc->filters)) + filter = (const char *)cupsArrayGetNext(pc->filters)) if (!_ppd_strncasecmp(filter, "application/vnd.cups-postscript", 31) && _ppd_isspace(filter[31])) break; @@ -2032,9 +2053,9 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file if ((ppd_attr = ppdFindAttr(ppd, "cupsPreFilter", NULL)) != NULL) { - pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->prefilters = cupsArrayNew(NULL, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); do cupsArrayAdd(pc->prefilters, ppd_attr->value); @@ -2062,9 +2083,9 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // pc->finishings = - cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings, + cupsArrayNew((cups_array_cb_t)ppd_pwg_compare_finishings, NULL, NULL, 0, NULL, - (cups_afree_func_t)ppd_pwg_free_finishings); + (cups_afree_cb_t)ppd_pwg_free_finishings); do { @@ -2088,9 +2109,9 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // pc->finishings = - cupsArrayNew3((cups_array_func_t)ppd_pwg_compare_finishings, + cupsArrayNew((cups_array_cb_t)ppd_pwg_compare_finishings, NULL, NULL, 0, NULL, - (cups_afree_func_t)ppd_pwg_free_finishings); + (cups_afree_cb_t)ppd_pwg_free_finishings); if ((ppd_option = ppdFindOption(ppd, "StapleLocation")) != NULL) { @@ -2217,7 +2238,7 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file "RIFoldType", "OutsideTwoFold"); } - if (cupsArrayCount(pc->finishings) == 0) + if (cupsArrayGetCount(pc->finishings) == 0) { cupsArrayDelete(pc->finishings); pc->finishings = NULL; @@ -2226,10 +2247,10 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file if ((ppd_option = ppdFindOption(ppd, "cupsFinishingTemplate")) != NULL) { - pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, + pc->templates = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); for (choice = ppd_option->choices, i = ppd_option->num_choices; i > 0; choice ++, i --) @@ -2240,8 +2261,8 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Add localized text for PWG keyword to message catalog... // - snprintf(msg_id, sizeof(msg_id), "finishing-template.%s", choice->choice); - ppd_pwg_add_message(pc->strings, msg_id, choice->text); + snprintf(id, sizeof(id), "finishing-template.%s", choice->choice); + ppd_ui_string_add(pc->strings, id, choice->text); } } @@ -2280,9 +2301,9 @@ ppdCacheCreateWithPPD(ppd_file_t *ppd) // I - PPD file // Support files... // - pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free); + pc->support_files = cupsArrayNew(NULL, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free); for (ppd_attr = ppdFindAttr(ppd, "cupsICCProfile", NULL); ppd_attr; @@ -2349,7 +2370,7 @@ ppdCacheAssignPresets(ppd_file_t *ppd, int is_color; unsigned int base_res_x = 0, base_res_y = 0; - cups_page_header2_t header, + cups_page_header_t header, optheader; int preferred_bits; ppd_attr_t *ppd_attr; @@ -2476,7 +2497,7 @@ ppdCacheAssignPresets(ppd_file_t *ppd, } // Array for properties of the choices - choice_properties = cupsArrayNew(NULL, NULL); + choice_properties = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); // // Gather the data for each choice @@ -2898,7 +2919,7 @@ ppdCacheAssignPresets(ppd_file_t *ppd, { for (k = 0; k < option->num_choices; k ++) { - properties = cupsArrayIndex(choice_properties, k); + properties = cupsArrayGetElement(choice_properties, k); // presets[0][0]: Mono/Draft if (best_mono_draft >= 0 && @@ -3007,7 +3028,7 @@ ppdCacheAssignPresets(ppd_file_t *ppd, for (k = 0; k < option->num_choices; k ++) { - properties = cupsArrayIndex(choice_properties, k); + properties = cupsArrayGetElement(choice_properties, k); c = option->choices[k].choice; // Vendor-specific options @@ -3290,7 +3311,7 @@ ppdCacheAssignPresets(ppd_file_t *ppd, } for (k = 0; k < option->num_choices; k ++) - free(cupsArrayIndex(choice_properties, k)); + free(cupsArrayGetElement(choice_properties, k)); cupsArrayDelete(choice_properties); } } @@ -3456,7 +3477,7 @@ ppdCacheGetFinishingOptions( // Range check input... // - if (!pc || cupsArrayCount(pc->finishings) == 0 || !options || + if (!pc || cupsArrayGetCount(pc->finishings) == 0 || !options || (!job && value == IPP_FINISHINGS_NONE)) return (num_options); @@ -3541,9 +3562,9 @@ ppdCacheGetFinishingValues( // Go through the finishings options and see what is set... // - for (f = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings); + for (f = (ppd_pwg_finishings_t *)cupsArrayGetFirst(pc->finishings); f; - f = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings)) + f = (ppd_pwg_finishings_t *)cupsArrayGetNext(pc->finishings)) { DEBUG_printf(("ppdCacheGetFinishingValues: Checking %d (%s)", (int)f->value, ippEnumString("finishings", (int)f->value))); @@ -3640,7 +3661,7 @@ ppdCacheGetInputSlot( ipp_attribute_t *media_col, // media-col attribute *media_source; // media-source attribute pwg_size_t size; // Dimensional size - int margins_set; // Were the margins set? + cups_bool_t margins_set; // Were the margins set? media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION); if (media_col && @@ -3779,8 +3800,8 @@ ppdCacheGetPageSize( *variant, // Page size variant *closest, // Closest size jobsize; // Size data from job - int margins_set, // Were the margins set? - dwidth, // Difference in width + cups_bool_t margins_set; // Were the margins set? + int dwidth, // Difference in width dlength, // Difference in length dleft, // Difference in left margins dright, // Difference in right margins @@ -4381,14 +4402,14 @@ ppdCacheWriteFile( if (pc->product) cupsFilePutConf(fp, "Product", pc->product); - for (value = (const char *)cupsArrayFirst(pc->filters); + for (value = (const char *)cupsArrayGetFirst(pc->filters); value; - value = (const char *)cupsArrayNext(pc->filters)) + value = (const char *)cupsArrayGetNext(pc->filters)) cupsFilePutConf(fp, "Filter", value); - for (value = (const char *)cupsArrayFirst(pc->prefilters); + for (value = (const char *)cupsArrayGetFirst(pc->prefilters); value; - value = (const char *)cupsArrayNext(pc->prefilters)) + value = (const char *)cupsArrayGetNext(pc->prefilters)) cupsFilePutConf(fp, "PreFilter", value); cupsFilePrintf(fp, "SingleFile %s\n", pc->single_file ? "true" : "false"); @@ -4397,9 +4418,9 @@ ppdCacheWriteFile( // Finishing options... // - for (f = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings); + for (f = (ppd_pwg_finishings_t *)cupsArrayGetFirst(pc->finishings); f; - f = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings)) + f = (ppd_pwg_finishings_t *)cupsArrayGetNext(pc->finishings)) { cupsFilePrintf(fp, "Finishings %d", f->value); for (i = f->num_options, option = f->options; i > 0; i --, option ++) @@ -4407,7 +4428,7 @@ ppdCacheWriteFile( cupsFilePutChar(fp, '\n'); } - for (value = (const char *)cupsArrayFirst(pc->templates); value; value = (const char *)cupsArrayNext(pc->templates)) + for (value = (const char *)cupsArrayGetFirst(pc->templates); value; value = (const char *)cupsArrayGetNext(pc->templates)) cupsFilePutConf(fp, "FinishingTemplate", value); // @@ -4430,18 +4451,18 @@ ppdCacheWriteFile( if (pc->password) cupsFilePutConf(fp, "JobPassword", pc->password); - for (value = (char *)cupsArrayFirst(pc->mandatory); + for (value = (char *)cupsArrayGetFirst(pc->mandatory); value; - value = (char *)cupsArrayNext(pc->mandatory)) + value = (char *)cupsArrayGetNext(pc->mandatory)) cupsFilePutConf(fp, "Mandatory", value); // // Support files... // - for (value = (char *)cupsArrayFirst(pc->support_files); + for (value = (char *)cupsArrayGetFirst(pc->support_files); value; - value = (char *)cupsArrayNext(pc->support_files)) + value = (char *)cupsArrayGetNext(pc->support_files)) cupsFilePutConf(fp, "SupportFile", value); // @@ -4450,10 +4471,10 @@ ppdCacheWriteFile( if (attrs) { - cupsFilePrintf(fp, "IPP " CUPS_LLFMT "\n", CUPS_LLCAST ippLength(attrs)); + cupsFilePrintf(fp, "IPP " CUPS_LLFMT "\n", CUPS_LLCAST ippGetLength(attrs)); ippSetState(attrs, IPP_STATE_IDLE); - ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL, attrs); + ippWriteIO(fp, (ipp_io_cb_t)cupsFileWrite, 1, NULL, attrs); } // @@ -4626,6 +4647,71 @@ ppdPwgPageSizeForMedia( } +// +// 'ppd_ui_string_add()' - Add an entry to the PPD-cached UI strings list. +// + +static void +ppd_ui_string_add(cups_array_t *l, // I - UI string list + const char *name, // I - Machine-readable name + const char *ui_str) // I - UI string +{ + _ppd_ui_string_t *u; // New entry + + + if ((u = calloc(1, sizeof(_ppd_ui_string_t))) != NULL) + { + u->name = strdup(name); + u->ui_str = strdup(ui_str); + cupsArrayAdd(l, u); + } +} + + +// +// 'ppd_ui_string_compare()' - Compare two messages. +// + +static int // O - Result of comparison +ppd_ui_string_compare( + _ppd_ui_string_t *u1, // I - First UI-string entry + _ppd_ui_string_t *u2) // I - Second UI-string entry +{ + return (strcmp(u1->name, u2->name)); +} + + +// +// 'ppd_ui_string_free()' - Free a message. +// + +static void +ppd_ui_string_free(_ppd_ui_string_t *u) // I - UI-string entry +{ + if (u->name) + free(u->name); + + if (u->ui_str) + free(u->ui_str); + + free(u); +} + + +// +// 'ppd_ui_strings_new()' - Make a new message catalog array. +// + +static cups_array_t * // O - Array +ppd_ui_strings_new(void *context) // I - User data +{ + return (cupsArrayNew((cups_array_cb_t )ppd_ui_string_compare, context, + (cups_ahash_cb_t)NULL, 0, + (cups_acopy_cb_t)NULL, + (cups_afree_cb_t)ppd_ui_string_free)); +} + + // // 'ppd_pwg_add_finishing()' - Add a finishings value. // @@ -4651,27 +4737,6 @@ ppd_pwg_add_finishing( } -// -// 'ppd_pwg_add_message()' - Add a message to the PPD cached strings. -// - -static void -ppd_pwg_add_message(cups_array_t *a, // I - Message catalog - const char *msg, // I - Message identifier - const char *str) // I - Localized string -{ - _ppd_message_t *m; // New message - - - if ((m = calloc(1, sizeof(_ppd_message_t))) != NULL) - { - m->msg = strdup(msg); - m->str = strdup(str); - cupsArrayAdd(a, m); - } -} - - // // 'ppd_pwg_compare_finishings()' - Compare two finishings values. // diff --git a/ppd/ppd-collection.cxx b/ppd/ppd-collection.cxx index 27a0b0118..d9f7119c3 100644 --- a/ppd/ppd-collection.cxx +++ b/ppd/ppd-collection.cxx @@ -18,10 +18,11 @@ #include #include -#include "ppd.h" -#include "ppdc.h" -#include "file-private.h" -#include "array-private.h" +#include +#include +#include +#include +#include #include #include @@ -86,7 +87,7 @@ typedef struct int ChangedPPD; // Did we change the PPD database? } ppd_list_t; -//typedef int (*cupsd_compare_func_t)(const void *, const void *); +//typedef int (*cupsd_compare_cb_t)(const void *, const void *); // @@ -226,10 +227,10 @@ ppdCollectionListPPDs( // Initialize PPD list... // - ppdlist.PPDsByName = cupsArrayNew((cups_array_func_t)compare_names, - NULL); - ppdlist.PPDsByMakeModel = cupsArrayNew((cups_array_func_t)compare_ppds, - NULL); + ppdlist.PPDsByName = cupsArrayNew((cups_array_cb_t)compare_names, + NULL, NULL, 0, NULL, NULL); + ppdlist.PPDsByMakeModel = cupsArrayNew((cups_array_cb_t)compare_ppds, + NULL, NULL, 0, NULL, NULL); ppdlist.ChangedPPD = 0; @@ -249,11 +250,11 @@ ppdCollectionListPPDs( // Load all PPDs in the specified directories and below... // - ppdlist.Inodes = cupsArrayNew((cups_array_func_t)compare_inodes, NULL); + ppdlist.Inodes = cupsArrayNew((cups_array_cb_t)compare_inodes, NULL, NULL, 0, NULL, NULL); - for (col = (ppd_collection_t *)cupsArrayFirst(ppd_collections); + for (col = (ppd_collection_t *)cupsArrayGetFirst(ppd_collections); col; - col = (ppd_collection_t *)cupsArrayNext(ppd_collections)) + col = (ppd_collection_t *)cupsArrayGetNext(ppd_collections)) load_ppds(col->path, col->name ? col->name : col->path, 1, &ppdlist, log, ld); @@ -263,9 +264,9 @@ ppdCollectionListPPDs( // Cull PPD files that are no longer present... // - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByName), i = 0; + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByName), i = 0; ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByName), i ++) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByName), i ++) if (!ppd->found) { // @@ -299,9 +300,9 @@ ppdCollectionListPPDs( cupsFileWrite(fp, (char *)&ppdsync, sizeof(ppdsync)); - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByName); + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByName); ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByName)) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByName)) cupsFileWrite(fp, (char *)&(ppd->record), sizeof(ppd_rec_t)); cupsFileClose(fp); @@ -315,7 +316,7 @@ ppdCollectionListPPDs( else if (log) log(ld, CF_LOGLEVEL_INFO, "libppd: [PPD Collections] Wrote \"%s\", %d PPDs...", - cachename, cupsArrayCount(ppdlist.PPDsByName)); + cachename, cupsArrayGetCount(ppdlist.PPDsByName)); } else if (log) log(ld, CF_LOGLEVEL_ERROR, @@ -389,15 +390,15 @@ ppdCollectionListPPDs( "libppd: [PPD Collections] %s=\"%s\"", options[i].name, options[i].value); - if (limit <= 0 || limit > cupsArrayCount(ppdlist.PPDsByMakeModel)) - count = cupsArrayCount(ppdlist.PPDsByMakeModel); + if (limit <= 0 || limit > (int)cupsArrayGetCount(ppdlist.PPDsByMakeModel)) + count = cupsArrayGetCount(ppdlist.PPDsByMakeModel); else count = limit; if (device_id || language || make || make_and_model || model_number_str || product) { - matches = cupsArrayNew((cups_array_func_t)compare_matches, NULL); + matches = cupsArrayNew((cups_array_cb_t)compare_matches, NULL, NULL, 0, NULL, NULL); matches_array_created = 1; if (device_id) @@ -410,9 +411,9 @@ ppdCollectionListPPDs( else make_and_model_re = NULL; - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByMakeModel); + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByMakeModel); ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByMakeModel)) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByMakeModel)) { // // Filter PPDs based on make, model, product, language, model number, @@ -531,12 +532,12 @@ ppdCollectionListPPDs( } else if (include || exclude) { - matches = cupsArrayNew((cups_array_func_t)compare_ppds, NULL); + matches = cupsArrayNew((cups_array_cb_t)compare_ppds, NULL, NULL, 0, NULL, NULL); matches_array_created = 1; - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByMakeModel); + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByMakeModel); ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByMakeModel)) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByMakeModel)) { // // Filter PPDs based on the include/exclude lists. @@ -556,11 +557,11 @@ ppdCollectionListPPDs( else matches = ppdlist.PPDsByMakeModel; - result = cupsArrayNew(NULL, NULL); + result = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByMakeModel), i = 0; + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByMakeModel), i = 0; count > 0 && ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByMakeModel), i ++) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByMakeModel), i ++) { // // Skip invalid PPDs... @@ -600,13 +601,13 @@ ppdCollectionListPPDs( for (this_make = ppd->record.make, - ppd = (ppd_info_t *)cupsArrayNext(matches); + ppd = (ppd_info_t *)cupsArrayGetNext(matches); ppd; - ppd = (ppd_info_t *)cupsArrayNext(matches)) + ppd = (ppd_info_t *)cupsArrayGetNext(matches)) if (_ppd_strcasecmp(this_make, ppd->record.make)) break; - cupsArrayPrev(matches); + cupsArrayGetPrev(matches); } } @@ -664,9 +665,9 @@ ppdCollectionGetPPD( if (ppd_collections) { - for (col = (ppd_collection_t *)cupsArrayFirst(ppd_collections); + for (col = (ppd_collection_t *)cupsArrayGetFirst(ppd_collections); col; - col = (ppd_collection_t *)cupsArrayNext(ppd_collections)) + col = (ppd_collection_t *)cupsArrayGetNext(ppd_collections)) { if (col->name) { @@ -773,7 +774,7 @@ ppdCollectionGetPPD( if ((fp = PipeCommand(&cpid, &epid, realname, argv, 0, log, ld)) != NULL) { - if ((fd = cupsTempFd(tempname, sizeof(tempname))) < 0) + if ((fd = cupsCreateTempFd(NULL, NULL, tempname, sizeof(tempname))) < 0) { if (log) log(ld, CF_LOGLEVEL_ERROR, "libppd: [PPD Collections] Unable to copy PPD to temp " @@ -824,10 +825,10 @@ ppdCollectionDumpCache(const char *filename, // I - Filename // ppdlist.Inodes = NULL; - ppdlist.PPDsByName = cupsArrayNew((cups_array_func_t)compare_names, - NULL); - ppdlist.PPDsByMakeModel = cupsArrayNew((cups_array_func_t)compare_ppds, - NULL); + ppdlist.PPDsByName = cupsArrayNew((cups_array_cb_t)compare_names, + NULL, NULL, 0, NULL, NULL); + ppdlist.PPDsByMakeModel = cupsArrayNew((cups_array_cb_t)compare_ppds, + NULL, NULL, 0, NULL, NULL); ppdlist.ChangedPPD = 0; @@ -843,9 +844,9 @@ ppdCollectionDumpCache(const char *filename, // I - Filename puts("mtime,size,model_number,type,filename,name,languages0,products0," "psversions0,make,make_and_model,device_id,scheme"); - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist.PPDsByName); + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist.PPDsByName); ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist.PPDsByName)) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist.PPDsByName)) printf("%d,%ld,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"," "\"%s\",\"%s\"\n", (int)ppd->record.mtime, (long)ppd->record.size, @@ -894,7 +895,7 @@ add_ppd(const char *filename, // I - PPD filename if (log) log(ld, CF_LOGLEVEL_ERROR, "libppd: [PPD Collections] Ran out of memory for %d PPD " "files!", - cupsArrayCount(ppdlist->PPDsByName)); + cupsArrayGetCount(ppdlist->PPDsByName)); return (NULL); } @@ -985,7 +986,7 @@ cat_drv(const char *filename, // I - *.drv file name ppdcCatalog *catalog; // Message catalog in .drv file - if ((fd = cupsTempFd(tempname, sizeof(tempname))) < 0) + if ((fd = cupsCreateTempFd(NULL, NULL, tempname, sizeof(tempname))) < 0) { if (log) log(ld, CF_LOGLEVEL_ERROR, "libppd: [PPD Collections] Unable to copy PPD to temp " @@ -1104,7 +1105,7 @@ cat_tar(const char *filename, // I - Archive name if (!strcmp(ppdname, curname)) { - if ((fd = cupsTempFd(tempname, sizeof(tempname))) < 0) + if ((fd = cupsCreateTempFd(NULL, NULL, tempname, sizeof(tempname))) < 0) { if (log) log(ld, CF_LOGLEVEL_ERROR, "libppd: [PPD Collections] Unable to copy PPD to temp " @@ -1252,9 +1253,9 @@ free_array(cups_array_t *a) // I - Array to free char *ptr; // Pointer to string - for (ptr = (char *)cupsArrayFirst(a); + for (ptr = (char *)cupsArrayGetFirst(a); ptr; - ptr = (char *)cupsArrayNext(a)) + ptr = (char *)cupsArrayGetNext(a)) free(ptr); cupsArrayDelete(a); @@ -1272,15 +1273,15 @@ free_ppdlist(ppd_list_t *ppdlist) // I - PPD list to free ppd_info_t *ppd; // Pointer to PPD info - for (dinfoptr = (struct stat *)cupsArrayFirst(ppdlist->Inodes); + for (dinfoptr = (struct stat *)cupsArrayGetFirst(ppdlist->Inodes); dinfoptr; - dinfoptr = (struct stat *)cupsArrayNext(ppdlist->Inodes)) + dinfoptr = (struct stat *)cupsArrayGetNext(ppdlist->Inodes)) free(dinfoptr); cupsArrayDelete(ppdlist->Inodes); - for (ppd = (ppd_info_t *)cupsArrayFirst(ppdlist->PPDsByName); + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppdlist->PPDsByName); ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppdlist->PPDsByName)) + ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist->PPDsByName)) free(ppd); cupsArrayDelete(ppdlist->PPDsByName); cupsArrayDelete(ppdlist->PPDsByMakeModel); @@ -1677,9 +1678,9 @@ load_ppd(const char *filename, // I - Real filename // Now read until we get the required fields... // - cups_languages = cupsArrayNew(NULL, NULL); - products = cupsArrayNew(NULL, NULL); - psversions = cupsArrayNew(NULL, NULL); + cups_languages = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); + products = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); + psversions = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); model_name[0] = '\0'; nick_name[0] = '\0'; @@ -1798,7 +1799,7 @@ load_ppd(const char *filename, // I - Real filename // if (!install_group && (model_name[0] || nick_name[0]) && - cupsArrayCount(products) > 0 && cupsArrayCount(psversions) > 0) + cupsArrayGetCount(products) > 0 && cupsArrayGetCount(psversions) > 0) break; } } @@ -1816,8 +1817,8 @@ load_ppd(const char *filename, // I - Real filename while (isspace(make_model[0] & 255)) _ppd_strcpy(make_model, make_model + 1); - if (!make_model[0] || cupsArrayCount(products) == 0 || - cupsArrayCount(psversions) == 0) + if (!make_model[0] || cupsArrayGetCount(products) == 0 || + cupsArrayGetCount(psversions) == 0) { // // We don't have all the info needed, so skip this file... @@ -1829,12 +1830,12 @@ load_ppd(const char *filename, // I - Real filename "in %s!", filename); - if (cupsArrayCount(products) == 0) + if (cupsArrayGetCount(products) == 0) if (log) log(ld, CF_LOGLEVEL_WARN, "libppd: [PPD Collections] Missing Product in %s!", filename); - if (cupsArrayCount(psversions) == 0) + if (cupsArrayGetCount(psversions) == 0) if (log) log(ld, CF_LOGLEVEL_WARN, "libppd: [PPD Collections] Missing PSVersion in %s!", filename); @@ -1960,8 +1961,8 @@ load_ppd(const char *filename, // I - Real filename "libppd: [PPD Collections] Adding PPD \"%s\"...", name); ppd = add_ppd(filename, name, lang_version, manufacturer, make_model, - device_id, (char *)cupsArrayFirst(products), - (char *)cupsArrayFirst(psversions), fileinfo->st_mtime, + device_id, (char *)cupsArrayGetFirst(products), + (char *)cupsArrayGetFirst(psversions), fileinfo->st_mtime, (size_t)fileinfo->st_size, model_number, type, scheme, ppdlist, log, ld); @@ -1989,9 +1990,9 @@ load_ppd(const char *filename, // I - Real filename strlcpy(ppd->record.name, name, sizeof(ppd->record.name)); strlcpy(ppd->record.languages[0], lang_version, sizeof(ppd->record.languages[0])); - strlcpy(ppd->record.products[0], (char *)cupsArrayFirst(products), + strlcpy(ppd->record.products[0], (char *)cupsArrayGetFirst(products), sizeof(ppd->record.products[0])); - strlcpy(ppd->record.psversions[0], (char *)cupsArrayFirst(psversions), + strlcpy(ppd->record.psversions[0], (char *)cupsArrayGetFirst(psversions), sizeof(ppd->record.psversions[0])); strlcpy(ppd->record.make, manufacturer, sizeof(ppd->record.make)); strlcpy(ppd->record.make_and_model, make_model, @@ -2005,20 +2006,20 @@ load_ppd(const char *filename, // I - Real filename // for (i = 1; - i < PPD_MAX_PROD && (ptr = (char *)cupsArrayNext(products)) != NULL; + i < PPD_MAX_PROD && (ptr = (char *)cupsArrayGetNext(products)) != NULL; i ++) strlcpy(ppd->record.products[i], ptr, sizeof(ppd->record.products[0])); for (i = 1; - i < PPD_MAX_VERS && (ptr = (char *)cupsArrayNext(psversions)) != NULL; + i < PPD_MAX_VERS && (ptr = (char *)cupsArrayGetNext(psversions)) != NULL; i ++) strlcpy(ppd->record.psversions[i], ptr, sizeof(ppd->record.psversions[0])); - for (i = 1, ptr = (char *)cupsArrayFirst(cups_languages); + for (i = 1, ptr = (char *)cupsArrayGetFirst(cups_languages); i < PPD_MAX_LANG && ptr; - i ++, ptr = (char *)cupsArrayNext(cups_languages)) + i ++, ptr = (char *)cupsArrayGetNext(cups_languages)) strlcpy(ppd->record.languages[i], ptr, sizeof(ppd->record.languages[0])); @@ -2180,14 +2181,14 @@ load_ppds(const char *d, // I - Actual directory // Rewind to the first entry for this file... // - while ((ppd = (ppd_info_t *)cupsArrayPrev(ppdlist->PPDsByName)) != NULL && + while ((ppd = (ppd_info_t *)cupsArrayGetPrev(ppdlist->PPDsByName)) != NULL && !strcmp(ppd->record.filename, filename)); // // Then mark all of the matches for this file as found... // - while ((ppd = (ppd_info_t *)cupsArrayNext(ppdlist->PPDsByName)) != NULL && + while ((ppd = (ppd_info_t *)cupsArrayGetNext(ppdlist->PPDsByName)) != NULL && !strcmp(ppd->record.filename, filename)) ppd->found = 1; @@ -2322,7 +2323,7 @@ load_ppds_dat(const char *filename, // I - Filename if (verbose) if (log) log(ld, CF_LOGLEVEL_INFO, "libppd: [PPD Collections] Read \"%s\", %d PPDs...", - filename, cupsArrayCount(ppdlist->PPDsByName)); + filename, cupsArrayGetCount(ppdlist->PPDsByName)); } cupsFileClose(fp); diff --git a/ppd/ppd-conflicts.c b/ppd/ppd-conflicts.c index 237fd487b..36822407b 100644 --- a/ppd/ppd-conflicts.c +++ b/ppd/ppd-conflicts.c @@ -14,9 +14,10 @@ // Include necessary headers... // -#include "string-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include // @@ -97,9 +98,9 @@ ppdGetConflicts( // Loop through all of the UI constraints and add any options that conflict... // - for (num_options = 0, c = (ppd_cups_uiconsts_t *)cupsArrayFirst(active); + for (num_options = 0, c = (ppd_cups_uiconsts_t *)cupsArrayGetFirst(active); c; - c = (ppd_cups_uiconsts_t *)cupsArrayNext(active)) + c = (ppd_cups_uiconsts_t *)cupsArrayGetNext(active)) { for (i = c->num_constraints, cptr = c->constraints; i > 0; @@ -221,7 +222,7 @@ ppdResolveConflicts( cupsArraySave(ppd->sorted_attrs); resolvers = NULL; - pass = cupsArrayNew((cups_array_func_t)_ppd_strcasecmp, NULL); + pass = cupsArrayNew((cups_array_cb_t)_ppd_strcasecmp, NULL, NULL, 0, NULL, NULL); tries = 0; while (tries < 100 && @@ -231,11 +232,11 @@ ppdResolveConflicts( tries ++; if (!resolvers) - resolvers = cupsArrayNew((cups_array_func_t)_ppd_strcasecmp, NULL); + resolvers = cupsArrayNew((cups_array_cb_t)_ppd_strcasecmp, NULL, NULL, 0, NULL, NULL); - for (consts = (ppd_cups_uiconsts_t *)cupsArrayFirst(active), changed = 0; + for (consts = (ppd_cups_uiconsts_t *)cupsArrayGetFirst(active), changed = 0; consts; - consts = (ppd_cups_uiconsts_t *)cupsArrayNext(active)) + consts = (ppd_cups_uiconsts_t *)cupsArrayGetNext(active)) { if (consts->resolver[0]) { @@ -599,16 +600,16 @@ ppdConflicts(ppd_file_t *ppd) // I - PPD to check active = ppd_test_constraints(ppd, NULL, NULL, 0, NULL, _PPD_ALL_CONSTRAINTS); - conflicts = cupsArrayCount(active); + conflicts = cupsArrayGetCount(active); // // Loop through all of the UI constraints and flag any options // that conflict... // - for (c = (ppd_cups_uiconsts_t *)cupsArrayFirst(active); + for (c = (ppd_cups_uiconsts_t *)cupsArrayGetFirst(active); c; - c = (ppd_cups_uiconsts_t *)cupsArrayNext(active)) + c = (ppd_cups_uiconsts_t *)cupsArrayGetNext(active)) { for (i = c->num_constraints, cptr = c->constraints; i > 0; @@ -720,7 +721,7 @@ ppd_load_constraints(ppd_file_t *ppd) // I - PPD file // Create an array to hold the constraint data... // - ppd->cups_uiconstraints = cupsArrayNew(NULL, NULL); + ppd->cups_uiconstraints = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); // // Find the installable options group if it exists... @@ -973,13 +974,13 @@ ppd_test_constraints( ppd_load_constraints(ppd); DEBUG_printf(("9ppd_test_constraints: %d constraints!", - cupsArrayCount(ppd->cups_uiconstraints))); + cupsArrayGetCount(ppd->cups_uiconstraints))); cupsArraySave(ppd->marked); - for (consts = (ppd_cups_uiconsts_t *)cupsArrayFirst(ppd->cups_uiconstraints); + for (consts = (ppd_cups_uiconsts_t *)cupsArrayGetFirst(ppd->cups_uiconstraints); consts; - consts = (ppd_cups_uiconsts_t *)cupsArrayNext(ppd->cups_uiconstraints)) + consts = (ppd_cups_uiconsts_t *)cupsArrayGetNext(ppd->cups_uiconstraints)) { DEBUG_printf(("9ppd_test_constraints: installable=%d, resolver=\"%s\", " "num_constraints=%d option1=\"%s\", choice1=\"%s\", " @@ -1180,7 +1181,7 @@ ppd_test_constraints( if (i <= 0) { if (!active) - active = cupsArrayNew(NULL, NULL); + active = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); cupsArrayAdd(active, consts); DEBUG_puts("9ppd_test_constraints: Added..."); @@ -1190,7 +1191,7 @@ ppd_test_constraints( cupsArrayRestore(ppd->marked); DEBUG_printf(("8ppd_test_constraints: Found %d active constraints!", - cupsArrayCount(active))); + cupsArrayGetCount(active))); return (active); } diff --git a/ppd/ppd-custom.c b/ppd/ppd-custom.c index da6cd355c..42b1f1a56 100644 --- a/ppd/ppd-custom.c +++ b/ppd/ppd-custom.c @@ -14,9 +14,10 @@ // Include necessary headers. // -#include "string-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include // @@ -56,9 +57,9 @@ ppdFindCustomParam(ppd_coption_t *opt, // I - Custom option if (!opt) return (NULL); - for (param = (ppd_cparam_t *)cupsArrayFirst(opt->params); + for (param = (ppd_cparam_t *)cupsArrayGetFirst(opt->params); param; - param = (ppd_cparam_t *)cupsArrayNext(opt->params)) + param = (ppd_cparam_t *)cupsArrayGetNext(opt->params)) if (!_ppd_strcasecmp(param->name, name)) break; @@ -78,7 +79,7 @@ ppdFirstCustomParam(ppd_coption_t *opt) // I - Custom option if (!opt) return (NULL); - return ((ppd_cparam_t *)cupsArrayFirst(opt->params)); + return ((ppd_cparam_t *)cupsArrayGetFirst(opt->params)); } @@ -94,5 +95,5 @@ ppdNextCustomParam(ppd_coption_t *opt) // I - Custom option if (!opt) return (NULL); - return ((ppd_cparam_t *)cupsArrayNext(opt->params)); + return ((ppd_cparam_t *)cupsArrayGetNext(opt->params)); } diff --git a/ppd/ppd-emit.c b/ppd/ppd-emit.c index 72c428616..a78555786 100644 --- a/ppd/ppd-emit.c +++ b/ppd/ppd-emit.c @@ -14,9 +14,10 @@ // Include necessary headers... // -#include "string-private.h" -#include "debug-internal.h" -#include "ppd.h" +#include +#include +#include +#include #if defined(_WIN32) || defined(__EMX__) # include #else @@ -101,14 +102,14 @@ ppdCollect2(ppd_file_t *ppd, // I - PPD file data count = 0; if ((collect = calloc(sizeof(ppd_choice_t *), - (size_t)cupsArrayCount(ppd->marked))) == NULL) + (size_t)cupsArrayGetCount(ppd->marked))) == NULL) { *choices = NULL; return (0); } if ((orders = calloc(sizeof(float), - (size_t)cupsArrayCount(ppd->marked))) == NULL) + (size_t)cupsArrayGetCount(ppd->marked))) == NULL) { *choices = NULL; free(collect); @@ -119,9 +120,9 @@ ppdCollect2(ppd_file_t *ppd, // I - PPD file data // Loop through all options and add choices as needed... // - for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked); + for (c = (ppd_choice_t *)cupsArrayGetFirst(ppd->marked); c; - c = (ppd_choice_t *)cupsArrayNext(ppd->marked)) + c = (ppd_choice_t *)cupsArrayGetNext(ppd->marked)) { csection = c->option->section; corder = c->option->order; @@ -721,9 +722,9 @@ ppdEmitString(ppd_file_t *ppd, // I - PPD file record // Add space to account for custom parameter substitution... // - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) { switch (cparam->type) { @@ -770,9 +771,9 @@ ppdEmitString(ppd_file_t *ppd, // I - PPD file record // %%BeginFeature: *Customkeyword True\n - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) { switch (cparam->type) { @@ -864,9 +865,9 @@ ppdEmitString(ppd_file_t *ppd, // I - PPD file record while (isdigit(*cptr & 255)) pnum = pnum * 10 + *cptr++ - '0'; - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) if (cparam->order == pnum) break; @@ -1067,20 +1068,20 @@ ppdEmitString(ppd_file_t *ppd, // I - PPD file record // order - params = cupsArrayNew((cups_array_func_t)ppd_compare_cparams, NULL); + params = cupsArrayNew((cups_array_cb_t)ppd_compare_cparams, NULL, NULL, 0, NULL, NULL); - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) cupsArrayAdd(params, cparam); snprintf(bufptr, (size_t)(bufend - bufptr + 1), "%%%%BeginFeature: *Custom%s True\n", coption->keyword); bufptr += strlen(bufptr); - for (cparam = (ppd_cparam_t *)cupsArrayFirst(params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(params)) { switch (cparam->type) { diff --git a/ppd/ppd-filter.c b/ppd/ppd-filter.c index f63515d45..7910a9bf0 100644 --- a/ppd/ppd-filter.c +++ b/ppd/ppd-filter.c @@ -12,8 +12,9 @@ // #include "config.h" -#include "ppd-filter.h" -#include "ppd.h" +#include +#include +#include #include #include #include @@ -706,7 +707,7 @@ ppdFilterLoadPPD(cf_filter_data_t *data) // I/O - Job and printer data { // We have a CUPS Raster driver PPD file data->header = - (cups_page_header2_t *)calloc(1, sizeof(cups_page_header2_t)); + (cups_page_header_t *)calloc(1, sizeof(cups_page_header_t)); if (ppdRasterInterpretPPD(data->header, ppd, data->num_options, data->options, NULL) < 0) { @@ -830,9 +831,9 @@ ppdFilterLoadPPD(cf_filter_data_t *data) // I/O - Job and printer data // Filter(s) specified by filter line(s), determine the one which got // actually used via final data MIME type bool cupsfilter2 = (ppdFindAttr(ppd, "cupsFilter2", NULL) != NULL); - for (lastfilter = (char *)cupsArrayFirst(ppd->cache->filters); + for (lastfilter = (char *)cupsArrayGetFirst(ppd->cache->filters); lastfilter; - lastfilter = (char *)cupsArrayNext(ppd->cache->filters)) + lastfilter = (char *)cupsArrayGetNext(ppd->cache->filters)) { char *p = lastfilter; if (cupsfilter2) @@ -1517,9 +1518,9 @@ ppdFilterUniversal(int inputfd, // I - File descriptor input stream if (log) log(ld, CF_LOGLEVEL_DEBUG, "ppdFilterUniversal: \"*cupsFilter(2): ...\" lines in the PPD file:"); - for (filter = (char *)cupsArrayFirst(cache->filters); + for (filter = (char *)cupsArrayGetFirst(cache->filters); filter; - filter = (char *)cupsArrayNext(cache->filters)) + filter = (char *)cupsArrayGetNext(cache->filters)) { char buf[256]; char *ptr, @@ -1666,7 +1667,7 @@ ppdFilterUniversal(int inputfd, // I - File descriptor input stream universal_filter.function = cfFilterUniversal; universal_filter.parameters = &universal_parameters; universal_filter.name = "universal"; - filter_chain = cupsArrayNew(NULL, NULL); + filter_chain = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); cupsArrayAdd(filter_chain, &universal_filter); cupsArrayAdd(filter_chain, &extra_filter); ret = cfFilterChain(inputfd, outputfd, inputseekable, data, diff --git a/ppd/ppd-generator.c b/ppd/ppd-generator.c index a815030b8..4b1614dd3 100644 --- a/ppd/ppd-generator.c +++ b/ppd/ppd-generator.c @@ -15,24 +15,23 @@ // information. // +// +// Include necessary headers. +// + #include -#include #include #include +#include #include #include +#include #include #include - - -// -// Include necessary headers. -// - +#include #include #include #include -#include // @@ -45,6 +44,27 @@ #endif +// +// Types... +// + +typedef struct _ppd_size_s // **** Media Size (cups_size_t of libcups2) **** +{ + char media[128]; // Media name to use + int width, // Width in hundredths of millimeters + length, // Length in hundredths of + // millimeters + bottom, // Bottom margin in hundredths of + // millimeters + left, // Left margin in hundredths of + // millimeters + right, // Right margin in hundredths of + // millimeters + top; // Top margin in hundredths of + // millimeters +} _ppd_size_t; + + // // Local functions... // @@ -189,7 +209,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer { cups_file_t *fp; // PPD file cups_array_t *printer_sizes; // Media sizes we've added - cups_size_t *size; // Current media size + _ppd_size_t *size; // Current media size ipp_attribute_t *attr, // xxx-supported *attr2, *lang_supp, // printer-strings-languages-supported @@ -243,7 +263,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer char *defaultoutbin = NULL; const char *outbin; char outbin_properties[1024]; - int octet_str_len; + cups_len_t octet_str_len; void *outbin_properties_octet; int outputorderinfofound = 0, faceupdown = 1, @@ -276,7 +296,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer // Open a temporary file for the PPD... // - if ((fp = cupsTempFile2(buffer, (int)bufsize)) == NULL) + if ((fp = cupsCreateTempFile(NULL, NULL, buffer, (int)bufsize)) == NULL) { if (status_msg && status_msg_size) snprintf(status_msg, status_msg_size, "%s", strerror(errno)); @@ -444,7 +464,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer printer_opt_strings_catalog = cfCatalogOptionArrayNew(); cfCatalogLoad(ippGetString(attr, 0, NULL), NULL, printer_opt_strings_catalog); - if (cupsArrayCount(printer_opt_strings_catalog) > 0) + if (cupsArrayGetCount(printer_opt_strings_catalog) > 0) { http_t *http = NULL; // Connection to printer const char *printer_uri = @@ -626,9 +646,9 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer max_res = NULL; // Put all available PDls into a simple case-insensitevely searchable // sorted string list - if ((pdl_list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0, - (cups_acopy_func_t)strdup, - (cups_afree_func_t)free)) == NULL) + if ((pdl_list = cupsArrayNew((cups_array_cb_t)strcasecmp, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, + (cups_afree_cb_t)free)) == NULL) goto bad_ppd; int formatfound = 0; @@ -808,7 +828,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer } } } - if (cupsArrayCount(current_res) > 0 && + if (cupsArrayGetCount(current_res) > 0 && cfJoinResolutionArrays(&common_res, ¤t_res, &common_def, ¤t_def)) { @@ -954,14 +974,14 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer } } if (common_def == NULL) { - count = cupsArrayCount(common_res); + count = cupsArrayGetCount(common_res); common_def = - cfCopyResolution(cupsArrayIndex(common_res, count / 2), NULL); + cfCopyResolution(cupsArrayGetElement(common_res, count / 2), NULL); } } // Get minimum and maximum resolution - min_res = cfCopyResolution(cupsArrayFirst(common_res), NULL); - max_res = cfCopyResolution(cupsArrayLast(common_res), NULL); + min_res = cfCopyResolution(cupsArrayGetFirst(common_res), NULL); + max_res = cfCopyResolution(cupsArrayGetLast(common_res), NULL); cupsArrayDelete(common_res); // @@ -969,7 +989,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer // supported and ppdize them one by one // - attr = ippFirstAttribute(supported); // first attribute + attr = ippGetFirstAttribute(supported); // first attribute while (attr) // loop through all the attributes { if ((is_apple && strncasecmp(ippGetName(attr), "urf-", 4) == 0) || @@ -985,12 +1005,12 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer { if ((current_res = cfIPPAttrToResolutionArray(attr)) != NULL) { - count = cupsArrayCount(current_res); + count = cupsArrayGetCount(current_res); if (count > 1) cupsFilePuts(fp, "\""); - for (i = 0, current_def = cupsArrayFirst(current_res); + for (i = 0, current_def = cupsArrayGetFirst(current_res); current_def; - i ++, current_def = cupsArrayNext(current_res)) + i ++, current_def = cupsArrayGetNext(current_res)) { int x = current_def->x; int y = current_def->y; @@ -1021,7 +1041,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePrintf(fp, "%s\n", buf); } } - attr = ippNextAttribute(supported); + attr = ippGetNextAttribute(supported); } // @@ -1038,7 +1058,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer else strcpy(ppdname, default_pagesize); - if (cupsArrayCount(sizes) > 0) + if (cupsArrayGetCount(sizes) > 0) { // // List all of the standard sizes... @@ -1057,8 +1077,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer // Find a page size without ".Borderless" suffix // (if all are ".Borderless" we drop the suffix in the PPD) - for (size = (cups_size_t *)cupsArrayFirst(sizes); size; - size = (cups_size_t *)cupsArrayNext(sizes)) + for (size = (_ppd_size_t *)cupsArrayGetFirst(sizes); size; + size = (_ppd_size_t *)cupsArrayGetNext(sizes)) if (strcasestr(size->media, ".Borderless") == NULL) break; if (size) @@ -1074,8 +1094,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePrintf(fp, "*OpenUI *PageSize/%s: PickOne\n" "*OrderDependency: 10 AnySetup *PageSize\n" "*DefaultPageSize: %s\n", "Media Size", ppdname); - for (size = (cups_size_t *)cupsArrayFirst(sizes); size; - size = (cups_size_t *)cupsArrayNext(sizes)) + for (size = (_ppd_size_t *)cupsArrayGetFirst(sizes); size; + size = (_ppd_size_t *)cupsArrayGetNext(sizes)) { cfStrFormatd(twidth, twidth + sizeof(twidth), size->width * 72.0 / 2540.0, loc); @@ -1123,8 +1143,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePrintf(fp, "*OpenUI *PageRegion/%s: PickOne\n" "*OrderDependency: 10 AnySetup *PageRegion\n" "*DefaultPageRegion: %s\n", "Media Size", ppdname); - for (size = (cups_size_t *)cupsArrayFirst(sizes); size; - size = (cups_size_t *)cupsArrayNext(sizes)) + for (size = (_ppd_size_t *)cupsArrayGetFirst(sizes); size; + size = (_ppd_size_t *)cupsArrayGetNext(sizes)) { cfStrFormatd(twidth, twidth + sizeof(twidth), size->width * 72.0 / 2540.0, loc); @@ -1172,8 +1192,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePrintf(fp, "*DefaultImageableArea: %s\n" "*DefaultPaperDimension: %s\n", ppdname, ppdname); - for (size = (cups_size_t *)cupsArrayFirst(sizes); size; - size = (cups_size_t *)cupsArrayNext(sizes)) + for (size = (_ppd_size_t *)cupsArrayGetFirst(sizes); size; + size = (_ppd_size_t *)cupsArrayGetNext(sizes)) { cfStrFormatd(tleft, tleft + sizeof(tleft), size->left * 72.0 / 2540.0, loc); @@ -1860,9 +1880,9 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer }; count = ippGetCount(attr); - names = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, - (cups_acopy_func_t)strdup, (cups_afree_func_t)free); - fin_options = cupsArrayNew((cups_array_func_t)strcmp, NULL); + names = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, + (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free); + fin_options = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL); // // Staple/Bind/Stitch @@ -2275,7 +2295,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePrintf(fp, "*cupsFinishingTemplate None/%s: \"\"\n", (human_readable ? human_readable : "None")); - templates = cupsArrayNew((cups_array_func_t)strcmp, NULL); + templates = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL); count = ippGetCount(attr); for (i = 0; i < count; i ++) @@ -2301,8 +2321,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer human_readable = (char *)keyword; cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\n", keyword, human_readable); - for (finishing_attr = ippFirstAttribute(finishing_col); finishing_attr; - finishing_attr = ippNextAttribute(finishing_col)) { + for (finishing_attr = ippGetFirstAttribute(finishing_col); finishing_attr; + finishing_attr = ippGetNextAttribute(finishing_col)) { if (ippGetValueTag(finishing_attr) == IPP_TAG_BEGIN_COLLECTION) { const char *name = ippGetName(finishing_attr); // Member attribute name @@ -2317,19 +2337,19 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n"); - if (cupsArrayCount(fin_options)) + if (cupsArrayGetCount(fin_options)) { const char *fin_option; // Current finishing option cupsFilePuts(fp, "*cupsUIConstraint finishing-template: \"*cupsFinishingTemplate"); - for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option; - fin_option = (const char *)cupsArrayNext(fin_options)) + for (fin_option = (const char *)cupsArrayGetFirst(fin_options); fin_option; + fin_option = (const char *)cupsArrayGetNext(fin_options)) cupsFilePrintf(fp, " %s", fin_option); cupsFilePuts(fp, "\"\n"); cupsFilePuts(fp, "*cupsUIResolver finishing-template: \"*cupsFinishingTemplate None"); - for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option; - fin_option = (const char *)cupsArrayNext(fin_options)) + for (fin_option = (const char *)cupsArrayGetFirst(fin_options); fin_option; + fin_option = (const char *)cupsArrayGetNext(fin_options)) cupsFilePrintf(fp, " %s None", fin_option); cupsFilePuts(fp, "\"\n"); } @@ -2573,8 +2593,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer cupsFilePrintf(fp, "*APPrinterPreset %s/%s: \"\n", preset_name, localized_name); - for (member = ippFirstAttribute(preset); member; - member = ippNextAttribute(preset)) + for (member = ippGetFirstAttribute(preset); member; + member = ippGetNextAttribute(preset)) { member_name = ippGetName(member); @@ -2723,8 +2743,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer if (conflicts != NULL) { char* constraint; - for (constraint = (char *)cupsArrayFirst(conflicts); constraint; - constraint = (char *)cupsArrayNext(conflicts)) + for (constraint = (char *)cupsArrayGetFirst(conflicts); constraint; + constraint = (char *)cupsArrayGetNext(conflicts)) cupsFilePrintf(fp, "%s", constraint); } @@ -2809,10 +2829,10 @@ http_connect(http_t **http, // IO - Current HTTP connection else encryption = HTTP_ENCRYPTION_IF_REQUESTED; - if (!*http || strcasecmp(host, httpGetHostname(*http, curhost, sizeof(curhost))) || httpAddrPort(httpGetAddress(*http)) != port || httpIsEncrypted(*http) != (encryption == HTTP_ENCRYPTION_ALWAYS)) + if (!*http || strcasecmp(host, httpGetHostname(*http, curhost, sizeof(curhost))) || httpAddrGetPort(httpGetAddress(*http)) != port || httpIsEncrypted(*http) != (encryption == HTTP_ENCRYPTION_ALWAYS)) { httpClose(*http); - *http = httpConnect2(host, port, NULL, AF_UNSPEC, encryption, 1, 5000, NULL); + *http = httpConnect(host, port, NULL, AF_UNSPEC, encryption, 1, 5000, NULL); } return (*http != NULL); diff --git a/ppd/ppd-ipp.c b/ppd/ppd-ipp.c index 82db2e17e..f157e2010 100644 --- a/ppd/ppd-ipp.c +++ b/ppd/ppd-ipp.c @@ -14,8 +14,9 @@ // Include necessary headers. // -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include #include #include @@ -339,7 +340,7 @@ ppdLoadAttributes( order, face_up, have_custom_size = 0; - cups_page_header2_t header; + cups_page_header_t header; static const char * const pdls[][2] = { // MIME media type to command set // mapping @@ -507,17 +508,17 @@ ppdLoadAttributes( // of the driver, as this is what our filter need to produce. // - docformats = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, NULL, - (cups_afree_func_t)free); + docformats = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, + (cups_afree_cb_t)free); is_texttotext = 0; strcpy(cmd, "CMD:"); cmdptr = cmd + 4; if (ppd->num_filters) { char *filter; - for (filter = (char *)cupsArrayFirst(pc->filters); + for (filter = (char *)cupsArrayGetFirst(pc->filters); filter; - filter = (char *)cupsArrayNext(pc->filters)) + filter = (char *)cupsArrayGetNext(pc->filters)) { // String of the "*cupsfilter:" or "*cupsfilter2:" line strncpy(buf, filter, sizeof(buf) - 1); @@ -742,23 +743,23 @@ ppdLoadAttributes( // document-format-supported attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "document-format-supported", - cupsArrayCount(docformats), NULL, NULL); - for (ptr = (char *)cupsArrayFirst(docformats), i = 0; ptr; - ptr = (char *)cupsArrayNext(docformats), i ++) + cupsArrayGetCount(docformats), NULL, NULL); + for (ptr = (char *)cupsArrayGetFirst(docformats), i = 0; ptr; + ptr = (char *)cupsArrayGetNext(docformats), i ++) ippSetString(attrs, &attr, i, ptr); // finishing-template-supported attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template-supported", - cupsArrayCount(pc->templates) + 1, NULL, NULL); + cupsArrayGetCount(pc->templates) + 1, NULL, NULL); ippSetString(attrs, &attr, 0, "none"); - for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); - template; i ++, template = (const char *)cupsArrayNext(pc->templates)) + for (i = 1, template = (const char *)cupsArrayGetFirst(pc->templates); + template; i ++, template = (const char *)cupsArrayGetNext(pc->templates)) ippSetString(attrs, &attr, i, template); // finishings-col-database attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-database", - cupsArrayCount(pc->templates) + 1, NULL); + cupsArrayGetCount(pc->templates) + 1, NULL); col = ippNew(); ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", @@ -766,8 +767,8 @@ ppdLoadAttributes( ippSetCollection(attrs, &attr, 0, col); ippDelete(col); - for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); - template; i ++, template = (const char *)cupsArrayNext(pc->templates)) + for (i = 1, template = (const char *)cupsArrayGetFirst(pc->templates); + template; i ++, template = (const char *)cupsArrayGetNext(pc->templates)) { col = ippNew(); ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", @@ -785,7 +786,7 @@ ppdLoadAttributes( // finishings-col-ready attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-ready", - cupsArrayCount(pc->templates) + 1, NULL); + cupsArrayGetCount(pc->templates) + 1, NULL); col = ippNew(); ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", @@ -793,8 +794,8 @@ ppdLoadAttributes( ippSetCollection(attrs, &attr, 0, col); ippDelete(col); - for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; - i ++, template = (const char *)cupsArrayNext(pc->templates)) + for (i = 1, template = (const char *)cupsArrayGetFirst(pc->templates); template; + i ++, template = (const char *)cupsArrayGetNext(pc->templates)) { col = ippNew(); ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", @@ -814,25 +815,25 @@ ppdLoadAttributes( // finishings-ready attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-ready", - cupsArrayCount(pc->finishings) + 1, NULL); + cupsArrayGetCount(pc->finishings) + 1, NULL); ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE); for (i = 1, - finishings = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings); + finishings = (ppd_pwg_finishings_t *)cupsArrayGetFirst(pc->finishings); finishings; i ++, - finishings = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings)) + finishings = (ppd_pwg_finishings_t *)cupsArrayGetNext(pc->finishings)) ippSetInteger(attrs, &attr, i, (int)finishings->value); // finishings-supported attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-supported", - cupsArrayCount(pc->finishings) + 1, NULL); + cupsArrayGetCount(pc->finishings) + 1, NULL); ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE); for (i = 1, - finishings = (ppd_pwg_finishings_t *)cupsArrayFirst(pc->finishings); + finishings = (ppd_pwg_finishings_t *)cupsArrayGetFirst(pc->finishings); finishings; i ++, - finishings = (ppd_pwg_finishings_t *)cupsArrayNext(pc->finishings)) + finishings = (ppd_pwg_finishings_t *)cupsArrayGetNext(pc->finishings)) ippSetInteger(attrs, &attr, i, (int)finishings->value); // media-bottom-margin-supported diff --git a/ppd/ppd-localize.c b/ppd/ppd-localize.c index a072d48a6..713953995 100644 --- a/ppd/ppd-localize.c +++ b/ppd/ppd-localize.c @@ -14,10 +14,10 @@ // Include necessary headers. // -#include "string-private.h" -#include "language-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include // @@ -109,13 +109,13 @@ ppdLocalize(ppd_file_t *ppd) // I - PPD file // Translate any custom parameters... // - for (coption = (ppd_coption_t *)cupsArrayFirst(ppd->coptions); + for (coption = (ppd_coption_t *)cupsArrayGetFirst(ppd->coptions); coption; - coption = (ppd_coption_t *)cupsArrayNext(ppd->coptions)) + coption = (ppd_coption_t *)cupsArrayGetNext(ppd->coptions)) { - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) { snprintf(ckeyword, sizeof(ckeyword), "ParamCustom%.29s", coption->keyword); @@ -287,11 +287,11 @@ ppdLocalizeIPPReason( !strcmp(ptr, "-warning"))) *ptr = '\0'; - message = _ppdLangString(lang, msgid); + message = cupsLangGetString(lang, msgid); if (message && strcmp(message, msgid)) { - strlcpy(buffer, _ppdLangString(lang, message), bufsize); + strlcpy(buffer, cupsLangGetString(lang, message), bufsize); return (buffer); } } @@ -484,9 +484,9 @@ ppdFreeLanguages( char *language; // Current language - for (language = (char *)cupsArrayFirst(languages); + for (language = (char *)cupsArrayGetFirst(languages); language; - language = (char *)cupsArrayNext(languages)) + language = (char *)cupsArrayGetNext(languages)) free(language); cupsArrayDelete(languages); @@ -518,7 +518,7 @@ ppdGetLanguages(ppd_file_t *ppd) // I - PPD file // Yes, load the list... // - if ((languages = cupsArrayNew((cups_array_func_t)strcmp, NULL)) == NULL) + if ((languages = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL)) == NULL) return (NULL); if ((value = strdup(attr->value)) == NULL) @@ -561,7 +561,7 @@ ppdGetLanguages(ppd_file_t *ppd) // I - PPD file free(value); - if (cupsArrayCount(languages) == 0) + if (cupsArrayGetCount(languages) == 0) { cupsArrayDelete(languages); return (NULL); @@ -710,7 +710,7 @@ ppd_ll_CC(char *ll_CC, // O - Country-specific locale name // Copy the locale name... // - strlcpy(ll_CC, lang->language, ll_CC_size); + strlcpy(ll_CC, cupsLangGetName(lang), ll_CC_size); if (strlen(ll_CC) == 2) { @@ -731,7 +731,7 @@ ppd_ll_CC(char *ll_CC, // O - Country-specific locale name strlcpy(ll_CC, "zh_CN", ll_CC_size); } - DEBUG_printf(("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...", - lang->language, ll_CC)); + DEBUG_printf(("8ppd_ll_CC: cupsLangGetName(lang)=\"%s\", ll_CC=\"%s\"...", + cupsLangGetName(lang), ll_CC)); return (lang); } diff --git a/ppd/ppd-mark.c b/ppd/ppd-mark.c index 748530f1f..1916f0a74 100644 --- a/ppd/ppd-mark.c +++ b/ppd/ppd-mark.c @@ -14,9 +14,10 @@ // Include necessary headers... // -#include "string-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include // @@ -512,9 +513,9 @@ ppdMarkDefaults(ppd_file_t *ppd) // I - PPD file record // Clean out the marked array... // - for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked); + for (c = (ppd_choice_t *)cupsArrayGetFirst(ppd->marked); c; - c = (ppd_choice_t *)cupsArrayNext(ppd->marked)) + c = (ppd_choice_t *)cupsArrayGetNext(ppd->marked)) { cupsArrayRemove(ppd->marked, c); c->marked = 0; @@ -583,7 +584,7 @@ ppdFirstOption(ppd_file_t *ppd) // I - PPD file if (!ppd) return (NULL); else - return ((ppd_option_t *)cupsArrayFirst(ppd->options)); + return ((ppd_option_t *)cupsArrayGetFirst(ppd->options)); } @@ -601,7 +602,7 @@ ppdNextOption(ppd_file_t *ppd) // I - PPD file if (!ppd) return (NULL); else - return ((ppd_option_t *)cupsArrayNext(ppd->options)); + return ((ppd_option_t *)cupsArrayGetNext(ppd->options)); } @@ -705,9 +706,9 @@ ppd_debug_marked(ppd_file_t *ppd, // I - PPD file data DEBUG_printf(("2ppdMarkOptions: %s", title)); - for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked); + for (c = (ppd_choice_t *)cupsArrayGetFirst(ppd->marked); c; - c = (ppd_choice_t *)cupsArrayNext(ppd->marked)) + c = (ppd_choice_t *)cupsArrayGetNext(ppd->marked)) DEBUG_printf(("2ppdMarkOptions: %s=%s", c->option->keyword, c->choice)); } #endif // DEBUG @@ -849,7 +850,7 @@ ppd_mark_option(ppd_file_t *ppd, // I - PPD file if ((coption = ppdFindCustomOption(ppd, option)) != NULL) { - if ((cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params)) == NULL) + if ((cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params)) == NULL) return; switch (cparam->type) diff --git a/ppd/ppd-test.c b/ppd/ppd-test.c index 45d662cee..4a99698f6 100644 --- a/ppd/ppd-test.c +++ b/ppd/ppd-test.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -161,9 +162,9 @@ int ppdTest(int ignore, // Which errors to ignore if (report && *report == NULL) { - *report = cupsArrayNew3(NULL, NULL, NULL, 0, - (cups_acopy_func_t)_ppdStrAlloc, - (cups_afree_func_t)_ppdStrFree); + *report = cupsArrayNew(NULL, NULL, NULL, 0, + (cups_acopy_cb_t)_ppdStrAlloc, + (cups_afree_cb_t)_ppdStrFree); if (*report == NULL) { if (log) log(ld, CF_LOGLEVEL_ERROR, @@ -179,9 +180,9 @@ int ppdTest(int ignore, // Which errors to ignore // Open the PPD file... // - for (i = 0, file = (char *)cupsArrayFirst(file_array); + for (i = 0, file = (char *)cupsArrayGetFirst(file_array); file; - i ++, file = (char *)cupsArrayNext(file_array)) + i ++, file = (char *)cupsArrayGetNext(file_array)) { if (strcmp(file, "-") == 0) { @@ -4599,9 +4600,9 @@ check_translations(ppd_file_t *ppd, // I - PPD file // This file contains localizations, check them... // - for (language = (char *)cupsArrayFirst(languages); + for (language = (char *)cupsArrayGetFirst(languages); language; - language = (char *)cupsArrayNext(languages)) + language = (char *)cupsArrayGetNext(languages)) { langlen = (int)strlen(language); if (langlen != 2 && langlen != 5) @@ -4760,9 +4761,9 @@ check_translations(ppd_file_t *ppd, // I - PPD file if (_ppd_strcasecmp(option->keyword, "PageSize")) { - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) { snprintf(ckeyword, sizeof(ckeyword), "%s.ParamCustom%.28s", language, option->keyword); @@ -4895,9 +4896,9 @@ check_translations(ppd_file_t *ppd, // I - PPD file // Verify that we have the base language for each localized one... // - for (language = (char *)cupsArrayFirst(languages); + for (language = (char *)cupsArrayGetFirst(languages); language; - language = (char *)cupsArrayNext(languages)) + language = (char *)cupsArrayGetNext(languages)) if (language[2]) { // @@ -5068,7 +5069,7 @@ test_raster(ppd_file_t *ppd, // I - PPD file void *ld) // I - Log function data { char str_format[2048]; // Formatted string - cups_page_header2_t header; // Page header + cups_page_header_t header; // Page header ppdMarkDefaults(ppd); diff --git a/ppd/ppd.c b/ppd/ppd.c index a8c478109..43cad48a1 100644 --- a/ppd/ppd.c +++ b/ppd/ppd.c @@ -14,11 +14,12 @@ // Include necessary headers. // -#include "string-private.h" -#include "language-private.h" -#include "thread-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include +#include +#include // @@ -33,6 +34,13 @@ #define PPD_HASHSIZE 512 // Size of hash +// +// Macro for localized text... +// + +# define _(x) x + + // // Line buffer structure... // @@ -209,13 +217,13 @@ ppdClose(ppd_file_t *ppd) // I - PPD file record // Free custom options... // - for (coption = (ppd_coption_t *)cupsArrayFirst(ppd->coptions); + for (coption = (ppd_coption_t *)cupsArrayGetFirst(ppd->coptions); coption; - coption = (ppd_coption_t *)cupsArrayNext(ppd->coptions)) + coption = (ppd_coption_t *)cupsArrayGetNext(ppd->coptions)) { - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) { switch (cparam->type) { @@ -248,9 +256,9 @@ ppdClose(ppd_file_t *ppd) // I - PPD file record ppd_cups_uiconsts_t *consts; // Current constraints - for (consts = (ppd_cups_uiconsts_t *)cupsArrayFirst(ppd->cups_uiconstraints); + for (consts = (ppd_cups_uiconsts_t *)cupsArrayGetFirst(ppd->cups_uiconstraints); consts; - consts = (ppd_cups_uiconsts_t *)cupsArrayNext(ppd->cups_uiconstraints)) + consts = (ppd_cups_uiconsts_t *)cupsArrayGetNext(ppd->cups_uiconstraints)) { free(consts->constraints); free(consts); @@ -315,9 +323,9 @@ ppdErrorString(ppd_status_t status) // I - PPD status if (status < PPD_OK || status >= PPD_MAX_STATUS) - return (_ppdLangString(cupsLangDefault(), _("Unknown"))); + return (cupsLangGetString(cupsLangDefault(), _("Unknown"))); else - return (_ppdLangString(cupsLangDefault(), messages[status])); + return (cupsLangGetString(cupsLangDefault(), messages[status])); } @@ -330,19 +338,19 @@ cups_encoding_t // O - CUPS encoding value ppdGetEncoding(const char *name) // I - LanguageEncoding string { if (!_ppd_strcasecmp(name, "ISOLatin1")) - return (CUPS_ISO8859_1); + return (CUPS_ENCODING_ISO8859_1); else if (!_ppd_strcasecmp(name, "ISOLatin2")) - return (CUPS_ISO8859_2); + return (CUPS_ENCODING_ISO8859_2); else if (!_ppd_strcasecmp(name, "ISOLatin5")) - return (CUPS_ISO8859_5); + return (CUPS_ENCODING_ISO8859_5); else if (!_ppd_strcasecmp(name, "JIS83-RKSJ")) - return (CUPS_JIS_X0213); + return (CUPS_ENCODING_JIS_X0213); else if (!_ppd_strcasecmp(name, "MacStandard")) - return (CUPS_MAC_ROMAN); + return (CUPS_ENCODING_MAC_ROMAN); else if (!_ppd_strcasecmp(name, "WindowsANSI")) - return (CUPS_WINDOWS_1252); + return (CUPS_ENCODING_WINDOWS_1252); else - return (CUPS_UTF8); + return (CUPS_ENCODING_UTF_8); } @@ -552,7 +560,7 @@ ppdOpenWithLocalization( if ((lang = cupsLangDefault()) == NULL) return (NULL); - snprintf(ll_CC, sizeof(ll_CC), "%.5s.", lang->language); + snprintf(ll_CC, sizeof(ll_CC), "%.5s.", cupsLangGetName(lang)); // // @@ -561,26 +569,26 @@ ppdOpenWithLocalization( // Need to use a different base language for some locales... // - if (!strcmp(lang->language, "zh_HK")) + if (!strcmp(cupsLangGetName(lang), "zh_HK")) { // Traditional Chinese + variants strlcpy(ll_CC, "zh_TW.", sizeof(ll_CC)); strlcpy(ll, "zh_", sizeof(ll)); } - else if (!strncmp(lang->language, "zh", 2)) + else if (!strncmp(cupsLangGetName(lang), "zh", 2)) strlcpy(ll, "zh_", sizeof(ll)); // Any Chinese variant - else if (!strncmp(lang->language, "jp", 2)) + else if (!strncmp(cupsLangGetName(lang), "jp", 2)) { // Any Japanese variant strlcpy(ll_CC, "ja", sizeof(ll_CC)); strlcpy(ll, "jp", sizeof(ll)); } - else if (!strncmp(lang->language, "nb", 2) || - !strncmp(lang->language, "no", 2)) + else if (!strncmp(cupsLangGetName(lang), "nb", 2) || + !strncmp(cupsLangGetName(lang), "no", 2)) { // Any Norwegian variant strlcpy(ll_CC, "nb", sizeof(ll_CC)); strlcpy(ll, "no", sizeof(ll)); } else - snprintf(ll, sizeof(ll), "%2.2s.", lang->language); + snprintf(ll, sizeof(ll), "%2.2s.", cupsLangGetName(lang)); ll_CC_len = strlen(ll_CC); ll_len = strlen(ll); @@ -642,8 +650,8 @@ ppdOpenWithLocalization( ppd->color_device = 0; ppd->colorspace = PPD_CS_N; ppd->landscape = -90; - ppd->coptions = cupsArrayNew((cups_array_func_t)ppd_compare_coptions, - NULL); + ppd->coptions = cupsArrayNew((cups_array_cb_t)ppd_compare_coptions, + NULL, NULL, 0, NULL, NULL); // // Read lines from the PPD file and add them to the file record... @@ -654,7 +662,7 @@ ppdOpenWithLocalization( option = NULL; choice = NULL; ui_keyword = 0; - encoding = CUPS_ISO8859_1; + encoding = CUPS_ENCODING_ISO8859_1; loc = localeconv(); while ((mask = ppd_read(fp, &line, keyword, name, text, &string, 1, pg)) != 0) @@ -851,7 +859,7 @@ ppdOpenWithLocalization( ppd->pcfilename = string; else if (!strcmp(keyword, "NickName")) { - if (encoding != CUPS_UTF8) + if (encoding != CUPS_ENCODING_UTF_8) { cups_utf8_t utf8[256]; // UTF-8 version of NickName @@ -2154,9 +2162,9 @@ ppdOpenWithLocalization( // each choice and custom option... // - ppd->options = cupsArrayNew2((cups_array_func_t)ppd_compare_options, NULL, - (cups_ahash_func_t)ppd_hash_option, - PPD_HASHSIZE); + ppd->options = cupsArrayNew((cups_array_cb_t)ppd_compare_options, NULL, + (cups_ahash_cb_t)ppd_hash_option, + PPD_HASHSIZE, NULL, NULL); for (i = ppd->num_groups, group = ppd->groups; i > 0; @@ -2183,7 +2191,7 @@ ppdOpenWithLocalization( // Create an array to track the marked choices... // - ppd->marked = cupsArrayNew((cups_array_func_t)ppd_compare_choices, NULL); + ppd->marked = cupsArrayNew((cups_array_cb_t)ppd_compare_choices, NULL, NULL, 0, NULL, NULL); // // Return the PPD file structure... @@ -2415,8 +2423,8 @@ ppd_add_attr(ppd_file_t *ppd, // I - PPD file data // if (!ppd->sorted_attrs) - ppd->sorted_attrs = cupsArrayNew((cups_array_func_t)ppd_compare_attrs, - NULL); + ppd->sorted_attrs = cupsArrayNew((cups_array_cb_t)ppd_compare_attrs, + NULL, NULL, 0, NULL, NULL); // // Allocate memory for the new attribute... @@ -2748,7 +2756,7 @@ ppd_get_coption(ppd_file_t *ppd, // I - PPD file strlcpy(copt->keyword, name, sizeof(copt->keyword)); - copt->params = cupsArrayNew((cups_array_func_t)NULL, NULL); + copt->params = cupsArrayNew((cups_array_cb_t)NULL, NULL, NULL, 0, NULL, NULL); cupsArrayAdd(ppd->coptions, copt); diff --git a/ppd/ppd.h b/ppd/ppd.h index fe5517ad3..74be7d803 100644 --- a/ppd/ppd.h +++ b/ppd/ppd.h @@ -28,6 +28,15 @@ # include +// +// Renamed CUPS type in API +// + +#if CUPS_VERSION_MAJOR < 3 +# define cups_page_header_t cups_page_header2_t +#endif + + // // C++ magic... // @@ -84,7 +93,7 @@ extern "C" { // Types and structures... // -typedef int (*cups_interpret_cb_t)(cups_page_header2_t *header, int preferred_bits); +typedef int (*cups_interpret_cb_t)(cups_page_header_t *header, int preferred_bits); // **** cupsRasterInterpretPPD callback // function **** // @@ -641,7 +650,7 @@ extern void ppdSetConformance(ppd_conform_t c); // **** New in CUPS 1.2 **** // cupsRasterInterpretPPD replaced by ppdRasterInterpretPPD in libppd -// extern int cupsRasterInterpretPPD(cups_page_header2_t *h, +// extern int cupsRasterInterpretPPD(cups_page_header_t *h, // ppd_file_t *ppd, // int num_options, // cups_option_t *options, @@ -707,7 +716,7 @@ extern int ppdPageSizeLimits(ppd_file_t *ppd, extern int ppdMarkOptions(ppd_file_t *ppd, int num_options, cups_option_t *options); -extern int ppdRasterInterpretPPD(cups_page_header2_t *h, +extern int ppdRasterInterpretPPD(cups_page_header_t *h, ppd_file_t *ppd, int num_options, cups_option_t *options, @@ -734,10 +743,10 @@ extern int ppdConvertOptions(ipp_t *request, int copies, int num_options, cups_option_t *options); -extern int ppdRasterExecPS(cups_page_header2_t *h, +extern int ppdRasterExecPS(cups_page_header_t *h, int *preferred_bits, const char *code); -extern int ppdRasterInterpretPPD(cups_page_header2_t *h, +extern int ppdRasterInterpretPPD(cups_page_header_t *h, ppd_file_t *ppd, int num_options, cups_option_t *options, @@ -817,7 +826,7 @@ extern int ppdGetOptions(cups_option_t **options, ppd_file_t *ppd); // **** New in libppd 2.0.0: Added for pclmtoraster filter **** -extern int ppdRasterMatchPPDSize(cups_page_header2_t *header, +extern int ppdRasterMatchPPDSize(cups_page_header_t *header, ppd_file_t *ppd, double margins[4], double dimensions[2], diff --git a/ppd/ppdc-catalog.cxx b/ppd/ppdc-catalog.cxx index 71cd73394..0b629dcae 100644 --- a/ppd/ppdc-catalog.cxx +++ b/ppd/ppdc-catalog.cxx @@ -852,7 +852,11 @@ put_utf16(cups_file_t *fp, // I - File to write to buffer[0] = (unsigned char)(ch >> 8); buffer[1] = (unsigned char)ch; +#ifdef HAVE_LIBCUPS2 if (cupsFileWrite(fp, (char *)buffer, 2) == 2) +#else + if (cupsFileWrite(fp, (char *)buffer, 2)) +#endif // HAVE_LIBCUPS2 return (0); } else @@ -865,7 +869,11 @@ put_utf16(cups_file_t *fp, // I - File to write to buffer[2] = (unsigned char)(0xdc | ((ch >> 8) & 0x03)); buffer[3] = (unsigned char)ch; +#ifdef HAVE_LIBCUPS2 if (cupsFileWrite(fp, (char *)buffer, 4) == 4) +#else + if (cupsFileWrite(fp, (char *)buffer, 4)) +#endif // HAVE_LIBCUPS2 return (0); } diff --git a/ppd/ppdc.cxx b/ppd/ppdc.cxx index f5dd80a30..c4fb0b3d4 100644 --- a/ppd/ppdc.cxx +++ b/ppd/ppdc.cxx @@ -12,7 +12,8 @@ // Include necessary headers... // -#include "ppdc-private.h" +#include +#include #include #include #include @@ -76,7 +77,7 @@ main(int argc, // I - Number of command-line arguments src = new ppdcSource(); use_model_name = 0; verbose = 0; - filenames = cupsArrayNew((cups_array_func_t)strcasecmp, NULL); + filenames = cupsArrayNew((cups_array_cb_t)strcasecmp, NULL, NULL, 0, NULL, NULL); progname = strrchr(argv[0], '/'); if (progname) diff --git a/ppd/ppdmerge.cxx b/ppd/ppdmerge.cxx index ab0e37fe2..d1de087c2 100644 --- a/ppd/ppdmerge.cxx +++ b/ppd/ppdmerge.cxx @@ -13,7 +13,8 @@ // #include -#include "ppd.h" +#include +#include #include //#include @@ -53,7 +54,7 @@ main(int argc, // I - Number of command-line arguments outname = NULL; outfile = NULL; languages = NULL; - ppds = cupsArrayNew(NULL, NULL); + ppds = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); for (i = 1; i < argc; i ++) if (argv[i][0] == '-') @@ -174,11 +175,11 @@ main(int argc, // I - Number of command-line arguments // Loop through the PPD files we loaded to generate a new language list... if (!languages) - languages = cupsArrayNew((cups_array_func_t)strcmp, NULL); + languages = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL); - for (ppd = (ppd_file_t *)cupsArrayFirst(ppds); + for (ppd = (ppd_file_t *)cupsArrayGetFirst(ppds); ppd; - ppd = (ppd_file_t *)cupsArrayNext(ppds)) + ppd = (ppd_file_t *)cupsArrayGetNext(ppds)) { locale = ppd_locale(ppd); @@ -208,10 +209,10 @@ main(int argc, // I - Number of command-line arguments cupsFileGets(infile, line, sizeof(line)); cupsFilePrintf(outfile, "%s\n", line); - if ((locale = (char *)cupsArrayFirst(languages)) != NULL) + if ((locale = (char *)cupsArrayGetFirst(languages)) != NULL) { cupsFilePrintf(outfile, "*cupsLanguages: \"%s", locale); - while ((locale = (char *)cupsArrayNext(languages)) != NULL) + while ((locale = (char *)cupsArrayGetNext(languages)) != NULL) cupsFilePrintf(outfile, " %s", locale); cupsFilePuts(outfile, "\"\n"); } @@ -223,9 +224,9 @@ main(int argc, // I - Number of command-line arguments } // Loop through the other PPD files we loaded to provide the translations... - for (ppd = (ppd_file_t *)cupsArrayFirst(ppds); + for (ppd = (ppd_file_t *)cupsArrayGetFirst(ppds); ppd; - ppd = (ppd_file_t *)cupsArrayNext(ppds)) + ppd = (ppd_file_t *)cupsArrayGetNext(ppds)) { // Output all of the UI text for this language... int j, k, l; // Looping vars diff --git a/ppd/raster-interpret.c b/ppd/raster-interpret.c index d120d2fce..de3a38cc7 100644 --- a/ppd/raster-interpret.c +++ b/ppd/raster-interpret.c @@ -12,9 +12,10 @@ // Include necessary headers... // -#include "raster-private.h" -#include "ppd.h" -#include "debug-internal.h" +#include +#include +#include +#include #include @@ -84,7 +85,7 @@ static _ppd_ps_obj_t *ppd_push_stack(_ppd_ps_stack_t *st, static int ppd_roll_stack(_ppd_ps_stack_t *st, int c, int s); static _ppd_ps_obj_t *ppd_scan_ps(_ppd_ps_stack_t *st, char **ptr); static int ppd_setpagedevice(_ppd_ps_stack_t *st, - cups_page_header2_t *h, + cups_page_header_t *h, int *preferred_bits); #ifdef DEBUG static void ppd_DEBUG_object(const char *prefix, _ppd_ps_obj_t *obj); @@ -108,7 +109,7 @@ static void ppd_DEBUG_stack(const char *prefix, _ppd_ps_stack_t *st); // // The "func" argument specifies an optional callback function that is // called prior to the computation of the final raster data. The function -// can make changes to the @link cups_page_header2_t@ data as needed to use a +// can make changes to the @link cups_page_header_t@ data as needed to use a // supported raster format and then returns 0 on success and -1 if the // requested attributes cannot be supported. // @@ -124,7 +125,7 @@ static void ppd_DEBUG_stack(const char *prefix, _ppd_ps_stack_t *st); int // O - 0 on success, -1 on failure ppdRasterInterpretPPD( - cups_page_header2_t *h, // O - Page header to create + cups_page_header_t *h, // O - Page header to create ppd_file_t *ppd, // I - PPD file int num_options, // I - Number of options cups_option_t *options, // I - Options @@ -159,7 +160,7 @@ ppdRasterInterpretPPD( // Reset the page header to the defaults... // - memset(h, 0, sizeof(cups_page_header2_t)); + memset(h, 0, sizeof(cups_page_header_t)); h->NumCopies = 1; h->PageSize[0] = 612; @@ -503,7 +504,7 @@ ppdRasterInterpretPPD( int // O - 0 on success, -1 on failure ppdRasterMatchPPDSize( - cups_page_header2_t *header, // I - Page header to match + cups_page_header_t *header, // I - Page header to match ppd_file_t *ppd, // I - PPD file double margins[4], // O - Margins of media in points double dimensions[2], // O - Width and Length of media in points @@ -659,7 +660,7 @@ ppdRasterMatchPPDSize( int // O - 0 on success, -1 on error ppdRasterExecPS( - cups_page_header2_t *h, // O - Page header + cups_page_header_t *h, // O - Page header int *preferred_bits,// O - Preferred bits per color const char *code) // I - PS code to execute { @@ -1552,7 +1553,7 @@ ppd_scan_ps(_ppd_ps_stack_t *st, // I - Stack static int // O - 0 on success, -1 on error ppd_setpagedevice( _ppd_ps_stack_t *st, // I - Stack - cups_page_header2_t *h, // O - Page header + cups_page_header_t *h, // O - Page header int *preferred_bits)// O - Preferred bits per color { int i; // Index into array diff --git a/ppd/rastertops.c b/ppd/rastertops.c index bd41653a1..e1cda804b 100644 --- a/ppd/rastertops.c +++ b/ppd/rastertops.c @@ -23,7 +23,8 @@ #include #include #include -#include "debug-internal.h" +#include +#include #include // @@ -229,7 +230,7 @@ convert_pixels(unsigned char *pixdata, // I - Original pixel data static int // O - Error value write_flate(cups_raster_t *ras, // I - Image data - cups_page_header2_t header, // I - Bytes Per Line + cups_page_header_t header, // I - Bytes Per Line rastertops_doc_t *doc) // I - Document information { int ret, // Return value of this @@ -406,7 +407,7 @@ ppdFilterRasterToPS(int inputfd, // I - File descriptor input stream cups_file_t *inputfp; // Print file FILE *outputfp; // Output data stream cups_raster_t *ras; // Raster stream for printing - cups_page_header2_t header; // Page header from file + cups_page_header_t header; // Page header from file int empty, // Is the input empty? Page = 0, // variable for counting the pages ret; // Return value of deflate compression @@ -469,7 +470,7 @@ ppdFilterRasterToPS(int inputfd, // I - File descriptor input stream Page = 0; empty = 1; - while (cupsRasterReadHeader2(ras, &header)) + while (cupsRasterReadHeader(ras, &header)) { if (iscanceled && iscanceled(icd)) { diff --git a/ppd/string.c b/ppd/string.c index b85fea31d..5cfba3052 100644 --- a/ppd/string.c +++ b/ppd/string.c @@ -13,10 +13,11 @@ // #define _PPD_STRING_C_ -#include "string-private.h" -#include "array-private.h" -#include "thread-private.h" -#include "debug-internal.h" +#include +#include +#include +#include +#include #include #include @@ -64,7 +65,7 @@ _ppdStrAlloc(const char *s) // I - String _ppdMutexLock(&sp_mutex); if (!stringpool) - stringpool = cupsArrayNew((cups_array_func_t)ppd_compare_sp_items, NULL); + stringpool = cupsArrayNew((cups_array_cb_t)ppd_compare_sp_items, NULL, NULL, 0, NULL, NULL); if (!stringpool) { @@ -151,13 +152,13 @@ _ppdStrFlush(void) DEBUG_printf(("4_ppdStrFlush: %d strings in array", - cupsArrayCount(stringpool))); + cupsArrayGetCount(stringpool))); _ppdMutexLock(&sp_mutex); - for (item = (_ppd_sp_item_t *)cupsArrayFirst(stringpool); + for (item = (_ppd_sp_item_t *)cupsArrayGetFirst(stringpool); item; - item = (_ppd_sp_item_t *)cupsArrayNext(stringpool)) + item = (_ppd_sp_item_t *)cupsArrayGetNext(stringpool)) free(item); cupsArrayDelete(stringpool); @@ -517,9 +518,9 @@ _ppdStrStatistics(size_t *alloc_bytes, // O - Allocated bytes _ppdMutexLock(&sp_mutex); for (count = 0, abytes = 0, tbytes = 0, - item = (_ppd_sp_item_t *)cupsArrayFirst(stringpool); + item = (_ppd_sp_item_t *)cupsArrayGetFirst(stringpool); item; - item = (_ppd_sp_item_t *)cupsArrayNext(stringpool)) + item = (_ppd_sp_item_t *)cupsArrayGetNext(stringpool)) { // // Count allocated memory, using a 64-bit aligned buffer as a basis. diff --git a/ppd/testppd.c b/ppd/testppd.c index 1ecc244a2..b4d221d67 100644 --- a/ppd/testppd.c +++ b/ppd/testppd.c @@ -12,9 +12,10 @@ // Include necessary headers... // -#include "ppd.h" -#include "array-private.h" -#include "raster-private.h" +#include +#include +#include +#include #include #ifdef _WIN32 # include @@ -32,7 +33,7 @@ static int do_ppd_tests(const char *filename, int num_options, cups_option_t *options); static int do_ps_tests(void); -static void print_changes(cups_page_header2_t *header, cups_page_header2_t *expected); +static void print_changes(cups_page_header_t *header, cups_page_header_t *expected); // @@ -134,7 +135,7 @@ static const char *setpagedevice_code = "/cupsPreferredBitsPerColor 17" ">> setpagedevice"; -static cups_page_header2_t setpagedevice_header = +static cups_page_header_t setpagedevice_header = { "Media Class", // MediaClass "(Media Color)", // MediaColor @@ -1209,16 +1210,16 @@ main(int argc, // I - Number of command-line arguments // PPD directory list -> See whether we have valid PPD collection cups_array_t *dirlist = _ppdArrayNewStrings(argv[1], ','); - cups_array_t *ppd_collections = cupsArrayNew(NULL, NULL); + cups_array_t *ppd_collections = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL); ppd_collection_t *col; cups_option_t *options = NULL; int num_options = 0; int i; char *testname = NULL; - for (s = (char *)cupsArrayFirst(dirlist), i = 1; + for (s = (char *)cupsArrayGetFirst(dirlist), i = 1; s; - s = (char *)cupsArrayNext(dirlist), i ++) + s = (char *)cupsArrayGetNext(dirlist), i ++) { col = (ppd_collection_t *)calloc(1, sizeof(ppd_collection_t)); col->path = s; @@ -1249,21 +1250,21 @@ main(int argc, // I - Number of command-line arguments { if (cupsGetOption("only-makes", num_options, options)) { - printf("Found %d manufacturers.\n\n", cupsArrayCount(ppds)); - for (s = (char *)cupsArrayFirst(ppds); + printf("Found %d manufacturers.\n\n", (int)cupsArrayGetCount(ppds)); + for (s = (char *)cupsArrayGetFirst(ppds); s; - s = (char *)cupsArrayNext(ppds)) + s = (char *)cupsArrayGetNext(ppds)) puts(s); } else { ppd_info_t *ppd; - printf("Found %d PPD files.\n\n", cupsArrayCount(ppds)); + printf("Found %d PPD files.\n\n", (int)cupsArrayGetCount(ppds)); puts("mtime,size,model_number,type,filename,name,languages0,products0," "psversions0,make,make_and_model,device_id,scheme"); - for (ppd = (ppd_info_t *)cupsArrayFirst(ppds); + for (ppd = (ppd_info_t *)cupsArrayGetFirst(ppds); ppd; - ppd = (ppd_info_t *)cupsArrayNext(ppds)) + ppd = (ppd_info_t *)cupsArrayGetNext(ppds)) { printf("%d,%ld,%d,%d,\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"," "\"%s\",\"%s\"\n", @@ -1303,9 +1304,9 @@ main(int argc, // I - Number of command-line arguments printf("%s: No PPD files found.\n", argv[1]); cupsArrayDelete(dirlist); - for (col = (ppd_collection_t *)cupsArrayFirst(ppd_collections); + for (col = (ppd_collection_t *)cupsArrayGetFirst(ppd_collections); col; - col = (ppd_collection_t *)cupsArrayNext(ppd_collections)) + col = (ppd_collection_t *)cupsArrayGetNext(ppd_collections)) { free(col->name); free(col); @@ -1313,9 +1314,9 @@ main(int argc, // I - Number of command-line arguments cupsArrayDelete(ppd_collections); if (ppds) { - for (s = (char *)cupsArrayFirst(ppds); + for (s = (char *)cupsArrayGetFirst(ppds); s; - s = (char *)cupsArrayNext(ppds)) + s = (char *)cupsArrayGetNext(ppds)) free(s); cupsArrayDelete(ppds); } @@ -1436,9 +1437,9 @@ main(int argc, // I - Number of command-line arguments if ((coption = ppdFindCustomOption(ppd, option->keyword)) != NULL) { - for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + for (cparam = (ppd_cparam_t *)cupsArrayGetFirst(coption->params); cparam; - cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + cparam = (ppd_cparam_t *)cupsArrayGetNext(coption->params)) { switch (cparam->type) { @@ -1531,15 +1532,15 @@ main(int argc, // I - Number of command-line arguments puts("\nAttributes:"); - for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs); + for (attr = (ppd_attr_t *)cupsArrayGetFirst(ppd->sorted_attrs); attr; - attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) + attr = (ppd_attr_t *)cupsArrayGetNext(ppd->sorted_attrs)) printf(" *%s %s/%s: \"%s\"\n", attr->name, attr->spec, attr->text, attr->value ? attr->value : ""); puts("\nPPD Cache:"); if ((pc = ppdCacheCreateWithPPD(ppd)) == NULL) - printf(" Unable to create: %s\n", cupsLastErrorString()); + printf(" Unable to create: %s\n", cupsGetErrorString()); else { ppdCacheWriteFile(pc, "t.cache", NULL); @@ -1580,7 +1581,7 @@ do_ppd_tests(const char *filename, // I - PPD file cups_option_t *options) // I - Options { ppd_file_t *ppd; // PPD file data - cups_page_header2_t header; // Page header + cups_page_header_t header; // Page header printf("\"%s\": ", filename); @@ -1626,7 +1627,7 @@ do_ppd_tests(const char *filename, // I - PPD file static int do_ps_tests(void) { - cups_page_header2_t header; // Page header + cups_page_header_t header; // Page header int preferred_bits; // Preferred bits int errors = 0; // Number of errors @@ -1751,8 +1752,8 @@ do_ps_tests(void) static void print_changes( - cups_page_header2_t *header, // I - Actual page header - cups_page_header2_t *expected) // I - Expected page header + cups_page_header_t *header, // I - Actual page header + cups_page_header_t *expected) // I - Expected page header { int i; // Looping var diff --git a/ppd/testppdfile.c b/ppd/testppdfile.c index f07cbe647..a5e750064 100644 --- a/ppd/testppdfile.c +++ b/ppd/testppdfile.c @@ -10,6 +10,7 @@ // #include +#include #include #include #include @@ -65,7 +66,7 @@ int main(int argc, // I - Number of command-line args int result; // Whether PPD pased or not - file_array = cupsArrayNew(NULL, ""); + file_array = cupsArrayNew(NULL, "", NULL, 0, NULL, NULL); for (i = 1; i < argc; i ++) if (!strcmp(argv[i], "--help")) @@ -175,8 +176,8 @@ int main(int argc, // I - Number of command-line args if (report) { - for (line = (char *)cupsArrayFirst(report); line; - line = (char *)cupsArrayNext(report)) + for (line = (char *)cupsArrayGetFirst(report); line; + line = (char *)cupsArrayGetNext(report)) puts(line); }