/*
* Simulated client test program for CUPS.
*
+ * Copyright © 2020 by Michael R Sweet
* Copyright © 2017-2019 by Apple Inc.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* Constants...
*/
-#define MAX_CLIENTS 16 /* Maximum number of client threads */
+#define MAX_CLIENTS 100 /* Maximum number of client threads */
/*
int grayscale, /* Force grayscale? */
keepfile; /* Keep temporary file? */
ipp_pstate_t printer_state; /* Current printer state */
- char printer_state_reasons[1024];
- /* Current printer-state-reasons */
+ char printer_state_reasons[1024];
+ /* Current printer-state-reasons */
int job_id; /* Job ID for submitted job */
ipp_jstate_t job_state; /* Current job state */
- char job_state_reasons[1024];
- /* Current job-state-reasons */
+ char job_state_reasons[1024];
+ /* Current job-state-reasons */
} _client_data_t;
* Local functions...
*/
-static const char *make_raster_file(ipp_t *response, int grayscale, char *tempname, size_t tempsize, const char **format);
-static void *monitor_printer(_client_data_t *data);
+static const char *make_raster_file(ipp_t *response, int grayscale, char *tempname, size_t tempsize, const char **format);
+static void *monitor_printer(_client_data_t *data);
static void *run_client(_client_data_t *data);
-static void show_attributes(const char *title, int request, ipp_t *ipp);
-static void show_capabilities(ipp_t *response);
-static void usage(void);
+static void show_attributes(const char *title, int request, ipp_t *ipp);
+static void show_capabilities(ipp_t *response);
+static void usage(void);
/*
* Figure out the the media, resolution, and color mode...
*/
- if ((attr = ippFindAttribute(response, "media-default", IPP_TAG_KEYWORD)) != NULL)
- {
- /*
- * Use default media...
- */
-
- media = pwgMediaForPWG(ippGetString(attr, 0, NULL));
- }
- else if ((attr = ippFindAttribute(response, "media-ready", IPP_TAG_KEYWORD)) != NULL)
+ if ((attr = ippFindAttribute(response, "media-ready", IPP_TAG_KEYWORD)) != NULL)
{
/*
* Use ready media...
else
media = pwgMediaForPWG(ippGetString(attr, 0, NULL));
}
+ else if ((attr = ippFindAttribute(response, "media-default", IPP_TAG_KEYWORD)) != NULL)
+ {
+ /*
+ * Use default media...
+ */
+
+ media = pwgMediaForPWG(ippGetString(attr, 0, NULL));
+ }
else
{
puts("No default or ready media reported by printer, aborting.");
header.cupsInteger[CUPS_RASTER_PWG_TotalPageCount] = 1;
- if (header.cupsWidth > (4 * header.HWResolution[0]))
+ if (header.cupsWidth > (2 * header.HWResolution[0]))
{
xoff = header.HWResolution[0] / 2;
yoff = header.HWResolution[1] / 2;
}
else
{
- xoff = 0;
- yoff = 0;
+ xoff = header.HWResolution[0] / 4;
+ yoff = header.HWResolution[1] / 4;
}
xrep = (header.cupsWidth - 2 * xoff) / 140;
ipp_attribute_t *attr; /* Attribute in response */
static const char * const pattrs[] = /* Printer attributes we are interested in */
{
- "job-template",
- "printer-defaults",
- "printer-description",
- "media-col-database",
- "media-col-ready"
+ "all",
+ "media-col-database"
};