Skip to content

Commit

Permalink
libcupsfilters: Let raster driver functions use log function
Browse files Browse the repository at this point in the history
libcupsfilters contains a lot of functions for raster drivers, to
convert raster formats, handle colors with lookup tables (LUTs),
... See cupsfilters/driver.h for the API. These functions, originally
designed for the use in CUPS filters, had logged directly to
stderr. Now to allow easy use of them in filter functions we have
changed all logging to go into a provided filter function and
appropriately added parameters to the call schemes of the functions
which need it to supply the log function.

Also updated the printer drivers rastertopclx and rastertoescpx and
also the test programs testcmyk and testdither to use the changed API.
  • Loading branch information
tillkamppeter committed Mar 22, 2022
1 parent 3b80c89 commit 530783e
Show file tree
Hide file tree
Showing 9 changed files with 330 additions and 221 deletions.
28 changes: 19 additions & 9 deletions cupsfilters/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ cupsFindAttr(ppd_file_t *ppd, /* I - PPD file */
const char *media, /* I - Media type */
const char *resolution, /* I - Resolution */
char *spec, /* O - Final selection string */
int specsize) /* I - Size of string buffer */
int specsize, /* I - Size of string buffer */
filter_logfunc_t log, /* I - Log function */
void *ld) /* I - Log function data */
{
ppd_attr_t *attr; /* Attribute */

Expand All @@ -63,41 +65,49 @@ cupsFindAttr(ppd_file_t *ppd, /* I - PPD file */
*/

snprintf(spec, specsize, "%s.%s.%s", colormodel, media, resolution);
fprintf(stderr, "DEBUG2: Looking for \"*%s %s\"...\n", name, spec);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s %s\"...", name, spec);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

snprintf(spec, specsize, "%s.%s", colormodel, resolution);
fprintf(stderr, "DEBUG2: Looking for \"*%s %s\"...\n", name, spec);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s %s\"...", name, spec);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

snprintf(spec, specsize, "%s", colormodel);
fprintf(stderr, "DEBUG2: Looking for \"*%s %s\"...\n", name, spec);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s %s\"...", name, spec);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

snprintf(spec, specsize, "%s.%s", media, resolution);
fprintf(stderr, "DEBUG2: Looking for \"*%s %s\"...\n", name, spec);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s %s\"...", name, spec);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

snprintf(spec, specsize, "%s", media);
fprintf(stderr, "DEBUG2: Looking for \"*%s %s\"...\n", name, spec);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s %s\"...", name, spec);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

snprintf(spec, specsize, "%s", resolution);
fprintf(stderr, "DEBUG2: Looking for \"*%s %s\"...\n", name, spec);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s %s\"...", name, spec);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

spec[0] = '\0';
fprintf(stderr, "DEBUG2: Looking for \"*%s\"...\n", name);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"Looking for \"*%s\"...", name);
if ((attr = ppdFindAttr(ppd, name, spec)) != NULL && attr->value != NULL)
return (attr);

fprintf(stderr, "DEBUG2: No instance of \"*%s\" found...\n", name);
if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
"No instance of \"*%s\" found...", name);

return (NULL);
}
Expand Down
Loading

0 comments on commit 530783e

Please sign in to comment.