From f8df996a76ed770fc01bb8f7096031874f945e67 Mon Sep 17 00:00:00 2001 From: suraj kulriya <45878143+surajkulriya@users.noreply.github.com> Date: Thu, 26 Aug 2021 19:49:55 +0530 Subject: [PATCH] libcupsfilters: For color management functions use log functions --- cupsfilters/colord.c | 119 ++++++++++++++++++++---------- cupsfilters/colord.h | 7 +- cupsfilters/colormanager.c | 101 +++++++++++++++++-------- cupsfilters/colormanager.h | 11 ++- cupsfilters/ghostscript.c | 6 +- cupsfilters/imagetoraster.c | 4 +- cupsfilters/mupdftoraster.c | 6 +- cupsfilters/pdftoraster.cxx | 12 +-- cupsfilters/pwgtoraster.c | 6 +- cupsfilters/rastertopdf.cpp | 4 +- filter/foomatic-rip/foomaticrip.c | 10 ++- filter/rastertopclx.c | 18 +++-- 12 files changed, 199 insertions(+), 105 deletions(-) diff --git a/cupsfilters/colord.c b/cupsfilters/colord.c index ad2f55c9d..f5e3e47eb 100644 --- a/cupsfilters/colord.c +++ b/cupsfilters/colord.c @@ -31,7 +31,7 @@ MIT Open Source License - http://www.opensource.org/ #include #include #include - +#include #ifdef HAVE_DBUS #include #endif @@ -112,9 +112,12 @@ colord_get_qualifier_for_ppd (ppd_file_t *ppd) #ifdef HAVE_DBUS static char * -get_filename_for_profile_path (DBusConnection *con, +get_filename_for_profile_path ( filter_data_t *data, + DBusConnection *con, const char *object_path) { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; char *filename = NULL; const char *interface = "org.freedesktop.ColorManager.Profile"; const char *property = "Filename"; @@ -136,13 +139,15 @@ get_filename_for_profile_path (DBusConnection *con, /* send syncronous */ dbus_error_init(&error); - fprintf(stderr, "DEBUG: Calling %s.Get(%s)\n", interface, property); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "Calling %s.Get(%s)", interface, property); + reply = dbus_connection_send_with_reply_and_block(con, message, -1, &error); if (reply == NULL) { - fprintf(stderr, "DEBUG: Failed to send: %s:%s\n", + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "DEBUG: Failed to send: %s:%s", error.name, error.message); dbus_error_free(&error); goto out; @@ -151,7 +156,8 @@ get_filename_for_profile_path (DBusConnection *con, /* get reply data */ dbus_message_iter_init(reply, &args); if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_VARIANT) { - fprintf(stderr, "DEBUG: Incorrect reply type\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG,"Incorrect reply type"); + goto out; } @@ -167,10 +173,13 @@ out: } static char * -get_profile_for_device_path (DBusConnection *con, +get_profile_for_device_path ( filter_data_t *data, + DBusConnection *con, const char *object_path, const char **split) { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; char **key = NULL; char *profile = NULL; char str[256]; @@ -224,13 +233,13 @@ get_profile_for_device_path (DBusConnection *con, /* send syncronous */ dbus_error_init(&error); - fprintf(stderr, "DEBUG: Calling GetProfileForQualifiers(%s...)\n", key[0]); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "Calling GetProfileForQualifiers(%s...)", key[0]); reply = dbus_connection_send_with_reply_and_block(con, message, -1, &error); if (reply == NULL) { - fprintf(stderr, "DEBUG: Failed to send: %s:%s\n", + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "DEBUG: Failed to send: %s:%s", error.name, error.message); dbus_error_free(&error); goto out; @@ -239,14 +248,14 @@ get_profile_for_device_path (DBusConnection *con, /* get reply data */ dbus_message_iter_init(reply, &args); if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) { - fprintf(stderr, "DEBUG: Incorrect reply type\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "Incorrect reply type"); goto out; } dbus_message_iter_get_basic(&args, &tmp); - fprintf(stderr, "DEBUG: Found profile %s\n", tmp); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "Found profile %s", tmp); /* get filename */ - profile = get_filename_for_profile_path(con, tmp); + profile = get_filename_for_profile_path(data, con, tmp); out: if (message != NULL) @@ -262,9 +271,12 @@ out: } static char * -get_device_path_for_device_id (DBusConnection *con, +get_device_path_for_device_id ( filter_data_t *data, + DBusConnection *con, const char *device_id) { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; char *device_path = NULL; const char *device_path_tmp; DBusError error; @@ -281,13 +293,13 @@ get_device_path_for_device_id (DBusConnection *con, /* send syncronous */ dbus_error_init(&error); - fprintf(stderr, "DEBUG: Calling FindDeviceById(%s)\n", device_id); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "Calling FindDeviceById(%s)", device_id); reply = dbus_connection_send_with_reply_and_block(con, message, -1, &error); if (reply == NULL) { - fprintf(stderr, "DEBUG: Failed to send: %s:%s\n", + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "DEBUG: Failed to send: %s:%s", error.name, error.message); dbus_error_free(&error); goto out; @@ -296,11 +308,13 @@ get_device_path_for_device_id (DBusConnection *con, /* get reply data */ dbus_message_iter_init(reply, &args); if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) { - fprintf(stderr, "DEBUG: Incorrect reply type\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Incorrect reply type"); goto out; } dbus_message_iter_get_basic(&args, &device_path_tmp); - fprintf(stderr, "DEBUG: Found device %s\n", device_path_tmp); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Found device %s", device_path_tmp); device_path = strdup(device_path_tmp); out: if (message != NULL) @@ -311,15 +325,19 @@ out: } char * -colord_get_profile_for_device_id (const char *device_id, +colord_get_profile_for_device_id (filter_data_t *data, + const char *device_id, const char **qualifier_tuple) { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; DBusConnection *con = NULL; char *device_path = NULL; char *filename = NULL; if (device_id == NULL) { - fprintf(stderr, "DEBUG: No colord device ID available\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "No colord device ID available"); goto out; } @@ -327,24 +345,28 @@ colord_get_profile_for_device_id (const char *device_id, con = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (con == NULL) { // If D-Bus is not reachable, gracefully leave and ignore error - //fprintf(stderr, "ERROR: Failed to connect to system bus\n"); +// if(log) log(ld, FILTER_LOGLEVEL_ERROR, +// "Failed to connect to system bus"); goto out; } /* find the device */ - device_path = get_device_path_for_device_id (con, device_id); + device_path = get_device_path_for_device_id (data, con, device_id); if (device_path == NULL) { - fprintf(stderr, "DEBUG: Failed to get device %s\n", device_id); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Failed to get device %s", device_id); goto out; } /* get the best profile for the device */ - filename = get_profile_for_device_path(con, device_path, qualifier_tuple); + filename = get_profile_for_device_path(data, con, device_path, qualifier_tuple); if (filename == NULL) { - fprintf(stderr, "DEBUG: Failed to get profile filename for %s\n", device_id); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Failed to get profile filename for %s", device_id); goto out; } - fprintf(stderr, "DEBUG: Use profile filename: '%s'\n", filename); + if(log) log(ld, FILTER_LOGLEVEL_ERROR, + "Use profile filename: '%s'", filename); out: free(device_path); if (con != NULL) @@ -353,8 +375,11 @@ out: } int -get_profile_inhibitors (DBusConnection *con, const char *object_path) +get_profile_inhibitors ( filter_data_t *data, + DBusConnection *con, const char *object_path) { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; char *tmp; const char *interface = "org.freedesktop.ColorManager.Device"; const char *property = "ProfilingInhibitors"; @@ -377,13 +402,15 @@ get_profile_inhibitors (DBusConnection *con, const char *object_path) /* send syncronous */ dbus_error_init(&error); - fprintf(stderr, "DEBUG: Calling %s.Get(%s)\n", interface, property); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Calling %s.Get(%s)", interface, property); reply = dbus_connection_send_with_reply_and_block(con, message, -1, &error); if (reply == NULL) { - fprintf(stderr, "DEBUG: Failed to send: %s:%s\n", + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Failed to send: %s:%s", error.name, error.message); dbus_error_free(&error); goto out; @@ -392,7 +419,8 @@ get_profile_inhibitors (DBusConnection *con, const char *object_path) /* get reply data */ dbus_message_iter_init(reply, &args); if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_VARIANT) { - fprintf(stderr, "DEBUG: Incorrect reply type\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Incorrect reply type"); goto out; } @@ -401,7 +429,8 @@ get_profile_inhibitors (DBusConnection *con, const char *object_path) dbus_message_iter_recurse(&sub2, &sub); while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) { dbus_message_iter_get_basic(&sub, &tmp); - fprintf(stderr, "DEBUG: Inhibitor %s exists\n", tmp); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "DEBUG: Inhibitor %s exists", tmp); dbus_message_iter_next(&sub); inhibitors++; } @@ -414,8 +443,11 @@ out: } int -colord_get_inhibit_for_device_id (const char *device_id) +colord_get_inhibit_for_device_id (filter_data_t *data, + const char *device_id) { + filter_logfunc_t log = data->logfunc; + void* ld = data->logdata; DBusConnection *con; char *device_path = NULL; int has_inhibitors = FALSE; @@ -424,19 +456,21 @@ colord_get_inhibit_for_device_id (const char *device_id) con = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); if (con == NULL) { // If D-Bus is not reachable, gracefully leave and ignore error - //fprintf(stderr, "ERROR: Failed to connect to system bus\n"); + if(log) log(ld, FILTER_LOGLEVEL_ERROR, + "Failed to connect to system bus"); goto out; } /* find the device */ - device_path = get_device_path_for_device_id (con, device_id); + device_path = get_device_path_for_device_id (data, con, device_id); if (device_path == NULL) { - fprintf(stderr, "DEBUG: Failed to get find device %s\n", device_id); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Failed to get find device %s", device_id); goto out; } /* get the best profile for the device */ - has_inhibitors = get_profile_inhibitors(con, device_path); + has_inhibitors = get_profile_inhibitors(data, con, device_path); out: free(device_path); if (con != NULL) @@ -447,17 +481,26 @@ out: #else char * -colord_get_profile_for_device_id (const char *device_id, +colord_get_profile_for_device_id (filter_data_t *data, + const char *device_id, const char **qualifier_tuple) { - fprintf(stderr, "WARN: not compiled with DBus support\n"); + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; + if(log) log(ld, FILTER_LOGLEVEL_WARN, + "not compiled with DBus support"); return NULL; } int -colord_get_inhibit_for_device_id (const char *device_id) +colord_get_inhibit_for_device_id (filter_data_t *data, + const char *device_id) { - fprintf(stderr, "WARN: not compiled with DBus support\n"); + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; + if(log) log(ld, FILTER_LOGLEVEL_WARN, + "not compiled with DBus support"); + return 0; } diff --git a/cupsfilters/colord.h b/cupsfilters/colord.h index bf07dc47c..f4867e595 100644 --- a/cupsfilters/colord.h +++ b/cupsfilters/colord.h @@ -36,11 +36,14 @@ extern "C" { #include #include +#include char **colord_get_qualifier_for_ppd (ppd_file_t *ppd); -char *colord_get_profile_for_device_id (const char *device_id, +char *colord_get_profile_for_device_id (filter_data_t *data, + const char *device_id, const char **qualifier_tuple); -int colord_get_inhibit_for_device_id (const char *device_id); +int colord_get_inhibit_for_device_id ( filter_data_t *data, + const char *device_id); # ifdef __cplusplus } diff --git a/cupsfilters/colormanager.c b/cupsfilters/colormanager.c index b443718ff..2e5f72fb2 100644 --- a/cupsfilters/colormanager.c +++ b/cupsfilters/colormanager.c @@ -28,6 +28,7 @@ MIT Open Source License - http://www.opensource.org/ #include "colormanager.h" #include +#include //#include @@ -35,12 +36,16 @@ MIT Open Source License - http://www.opensource.org/ /* Private function prototypes */ -static int _get_colord_printer_cm_status (const char *printer_name); -static char *_get_colord_printer_id (const char *printer_name); -static int _get_colord_profile (const char *printer_name, +static int _get_colord_printer_cm_status (filter_data_t *data, + const char *printer_name); +static char *_get_colord_printer_id (filter_data_t *data, + const char *printer_name); +static int _get_colord_profile (filter_data_t *data, + const char *printer_name, char **profile, ppd_file_t *ppd); -static char *_get_ppd_icc_fallback (ppd_file_t *ppd, +static char *_get_ppd_icc_fallback (filter_data_t *data, + ppd_file_t *ppd, char **qualifier); @@ -66,17 +71,20 @@ double blackpoint_default[3] = {0.0, 0.0, 0.0}; /* Get printer color management status from the system's color manager */ int -cmIsPrinterCmDisabled(const char *printer_name) /* dest name */ +cmIsPrinterCmDisabled( filter_data_t *data, + const char *printer_name) /* dest name */ { - + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; int is_cm_off = 0; /* color management status flag */ /* Request color management status from colord */ - is_cm_off = _get_colord_printer_cm_status(printer_name); + is_cm_off = _get_colord_printer_cm_status(data, printer_name); if (is_cm_off) - fprintf(stderr,"DEBUG: Color Manager: Color management disabled by OS.\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Color Manager: Color management disabled by OS."); return is_cm_off; @@ -85,18 +93,20 @@ cmIsPrinterCmDisabled(const char *printer_name) /* dest name */ /* Get printer ICC profile from the system's color manager */ int -cmGetPrinterIccProfile(const char *printer_name, /* Printer name (usually "dest" name) */ +cmGetPrinterIccProfile(filter_data_t *data, + const char *printer_name, /* Printer name (usually "dest" name) */ char **icc_profile, /* ICC Profile Path */ ppd_file_t *ppd) /* Optional PPD file for fallback profile */ { - + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; int profile_set = 0; /* 'is profile found' flag */ /* Request a profile from colord */ - profile_set = _get_colord_profile(printer_name, icc_profile, ppd); - - fprintf(stderr, "DEBUG: Color Manager: ICC Profile: %s\n", *icc_profile ? + profile_set = _get_colord_profile(data, printer_name, icc_profile, ppd); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "DEBUG: Color Manager: ICC Profile: %s\n", *icc_profile ? *icc_profile : "None"); return profile_set; @@ -106,10 +116,13 @@ cmGetPrinterIccProfile(const char *printer_name, /* Printer name (usually "dest /* Find the "cm-calibration" CUPS option */ cm_calibration_t -cmGetCupsColorCalibrateMode(cups_option_t *options, /* Options from CUPS */ +cmGetCupsColorCalibrateMode(filter_data_t *data, + cups_option_t *options, /* Options from CUPS */ int num_options) /* Options from CUPS */ { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; cm_calibration_t status; /* color management status */ @@ -119,7 +132,8 @@ cmGetCupsColorCalibrateMode(cups_option_t *options, /* Options from CUPS */ else status = CM_CALIBRATION_DISABLED; - fprintf(stderr, "DEBUG: Color Manager: %s\n", status ? + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "DEBUG: Color Manager: %s", status ? "Calibration Mode/Enabled" : "Calibration Mode/Off"); return status; @@ -178,11 +192,15 @@ double *cmBlackPointDefault(void) char * -_get_colord_printer_id(const char *printer_name) /* Dest name */ +_get_colord_printer_id( filter_data_t *data, + const char *printer_name) /* Dest name */ { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; if (printer_name == NULL) { - fprintf(stderr, "DEBUG: Color Manager: Invalid printer name.\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Color Manager: Invalid printer name."); return 0; } @@ -196,12 +214,17 @@ _get_colord_printer_id(const char *printer_name) /* Dest name */ int -_get_colord_printer_cm_status(const char *printer_name) /* Dest name */ +_get_colord_printer_cm_status( filter_data_t *data, + const char *printer_name) /* Dest name */ { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; + /* If invalid input, we leave color management alone */ if (printer_name == NULL) { - fprintf(stderr, "DEBUG: Color Manager: Invalid printer name.\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Color Manager: Invalid printer name."); return 0; } else if (!strcmp(printer_name, "(null)")) return 0; @@ -211,8 +234,8 @@ _get_colord_printer_cm_status(const char *printer_name) /* Dest name */ /* Check if device is inhibited/disabled in colord */ - printer_id = _get_colord_printer_id(printer_name); - is_printer_cm_disabled = colord_get_inhibit_for_device_id (printer_id); + printer_id = _get_colord_printer_id(data, printer_name); + is_printer_cm_disabled = colord_get_inhibit_for_device_id (data, printer_id); if (printer_id != NULL) free(printer_id); @@ -222,13 +245,18 @@ _get_colord_printer_cm_status(const char *printer_name) /* Dest name */ } int -_get_colord_profile(const char *printer_name, /* Dest name */ +_get_colord_profile(filter_data_t *data, + const char *printer_name, /* Dest name */ char **profile, /* Requested icc profile path */ ppd_file_t *ppd) /* PPD file */ { + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; + if (printer_name == NULL || profile == 0) { - fprintf(stderr, "DEBUG: Color Manager: Invalid input - Unable to find profile.\n"); + if(log) log(ld, FILTER_LOGLEVEL_DEBUG, + "Color Manager: Invalid input - Unable to find profile."); return -1; } @@ -242,9 +270,10 @@ _get_colord_profile(const char *printer_name, /* Dest name */ qualifier = colord_get_qualifier_for_ppd(ppd); if (qualifier != NULL) { - printer_id = _get_colord_printer_id(printer_name); + printer_id = _get_colord_printer_id(data, printer_name); /* Get profile from colord using qualifiers */ - icc_profile = colord_get_profile_for_device_id ((const char *)printer_id, + icc_profile = colord_get_profile_for_device_id (data, + (const char *)printer_id, (const char **)qualifier); } @@ -252,7 +281,7 @@ _get_colord_profile(const char *printer_name, /* Dest name */ is_profile_set = 1; else if (ppd) { /* Get optional fallback PPD profile */ - icc_profile = _get_ppd_icc_fallback(ppd, qualifier); + icc_profile = _get_ppd_icc_fallback(data, ppd, qualifier); if (icc_profile) is_profile_set = 1; } @@ -286,8 +315,11 @@ _get_colord_profile(const char *printer_name, /* Dest name */ /* From gstoraster */ char * -_get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) +_get_ppd_icc_fallback (filter_data_t *data, ppd_file_t *ppd, char **qualifier) { + + filter_logfunc_t log = data->logfunc; + void *ld = data->logdata; char full_path[1024]; char *icc_profile = NULL; char qualifer_tmp[1024]; @@ -311,14 +343,17 @@ _get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) /* neither */ if (attr == NULL) { - fprintf(stderr, "INFO: Color Manager: no profiles specified in PPD\n"); + if(log) log(ld, FILTER_LOGLEVEL_INFO, + "Color Manager: no profiles specified in PPD"); + goto out; } /* try to find a profile that matches the qualifier exactly */ for (;attr != NULL; attr = ppdFindNextAttr(ppd, profile_key, NULL)) { - fprintf(stderr, "INFO: Color Manager: found profile %s in PPD with qualifier '%s'\n", - attr->value, attr->spec); + if(log) log(ld, FILTER_LOGLEVEL_INFO, + "Color Manager: found profile %s in PPD with qualifier '%s'\n", + attr->value, attr->spec); /* invalid entry */ if (attr->spec == NULL || attr->value == NULL) @@ -336,7 +371,8 @@ _get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) /* check the file exists */ if (access(full_path, 0)) { - fprintf(stderr, "INFO: Color Manager: found profile %s in PPD that does not exist\n", + if(log) log(ld, FILTER_LOGLEVEL_INFO, + "Color Manager: found profile %s in PPD that does not exist\n", full_path); continue; } @@ -350,7 +386,8 @@ _get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) /* no match */ if (attr == NULL) { - fprintf(stderr, "INFO: Color Manager: no profiles in PPD for qualifier '%s'\n", + if(log) log(ld, FILTER_LOGLEVEL_INFO, + "Color Manager: no profiles in PPD for qualifier '%s'\n", qualifer_tmp); goto out; } diff --git a/cupsfilters/colormanager.h b/cupsfilters/colormanager.h index c5ddc9b4d..ca796fa4b 100644 --- a/cupsfilters/colormanager.h +++ b/cupsfilters/colormanager.h @@ -39,7 +39,7 @@ extern "C" { #include #include - +#include #define CM_CALIBRATION_STRING "cm-calibration" /* String for "Color Calibration Mode" */ @@ -60,14 +60,17 @@ typedef enum cm_calibration_e extern -cm_calibration_t cmGetCupsColorCalibrateMode (cups_option_t *options, +cm_calibration_t cmGetCupsColorCalibrateMode ( filter_data_t *data, + cups_option_t *options, int num_options); -extern int cmGetPrinterIccProfile (const char *printer_id, +extern int cmGetPrinterIccProfile (filter_data_t *data, + const char *printer_id, char **icc_profile, ppd_file_t *ppd); -extern int cmIsPrinterCmDisabled (const char *printer_id); +extern int cmIsPrinterCmDisabled (filter_data_t *data, + const char *printer_id); extern double* cmGammaAdobeRgb (void); extern double* cmGammaSGray (void); diff --git a/cupsfilters/ghostscript.c b/cupsfilters/ghostscript.c index 9ed9d1d0e..6a5195bca 100644 --- a/cupsfilters/ghostscript.c +++ b/cupsfilters/ghostscript.c @@ -1058,15 +1058,15 @@ ghostscript(int inputfd, /* I - File descriptor input stream */ "Print rendering intent = %s", h.cupsRenderingIntent); /* Check status of color management in CUPS */ - cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (cm_calibrate == CM_CALIBRATION_ENABLED) cm_disabled = 1; else - cm_disabled = cmIsPrinterCmDisabled(data->printer); + cm_disabled = cmIsPrinterCmDisabled(data, data->printer); if (!cm_disabled) - cmGetPrinterIccProfile(data->printer, &icc_profile, ppd); + cmGetPrinterIccProfile(data, data->printer, &icc_profile, ppd); /* Ghostscript parameters */ gs_args = cupsArrayNew(NULL, NULL); diff --git a/cupsfilters/imagetoraster.c b/cupsfilters/imagetoraster.c index f0d413b60..35305496c 100644 --- a/cupsfilters/imagetoraster.c +++ b/cupsfilters/imagetoraster.c @@ -646,12 +646,12 @@ if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "doc.color = %d", doc.Color); if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "Resolution = %s", resolution); /* support the "cm-calibration" option */ - cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (cm_calibrate == CM_CALIBRATION_ENABLED) cm_disabled = 1; else - cm_disabled = cmIsPrinterCmDisabled(getenv("PRINTER")); + cm_disabled = cmIsPrinterCmDisabled(data, data->printer); /* * Choose the appropriate colorspace... diff --git a/cupsfilters/mupdftoraster.c b/cupsfilters/mupdftoraster.c index 4349e0c2a..5e759bd01 100644 --- a/cupsfilters/mupdftoraster.c +++ b/cupsfilters/mupdftoraster.c @@ -343,15 +343,15 @@ mupdftoraster (int inputfd, /* I - File descriptor input stream */ empty = 1; /* Check status of color management in CUPS */ - cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (cm_calibrate == CM_CALIBRATION_ENABLED) cm_disabled = 1; else - cm_disabled = cmIsPrinterCmDisabled(getenv("PRINTER")); + cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER")); if (!cm_disabled) - cmGetPrinterIccProfile(getenv("PRINTER"), &icc_profile, ppd); + cmGetPrinterIccProfile(data, getenv("PRINTER"), &icc_profile, ppd); /* Find print-rendering-intent */ diff --git a/cupsfilters/pdftoraster.cxx b/cupsfilters/pdftoraster.cxx index dcfa25ac5..89af88ac2 100644 --- a/cupsfilters/pdftoraster.cxx +++ b/cupsfilters/pdftoraster.cxx @@ -406,15 +406,15 @@ static void parseOpts(filter_data_t *data, } /* support the CUPS "cm-calibration" option */ - doc->colour_profile.cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + doc->colour_profile.cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (doc->colour_profile.cm_calibrate == CM_CALIBRATION_ENABLED) doc->colour_profile.cm_disabled = 1; else - doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data->printer); + doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data, data->printer); if (!doc->colour_profile.cm_disabled) - cmGetPrinterIccProfile(data->printer, &profile, doc->ppd); + cmGetPrinterIccProfile(data, data->printer, &profile, doc->ppd); if (profile != NULL) { doc->colour_profile.colorProfile = cmsOpenProfileFromFile(profile,"r"); @@ -491,15 +491,15 @@ static void parseOpts(filter_data_t *data, } /* support the CUPS "cm-calibration" option */ - doc->colour_profile.cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + doc->colour_profile.cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (doc->colour_profile.cm_calibrate == CM_CALIBRATION_ENABLED) doc->colour_profile.cm_disabled = 1; else - doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data->printer); + doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data, data->printer); if (!doc->colour_profile.cm_disabled) - cmGetPrinterIccProfile(data->printer, &profile, doc->ppd); + cmGetPrinterIccProfile(data, data->printer, &profile, doc->ppd); if (profile != NULL) { doc->colour_profile.colorProfile = cmsOpenProfileFromFile(profile,"r"); diff --git a/cupsfilters/pwgtoraster.c b/cupsfilters/pwgtoraster.c index 1364d71bc..04d8af840 100644 --- a/cupsfilters/pwgtoraster.c +++ b/cupsfilters/pwgtoraster.c @@ -381,15 +381,15 @@ static void parseOpts(filter_data_t *data, } /* support the CUPS "cm-calibration" option */ - doc->color_profile.cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + doc->color_profile.cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (doc->color_profile.cm_calibrate == CM_CALIBRATION_ENABLED) doc->color_profile.cm_disabled = 1; else - doc->color_profile.cm_disabled = cmIsPrinterCmDisabled(data->printer); + doc->color_profile.cm_disabled = cmIsPrinterCmDisabled(data, data->printer); if (!doc->color_profile.cm_disabled) - cmGetPrinterIccProfile(data->printer, &profile, doc->ppd); + cmGetPrinterIccProfile(data, data->printer, &profile, doc->ppd); if (profile != NULL) { doc->color_profile.colorProfile = cmsOpenProfileFromFile(profile,"r"); diff --git a/cupsfilters/rastertopdf.cpp b/cupsfilters/rastertopdf.cpp index 9027e9439..1d7969e13 100644 --- a/cupsfilters/rastertopdf.cpp +++ b/cupsfilters/rastertopdf.cpp @@ -1460,13 +1460,13 @@ rastertopdf(int inputfd, /* I - File descriptor input stream */ doc.iscanceleddata = icd; /* support the CUPS "cm-calibration" option */ - cm_calibrate = cmGetCupsColorCalibrateMode(data->options, data->num_options); + cm_calibrate = cmGetCupsColorCalibrateMode(data, data->options, data->num_options); if (outformat == OUTPUT_FORMAT_PCLM || cm_calibrate == CM_CALIBRATION_ENABLED) doc.cm_disabled = 1; else - doc.cm_disabled = cmIsPrinterCmDisabled(getenv("PRINTER")); + doc.cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER")); #ifdef QPDF_HAVE_PCLM if (outformat == OUTPUT_FORMAT_PCLM && data->ppd == NULL diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c index 968dd0a2c..fda687200 100644 --- a/filter/foomatic-rip/foomaticrip.c +++ b/filter/foomatic-rip/foomaticrip.c @@ -44,6 +44,7 @@ #include #include #include +#include /* Logging */ FILE* logh = NULL; @@ -763,7 +764,10 @@ int main(int argc, char** argv) int havefilter, havegstoraster; dstr_t *filelist; list_t * arglist; - + filter_data_t temp; + filter_data_t *data = &temp; + data->logdata = NULL; + data->logfunc = cups_logfunc; arglist = list_create_from_array(argc -1, (void**)&argv[1]); if (argc == 2 && (arglist_find(arglist, "--version") || arglist_find(arglist, "--help") || @@ -857,7 +861,7 @@ int main(int argc, char** argv) } /* Check status of printer color management from the color manager */ - cm_disabled = cmIsPrinterCmDisabled(getenv("PRINTER")); + cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER")); /* CUPS calls foomatic-rip only with 5 or 6 positional parameters, not with named options, like for example "-p ". */ @@ -1036,7 +1040,7 @@ int main(int argc, char** argv) _log("INFO: Using qualifer: '%s.%s.%s'\n", qualifier[0], qualifier[1], qualifier[2]); - cmGetPrinterIccProfile(getenv("PRINTER"), + cmGetPrinterIccProfile(data, getenv("PRINTER"), (char **)&icc_profile, 0); /* fall back to PPD */ diff --git a/filter/rastertopclx.c b/filter/rastertopclx.c index 99390867b..165b9c0eb 100644 --- a/filter/rastertopclx.c +++ b/filter/rastertopclx.c @@ -30,7 +30,7 @@ #include #include "pcl-common.h" #include - +#include /* * Output modes... @@ -86,7 +86,7 @@ int Canceled; /* Is the job canceled? */ * Prototypes... */ -void StartPage(ppd_file_t *ppd, cups_page_header2_t *header, int job_id, +void StartPage(filter_data_t *data, ppd_file_t *ppd, cups_page_header2_t *header, int job_id, const char *user, const char *title, int num_options, cups_option_t *options); void EndPage(ppd_file_t *ppd, cups_page_header2_t *header); @@ -105,7 +105,8 @@ int ReadLine(cups_raster_t *ras, cups_page_header2_t *header); */ void -StartPage(ppd_file_t *ppd, /* I - PPD file */ +StartPage(filter_data_t *data, /* I - filter data */ + ppd_file_t *ppd, /* I - PPD file */ cups_page_header2_t *header, /* I - Page header */ int job_id, /* I - Job ID */ const char *user, /* I - User printing job */ @@ -344,12 +345,12 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ fprintf(stderr, "DEBUG: Resolution = %s\n", resolution); /* support the "cm-calibration" option */ - cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options); + cm_calibrate = cmGetCupsColorCalibrateMode(data, options, num_options); if (cm_calibrate == CM_CALIBRATION_ENABLED) cm_disabled = 1; else - cm_disabled = cmIsPrinterCmDisabled(getenv("PRINTER")); + cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER")); if (ppd && !cm_disabled) { @@ -1817,7 +1818,10 @@ main(int argc, /* I - Number of command-line arguments */ /* * Check command-line... */ - + filter_data_t temp; + filter_data_t *data = &temp; + data->logdata = NULL; + data->logfunc = cups_logfunc; if (argc < 6 || argc > 7) { fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", @@ -1911,7 +1915,7 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "PAGE: %d %d\n", Page, header.NumCopies); fprintf(stderr, "INFO: Starting page %d.\n", Page); - StartPage(ppd, &header, atoi(argv[1]), argv[2], argv[3], + StartPage(data, ppd, &header, atoi(argv[1]), argv[2], argv[3], num_options, options); for (y = 0; y < (int)header.cupsHeight; y ++) -- 2.47.3