Skip to content

Commit

Permalink
New IPP and raster APIs, plus cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Sep 11, 2023
1 parent 033b403 commit 4f05fa3
Show file tree
Hide file tree
Showing 71 changed files with 14,889 additions and 13,234 deletions.
6 changes: 3 additions & 3 deletions backend/dnssd.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ browse_callback(
fprintf(stderr, "DEBUG2: browse_callback(sdRef=%p, flags=%x, "
"interfaceIndex=%u, errorCode=%d, serviceName=\"%s\", "
"regtype=\"%s\", replyDomain=\"%s\", context=%p)\n",
sdRef, flags, interfaceIndex, errorCode,
(void *)sdRef, flags, interfaceIndex, errorCode,
serviceName, regtype, replyDomain, context);

/*
Expand Down Expand Up @@ -586,7 +586,7 @@ browse_local_callback(
fprintf(stderr, "DEBUG2: browse_local_callback(sdRef=%p, flags=%x, "
"interfaceIndex=%u, errorCode=%d, serviceName=\"%s\", "
"regtype=\"%s\", replyDomain=\"%s\", context=%p)\n",
sdRef, flags, interfaceIndex, errorCode,
(void *)sdRef, flags, interfaceIndex, errorCode,
serviceName, regtype, replyDomain, context);

/*
Expand Down Expand Up @@ -1005,7 +1005,7 @@ query_callback(
"interfaceIndex=%u, errorCode=%d, fullName=\"%s\", "
"rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, "
"context=%p)\n",
sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context);
(void *)sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context);

/*
* Only process "add" data...
Expand Down
28 changes: 16 additions & 12 deletions backend/ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static char mandatory_attrs[1024] = "";
* Local functions...
*/

static void adjust_options(int num_options, cups_option_t *options);
static int adjust_options(int num_options, cups_option_t **options);
static void cancel_job(http_t *http, const char *uri, int id,
const char *resource, const char *user,
int version);
Expand Down Expand Up @@ -2288,9 +2288,9 @@ main(int argc, /* I - Number of command-line args */
* Support for each PPD x IPP option pair is added adhoc, based on demand.
*/

static void
static int /* O - New number of options */
adjust_options(int num_options, /* I - Number of options */
cups_option_t *options) /* I - Array of job options */
cups_option_t **options) /* I - Array of job options */
{
const char *ppd_option_value = NULL; /* PPD option value */
const char *ipp_attr_value = NULL; /* IPP attribute value */
Expand All @@ -2301,33 +2301,35 @@ adjust_options(int num_options, /* I - Number of options */
if (options == NULL || num_options < 2)
{
fprintf(stderr, "DEBUG: adjust_options(): Invalid values.\n");
return;
return (num_options);
}

/*
* PPD option ColorModel and IPP attribute print-color-mode
*/

ppd_option_value = cupsGetOption("ColorModel", num_options, options);
ipp_attr_value = cupsGetOption("print-color-mode", num_options, options);
ppd_option_value = cupsGetOption("ColorModel", num_options, *options);
ipp_attr_value = cupsGetOption("print-color-mode", num_options, *options);

if (!ppd_option_value || !ipp_attr_value)
return;
return (num_options);

if (strcmp(ipp_attr_value, "monochrome") && (!strcmp(ppd_option_value, "Gray")
|| !strcmp(ppd_option_value, "FastGray")
|| !strcmp(ppd_option_value, "DeviceGray")))
{
fprintf(stderr, "DEBUG: adjust_options(): Adjusting print-color-mode to monochrome.\n");
num_options = cupsAddOption("print-color-mode", "monochrome", num_options, &options);
num_options = cupsAddOption("print-color-mode", "monochrome", num_options, options);
}
else if (strcmp(ipp_attr_value, "color") && (!strcmp(ppd_option_value, "CMY")
|| !strcmp(ppd_option_value, "CMYK")
|| !strcmp(ppd_option_value, "RGB")))
{
fprintf(stderr, "DEBUG: adjust_options(): Adjusting print-color-mode to color.\n");
num_options = cupsAddOption("print-color-mode", "color", num_options, &options);
num_options = cupsAddOption("print-color-mode", "color", num_options, options);
}

return (num_options);
}


Expand Down Expand Up @@ -2797,6 +2799,8 @@ new_request(
const char *keyword; /* PWG keyword */


(void)compression; // TODO: Add compression support???

/*
* Create the IPP request...
*/
Expand Down Expand Up @@ -2942,7 +2946,7 @@ new_request(
*/

fputs("DEBUG: Adding all operation/job attributes.\n", stderr);
adjust_options(num_options, options);
num_options = adjust_options(num_options, &options);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);
}
Expand Down Expand Up @@ -2974,8 +2978,8 @@ password_cb(const char *prompt, /* I - Prompt (not used) */

fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\", http=%p, method=\"%s\", "
"resource=\"%s\", password_tries=%p(%d)), password=%p\n",
prompt, http, method, resource, password_tries, *password_tries,
password);
prompt, (void *)http, method, resource, (void *)password_tries, *password_tries,
(void *)password);

(void)prompt;
(void)method;
Expand Down
4 changes: 2 additions & 2 deletions backend/runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ backendRunLoop(
fprintf(stderr,
"DEBUG: backendRunLoop(print_fd=%d, device_fd=%d, snmp_fd=%d, "
"addr=%p, use_bc=%d, side_cb=%p)\n",
print_fd, device_fd, snmp_fd, addr, use_bc, side_cb);
print_fd, device_fd, snmp_fd, (void *)addr, use_bc, (void *)side_cb);

/*
* If we are printing data from a print driver on stdin, ignore SIGTERM
Expand Down Expand Up @@ -420,7 +420,7 @@ backendWaitLoop(


fprintf(stderr, "DEBUG: backendWaitLoop(snmp_fd=%d, addr=%p, side_cb=%p)\n",
snmp_fd, addr, side_cb);
snmp_fd, (void *)addr, (void *)side_cb);

/*
* Now loop until we receive data from stdin...
Expand Down
2 changes: 1 addition & 1 deletion backend/usb-darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static CFStringRef deviceIDCopySerialNumber(CFStringRef deviceID);
* 'list_devices()' - List all USB devices.
*/

void list_devices()
void list_devices(void)
{
iterate_printers(list_device_cb, NULL);
}
Expand Down
6 changes: 3 additions & 3 deletions berkeley/lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ show_status(http_t *http, /* I - HTTP connection to server */
* attributes-natural-language
*/

request = ippNewRequest(CUPS_GET_PRINTERS);
request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);

ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", sizeof(requested) / sizeof(requested[0]),
Expand Down Expand Up @@ -301,7 +301,7 @@ show_status(http_t *http, /* I - HTTP connection to server */

printer = NULL;
device = "file:/dev/null";
pstate = IPP_PRINTER_IDLE;
pstate = IPP_PSTATE_IDLE;
jobcount = 0;
accepting = 1;

Expand Down Expand Up @@ -430,7 +430,7 @@ show_status(http_t *http, /* I - HTTP connection to server */
else
_cupsLangPuts(stdout, _("\tqueuing is disabled"));

if (pstate != IPP_PRINTER_STOPPED)
if (pstate != IPP_PSTATE_STOPPED)
_cupsLangPuts(stdout, _("\tprinting is enabled"));
else
_cupsLangPuts(stdout, _("\tprinting is disabled"));
Expand Down
20 changes: 10 additions & 10 deletions berkeley/lpq.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ show_jobs(const char *command, /* I - Command name */
* requesting-user-name
*/

request = ippNewRequest(id ? IPP_GET_JOB_ATTRIBUTES : IPP_GET_JOBS);
request = ippNewRequest(id ? IPP_OP_GET_JOB_ATTRIBUTES : IPP_OP_GET_JOBS);

if (id)
{
Expand Down Expand Up @@ -404,7 +404,7 @@ show_jobs(const char *command, /* I - Command name */

if ((response = cupsDoRequest(http, request, "/")) != NULL)
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
if (response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
ippDelete(response);
Expand Down Expand Up @@ -435,7 +435,7 @@ show_jobs(const char *command, /* I - Command name */

jobid = 0;
jobsize = 0;
jobstate = IPP_JOB_PENDING;
jobstate = IPP_JSTATE_PENDING;
jobname = "unknown";
jobuser = "unknown";
jobdest = NULL;
Expand Down Expand Up @@ -498,7 +498,7 @@ show_jobs(const char *command, /* I - Command name */
* Display the job...
*/

if (jobstate == IPP_JOB_PROCESSING)
if (jobstate == IPP_JSTATE_PROCESSING)
cupsCopyString(rankstr, "active", sizeof(rankstr));
else
{
Expand Down Expand Up @@ -582,7 +582,7 @@ show_printer(const char *command, /* I - Command name */
* printer-uri
*/

request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);

httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, "/printers/%s", dest);
Expand All @@ -595,7 +595,7 @@ show_printer(const char *command, /* I - Command name */

if ((response = cupsDoRequest(http, request, "/")) != NULL)
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
if (response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
ippDelete(response);
Expand All @@ -605,18 +605,18 @@ show_printer(const char *command, /* I - Command name */
if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL)
state = (ipp_pstate_t)attr->values[0].integer;
else
state = IPP_PRINTER_STOPPED;
state = IPP_PSTATE_STOPPED;

switch (state)
{
case IPP_PRINTER_IDLE :
case IPP_PSTATE_IDLE :
_cupsLangPrintf(stdout, _("%s is ready"), dest);
break;
case IPP_PRINTER_PROCESSING :
case IPP_PSTATE_PROCESSING :
_cupsLangPrintf(stdout, _("%s is ready and printing"),
dest);
break;
case IPP_PRINTER_STOPPED :
case IPP_PSTATE_STOPPED :
_cupsLangPrintf(stdout, _("%s is not ready"), dest);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion berkeley/lpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ main(int argc, /* I - Number of command-line arguments */
return (1);
}

if (cupsFinishDocument(CUPS_HTTP_DEFAULT, printer) != IPP_OK)
if (cupsFinishDocument(CUPS_HTTP_DEFAULT, printer) != IPP_STATUS_OK)
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
Expand Down
4 changes: 2 additions & 2 deletions berkeley/lprm.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ main(int argc, /* I - Number of command-line arguments */
goto error;
}

if (cupsCancelJob2(CUPS_HTTP_DEFAULT, name, job_id, 0) != IPP_OK)
if (cupsCancelJob2(CUPS_HTTP_DEFAULT, name, job_id, 0) != IPP_STATUS_OK)
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
goto error;
Expand All @@ -200,7 +200,7 @@ main(int argc, /* I - Number of command-line arguments */
* (or default) printer...
*/

if (!did_cancel && cupsCancelJob2(CUPS_HTTP_DEFAULT, name, 0, 0) != IPP_OK)
if (!did_cancel && cupsCancelJob2(CUPS_HTTP_DEFAULT, name, 0, 0) != IPP_STATUS_OK)
{
_cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
goto error;
Expand Down
Loading

0 comments on commit 4f05fa3

Please sign in to comment.