/* Private function prototypes */
-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,
+static int _get_colord_printer_cm_status (filter_data_t *data);
+static char *_get_colord_printer_id (filter_data_t *data);
+static int _get_colord_profile (filter_data_t *data,
char **profile,
ppd_file_t *ppd);
static char *_get_ppd_icc_fallback (filter_data_t *data,
/* Get printer color management status from the system's color manager */
int
-cmIsPrinterCmDisabled( filter_data_t *data,
- const char *printer_name) /* dest name */
+cmIsPrinterCmDisabled(filter_data_t *data)
{
filter_logfunc_t log = data->logfunc;
void *ld = data->logdata;
/* Request color management status from colord */
- is_cm_off = _get_colord_printer_cm_status(data, printer_name);
+ is_cm_off = _get_colord_printer_cm_status(data);
if (is_cm_off)
if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
/* Get printer ICC profile from the system's color manager */
int
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 */
{
/* Request a profile from colord */
- profile_set = _get_colord_profile(data, printer_name, icc_profile, ppd);
+ profile_set = _get_colord_profile(data, icc_profile, ppd);
if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Color Manager: ICC Profile: %s", *icc_profile ?
*icc_profile : "None");
char *
-_get_colord_printer_id( filter_data_t *data,
- const char *printer_name) /* Dest name */
+_get_colord_printer_id( filter_data_t *data)
{
filter_logfunc_t log = data->logfunc;
void *ld = data->logdata;
- if (printer_name == NULL) {
+ if (data->printer == NULL) {
if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Color Manager: Invalid printer name.");
return 0;
/* Create printer id string for colord */
char* printer_id = (char*)malloc(CM_MAX_FILE_LENGTH);
- snprintf (printer_id, CM_MAX_FILE_LENGTH, "cups-%s", printer_name);
+ snprintf (printer_id, CM_MAX_FILE_LENGTH, "cups-%s", data->printer);
return printer_id;
int
-_get_colord_printer_cm_status( filter_data_t *data,
- const char *printer_name) /* Dest name */
+_get_colord_printer_cm_status( filter_data_t *data)
{
filter_logfunc_t log = data->logfunc;
void *ld = data->logdata;
/* If invalid input, we leave color management alone */
- if (printer_name == NULL) {
+ if (data->printer == NULL) {
if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Color Manager: Invalid printer name.");
return 0;
- } else if (!strcmp(printer_name, "(null)"))
+ } else if (!strcmp(data->printer, "(null)"))
return 0;
int is_printer_cm_disabled = 0; /* color management status flag */
/* Check if device is inhibited/disabled in colord */
- printer_id = _get_colord_printer_id(data, printer_name);
+ printer_id = _get_colord_printer_id(data);
is_printer_cm_disabled = colord_get_inhibit_for_device_id (data, printer_id);
if (printer_id != NULL)
int
_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) {
+ if (data->printer == NULL || profile == 0) {
if(log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Color Manager: Invalid input - Unable to find profile.");
return -1;
qualifier = colord_get_qualifier_for_ppd(ppd);
if (qualifier != NULL) {
- printer_id = _get_colord_printer_id(data, printer_name);
+ printer_id = _get_colord_printer_id(data);
/* Get profile from colord using qualifiers */
icc_profile = colord_get_profile_for_device_id (data,
(const char *)printer_id,
extern
-cm_calibration_t cmGetCupsColorCalibrateMode ( filter_data_t *data,
+cm_calibration_t cmGetCupsColorCalibrateMode (filter_data_t *data,
cups_option_t *options,
int num_options);
extern int cmGetPrinterIccProfile (filter_data_t *data,
- const char *printer_id,
char **icc_profile,
ppd_file_t *ppd);
-extern int cmIsPrinterCmDisabled (filter_data_t *data,
- const char *printer_id);
+extern int cmIsPrinterCmDisabled (filter_data_t *data);
extern double* cmGammaAdobeRgb (void);
extern double* cmGammaSGray (void);
return status;
}
-#if 0
-static char *
-get_ppd_icc_fallback (ppd_file_t *ppd,
- char **qualifier,
- filter_logfunc_t log,
- void *ld)
-{
- char full_path[1024];
- char *icc_profile = NULL;
- char qualifer_tmp[1024];
- const char *profile_key;
- ppd_attr_t *attr;
- char *datadir;
-
- /* get profile attr, falling back to CUPS */
- profile_key = "APTiogaProfile";
- attr = ppdFindAttr(ppd, profile_key, NULL);
- if (attr == NULL) {
- profile_key = "cupsICCProfile";
- attr = ppdFindAttr(ppd, profile_key, NULL);
- }
-
- /* create a string for a quick comparion */
- snprintf(qualifer_tmp, sizeof(qualifer_tmp),
- "%s.%s.%s",
- qualifier[0],
- qualifier[1],
- qualifier[2]);
-
- /* neither */
- if (attr == NULL) {
- if (log) log(ld, FILTER_LOGLEVEL_INFO,
- "ghostscript: no profiles specified in PPD");
- goto out;
- }
-
- if ((datadir = getenv("CUPS_DATADIR")) == NULL)
- datadir = CUPS_DATADIR;
-
- /* try to find a profile that matches the qualifier exactly */
- for (;attr != NULL; attr = ppdFindNextAttr(ppd, profile_key, NULL)) {
- if (log) log(ld, FILTER_LOGLEVEL_INFO,
- "ghostscript: found profile %s in PPD with qualifier '%s'",
- attr->value, attr->spec);
-
- /* invalid entry */
- if (attr->spec == NULL || attr->value == NULL)
- continue;
-
- /* expand to a full path if not already specified */
- if (attr->value[0] != '/')
- snprintf(full_path, sizeof(full_path),
- "%s/profiles/%s", datadir, attr->value);
- else
- strncpy(full_path, attr->value, sizeof(full_path));
-
- /* check the file exists */
- if (access(full_path, 0)) {
- if (log) log(ld, FILTER_LOGLEVEL_INFO,
- "ghostscript: found profile %s in PPD that does not exist",
- full_path);
- continue;
- }
-
- /* matches the qualifier */
- if (strcmp(qualifer_tmp, attr->spec) == 0) {
- icc_profile = strdup(full_path);
- goto out;
- }
- }
-
- /* no match */
- if (attr == NULL) {
- if (log) log(ld, FILTER_LOGLEVEL_INFO,
- "ghostscript: no profiles in PPD for qualifier '%s'",
- qualifer_tmp);
- goto out;
- }
-
-out:
- return icc_profile;
-}
-#endif /* 0 */
-
/*
* 'ghostscript()' - Filter function to use Ghostscript for print
* data conversions
if (cm_calibrate == CM_CALIBRATION_ENABLED)
cm_disabled = 1;
else
- cm_disabled = cmIsPrinterCmDisabled(data, data->printer);
+ cm_disabled = cmIsPrinterCmDisabled(data);
if (!cm_disabled)
- cmGetPrinterIccProfile(data, data->printer, &icc_profile, ppd);
+ cmGetPrinterIccProfile(data, &icc_profile, ppd);
/* Ghostscript parameters */
gs_args = cupsArrayNew(NULL, NULL);
if (cm_calibrate == CM_CALIBRATION_ENABLED)
cm_disabled = 1;
else
- cm_disabled = cmIsPrinterCmDisabled(data, data->printer);
+ cm_disabled = cmIsPrinterCmDisabled(data);
/*
* Choose the appropriate colorspace...
if (cm_calibrate == CM_CALIBRATION_ENABLED)
cm_disabled = 1;
else
- cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER"));
+ cm_disabled = cmIsPrinterCmDisabled(data);
if (!cm_disabled)
- cmGetPrinterIccProfile(data, getenv("PRINTER"), &icc_profile, ppd);
+ cmGetPrinterIccProfile(data, &icc_profile, ppd);
/* Find print-rendering-intent */
if (doc->colour_profile.cm_calibrate == CM_CALIBRATION_ENABLED)
doc->colour_profile.cm_disabled = 1;
else
- doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data, data->printer);
+ doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data);
if (!doc->colour_profile.cm_disabled)
- cmGetPrinterIccProfile(data, data->printer, &profile, doc->ppd);
+ cmGetPrinterIccProfile(data, &profile, doc->ppd);
if (profile != NULL) {
doc->colour_profile.colorProfile = cmsOpenProfileFromFile(profile,"r");
if (doc->colour_profile.cm_calibrate == CM_CALIBRATION_ENABLED)
doc->colour_profile.cm_disabled = 1;
else
- doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data, data->printer);
+ doc->colour_profile.cm_disabled = cmIsPrinterCmDisabled(data);
if (!doc->colour_profile.cm_disabled)
- cmGetPrinterIccProfile(data, data->printer, &profile, doc->ppd);
+ cmGetPrinterIccProfile(data, &profile, doc->ppd);
if (profile != NULL) {
doc->colour_profile.colorProfile = cmsOpenProfileFromFile(profile,"r");
if (doc->color_profile.cm_calibrate == CM_CALIBRATION_ENABLED)
doc->color_profile.cm_disabled = 1;
else
- doc->color_profile.cm_disabled = cmIsPrinterCmDisabled(data, data->printer);
+ doc->color_profile.cm_disabled = cmIsPrinterCmDisabled(data);
if (!doc->color_profile.cm_disabled)
- cmGetPrinterIccProfile(data, data->printer, &profile, doc->ppd);
+ cmGetPrinterIccProfile(data, &profile, doc->ppd);
if (profile != NULL) {
doc->color_profile.colorProfile = cmsOpenProfileFromFile(profile,"r");
cm_calibrate == CM_CALIBRATION_ENABLED)
doc.cm_disabled = 1;
else
- doc.cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER"));
+ doc.cm_disabled = cmIsPrinterCmDisabled(data);
if (outformat == OUTPUT_FORMAT_PCLM && data->ppd == NULL
&& printer_attrs == NULL )
if (strlen(getenv("PPD")) > 2047)
job->ppdfile[2047] = '\0';
spooler = SPOOLER_CUPS;
- if (getenv("CUPS_SERVERBIN")) {
- strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"),
- sizeof(cupsfilterpath) - 1);
- if (strlen(getenv("CUPS_SERVERBIN")) > PATH_MAX-1)
- cupsfilterpath[PATH_MAX-1] = '\0';
+ strncpy_omit(job->printer, getenv("PRINTER"), 256, omit_shellescapes);
+ if (getenv("CUPS_SERVERBIN")) {
+ strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"),
+ sizeof(cupsfilterpath) - 1);
+ if (strlen(getenv("CUPS_SERVERBIN")) > PATH_MAX-1)
+ cupsfilterpath[PATH_MAX-1] = '\0';
}
}
- /* Check status of printer color management from the color manager */
- 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 <string>". */
if (spooler != SPOOLER_CUPS) {
}
+ /* Check status of printer color management from the color manager */
+ data->printer = job->printer;
+ cm_disabled = cmIsPrinterCmDisabled(data);
+
_log("'CM Color Calibration' Mode in SPOOLER-LESS: %s\n", cm_calibrate ?
"Activated" : "Off");
_log("INFO: Using qualifer: '%s.%s.%s'\n",
qualifier[0], qualifier[1], qualifier[2]);
- cmGetPrinterIccProfile(data, getenv("PRINTER"),
- (char **)&icc_profile, 0);
+ cmGetPrinterIccProfile(data, (char **)&icc_profile, 0);
/* fall back to PPD */
if (icc_profile == NULL) {
*/
void
-StartPage(filter_data_t *data, /* I - filter data */
+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 */
if (cm_calibrate == CM_CALIBRATION_ENABLED)
cm_disabled = 1;
else
- cm_disabled = cmIsPrinterCmDisabled(data, getenv("PRINTER"));
+ cm_disabled = cmIsPrinterCmDisabled(data);
if (ppd && !cm_disabled)
{
*/
filter_data_t temp;
filter_data_t *data = &temp;
+ data->printer = getenv("PRINTER");
data->logdata = NULL;
data->logfunc = cups_logfunc;
if (argc < 6 || argc > 7)