cups_option_t *options = NULL;
int fd, nullfd;
filter_data_t filter_data;
- filter_input_output_format_t input_output_format;
+ universal_parameter_t universal_parameters;
filter_external_cups_t ipp_backend_params;
filter_filter_in_chain_t universal_in_chain,
ipp_in_chain;
filterOpenBackAndSidePipes(&filter_data);
/* Parameters (input/output MIME types) for universal() call */
- input_output_format.input_format = "application/vnd.cups-pdf";
- input_output_format.output_format = document_format;
+ universal_parameters.input_format = "application/vnd.cups-pdf";
+ universal_parameters.output_format = document_format;
+ memset(&(universal_parameters.texttopdf_params), 0,
+ sizeof(texttopdf_parameter_t));
/* Parameters for filterExternalCUPS() call for IPP backend */
ipp_backend_params.filter = "ipp";
/* Filter chain entry for the universal() filter function call */
universal_in_chain.function = universal;
- universal_in_chain.parameters = &input_output_format;
+ universal_in_chain.parameters = &universal_parameters;
universal_in_chain.name = "Filters";
/* Filter chain entry for the IPP CUPS backend call */
typedef int (*filter_function_t)(int inputfd, int outputfd, int inputseekable,
filter_data_t *data, void *parameters);
-typedef enum filter_out_format_e { /* Possible output formats for rastertopdf()
- filter function */
+typedef enum filter_out_format_e { /* Possible output formats for filter
+ functions */
OUTPUT_FORMAT_PDF, /* PDF */
OUTPUT_FORMAT_PDF_IMAGE, /* Raster-only PDF */
OUTPUT_FORMAT_PCLM, /* PCLM */
typedef struct texttopdf_parameter_s { /* parameters container of environemnt
variables needed by texttopdf
filter function */
- const char *data_dir;
- const char *char_set;
- const char *content_type;
- const char *classification;
+ char *data_dir;
+ char *char_set;
+ char *content_type;
+ char *classification;
} texttopdf_parameter_t;
-typedef struct filter_input_output_format_s { /* Contains input and output type
- to be supplied to the universal function */
+typedef struct universal_parameter_s { /* Contains input and output
+ type to be supplied to the
+ universal function, and also
+ parameters for texttopdf() */
char *input_format;
char *output_format;
-} filter_input_output_format_t;
+ texttopdf_parameter_t texttopdf_params;
+} universal_parameter_t;
+
/*
* Prototypes...
filter_data_t *data,
void *parameters);
-/* Parameters: filter_input_output_format_t
- Contains : Input_type : CONTENT_TYPE environment variable
- Output type : FINAL_CONTENT TYPE environment variable */
+/* Parameters: universal_parameter_t
+ Contains : Input_type: CONTENT_TYPE environment variable of CUPS
+ Output type: FINAL_CONTENT TYPE environment variable of CUPS
+ texttopdf_params: parameters for texttopdf */
extern void filterSetCommonOptions(ppd_file_t *ppd,
#include "filter.h"
-#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
char output_type[256];
filter_out_format_t *outformat;
filter_filter_in_chain_t *filter, *next;
- filter_input_output_format_t input_output_format;
+ universal_parameter_t universal_parameters;
ppd_file_t *ppd;
ppd_cache_t *cache;
filter_logfunc_t log = data->logfunc;
void *ld = data->logdata;
int ret = 0;
- input_output_format = *(filter_input_output_format_t *)parameters;
- input = input_output_format.input_format;
- final_output = input_output_format.output_format;
+ universal_parameters = *(universal_parameter_t *)parameters;
+ input = universal_parameters.input_format;
+ if (input == NULL)
+ {
+ if (log) log(ld, FILTER_LOGLEVEL_ERROR,
+ "universal: No input data format supplied.");
+ return (1);
+ }
+ final_output = universal_parameters.output_format;
+ if (final_output == NULL)
+ {
+ if (log) log(ld, FILTER_LOGLEVEL_ERROR,
+ "universal: No output data format supplied.");
+ return (1);
+ }
strncpy(output, final_output, sizeof(output) - 1);
/* If we have a PPD, load it and its cache, so that we can access the
filter = malloc(sizeof(filter_filter_in_chain_t));
texttopdf_parameter_t* parameters =
(texttopdf_parameter_t *) malloc(sizeof(texttopdf_parameter_t));
- char *p;
- if ((p = getenv("CUPS_DATADIR")) != NULL)
- parameters->data_dir = p;
- else
- parameters->data_dir = CUPS_DATADIR;
-
- if ((p = getenv("CHARSET")) != NULL)
- parameters->char_set = p;
- else
- parameters->char_set = NULL;
-
- if ((p = getenv("CONTENT_TYPE")) != NULL)
- parameters->content_type = p;
- else
- parameters->content_type = NULL;
-
- if ((p = getenv("CLASSIFICATION")) != NULL)
- parameters->classification = p;
- else
- parameters->classification = NULL;
-
+ *parameters = universal_parameters.texttopdf_params;
filter->function = texttopdf;
filter->parameters = parameters;
filter->name = "texttopdf";
*/
#include <cupsfilters/filter.h>
+#include <config.h>
#include <signal.h>
char *argv[]) /* I - Command-line arguments */
{
int ret;
- filter_input_output_format_t input_output_format;
+ char *p;
+ universal_parameter_t universal_parameters;
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
signal(SIGTERM, cancel_job);
#endif /* HAVE_SIGSET */
- input_output_format.input_format = getenv("CONTENT_TYPE");
- input_output_format.output_format = getenv("FINAL_CONTENT_TYPE");
- ret = filterCUPSWrapper(argc, argv, universal, &input_output_format , &JobCanceled);
+ if ((p = getenv("CONTENT_TYPE")) != NULL)
+ universal_parameters.input_format = strdup(p);
+ else
+ universal_parameters.input_format = NULL;
+
+ if ((p = getenv("FINAL_CONTENT_TYPE")) != NULL)
+ universal_parameters.output_format = strdup(p);
+ else
+ universal_parameters.output_format = NULL;
+
+ if ((p = getenv("CUPS_DATADIR")) != NULL)
+ universal_parameters.texttopdf_params.data_dir = strdup(p);
+ else
+ universal_parameters.texttopdf_params.data_dir = strdup(CUPS_DATADIR);
+
+ if ((p = getenv("CHARSET")) != NULL)
+ universal_parameters.texttopdf_params.char_set = strdup(p);
+ else
+ universal_parameters.texttopdf_params.char_set = NULL;
+
+ universal_parameters.texttopdf_params.content_type =
+ universal_parameters.input_format;
+
+ if ((p = getenv("CLASSIFICATION")) != NULL)
+ universal_parameters.texttopdf_params.classification = strdup(p);
+ else
+ universal_parameters.texttopdf_params.classification = NULL;
+
+ ret = filterCUPSWrapper(argc, argv, universal, &universal_parameters,
+ &JobCanceled);
if (ret)
fprintf(stderr, "ERROR: universal filter failed.\n");
+ free(universal_parameters.input_format);
+ free(universal_parameters.output_format);
+ free(universal_parameters.texttopdf_params.data_dir);
+ free(universal_parameters.texttopdf_params.char_set);
+ free(universal_parameters.texttopdf_params.classification);
+
return (ret);
}