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);
/*
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);
/*
"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...
* 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);
* 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 */
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);
}
const char *keyword; /* PWG keyword */
+ (void)compression; // TODO: Add compression support???
+
/*
* Create the IPP 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);
}
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;
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
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...
* 'list_devices()' - List all USB devices.
*/
-void list_devices()
+void list_devices(void)
{
iterate_printers(list_device_cb, NULL);
}
* 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]),
printer = NULL;
device = "file:/dev/null";
- pstate = IPP_PRINTER_IDLE;
+ pstate = IPP_PSTATE_IDLE;
jobcount = 0;
accepting = 1;
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"));
* 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)
{
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);
jobid = 0;
jobsize = 0;
- jobstate = IPP_JOB_PENDING;
+ jobstate = IPP_JSTATE_PENDING;
jobname = "unknown";
jobuser = "unknown";
jobdest = NULL;
* Display the job...
*/
- if (jobstate == IPP_JOB_PROCESSING)
+ if (jobstate == IPP_JSTATE_PROCESSING)
cupsCopyString(rankstr, "active", sizeof(rankstr));
else
{
* 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);
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);
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;
}
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);
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;
* (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;
* attributes-natural-language
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type",
CUPS_PRINTER_LOCAL);
* 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, "/classes/%s", name);
* member-uris
*/
- request = ippNewRequest(CUPS_ADD_CLASS);
+ request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_CLASS);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, "/classes/%s", name);
ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
- IPP_PRINTER_IDLE);
+ IPP_PSTATE_IDLE);
if ((num_printers = cgiGetSize("MEMBER_URIS")) > 0)
{
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(title);
cgiShowIPPError(modify ? _("Unable to modify class") :
* 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",
current_device = 0;
if (cupsGetDevices(http, 5, CUPS_INCLUDE_ALL, CUPS_EXCLUDE_NONE,
(cups_device_cb_t)choose_device_cb,
- (void *)title) == IPP_OK)
+ (void *)title) == IPP_STATUS_OK)
{
fputs("DEBUG: Got device list!\n", stderr);
fprintf(stderr,
"ERROR: CUPS-Get-Devices request failed with status %x: %s\n",
cupsGetError(), cupsGetErrorString());
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
* printer-uri
*/
- request = ippNewRequest(CUPS_GET_PPDS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PPDS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost/printers/");
ippDelete(response);
- request = ippNewRequest(CUPS_GET_PPDS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PPDS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost/printers/");
* printer-state
*/
- request = ippNewRequest(CUPS_ADD_PRINTER);
+ request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, "/printers/%s",
var && (!strcmp(var, "1") || !strcmp(var, "on")));
ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
- IPP_PRINTER_IDLE);
+ IPP_PSTATE_IDLE);
/*
* Do the request and get back a response...
else
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(title);
cgiShowIPPError(modify ? _("Unable to modify printer") :
if (!cupsAdminSetServerSettings(http, num_newsettings, newsettings))
{
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
* printer-uri
*/
- request = ippNewRequest(CUPS_DELETE_CLASS);
+ request = ippNewRequest(IPP_OP_CUPS_DELETE_CLASS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
* Show the results...
*/
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() <= IPP_OK_CONFLICT)
+ else if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
{
/*
* Redirect successful updates back to the classes page...
cgiStartHTML(cgiText(_("Delete Class")));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
cgiShowIPPError(_("Unable to delete class"));
else
cgiCopyTemplateLang("class-deleted.tmpl");
* printer-uri
*/
- request = ippNewRequest(CUPS_DELETE_PRINTER);
+ request = ippNewRequest(IPP_OP_CUPS_DELETE_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
* Show the results...
*/
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() <= IPP_OK_CONFLICT)
+ else if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
{
/*
* Redirect successful updates back to the printers page...
cgiStartHTML(cgiText(_("Delete Printer")));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
cgiShowIPPError(_("Unable to delete printer"));
else
cgiCopyTemplateLang("printer-deleted.tmpl");
* Get the list of printers and their devices...
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", NULL, "device-uri");
ippDelete(response);
- request = ippNewRequest(CUPS_GET_DEVICES);
+ request = ippNewRequest(IPP_OP_CUPS_GET_DEVICES);
if ((response = cupsDoRequest(http, request, "/")) != NULL)
{
* requested-attributes
*/
- 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, is_class ? "/classes/%s" : "/printers/%s",
cgiStartHTML(cgiText(_("Set Allowed Users")));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
cgiShowIPPError(_("Unable to get printer attributes"));
else
cgiCopyTemplateLang("users.tmpl");
* requesting-user-name-{allowed,denied}
*/
- request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER);
+ request = ippNewRequest(is_class ? IPP_OP_CUPS_ADD_MODIFY_CLASS : IPP_OP_CUPS_ADD_MODIFY_PRINTER);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(cgiText(_("Set Allowed Users")));
cgiShowIPPError(_("Unable to change printer"));
* printer-uri
*/
- request = ippNewRequest(CUPS_SET_DEFAULT);
+ request = ippNewRequest(IPP_OP_CUPS_SET_DEFAULT);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to set server default"));
* Get the printer attributes...
*/
- 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", printer);
* [ppd file]
*/
- request = ippNewRequest(is_class ? CUPS_ADD_MODIFY_CLASS :
- CUPS_ADD_MODIFY_PRINTER);
+ request = ippNewRequest(is_class ? IPP_OP_CUPS_ADD_MODIFY_CLASS :
+ IPP_OP_CUPS_ADD_MODIFY_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
else
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to set options"));
* printer-is-shared
*/
- request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER);
+ request = ippNewRequest(is_class ? IPP_OP_CUPS_ADD_MODIFY_CLASS : IPP_OP_CUPS_ADD_MODIFY_PRINTER);
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
"localhost", 0, is_class ? "/classes/%s" : "/printers/%s",
ippDelete(response);
}
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(cgiText(_("Set Publishing")));
cgiShowIPPError(_("Unable to change printer-is-shared attribute"));
* Get the default destination...
*/
- request = ippNewRequest(CUPS_GET_DEFAULT);
+ request = ippNewRequest(IPP_OP_CUPS_GET_DEFAULT);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
printf("Location: %s\n\n", uri);
}
else if (!strcmp(op, "start-class"))
- do_class_op(http, pclass, IPP_RESUME_PRINTER, cgiText(_("Resume Class")));
+ do_class_op(http, pclass, IPP_OP_RESUME_PRINTER, cgiText(_("Resume Class")));
else if (!strcmp(op, "stop-class"))
- do_class_op(http, pclass, IPP_PAUSE_PRINTER, cgiText(_("Pause Class")));
+ do_class_op(http, pclass, IPP_OP_PAUSE_PRINTER, cgiText(_("Pause Class")));
else if (!strcmp(op, "accept-jobs"))
- do_class_op(http, pclass, CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
+ do_class_op(http, pclass, IPP_OP_CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
else if (!strcmp(op, "reject-jobs"))
- do_class_op(http, pclass, CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
+ do_class_op(http, pclass, IPP_OP_CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
else if (!strcmp(op, "cancel-jobs"))
do_class_op(http, pclass, IPP_OP_CANCEL_JOBS, cgiText(_("Cancel Jobs")));
else if (!_cups_strcasecmp(op, "print-test-page"))
snprintf(resource, sizeof(resource), "/classes/%s", printer);
ippDelete(cupsDoRequest(http, request, resource));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to do maintenance command"));
cgiSetVariable("IS_CLASS", "YES");
- if (op == IPP_PAUSE_PRINTER)
+ if (op == IPP_OP_PAUSE_PRINTER)
cgiCopyTemplateLang("printer-stop.tmpl");
- else if (op == IPP_RESUME_PRINTER)
+ else if (op == IPP_OP_RESUME_PRINTER)
cgiCopyTemplateLang("printer-start.tmpl");
- else if (op == CUPS_ACCEPT_JOBS)
+ else if (op == IPP_OP_CUPS_ACCEPT_JOBS)
cgiCopyTemplateLang("printer-accept.tmpl");
- else if (op == CUPS_REJECT_JOBS)
+ else if (op == IPP_OP_CUPS_REJECT_JOBS)
cgiCopyTemplateLang("printer-reject.tmpl");
else if (op == IPP_OP_CANCEL_JOBS)
cgiCopyTemplateLang("printer-cancel-jobs.tmpl");
* requesting-user-name
*/
- request = ippNewRequest(CUPS_GET_CLASSES);
+ request = ippNewRequest(IPP_OP_CUPS_GET_CLASSES);
if (user)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_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, "/classes/%s", pclass);
if (pclass && (attr = ippFindAttribute(response, "printer-state",
IPP_TAG_ENUM)) != NULL &&
- attr->values[0].integer == IPP_PRINTER_PROCESSING)
+ attr->values[0].integer == IPP_PSTATE_PROCESSING)
{
/*
* Class is processing - automatically refresh the page until we
fprintf(stderr,
- "DEBUG: si=%p, si->sorted=%p, cupsArrayCount(si->sorted)=%d\n", si,
- si->sorted, cupsArrayCount(si->sorted));
+ "DEBUG: si=%p, si->sorted=%p, cupsArrayCount(si->sorted)=%d\n", (void *)si,
+ (void *)si->sorted, cupsArrayCount(si->sorted));
for (i = 0, n = (help_node_t *)cupsArrayFirst(si->sorted);
n;
char job_uri[1024]; /* Job URI */
- request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);
+ request = ippNewRequest(IPP_OP_GET_JOB_ATTRIBUTES);
snprintf(job_uri, sizeof(job_uri), "ipp://localhost/jobs/%d", job_id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
* Get the list of available destinations...
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", NULL, "printer-uri-supported");
const char *job_printer_name; /* New printer name */
- request = ippNewRequest(CUPS_MOVE_JOB);
+ request = ippNewRequest(IPP_OP_CUPS_MOVE_JOB);
if (job_id)
{
job_printer_name = strrchr(job_printer_uri, '/') + 1;
- if (cupsGetError() <= IPP_OK_CONFLICT)
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
{
const char *path = strstr(job_printer_uri, "/printers/");
if (!path)
else
cgiStartHTML(cgiText(_("Move All Jobs")));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
if (job_id)
cgiShowIPPError(_("Unable to move job"));
if (status == HTTP_STATUS_CONTINUE)
cupsFinishDocument(http, dest);
- if (cupsGetError() >= IPP_REDIRECTION_OTHER_SITE)
+ if (cupsGetError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
{
cgiSetVariable("MESSAGE", cgiText(_("Unable to send command to printer driver")));
cgiSetVariable("ERROR", cupsGetErrorString());
*/
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
- request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);
+ request = ippNewRequest(IPP_OP_GET_JOB_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri",
NULL, uri);
if (user)
cgiSetIPPVars(response, NULL, NULL, NULL, 0);
attr = ippFindAttribute(response, "job-state", IPP_TAG_ENUM);
- if (!attr || attr->values[0].integer >= IPP_JOB_STOPPED ||
- attr->values[0].integer == IPP_JOB_HELD)
+ if (!attr || attr->values[0].integer >= IPP_JSTATE_STOPPED ||
+ attr->values[0].integer == IPP_JSTATE_HELD)
{
ippDelete(response);
break;
* requesting-user-name
*/
- request = ippNewRequest(IPP_PRINT_JOB);
+ request = ippNewRequest(IPP_OP_PRINT_JOB);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
ippDelete(response);
}
- if (cupsGetError() <= IPP_OK_CONFLICT)
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
{
/*
* Automatically reload the printer status page...
snprintf(refresh, sizeof(refresh), "2;URL=%s", uri);
cgiSetVariable("refresh_page", refresh);
}
- else if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
cgiStartHTML(cgiText(_("Print Test Page")));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
cgiShowIPPError(_("Unable to print test page"));
else
{
fprintf(stderr, "DEBUG2: cgiSetIPPObjectVars(obj=%p, prefix=\"%s\", "
"element=%d)\n",
- obj, prefix ? prefix : "(null)", element);
+ (void *)obj, prefix ? prefix : "(null)", element);
/*
* Set common CGI template variables...
fprintf(stderr, "DEBUG2: cgiSetIPPVars(response=%p, filter_name=\"%s\", "
"filter_value=\"%s\", prefix=\"%s\", parent_el=%d)\n",
- response, filter_name ? filter_name : "(null)",
+ (void *)response, filter_name ? filter_name : "(null)",
filter_value ? filter_value : "(null)",
prefix ? prefix : "(null)", parent_el);
* printer-uri
*/
- request = ippNewRequest(IPP_GET_JOBS);
+ request = ippNewRequest(IPP_OP_GET_JOBS);
if (dest)
{
*/
if (!strcmp(op, "cancel-job"))
- do_job_op(http, job_id, IPP_CANCEL_JOB);
+ do_job_op(http, job_id, IPP_OP_CANCEL_JOB);
else if (!strcmp(op, "hold-job"))
- do_job_op(http, job_id, IPP_HOLD_JOB);
+ do_job_op(http, job_id, IPP_OP_HOLD_JOB);
else if (!strcmp(op, "move-job"))
cgiMoveJobs(http, NULL, job_id);
else if (!strcmp(op, "release-job"))
- do_job_op(http, job_id, IPP_RELEASE_JOB);
+ do_job_op(http, job_id, IPP_OP_RELEASE_JOB);
else if (!strcmp(op, "restart-job"))
- do_job_op(http, job_id, IPP_RESTART_JOB);
+ do_job_op(http, job_id, IPP_OP_RESTART_JOB);
else
{
/*
ippDelete(cupsDoRequest(http, request, "/jobs"));
- if (cupsGetError() <= IPP_OK_CONFLICT && getenv("HTTP_REFERER"))
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING && getenv("HTTP_REFERER"))
{
/*
* Redirect successful updates back to the parent page...
cgiFormEncode(url + 6, getenv("HTTP_REFERER"), sizeof(url) - 6);
cgiSetVariable("refresh_page", url);
}
- else if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
cgiStartHTML(cgiText(_("Jobs")));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
cgiShowIPPError(_("Job operation failed"));
- else if (op == IPP_CANCEL_JOB)
+ else if (op == IPP_OP_CANCEL_JOB)
cgiCopyTemplateLang("job-cancel.tmpl");
- else if (op == IPP_HOLD_JOB)
+ else if (op == IPP_OP_HOLD_JOB)
cgiCopyTemplateLang("job-hold.tmpl");
- else if (op == IPP_RELEASE_JOB)
+ else if (op == IPP_OP_RELEASE_JOB)
cgiCopyTemplateLang("job-release.tmpl");
- else if (op == IPP_RESTART_JOB)
+ else if (op == IPP_OP_RESTART_JOB)
cgiCopyTemplateLang("job-restart.tmpl");
cgiEndHTML();
* Get the default destination...
*/
- request = ippNewRequest(CUPS_GET_DEFAULT);
+ request = ippNewRequest(IPP_OP_CUPS_GET_DEFAULT);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
printf("Location: %s\n\n", uri);
}
else if (!strcmp(op, "start-printer"))
- do_printer_op(http, printer, IPP_RESUME_PRINTER,
+ do_printer_op(http, printer, IPP_OP_RESUME_PRINTER,
cgiText(_("Resume Printer")));
else if (!strcmp(op, "stop-printer"))
- do_printer_op(http, printer, IPP_PAUSE_PRINTER,
+ do_printer_op(http, printer, IPP_OP_PAUSE_PRINTER,
cgiText(_("Pause Printer")));
else if (!strcmp(op, "accept-jobs"))
- do_printer_op(http, printer, CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
+ do_printer_op(http, printer, IPP_OP_CUPS_ACCEPT_JOBS, cgiText(_("Accept Jobs")));
else if (!strcmp(op, "reject-jobs"))
- do_printer_op(http, printer, CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
+ do_printer_op(http, printer, IPP_OP_CUPS_REJECT_JOBS, cgiText(_("Reject Jobs")));
else if (!strcmp(op, "cancel-jobs"))
do_printer_op(http, printer, IPP_OP_CANCEL_JOBS, cgiText(_("Cancel Jobs")));
else if (!_cups_strcasecmp(op, "print-self-test-page"))
snprintf(resource, sizeof(resource), "/printers/%s", printer);
ippDelete(cupsDoRequest(http, request, resource));
- if (cupsGetError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_STATUS_ERROR_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to do maintenance command"));
cgiStartHTML(title);
- if (op == IPP_PAUSE_PRINTER)
+ if (op == IPP_OP_PAUSE_PRINTER)
cgiCopyTemplateLang("printer-stop.tmpl");
- else if (op == IPP_RESUME_PRINTER)
+ else if (op == IPP_OP_RESUME_PRINTER)
cgiCopyTemplateLang("printer-start.tmpl");
- else if (op == CUPS_ACCEPT_JOBS)
+ else if (op == IPP_OP_CUPS_ACCEPT_JOBS)
cgiCopyTemplateLang("printer-accept.tmpl");
- else if (op == CUPS_REJECT_JOBS)
+ else if (op == IPP_OP_CUPS_REJECT_JOBS)
cgiCopyTemplateLang("printer-reject.tmpl");
else if (op == IPP_OP_CANCEL_JOBS)
cgiCopyTemplateLang("printer-cancel-jobs.tmpl");
fprintf(stderr, "DEBUG: show_all_printers(http=%p, user=\"%s\")\n",
- http, user ? user : "(null)");
+ (void *)http, user ? user : "(null)");
/*
* Show the standard header...
* requesting-user-name
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM,
"printer-type", 0);
fprintf(stderr, "DEBUG: show_printer(http=%p, printer=\"%s\")\n",
- http, printer ? printer : "(null)");
+ (void *)http, printer ? printer : "(null)");
/*
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
* 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", printer);
if (printer && (attr = ippFindAttribute(response, "printer-state",
IPP_TAG_ENUM)) != NULL &&
- attr->values[0].integer == IPP_PRINTER_PROCESSING)
+ attr->values[0].integer == IPP_PSTATE_PROCESSING)
{
/*
* Printer is processing - automatically refresh the page until we
{
FILE *in; /* Input file */
- fprintf(stderr, "DEBUG2: cgiCopyTemplateFile(out=%p, tmpl=\"%s\")\n", out,
+ fprintf(stderr, "DEBUG2: cgiCopyTemplateFile(out=%p, tmpl=\"%s\")\n", (void *)out,
tmpl ? tmpl : "(null)");
/*
}
fprintf(stderr, "DEBUG2: %*sFinished \"{%s%c%s\", out=%p...\n", indent, "",
- name, op, compare, out);
+ name, op, compare, (void *)out);
}
else if (ch == '\\') /* Quoted char */
{
http-support.o \
ipp.o \
ipp-file.o \
- ipp-vars.o \
ipp-support.o \
langprintf.o \
language.o \
notify.o \
options.o \
pwg-media.o \
+ rand.o \
raster-error.o \
raster-stream.o \
raster-stubs.o \
testpwg.o \
testraster.o \
testsnmp.o \
+ testtestpage.o \
testthreads.o \
tlscheck.o
OBJS = \
testpwg \
testraster \
testsnmp \
+ testtestpage \
testthreads \
tlscheck
./testpwg test.ppd >>test.log
echo Running raster API tests...
./testraster >>test.log
+ echo Running raster testpage API tests...
+ ./testtestpage >>test.log
# echo Fuzzing IPP API...
# ./fuzzipp >>test.log
echo "Tests finished at $(date)..." >>test.log
$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+#
+# testtestpage (dependency on static CUPS library is intentional)
+#
+
+testtestpage: testtestpage.o $(LIBCUPSSTATIC)
+ echo Linking $@...
+ $(LD_CC) $(ALL_LDFLAGS) -o $@ testtestpage.o $(LINKCUPSSTATIC)
+ $(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
+
+
#
# testthreads (dependency on static CUPS library is intentional)
#
apihelp:
echo "Generating CUPS Programming Manual..."
$(RM) cupspm.xml
- codedoc --section "Programming" --body cupspm.md \
- cupspm.xml \
- array.[ch] auth.c cups.h dest*.c dir.[ch] encode.c file.[ch] \
- http.h http*.c ipp.h ipp*.c options.c pwg.[ch] \
- raster.h raster-stubs.c string.c tempfile.c thread.[ch] tls.c tls-openssl.c usersys.c util.c \
- --coverimage cupspm.png \
- --epub ../doc/help/cupspm.epub
- codedoc --section "Programming" --body cupspm.md \
- cupspm.xml > ../doc/help/cupspm.html
+ codedoc --section "Programming" --body cupspm.md cupspm.xml \
+ $(COREOBJS:.o=.c) $(COREHEADERS) tls-openssl.c \
+ --coverimage cupspm.png --epub ../doc/help/cupspm.epub
+ codedoc --section "Programming" --body cupspm.md cupspm.xml > ../doc/help/cupspm.html
$(RM) cupspm.xml
echo "Generating Administration APIs help..."
codedoc --section "Programming" --title "Administration APIs" \
/*
* Authentication functions for CUPS.
*
- * Copyright © 2021 by OpenPrinting.
+ * Copyright © 2021-2023 by OpenPrinting.
* Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products.
*
char nonce[HTTP_MAX_VALUE]; /* nonce="xyz" string */
cups_auth_param(schemedata, "algorithm", http->algorithm, sizeof(http->algorithm));
+ cups_auth_param(schemedata, "nonce", nonce, sizeof(nonce));
cups_auth_param(schemedata, "opaque", http->opaque, sizeof(http->opaque));
cups_auth_param(schemedata, "qop", http->qop, sizeof(http->qop));
- cups_auth_param(schemedata, "nonce", nonce, sizeof(nonce));
cups_auth_param(schemedata, "realm", http->realm, sizeof(http->realm));
if (_httpSetDigestAuthString(http, nonce, method, resource))
char buf[1024]; /* Name buffer */
- DEBUG_printf("7cups_gss_getname(http=%p, service_name=\"%s\")", http, service_name);
+ DEBUG_printf("7cups_gss_getname(http=%p, service_name=\"%s\")", (void *)http, service_name);
/*
* Get the hostname...
// function and freed using the @link cupsFreeOptions@ function.
//
-size_t // O - Number of key/value pairs
+int // O - Number of key/value pairs
cupsDNSSDDecodeTXT(
const unsigned char *txtrec, // I - TXT record data
uint16_t txtlen, // I - TXT record length
cups_option_t **txt) // O - Key/value pairs
{
- size_t num_txt = 0; // Number of key/value pairs
+ int num_txt = 0; // Number of key/value pairs
unsigned char keylen; // Length of key/value
char key[256], // Key/value buffer
*value; // Pointer to value
// const char *fullname,
// const char *host,
// uint16_t port,
-// size_t num_txt,
+// int num_txt,
// cups_option_t *txt)
// {
// // Process resolved service
const char *domain, // I - Domain name or `NULL` for default
const char *host, // I - Host name or `NULL` for default
uint16_t port, // I - Port number or `0` for none
- size_t num_txt, // I - Number of TXT record values
+ int num_txt, // I - Number of TXT record values
cups_option_t *txt) // I - TXT record values
{
bool ret = true; // Return value
- size_t i; // Looping var
+ int i; // Looping var
- DEBUG_printf("cupsDNSSDServiceAdd(service=%p, types=\"%s\", domain=\"%s\", host=\"%s\", port=%u, num_txt=%u, txt=%p)", (void *)service, types, domain, host, port, (unsigned)num_txt, (void *)txt);
+ DEBUG_printf("cupsDNSSDServiceAdd(service=%p, types=\"%s\", domain=\"%s\", host=\"%s\", port=%u, num_txt=%d, txt=%p)", (void *)service, types, domain, host, port, num_txt, (void *)txt);
// Range check input...
if (!service || !types)
const unsigned char *txtrec, // I - TXT record
cups_dnssd_resolve_t *resolve) // I - Resolve request
{
- size_t num_txt; // Number of TXT key/value pairs
+ int num_txt; // Number of TXT key/value pairs
cups_option_t *txt; // TXT key/value pairs
cups_dnssd_resolve_t *resolve) // I - Resolve request
{
AvahiStringList *txtpair; // Current pair
- size_t num_txt = 0; // Number of TXT key/value pairs
+ int num_txt = 0; // Number of TXT key/value pairs
cups_option_t *txt = NULL; // TXT key/value pairs
char fullname[1024]; // Full service name
typedef struct _cups_dnssd_resolve_s cups_dnssd_resolve_t;
// DNS resolve request
-typedef void (*cups_dnssd_resolve_cb_t)(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, size_t num_txt, cups_option_t *txt);
+typedef void (*cups_dnssd_resolve_cb_t)(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, int num_txt, cups_option_t *txt);
// DNS-SD resolve callback
typedef struct _cups_dnssd_service_s cups_dnssd_service_t;
extern cups_dnssd_t *cupsDNSSDResolveGetContext(cups_dnssd_resolve_t *res) _CUPS_PUBLIC;
extern cups_dnssd_resolve_t *cupsDNSSDResolveNew(cups_dnssd_t *dnssd, uint32_t if_index, const char *name, const char *type, const char *domain, cups_dnssd_resolve_cb_t resolve_cb, void *cb_data) _CUPS_PUBLIC;
-extern bool cupsDNSSDServiceAdd(cups_dnssd_service_t *service, const char *types, const char *domain, const char *host, uint16_t port, size_t num_txt, cups_option_t *txt) _CUPS_PUBLIC;
+extern bool cupsDNSSDServiceAdd(cups_dnssd_service_t *service, const char *types, const char *domain, const char *host, uint16_t port, int num_txt, cups_option_t *txt) _CUPS_PUBLIC;
extern void cupsDNSSDServiceDelete(cups_dnssd_service_t *service) _CUPS_PUBLIC;
extern cups_dnssd_t *cupsDNSSDServiceGetContext(cups_dnssd_service_t *service) _CUPS_PUBLIC;
extern const char *cupsDNSSDServiceGetName(cups_dnssd_service_t *service) _CUPS_PUBLIC;
extern bool cupsDNSSDServiceSetLocation(cups_dnssd_service_t *service, const char *geo_uri) _CUPS_PUBLIC;
extern bool cupsDNSSDAssembleFullName(char *fullname, size_t fullsize, const char *name, const char *type, const char *domain);
-extern size_t cupsDNSSDDecodeTXT(const unsigned char *txtrec, uint16_t txtlen, cups_option_t **txt) _CUPS_PUBLIC;
+extern int cupsDNSSDDecodeTXT(const unsigned char *txtrec, uint16_t txtlen, cups_option_t **txt) _CUPS_PUBLIC;
extern bool cupsDNSSDSeparateFullName(const char *fullname, char *name, size_t namesize, char *type, size_t typesize, char *domain, size_t domainsize);
/* Default field values, if any */
/**** New in CUPS 2.5 ****/
char qop[HTTP_MAX_VALUE];
- /* qop value from WWW-Authenticate */
+ /* Quality of Protection (qop) value from WWW-Authenticate */
};
# endif /* !_HTTP_NO_PRIVATE */
static const char *http_copy_decode(char *dst, const char *src, size_t dstsize, const char *term, int decode);
static char *http_copy_encode(char *dst, const char *src, char *dstend, const char *reserved, const char *term, int encode);
-static void http_resolve_cb(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, size_t num_txt, cups_option_t *txt);
+static void http_resolve_cb(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, int num_txt, cups_option_t *txt);
//
httpEncode64(char *out, // I - String to write to
const char *in) // I - String to read from
{
- return (httpEncode64_2(out, 512, in, (int)strlen(in)));
+ return (httpEncode64_3(out, 512, in, (size_t)strlen(in), false));
}
const char *in, // I - String to read from
int inlen) // I - Size of input string
{
- return (httpEncode64_3(out, outlen, in, inlen, false));
+ return (httpEncode64_3(out, (size_t)outlen, in, (size_t)inlen, false));
}
if ((sep = strpbrk(uri, "@/")) != NULL && *sep == '@')
{
// Get a username:password combo...
- uri = http_copy_decode(username, uri, usernamelen, "@", decoding & HTTP_URI_CODING_USERNAME);
+ uri = http_copy_decode(username, uri, (size_t)usernamelen, "@", decoding & HTTP_URI_CODING_USERNAME);
if (!uri)
{
uri ++;
}
- uri = http_copy_decode(host, uri, hostlen, "]", decoding & HTTP_URI_CODING_HOSTNAME);
+ uri = http_copy_decode(host, uri, (size_t)hostlen, "]", decoding & HTTP_URI_CODING_HOSTNAME);
if (!uri)
{
}
// Then copy the hostname or IPv4 address to the buffer...
- uri = http_copy_decode(host, uri, hostlen, ":?/", decoding & HTTP_URI_CODING_HOSTNAME);
+ uri = http_copy_decode(host, uri, (size_t)hostlen, ":?/", decoding & HTTP_URI_CODING_HOSTNAME);
if (!uri)
{
// Copy any query string...
if (*uri == '?')
- uri = http_copy_decode(resource + 1, uri, resourcelen - 1, NULL, decoding & HTTP_URI_CODING_QUERY);
+ uri = http_copy_decode(resource + 1, uri, (size_t)resourcelen - 1, NULL, decoding & HTTP_URI_CODING_QUERY);
else
resource[1] = '\0';
}
else
{
- uri = http_copy_decode(resource, uri, resourcelen, "?", decoding & HTTP_URI_CODING_RESOURCE);
+ uri = http_copy_decode(resource, uri, (size_t)resourcelen, "?", decoding & HTTP_URI_CODING_RESOURCE);
if (uri && *uri == '?')
{
// Concatenate any query string...
char *resptr = resource + strlen(resource);
- uri = http_copy_decode(resptr, uri, resourcelen - (int)(resptr - resource), NULL, decoding & HTTP_URI_CODING_QUERY);
+ uri = http_copy_decode(resptr, uri, (size_t)(resourcelen - (resptr - resource)), NULL, decoding & HTTP_URI_CODING_QUERY);
}
}
int i; /* Looping var */
char cnonce[65]; /* cnonce value */
const char *hashalg; /* Hashing algorithm */
- const char *qop; /* quality of protection */
+ const char *qop; /* Quality of Protection */
DEBUG_puts("3_httpSetDigestAuthString: Follow RFC 2617/7616...");
return (0);
}
- if (!_cups_strcasecmp(http->algorithm, "MD5"))
+ if (!http->algorithm[0] || !_cups_strcasecmp(http->algorithm, "MD5"))
{
// RFC 2617 Digest with MD5
if (cg->digestoptions == _CUPS_DIGESTOPTIONS_DENYMD5)
const char *src, // I - Source URI
size_t dstsize) // I - Size of destination buffer
{
- if (http_copy_decode(dst, src, (int)dstsize, NULL, 1))
+ if (http_copy_decode(dst, src, dstsize, NULL, 1))
return (dst);
else
return (NULL);
const char *fullname, // I - Full service name
const char *host, // I - Hostname
uint16_t port, // I - Port number
- size_t num_txt, // I - Number of TXT key/value pairs
+ int num_txt, // I - Number of TXT key/value pairs
cups_option_t *txt) // I - TXT key/value pairs
{
_http_uribuf_t *uribuf = (_http_uribuf_t *)cb_data;
-/*
- * IPP data file parsing functions.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "ipp-private.h"
-#include "string-private.h"
-#include "debug-internal.h"
-
-
-/*
- * Local functions...
- */
-
-static ipp_t *parse_collection(_ipp_file_t *f, _ipp_vars_t *v, void *user_data);
-static int parse_value(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, ipp_t *ipp, ipp_attribute_t **attr, int element);
-static void report_error(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, const char *message, ...) _CUPS_FORMAT(4, 5);
-
-
-/*
- * '_ippFileParse()' - Parse an IPP data file.
- */
-
-ipp_t * /* O - IPP attributes or @code NULL@ on failure */
-_ippFileParse(
- _ipp_vars_t *v, /* I - Variables */
- const char *filename, /* I - Name of file to parse */
- void *user_data) /* I - User data pointer */
+//
+// IPP data file functions.
+//
+// Copyright © 2021-2022 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "cups-private.h"
+
+
+//
+// Private structures...
+//
+
+struct _ipp_file_s // IPP data file
{
- _ipp_file_t f; /* IPP data file information */
- ipp_t *attrs = NULL; /* Active IPP message */
- ipp_attribute_t *attr = NULL; /* Current attribute */
- char token[1024]; /* Token string */
- ipp_t *ignored = NULL; /* Ignored attributes */
+ ipp_file_t *parent; // Parent data file, if any
+ cups_file_t *fp; // File pointer
+ char *filename, // Filename
+ mode; // Read/write mode
+ int indent, // Current indentation
+ column, // Current column
+ linenum, // Current line number
+ save_line; // Saved line number
+ off_t save_pos; // Saved position
+ ipp_tag_t group_tag; // Current group for attributes
+ ipp_t *attrs; // Current attributes
+ size_t num_vars; // Number of variables
+ cups_option_t *vars; // Variables
+ ipp_fattr_cb_t attr_cb; // Attribute (filter) callback
+ ipp_ferror_cb_t error_cb; // Error reporting callback
+ ipp_ftoken_cb_t token_cb; // Token processing callback
+ void *cb_data; // Callback data
+ char *buffer; // Output buffer
+ size_t alloc_buffer; // Size of output buffer
+};
+
+
+//
+// Local functions...
+//
+
+static bool expand_buffer(ipp_file_t *file, size_t buffer_size);
+static bool parse_value(ipp_file_t *file, ipp_t *ipp, ipp_attribute_t **attr, size_t element);
+static bool report_error(ipp_file_t *file, const char *message, ...) _CUPS_FORMAT(2,3);
+static bool write_string(ipp_file_t *file, const char *s, size_t len);
+
+
+//
+// 'ippFileClose()' - Close an IPP data file.
+//
+// This function closes the current IPP data file. The `ipp_file_t` object can
+// be reused for another file as needed.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileClose(ipp_file_t *file) // I - IPP data file
+{
+ bool ret; // Return value
+
+
+ if (!file || !file->fp)
+ return (false);
+
+ if ((ret = cupsFileClose(file->fp)) == false)
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ free(file->filename);
- DEBUG_printf("_ippFileParse(v=%p, filename=\"%s\", user_data=%p)", (void *)v, filename, user_data);
+ file->fp = NULL;
+ file->filename = NULL;
+ file->mode = '\0';
+ file->attrs = NULL;
+
+ return (ret);
+}
- /*
- * Initialize file info...
- */
- memset(&f, 0, sizeof(f));
- f.filename = filename;
- f.linenum = 1;
+//
+// 'ippFileDelete()' - Close an IPP data file and free all memory.
+//
+// This function closes an IPP data file, if necessary, and frees all memory
+// associated with it.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileDelete(ipp_file_t *file) // I - IPP data file
+{
+ if (!file)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
- if ((f.fp = cupsFileOpen(filename, "r")) == NULL)
+ if (file->fp)
{
- DEBUG_printf("1_ippFileParse: Unable to open \"%s\": %s", filename, strerror(errno));
- return (0);
+ if (!ippFileClose(file))
+ return (false);
}
- /*
- * Do the callback with a NULL token to setup any initial state...
- */
+ cupsFreeOptions(file->num_vars, file->vars);
+ free(file->buffer);
+ free(file);
+
+ return (true);
+}
+
+
+//
+// 'ippFileExpandVars()' - Expand IPP data file and environment variables in a string.
+//
+// This function expands IPP data file variables of the form "$name" and
+// environment variables of the form "$ENV[name]" in the source string to the
+// destination string. The
+//
+
+size_t // O - Required size for expanded variables
+ippFileExpandVars(ipp_file_t *file, // I - IPP data file
+ char *dst, // I - Destination buffer
+ const char *src, // I - Source string
+ size_t dstsize) // I - Size of destination buffer
+{
+ char *dstptr, // Pointer into destination
+ *dstend, // End of destination
+ temp[256], // Temporary string
+ *tempptr; // Pointer into temporary string
+ const char *value; // Value to substitute
+
- (*v->tokencb)(&f, v, user_data, NULL);
+ // Range check input...
+ if (!file || !dst || !src || dstsize < 32)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
- /*
- * Read data file, using the callback function as needed...
- */
+ // Copy the source string to the destination, expanding variables as needed...
+ dstptr = dst;
+ dstend = dst + dstsize - 1;
- while (_ippFileReadToken(&f, token, sizeof(token)))
+ while (*src)
+ {
+ if (*src == '$')
+ {
+ // Substitute a string/number...
+ if (!strncmp(src, "$$", 2))
+ {
+ // Literal $
+ value = "$";
+ src += 2;
+ }
+ else if (!strncmp(src, "$ENV[", 5))
+ {
+ // Environment variable
+ cupsCopyString(temp, src + 5, sizeof(temp));
+
+ for (tempptr = temp; *tempptr; tempptr ++)
+ {
+ if (*tempptr == ']')
+ break;
+ }
+
+ if (*tempptr)
+ *tempptr++ = '\0';
+
+ value = getenv(temp);
+ src += tempptr - temp + 5;
+ }
+ else
+ {
+ // $name or ${name}
+ if (src[1] == '{')
+ {
+ src += 2;
+ cupsCopyString(temp, src, sizeof(temp));
+ if ((tempptr = strchr(temp, '}')) != NULL)
+ *tempptr = '\0';
+ else
+ tempptr = temp + strlen(temp);
+ }
+ else
+ {
+ cupsCopyString(temp, src + 1, sizeof(temp));
+
+ for (tempptr = temp; *tempptr; tempptr ++)
+ {
+ if (!isalnum(*tempptr & 255) && *tempptr != '-' && *tempptr != '_')
+ break;
+ }
+
+ if (*tempptr)
+ *tempptr = '\0';
+ }
+
+ value = ippFileGetVar(file, temp);
+ src += tempptr - temp + 1;
+ }
+
+ if (value)
+ {
+ if (dstptr < dstend)
+ cupsCopyString(dstptr, value, (size_t)(dstend - dstptr + 1));
+ dstptr += strlen(value);
+ }
+ }
+ else if (dstptr < dstend)
+ *dstptr++ = *src++;
+ else
+ dstptr ++;
+ }
+
+ if (dstptr < dstend)
+ *dstptr = '\0';
+ else
+ *dstend = '\0';
+
+ return ((size_t)(dstptr - dst));
+}
+
+
+//
+// 'ippFileGetAttribute()' - Get a single named attribute from an IPP data file.
+//
+// This function finds the first occurence of a named attribute in the current
+// IPP attributes in the specified data file. Unlike
+// @link ippFileGetAttributes@, this function does not clear the attribute
+// state.
+//
+
+ipp_attribute_t * // O - Attribute or `NULL` if none
+ippFileGetAttribute(
+ ipp_file_t *file, // I - IPP data file
+ const char *name, // I - Attribute name
+ ipp_tag_t value_tag) // I - Value tag or `IPP_TAG_ZERO` for any
+{
+ if (!file || !name)
+ return (NULL);
+ else
+ return (ippFindAttribute(file->attrs, name, value_tag));
+}
+
+
+//
+// 'ippFileGetAttributes()' - Get the current set of attributes from an IPP data file.
+//
+// This function gets the current set of attributes from an IPP data file.
+//
+
+ipp_t * // O - IPP attributes
+ippFileGetAttributes(ipp_file_t *file) // I - IPP data file
+{
+ return (file ? file->attrs : NULL);
+}
+
+
+//
+// 'ippFileGetFilename()' - Get the filename for an IPP data file.
+//
+// This function returns the filename associated with an IPP data file.
+//
+
+const char * // O - Filename
+ippFileGetFilename(ipp_file_t *file) // I - IPP data file
+{
+ return (file ? file->filename : NULL);
+}
+
+
+//
+// 'ippFileGetLineNumber()' - Get the current line number in an IPP data file.
+//
+// This function returns the current line number in an IPP data file.
+//
+
+int // O - Line number
+ippFileGetLineNumber(ipp_file_t *file) // I - IPP data file
+{
+ return (file ? file->linenum : 0);
+}
+
+
+//
+// 'ippFileGetVar()' - Get the value of an IPP data file variable.
+//
+// This function returns the value of an IPP data file variable. `NULL` is
+// returned if the variable is not set.
+//
+
+const char * // O - Variable value or `NULL` if none.
+ippFileGetVar(ipp_file_t *file, // I - IPP data file
+ const char *name) // I - Variable name
+{
+ const char *value; // Value
+
+
+ if (!file || !name)
+ return (NULL);
+ else if (!strcmp(name, "user"))
+ return (cupsGetUser());
+ else if ((value = cupsGetOption(name, file->num_vars, file->vars)) != NULL)
+ return (value);
+ else if (file->parent)
+ return (cupsGetOption(name, file->parent->num_vars, file->parent->vars));
+ else
+ return (NULL);
+}
+
+
+//
+// 'ippFileNew()' - Create a new IPP data file object for reading or writing.
+//
+// This function opens an IPP data file for reading (mode="r") or writing
+// (mode="w"). If the "parent" argument is not `NULL`, all variables from the
+// parent data file are copied to the new file.
+//
+
+ipp_file_t * // O - IPP data file
+ippFileNew(ipp_file_t *parent, // I - Parent data file or `NULL` for none
+ ipp_fattr_cb_t attr_cb, // I - Attribute filtering callback, if any
+ ipp_ferror_cb_t error_cb, // I - Error reporting callback, if any
+ void *cb_data) // I - Callback data, if any
+{
+ ipp_file_t *file; // IPP data file
+
+
+ // Allocate memory...
+ if ((file = (ipp_file_t *)calloc(1, sizeof(ipp_file_t))) == NULL)
+ return (NULL);
+
+ // Set callbacks and parent...
+ file->parent = parent;
+ file->attr_cb = attr_cb;
+ file->error_cb = error_cb;
+ file->cb_data = cb_data;
+
+ return (file);
+}
+
+
+//
+// 'ippFileOpen()' - Open an IPP data file for reading or writing.
+//
+// This function opens an IPP data file for reading (mode="r") or writing
+// (mode="w"). If the "parent" argument is not `NULL`, all variables from the
+// parent data file are copied to the new file.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileOpen(ipp_file_t *file, // I - IPP data file
+ const char *filename, // I - Filename to open
+ const char *mode) // I - Open mode - "r" to read and "w" to write
+{
+ cups_file_t *fp; // IPP data file pointer
+
+
+ // Range check input...
+ if (!file || !filename || !mode || (strcmp(mode, "r") && strcmp(mode, "w")))
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+ else if (file->fp)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EBUSY), 0);
+ return (false);
+ }
+
+ // Try opening the file...
+ if ((fp = cupsFileOpen(filename, mode)) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
+ return (false);
+ }
+
+ // Save the file information and return...
+ file->fp = fp;
+ file->filename = strdup(filename);
+ file->mode = *mode;
+ file->column = 0;
+ file->linenum = 1;
+
+ return (true);
+}
+
+
+//
+// 'ippFileRead()' - Read an IPP data file.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileRead(ipp_file_t *file, // I - IPP data file
+ ipp_ftoken_cb_t token_cb, // I - Token callback
+ bool with_groups)// I - Read attributes with GROUP directives
+{
+ ipp_t *attrs = NULL; // Active IPP message
+ ipp_attribute_t *attr = NULL; // Current attribute
+ char token[1024]; // Token string
+ ipp_t *ignored = NULL; // Ignored attributes
+ bool ret = true; // Return value
+
+
+ // Range check input
+ if (!file || file->mode != 'r')
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ // Read data file, using the callback function as needed...
+ while (ippFileReadToken(file, token, sizeof(token)))
{
if (!_cups_strcasecmp(token, "DEFINE") || !_cups_strcasecmp(token, "DEFINE-DEFAULT"))
{
- char name[128], /* Variable name */
- value[1024], /* Variable value */
- temp[1024]; /* Temporary string */
+ // Define a variable...
+ char name[128], // Variable name
+ value[1024], // Variable value
+ temp[1024]; // Temporary string
attr = NULL;
- if (_ippFileReadToken(&f, name, sizeof(name)) && _ippFileReadToken(&f, temp, sizeof(temp)))
+ if (ippFileReadToken(file, name, sizeof(name)) && ippFileReadToken(file, temp, sizeof(temp)))
{
- if (_cups_strcasecmp(token, "DEFINE-DEFAULT") || !_ippVarsGet(v, name))
+ if (_cups_strcasecmp(token, "DEFINE-DEFAULT") || !ippFileGetVar(file, name))
{
- _ippVarsExpand(v, value, temp, sizeof(value));
- _ippVarsSet(v, name, value);
+ ippFileExpandVars(file, value, temp, sizeof(value));
+ ippFileSetVar(file, name, value);
}
}
else
{
- report_error(&f, v, user_data, "Missing %s name and/or value on line %d of \"%s\".", token, f.linenum, f.filename);
+ report_error(file, "Missing %s name and/or value on line %d of '%s'.", token, file->linenum, file->filename);
+ ret = false;
break;
}
}
- else if (f.attrs && !_cups_strcasecmp(token, "ATTR"))
+ else if (file->attrs && with_groups && !_cups_strcasecmp(token, "GROUP"))
+ {
+ // Attribute group...
+ char temp[1024]; // Temporary token
+ ipp_tag_t group_tag; // Group tag
+
+ if (!ippFileReadToken(file, temp, sizeof(temp)))
+ {
+ report_error(file, "Missing GROUP tag on line %d of '%s'.", file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+
+ if ((group_tag = ippTagValue(temp)) == IPP_TAG_ZERO || group_tag >= IPP_TAG_UNSUPPORTED_VALUE)
+ {
+ report_error(file, "Bad GROUP tag '%s' on line %d of '%s'.", temp, file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+
+ if (group_tag == file->group_tag)
+ ippAddSeparator(file->attrs);
+
+ file->group_tag = group_tag;
+ }
+ else if (file->attrs && !_cups_strcasecmp(token, "ATTR"))
{
- /*
- * Attribute definition...
- */
+ // Attribute definition...
+ char syntax[128], // Attribute syntax (value tag)
+ name[128]; // Attribute name
+ ipp_tag_t value_tag; // Value tag
+
+ attr = NULL;
+
+ if (!ippFileReadToken(file, syntax, sizeof(syntax)))
+ {
+ report_error(file, "Missing ATTR syntax on line %d of '%s'.", file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+ else if ((value_tag = ippTagValue(syntax)) < IPP_TAG_UNSUPPORTED_VALUE)
+ {
+ report_error(file, "Bad ATTR syntax \"%s\" on line %d of '%s'.", syntax, file->linenum, file->filename);
+ ret = false;
+ break;
+ }
- char syntax[128], /* Attribute syntax (value tag) */
- name[128]; /* Attribute name */
- ipp_tag_t value_tag; /* Value tag */
+ if (!ippFileReadToken(file, name, sizeof(name)) || !name[0])
+ {
+ report_error(file, "Missing ATTR name on line %d of '%s'.", file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+
+ if (!file->attr_cb || (*file->attr_cb)(file, file->cb_data, name))
+ {
+ // Add this attribute...
+ attrs = file->attrs;
+ }
+ else
+ {
+ // Ignore this attribute...
+ if (!ignored)
+ ignored = ippNew();
+
+ attrs = ignored;
+ }
+
+ if (value_tag < IPP_TAG_INTEGER)
+ {
+ // Add out-of-band attribute - no value string needed...
+ ippAddOutOfBand(attrs, file->group_tag, value_tag, name);
+ }
+ else
+ {
+ // Add attribute with one or more values...
+ attr = ippAddString(attrs, file->group_tag, value_tag, name, NULL, NULL);
+
+ if (!parse_value(file, attrs, &attr, 0))
+ {
+ ret = false;
+ break;
+ }
+ }
+ }
+ else if (file->attrs && (!_cups_strcasecmp(token, "ATTR-IF-DEFINED") || !_cups_strcasecmp(token, "ATTR-IF-NOT-DEFINED")))
+ {
+ // Conditional attribute definition...
+ char varname[128], // Variable name
+ syntax[128], // Attribute syntax (value tag)
+ name[128]; // Attribute name
+ ipp_tag_t value_tag; // Value tag
+
+ if (!ippFileReadToken(file, varname, sizeof(varname)))
+ {
+ report_error(file, "Missing %s variable on line %d of '%s'.", token, file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+
+ if (!ippFileReadToken(file, syntax, sizeof(syntax)))
+ {
+ report_error(file, "Missing %s syntax on line %d of '%s'.", token, file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+ else if ((value_tag = ippTagValue(syntax)) < IPP_TAG_UNSUPPORTED_VALUE)
+ {
+ report_error(file, "Bad %s syntax \"%s\" on line %d of '%s'.", token, syntax, file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+
+ if (!ippFileReadToken(file, name, sizeof(name)) || !name[0])
+ {
+ report_error(file, "Missing %s name on line %d of '%s'.", token, file->linenum, file->filename);
+ ret = false;
+ break;
+ }
+
+ if (!file->attr_cb || (*file->attr_cb)(file, file->cb_data, name))
+ {
+ // Add this attribute...
+ attrs = file->attrs;
+ }
+ else if (!_cups_strcasecmp(token, "ATTR-IF-DEFINED"))
+ {
+ if (ippFileGetVar(file, varname))
+ attrs = file->attrs;
+ else
+ attrs = ignored;
+ }
+ else // ATTR-IF-NOT-DEFINED
+ {
+ if (ippFileGetVar(file, varname))
+ attrs = ignored;
+ else
+ attrs = file->attrs;
+ }
+
+ if (value_tag < IPP_TAG_INTEGER)
+ {
+ // Add out-of-band attribute - no value string needed...
+ ippAddOutOfBand(attrs, file->group_tag, value_tag, name);
+ }
+ else
+ {
+ // Add attribute with one or more values...
+ attr = ippAddString(attrs, file->group_tag, value_tag, name, NULL, NULL);
+
+ if (!parse_value(file, attrs, &attr, 0))
+ {
+ ret = false;
+ break;
+ }
+ }
+ }
+ else if (attr && !_cups_strcasecmp(token, ","))
+ {
+ // Additional value...
+ if (!parse_value(file, attrs, &attr, ippGetCount(attr)))
+ {
+ ret = false;
+ break;
+ }
+ }
+ else
+ {
+ // Something else...
+ attr = NULL;
+ attrs = NULL;
+
+ if (!token_cb)
+ {
+ ret = false;
+ break;
+ }
+ else if ((ret = (token_cb)(file, file->cb_data, token)) == false)
+ {
+ break;
+ }
+ }
+ }
+
+ // Free any ignored attributes and return...
+ ippDelete(ignored);
+
+ return (ret);
+}
+
+
+//
+// 'ippFileReadCollection()' - Read a collection from an IPP data file.
+//
+// This function reads a collection value from an IPP data file. Collection
+// values are surrounded by curly braces ("{" and "}") and have "MEMBER"
+// directives to define member attributes in the collection.
+//
+
+ipp_t * // O - Collection value
+ippFileReadCollection(ipp_file_t *file) // I - IPP data file
+{
+ ipp_t *col; // Collection value
+ ipp_attribute_t *attr = NULL; // Current member attribute
+ char token[1024]; // Token string
+
+
+ // Range check input...
+ if (!file)
+ return (NULL);
+
+ // Read the first token to verify it is an open curly brace...
+ if (!ippFileReadToken(file, token, sizeof(token)))
+ {
+ report_error(file, "Missing collection value on line %d of '%s'.", file->linenum, file->filename);
+ return (NULL);
+ }
+ else if (strcmp(token, "{"))
+ {
+ report_error(file, "Bad collection value on line %d of '%s'.", file->linenum, file->filename);
+ return (NULL);
+ }
+
+ // Parse the collection value...
+ col = ippNew();
+
+ while (ippFileReadToken(file, token, sizeof(token)))
+ {
+ if (!strcmp(token, "}"))
+ {
+ // End of collection value...
+ break;
+ }
+ else if (!_cups_strcasecmp(token, "MEMBER"))
+ {
+ // Member attribute definition...
+ char syntax[128], // Attribute syntax (value tag)
+ name[128]; // Attribute name
+ ipp_tag_t value_tag; // Value tag
attr = NULL;
- if (!_ippFileReadToken(&f, syntax, sizeof(syntax)))
+ if (!ippFileReadToken(file, syntax, sizeof(syntax)))
{
- report_error(&f, v, user_data, "Missing ATTR syntax on line %d of \"%s\".", f.linenum, f.filename);
+ report_error(file, "Missing MEMBER syntax on line %d of '%s'.", file->linenum, file->filename);
+ ippDelete(col);
+ col = NULL;
break;
}
else if ((value_tag = ippTagValue(syntax)) < IPP_TAG_UNSUPPORTED_VALUE)
{
- report_error(&f, v, user_data, "Bad ATTR syntax \"%s\" on line %d of \"%s\".", syntax, f.linenum, f.filename);
+ report_error(file, "Bad MEMBER syntax \"%s\" on line %d of '%s'.", syntax, file->linenum, file->filename);
+ ippDelete(col);
+ col = NULL;
+ break;
+ }
+
+ if (!ippFileReadToken(file, name, sizeof(name)) || !name[0])
+ {
+ report_error(file, "Missing MEMBER name on line %d of '%s'.", file->linenum, file->filename);
+ ippDelete(col);
+ col = NULL;
break;
}
- if (!_ippFileReadToken(&f, name, sizeof(name)) || !name[0])
+ if (value_tag < IPP_TAG_INTEGER)
+ {
+ // Add out-of-band attribute - no value string needed...
+ ippAddOutOfBand(col, IPP_TAG_ZERO, value_tag, name);
+ }
+ else
+ {
+ // Add attribute with one or more values...
+ attr = ippAddString(col, IPP_TAG_ZERO, value_tag, name, NULL, NULL);
+
+ if (!parse_value(file, col, &attr, 0))
+ {
+ ippDelete(col);
+ col = NULL;
+ break;
+ }
+ }
+
+ }
+ else if (attr && !_cups_strcasecmp(token, ","))
+ {
+ // Additional value...
+ if (!parse_value(file, col, &attr, ippGetCount(attr)))
{
- report_error(&f, v, user_data, "Missing ATTR name on line %d of \"%s\".", f.linenum, f.filename);
+ ippDelete(col);
+ col = NULL;
break;
}
+ }
+ else
+ {
+ // Something else...
+ report_error(file, "Unknown directive \"%s\" on line %d of '%s'.", token, file->linenum, file->filename);
+ ippDelete(col);
+ col = NULL;
+ attr = NULL;
+ break;
+
+ }
+ }
+
+ return (col);
+}
+
+
+//
+// 'ippFileReadToken()' - Read a token from an IPP data file.
+//
+// This function reads a single token or value from an IPP data file, skipping
+// comments and whitespace as needed.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileReadToken(ipp_file_t *file, // I - IPP data file
+ char *token, // I - Token buffer
+ size_t tokensize) // I - Size of token buffer
+{
+ int ch, // Character from file
+ quote = 0; // Quoting character
+ char *tokptr = token, // Pointer into token buffer
+ *tokend = token + tokensize - 1;// End of token buffer
+
+
+ // Range check input...
+ if (!file || !token || tokensize < 32)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+
+ if (token)
+ *token = '\0';
+
+ return (false);
+ }
+
+ // Skip whitespace and comments...
+ DEBUG_printf("1ippFileReadToken: linenum=%d, pos=%ld", file->linenum, (long)cupsFileTell(file->fp));
+
+ while ((ch = cupsFileGetChar(file->fp)) != EOF)
+ {
+ if (_cups_isspace(ch))
+ {
+ // Whitespace...
+ if (ch == '\n')
+ {
+ file->linenum ++;
+ DEBUG_printf("1ippFileReadToken: LF in leading whitespace, linenum=%d, pos=%ld", file->linenum, (long)cupsFileTell(file->fp));
+ }
+ }
+ else if (ch == '#')
+ {
+ // Comment...
+ DEBUG_puts("1ippFileReadToken: Skipping comment in leading whitespace...");
+
+ while ((ch = cupsFileGetChar(file->fp)) != EOF)
+ {
+ if (ch == '\n')
+ break;
+ }
+
+ if (ch == '\n')
+ {
+ file->linenum ++;
+ DEBUG_printf("1ippFileReadToken: LF at end of comment, linenum=%d, pos=%ld", file->linenum, (long)cupsFileTell(file->fp));
+ }
+ else
+ break;
+ }
+ else
+ break;
+ }
+
+ if (ch == EOF)
+ {
+ DEBUG_puts("1ippFileReadToken: EOF");
+ return (false);
+ }
+
+ // Read a token...
+ while (ch != EOF)
+ {
+ if (ch == '\n')
+ {
+ file->linenum ++;
+ DEBUG_printf("1ippFileReadToken: LF in token, linenum=%d, pos=%ld", file->linenum, (long)cupsFileTell(file->fp));
+ }
+
+ if (ch == quote)
+ {
+ // End of quoted text...
+ *tokptr = '\0';
+ DEBUG_printf("1ippFileReadToken: Returning \"%s\" at closing quote.", token);
+ return (true);
+ }
+ else if (!quote && _cups_isspace(ch))
+ {
+ // End of unquoted text...
+ *tokptr = '\0';
+ DEBUG_printf("1ippFileReadToken: Returning \"%s\" before whitespace.", token);
+ return (true);
+ }
+ else if (!quote && (ch == '\'' || ch == '\"'))
+ {
+ // Start of quoted text or regular expression...
+ quote = ch;
+
+ DEBUG_printf("1ippFileReadToken: Start of quoted string, quote=%c, pos=%ld", quote, (long)cupsFileTell(file->fp));
+ }
+ else if (!quote && ch == '#')
+ {
+ // Start of comment...
+ cupsFileSeek(file->fp, cupsFileTell(file->fp) - 1);
+ *tokptr = '\0';
+ DEBUG_printf("1ippFileReadToken: Returning \"%s\" before comment.", token);
+ return (true);
+ }
+ else if (!quote && (ch == '{' || ch == '}' || ch == ','))
+ {
+ // Delimiter...
+ if (tokptr > token)
+ {
+ // Return the preceding token first...
+ cupsFileSeek(file->fp, cupsFileTell(file->fp) - 1);
+ }
+ else
+ {
+ // Return this delimiter by itself...
+ *tokptr++ = (char)ch;
+ }
+
+ *tokptr = '\0';
+ DEBUG_printf("1ippFileReadToken: Returning \"%s\".", token);
+ return (true);
+ }
+ else
+ {
+ if (ch == '\\')
+ {
+ // Quoted character...
+ DEBUG_printf("1ippFileReadToken: Quoted character at pos=%ld", (long)cupsFileTell(file->fp));
+
+ if ((ch = cupsFileGetChar(file->fp)) == EOF)
+ {
+ *token = '\0';
+ DEBUG_puts("1ippFileReadToken: EOF");
+ return (false);
+ }
+ else if (ch == '\n')
+ {
+ file->linenum ++;
+ DEBUG_printf("1ippFileReadToken: quoted LF, linenum=%d, pos=%ld", file->linenum, (long)cupsFileTell(file->fp));
+ }
+ else if (ch == 'a')
+ ch = '\a';
+ else if (ch == 'b')
+ ch = '\b';
+ else if (ch == 'f')
+ ch = '\f';
+ else if (ch == 'n')
+ ch = '\n';
+ else if (ch == 'r')
+ ch = '\r';
+ else if (ch == 't')
+ ch = '\t';
+ else if (ch == 'v')
+ ch = '\v';
+ }
+
+ if (tokptr < tokend)
+ {
+ // Add to current token...
+ *tokptr++ = (char)ch;
+ }
+ else
+ {
+ // Token too long...
+ *tokptr = '\0';
+ DEBUG_printf("1ippFileReadToken: Too long: \"%s\".", token);
+ return (false);
+ }
+ }
+
+ // Get the next character...
+ ch = cupsFileGetChar(file->fp);
+ }
+
+ *tokptr = '\0';
+ DEBUG_printf("1ippFileReadToken: Returning \"%s\" at EOF.", token);
+
+ return (tokptr > token);
+}
+
+
+//
+// 'ippFileRestorePosition()' - Restore the previous position in an IPP data file.
+//
+// This function restores the previous position in an IPP data file that is open
+// for reading.
+//
+
+bool // O - `true` on success, `false` on failure
+ippFileRestorePosition(ipp_file_t *file)// I - IPP data file
+{
+ // Range check input...
+ if (!file || file->mode != 'r' || file->save_line == 0)
+ return (false);
+
+ // Seek back to the saved position...
+ if (cupsFileSeek(file->fp, file->save_pos) != file->save_pos)
+ return (false);
+
+ file->linenum = file->save_line;
+ file->save_pos = 0;
+ file->save_line = 0;
+
+ return (true);
+}
+
+
+//
+// 'ippFileSavePosition()' - Save the current position in an IPP data file.
+//
+// This function saves the current position in an IPP data file that is open
+// for reading.
+//
+
+bool // O - `true` on success, `false` on failure
+ippFileSavePosition(ipp_file_t *file) // I - IPP data file
+{
+ // Range check input...
+ if (!file || file->mode != 'r')
+ return (false);
+
+ // Save the current position...
+ file->save_pos = cupsFileTell(file->fp);
+ file->save_line = file->linenum;
+
+ return (true);
+}
+
+
+//
+// 'ippFileSetAttributes()' - Set the attributes for an IPP data file.
+//
+// This function sets the current set of attributes for an IPP data file,
+// typically an empty collection created with @link ippNew@.
+//
+
+bool // O - `true` on success, `false` otherwise
+ippFileSetAttributes(ipp_file_t *file, // I - IPP data file
+ ipp_t *attrs) // I - IPP attributes
+{
+ if (file)
+ {
+ file->attrs = attrs;
+ return (true);
+ }
+
+ return (false);
+}
+
+
+//
+// 'ippFileSetGroupTag()' - Set the group tag for an IPP data file.
+//
+// This function sets the group tag associated with attributes that are read
+// from an IPP data file.
+//
+
+bool // O - `true` on success, `false` otherwise
+ippFileSetGroupTag(ipp_file_t *file, // I - IPP data file
+ ipp_tag_t group_tag)// I - Group tag
+{
+ if (file && group_tag >= IPP_TAG_OPERATION && group_tag <= IPP_TAG_SYSTEM)
+ {
+ file->group_tag = group_tag;
+ return (true);
+ }
+
+ return (false);
+}
+
+
+//
+// 'ippFileSetVar()' - Set an IPP data file variable to a constant value.
+//
+// This function sets an IPP data file variable to a constant value. Setting
+// the "uri" variable also initializes the "scheme", "uriuser", "hostname",
+// "port", and "resource" variables.
+//
+
+bool // O - `true` on success, `false` on failure
+ippFileSetVar(ipp_file_t *file, // I - IPP data file
+ const char *name, // I - Variable name
+ const char *value) // I - Value
+{
+ if (!file || !name || !value)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ // Save new variable...
+ if (!strcmp(name, "uri"))
+ {
+ // Also set URI component values...
+ char uri[1024], // New printer URI
+ resolved[1024], // Resolved mDNS URI
+ scheme[32], // URI scheme
+ userpass[256], // URI username:password
+ *password, // Pointer to password
+ hostname[256], // URI hostname
+ resource[256]; // URI resource path
+ int port; // URI port number
+ http_uri_status_t uri_status; // URI decoding status
+
+ if (strstr(value, "._tcp"))
+ {
+ // Resolve URI...
+ if (!httpResolveURI(value, resolved, sizeof(resolved), HTTP_RESOLVE_DEFAULT, NULL, NULL))
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOENT), 0);
+ return (false);
+ }
+
+ value = resolved;
+ }
+
+ if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource))) < HTTP_URI_STATUS_OK)
+ {
+ // Bad URI...
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, httpURIStatusString(uri_status), 0);
+ return (false);
+ }
+ else
+ {
+ // Valid URI...
+ if ((password = strchr(userpass, ':')) != NULL)
+ {
+ // Separate and save password from URI...
+ *password++ = '\0';
+
+ file->num_vars = cupsAddOption("uripassword", password, file->num_vars, &file->vars);
+ }
+
+ file->num_vars = cupsAddOption("scheme", scheme, file->num_vars, &file->vars);
+ file->num_vars = cupsAddOption("uriuser", userpass, file->num_vars, &file->vars);
+ file->num_vars = cupsAddOption("hostname", hostname, file->num_vars, &file->vars);
+ file->num_vars = cupsAddIntegerOption("port", port, file->num_vars, &file->vars);
+ file->num_vars = cupsAddOption("resource", resource, file->num_vars, &file->vars);
+
+ // Reassemble URI without username or password...
+ httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), scheme, NULL, hostname, port, resource);
+ file->num_vars = cupsAddOption("uri", uri, file->num_vars, &file->vars);
+ }
+ }
+ else
+ {
+ // Set another variable...
+ file->num_vars = cupsAddOption(name, value, file->num_vars, &file->vars);
+ }
+
+ return (true);
+}
+
+
+//
+// 'ippFileSetVarf()' - Set an IPP data file variable to a formatted value.
+//
+// This function sets an IPP data file variable to a formatted value. Setting
+// the "uri" variable also initializes the "scheme", "uriuser", "hostname",
+// "port", and "resource" variables.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileSetVarf(ipp_file_t *file, // I - IPP data file
+ const char *name, // I - Variable name
+ const char *value, // I - Printf-style value
+ ...) // I - Additional arguments as needed
+{
+ va_list ap; // Pointer to arguments
+ char buffer[16384]; // Value buffer
+
+
+ if (!file || !name || !value)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ va_start(ap, value);
+ vsnprintf(buffer, sizeof(buffer), value, ap);
+ va_end(ap);
+
+ return (ippFileSetVar(file, name, buffer));
+}
+
+
+//
+// 'ippFileWriteAttributes()' - Write an IPP message to an IPP data file.
+//
+// This function writes an IPP message to an IPP data file using the attribute
+// filter specified in the call to @link ippFileOpen@. If "with_group" is
+// `true`, "GROUP" directives are written as necessary to place the attributes
+// in the correct groups.
+//
+
+bool // O - `true` on success, `false` on error
+ippFileWriteAttributes(
+ ipp_file_t *file, // I - IPP data file
+ ipp_t *ipp, // I - IPP attributes to write
+ bool with_groups) // I - `true` to include GROUPs, `false` otherwise
+{
+ bool ret = true; // Return value
+ ipp_attribute_t *attr; // Current attribute
+ const char *name; // Attribute name
+ ipp_tag_t group_tag, // Group tag
+ value_tag; // Value tag
+ size_t i, // Looping var
+ count; // Number of values
+
+
+ // Range check input...
+ if (!file || file->mode != 'w' || !ipp)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ // Make sure we are on a new line...
+ if (file->column)
+ {
+ cupsFilePutChar(file->fp, '\n');
+ file->column = 0;
+ }
+
+ // Loop through the attributes...
+ for (attr = ippGetFirstAttribute(ipp); attr; attr = ippGetNextAttribute(ipp))
+ {
+ if ((name = ippGetName(attr)) == NULL)
+ continue;
+
+ if (file->attr_cb && !(*file->attr_cb)(file, file->cb_data, name))
+ continue;
+
+ count = ippGetCount(attr);
+ group_tag = ippGetGroupTag(attr);
+ value_tag = ippGetValueTag(attr);
+
+ if (with_groups && group_tag != IPP_TAG_ZERO && group_tag != file->group_tag)
+ {
+ ret &= ippFileWriteToken(file, "GROUP");
+ ret &= ippFileWriteTokenf(file, "%s\n", ippTagString(group_tag));
+ file->group_tag = group_tag;
+ }
+
+ ret &= ippFileWriteToken(file, group_tag == IPP_TAG_ZERO ? "MEMBER" : "ATTR");
+ ret &= ippFileWriteToken(file, ippTagString(value_tag));
+ ret &= ippFileWriteToken(file, name);
+
+ switch (value_tag)
+ {
+ case IPP_TAG_INTEGER :
+ case IPP_TAG_ENUM :
+ for (i = 0; i < count; i ++)
+ ret &= cupsFilePrintf(file->fp, "%s%d", i ? "," : " ", ippGetInteger(attr, i));
+ break;
- if (!v->attrcb || (*v->attrcb)(&f, user_data, name))
- {
- /*
- * Add this attribute...
- */
+ case IPP_TAG_BOOLEAN :
+ ret &= cupsFilePuts(file->fp, ippGetBoolean(attr, 0) ? " true" : " false");
- attrs = f.attrs;
- }
- else
- {
- /*
- * Ignore this attribute...
- */
+ for (i = 1; i < count; i ++)
+ ret &= cupsFilePuts(file->fp, ippGetBoolean(attr, 1) ? ",true" : ",false");
+ break;
- if (!ignored)
- ignored = ippNew();
+ case IPP_TAG_RANGE :
+ for (i = 0; i < count; i ++)
+ {
+ int upper, lower = ippGetRange(attr, i, &upper);
+ // Upper/lower range values
- attrs = ignored;
- }
+ ret &= cupsFilePrintf(file->fp, "%s%d-%d", i ? "," : " ", lower, upper);
+ }
+ break;
- if (value_tag < IPP_TAG_INTEGER)
- {
- /*
- * Add out-of-band attribute - no value string needed...
- */
+ case IPP_TAG_RESOLUTION :
+ for (i = 0; i < count; i ++)
+ {
+ ipp_res_t units; // Resolution units
+ int yres, xres = ippGetResolution(attr, i, &yres, &units);
+ // X/Y resolution
- ippAddOutOfBand(attrs, f.group_tag, value_tag, name);
- }
- else
- {
- /*
- * Add attribute with one or more values...
- */
+ if (xres == yres)
+ ret &= cupsFilePrintf(file->fp, "%s%d%s", i ? "," : " ", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
+ else
+ ret &= cupsFilePrintf(file->fp, "%s%dx%d%s", i ? "," : " ", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
+ }
+ break;
- attr = ippAddString(attrs, f.group_tag, value_tag, name, NULL, NULL);
+ case IPP_TAG_DATE :
+ for (i = 0; i < count; i ++)
+ {
+ time_t utctime = ippDateToTime(ippGetDate(attr, i));
+ // Date/time value
+ struct tm utcdate; // Date/time components
- if (!parse_value(&f, v, user_data, attrs, &attr, 0))
- break;
- }
+ // Get the UTC date and time corresponding to this date value...
+ gmtime_r(&utctime, &utcdate);
- }
- else if (attr && !_cups_strcasecmp(token, ","))
- {
- /*
- * Additional value...
- */
+ ret &= cupsFilePrintf(file->fp, "%s%04d-%02d-%02dT%02d:%02d:%02dZ", i ? "," : " ", utcdate.tm_year + 1900, utcdate.tm_mon + 1, utcdate.tm_mday, utcdate.tm_hour, utcdate.tm_min, utcdate.tm_sec);
+ }
+ break;
- if (!parse_value(&f, v, user_data, attrs, &attr, ippGetCount(attr)))
- break;
- }
- else
- {
- /*
- * Something else...
- */
+ case IPP_TAG_STRING :
+ for (i = 0; i < count; i ++)
+ {
+ size_t len; // Length of octetString
+ const char *s = (const char *)ippGetOctetString(attr, i, &len);
+ // octetString value
- attr = NULL;
- attrs = NULL;
+ ret &= cupsFilePuts(file->fp, i ? "," : " ");
+ ret &= write_string(file, s, len);
+ }
+ break;
+
+ case IPP_TAG_TEXT :
+ case IPP_TAG_TEXTLANG :
+ case IPP_TAG_NAME :
+ case IPP_TAG_NAMELANG :
+ case IPP_TAG_KEYWORD :
+ case IPP_TAG_URI :
+ case IPP_TAG_URISCHEME :
+ case IPP_TAG_CHARSET :
+ case IPP_TAG_LANGUAGE :
+ case IPP_TAG_MIMETYPE :
+ for (i = 0; i < count; i ++)
+ {
+ const char *s = ippGetString(attr, i, NULL);
+ // String value
- if (!(*v->tokencb)(&f, v, user_data, token))
- break;
- }
- }
+ ret &= cupsFilePuts(file->fp, i ? "," : " ");
+ ret &= write_string(file, s, strlen(s));
+ }
+ break;
+
+ case IPP_TAG_BEGIN_COLLECTION :
+ file->indent += 4;
+ for (i = 0; i < count; i ++)
+ {
+ ret &= cupsFilePuts(file->fp, i ? ",{\n" : " {\n");
+ ret &= ippFileWriteAttributes(file, ippGetCollection(attr, i), false);
+ ret &= cupsFilePrintf(file->fp, "%*s}", file->indent - 4, "");
+ }
+ file->indent -= 4;
+ break;
- /*
- * Close the file and free ignored attributes, then return any attributes we
- * kept...
- */
+ default :
+ /* Out-of-band value */
+ break;
+ }
- cupsFileClose(f.fp);
- ippDelete(ignored);
+ // Finish with a newline after the attribute definition
+ ret &= cupsFilePutChar(file->fp, '\n');
+ }
- return (f.attrs);
+ return (ret);
}
-/*
- * '_ippFileReadToken()' - Read a token from an IPP data file.
- */
+//
+// 'ippFileWriteComment()' - Write a comment to an IPP data file.
+//
+// This function writes a comment to an IPP data file. Every line in the string
+// is prefixed with the "#" character and indented as needed.
+//
-int /* O - 1 on success, 0 on failure */
-_ippFileReadToken(_ipp_file_t *f, /* I - File to read from */
- char *token, /* I - Token string buffer */
- size_t tokensize)/* I - Size of token string buffer */
+bool // O - `true` on success, `false` on error
+ippFileWriteComment(ipp_file_t *file, // I - IPP data file
+ const char *comment,// I - Printf-style comment string
+ ...) // I - Additional arguments as needed
{
- int ch, /* Character from file */
- quote = 0; /* Quoting character */
- char *tokptr = token, /* Pointer into token buffer */
- *tokend = token + tokensize - 1;/* End of token buffer */
+ bool ret = true; // Return value
+ va_list ap, // Pointer to arguments
+ ap2; // Copy of arguments
+ int bufsize; // Size of formatted string
+ const char *start, // Start of comment line
+ *ptr; // Pointer into comment
- /*
- * Skip whitespace and comments...
- */
+ // Range check input...
+ if (!file || file->mode != 'w' || !comment)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
- DEBUG_printf("1_ippFileReadToken: linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
+ // Format the comment...
+ va_start(ap, comment);
+ va_copy(ap2, ap);
- while ((ch = cupsFileGetChar(f->fp)) != EOF)
+ if ((bufsize = vsnprintf(file->buffer, file->alloc_buffer, comment, ap2)) >= (int)file->alloc_buffer)
{
- if (_cups_isspace(ch))
+ if (!expand_buffer(file, (size_t)bufsize + 1))
{
- /*
- * Whitespace...
- */
-
- if (ch == '\n')
- {
- f->linenum ++;
- DEBUG_printf("1_ippFileReadToken: LF in leading whitespace, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
- }
+ va_end(ap2);
+ va_end(ap);
+ return (false);
}
- else if (ch == '#')
- {
- /*
- * Comment...
- */
- DEBUG_puts("1_ippFileReadToken: Skipping comment in leading whitespace...");
+ vsnprintf(file->buffer, file->alloc_buffer, comment, ap);
+ }
- while ((ch = cupsFileGetChar(f->fp)) != EOF)
- {
- if (ch == '\n')
- break;
- }
+ va_end(ap2);
+ va_end(ap);
- if (ch == '\n')
- {
- f->linenum ++;
- DEBUG_printf("1_ippFileReadToken: LF at end of comment, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
- }
- else
- break;
- }
- else
- break;
+ // Make sure we start on a new line...
+ if (file->column > 0)
+ {
+ ret &= cupsFilePutChar(file->fp, '\n');
+ file->column = 0;
}
- if (ch == EOF)
+ for (start = file->buffer, ptr = start; *ptr; start = ptr)
{
- DEBUG_puts("1_ippFileReadToken: EOF");
- return (0);
+ // Find the end of the line...
+ while (*ptr && *ptr != '\n')
+ ptr ++;
+
+ // Write this line...
+ ret &= cupsFilePrintf(file->fp, "%*s# ", file->indent, "");
+ ret &= cupsFileWrite(file->fp, start, (size_t)(ptr - start));
+ ret &= cupsFilePutChar(file->fp, '\n');
+
+ // Skip newline, if any...
+ if (*ptr)
+ ptr ++;
}
- /*
- * Read a token...
- */
+ return (ret);
+}
- while (ch != EOF)
- {
- if (ch == '\n')
- {
- f->linenum ++;
- DEBUG_printf("1_ippFileReadToken: LF in token, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
- }
- if (ch == quote)
- {
- /*
- * End of quoted text...
- */
+//
+// 'ippFileWriteToken()' - Write a token or value string to an IPP data file.
+//
+// This function writes a token or value string to an IPP data file, quoting
+// and indenting the string as needed.
+//
- *tokptr = '\0';
- DEBUG_printf("1_ippFileReadToken: Returning \"%s\" at closing quote.", token);
- return (1);
- }
- else if (!quote && _cups_isspace(ch))
- {
- /*
- * End of unquoted text...
- */
+bool // O - `true` on success, `false` on error
+ippFileWriteToken(ipp_file_t *file, // I - IPP data file
+ const char *token) // I - Token/value string
+{
+ const char *ptr; // Pointer into token/value string
+ bool ret = true; // Return value
- *tokptr = '\0';
- DEBUG_printf("1_ippFileReadToken: Returning \"%s\" before whitespace.", token);
- return (1);
- }
- else if (!quote && (ch == '\'' || ch == '\"'))
- {
- /*
- * Start of quoted text or regular expression...
- */
- quote = ch;
+ // Range check input...
+ if (!file || file->mode != 'w' || !token)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
- DEBUG_printf("1_ippFileReadToken: Start of quoted string, quote=%c, pos=%ld", quote, (long)cupsFileTell(f->fp));
- }
- else if (!quote && ch == '#')
+ // Handle indentation...
+ if (!strcmp(token, "}"))
+ {
+ // Add newline before '}' as needed and unindent...
+ if (file->column > 0)
{
- /*
- * Start of comment...
- */
-
- cupsFileSeek(f->fp, cupsFileTell(f->fp) - 1);
- *tokptr = '\0';
- DEBUG_printf("1_ippFileReadToken: Returning \"%s\" before comment.", token);
- return (1);
+ ret &= cupsFilePutChar(file->fp, '\n');
+ file->column = 0;
}
- else if (!quote && (ch == '{' || ch == '}' || ch == ','))
- {
- /*
- * Delimiter...
- */
- if (tokptr > token)
- {
- /*
- * Return the preceding token first...
- */
+ if (file->indent > 0)
+ file->indent -= 4;
+ }
- cupsFileSeek(f->fp, cupsFileTell(f->fp) - 1);
- }
- else
- {
- /*
- * Return this delimiter by itself...
- */
+ if (file->column == 0 && file->indent > 0)
+ {
+ ret &= cupsFilePrintf(file->fp, "%*s", file->indent, "");
+ file->column += file->indent;
+ }
+ else if (strcmp(token, "{") && strcmp(token, "}"))
+ {
+ ret &= cupsFilePutChar(file->fp, ' ');
+ file->column ++;
+ }
- *tokptr++ = (char)ch;
- }
+ // Look for whitespace or special characters...
+ for (ptr = token; *ptr; ptr ++)
+ {
+ if (strchr(" \t\'\"\\", *ptr))
+ break;
+ }
- *tokptr = '\0';
- DEBUG_printf("1_ippFileReadToken: Returning \"%s\".", token);
- return (1);
+ if (*ptr)
+ {
+ // Need to quote the string
+ ret &= write_string(file, token, strlen(token));
+ }
+ else if (!strcmp(token, "{"))
+ {
+ // Add newline after '{' and indent...
+ ret &= cupsFilePuts(file->fp, "{\n");
+ file->column = 0;
+ file->indent += 4;
+ }
+ else if (!strcmp(token, "}"))
+ {
+ // Add newline after '}'...
+ ret &= cupsFilePuts(file->fp, "}\n");
+ file->column = 0;
+ }
+ else
+ {
+ // Just write the string as-is...
+ ret &= cupsFilePuts(file->fp, token);
+
+ if ((ptr = token + strlen(token) - 1) >= token && *ptr == '\n')
+ {
+ // New line...
+ file->column = 0;
}
else
{
- if (ch == '\\')
- {
- /*
- * Quoted character...
- */
-
- DEBUG_printf("1_ippFileReadToken: Quoted character at pos=%ld", (long)cupsFileTell(f->fp));
-
- if ((ch = cupsFileGetChar(f->fp)) == EOF)
- {
- *token = '\0';
- DEBUG_puts("1_ippFileReadToken: EOF");
- return (0);
- }
- else if (ch == '\n')
- {
- f->linenum ++;
- DEBUG_printf("1_ippFileReadToken: quoted LF, linenum=%d, pos=%ld", f->linenum, (long)cupsFileTell(f->fp));
- }
- else if (ch == 'a')
- ch = '\a';
- else if (ch == 'b')
- ch = '\b';
- else if (ch == 'f')
- ch = '\f';
- else if (ch == 'n')
- ch = '\n';
- else if (ch == 'r')
- ch = '\r';
- else if (ch == 't')
- ch = '\t';
- else if (ch == 'v')
- ch = '\v';
- }
-
- if (tokptr < tokend)
- {
- /*
- * Add to current token...
- */
-
- *tokptr++ = (char)ch;
- }
- else
- {
- /*
- * Token too long...
- */
-
- *tokptr = '\0';
- DEBUG_printf("1_ippFileReadToken: Too long: \"%s\".", token);
- return (0);
- }
+ // Existing line...
+ file->column += strlen(token);
}
-
- /*
- * Get the next character...
- */
-
- ch = cupsFileGetChar(f->fp);
}
- *tokptr = '\0';
- DEBUG_printf("1_ippFileReadToken: Returning \"%s\" at EOF.", token);
-
- return (tokptr > token);
+ return (ret);
}
-/*
- * 'parse_collection()' - Parse an IPP collection value.
- */
+//
+// 'ippFileWriteTokenf()' - Write a formatted token or value string to an IPP data file.
+//
+// This function writes a formatted token or value string to an IPP data file,
+// quoting and indenting the string as needed.
+//
-static ipp_t * /* O - Collection value or @code NULL@ on error */
-parse_collection(
- _ipp_file_t *f, /* I - IPP data file */
- _ipp_vars_t *v, /* I - IPP variables */
- void *user_data) /* I - User data pointer */
+bool // O - `true` on success, `false` on error
+ippFileWriteTokenf(ipp_file_t *file, // I - IPP data file
+ const char *token, // I - Printf-style token/value string
+ ...) // I - Additional arguments as needed
{
- ipp_t *col = ippNew(); /* Collection value */
- ipp_attribute_t *attr = NULL; /* Current member attribute */
- char token[1024]; /* Token string */
+ va_list ap, // Pointer to arguments
+ ap2; // Copy of arguments
+ int bufsize; // Size of formatted string
+
+ // Range check input...
+ if (!file || file->mode != 'w' || !token)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
- /*
- * Parse the collection value...
- */
+ // Format the message...
+ va_start(ap, token);
+ va_copy(ap2, ap);
- while (_ippFileReadToken(f, token, sizeof(token)))
+ if ((bufsize = vsnprintf(file->buffer, file->alloc_buffer, token, ap2)) >= (int)file->alloc_buffer)
{
- if (!_cups_strcasecmp(token, "}"))
+ if (!expand_buffer(file, (size_t)bufsize + 1))
{
- /*
- * End of collection value...
- */
-
- break;
+ va_end(ap2);
+ va_end(ap);
+ return (false);
}
- else if (!_cups_strcasecmp(token, "MEMBER"))
- {
- /*
- * Member attribute definition...
- */
-
- char syntax[128], /* Attribute syntax (value tag) */
- name[128]; /* Attribute name */
- ipp_tag_t value_tag; /* Value tag */
-
- attr = NULL;
- if (!_ippFileReadToken(f, syntax, sizeof(syntax)))
- {
- report_error(f, v, user_data, "Missing MEMBER syntax on line %d of \"%s\".", f->linenum, f->filename);
- ippDelete(col);
- col = NULL;
- break;
- }
- else if ((value_tag = ippTagValue(syntax)) < IPP_TAG_UNSUPPORTED_VALUE)
- {
- report_error(f, v, user_data, "Bad MEMBER syntax \"%s\" on line %d of \"%s\".", syntax, f->linenum, f->filename);
- ippDelete(col);
- col = NULL;
- break;
- }
+ vsnprintf(file->buffer, file->alloc_buffer, token, ap);
+ }
- if (!_ippFileReadToken(f, name, sizeof(name)) || !name[0])
- {
- report_error(f, v, user_data, "Missing MEMBER name on line %d of \"%s\".", f->linenum, f->filename);
- ippDelete(col);
- col = NULL;
- break;
- }
+ va_end(ap2);
+ va_end(ap);
- if (value_tag < IPP_TAG_INTEGER)
- {
- /*
- * Add out-of-band attribute - no value string needed...
- */
+ return (ippFileWriteToken(file, file->buffer));
+}
- ippAddOutOfBand(col, IPP_TAG_ZERO, value_tag, name);
- }
- else
- {
- /*
- * Add attribute with one or more values...
- */
- attr = ippAddString(col, IPP_TAG_ZERO, value_tag, name, NULL, NULL);
+//
+// 'expand_buffer()' - Expand the output buffer of the IPP data file as needed.
+//
- if (!parse_value(f, v, user_data, col, &attr, 0))
- {
- ippDelete(col);
- col = NULL;
- break;
- }
- }
+static bool // O - `true` on success, `false` on failure
+expand_buffer(ipp_file_t *file, // I - IPP data file
+ size_t buffer_size) // I - Required size
+{
+ char *buffer; // New buffer pointer
- }
- else if (attr && !_cups_strcasecmp(token, ","))
- {
- /*
- * Additional value...
- */
- if (!parse_value(f, v, user_data, col, &attr, ippGetCount(attr)))
- {
- ippDelete(col);
- col = NULL;
- break;
- }
- }
- else
- {
- /*
- * Something else...
- */
+ // If we already have enough, return right away...
+ if (buffer_size <= file->alloc_buffer)
+ return (true);
- report_error(f, v, user_data, "Unknown directive \"%s\" on line %d of \"%s\".", token, f->linenum, f->filename);
- ippDelete(col);
- col = NULL;
- attr = NULL;
- break;
+ // Try allocating/expanding the current buffer...
+ if ((buffer = realloc(file->buffer, buffer_size)) == NULL)
+ return (false);
- }
- }
+ // Save new buffer and size...
+ file->buffer = buffer;
+ file->alloc_buffer = buffer_size;
- return (col);
+ return (true);
}
-/*
- * 'parse_value()' - Parse an IPP value.
- */
+//
+// 'parse_value()' - Parse an IPP value.
+//
-static int /* O - 1 on success or 0 on error */
-parse_value(_ipp_file_t *f, /* I - IPP data file */
- _ipp_vars_t *v, /* I - IPP variables */
- void *user_data,/* I - User data pointer */
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element) /* I - Element number */
+static bool // O - `true` on success or `false` on error
+parse_value(ipp_file_t *file, // I - IPP data file
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ size_t element) // I - Element number
{
- char value[2049], /* Value string */
- *valueptr, /* Pointer into value string */
- temp[2049], /* Temporary string */
- *tempptr; /* Pointer into temporary string */
- size_t valuelen; /* Length of value */
+ char value[2049], // Value string
+ *valueptr, // Pointer into value string
+ temp[2049], // Temporary string
+ *tempptr; // Pointer into temporary string
+ size_t valuelen; // Length of value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ ippFileSavePosition(file);
+
+ if (!ippFileReadToken(file, temp, sizeof(temp)))
{
- report_error(f, v, user_data, "Missing value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ report_error(file, "Missing value on line %d of '%s'.", file->linenum, file->filename);
+ return (false);
}
- _ippVarsExpand(v, value, temp, sizeof(value));
+ ippFileExpandVars(file, value, temp, sizeof(value));
switch (ippGetValueTag(*attr))
{
case IPP_TAG_DATE :
{
- int year, /* Year */
- month, /* Month */
- day, /* Day of month */
- hour, /* Hour */
- minute, /* Minute */
- second, /* Second */
- utc_offset = 0; /* Timezone offset from UTC */
- ipp_uchar_t date[11]; /* dateTime value */
+ int year, // Year
+ month, // Month
+ day, // Day of month
+ hour, // Hour
+ minute, // Minute
+ second, // Second
+ utc_offset = 0; // Timezone offset from UTC
+ ipp_uchar_t date[11]; // dateTime value
if (*value == 'P')
{
- /*
- * Time period...
- */
-
- time_t curtime; /* Current time in seconds */
- int period = 0, /* Current period value */
- saw_T = 0; /* Saw time separator */
+ // Time period...
+ time_t curtime; // Current time in seconds
+ int period = 0; // Current period value
+ bool saw_T = false; // Saw time separator?
curtime = time(NULL);
if (!valueptr || period < 0)
{
- report_error(f, v, user_data, "Bad dateTime value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ report_error(file, "Bad dateTime value \"%s\" on line %d of '%s'.", value, file->linenum, file->filename);
+ return (false);
}
}
}
else if (*valueptr == 'T')
{
- saw_T = 1;
+ saw_T = true;
period = 0;
}
else
{
- report_error(f, v, user_data, "Bad dateTime value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ report_error(file, "Bad dateTime value \"%s\" on line %d of '%s'.", value, file->linenum, file->filename);
+ return (false);
}
}
}
else if (sscanf(value, "%d-%d-%dT%d:%d:%d%d", &year, &month, &day, &hour, &minute, &second, &utc_offset) < 6)
{
- /*
- * Date/time value did not parse...
- */
-
- report_error(f, v, user_data, "Bad dateTime value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ // Date/time value did not parse...
+ report_error(file, "Bad dateTime value \"%s\" on line %d of '%s'.", value, file->linenum, file->filename);
+ return (false);
}
date[0] = (ipp_uchar_t)(year >> 8);
case IPP_TAG_RESOLUTION :
{
- int xres, /* X resolution */
- yres; /* Y resolution */
- char *ptr; /* Pointer into value */
+ int xres, // X resolution
+ yres; // Y resolution
+ char *ptr; // Pointer into value
- xres = yres = (int)strtol(value, &ptr, 10);
+ xres = yres = (int)strtol(value, (char **)&ptr, 10);
if (ptr > value && xres > 0)
{
if (*ptr == 'x')
- yres = (int)strtol(ptr + 1, &ptr, 10);
+ yres = (int)strtol(ptr + 1, (char **)&ptr, 10);
}
if (ptr <= value || xres <= 0 || yres <= 0 || !ptr || (_cups_strcasecmp(ptr, "dpi") && _cups_strcasecmp(ptr, "dpc") && _cups_strcasecmp(ptr, "dpcm") && _cups_strcasecmp(ptr, "other")))
{
- report_error(f, v, user_data, "Bad resolution value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ report_error(file, "Bad resolution value \"%s\" on line %d of '%s'.", value, file->linenum, file->filename);
+ return (false);
}
if (!_cups_strcasecmp(ptr, "dpi"))
case IPP_TAG_RANGE :
{
- int lower, /* Lower value */
- upper; /* Upper value */
+ int lower, // Lower value
+ upper; // Upper value
if (sscanf(value, "%d-%d", &lower, &upper) != 2)
{
- report_error(f, v, user_data, "Bad rangeOfInteger value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ report_error(file, "Bad rangeOfInteger value \"%s\" on line %d of '%s'.", value, file->linenum, file->filename);
+ return (false);
}
return (ippSetRange(ipp, attr, element, lower, upper));
{
if (valuelen & 1)
{
- report_error(f, v, user_data, "Bad octetString value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ report_error(file, "Bad octetString value on line %d of '%s'.", file->linenum, file->filename);
+ return (false);
}
valueptr = value + 1;
tempptr = temp;
- while (*valueptr && *valueptr != '>')
+ while (*valueptr && *valueptr != '>' && tempptr < (temp + sizeof(temp)))
{
if (!isxdigit(valueptr[0] & 255) || !isxdigit(valueptr[1] & 255))
{
- report_error(f, v, user_data, "Bad octetString value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ report_error(file, "Bad octetString value on line %d of '%s'.", file->linenum, file->filename);
+ return (false);
}
if (valueptr[0] >= '0' && valueptr[0] <= '9')
*tempptr |= (tolower(valueptr[1]) - 'a' + 10);
tempptr ++;
+ valueptr += 2;
}
- return (ippSetOctetString(ipp, attr, element, temp, (int)(tempptr - temp)));
+ if (*valueptr != '>')
+ {
+ if (*valueptr)
+ report_error(file, "octetString value too long on line %d of '%s'.", file->linenum, file->filename);
+ else
+ report_error(file, "Bad octetString value on line %d of '%s'.", file->linenum, file->filename);
+
+ return (false);
+ }
+
+ return (ippSetOctetString(ipp, attr, element, temp, (size_t)(tempptr - temp)));
}
else
- return (ippSetOctetString(ipp, attr, element, value, (int)valuelen));
+ return (ippSetOctetString(ipp, attr, element, value, valuelen));
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
case IPP_TAG_BEGIN_COLLECTION :
{
- int status; /* Add status */
- ipp_t *col; /* Collection value */
+ bool status; // Add status
+ ipp_t *col; // Collection value
- if (strcmp(value, "{"))
- {
- report_error(f, v, user_data, "Bad collection value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
- }
+ ippFileRestorePosition(file);
- if ((col = parse_collection(f, v, user_data)) == NULL)
- return (0);
+ if ((col = ippFileReadCollection(file)) == NULL)
+ return (false);
status = ippSetCollection(ipp, attr, element, col);
ippDelete(col);
}
default :
- report_error(f, v, user_data, "Unsupported value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ report_error(file, "Unsupported value on line %d of '%s'.", file->linenum, file->filename);
+ return (false);
}
}
-/*
- * 'report_error()' - Report an error.
- */
+//
+// 'report_error()' - Report an error.
+//
-static void
+static bool // O - `true` to continue, `false` to stop
report_error(
- _ipp_file_t *f, /* I - IPP data file */
- _ipp_vars_t *v, /* I - Error callback function, if any */
- void *user_data, /* I - User data pointer */
- const char *message, /* I - Printf-style message */
- ...) /* I - Additional arguments as needed */
+ ipp_file_t *file, // I - IPP data file
+ const char *message, // I - Printf-style message
+ ...) // I - Additional arguments as needed
{
- char buffer[8192]; /* Formatted string */
- va_list ap; /* Argument pointer */
+ va_list ap; // Argument pointer
+ char buffer[8192]; // Formatted string
va_start(ap, message);
vsnprintf(buffer, sizeof(buffer), message, ap);
va_end(ap);
- if (v->errorcb)
- (*v->errorcb)(f, user_data, buffer);
- else
- fprintf(stderr, "%s\n", buffer);
+ if (file->error_cb)
+ return ((*file->error_cb)(file, file->cb_data, buffer));
+
+ fprintf(stderr, "%s\n", buffer);
+ return (false);
+}
+
+
+//
+// 'write_string()' - Write a quoted string value.
+//
+
+static bool // O - `true` on success, `false` on failure
+write_string(ipp_file_t *file, // I - IPP data file
+ const char *s, // I - String
+ size_t len) // I - Length of string
+{
+ bool ret = true; // Return value
+ const char *start, // Start of string
+ *ptr, // Pointer into string
+ *end; // End of string
+
+
+ // Start with a double quote...
+ ret &= cupsFilePutChar(file->fp, '\"');
+ file->column ++;
+
+ // Loop through the string...
+ for (start = s, end = s + len, ptr = start; ptr < end; ptr ++)
+ {
+ if (*ptr == '\"' || *ptr == '\\')
+ {
+ // Something that needs to be quoted...
+ if (ptr > start)
+ {
+ // Write lead-in text...
+ ret &= cupsFileWrite(file->fp, start, (size_t)(ptr - start));
+ file->column += ptr - start;
+ }
+
+ // Then quote the " or \...
+ ret &= cupsFilePrintf(file->fp, "\\%c", *ptr);
+ start = ptr + 1;
+ file->column ++;
+ }
+ }
+
+ if (ptr > start)
+ {
+ ret &= cupsFileWrite(file->fp, start, (size_t)(ptr - start));
+ file->column += ptr - start;
+ }
+
+ ret &= cupsFilePutChar(file->fp, '\"');
+ file->column ++;
+
+ return (ret);
}
-/*
- * Private IPP definitions for CUPS.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Private IPP definitions for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_IPP_PRIVATE_H_
# define _CUPS_IPP_PRIVATE_H_
-
-/*
- * Include necessary headers...
- */
-
# include <cups/cups.h>
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Constants...
- */
+//
+// Constants...
+//
# define IPP_BUF_SIZE (IPP_MAX_LENGTH + 2)
- /* Size of buffer */
+ // Size of buffer
+# define _IPP_MAX_FIND 8 // Size of find stack
-/*
- * Structures...
- */
+//
+// Structures...
+//
-typedef union _ipp_request_u /**** Request Header ****/
+typedef union _ipp_request_u // Request Header
{
- struct /* Any Header */
+ struct // Any Header
{
- ipp_uchar_t version[2]; /* Protocol version number */
- int op_status; /* Operation ID or status code*/
- int request_id; /* Request ID */
+ ipp_uchar_t version[2]; // Protocol version number
+ int op_status; // Operation ID or status code
+ int request_id; // Request ID
} any;
- struct /* Operation Header */
+ struct // Operation Header
{
- ipp_uchar_t version[2]; /* Protocol version number */
- ipp_op_t operation_id; /* Operation ID */
- int request_id; /* Request ID */
+ ipp_uchar_t version[2]; // Protocol version number
+ ipp_op_t operation_id; // Operation ID
+ int request_id; // Request ID
} op;
- struct /* Status Header */
+ struct // Status Header
{
- ipp_uchar_t version[2]; /* Protocol version number */
- ipp_status_t status_code; /* Status code */
- int request_id; /* Request ID */
+ ipp_uchar_t version[2]; // Protocol version number
+ ipp_status_t status_code; // Status code
+ int request_id; // Request ID
} status;
- /**** New in CUPS 1.1.19 ****/
- struct /* Event Header @since CUPS 1.1.19/macOS 10.3@ */
+ struct // Event Header
{
- ipp_uchar_t version[2]; /* Protocol version number */
- ipp_status_t status_code; /* Status code */
- int request_id; /* Request ID */
+ ipp_uchar_t version[2]; // Protocol version number
+ ipp_status_t status_code; // Status code
+ int request_id; // Request ID
} event;
} _ipp_request_t;
-typedef union _ipp_value_u /**** Attribute Value ****/
+typedef union _ipp_value_u // Attribute Value
{
- int integer; /* Integer/enumerated value */
+ int integer; // Integer/enumerated value
- char boolean; /* Boolean value */
+ char boolean; // Boolean value
- ipp_uchar_t date[11]; /* Date/time value */
+ ipp_uchar_t date[11]; // Date/time value
struct
{
- int xres, /* Horizontal resolution */
- yres; /* Vertical resolution */
- ipp_res_t units; /* Resolution units */
- } resolution; /* Resolution value */
+ int xres, // Horizontal resolution
+ yres; // Vertical resolution
+ ipp_res_t units; // Resolution units
+ } resolution; // Resolution value
struct
{
- int lower, /* Lower value */
- upper; /* Upper value */
- } range; /* Range of integers value */
+ int lower, // Lower value
+ upper; // Upper value
+ } range; // Range of integers value
struct
{
- char *language; /* Language code */
- char *text; /* String */
- } string; /* String with language value */
+ char *language; // Language code
+ char *text; // String
+ } string; // String with language value
struct
{
- int length; /* Length of attribute */
- void *data; /* Data in attribute */
- } unknown; /* Unknown attribute type */
+ int length; // Length of attribute
+ void *data; // Data in attribute
+ } unknown; // Unknown attribute type
-/**** New in CUPS 1.1.19 ****/
- ipp_t *collection; /* Collection value @since CUPS 1.1.19/macOS 10.3@ */
+ ipp_t *collection; // Collection value
} _ipp_value_t;
-struct _ipp_attribute_s /**** IPP attribute ****/
+struct _ipp_attribute_s // IPP attribute
{
- ipp_attribute_t *next; /* Next attribute in list */
- ipp_tag_t group_tag, /* Job/Printer/Operation group tag */
- value_tag; /* What type of value is it? */
- char *name; /* Name of attribute */
- int num_values; /* Number of values */
- _ipp_value_t values[1]; /* Values */
+ ipp_attribute_t *next; // Next attribute in list
+ ipp_tag_t group_tag, // Job/Printer/Operation group tag
+ value_tag; // What type of value is it?
+ char *name; // Name of attribute
+ int num_values; // Number of values
+ _ipp_value_t values[1]; // Values
};
-struct _ipp_s /**** IPP Request/Response/Notification ****/
+typedef struct _ipp_find_s // IPP find data
{
- ipp_state_t state; /* State of request */
- _ipp_request_t request; /* Request header */
- ipp_attribute_t *attrs; /* Attributes */
- ipp_attribute_t *last; /* Last attribute in list */
- ipp_attribute_t *current; /* Current attribute (for read/write) */
- ipp_tag_t curtag; /* Current attribute group tag */
-
-/**** New in CUPS 1.2 ****/
- ipp_attribute_t *prev; /* Previous attribute (for read) @since CUPS 1.2/macOS 10.5@ */
-
-/**** New in CUPS 1.4.4 ****/
- int use; /* Use count @since CUPS 1.4.4/macOS 10.6.?@ */
-/**** New in CUPS 2.0 ****/
- int atend, /* At end of list? */
- curindex; /* Current attribute index for hierarchical search */
+ ipp_attribute_t *attr; // Current attribute
+ int idx; // Current attribute index for hierarchical search
+ bool atend; // At the end of the message?
+} _ipp_find_t;
+
+struct _ipp_s // IPP Request/Response/Notification
+{
+ ipp_state_t state; // State of request
+ _ipp_request_t request; // Request header
+ ipp_attribute_t *attrs; // Attributes
+ ipp_attribute_t *last; // Last attribute in list
+ ipp_attribute_t *current; // Current attribute (for read/write)
+ ipp_tag_t curtag; // Current attribute group tag
+ ipp_attribute_t *prev; // Previous attribute (for read)
+ int use; // Use count
+ _ipp_find_t fstack[_IPP_MAX_FIND];
+ // Find stack
+ _ipp_find_t *find; // Current find
};
-typedef struct _ipp_option_s /**** Attribute mapping data ****/
+typedef struct _ipp_option_s // Attribute mapping data
{
- int multivalue; /* Option has multiple values? */
- const char *name; /* Option/attribute name */
- ipp_tag_t value_tag; /* Value tag for this attribute */
- ipp_tag_t group_tag; /* Group tag for this attribute */
+ int multivalue; // Option has multiple values?
+ const char *name; // Option/attribute name
+ ipp_tag_t value_tag; // Value tag for this attribute
+ ipp_tag_t group_tag; // Group tag for this attribute
ipp_tag_t alt_group_tag; /* Alternate group tag for this
* attribute */
- const ipp_op_t *operations; /* Allowed operations for this attr */
+ const ipp_op_t *operations; // Allowed operations for this attr
} _ipp_option_t;
-typedef struct _ipp_file_s _ipp_file_t;/**** File Parser ****/
-typedef struct _ipp_vars_s _ipp_vars_t;/**** Variables ****/
-
-typedef int (*_ipp_fattr_cb_t)(_ipp_file_t *f, void *user_data, const char *attr);
- /**** File Attribute (Filter) Callback ****/
-typedef int (*_ipp_ferror_cb_t)(_ipp_file_t *f, void *user_data, const char *error);
- /**** File Parser Error Callback ****/
-typedef int (*_ipp_ftoken_cb_t)(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, const char *token);
- /**** File Parser Token Callback ****/
-
-struct _ipp_vars_s /**** Variables ****/
-{
- char *uri, /* URI for printer */
- scheme[64], /* Scheme from URI */
- username[256], /* Username from URI */
- *password, /* Password from URI (if any) */
- host[256], /* Hostname from URI */
- portstr[32], /* Port number string */
- resource[1024]; /* Resource path from URI */
- int port; /* Port number from URI */
- int num_vars; /* Number of variables */
- cups_option_t *vars; /* Array of variables */
- int password_tries; /* Number of retries for password */
- _ipp_fattr_cb_t attrcb; /* Attribute (filter) callback */
- _ipp_ferror_cb_t errorcb; /* Error callback */
- _ipp_ftoken_cb_t tokencb; /* Token callback */
-};
-
-struct _ipp_file_s /**** File Parser */
-{
- const char *filename; /* Filename */
- cups_file_t *fp; /* File pointer */
- int linenum; /* Current line number */
- ipp_t *attrs; /* Attributes */
- ipp_tag_t group_tag; /* Current group for new attributes */
-};
+//
+// Functions...
+//
-/*
- * Prototypes for private functions...
- */
-
-/* encode.c */
#ifdef DEBUG
extern const char *_ippCheckOptions(void) _CUPS_PRIVATE;
-#endif /* DEBUG */
+#endif // DEBUG
extern _ipp_option_t *_ippFindOption(const char *name) _CUPS_PRIVATE;
-/* ipp-file.c */
-extern ipp_t *_ippFileParse(_ipp_vars_t *v, const char *filename, void *user_data) _CUPS_PRIVATE;
-extern int _ippFileReadToken(_ipp_file_t *f, char *token, size_t tokensize) _CUPS_PRIVATE;
-
-/* ipp-vars.c */
-extern void _ippVarsDeinit(_ipp_vars_t *v) _CUPS_PRIVATE;
-extern void _ippVarsExpand(_ipp_vars_t *v, char *dst, const char *src, size_t dstsize) _CUPS_NONNULL(1,2,3) _CUPS_PRIVATE;
-extern const char *_ippVarsGet(_ipp_vars_t *v, const char *name) _CUPS_PRIVATE;
-extern void _ippVarsInit(_ipp_vars_t *v, _ipp_fattr_cb_t attrcb, _ipp_ferror_cb_t errorcb, _ipp_ftoken_cb_t tokencb) _CUPS_PRIVATE;
-extern const char *_ippVarsPasswordCB(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data) _CUPS_PRIVATE;
-extern int _ippVarsSet(_ipp_vars_t *v, const char *name, const char *value) _CUPS_PRIVATE;
-
-
-/*
- * C++ magic...
- */
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_IPP_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_IPP_H_
-/*
- * Internet Printing Protocol support functions for CUPS.
- *
- * Copyright © 2023 by OpenPrinting.
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Internet Printing Protocol support functions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#include "cups-private.h"
-#include "debug-internal.h"
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static const char * const ipp_states[] =
{
"IPP_STATE_ATTRIBUTE",
"IPP_STATE_DATA"
};
-static const char * const ipp_status_oks[] = /* "OK" status codes */
- { /* (name) = abandoned standard value */
+static const char * const ipp_status_oks[] = // "OK" status codes
+ { // (name) = abandoned standard value
"successful-ok",
"successful-ok-ignored-or-substituted-attributes",
"successful-ok-conflicting-attributes",
"(successful-ok-but-cancel-subscription)",
"successful-ok-events-complete"
},
- * const ipp_status_400s[] = /* Client errors */
- { /* (name) = abandoned standard value */
+ * const ipp_status_400s[] = // Client errors
+ { // (name) = abandoned standard value
"client-error-bad-request",
"client-error-forbidden",
"client-error-not-authenticated",
"client-error-account-authorization-failed",
"client-error-not-fetchable"
},
- * const ipp_status_480s[] = /* Vendor client errors */
+ * const ipp_status_480s[] = // Vendor client errors
{
- /* 0x0480 - 0x048F */
+ // 0x0480 - 0x048F
"0x0480",
"0x0481",
"0x0482",
"0x048D",
"0x048E",
"0x048F",
- /* 0x0490 - 0x049F */
+ // 0x0490 - 0x049F
"0x0490",
"0x0491",
"0x0492",
"cups-error-account-limit-reached",
"cups-error-account-authorization-failed"
},
- * const ipp_status_500s[] = /* Server errors */
+ * const ipp_status_500s[] = // Server errors
{
"server-error-internal-error",
"server-error-operation-not-supported",
"server-error-too-many-jobs",
"server-error-too-many-documents"
},
- * const ipp_status_1000s[] = /* CUPS internal */
+ * const ipp_status_1000s[] = // CUPS internal
{
"cups-authentication-canceled",
"cups-pki-error",
};
static const char * const ipp_std_ops[] =
{
- /* 0x0000 - 0x000f */
+ // 0x0000 - 0x000f
"0x0000",
"0x0001",
- "Print-Job", /* RFC 8011 */
- "Print-URI", /* RFC 8011 */
- "Validate-Job", /* RFC 8011 */
- "Create-Job", /* RFC 8011 */
- "Send-Document", /* RFC 8011 */
- "Send-URI", /* RFC 8011 */
- "Cancel-Job", /* RFC 8011 */
- "Get-Job-Attributes", /* RFC 8011 */
- "Get-Jobs", /* RFC 8011 */
- "Get-Printer-Attributes", /* RFC 8011 */
- "Hold-Job", /* RFC 8011 */
- "Release-Job", /* RFC 8011 */
- "Restart-Job", /* RFC 8011 */
+ "Print-Job", // RFC 8011
+ "Print-URI", // RFC 8011
+ "Validate-Job", // RFC 8011
+ "Create-Job", // RFC 8011
+ "Send-Document", // RFC 8011
+ "Send-URI", // RFC 8011
+ "Cancel-Job", // RFC 8011
+ "Get-Job-Attributes", // RFC 8011
+ "Get-Jobs", // RFC 8011
+ "Get-Printer-Attributes", // RFC 8011
+ "Hold-Job", // RFC 8011
+ "Release-Job", // RFC 8011
+ "Restart-Job", // RFC 8011
"0x000f",
- /* 0x0010 - 0x001f */
- "Pause-Printer", /* RFC 8011 */
- "Resume-Printer", /* RFC 8011 */
- "Purge-Jobs", /* RFC 8011 */
- "Set-Printer-Attributes", /* RFC 3380 */
- "Set-Job-Attributes", /* RFC 3380 */
- "Get-Printer-Supported-Values", /* RFC 3380 */
- "Create-Printer-Subscriptions", /* RFC 3995 */
- "Create-Job-Subscriptions", /* RFC 3995 */
- "Get-Subscription-Attributes", /* RFC 3995 */
- "Get-Subscriptions", /* RFC 3995 */
- "Renew-Subscription", /* RFC 3995 */
- "Cancel-Subscription", /* RFC 3995 */
- "Get-Notifications", /* RFC 3996 */
+ // 0x0010 - 0x001f
+ "Pause-Printer", // RFC 8011
+ "Resume-Printer", // RFC 8011
+ "Purge-Jobs", // RFC 8011
+ "Set-Printer-Attributes", // RFC 3380
+ "Set-Job-Attributes", // RFC 3380
+ "Get-Printer-Supported-Values",// RFC 3380
+ "Create-Printer-Subscriptions",// RFC 3995
+ "Create-Job-Subscriptions", // RFC 3995
+ "Get-Subscription-Attributes",// RFC 3995
+ "Get-Subscriptions", // RFC 3995
+ "Renew-Subscription", // RFC 3995
+ "Cancel-Subscription", // RFC 3995
+ "Get-Notifications", // RFC 3996
"(Send-Notifications)",
- "Get-Resource-Attributes", /* IPP System */
+ "Get-Resource-Attributes", // IPP System
"(Get-Resource-Data)",
- /* 0x0020 - 0x002f */
- "Get-Resources", /* IPP System */
+ // 0x0020 - 0x002f
+ "Get-Resources", // IPP System
"(Get-Printer-Support-Files)",
- "Enable-Printer", /* RFC 3998 */
- "Disable-Printer", /* RFC 3998 */
- "Pause-Printer-After-Current-Job", /* RFC 3998 */
- "Hold-New-Jobs", /* RFC 3998 */
- "Release-Held-New-Jobs", /* RFC 3998 */
- "Deactivate-Printer", /* RFC 3998 */
- "Activate-Printer", /* RFC 3998 */
- "Restart-Printer", /* RFC 3998 */
- "Shutdown-Printer", /* RFC 3998 */
- "Startup-Printer", /* RFC 3998 */
- "Reprocess-Job", /* RFC 3998 */
- "Cancel-Current-Job", /* RFC 3998 */
- "Suspend-Current-Job", /* RFC 3998 */
- "Resume-Job", /* RFC 3998 */
-
- /* 0x0030 - 0x003f */
- "Promote-Job", /* RFC 3998 */
- "Schedule-Job-After", /* RFC 3998 */
+ "Enable-Printer", // RFC 3998
+ "Disable-Printer", // RFC 3998
+ "Pause-Printer-After-Current-Job",// RFC 3998
+ "Hold-New-Jobs", // RFC 3998
+ "Release-Held-New-Jobs", // RFC 3998
+ "Deactivate-Printer", // RFC 3998
+ "Activate-Printer", // RFC 3998
+ "Restart-Printer", // RFC 3998
+ "Shutdown-Printer", // RFC 3998
+ "Startup-Printer", // RFC 3998
+ "Reprocess-Job", // RFC 3998
+ "Cancel-Current-Job", // RFC 3998
+ "Suspend-Current-Job", // RFC 3998
+ "Resume-Job", // RFC 3998
+
+ // 0x0030 - 0x003f
+ "Promote-Job", // RFC 3998
+ "Schedule-Job-After", // RFC 3998
"0x0032",
- "Cancel-Document", /* IPP DocObject */
- "Get-Document-Attributes", /* IPP DocObject */
- "Get-Documents", /* IPP DocObject */
- "Delete-Document", /* IPP DocObject */
- "Set-Document-Attributes", /* IPP DocObject */
- "Cancel-Jobs", /* IPP JPS2 */
- "Cancel-My-Jobs", /* IPP JPS2 */
- "Resubmit-Job", /* IPP JPS2 */
- "Close-Job", /* IPP JPS2 */
- "Identify-Printer", /* IPP JPS3 */
- "Validate-Document", /* IPP JPS3 */
- "Add-Document-Images", /* IPP Scan */
- "Acknowledge-Document", /* IPP INFRA */
-
- /* 0x0040 - 0x004f */
- "Acknowledge-Identify-Printer", /* IPP INFRA */
- "Acknowledge-Job", /* IPP INFRA */
- "Fetch-Document", /* IPP INFRA */
- "Fetch-Job", /* IPP INFRA */
- "Get-Output-Device-Attributes", /* IPP INFRA */
- "Update-Active-Jobs", /* IPP INFRA */
- "Deregister-Output-Device", /* IPP INFRA */
- "Update-Document-Status", /* IPP INFRA */
- "Update-Job-Status", /* IPP INFRA */
- "Update-Output-Device-Attributes", /* IPP INFRA */
- "Get-Next-Document-Data", /* IPP Scan */
- "Allocate-Printer-Resources", /* IPP System */
- "Create-Printer", /* IPP System */
- "Deallocate-Printer-Resources", /* IPP System */
- "Delete-Printer", /* IPP System */
- "Get-Printers", /* IPP System */
-
- /* 0x0050 - 0x005f */
- "Shutdown-One-Printer", /* IPP System */
- "Startup-One-Printer", /* IPP System */
- "Cancel-Resource", /* IPP System */
- "Create-Resource", /* IPP System */
- "Install-Resource", /* IPP System */
- "Send-Resource-Data", /* IPP System */
- "Set-Resource-Attributes", /* IPP System */
- "Create-Resource-Subscriptions", /* IPP System */
- "Create-System-Subscriptions", /* IPP System */
- "Disable-All-Printers", /* IPP System */
- "Enable-All-Printers", /* IPP System */
- "Get-System-Attributes", /* IPP System */
- "Get-System-Supported-Values", /* IPP System */
- "Pause-All-Printers", /* IPP System */
- "Pause-All-Printers-After-Current-Job", /* IPP System */
- "Register-Output-Device", /* IPP System */
-
- /* 0x0060 - 0x0064 */
- "Restart-System", /* IPP System */
- "Resume-All-Printers", /* IPP System */
- "Set-System-Attributes", /* IPP System */
- "Shutdown-All-Printers", /* IPP System */
- "Startup-All-Printers" /* IPP System */
+ "Cancel-Document", // IPP DocObject
+ "Get-Document-Attributes", // IPP DocObject
+ "Get-Documents", // IPP DocObject
+ "Delete-Document", // IPP DocObject
+ "Set-Document-Attributes", // IPP DocObject
+ "Cancel-Jobs", // IPP JPS2
+ "Cancel-My-Jobs", // IPP JPS2
+ "Resubmit-Job", // IPP JPS2
+ "Close-Job", // IPP JPS2
+ "Identify-Printer", // IPP JPS3
+ "Validate-Document", // IPP JPS3
+ "Add-Document-Images", // IPP Scan
+ "Acknowledge-Document", // IPP INFRA
+
+ // 0x0040 - 0x004f
+ "Acknowledge-Identify-Printer",// IPP INFRA
+ "Acknowledge-Job", // IPP INFRA
+ "Fetch-Document", // IPP INFRA
+ "Fetch-Job", // IPP INFRA
+ "Get-Output-Device-Attributes",// IPP INFRA
+ "Update-Active-Jobs", // IPP INFRA
+ "Deregister-Output-Device", // IPP INFRA
+ "Update-Document-Status", // IPP INFRA
+ "Update-Job-Status", // IPP INFRA
+ "Update-Output-Device-Attributes",// IPP INFRA
+ "Get-Next-Document-Data", // IPP Scan
+ "Allocate-Printer-Resources", // IPP System
+ "Create-Printer", // IPP System
+ "Deallocate-Printer-Resources",// IPP System
+ "Delete-Printer", // IPP System
+ "Get-Printers", // IPP System
+
+ // 0x0050 - 0x005f
+ "Shutdown-One-Printer", // IPP System
+ "Startup-One-Printer", // IPP System
+ "Cancel-Resource", // IPP System
+ "Create-Resource", // IPP System
+ "Install-Resource", // IPP System
+ "Send-Resource-Data", // IPP System
+ "Set-Resource-Attributes", // IPP System
+ "Create-Resource-Subscriptions",// IPP System
+ "Create-System-Subscriptions",// IPP System
+ "Disable-All-Printers", // IPP System
+ "Enable-All-Printers", // IPP System
+ "Get-System-Attributes", // IPP System
+ "Get-System-Supported-Values",// IPP System
+ "Pause-All-Printers", // IPP System
+ "Pause-All-Printers-After-Current-Job",// IPP System
+ "Register-Output-Device", // IPP System
+
+ // 0x0060 - 0x0064
+ "Restart-System", // IPP System
+ "Resume-All-Printers", // IPP System
+ "Set-System-Attributes", // IPP System
+ "Shutdown-All-Printers", // IPP System
+ "Startup-All-Printers" // IPP System
},
* const ipp_cups_ops[] =
{
"CUPS-Create-Local-Printer"
},
* const ipp_tag_names[] =
- { /* Value/group tag names */
- "zero", /* 0x00 */
+ { // Value/group tag names
+ "zero", // 0x00
"operation-attributes-tag",
- /* 0x01 */
- "job-attributes-tag", /* 0x02 */
+ // 0x01
+ "job-attributes-tag", // 0x02
"end-of-attributes-tag",
- /* 0x03 */
+ // 0x03
"printer-attributes-tag",
- /* 0x04 */
+ // 0x04
"unsupported-attributes-tag",
- /* 0x05 */
+ // 0x05
"subscription-attributes-tag",
- /* 0x06 - RFC 3995 */
+ // 0x06 - RFC 3995
"event-notification-attributes-tag",
- /* 0x07 - RFC 3995 */
+ // 0x07 - RFC 3995
"resource-attributes-tag",
- /* 0x08 - IPP System */
+ // 0x08 - IPP System
"document-attributes-tag",
- /* 0x09 - IPP DocObject */
+ // 0x09 - IPP DocObject
"system-attributes-tag",
- /* 0x0a - IPP System */
- "0x0b", /* 0x0b */
- "0x0c", /* 0x0c */
- "0x0d", /* 0x0d */
- "0x0e", /* 0x0e */
- "0x0f", /* 0x0f */
- "unsupported", /* 0x10 */
- "default", /* 0x11 */
- "unknown", /* 0x12 */
- "no-value", /* 0x13 */
- "0x14", /* 0x14 */
- "not-settable", /* 0x15 - RFC 3380 */
- "delete-attribute", /* 0x16 - RFC 3380 */
- "admin-define", /* 0x17 - RFC 3380 */
- "0x18", /* 0x18 */
- "0x19", /* 0x19 */
- "0x1a", /* 0x1a */
- "0x1b", /* 0x1b */
- "0x1c", /* 0x1c */
- "0x1d", /* 0x1d */
- "0x1e", /* 0x1e */
- "0x1f", /* 0x1f */
- "0x20", /* 0x20 */
- "integer", /* 0x21 */
- "boolean", /* 0x22 */
- "enum", /* 0x23 */
- "0x24", /* 0x24 */
- "0x25", /* 0x25 */
- "0x26", /* 0x26 */
- "0x27", /* 0x27 */
- "0x28", /* 0x28 */
- "0x29", /* 0x29 */
- "0x2a", /* 0x2a */
- "0x2b", /* 0x2b */
- "0x2c", /* 0x2c */
- "0x2d", /* 0x2d */
- "0x2e", /* 0x2e */
- "0x2f", /* 0x2f */
- "octetString", /* 0x30 */
- "dateTime", /* 0x31 */
- "resolution", /* 0x32 */
- "rangeOfInteger", /* 0x33 */
- "collection", /* 0x34 */
- "textWithLanguage", /* 0x35 */
- "nameWithLanguage", /* 0x36 */
- "endCollection", /* 0x37 */
- "0x38", /* 0x38 */
- "0x39", /* 0x39 */
- "0x3a", /* 0x3a */
- "0x3b", /* 0x3b */
- "0x3c", /* 0x3c */
- "0x3d", /* 0x3d */
- "0x3e", /* 0x3e */
- "0x3f", /* 0x3f */
- "0x40", /* 0x40 */
- "textWithoutLanguage",/* 0x41 */
- "nameWithoutLanguage",/* 0x42 */
- "0x43", /* 0x43 */
- "keyword", /* 0x44 */
- "uri", /* 0x45 */
- "uriScheme", /* 0x46 */
- "charset", /* 0x47 */
- "naturalLanguage", /* 0x48 */
- "mimeMediaType", /* 0x49 */
- "memberAttrName" /* 0x4a */
+ // 0x0a - IPP System
+ "0x0b", // 0x0b
+ "0x0c", // 0x0c
+ "0x0d", // 0x0d
+ "0x0e", // 0x0e
+ "0x0f", // 0x0f
+ "unsupported", // 0x10
+ "default", // 0x11
+ "unknown", // 0x12
+ "no-value", // 0x13
+ "0x14", // 0x14
+ "not-settable", // 0x15 - RFC 3380
+ "delete-attribute", // 0x16 - RFC 3380
+ "admin-define", // 0x17 - RFC 3380
+ "0x18", // 0x18
+ "0x19", // 0x19
+ "0x1a", // 0x1a
+ "0x1b", // 0x1b
+ "0x1c", // 0x1c
+ "0x1d", // 0x1d
+ "0x1e", // 0x1e
+ "0x1f", // 0x1f
+ "0x20", // 0x20
+ "integer", // 0x21
+ "boolean", // 0x22
+ "enum", // 0x23
+ "0x24", // 0x24
+ "0x25", // 0x25
+ "0x26", // 0x26
+ "0x27", // 0x27
+ "0x28", // 0x28
+ "0x29", // 0x29
+ "0x2a", // 0x2a
+ "0x2b", // 0x2b
+ "0x2c", // 0x2c
+ "0x2d", // 0x2d
+ "0x2e", // 0x2e
+ "0x2f", // 0x2f
+ "octetString", // 0x30
+ "dateTime", // 0x31
+ "resolution", // 0x32
+ "rangeOfInteger", // 0x33
+ "collection", // 0x34
+ "textWithLanguage", // 0x35
+ "nameWithLanguage", // 0x36
+ "endCollection", // 0x37
+ "0x38", // 0x38
+ "0x39", // 0x39
+ "0x3a", // 0x3a
+ "0x3b", // 0x3b
+ "0x3c", // 0x3c
+ "0x3d", // 0x3d
+ "0x3e", // 0x3e
+ "0x3f", // 0x3f
+ "0x40", // 0x40
+ "textWithoutLanguage",// 0x41
+ "nameWithoutLanguage",// 0x42
+ "0x43", // 0x43
+ "keyword", // 0x44
+ "uri", // 0x45
+ "uriScheme", // 0x46
+ "charset", // 0x47
+ "naturalLanguage", // 0x48
+ "mimeMediaType", // 0x49
+ "memberAttrName" // 0x4a
};
static const char * const ipp_document_states[] =
- { /* document-state-enums */
+ { // document-state-enums
"pending",
"4",
"processing",
- "processing-stopped", /* IPP INFRA */
+ "processing-stopped", // IPP INFRA
"canceled",
"aborted",
"completed"
},
* const ipp_finishings[] =
- { /* finishings enums */
+ { // finishings enums
"none",
"staple",
"punch",
"bale",
"booklet-maker",
"jog-offset",
- "coat", /* IPP Finishings 2.0 */
- "laminate", /* IPP Finishings 2.0 */
+ "coat", // IPP Finishings 2.0
+ "laminate", // IPP Finishings 2.0
"17",
"18",
"19",
"staple-dual-top",
"staple-dual-right",
"staple-dual-bottom",
- "staple-triple-left", /* IPP Finishings 2.0 */
- "staple-triple-top", /* IPP Finishings 2.0 */
- "staple-triple-right",/* IPP Finishings 2.0 */
- "staple-triple-bottom",/* IPP Finishings 2.0 */
+ "staple-triple-left", // IPP Finishings 2.0
+ "staple-triple-top", // IPP Finishings 2.0
+ "staple-triple-right",// IPP Finishings 2.0
+ "staple-triple-bottom",// IPP Finishings 2.0
"36",
"37",
"38",
"67",
"68",
"69",
- "punch-top-left", /* IPP Finishings 2.0 */
- "punch-bottom-left", /* IPP Finishings 2.0 */
- "punch-top-right", /* IPP Finishings 2.0 */
- "punch-bottom-right", /* IPP Finishings 2.0 */
- "punch-dual-left", /* IPP Finishings 2.0 */
- "punch-dual-top", /* IPP Finishings 2.0 */
- "punch-dual-right", /* IPP Finishings 2.0 */
- "punch-dual-bottom", /* IPP Finishings 2.0 */
- "punch-triple-left", /* IPP Finishings 2.0 */
- "punch-triple-top", /* IPP Finishings 2.0 */
- "punch-triple-right", /* IPP Finishings 2.0 */
- "punch-triple-bottom",/* IPP Finishings 2.0 */
- "punch-quad-left", /* IPP Finishings 2.0 */
- "punch-quad-top", /* IPP Finishings 2.0 */
- "punch-quad-right", /* IPP Finishings 2.0 */
- "punch-quad-bottom", /* IPP Finishings 2.0 */
- "punch-multiple-left",/* IPP Finishings 2.1/Canon */
- "punch-multiple-top", /* IPP Finishings 2.1/Canon */
- "punch-multiple-right",/* IPP Finishings 2.1/Canon */
- "punch-multiple-bottom",/* IPP Finishings 2.1/Canon */
- "fold-accordion", /* IPP Finishings 2.0 */
- "fold-double-gate", /* IPP Finishings 2.0 */
- "fold-gate", /* IPP Finishings 2.0 */
- "fold-half", /* IPP Finishings 2.0 */
- "fold-half-z", /* IPP Finishings 2.0 */
- "fold-left-gate", /* IPP Finishings 2.0 */
- "fold-letter", /* IPP Finishings 2.0 */
- "fold-parallel", /* IPP Finishings 2.0 */
- "fold-poster", /* IPP Finishings 2.0 */
- "fold-right-gate", /* IPP Finishings 2.0 */
- "fold-z", /* IPP Finishings 2.0 */
- "fold-engineering-z" /* IPP Finishings 2.1 */
+ "punch-top-left", // IPP Finishings 2.0
+ "punch-bottom-left", // IPP Finishings 2.0
+ "punch-top-right", // IPP Finishings 2.0
+ "punch-bottom-right", // IPP Finishings 2.0
+ "punch-dual-left", // IPP Finishings 2.0
+ "punch-dual-top", // IPP Finishings 2.0
+ "punch-dual-right", // IPP Finishings 2.0
+ "punch-dual-bottom", // IPP Finishings 2.0
+ "punch-triple-left", // IPP Finishings 2.0
+ "punch-triple-top", // IPP Finishings 2.0
+ "punch-triple-right", // IPP Finishings 2.0
+ "punch-triple-bottom",// IPP Finishings 2.0
+ "punch-quad-left", // IPP Finishings 2.0
+ "punch-quad-top", // IPP Finishings 2.0
+ "punch-quad-right", // IPP Finishings 2.0
+ "punch-quad-bottom", // IPP Finishings 2.0
+ "punch-multiple-left",// IPP Finishings 2.1/Canon
+ "punch-multiple-top", // IPP Finishings 2.1/Canon
+ "punch-multiple-right",// IPP Finishings 2.1/Canon
+ "punch-multiple-bottom",// IPP Finishings 2.1/Canon
+ "fold-accordion", // IPP Finishings 2.0
+ "fold-double-gate", // IPP Finishings 2.0
+ "fold-gate", // IPP Finishings 2.0
+ "fold-half", // IPP Finishings 2.0
+ "fold-half-z", // IPP Finishings 2.0
+ "fold-left-gate", // IPP Finishings 2.0
+ "fold-letter", // IPP Finishings 2.0
+ "fold-parallel", // IPP Finishings 2.0
+ "fold-poster", // IPP Finishings 2.0
+ "fold-right-gate", // IPP Finishings 2.0
+ "fold-z", // IPP Finishings 2.0
+ "fold-engineering-z" // IPP Finishings 2.1
},
* const ipp_finishings_vendor[] =
{
- /* 0x40000000 to 0x4000000F */
+ // 0x40000000 to 0x4000000F
"0x40000000",
"0x40000001",
"0x40000002",
"0x4000000D",
"0x4000000E",
"0x4000000F",
- /* 0x40000010 to 0x4000001F */
+ // 0x40000010 to 0x4000001F
"0x40000010",
"0x40000011",
"0x40000012",
"0x4000001D",
"0x4000001E",
"0x4000001F",
- /* 0x40000020 to 0x4000002F */
+ // 0x40000020 to 0x4000002F
"0x40000020",
"0x40000021",
"0x40000022",
"0x4000002D",
"0x4000002E",
"0x4000002F",
- /* 0x40000030 to 0x4000003F */
+ // 0x40000030 to 0x4000003F
"0x40000030",
"0x40000031",
"0x40000032",
"0x4000003D",
"0x4000003E",
"0x4000003F",
- /* 0x40000040 - 0x4000004F */
+ // 0x40000040 - 0x4000004F
"0x40000040",
"0x40000041",
"0x40000042",
"cups-punch-dual-bottom",
"cups-punch-triple-left",
"cups-punch-triple-top",
- /* 0x40000050 - 0x4000005F */
+ // 0x40000050 - 0x4000005F
"cups-punch-triple-right",
"cups-punch-triple-bottom",
"cups-punch-quad-left",
"cups-fold-half",
"cups-fold-half-z",
"cups-fold-left-gate",
- /* 0x40000060 - 0x40000064 */
+ // 0x40000060 - 0x40000064
"cups-fold-letter",
"cups-fold-parallel",
"cups-fold-poster",
"cups-fold-z"
},
* const ipp_job_collation_types[] =
- { /* job-collation-type enums */
+ { // job-collation-type enums
"uncollated-sheets",
"collated-documents",
"uncollated-documents"
},
* const ipp_job_states[] =
- { /* job-state enums */
+ { // job-state enums
"pending",
"pending-held",
"processing",
"completed"
},
* const ipp_orientation_requesteds[] =
- { /* orientation-requested enums */
+ { // orientation-requested enums
"portrait",
"landscape",
"reverse-landscape",
"none"
},
* const ipp_print_qualities[] =
- { /* print-quality enums */
+ { // print-quality enums
"draft",
"normal",
"high"
},
* const ipp_printer_states[] =
- { /* printer-state enums */
+ { // printer-state enums
"idle",
"processing",
"stopped"
},
* const ipp_resource_states[] =
- { /* resource-state enums */
+ { // resource-state enums
"pending",
"available",
"installed",
"aborted"
},
* const ipp_system_states[] =
- { /* system-state enums */
+ { // system-state enums
"idle",
"processing",
"stopped"
};
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static size_t ipp_col_string(ipp_t *col, char *buffer, size_t bufsize);
-/*
- * 'ippAttributeString()' - Convert the attribute's value to a string.
- *
- * Returns the number of bytes that would be written, not including the
- * trailing nul. The buffer pointer can be NULL to get the required length,
- * just like (v)snprintf.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippAttributeString()' - Convert the attribute's value to a string.
+//
+// Returns the number of bytes that would be written, not including the
+// trailing nul. The buffer pointer can be NULL to get the required length,
+// just like (v)snprintf.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-size_t /* O - Number of bytes less nul */
+size_t // O - Number of bytes less nul
ippAttributeString(
- ipp_attribute_t *attr, /* I - Attribute */
- char *buffer, /* I - String buffer or NULL */
- size_t bufsize) /* I - Size of string buffer */
+ ipp_attribute_t *attr, // I - Attribute
+ char *buffer, // I - String buffer or NULL
+ size_t bufsize) // I - Size of string buffer
{
- int i; /* Looping var */
- char *bufptr, /* Pointer into buffer */
- *bufend, /* End of buffer */
- temp[256]; /* Temporary string */
- const char *ptr, /* Pointer into string */
- *end; /* Pointer to end of string */
- _ipp_value_t *val; /* Current value */
+ int i; // Looping var
+ char *bufptr, // Pointer into buffer
+ *bufend, // End of buffer
+ temp[256]; // Temporary string
+ const char *ptr, // Pointer into string
+ *end; // Pointer to end of string
+ _ipp_value_t *val; // Current value
if (!attr || !attr->name)
case IPP_TAG_DATE :
{
- unsigned year; /* Year */
+ unsigned year; // Year
year = ((unsigned)val->date[0] << 8) | (unsigned)val->date[1];
}
-/*
- * 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
- * given requested-attributes attribute.
- *
- * This function creates a (sorted) CUPS array of attribute names matching the
- * list of "requested-attribute" values supplied in an IPP request. All IANA-
- * registered values are supported in addition to the CUPS IPP extension
- * attributes.
- *
- * The @code request@ parameter specifies the request message that was read from
- * the client.
- *
- * @code NULL@ is returned if all attributes should be returned. Otherwise, the
- * result is a sorted array of attribute names, where @code cupsArrayFind(array,
- * "attribute-name")@ will return a non-NULL pointer. The array must be freed
- * using the @code cupsArrayDelete@ function.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-cups_array_t * /* O - CUPS array or @code NULL@ if all */
-ippCreateRequestedArray(ipp_t *request) /* I - IPP request */
+//
+// 'ippCreateRequestedArray()' - Create a CUPS array of attribute names from the
+// given requested-attributes attribute.
+//
+// This function creates a (sorted) CUPS array of attribute names matching the
+// list of "requested-attribute" values supplied in an IPP request. All IANA-
+// registered values are supported in addition to the CUPS IPP extension
+// attributes.
+//
+// The @code request@ parameter specifies the request message that was read from
+// the client.
+//
+// @code NULL@ is returned if all attributes should be returned. Otherwise, the
+// result is a sorted array of attribute names, where @code cupsArrayFind(array,
+// "attribute-name")@ will return a non-NULL pointer. The array must be freed
+// using the @code cupsArrayDelete@ function.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+cups_array_t * // O - CUPS array or @code NULL@ if all
+ippCreateRequestedArray(ipp_t *request) // I - IPP request
{
- int i, j, /* Looping vars */
- count, /* Number of values */
- added; /* Was name added? */
- ipp_op_t op; /* IPP operation code */
- ipp_attribute_t *requested; /* requested-attributes attribute */
- cups_array_t *ra; /* Requested attributes array */
- const char *value; /* Current value */
- /* The following lists come from the current IANA IPP registry of attributes */
+ int i, j, // Looping vars
+ count, // Number of values
+ added; // Was name added?
+ ipp_op_t op; // IPP operation code
+ ipp_attribute_t *requested; // requested-attributes attribute
+ cups_array_t *ra; // Requested attributes array
+ const char *value; // Current value
+ // The following lists come from the current IANA IPP registry of attributes
static const char * const document_description[] =
- { /* document-description group */
+ { // document-description group
"compression",
"copies-actual",
"cover-back-actual",
"document-state-message",
"document-state-reasons",
"document-uri",
- "document-uuid", /* IPP JPS3 */
+ "document-uuid", // IPP JPS3
"errors-count",
"finishings-actual",
"finishings-col-actual",
"k-octets",
"k-octets-processed",
"last-document",
- "materials-col-actual", /* IPP 3D */
+ "materials-col-actual", // IPP 3D
"media-actual",
"media-col-actual",
"media-input-tray-check-actual",
"media-sheets-completed",
"media-sheets-completed-col",
"more-info",
- "multiple-object-handling-actual", /* IPP 3D */
+ "multiple-object-handling-actual", // IPP 3D
"number-up-actual",
"orientation-requested-actual",
"output-bin-actual",
"pages-completed",
"pages-completed-col",
"pages-completed-current-copy",
- "platform-temperature-actual", /* IPP 3D */
+ "platform-temperature-actual", // IPP 3D
"presentation-direction-number-up-actual",
- "print-accuracy-actual", /* IPP 3D */
- "print-base-actual", /* IPP 3D */
+ "print-accuracy-actual", // IPP 3D
+ "print-base-actual", // IPP 3D
"print-color-mode-actual",
"print-content-optimize-actual",
- "print-objects-actual", /* IPP 3D */
+ "print-objects-actual", // IPP 3D
"print-quality-actual",
"print-rendering-intent-actual",
- "print-scaling-actual", /* IPP Paid Printing */
- "print-supports-actual", /* IPP 3D */
+ "print-scaling-actual", // IPP Paid Printing
+ "print-supports-actual", // IPP 3D
"printer-resolution-actual",
"printer-up-time",
"separator-sheets-actual",
"y-side2-image-shift-actual"
};
static const char * const document_template[] =
- { /* document-template group */
- "chamber-humidity", /* IPP 3D */
- "chamber-humidity-default", /* IPP 3D */
- "chamber-humidity-supported", /* IPP 3D */
- "chamber-temperature", /* IPP 3D */
- "chamber-temperature-default", /* IPP 3D */
- "chamber-temperature-supported", /* IPP 3D */
+ { // document-template group
+ "chamber-humidity", // IPP 3D
+ "chamber-humidity-default", // IPP 3D
+ "chamber-humidity-supported", // IPP 3D
+ "chamber-temperature", // IPP 3D
+ "chamber-temperature-default", // IPP 3D
+ "chamber-temperature-supported", // IPP 3D
"copies",
"copies-default",
"copies-supported",
"insert-sheet",
"insert-sheet-default",
"insert-sheet-supported",
- "material-amount-units-supported", /* IPP 3D */
- "material-diameter-supported", /* IPP 3D */
- "material-purpose-supported", /* IPP 3D */
- "material-rate-supported", /* IPP 3D */
- "material-rate-units-supported", /* IPP 3D */
- "material-shell-thickness-supported",/* IPP 3D */
- "material-temperature-supported", /* IPP 3D */
- "material-type-supported", /* IPP 3D */
- "materials-col", /* IPP 3D */
- "materials-col-database", /* IPP 3D */
- "materials-col-default", /* IPP 3D */
- "materials-col-ready", /* IPP 3D */
- "materials-col-supported", /* IPP 3D */
- "max-materials-col-supported", /* IPP 3D */
+ "material-amount-units-supported", // IPP 3D
+ "material-diameter-supported", // IPP 3D
+ "material-purpose-supported", // IPP 3D
+ "material-rate-supported", // IPP 3D
+ "material-rate-units-supported", // IPP 3D
+ "material-shell-thickness-supported",// IPP 3D
+ "material-temperature-supported", // IPP 3D
+ "material-type-supported", // IPP 3D
+ "materials-col", // IPP 3D
+ "materials-col-database", // IPP 3D
+ "materials-col-default", // IPP 3D
+ "materials-col-ready", // IPP 3D
+ "materials-col-supported", // IPP 3D
+ "max-materials-col-supported", // IPP 3D
"max-stitching-locations-supported",
"media",
"media-back-coating-supported",
"multiple-document-handling",
"multiple-document-handling-default",
"multiple-document-handling-supported",
- "multiple-object-handling", /* IPP 3D */
- "multiple-object-handling-default", /* IPP 3D */
- "multiple-object-handling-supported",/* IPP 3D */
+ "multiple-object-handling", // IPP 3D
+ "multiple-object-handling-default", // IPP 3D
+ "multiple-object-handling-supported",// IPP 3D
"number-up",
"number-up-default",
"number-up-supported",
"orientation-requested",
"orientation-requested-default",
"orientation-requested-supported",
- "output-mode", /* CUPS extension */
- "output-mode-default", /* CUPS extension */
- "output-mode-supported", /* CUPS extension */
+ "output-mode", // CUPS extension
+ "output-mode-default", // CUPS extension
+ "output-mode-supported", // CUPS extension
"overrides",
"overrides-supported",
"page-delivery",
"pdl-init-file-name-subdirectory-supported",
"pdl-init-file-name-supported",
"pdl-init-file-supported",
- "platform-temperature", /* IPP 3D */
- "platform-temperature-default", /* IPP 3D */
- "platform-temperature-supported", /* IPP 3D */
+ "platform-temperature", // IPP 3D
+ "platform-temperature-default", // IPP 3D
+ "platform-temperature-supported", // IPP 3D
"presentation-direction-number-up",
"presentation-direction-number-up-default",
"presentation-direction-number-up-supported",
- "print-accuracy", /* IPP 3D */
- "print-accuracy-default", /* IPP 3D */
- "print-accuracy-supported", /* IPP 3D */
- "print-base", /* IPP 3D */
- "print-base-default", /* IPP 3D */
- "print-base-supported", /* IPP 3D */
+ "print-accuracy", // IPP 3D
+ "print-accuracy-default", // IPP 3D
+ "print-accuracy-supported", // IPP 3D
+ "print-base", // IPP 3D
+ "print-base-default", // IPP 3D
+ "print-base-supported", // IPP 3D
"print-color-mode",
"print-color-mode-default",
"print-color-mode-supported",
"print-content-optimize",
"print-content-optimize-default",
"print-content-optimize-supported",
- "print-objects", /* IPP 3D */
- "print-objects-default", /* IPP 3D */
- "print-objects-supported", /* IPP 3D */
+ "print-objects", // IPP 3D
+ "print-objects-default", // IPP 3D
+ "print-objects-supported", // IPP 3D
"print-quality",
"print-quality-default",
"print-quality-supported",
"print-rendering-intent",
"print-rendering-intent-default",
"print-rendering-intent-supported",
- "print-scaling", /* IPP Paid Printing */
- "print-scaling-default", /* IPP Paid Printing */
- "print-scaling-supported", /* IPP Paid Printing */
- "print-supports", /* IPP 3D */
- "print-supports-default", /* IPP 3D */
- "print-supports-supported", /* IPP 3D */
+ "print-scaling", // IPP Paid Printing
+ "print-scaling-default", // IPP Paid Printing
+ "print-scaling-supported", // IPP Paid Printing
+ "print-supports", // IPP 3D
+ "print-supports-default", // IPP 3D
+ "print-supports-supported", // IPP 3D
"printer-resolution",
"printer-resolution-default",
"printer-resolution-supported",
"y-side2-image-shift-supported"
};
static const char * const job_description[] =
- { /* job-description group */
- "chamber-humidity-actual", /* IPP 3D */
- "chamber-temperature-actual", /* IPP 3D */
+ { // job-description group
+ "chamber-humidity-actual", // IPP 3D
+ "chamber-temperature-actual", // IPP 3D
"compression-supplied",
"copies-actual",
"cover-back-actual",
"job-accounting-sheets-actual",
"job-accounting-user-id-actual",
"job-attribute-fidelity",
- "job-charge-info", /* CUPS extension */
+ "job-charge-info", // CUPS extension
"job-collation-type",
"job-collation-type-actual",
"job-copies-actual",
"job-k-octets",
"job-k-octets-processed",
"job-mandatory-attributes",
- "job-media-progress", /* CUPS extension */
+ "job-media-progress", // CUPS extension
"job-media-sheets",
"job-media-sheets-col",
"job-media-sheets-completed",
"job-message-from-operator",
"job-more-info",
"job-name",
- "job-originating-host-name", /* CUPS extension */
+ "job-originating-host-name", // CUPS extension
"job-originating-user-name",
- "job-originating-user-uri", /* IPP JPS3 */
+ "job-originating-user-uri", // IPP JPS3
"job-pages",
"job-pages-col",
"job-pages-completed",
"job-pages-completed-col",
"job-pages-completed-current-copy",
- "job-printer-state-message", /* CUPS extension */
- "job-printer-state-reasons", /* CUPS extension */
+ "job-printer-state-message", // CUPS extension
+ "job-printer-state-reasons", // CUPS extension
"job-printer-up-time",
"job-printer-uri",
"job-priority-actual",
- "job-resource-ids", /* IPP System */
+ "job-resource-ids", // IPP System
"job-save-printer-make-and-model",
"job-sheet-message-actual",
"job-sheets-actual",
"job-state-message",
"job-state-reasons",
"job-uri",
- "job-uuid", /* IPP JPS3 */
- "materials-col-actual", /* IPP 3D */
+ "job-uuid", // IPP JPS3
+ "materials-col-actual", // IPP 3D
"media-actual",
"media-col-actual",
"media-check-input-tray-actual",
"multiple-document-handling-actual",
- "multiple-object-handling-actual", /* IPP 3D */
+ "multiple-object-handling-actual", // IPP 3D
"number-of-documents",
"number-of-intervening-jobs",
"number-up-actual",
"original-requesting-user-name",
"output-bin-actual",
"output-device-assigned",
- "output-device-job-state", /* IPP INFRA */
- "output-device-job-state-message", /* IPP INFRA */
- "output-device-job-state-reasons", /* IPP INFRA */
- "output-device-uuid-assigned", /* IPP INFRA */
+ "output-device-job-state", // IPP INFRA
+ "output-device-job-state-message", // IPP INFRA
+ "output-device-job-state-reasons", // IPP INFRA
+ "output-device-uuid-assigned", // IPP INFRA
"overrides-actual",
"page-delivery-actual",
"page-order-received-actual",
"page-ranges-actual",
- "platform-temperature-actual", /* IPP 3D */
+ "platform-temperature-actual", // IPP 3D
"presentation-direction-number-up-actual",
- "print-accuracy-actual", /* IPP 3D */
- "print-base-actual", /* IPP 3D */
+ "print-accuracy-actual", // IPP 3D
+ "print-base-actual", // IPP 3D
"print-color-mode-actual",
"print-content-optimize-actual",
- "print-objects-actual", /* IPP 3D */
+ "print-objects-actual", // IPP 3D
"print-quality-actual",
"print-rendering-intent-actual",
- "print-scaling-actual", /* IPP Paid Printing */
- "print-supports-actual", /* IPP 3D */
+ "print-scaling-actual", // IPP Paid Printing
+ "print-supports-actual", // IPP 3D
"printer-resolution-actual",
"separator-sheets-actual",
"sheet-collate-actual",
"y-side2-image-shift-actual"
};
static const char * const job_template[] =
- { /* job-template group */
- "accuracy-units-supported", /* IPP 3D */
- "chamber-humidity", /* IPP 3D */
- "chamber-humidity-default", /* IPP 3D */
- "chamber-humidity-supported", /* IPP 3D */
- "chamber-temperature", /* IPP 3D */
- "chamber-temperature-default", /* IPP 3D */
- "chamber-temperature-supported", /* IPP 3D */
- "confirmation-sheet-print", /* IPP FaxOut */
+ { // job-template group
+ "accuracy-units-supported", // IPP 3D
+ "chamber-humidity", // IPP 3D
+ "chamber-humidity-default", // IPP 3D
+ "chamber-humidity-supported", // IPP 3D
+ "chamber-temperature", // IPP 3D
+ "chamber-temperature-default", // IPP 3D
+ "chamber-temperature-supported", // IPP 3D
+ "confirmation-sheet-print", // IPP FaxOut
"confirmation-sheet-print-default",
"copies",
"copies-default",
"cover-front",
"cover-front-default",
"cover-front-supported",
- "cover-sheet-info", /* IPP FaxOut */
+ "cover-sheet-info", // IPP FaxOut
"cover-sheet-info-default",
"cover-sheet-info-supported",
- "destination-uri-schemes-supported",/* IPP FaxOut */
- "destination-uris", /* IPP FaxOut */
+ "destination-uri-schemes-supported",// IPP FaxOut
+ "destination-uris", // IPP FaxOut
"destination-uris-supported",
"feed-orientation",
"feed-orientation-default",
"job-sheets-default",
"job-sheets-supported",
"logo-uri-schemes-supported",
- "material-amount-units-supported", /* IPP 3D */
- "material-diameter-supported", /* IPP 3D */
- "material-purpose-supported", /* IPP 3D */
- "material-rate-supported", /* IPP 3D */
- "material-rate-units-supported", /* IPP 3D */
- "material-shell-thickness-supported",/* IPP 3D */
- "material-temperature-supported", /* IPP 3D */
- "material-type-supported", /* IPP 3D */
- "materials-col", /* IPP 3D */
- "materials-col-database", /* IPP 3D */
- "materials-col-default", /* IPP 3D */
- "materials-col-ready", /* IPP 3D */
- "materials-col-supported", /* IPP 3D */
- "max-materials-col-supported", /* IPP 3D */
+ "material-amount-units-supported", // IPP 3D
+ "material-diameter-supported", // IPP 3D
+ "material-purpose-supported", // IPP 3D
+ "material-rate-supported", // IPP 3D
+ "material-rate-units-supported", // IPP 3D
+ "material-shell-thickness-supported",// IPP 3D
+ "material-temperature-supported", // IPP 3D
+ "material-type-supported", // IPP 3D
+ "materials-col", // IPP 3D
+ "materials-col-database", // IPP 3D
+ "materials-col-default", // IPP 3D
+ "materials-col-ready", // IPP 3D
+ "materials-col-supported", // IPP 3D
+ "max-materials-col-supported", // IPP 3D
"max-save-info-supported",
"max-stitching-locations-supported",
"media",
"multiple-document-handling",
"multiple-document-handling-default",
"multiple-document-handling-supported",
- "multiple-object-handling", /* IPP 3D */
- "multiple-object-handling-default", /* IPP 3D */
- "multiple-object-handling-supported",/* IPP 3D */
- "number-of-retries", /* IPP FaxOut */
+ "multiple-object-handling", // IPP 3D
+ "multiple-object-handling-default", // IPP 3D
+ "multiple-object-handling-supported",// IPP 3D
+ "number-of-retries", // IPP FaxOut
"number-of-retries-default",
"number-of-retries-supported",
"number-up",
"output-bin-supported",
"output-device",
"output-device-supported",
- "output-device-uuid-supported", /* IPP INFRA */
- "output-mode", /* CUPS extension */
- "output-mode-default", /* CUPS extension */
- "output-mode-supported", /* CUPS extension */
+ "output-device-uuid-supported", // IPP INFRA
+ "output-mode", // CUPS extension
+ "output-mode-default", // CUPS extension
+ "output-mode-supported", // CUPS extension
"overrides",
"overrides-supported",
"page-delivery",
"pdl-init-file-name-subdirectory-supported",
"pdl-init-file-name-supported",
"pdl-init-file-supported",
- "platform-temperature", /* IPP 3D */
- "platform-temperature-default", /* IPP 3D */
- "platform-temperature-supported", /* IPP 3D */
+ "platform-temperature", // IPP 3D
+ "platform-temperature-default", // IPP 3D
+ "platform-temperature-supported", // IPP 3D
"presentation-direction-number-up",
"presentation-direction-number-up-default",
"presentation-direction-number-up-supported",
- "print-accuracy", /* IPP 3D */
- "print-accuracy-default", /* IPP 3D */
- "print-accuracy-supported", /* IPP 3D */
- "print-base", /* IPP 3D */
- "print-base-default", /* IPP 3D */
- "print-base-supported", /* IPP 3D */
+ "print-accuracy", // IPP 3D
+ "print-accuracy-default", // IPP 3D
+ "print-accuracy-supported", // IPP 3D
+ "print-base", // IPP 3D
+ "print-base-default", // IPP 3D
+ "print-base-supported", // IPP 3D
"print-color-mode",
"print-color-mode-default",
"print-color-mode-supported",
"print-content-optimize",
"print-content-optimize-default",
"print-content-optimize-supported",
- "print-objects", /* IPP 3D */
- "print-objects-default", /* IPP 3D */
- "print-objects-supported", /* IPP 3D */
+ "print-objects", // IPP 3D
+ "print-objects-default", // IPP 3D
+ "print-objects-supported", // IPP 3D
"print-quality",
"print-quality-default",
"print-quality-supported",
"print-rendering-intent",
"print-rendering-intent-default",
"print-rendering-intent-supported",
- "print-scaling", /* IPP Paid Printing */
- "print-scaling-default", /* IPP Paid Printing */
- "print-scaling-supported", /* IPP Paid Printing */
- "print-supports", /* IPP 3D */
- "print-supports-default", /* IPP 3D */
- "print-supports-supported", /* IPP 3D */
+ "print-scaling", // IPP Paid Printing
+ "print-scaling-default", // IPP Paid Printing
+ "print-scaling-supported", // IPP Paid Printing
+ "print-supports", // IPP 3D
+ "print-supports-default", // IPP 3D
+ "print-supports-supported", // IPP 3D
"printer-resolution",
"printer-resolution-default",
"printer-resolution-supported",
"proof-print",
"proof-print-default",
"proof-print-supported",
- "retry-interval", /* IPP FaxOut */
+ "retry-interval", // IPP FaxOut
"retry-interval-default",
"retry-interval-supported",
- "retry-timeout", /* IPP FaxOut */
+ "retry-timeout", // IPP FaxOut
"retry-timeout-default",
"retry-timeout-supported",
"save-disposition-supported",
"y-side2-image-shift-supported"
};
static const char * const printer_description[] =
- { /* printer-description group */
- "auth-info-required", /* CUPS extension */
- "chamber-humidity-current", /* IPP 3D */
- "chamber-temperature-current", /* IPP 3D */
+ { // printer-description group
+ "auth-info-required", // CUPS extension
+ "chamber-humidity-current", // IPP 3D
+ "chamber-temperature-current", // IPP 3D
"charset-configured",
"charset-supported",
"color-supported",
"compression-supported",
"device-service-count",
- "device-uri", /* CUPS extension */
+ "device-uri", // CUPS extension
"device-uuid",
"document-charset-default",
"document-charset-supported",
"document-format-default",
"document-format-details-default",
"document-format-details-supported",
- "document-format-preferred", /* AirPrint extension */
+ "document-format-preferred", // AirPrint extension
"document-format-supported",
"document-format-varying-attributes",
"document-format-version-default",
"document-natural-language-default",
"document-natural-language-supported",
"document-password-supported",
- "document-privacy-attributes", /* IPP Privacy Attributes */
- "document-privacy-scope", /* IPP Privacy Attributes */
+ "document-privacy-attributes", // IPP Privacy Attributes
+ "document-privacy-scope", // IPP Privacy Attributes
"generated-natural-language-supported",
"identify-actions-default",
"identify-actions-supported",
"ipp-features-supported",
"ipp-versions-supported",
"ippget-event-life",
- "job-authorization-uri-supported", /* CUPS extension */
+ "job-authorization-uri-supported", // CUPS extension
"job-constraints-supported",
"job-creation-attributes-supported",
"job-finishings-col-ready",
"job-finishings-ready",
"job-ids-supported",
"job-impressions-supported",
- "job-k-limit", /* CUPS extension */
+ "job-k-limit", // CUPS extension
"job-k-octets-supported",
"job-media-sheets-supported",
- "job-page-limit", /* CUPS extension */
+ "job-page-limit", // CUPS extension
"job-password-encryption-supported",
"job-password-supported",
- "job-presets-supported", /* IPP Presets */
- "job-privacy-attributes", /* IPP Privacy Attributes */
- "job-privacy-scope", /* IPP Privacy Attributes */
- "job-quota-period", /* CUPS extension */
+ "job-presets-supported", // IPP Presets
+ "job-privacy-attributes", // IPP Privacy Attributes
+ "job-privacy-scope", // IPP Privacy Attributes
+ "job-quota-period", // CUPS extension
"job-resolvers-supported",
"job-settable-attributes-supported",
"job-spooling-supported",
- "job-triggers-supported", /* IPP Presets */
- "jpeg-k-octets-supported", /* CUPS extension */
- "jpeg-x-dimension-supported", /* CUPS extension */
- "jpeg-y-dimension-supported", /* CUPS extension */
+ "job-triggers-supported", // IPP Presets
+ "jpeg-k-octets-supported", // CUPS extension
+ "jpeg-x-dimension-supported", // CUPS extension
+ "jpeg-y-dimension-supported", // CUPS extension
"landscape-orientation-requested-preferred",
- /* CUPS extension */
- "marker-change-time", /* CUPS extension */
- "marker-colors", /* CUPS extension */
- "marker-high-levels", /* CUPS extension */
- "marker-levels", /* CUPS extension */
- "marker-low-levels", /* CUPS extension */
- "marker-message", /* CUPS extension */
- "marker-names", /* CUPS extension */
- "marker-types", /* CUPS extension */
- "member-names", /* CUPS extension */
- "member-uris", /* CUPS extension */
- "mopria-certified", /* Mopria extension */
- "multiple-destination-uris-supported",/* IPP FaxOut */
+ // CUPS extension
+ "marker-change-time", // CUPS extension
+ "marker-colors", // CUPS extension
+ "marker-high-levels", // CUPS extension
+ "marker-levels", // CUPS extension
+ "marker-low-levels", // CUPS extension
+ "marker-message", // CUPS extension
+ "marker-names", // CUPS extension
+ "marker-types", // CUPS extension
+ "member-names", // CUPS extension
+ "member-uris", // CUPS extension
+ "mopria-certified", // Mopria extension
+ "multiple-destination-uris-supported",// IPP FaxOut
"multiple-document-jobs-supported",
"multiple-operation-time-out",
"multiple-operation-time-out-action",
"operations-supported",
"pages-per-minute",
"pages-per-minute-color",
- "pdf-k-octets-supported", /* CUPS extension */
- "pdf-features-supported", /* IPP 3D */
- "pdf-versions-supported", /* CUPS extension */
+ "pdf-k-octets-supported", // CUPS extension
+ "pdf-features-supported", // IPP 3D
+ "pdf-versions-supported", // CUPS extension
"pdl-override-supported",
- "platform-shape", /* IPP 3D */
- "port-monitor", /* CUPS extension */
- "port-monitor-supported", /* CUPS extension */
+ "platform-shape", // IPP 3D
+ "port-monitor", // CUPS extension
+ "port-monitor-supported", // CUPS extension
"preferred-attributes-supported",
"printer-alert",
"printer-alert-description",
- "printer-camera-image-uri", /* IPP 3D */
+ "printer-camera-image-uri", // IPP 3D
"printer-charge-info",
"printer-charge-info-uri",
- "printer-commands", /* CUPS extension */
+ "printer-commands", // CUPS extension
"printer-config-change-date-time",
"printer-config-change-time",
- "printer-config-changes", /* IPP System */
- "printer-contact-col", /* IPP System */
+ "printer-config-changes", // IPP System
+ "printer-contact-col", // IPP System
"printer-current-time",
"printer-detailed-status-messages",
"printer-device-id",
- "printer-dns-sd-name", /* CUPS extension */
+ "printer-dns-sd-name", // CUPS extension
"printer-driver-installer",
- "printer-fax-log-uri", /* IPP FaxOut */
- "printer-fax-modem-info", /* IPP FaxOut */
- "printer-fax-modem-name", /* IPP FaxOut */
- "printer-fax-modem-number", /* IPP FaxOut */
- "printer-firmware-name", /* PWG 5110.1 */
- "printer-firmware-patches", /* PWG 5110.1 */
- "printer-firmware-string-version", /* PWG 5110.1 */
- "printer-firmware-version", /* PWG 5110.1 */
+ "printer-fax-log-uri", // IPP FaxOut
+ "printer-fax-modem-info", // IPP FaxOut
+ "printer-fax-modem-name", // IPP FaxOut
+ "printer-fax-modem-number", // IPP FaxOut
+ "printer-firmware-name", // PWG 5110.1
+ "printer-firmware-patches", // PWG 5110.1
+ "printer-firmware-string-version", // PWG 5110.1
+ "printer-firmware-version", // PWG 5110.1
"printer-geo-location",
"printer-get-attributes-supported",
"printer-icc-profiles",
"printer-icons",
- "printer-id", /* IPP System */
+ "printer-id", // IPP System
"printer-info",
- "printer-input-tray", /* IPP JPS3 */
+ "printer-input-tray", // IPP JPS3
"printer-is-accepting-jobs",
- "printer-is-shared", /* CUPS extension */
- "printer-is-temporary", /* CUPS extension */
- "printer-kind", /* IPP Paid Printing */
+ "printer-is-shared", // CUPS extension
+ "printer-is-temporary", // CUPS extension
+ "printer-kind", // IPP Paid Printing
"printer-location",
"printer-make-and-model",
"printer-mandatory-job-attributes",
"printer-native-formats",
"printer-organization",
"printer-organizational-unit",
- "printer-output-tray", /* IPP JPS3 */
- "printer-service-type", /* IPP System */
+ "printer-output-tray", // IPP JPS3
+ "printer-service-type", // IPP System
"printer-settable-attributes-supported",
"printer-state",
"printer-state-change-date-time",
"printer-state-message",
"printer-state-reasons",
"printer-strings-languages-supported",
- /* IPP JPS3 */
- "printer-strings-uri", /* IPP JPS3 */
+ // IPP JPS3
+ "printer-strings-uri", // IPP JPS3
"printer-supply",
"printer-supply-description",
"printer-supply-info-uri",
- "printer-type", /* CUPS extension */
+ "printer-type", // CUPS extension
"printer-up-time",
"printer-uri-supported",
"printer-uuid",
- "printer-wifi-ssid", /* AirPrint extension */
- "printer-wifi-state", /* AirPrint extension */
+ "printer-wifi-ssid", // AirPrint extension
+ "printer-wifi-state", // AirPrint extension
"printer-xri-supported",
"pwg-raster-document-resolution-supported",
"pwg-raster-document-sheet-back",
"queued-job-count",
"reference-uri-schemes-supported",
"repertoire-supported",
- "requesting-user-name-allowed", /* CUPS extension */
- "requesting-user-name-denied", /* CUPS extension */
+ "requesting-user-name-allowed", // CUPS extension
+ "requesting-user-name-denied", // CUPS extension
"requesting-user-uri-supported",
- "smi2699-auth-print-group", /* PWG ippserver extension */
- "smi2699-auth-proxy-group", /* PWG ippserver extension */
- "smi2699-device-command", /* PWG ippserver extension */
- "smi2699-device-format", /* PWG ippserver extension */
- "smi2699-device-name", /* PWG ippserver extension */
- "smi2699-device-uri", /* PWG ippserver extension */
+ "smi2699-auth-print-group", // PWG ippserver extension
+ "smi2699-auth-proxy-group", // PWG ippserver extension
+ "smi2699-device-command", // PWG ippserver extension
+ "smi2699-device-format", // PWG ippserver extension
+ "smi2699-device-name", // PWG ippserver extension
+ "smi2699-device-uri", // PWG ippserver extension
"subordinate-printers-supported",
- "subscription-privacy-attributes", /* IPP Privacy Attributes */
- "subscription-privacy-scope", /* IPP Privacy Attributes */
- "urf-supported", /* CUPS extension */
+ "subscription-privacy-attributes", // IPP Privacy Attributes
+ "subscription-privacy-scope", // IPP Privacy Attributes
+ "urf-supported", // CUPS extension
"uri-authentication-supported",
"uri-security-supported",
"user-defined-value-supported",
"xri-uri-scheme-supported"
};
static const char * const resource_description[] =
- { /* resource-description group - IPP System */
+ { // resource-description group - IPP System
"resource-info",
"resource-name"
};
static const char * const resource_status[] =
- { /* resource-status group - IPP System */
+ { // resource-status group - IPP System
"date-time-at-canceled",
"date-time-at-creation",
"date-time-at-installed",
"time-at-installed"
};
static const char * const resource_template[] =
- { /* resource-template group - IPP System */
+ { // resource-template group - IPP System
"resource-format",
"resource-format-supported",
"resource-info",
"resource-type-supported"
};
static const char * const subscription_description[] =
- { /* subscription-description group */
+ { // subscription-description group
"notify-job-id",
"notify-lease-expiration-time",
"notify-printer-up-time",
"notify-printer-uri",
- "notify-resource-id", /* IPP System */
- "notify-system-uri", /* IPP System */
+ "notify-resource-id", // IPP System
+ "notify-system-uri", // IPP System
"notify-sequence-number",
"notify-subscriber-user-name",
"notify-subscriber-user-uri",
"notify-subscription-id",
- "notify-subscription-uuid" /* IPP JPS3 */
+ "notify-subscription-uuid" // IPP JPS3
};
static const char * const subscription_template[] =
- { /* subscription-template group */
+ { // subscription-template group
"notify-attributes",
"notify-attributes-supported",
"notify-charset",
"notify-user-data"
};
static const char * const system_description[] =
- { /* system-description group - IPP System */
+ { // system-description group - IPP System
"charset-configured",
"charset-supported",
"generated-natural-language-supported",
"power-timeout-policy-col",
"printer-creation-attributes-supported",
"resource-settable-attributes-supported",
- "smi2699-auth-group-supported", /* PWG ippserver extension */
- "smi2699-device-command-supported", /* PWG ippserver extension */
- "smi2699-device-format-format", /* PWG ippserver extension */
+ "smi2699-auth-group-supported", // PWG ippserver extension
+ "smi2699-device-command-supported", // PWG ippserver extension
+ "smi2699-device-format-format", // PWG ippserver extension
"smi2699-device-uri-schemes-supported",
- /* PWG ippserver extension */
+ // PWG ippserver extension
"system-contact-col",
"system-current-time",
"system-default-printer-id",
"system-xri-supported"
};
static const char * const system_status[] =
- { /* system-status group - IPP System */
+ { // system-status group - IPP System
"power-log-col",
"power-state-capabilities-col",
"power-state-counters-col",
}
-/*
- * 'ippEnumString()' - Return a string corresponding to the enum value.
- */
+//
+// 'ippEnumString()' - Return a string corresponding to the enum value.
+//
-const char * /* O - Enum string */
-ippEnumString(const char *attrname, /* I - Attribute name */
- int enumvalue) /* I - Enum value */
+const char * // O - Enum string
+ippEnumString(const char *attrname, // I - Attribute name
+ int enumvalue) // I - Enum value
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
+ _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
/*
}
-/*
- * 'ippEnumValue()' - Return the value associated with a given enum string.
- */
+//
+// 'ippEnumValue()' - Return the value associated with a given enum string.
+//
-int /* O - Enum value or -1 if unknown */
-ippEnumValue(const char *attrname, /* I - Attribute name */
- const char *enumstring) /* I - Enum string */
+int // O - Enum value or -1 if unknown
+ippEnumValue(const char *attrname, // I - Attribute name
+ const char *enumstring) // I - Enum string
{
- int i, /* Looping var */
- num_strings; /* Number of strings to compare */
- const char * const *strings; /* Strings to compare */
+ int i, // Looping var
+ num_strings; // Number of strings to compare
+ const char * const *strings; // Strings to compare
/*
}
-/*
- * 'ippErrorString()' - Return a name for the given status code.
- */
+//
+// 'ippErrorString()' - Return a name for the given status code.
+//
-const char * /* O - Text string */
-ippErrorString(ipp_status_t error) /* I - Error status */
+const char * // O - Text string
+ippErrorString(ipp_status_t error) // I - Error status
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
+ _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
/*
}
-/*
- * 'ippErrorValue()' - Return a status code for the given name.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ippErrorValue()' - Return a status code for the given name.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ipp_status_t /* O - IPP status code */
-ippErrorValue(const char *name) /* I - Name */
+ipp_status_t // O - IPP status code
+ippErrorValue(const char *name) // I - Name
{
- size_t i; /* Looping var */
+ size_t i; // Looping var
for (i = 0; i < (sizeof(ipp_status_oks) / sizeof(ipp_status_oks[0])); i ++)
}
-/*
- * 'ippOpString()' - Return a name for the given operation id.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ippGetPort()' - Return the default IPP port number.
+//
+// @since CUPS 2.5@
+//
-const char * /* O - Name */
-ippOpString(ipp_op_t op) /* I - Operation ID */
+int // O - Port number
+ippGetPort(void)
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
+ _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
+
+
+ DEBUG_puts("ippPort()");
+
+ if (!cg->ipp_port)
+ _cupsSetDefaults();
+
+ DEBUG_printf("1ippPort: Returning %d...", cg->ipp_port);
+
+ return (cg->ipp_port);
+}
+
+
+//
+// 'ippOpString()' - Return a name for the given operation id.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
+
+const char * // O - Name
+ippOpString(ipp_op_t op) // I - Operation ID
+{
+ _cups_globals_t *cg = _cupsGlobals(); // Pointer to library globals
/*
}
-/*
- * 'ippOpValue()' - Return an operation id for the given name.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ippOpValue()' - Return an operation id for the given name.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ipp_op_t /* O - Operation ID */
-ippOpValue(const char *name) /* I - Textual name */
+ipp_op_t // O - Operation ID
+ippOpValue(const char *name) // I - Textual name
{
- size_t i; /* Looping var */
+ size_t i; // Looping var
if (!strncmp(name, "0x", 2))
}
-/*
- * 'ippPort()' - Return the default IPP port number.
- */
+//
+// 'ippPort()' - Return the default IPP port number.
+//
+// @deprecated@ @exclude all@
+//
-int /* O - Port number */
+int // O - Port number
ippPort(void)
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
-
-
- DEBUG_puts("ippPort()");
-
- if (!cg->ipp_port)
- _cupsSetDefaults();
-
- DEBUG_printf("1ippPort: Returning %d...", cg->ipp_port);
-
- return (cg->ipp_port);
+ return (ippGetPort());
}
-/*
- * 'ippSetPort()' - Set the default port number.
- */
+//
+// 'ippSetPort()' - Set the default port number.
+//
void
-ippSetPort(int p) /* I - Port number to use */
+ippSetPort(int p) // I - Port number to use
{
DEBUG_printf("ippSetPort(p=%d)", p);
}
-/*
- * 'ippStateString()' - Return the name corresponding to a state value.
- *
- * @since CUPS 2.0/OS 10.10@
- */
+//
+// 'ippStateString()' - Return the name corresponding to a state value.
+//
+// @since CUPS 2.0/OS 10.10@
+//
-const char * /* O - State name */
-ippStateString(ipp_state_t state) /* I - State value */
+const char * // O - State name
+ippStateString(ipp_state_t state) // I - State value
{
if (state >= IPP_STATE_ERROR && state <= IPP_STATE_DATA)
return (ipp_states[state - IPP_STATE_ERROR]);
}
-/*
- * 'ippTagString()' - Return the tag name corresponding to a tag value.
- *
- * The returned names are defined in RFC 8011 and the IANA IPP Registry.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
+//
+// 'ippTagString()' - Return the tag name corresponding to a tag value.
+//
+// The returned names are defined in RFC 8011 and the IANA IPP Registry.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
-const char * /* O - Tag name */
-ippTagString(ipp_tag_t tag) /* I - Tag value */
+const char * // O - Tag name
+ippTagString(ipp_tag_t tag) // I - Tag value
{
tag &= IPP_TAG_CUPS_MASK;
}
-/*
- * 'ippTagValue()' - Return the tag value corresponding to a tag name.
- *
- * The tag names are defined in RFC 8011 and the IANA IPP Registry.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
+//
+// 'ippTagValue()' - Return the tag value corresponding to a tag name.
+//
+// The tag names are defined in RFC 8011 and the IANA IPP Registry.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
-ipp_tag_t /* O - Tag value */
-ippTagValue(const char *name) /* I - Tag name */
+ipp_tag_t // O - Tag value
+ippTagValue(const char *name) // I - Tag name
{
- size_t i; /* Looping var */
+ size_t i; // Looping var
for (i = 0; i < (sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])); i ++)
}
-/*
- * 'ipp_col_string()' - Convert a collection to a string.
- */
+//
+// 'ipp_col_string()' - Convert a collection to a string.
+//
-static size_t /* O - Number of bytes */
-ipp_col_string(ipp_t *col, /* I - Collection attribute */
- char *buffer, /* I - Buffer or NULL */
- size_t bufsize) /* I - Size of buffer */
+static size_t // O - Number of bytes
+ipp_col_string(ipp_t *col, // I - Collection attribute
+ char *buffer, // I - Buffer or NULL
+ size_t bufsize) // I - Size of buffer
{
- char *bufptr, /* Position in buffer */
- *bufend, /* End of buffer */
- prefix = '{', /* Prefix character */
- temp[256]; /* Temporary string */
- ipp_attribute_t *attr; /* Current member attribute */
+ char *bufptr, // Position in buffer
+ *bufend, // End of buffer
+ prefix = '{', // Prefix character
+ temp[256]; // Temporary string
+ ipp_attribute_t *attr; // Current member attribute
if (!col)
+++ /dev/null
-/*
- * IPP data file parsing functions.
- *
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
-
-#include "cups-private.h"
-#include "ipp-private.h"
-#include "string-private.h"
-#include "debug-internal.h"
-
-
-/*
- * '_ippVarsDeinit()' - Free all memory associated with the IPP variables.
- */
-
-void
-_ippVarsDeinit(_ipp_vars_t *v) /* I - IPP variables */
-{
- if (v->uri)
- {
- free(v->uri);
- v->uri = NULL;
- }
-
- cupsFreeOptions(v->num_vars, v->vars);
- v->num_vars = 0;
- v->vars = NULL;
-}
-
-
-/*
- * '_ippVarsExpand()' - Expand variables in the source string.
- */
-
-void
-_ippVarsExpand(_ipp_vars_t *v, /* I - IPP variables */
- char *dst, /* I - Destination buffer */
- const char *src, /* I - Source string */
- size_t dstsize) /* I - Destination buffer size */
-{
- char *dstptr, /* Pointer into destination */
- *dstend, /* End of destination */
- temp[256], /* Temporary string */
- *tempptr; /* Pointer into temporary string */
- const char *value; /* Value to substitute */
-
-
- dstptr = dst;
- dstend = dst + dstsize - 1;
-
- while (*src && dstptr < dstend)
- {
- if (*src == '$')
- {
- /*
- * Substitute a string/number...
- */
-
- if (!strncmp(src, "$$", 2))
- {
- value = "$";
- src += 2;
- }
- else if (!strncmp(src, "$ENV[", 5))
- {
- cupsCopyString(temp, src + 5, sizeof(temp));
-
- for (tempptr = temp; *tempptr; tempptr ++)
- if (*tempptr == ']')
- break;
-
- if (*tempptr)
- *tempptr++ = '\0';
-
- value = getenv(temp);
- src += tempptr - temp + 5;
- }
- else
- {
- if (src[1] == '{')
- {
- src += 2;
- cupsCopyString(temp, src, sizeof(temp));
- if ((tempptr = strchr(temp, '}')) != NULL)
- *tempptr = '\0';
- else
- tempptr = temp + strlen(temp);
- }
- else
- {
- cupsCopyString(temp, src + 1, sizeof(temp));
-
- for (tempptr = temp; *tempptr; tempptr ++)
- if (!isalnum(*tempptr & 255) && *tempptr != '-' && *tempptr != '_')
- break;
-
- if (*tempptr)
- *tempptr = '\0';
- }
-
- value = _ippVarsGet(v, temp);
-
- src += tempptr - temp + 1;
- }
-
- if (value)
- {
- cupsCopyString(dstptr, value, (size_t)(dstend - dstptr + 1));
- dstptr += strlen(dstptr);
- }
- }
- else
- *dstptr++ = *src++;
- }
-
- *dstptr = '\0';
-}
-
-
-/*
- * '_ippVarsGet()' - Get a variable string.
- */
-
-const char * /* O - Value or @code NULL@ if not set */
-_ippVarsGet(_ipp_vars_t *v, /* I - IPP variables */
- const char *name) /* I - Variable name */
-{
- if (!v)
- return (NULL);
- else if (!strcmp(name, "uri"))
- return (v->uri);
- else if (!strcmp(name, "uriuser") || !strcmp(name, "username"))
- return (v->username[0] ? v->username : NULL);
- else if (!strcmp(name, "scheme") || !strcmp(name, "method"))
- return (v->scheme);
- else if (!strcmp(name, "hostname"))
- return (v->host);
- else if (!strcmp(name, "port"))
- return (v->portstr);
- else if (!strcmp(name, "resource"))
- return (v->resource);
- else if (!strcmp(name, "user"))
- return (cupsGetUser());
- else
- return (cupsGetOption(name, v->num_vars, v->vars));
-}
-
-
-/*
- * '_ippVarsInit()' - Initialize .
- */
-
-void
-_ippVarsInit(_ipp_vars_t *v, /* I - IPP variables */
- _ipp_fattr_cb_t attrcb, /* I - Attribute (filter) callback */
- _ipp_ferror_cb_t errorcb, /* I - Error callback */
- _ipp_ftoken_cb_t tokencb) /* I - Token callback */
-{
- memset(v, 0, sizeof(_ipp_vars_t));
-
- v->attrcb = attrcb;
- v->errorcb = errorcb;
- v->tokencb = tokencb;
-}
-
-
-/*
- * '_ippVarsPasswordCB()' - Password callback using the IPP variables.
- */
-
-const char * /* O - Password string or @code NULL@ */
-_ippVarsPasswordCB(
- const char *prompt, /* I - Prompt string (not used) */
- http_t *http, /* I - HTTP connection (not used) */
- const char *method, /* I - HTTP method (not used) */
- const char *resource, /* I - Resource path (not used) */
- void *user_data) /* I - IPP variables */
-{
- _ipp_vars_t *v = (_ipp_vars_t *)user_data;
- /* I - IPP variables */
-
-
- (void)prompt;
- (void)http;
- (void)method;
- (void)resource;
-
- if (v->username[0] && v->password && v->password_tries < 3)
- {
- v->password_tries ++;
-
- cupsSetUser(v->username);
-
- return (v->password);
- }
- else
- {
- return (NULL);
- }
-}
-
-
-/*
- * '_ippVarsSet()' - Set an IPP variable.
- */
-
-int /* O - 1 on success, 0 on failure */
-_ippVarsSet(_ipp_vars_t *v, /* I - IPP variables */
- const char *name, /* I - Variable name */
- const char *value) /* I - Variable value */
-{
- if (!strcmp(name, "uri"))
- {
- char uri[1024]; /* New printer URI */
- char resolved[1024]; /* Resolved mDNS URI */
-
- if (strstr(value, "._tcp"))
- {
- /*
- * Resolve URI...
- */
-
- if (!httpResolveURI(value, resolved, sizeof(resolved), HTTP_RESOLVE_DEFAULT, NULL, NULL))
- return (0);
-
- value = resolved;
- }
-
- if (httpSeparateURI(HTTP_URI_CODING_ALL, value, v->scheme, sizeof(v->scheme), v->username, sizeof(v->username), v->host, sizeof(v->host), &(v->port), v->resource, sizeof(v->resource)) < HTTP_URI_STATUS_OK)
- return (0);
-
- if (v->username[0])
- {
- if ((v->password = strchr(v->username, ':')) != NULL)
- *(v->password)++ = '\0';
- }
-
- snprintf(v->portstr, sizeof(v->portstr), "%d", v->port);
-
- if (v->uri)
- free(v->uri);
-
- httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), v->scheme, NULL, v->host, v->port, v->resource);
- v->uri = strdup(uri);
-
- return (v->uri != NULL);
- }
- else
- {
- v->num_vars = cupsAddOption(name, value, v->num_vars, &v->vars);
- return (1);
- }
-}
-/*
- * Internet Printing Protocol functions for CUPS.
- *
- * Copyright © 2007-2021 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Internet Printing Protocol functions for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2021 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products, all rights reserved.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#include "cups-private.h"
-#include "debug-internal.h"
#include <regex.h>
#ifdef _WIN32
# include <io.h>
-#endif /* _WIN32 */
+#endif // _WIN32
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
-static ipp_attribute_t *ipp_add_attr(ipp_t *ipp, const char *name,
- ipp_tag_t group_tag, ipp_tag_t value_tag,
- int num_values);
-static void ipp_free_values(ipp_attribute_t *attr, int element,
- int count);
+static ipp_attribute_t *ipp_add_attr(ipp_t *ipp, const char *name, ipp_tag_t group_tag, ipp_tag_t value_tag, int num_values);
+static void ipp_free_values(ipp_attribute_t *attr, int element, int count);
static char *ipp_get_code(const char *locale, char *buffer, size_t bufsize) _CUPS_NONNULL(1,2);
static char *ipp_lang_code(const char *locale, char *buffer, size_t bufsize) _CUPS_NONNULL(1,2);
static size_t ipp_length(ipp_t *ipp, int collection);
-static ssize_t ipp_read_http(http_t *http, ipp_uchar_t *buffer,
- size_t length);
-static ssize_t ipp_read_file(int *fd, ipp_uchar_t *buffer,
- size_t length);
-static void ipp_set_error(ipp_status_t status, const char *format,
- ...);
-static _ipp_value_t *ipp_set_value(ipp_t *ipp, ipp_attribute_t **attr,
- int element);
-static ssize_t ipp_write_file(int *fd, ipp_uchar_t *buffer,
- size_t length);
-
-
-/*
- * '_cupsBufferGet()' - Get a read/write buffer.
- */
-
-char * /* O - Buffer */
-_cupsBufferGet(size_t size) /* I - Size required */
+static ssize_t ipp_read_http(http_t *http, ipp_uchar_t *buffer, size_t length);
+static ssize_t ipp_read_file(int *fd, ipp_uchar_t *buffer, size_t length);
+static void ipp_set_error(ipp_status_t status, const char *format, ...);
+static _ipp_value_t *ipp_set_value(ipp_t *ipp, ipp_attribute_t **attr, int element);
+static ssize_t ipp_write_file(int *fd, ipp_uchar_t *buffer, size_t length);
+
+
+//
+// '_cupsBufferGet()' - Get a read/write buffer.
+//
+
+char * // O - Buffer
+_cupsBufferGet(size_t size) // I - Size required
{
- _cups_buffer_t *buffer; /* Current buffer */
+ _cups_buffer_t *buffer; // Current buffer
_cups_globals_t *cg = _cupsGlobals();
- /* Global data */
+ // Global data
for (buffer = cg->cups_buffers; buffer; buffer = buffer->next)
}
-/*
- * '_cupsBufferRelease()' - Release a read/write buffer.
- */
+//
+// '_cupsBufferRelease()' - Release a read/write buffer.
+//
void
-_cupsBufferRelease(char *b) /* I - Buffer to release */
+_cupsBufferRelease(char *b) // I - Buffer to release
{
- _cups_buffer_t *buffer; /* Buffer */
-
+ _cups_buffer_t *buffer; // Buffer
- /*
- * Mark this buffer as unused...
- */
+ // Mark this buffer as unused...
buffer = (_cups_buffer_t *)(b - offsetof(_cups_buffer_t, d));
buffer->used = 0;
}
-/*
- * 'ippAddBoolean()' - Add a boolean attribute to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddBoolean(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- char value) /* I - Value of attribute */
+//
+// 'ippAddBoolean()' - Add a boolean attribute to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddBoolean(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ char value) // I - Value of attribute
{
- ipp_attribute_t *attr; /* New attribute */
+ ipp_attribute_t *attr; // New attribute
DEBUG_printf("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), name, value);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BOOLEAN, 1)) == NULL)
return (NULL);
}
-/*
- * 'ippAddBooleans()' - Add an array of boolean values.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddBooleans(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- int num_values, /* I - Number of values */
- const char *values) /* I - Values */
+//
+// 'ippAddBooleans()' - Add an array of boolean values.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddBooleans(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ int num_values, // I - Number of values
+ const char *values) // I - Values
{
- int i; /* Looping var */
- ipp_attribute_t *attr; /* New attribute */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ ipp_attribute_t *attr; // New attribute
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- num_values < 1)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || num_values < 1)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BOOLEAN, num_values)) == NULL)
return (NULL);
if (values)
{
- for (i = num_values, value = attr->values;
- i > 0;
- i --, value ++)
+ for (i = num_values, value = attr->values; i > 0; i --, value ++)
value->boolean = *values++;
}
}
-/*
- * 'ippAddCollection()' - Add a collection value.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddCollection(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- ipp_t *value) /* I - Value */
+//
+// 'ippAddCollection()' - Add a collection value.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddCollection(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ ipp_t *value) // I - Value
{
- ipp_attribute_t *attr; /* New attribute */
+ ipp_attribute_t *attr; // New attribute
DEBUG_printf("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BEGIN_COLLECTION, 1)) == NULL)
return (NULL);
}
-/*
- * 'ippAddCollections()' - Add an array of collection values.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
-
-ipp_attribute_t * /* O - New attribute */
+//
+// 'ippAddCollections()' - Add an array of collection values.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
+
+ipp_attribute_t * // O - New attribute
ippAddCollections(
- ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- int num_values, /* I - Number of values */
- const ipp_t **values) /* I - Values */
+ ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ int num_values, // I - Number of values
+ const ipp_t **values) // I - Values
{
- int i; /* Looping var */
- ipp_attribute_t *attr; /* New attribute */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ ipp_attribute_t *attr; // New attribute
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- num_values < 1)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || num_values < 1)
return (NULL);
- /*
- * Create the attribute...
- */
-
- if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BEGIN_COLLECTION,
- num_values)) == NULL)
+ // Create the attribute...
+ if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BEGIN_COLLECTION, num_values)) == NULL)
return (NULL);
if (values)
{
- for (i = num_values, value = attr->values;
- i > 0;
- i --, value ++)
+ for (i = num_values, value = attr->values; i > 0; i --, value ++)
{
value->collection = (ipp_t *)*values++;
value->collection->use ++;
}
-/*
- * 'ippAddDate()' - Add a dateTime attribute to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddDate(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- const ipp_uchar_t *value) /* I - Value */
+//
+// 'ippAddCredentialsString()' - Add a credentials string attribute to an IPP message.
+//
+// This function adds a 1setOf text attribute to an IPP message corresponding to
+// the specified credentials string.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// @since CUPS 2.5@
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddCredentialsString(
+ ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Attribute name
+ const char *credentials) // I - Credentials string
{
- ipp_attribute_t *attr; /* New attribute */
-
+ ipp_attribute_t *attr; // New attribute
+ char *cvalue, // Copied value
+ *cstart, // Start of value
+ *cptr; // Pointer into copied value
+ size_t i, // Looping var
+ num_values; // Number of values
- DEBUG_printf("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value);
- /*
- * Range check input...
- */
+ // Range check input...
+ if (!ipp || !name || !credentials)
+ return (NULL);
- if (!ipp || !name || !value || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ // Copy the value string and figure out the number of values...
+ if ((cvalue = strdup(credentials)) == NULL)
return (NULL);
- /*
- * Create the attribute...
- */
+ for (num_values = 0, cptr = cvalue; cptr;)
+ {
+ // Find the next delimiter
+ if (*cptr && *cptr != '\r' && *cptr != '\n')
+ num_values ++;
+ cstart = cptr;
+ if ((cptr = strchr(cstart, '\r')) != NULL)
+ {
+ // Skip CR or CR LF
+ if (cptr[1] == '\n')
+ cptr += 2;
+ else
+ cptr ++;
+ }
+ else if ((cptr = strchr(cstart, '\n')) != NULL)
+ {
+ // Skip LF
+ cptr ++;
+ }
+ }
+
+ // Create the empty attribute and copy the values...
+ if ((attr = ippAddStrings(ipp, group, IPP_TAG_TEXT, name, num_values, NULL, NULL)) != NULL)
+ {
+ for (i = 0, cptr = cvalue; cptr && i < num_values;)
+ {
+ cstart = cptr;
+ if ((cptr = strchr(cptr, '\r')) != NULL)
+ {
+ // Terminate on CR
+ *cptr++ = '\0';
+ if (*cptr == '\n')
+ cptr ++; // Skip LF
+ }
+ else if ((cptr = strchr(cptr, '\n')) != NULL)
+ {
+ // Terminate on LF
+ *cptr++ = '\0';
+ }
+
+ if (*cstart)
+ attr->values[i++].string.text = _cupsStrAlloc(cstart);
+ }
+ }
+
+ // Free the copied string and return...
+ free(cvalue);
+
+ return (attr);
+}
+
+
+//
+// 'ippAddDate()' - Add a dateTime attribute to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddDate(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ const ipp_uchar_t *value) // I - Value
+{
+ ipp_attribute_t *attr; // New attribute
+
+
+ DEBUG_printf("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value);
+
+ // Range check input...
+ if (!ipp || !name || !value || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ return (NULL);
+
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_DATE, 1)) == NULL)
return (NULL);
}
-/*
- * 'ippAddInteger()' - Add a integer attribute to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported values include enum (@code IPP_TAG_ENUM@) and integer
- * (@code IPP_TAG_INTEGER@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddInteger(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- int value) /* I - Value of attribute */
+//
+// 'ippAddInteger()' - Add a integer attribute to an IPP message.
+//
+// This function adds an integer or enum attribute to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported values include enum (`IPP_TAG_ENUM`) and integer
+// (`IPP_TAG_INTEGER`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddInteger(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name, // I - Name of attribute
+ int value) // I - Value of attribute
{
- ipp_attribute_t *attr; /* New attribute */
+ ipp_attribute_t *attr; // New attribute
DEBUG_printf("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, value);
value_tag &= IPP_TAG_CUPS_MASK;
- /*
- * Special-case for legacy usage: map out-of-band attributes to new ippAddOutOfBand
- * function...
- */
-
+ // Special-case for legacy usage: map out-of-band attributes to new ippAddOutOfBand function...
if (value_tag >= IPP_TAG_UNSUPPORTED_VALUE && value_tag <= IPP_TAG_ADMINDEFINE)
return (ippAddOutOfBand(ipp, group, value_tag, name));
- /*
- * Range check input...
- */
-
-#if 0
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM))
- return (NULL);
-#else
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM))
return (NULL);
-#endif /* 0 */
-
- /*
- * Create the attribute...
- */
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, value_tag, 1)) == NULL)
return (NULL);
}
-/*
- * 'ippAddIntegers()' - Add an array of integer values.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported values include enum (@code IPP_TAG_ENUM@) and integer
- * (@code IPP_TAG_INTEGER@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddIntegers(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- int num_values, /* I - Number of values */
- const int *values) /* I - Values */
+//
+// 'ippAddIntegers()' - Add an array of integer values.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported values include enum (`IPP_TAG_ENUM`) and integer
+// (`IPP_TAG_INTEGER`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddIntegers(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name, // I - Name of attribute
+ int num_values, // I - Number of values
+ const int *values) // I - Values
{
- int i; /* Looping var */
- ipp_attribute_t *attr; /* New attribute */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ ipp_attribute_t *attr; // New attribute
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, (void *)values);
value_tag &= IPP_TAG_CUPS_MASK;
- /*
- * Range check input...
- */
-
-#if 0
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM) ||
- num_values < 1)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM) || num_values < 1)
return (NULL);
-#else
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- num_values < 1)
- return (NULL);
-#endif /* 0 */
-
- /*
- * Create the attribute...
- */
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, value_tag, num_values)) == NULL)
return (NULL);
if (values)
{
- for (i = num_values, value = attr->values;
- i > 0;
- i --, value ++)
+ for (i = num_values, value = attr->values; i > 0; i --, value ++)
value->integer = *values++;
}
}
-/*
- * 'ippAddOctetString()' - Add an octetString value to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * @since CUPS 1.2/macOS 10.5@
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddOctetString(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- const void *data, /* I - octetString data */
- int datalen) /* I - Length of data in bytes */
+//
+// 'ippAddOctetString()' - Add an octetString value to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// @since CUPS 1.2/macOS 10.5@
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddOctetString(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ const void *data, // I - octetString data
+ int datalen) // I - Length of data in bytes
{
- ipp_attribute_t *attr; /* New attribute */
+ ipp_attribute_t *attr; // New attribute
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- datalen < 0 || datalen > IPP_MAX_LENGTH)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || datalen < 0 || datalen > IPP_MAX_LENGTH)
return (NULL);
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_STRING, 1)) == NULL)
return (NULL);
- /*
- * Initialize the attribute data...
- */
-
+ // Initialize the attribute data...
attr->values[0].unknown.length = datalen;
if (data)
memcpy(attr->values[0].unknown.data, data, (size_t)datalen);
}
- /*
- * Return the new attribute...
- */
-
+ // Return the new attribute...
return (attr);
}
-/*
- * 'ippAddOutOfBand()' - Add an out-of-band value to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported out-of-band values include unsupported-value
- * (@code IPP_TAG_UNSUPPORTED_VALUE@), default (@code IPP_TAG_DEFAULT@), unknown
- * (@code IPP_TAG_UNKNOWN@), no-value (@code IPP_TAG_NOVALUE@), not-settable
- * (@code IPP_TAG_NOTSETTABLE@), delete-attribute (@code IPP_TAG_DELETEATTR@), and
- * admin-define (@code IPP_TAG_ADMINDEFINE@).
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddOutOfBand(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name) /* I - Name of attribute */
+//
+// 'ippAddOutOfBand()' - Add an out-of-band value to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported out-of-band values include unsupported-value
+// (`IPP_TAG_UNSUPPORTED_VALUE`), default (`IPP_TAG_DEFAULT`), unknown
+// (`IPP_TAG_UNKNOWN`), no-value (`IPP_TAG_NOVALUE`), not-settable
+// (`IPP_TAG_NOTSETTABLE`), delete-attribute (`IPP_TAG_DELETEATTR`), and
+// admin-define (`IPP_TAG_ADMINDEFINE`).
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddOutOfBand(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name) // I - Name of attribute
{
DEBUG_printf("ippAddOutOfBand(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name);
value_tag &= IPP_TAG_CUPS_MASK;
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- (value_tag != IPP_TAG_UNSUPPORTED_VALUE &&
- value_tag != IPP_TAG_DEFAULT &&
- value_tag != IPP_TAG_UNKNOWN &&
- value_tag != IPP_TAG_NOVALUE &&
- value_tag != IPP_TAG_NOTSETTABLE &&
- value_tag != IPP_TAG_DELETEATTR &&
- value_tag != IPP_TAG_ADMINDEFINE))
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || (value_tag != IPP_TAG_UNSUPPORTED_VALUE && value_tag != IPP_TAG_DEFAULT && value_tag != IPP_TAG_UNKNOWN && value_tag != IPP_TAG_NOVALUE && value_tag != IPP_TAG_NOTSETTABLE && value_tag != IPP_TAG_DELETEATTR && value_tag != IPP_TAG_ADMINDEFINE))
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
return (ipp_add_attr(ipp, name, group, value_tag, 1));
}
-/*
- * 'ippAddRange()' - Add a range of values to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * The @code lower@ parameter must be less than or equal to the @code upper@ parameter.
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddRange(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- int lower, /* I - Lower value */
- int upper) /* I - Upper value */
+//
+// 'ippAddRange()' - Add a range of values to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// The "lower" parameter must be less than or equal to the "upper" parameter.
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddRange(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ int lower, // I - Lower value
+ int upper) // I - Upper value
{
- ipp_attribute_t *attr; /* New attribute */
+ ipp_attribute_t *attr; // New attribute
DEBUG_printf("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, upper=%d)", (void *)ipp, group, ippTagString(group), name, lower, upper);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RANGE, 1)) == NULL)
return (NULL);
}
-/*
- * 'ippAddRanges()' - Add ranges of values to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddRanges(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- int num_values, /* I - Number of values */
- const int *lower, /* I - Lower values */
- const int *upper) /* I - Upper values */
+//
+// 'ippAddRanges()' - Add ranges of values to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddRanges(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ int num_values, // I - Number of values
+ const int *lower, // I - Lower values
+ const int *upper) // I - Upper values
{
- int i; /* Looping var */
- ipp_attribute_t *attr; /* New attribute */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ ipp_attribute_t *attr; // New attribute
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, lower=%p, upper=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)lower, (void *)upper);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- num_values < 1)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || num_values < 1)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RANGE, num_values)) == NULL)
return (NULL);
if (lower && upper)
{
- for (i = num_values, value = attr->values;
- i > 0;
- i --, value ++)
+ for (i = num_values, value = attr->values; i > 0; i --, value ++)
{
value->range.lower = *lower++;
value->range.upper = *upper++;
}
-/*
- * 'ippAddResolution()' - Add a resolution value to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddResolution(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- ipp_res_t units, /* I - Units for resolution */
- int xres, /* I - X resolution */
- int yres) /* I - Y resolution */
+//
+// 'ippAddResolution()' - Add a resolution value to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddResolution(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ ipp_res_t units, // I - Units for resolution
+ int xres, // I - X resolution
+ int yres) // I - Y resolution
{
- ipp_attribute_t *attr; /* New attribute */
+ ipp_attribute_t *attr; // New attribute
DEBUG_printf("ippAddResolution(ipp=%p, group=%02x(%s), name=\"%s\", units=%d, xres=%d, yres=%d)", (void *)ipp, group, ippTagString(group), name, units, xres, yres);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- units < IPP_RES_PER_INCH || units > IPP_RES_PER_CM ||
- xres < 0 || yres < 0)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || units < IPP_RES_PER_INCH || units > IPP_RES_PER_CM || xres < 0 || yres < 0)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RESOLUTION, 1)) == NULL)
return (NULL);
}
-/*
- * 'ippAddResolutions()' - Add resolution values to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddResolutions(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- const char *name, /* I - Name of attribute */
- int num_values,/* I - Number of values */
- ipp_res_t units, /* I - Units for resolution */
- const int *xres, /* I - X resolutions */
- const int *yres) /* I - Y resolutions */
+//
+// 'ippAddResolutions()' - Add resolution values to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddResolutions(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ const char *name, // I - Name of attribute
+ int num_values,// I - Number of values
+ ipp_res_t units, // I - Units for resolution
+ const int *xres, // I - X resolutions
+ const int *yres) // I - Y resolutions
{
- int i; /* Looping var */
- ipp_attribute_t *attr; /* New attribute */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ ipp_attribute_t *attr; // New attribute
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", num_value=%d, units=%d, xres=%p, yres=%p)", (void *)ipp, group, ippTagString(group), name, num_values, units, (void *)xres, (void *)yres);
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- num_values < 1 ||
- units < IPP_RES_PER_INCH || units > IPP_RES_PER_CM)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || num_values < 1 || units < IPP_RES_PER_INCH || units > IPP_RES_PER_CM)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RESOLUTION, num_values)) == NULL)
return (NULL);
if (xres && yres)
{
- for (i = num_values, value = attr->values;
- i > 0;
- i --, value ++)
+ for (i = num_values, value = attr->values; i > 0; i --, value ++)
{
value->resolution.xres = *xres++;
value->resolution.yres = *yres++;
}
-/*
- * 'ippAddSeparator()' - Add a group separator to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- */
+//
+// 'ippAddSeparator()' - Add a group separator to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
-ipp_attribute_t * /* O - New attribute */
-ippAddSeparator(ipp_t *ipp) /* I - IPP message */
+ipp_attribute_t * // O - New attribute
+ippAddSeparator(ipp_t *ipp) // I - IPP message
{
DEBUG_printf("ippAddSeparator(ipp=%p)", (void *)ipp);
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (NULL);
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
return (ipp_add_attr(ipp, NULL, IPP_TAG_ZERO, IPP_TAG_ZERO, 0));
}
-/*
- * 'ippAddString()' - Add a language-encoded string to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported string values include charset (@code IPP_TAG_CHARSET@), keyword
- * (@code IPP_TAG_KEYWORD@), language (@code IPP_TAG_LANGUAGE@), mimeMediaType
- * (@code IPP_TAG_MIMETYPE@), name (@code IPP_TAG_NAME@), nameWithLanguage
- * (@code IPP_TAG_NAMELANG), text (@code IPP_TAG_TEXT@), textWithLanguage
- * (@code IPP_TAG_TEXTLANG@), uri (@code IPP_TAG_URI@), and uriScheme
- * (@code IPP_TAG_URISCHEME@).
- *
- * The @code language@ parameter must be non-@code NULL@ for nameWithLanguage and
- * textWithLanguage string values and must be @code NULL@ for all other string values.
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddString(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- const char *language, /* I - Language code */
- const char *value) /* I - Value */
+//
+// 'ippAddString()' - Add a language-encoded string to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported string values include charset (`IPP_TAG_CHARSET`), keyword
+// (`IPP_TAG_KEYWORD`), language (`IPP_TAG_LANGUAGE`), mimeMediaType
+// (`IPP_TAG_MIMETYPE`), name (`IPP_TAG_NAME`), nameWithLanguage
+// (@code IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
+// (`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
+// (`IPP_TAG_URISCHEME`).
+//
+// The "language" parameter must be non-`NULL` for nameWithLanguage and
+// textWithLanguage string values and must be `NULL` for all other string values.
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddString(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name, // I - Name of attribute
+ const char *language, // I - Language code
+ const char *value) // I - Value
{
- ipp_tag_t temp_tag; /* Temporary value tag (masked) */
- ipp_attribute_t *attr; /* New attribute */
+ ipp_tag_t temp_tag; // Temporary value tag (masked)
+ ipp_attribute_t *attr; // New attribute
char code[IPP_MAX_LANGUAGE];
- /* Charset/language code buffer */
+ // Charset/language code buffer
DEBUG_printf("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", language=\"%s\", value=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, language, value);
- /*
- * Range check input...
- */
-
+ // Range check input...
temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_CUPS_MASK);
#if 0
!= (language != NULL))
return (NULL);
#else
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
return (NULL);
-#endif /* 0 */
-
- /*
- * See if we need to map charset, language, or locale values...
- */
-
- if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) &&
- strcmp(language, ipp_lang_code(language, code, sizeof(code))))
- value_tag = temp_tag; /* Don't do a fast copy */
- else if (value && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST) &&
- strcmp(value, ipp_get_code(value, code, sizeof(code))))
- value_tag = temp_tag; /* Don't do a fast copy */
- else if (value && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST) &&
- strcmp(value, ipp_lang_code(value, code, sizeof(code))))
- value_tag = temp_tag; /* Don't do a fast copy */
-
- /*
- * Create the attribute...
- */
+#endif // 0
+ // See if we need to map charset, language, or locale values...
+ if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) && strcmp(language, ipp_lang_code(language, code, sizeof(code))))
+ value_tag = temp_tag; // Don't do a fast copy
+ else if (value && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST) && strcmp(value, ipp_get_code(value, code, sizeof(code))))
+ value_tag = temp_tag; // Don't do a fast copy
+ else if (value && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST) && strcmp(value, ipp_lang_code(value, code, sizeof(code))))
+ value_tag = temp_tag; // Don't do a fast copy
+
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, value_tag, 1)) == NULL)
return (NULL);
- /*
- * Initialize the attribute data...
- */
-
+ // Initialize the attribute data...
if ((int)value_tag & IPP_TAG_CUPS_CONST)
{
attr->values[0].string.language = (char *)language;
else
{
if (language)
- attr->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language, code,
- sizeof(code)));
+ attr->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language, code, sizeof(code)));
if (value)
{
if (value_tag == IPP_TAG_CHARSET)
- attr->values[0].string.text = _cupsStrAlloc(ipp_get_code(value, code,
- sizeof(code)));
+ attr->values[0].string.text = _cupsStrAlloc(ipp_get_code(value, code, sizeof(code)));
else if (value_tag == IPP_TAG_LANGUAGE)
- attr->values[0].string.text = _cupsStrAlloc(ipp_lang_code(value, code,
- sizeof(code)));
+ attr->values[0].string.text = _cupsStrAlloc(ipp_lang_code(value, code, sizeof(code)));
else
attr->values[0].string.text = _cupsStrAlloc(value);
}
}
-/*
- * 'ippAddStringf()' - Add a formatted string to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document
- * (@code IPP_TAG_DOCUMENT@), event notification
- * (@code IPP_TAG_EVENT_NOTIFICATION@), operation (@code IPP_TAG_OPERATION@),
- * printer (@code IPP_TAG_PRINTER@), subscription (@code IPP_TAG_SUBSCRIPTION@),
- * or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported string values include charset (@code IPP_TAG_CHARSET@), keyword
- * (@code IPP_TAG_KEYWORD@), language (@code IPP_TAG_LANGUAGE@), mimeMediaType
- * (@code IPP_TAG_MIMETYPE@), name (@code IPP_TAG_NAME@), nameWithLanguage
- * (@code IPP_TAG_NAMELANG), text (@code IPP_TAG_TEXT@), textWithLanguage
- * (@code IPP_TAG_TEXTLANG@), uri (@code IPP_TAG_URI@), and uriScheme
- * (@code IPP_TAG_URISCHEME@).
- *
- * The @code language@ parameter must be non-@code NULL@ for nameWithLanguage
- * and textWithLanguage string values and must be @code NULL@ for all other
- * string values.
- *
- * The @code format@ parameter uses formatting characters compatible with the
- * printf family of standard functions. Additional arguments follow it as
- * needed. The formatted string is truncated as needed to the maximum length of
- * the corresponding value type.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddStringf(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- const char *language, /* I - Language code (@code NULL@ for default) */
- const char *format, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
+//
+// 'ippAddStringf()' - Add a formatted string to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document
+// (`IPP_TAG_DOCUMENT`), event notification
+// (`IPP_TAG_EVENT_NOTIFICATION`), operation (`IPP_TAG_OPERATION`),
+// printer (`IPP_TAG_PRINTER`), subscription (`IPP_TAG_SUBSCRIPTION`),
+// or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported string values include charset (`IPP_TAG_CHARSET`), keyword
+// (`IPP_TAG_KEYWORD`), language (`IPP_TAG_LANGUAGE`), mimeMediaType
+// (`IPP_TAG_MIMETYPE`), name (`IPP_TAG_NAME`), nameWithLanguage
+// (@code IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
+// (`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
+// (`IPP_TAG_URISCHEME`).
+//
+// The "language" parameter must be non-`NULL` for nameWithLanguage
+// and textWithLanguage string values and must be `NULL` for all other
+// string values.
+//
+// The "format" parameter uses formatting characters compatible with the
+// printf family of standard functions. Additional arguments follow it as
+// needed. The formatted string is truncated as needed to the maximum length of
+// the corresponding value type.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddStringf(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name, // I - Name of attribute
+ const char *language, // I - Language code (`NULL` for default)
+ const char *format, // I - Printf-style format string
+ ...) // I - Additional arguments as needed
{
- ipp_attribute_t *attr; /* New attribute */
- va_list ap; /* Argument pointer */
+ ipp_attribute_t *attr; // New attribute
+ va_list ap; // Argument pointer
va_start(ap, format);
}
-/*
- * 'ippAddStringfv()' - Add a formatted string to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document
- * (@code IPP_TAG_DOCUMENT@), event notification
- * (@code IPP_TAG_EVENT_NOTIFICATION@), operation (@code IPP_TAG_OPERATION@),
- * printer (@code IPP_TAG_PRINTER@), subscription (@code IPP_TAG_SUBSCRIPTION@),
- * or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported string values include charset (@code IPP_TAG_CHARSET@), keyword
- * (@code IPP_TAG_KEYWORD@), language (@code IPP_TAG_LANGUAGE@), mimeMediaType
- * (@code IPP_TAG_MIMETYPE@), name (@code IPP_TAG_NAME@), nameWithLanguage
- * (@code IPP_TAG_NAMELANG), text (@code IPP_TAG_TEXT@), textWithLanguage
- * (@code IPP_TAG_TEXTLANG@), uri (@code IPP_TAG_URI@), and uriScheme
- * (@code IPP_TAG_URISCHEME@).
- *
- * The @code language@ parameter must be non-@code NULL@ for nameWithLanguage
- * and textWithLanguage string values and must be @code NULL@ for all other
- * string values.
- *
- * The @code format@ parameter uses formatting characters compatible with the
- * printf family of standard functions. Additional arguments are passed in the
- * stdarg pointer @code ap@. The formatted string is truncated as needed to the
- * maximum length of the corresponding value type.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-ipp_attribute_t * /* O - New attribute */
-ippAddStringfv(ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- const char *language, /* I - Language code (@code NULL@ for default) */
- const char *format, /* I - Printf-style format string */
- va_list ap) /* I - Additional arguments */
+//
+// 'ippAddStringfv()' - Add a formatted string to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document
+// (`IPP_TAG_DOCUMENT`), event notification
+// (`IPP_TAG_EVENT_NOTIFICATION`), operation (`IPP_TAG_OPERATION`),
+// printer (`IPP_TAG_PRINTER`), subscription (`IPP_TAG_SUBSCRIPTION`),
+// or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported string values include charset (`IPP_TAG_CHARSET`), keyword
+// (`IPP_TAG_KEYWORD`), language (`IPP_TAG_LANGUAGE`), mimeMediaType
+// (`IPP_TAG_MIMETYPE`), name (`IPP_TAG_NAME`), nameWithLanguage
+// (@code IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
+// (`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
+// (`IPP_TAG_URISCHEME`).
+//
+// The "language" parameter must be non-`NULL` for nameWithLanguage
+// and textWithLanguage string values and must be `NULL` for all other
+// string values.
+//
+// The "format" parameter uses formatting characters compatible with the
+// printf family of standard functions. Additional arguments are passed in the
+// stdarg pointer "ap". The formatted string is truncated as needed to the
+// maximum length of the corresponding value type.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+ipp_attribute_t * // O - New attribute
+ippAddStringfv(ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name, // I - Name of attribute
+ const char *language, // I - Language code (`NULL` for default)
+ const char *format, // I - Printf-style format string
+ va_list ap) // I - Additional arguments
{
char buffer[IPP_MAX_TEXT + 4];
- /* Formatted text string */
- ssize_t bytes, /* Length of formatted value */
- max_bytes; /* Maximum number of bytes for value */
+ // Formatted text string
+ ssize_t bytes, // Length of formatted value
+ max_bytes; // Maximum number of bytes for value
- /*
- * Range check input...
- */
-
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG &&
- value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE ||
- !format)
+ // Range check input...
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG && value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE || !format)
return (NULL);
- if ((value_tag == IPP_TAG_TEXTLANG || value_tag == IPP_TAG_NAMELANG)
- != (language != NULL))
+ if ((value_tag == IPP_TAG_TEXTLANG || value_tag == IPP_TAG_NAMELANG) != (language != NULL))
return (NULL);
- /*
- * Format the string...
- */
-
+ // Format the string...
if (!strcmp(format, "%s"))
{
- /*
- * Optimize the simple case...
- */
-
+ // Optimize the simple case...
const char *s = va_arg(ap, char *);
if (!s)
}
else
{
- /*
- * Do a full formatting of the message...
- */
-
+ // Do a full formatting of the message...
if ((bytes = vsnprintf(buffer, sizeof(buffer), format, ap)) < 0)
return (NULL);
}
- /*
- * Limit the length of the string...
- */
-
+ // Limit the length of the string...
switch (value_tag)
{
default :
if (bytes >= max_bytes)
{
- char *bufmax, /* Buffer at max_bytes */
- *bufptr; /* Pointer into buffer */
+ char *bufmax, // Buffer at max_bytes
+ *bufptr; // Pointer into buffer
bufptr = buffer + strlen(buffer) - 1;
bufmax = buffer + max_bytes - 1;
*bufptr = '\0';
}
- /*
- * Add the formatted string and return...
- */
-
+ // Add the formatted string and return...
return (ippAddString(ipp, group, value_tag, name, language, buffer));
}
-/*
- * 'ippAddStrings()' - Add language-encoded strings to an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * Supported string values include charset (@code IPP_TAG_CHARSET@), keyword
- * (@code IPP_TAG_KEYWORD@), language (@code IPP_TAG_LANGUAGE@), mimeMediaType
- * (@code IPP_TAG_MIMETYPE@), name (@code IPP_TAG_NAME@), nameWithLanguage
- * (@code IPP_TAG_NAMELANG), text (@code IPP_TAG_TEXT@), textWithLanguage
- * (@code IPP_TAG_TEXTLANG@), uri (@code IPP_TAG_URI@), and uriScheme
- * (@code IPP_TAG_URISCHEME@).
- *
- * The @code language@ parameter must be non-@code NULL@ for nameWithLanguage and
- * textWithLanguage string values and must be @code NULL@ for all other string values.
- */
-
-ipp_attribute_t * /* O - New attribute */
+//
+// 'ippAddStrings()' - Add language-encoded strings to an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// Supported string values include charset (`IPP_TAG_CHARSET`), keyword
+// (`IPP_TAG_KEYWORD`), language (`IPP_TAG_LANGUAGE`), mimeMediaType
+// (`IPP_TAG_MIMETYPE`), name (`IPP_TAG_NAME`), nameWithLanguage
+// (@code IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
+// (`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
+// (`IPP_TAG_URISCHEME`).
+//
+// The "language" parameter must be non-`NULL` for nameWithLanguage and
+// textWithLanguage string values and must be `NULL` for all other string values.
+//
+
+ipp_attribute_t * // O - New attribute
ippAddStrings(
- ipp_t *ipp, /* I - IPP message */
- ipp_tag_t group, /* I - IPP group */
- ipp_tag_t value_tag, /* I - Type of attribute */
- const char *name, /* I - Name of attribute */
- int num_values, /* I - Number of values */
- const char *language, /* I - Language code (@code NULL@ for default) */
- const char * const *values) /* I - Values */
+ ipp_t *ipp, // I - IPP message
+ ipp_tag_t group, // I - IPP group
+ ipp_tag_t value_tag, // I - Type of attribute
+ const char *name, // I - Name of attribute
+ int num_values, // I - Number of values
+ const char *language, // I - Language code (`NULL` for default)
+ const char * const *values) // I - Values
{
- int i; /* Looping var */
- ipp_tag_t temp_tag; /* Temporary value tag (masked) */
- ipp_attribute_t *attr; /* New attribute */
- _ipp_value_t *value; /* Current value */
- char code[32]; /* Language/charset value buffer */
+ int i; // Looping var
+ ipp_tag_t temp_tag; // Temporary value tag (masked)
+ ipp_attribute_t *attr; // New attribute
+ _ipp_value_t *value; // Current value
+ char code[32]; // Language/charset value buffer
DEBUG_printf("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", num_values=%d, language=\"%s\", values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, language, (void *)values);
- /*
- * Range check input...
- */
-
+ // Range check input...
temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_CUPS_MASK);
#if 0
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- (temp_tag < IPP_TAG_TEXT && temp_tag != IPP_TAG_TEXTLANG &&
- temp_tag != IPP_TAG_NAMELANG) || temp_tag > IPP_TAG_MIMETYPE ||
- num_values < 1)
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || (temp_tag < IPP_TAG_TEXT && temp_tag != IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_NAMELANG) || temp_tag > IPP_TAG_MIMETYPE || num_values < 1)
return (NULL);
- if ((temp_tag == IPP_TAG_TEXTLANG || temp_tag == IPP_TAG_NAMELANG)
- != (language != NULL))
+ if ((temp_tag == IPP_TAG_TEXTLANG || temp_tag == IPP_TAG_NAMELANG) != (language != NULL))
return (NULL);
#else
- if (!ipp || !name || group < IPP_TAG_ZERO ||
- group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
- num_values < 1)
+ if (!ipp || !name || group < IPP_TAG_ZERO || group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || num_values < 1)
return (NULL);
-#endif /* 0 */
-
- /*
- * See if we need to map charset, language, or locale values...
- */
+#endif // 0
- if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) &&
- strcmp(language, ipp_lang_code(language, code, sizeof(code))))
- value_tag = temp_tag; /* Don't do a fast copy */
+ // See if we need to map charset, language, or locale values...
+ if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) && strcmp(language, ipp_lang_code(language, code, sizeof(code))))
+ {
+ value_tag = temp_tag; // Don't do a fast copy
+ }
else if (values && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST))
{
for (i = 0; i < num_values; i ++)
+ {
if (strcmp(values[i], ipp_get_code(values[i], code, sizeof(code))))
{
- value_tag = temp_tag; /* Don't do a fast copy */
+ value_tag = temp_tag; // Don't do a fast copy
break;
}
+ }
}
else if (values && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST))
{
for (i = 0; i < num_values; i ++)
+ {
if (strcmp(values[i], ipp_lang_code(values[i], code, sizeof(code))))
{
- value_tag = temp_tag; /* Don't do a fast copy */
+ value_tag = temp_tag; // Don't do a fast copy
break;
}
+ }
}
- /*
- * Create the attribute...
- */
-
+ // Create the attribute...
if ((attr = ipp_add_attr(ipp, name, group, value_tag, num_values)) == NULL)
return (NULL);
- /*
- * Initialize the attribute data...
- */
-
- for (i = num_values, value = attr->values;
- i > 0;
- i --, value ++)
+ // Initialize the attribute data...
+ for (i = num_values, value = attr->values; i > 0; i --, value ++)
{
if (language)
{
if ((int)value_tag & IPP_TAG_CUPS_CONST)
value->string.language = (char *)language;
else
- value->string.language = _cupsStrAlloc(ipp_lang_code(language, code,
- sizeof(code)));
+ value->string.language = _cupsStrAlloc(ipp_lang_code(language, code, sizeof(code)));
}
else
+ {
value->string.language = attr->values[0].string.language;
+ }
}
if (values)
}
-/*
- * 'ippContainsInteger()' - Determine whether an attribute contains the
- * specified value or is within the list of ranges.
- *
- * Returns non-zero when the attribute contains either a matching integer or
- * enum value, or the value falls within one of the rangeOfInteger values for
- * the attribute.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'ippContainsInteger()' - Determine whether an attribute contains the
+// specified value or is within the list of ranges.
+//
+// Returns non-zero when the attribute contains either a matching integer or
+// enum value, or the value falls within one of the rangeOfInteger values for
+// the attribute.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
-int /* O - 1 on a match, 0 on no match */
+int // O - 1 on a match, 0 on no match
ippContainsInteger(
- ipp_attribute_t *attr, /* I - Attribute */
- int value) /* I - Integer/enum value */
+ ipp_attribute_t *attr, // I - Attribute
+ int value) // I - Integer/enum value
{
- int i; /* Looping var */
- _ipp_value_t *avalue; /* Current attribute value */
-
+ int i; // Looping var
+ _ipp_value_t *avalue; // Current attribute value
- /*
- * Range check input...
- */
+ // Range check input...
if (!attr)
return (0);
- if (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM &&
- attr->value_tag != IPP_TAG_RANGE)
+ if (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM && attr->value_tag != IPP_TAG_RANGE)
return (0);
- /*
- * Compare...
- */
-
+ // Compare...
if (attr->value_tag == IPP_TAG_RANGE)
{
+ // Check ranges...
for (i = attr->num_values, avalue = attr->values; i > 0; i --, avalue ++)
+ {
if (value >= avalue->range.lower && value <= avalue->range.upper)
return (1);
+ }
}
else
{
+ // Check discrete values...
for (i = attr->num_values, avalue = attr->values; i > 0; i --, avalue ++)
+ {
if (value == avalue->integer)
return (1);
+ }
}
return (0);
}
-/*
- * 'ippContainsString()' - Determine whether an attribute contains the
- * specified string value.
- *
- * Returns non-zero when the attribute contains a matching charset, keyword,
- * naturalLanguage, mimeMediaType, name, text, uri, or uriScheme value.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'ippContainsString()' - Determine whether an attribute contains the
+// specified string value.
+//
+// Returns non-zero when the attribute contains a matching charset, keyword,
+// naturalLanguage, mimeMediaType, name, text, uri, or uriScheme value.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
-int /* O - 1 on a match, 0 on no match */
+int // O - 1 on a match, 0 on no match
ippContainsString(
- ipp_attribute_t *attr, /* I - Attribute */
- const char *value) /* I - String value */
+ ipp_attribute_t *attr, // I - Attribute
+ const char *value) // I - String value
{
- int i; /* Looping var */
- _ipp_value_t *avalue; /* Current attribute value */
+ int i; // Looping var
+ _ipp_value_t *avalue; // Current attribute value
DEBUG_printf("ippContainsString(attr=%p, value=\"%s\")", (void *)attr, value);
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!attr || !value)
{
DEBUG_puts("1ippContainsString: Returning 0 (bad input)");
return (0);
}
- /*
- * Compare...
- */
-
+ // Compare...
DEBUG_printf("1ippContainsString: attr %s, %s with %d values.", attr->name, ippTagString(attr->value_tag), attr->num_values);
switch (attr->value_tag & IPP_TAG_CUPS_MASK)
case IPP_TAG_LANGUAGE :
case IPP_TAG_URI :
case IPP_TAG_URISCHEME :
- for (i = attr->num_values, avalue = attr->values;
- i > 0;
- i --, avalue ++)
+ for (i = attr->num_values, avalue = attr->values; i > 0; i --, avalue ++)
{
DEBUG_printf("1ippContainsString: value[%d]=\"%s\"", attr->num_values - i, avalue->string.text);
- if (!strcmp(value, avalue->string.text))
+ if (avalue->string.text && !strcmp(value, avalue->string.text))
{
DEBUG_puts("1ippContainsString: Returning 1 (match)");
return (1);
case IPP_TAG_NAMELANG :
case IPP_TAG_TEXT :
case IPP_TAG_TEXTLANG :
- for (i = attr->num_values, avalue = attr->values;
- i > 0;
- i --, avalue ++)
+ for (i = attr->num_values, avalue = attr->values; i > 0; i --, avalue ++)
{
DEBUG_printf("1ippContainsString: value[%d]=\"%s\"", attr->num_values - i, avalue->string.text);
- if (!_cups_strcasecmp(value, avalue->string.text))
+ if (avalue->string.text && !_cups_strcasecmp(value, avalue->string.text))
{
DEBUG_puts("1ippContainsString: Returning 1 (match)");
return (1);
}
-/*
- * 'ippCopyAttribute()' - Copy an attribute.
- *
- * The specified attribute, @code attr@, is copied to the destination IPP message.
- * When @code quickcopy@ is non-zero, a "shallow" reference copy of the attribute is
- * created - this should only be done as long as the original source IPP message will
- * not be freed for the life of the destination.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippCopyAttribute()' - Copy an attribute.
+//
+// The specified attribute, @code attr@, is copied to the destination IPP message.
+// When "quickcopy" is non-zero, a "shallow" reference copy of the attribute is
+// created - this should only be done as long as the original source IPP message will
+// not be freed for the life of the destination.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-
-ipp_attribute_t * /* O - New attribute */
+ipp_attribute_t * // O - New attribute
ippCopyAttribute(
- ipp_t *dst, /* I - Destination IPP message */
- ipp_attribute_t *srcattr, /* I - Attribute to copy */
- int quickcopy) /* I - 1 for a referenced copy, 0 for normal */
+ ipp_t *dst, // I - Destination IPP message
+ ipp_attribute_t *srcattr, // I - Attribute to copy
+ int quickcopy) // I - 1 for a referenced copy, 0 for normal
{
- int i; /* Looping var */
- ipp_tag_t srctag; /* Source value tag */
- ipp_attribute_t *dstattr; /* Destination attribute */
- _ipp_value_t *srcval, /* Source value */
- *dstval; /* Destination value */
+ int i; // Looping var
+ ipp_tag_t srctag, // Source value tag
+ dstcopy; // Copy bit for quick copies
+ ipp_attribute_t *dstattr; // Destination attribute
+ _ipp_value_t *srcval, // Source value
+ *dstval; // Destination value
DEBUG_printf("ippCopyAttribute(dst=%p, srcattr=%p, quickcopy=%d)", (void *)dst, (void *)srcattr, quickcopy);
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!dst || !srcattr)
return (NULL);
- /*
- * Copy it...
- */
-
- quickcopy = (quickcopy && (srcattr->value_tag & IPP_TAG_CUPS_CONST)) ? IPP_TAG_CUPS_CONST : 0;
- srctag = srcattr->value_tag & IPP_TAG_CUPS_MASK;
+ // Copy it...
+ dstcopy = (quickcopy && (srcattr->value_tag & IPP_TAG_CUPS_CONST)) ? IPP_TAG_CUPS_CONST : 0;
+ srctag = srcattr->value_tag & IPP_TAG_CUPS_MASK;
switch (srctag)
{
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- if ((dstattr = ippAddStrings(dst, srcattr->group_tag, (ipp_tag_t)(srctag | quickcopy), srcattr->name, srcattr->num_values, NULL, NULL)) == NULL)
+ if ((dstattr = ippAddStrings(dst, srcattr->group_tag, (ipp_tag_t)(srctag | dstcopy), srcattr->name, srcattr->num_values, NULL, NULL)) == NULL)
break;
- if (quickcopy)
+ if (dstcopy)
{
- /*
- * Can safely quick-copy these string values...
- */
-
+ // Can safely quick-copy these string values...
memcpy(dstattr->values, srcattr->values, (size_t)srcattr->num_values * sizeof(_ipp_value_t));
}
else
{
- /*
- * Otherwise do a normal reference counted copy...
- */
-
+ // Otherwise do a normal reference counted copy...
for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
dstval->string.text = _cupsStrAlloc(srcval->string.text);
}
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
- if ((dstattr = ippAddStrings(dst, srcattr->group_tag, (ipp_tag_t)(srctag | quickcopy), srcattr->name, srcattr->num_values, NULL, NULL)) == NULL)
+ if ((dstattr = ippAddStrings(dst, srcattr->group_tag, (ipp_tag_t)(srctag | dstcopy), srcattr->name, srcattr->num_values, NULL, NULL)) == NULL)
break;
- if (quickcopy)
+ if (dstcopy)
{
- /*
- * Can safely quick-copy these string values...
- */
-
+ // Can safely quick-copy these string values...
memcpy(dstattr->values, srcattr->values, (size_t)srcattr->num_values * sizeof(_ipp_value_t));
}
else if (srcattr->value_tag & IPP_TAG_CUPS_CONST)
{
- /*
- * Otherwise do a normal reference counted copy...
- */
-
+ // Otherwise do a normal reference counted copy...
for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
{
if (srcval == srcattr->values)
break;
case IPP_TAG_BEGIN_COLLECTION :
- if ((dstattr = ippAddCollections(dst, srcattr->group_tag, srcattr->name, srcattr->num_values, NULL)) == NULL)
- break;
-
- for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values; i > 0; i --, srcval ++, dstval ++)
+ for (i = srcattr->num_values, srcval = srcattr->values, dstattr = NULL; i > 0; i --, srcval ++)
{
- dstval->collection = srcval->collection;
- srcval->collection->use ++;
+ if (srcval->collection)
+ {
+ if (dstattr)
+ ippSetCollection(dst, &dstattr, ippGetCount(dstattr), srcval->collection);
+ else
+ dstattr = ippAddCollection(dst, srcattr->group_tag, srcattr->name, srcval->collection);
+ }
}
break;
memcpy(dstval->unknown.data, srcval->unknown.data, (size_t)dstval->unknown.length);
}
}
- break; /* anti-compiler-warning-code */
+ break; // anti-compiler-warning-code
}
return (dstattr);
}
-/*
- * 'ippCopyAttributes()' - Copy attributes from one IPP message to another.
- *
- * Zero or more attributes are copied from the source IPP message, @code src@, to the
- * destination IPP message, @code dst@. When @code quickcopy@ is non-zero, a "shallow"
- * reference copy of the attribute is created - this should only be done as long as the
- * original source IPP message will not be freed for the life of the destination.
- *
- * The @code cb@ and @code context@ parameters provide a generic way to "filter" the
- * attributes that are copied - the function must return 1 to copy the attribute or
- * 0 to skip it. The function may also choose to do a partial copy of the source attribute
- * itself.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on error */
+//
+// 'ippCopyAttributes()' - Copy attributes from one IPP message to another.
+//
+// Zero or more attributes are copied from the source IPP message "src" to the
+// destination IPP message "dst". When "quickcopy" is non-zero, a "shallow"
+// reference copy of the attribute is created - this should only be done as long
+// as the original source IPP message will not be freed for the life of the
+// destination.
+//
+// The "cb" and "context" parameters provide a generic way to "filter" the
+// attributes that are copied - the function must return 1 to copy the attribute or
+// 0 to skip it. The function may also choose to do a partial copy of the source attribute
+// itself.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on error
ippCopyAttributes(
- ipp_t *dst, /* I - Destination IPP message */
- ipp_t *src, /* I - Source IPP message */
- int quickcopy, /* I - 1 for a referenced copy, 0 for normal */
- ipp_copycb_t cb, /* I - Copy callback or @code NULL@ for none */
- void *context) /* I - Context pointer */
+ ipp_t *dst, // I - Destination IPP message
+ ipp_t *src, // I - Source IPP message
+ int quickcopy, // I - 1 for a referenced copy, 0 for normal
+ ipp_copy_cb_t cb, // I - Copy callback or `NULL` for none
+ void *context) // I - Context pointer
{
- ipp_attribute_t *srcattr; /* Source attribute */
+ ipp_attribute_t *srcattr; // Source attribute
DEBUG_printf("ippCopyAttributes(dst=%p, src=%p, quickcopy=%d, cb=%p, context=%p)", (void *)dst, (void *)src, quickcopy, (void *)cb, context);
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!dst || !src)
return (0);
- /*
- * Loop through source attributes and copy as needed...
- */
-
+ // Loop through source attributes and copy as needed...
for (srcattr = src->attrs; srcattr; srcattr = srcattr->next)
+ {
if (!cb || (*cb)(context, dst, srcattr))
if (!ippCopyAttribute(dst, srcattr, quickcopy))
return (0);
+ }
return (1);
}
-/*
- * 'ippDateToTime()' - Convert from RFC 2579 Date/Time format to time in
- * seconds.
- */
+//
+// 'ippCopyCredentialsString()' - Copy a credentials value from an IPP attribute.
+//
+// This function concatenates the 1setOf text credential values of an attribute,
+// separated by newlines. The returned string must be freed using the `free`
+// function.
+//
-time_t /* O - UNIX time value */
-ippDateToTime(const ipp_uchar_t *date) /* I - RFC 2579 date info */
+char * // O - Combined string or `NULL` on error
+ippCopyCredentialsString(
+ ipp_attribute_t *attr) // I - Attribute
{
- struct tm unixdate; /* UNIX date/time info */
- time_t t; /* Computed time */
+ char *s = NULL, // Combined string
+ *ptr; // Pointer into string
+ size_t i, // Looping var
+ slen; // Length of combined string
+
+
+ if (attr && ippGetValueTag(attr) == IPP_TAG_TEXT)
+ {
+ // Loop through string values and add up the total length...
+ for (i = 0, slen = 0; i < attr->num_values; i ++)
+ {
+ if (attr->values[i].string.text)
+ slen += strlen(attr->values[i].string.text) + 1;
+ }
+
+ if (slen > 0)
+ {
+ // Allocate memory...
+ if ((s = malloc(slen + 1)) != NULL)
+ {
+ for (i = 0, ptr = s; i < attr->num_values; i ++)
+ {
+ if (attr->values[i].string.text)
+ {
+ size_t len = strlen(attr->values[i].string.text);
+ // Length of string
+
+ memcpy(ptr, attr->values[i].string.text, len);
+ ptr += len;
+ *ptr++ = '\n';
+ }
+ }
+
+ *ptr = '\0';
+ }
+ }
+ }
+
+ return (s);
+}
+
+
+//
+// 'ippDateToTime()' - Convert from RFC 2579 Date/Time format to time in
+// seconds.
+//
+
+time_t // O - UNIX time value
+ippDateToTime(const ipp_uchar_t *date) // I - RFC 2579 date info
+{
+ struct tm unixdate; // UNIX date/time info
+ time_t t; // Computed time
if (!date)
memset(&unixdate, 0, sizeof(unixdate));
- /*
- * RFC-2579 date/time format is:
- *
- * Byte(s) Description
- * ------- -----------
- * 0-1 Year (0 to 65535)
- * 2 Month (1 to 12)
- * 3 Day (1 to 31)
- * 4 Hours (0 to 23)
- * 5 Minutes (0 to 59)
- * 6 Seconds (0 to 60, 60 = "leap second")
- * 7 Deciseconds (0 to 9)
- * 8 +/- UTC
- * 9 UTC hours (0 to 11)
- * 10 UTC minutes (0 to 59)
- */
-
+ // RFC-2579 date/time format is:
+ //
+ // Byte(s) Description
+ // ------- -----------
+ // 0-1 Year (0 to 65535)
+ // 2 Month (1 to 12)
+ // 3 Day (1 to 31)
+ // 4 Hours (0 to 23)
+ // 5 Minutes (0 to 59)
+ // 6 Seconds (0 to 60, 60 = "leap second")
+ // 7 Deciseconds (0 to 9)
+ // 8 +/- UTC
+ // 9 UTC hours (0 to 11)
+ // 10 UTC minutes (0 to 59)
unixdate.tm_year = ((date[0] << 8) | date[1]) - 1900;
unixdate.tm_mon = date[2] - 1;
unixdate.tm_mday = date[3];
}
-/*
- * 'ippDelete()' - Delete an IPP message.
- */
+//
+// 'ippDelete()' - Delete an IPP message.
+//
void
-ippDelete(ipp_t *ipp) /* I - IPP message */
+ippDelete(ipp_t *ipp) // I - IPP message
{
- ipp_attribute_t *attr, /* Current attribute */
- *next; /* Next attribute */
+ ipp_attribute_t *attr, // Current attribute
+ *next; // Next attribute
DEBUG_printf("ippDelete(ipp=%p)", (void *)ipp);
}
-/*
- * 'ippDeleteAttribute()' - Delete a single attribute in an IPP message.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ippDeleteAttribute()' - Delete a single attribute in an IPP message.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
void
ippDeleteAttribute(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t *attr) /* I - Attribute to delete */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t *attr) // I - Attribute to delete
{
- ipp_attribute_t *current, /* Current attribute */
- *prev; /* Previous attribute */
+ ipp_attribute_t *current, // Current attribute
+ *prev; // Previous attribute
DEBUG_printf("ippDeleteAttribute(ipp=%p, attr=%p(%s))", (void *)ipp, (void *)attr, attr ? attr->name : "(null)");
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!attr)
return;
DEBUG_printf("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values);
- /*
- * Find the attribute in the list...
- */
-
+ // Find the attribute in the list...
if (ipp)
{
- for (current = ipp->attrs, prev = NULL;
- current;
- prev = current, current = current->next)
+ for (current = ipp->attrs, prev = NULL; current; prev = current, current = current->next)
+ {
if (current == attr)
{
- /*
- * Found it, remove the attribute from the list...
- */
-
+ // Found it, remove the attribute from the list...
if (prev)
prev->next = current->next;
else
break;
}
+ }
if (!current)
return;
}
- /*
- * Free memory used by the attribute...
- */
-
+ // Free memory used by the attribute...
ipp_free_values(attr, 0, attr->num_values);
if (attr->name)
}
-/*
- * 'ippDeleteValues()' - Delete values in an attribute.
- *
- * The @code element@ parameter specifies the first value to delete, starting at
- * 0. It must be less than the number of values returned by @link ippGetCount@.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * Deleting all values in an attribute deletes the attribute.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ippDeleteValues()' - Delete values in an attribute.
+//
+// This function deletes one or more values in an attribute. The "element"
+// parameter specifies the first value to delete, starting at 0. It must be
+// less than the number of values returned by @link ippGetCount@.
+//
+// The "attr" parameter may be modified as a result of setting the value,
+// which will set the variable to `NULL`.
+//
+// Deleting all values in an attribute deletes the attribute.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
ippDeleteValues(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - Attribute */
- int element, /* I - Index of first value to delete (0-based) */
- int count) /* I - Number of values to delete */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - Attribute
+ int element, // I - Index of first value to delete (0-based)
+ int count) // I - Number of values to delete
{
- /*
- * Range check input...
- */
-
- if (!ipp || !attr || !*attr ||
- element < 0 || element >= (*attr)->num_values || count <= 0 ||
- (element + count) > (*attr)->num_values)
+ // Range check input...
+ if (!ipp || !attr || !*attr || element < 0 || element >= (*attr)->num_values || count <= 0 || (element + count) > (*attr)->num_values)
return (0);
- /*
- * If we are deleting all values, just delete the attribute entirely.
- */
-
+ // If we are deleting all values, just delete the attribute entirely.
if (count == (*attr)->num_values)
{
ippDeleteAttribute(ipp, *attr);
return (1);
}
- /*
- * Otherwise free the values in question and return.
- */
-
+ // Otherwise free the values in question and return.
ipp_free_values(*attr, element, count);
return (1);
}
-/*
- * 'ippFindAttribute()' - Find a named attribute in a request.
- *
- * Starting with CUPS 2.0, the attribute name can contain a hierarchical list
- * of attribute and member names separated by slashes, for example
- * "media-col/media-size".
- */
+//
+// 'ippFindAttribute()' - Find a named attribute in a request.
+//
+// This function finds the first occurrence of a named attribute in an IPP
+// message. The attribute name can contain a hierarchical list of attribute and
+// member names separated by slashes, for example "media-col/media-size".
+//
-ipp_attribute_t * /* O - Matching attribute */
-ippFindAttribute(ipp_t *ipp, /* I - IPP message */
- const char *name, /* I - Name of attribute */
- ipp_tag_t type) /* I - Type of attribute */
+ipp_attribute_t * // O - Matching attribute
+ippFindAttribute(ipp_t *ipp, // I - IPP message
+ const char *name, // I - Name of attribute
+ ipp_tag_t type) // I - Type of attribute
{
DEBUG_printf("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type));
+ // Range check input...
if (!ipp || !name)
return (NULL);
- /*
- * Reset the current pointer...
- */
-
- ipp->current = NULL;
- ipp->atend = 0;
-
- /*
- * Search for the attribute...
- */
+ // Reset the current attribute pointer...
+ ipp->find->attr = NULL;
+ ipp->find->idx = 0;
+ ipp->find->atend = false;
+ // Search for the attribute...
return (ippFindNextAttribute(ipp, name, type));
}
-/*
- * 'ippFindNextAttribute()' - Find the next named attribute in a request.
- *
- * Starting with CUPS 2.0, the attribute name can contain a hierarchical list
- * of attribute and member names separated by slashes, for example
- * "media-col/media-size".
- */
+//
+// 'ippFindNextAttribute()' - Find the next named attribute in a request.
+//
+// This function finds the next named attribute in an IPP message. The
+// attribute name can contain a hierarchical list of attribute and member names
+// separated by slashes, for example "media-col/media-size".
+//
-ipp_attribute_t * /* O - Matching attribute */
-ippFindNextAttribute(ipp_t *ipp, /* I - IPP message */
- const char *name, /* I - Name of attribute */
- ipp_tag_t type) /* I - Type of attribute */
+ipp_attribute_t * // O - Matching attribute
+ippFindNextAttribute(ipp_t *ipp, // I - IPP message
+ const char *name, // I - Name of attribute
+ ipp_tag_t type) // I - Type of attribute
{
- ipp_attribute_t *attr, /* Current attribute */
- *childattr; /* Child attribute */
- ipp_tag_t value_tag; /* Value tag */
- char parent[1024], /* Parent attribute name */
- *child = NULL; /* Child attribute name */
+ ipp_attribute_t *attr, // Current attribute
+ *childattr; // Child attribute
+ ipp_tag_t value_tag; // Value tag
+ char parent[1024], // Parent attribute name
+ *child = NULL; // Child attribute name
DEBUG_printf("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type));
+ // Range check input...
if (!ipp || !name)
return (NULL);
- DEBUG_printf("3ippFindNextAttribute: atend=%d", ipp->atend);
+ DEBUG_printf("3ippFindNextAttribute: atend=%s", ipp->find->atend ? "true" : "false");
- if (ipp->atend)
+ if (ipp->find->atend)
return (NULL);
if (strchr(name, '/'))
{
- /*
- * Search for child attribute...
- */
-
+ // Search for child attribute...
cupsCopyString(parent, name, sizeof(parent));
if ((child = strchr(parent, '/')) == NULL)
{
*child++ = '\0';
- if (ipp->current && ipp->current->name && ipp->current->value_tag == IPP_TAG_BEGIN_COLLECTION && !strcmp(parent, ipp->current->name))
+ if (ipp->find->attr && ipp->find->attr->name && ipp->find->attr->value_tag == IPP_TAG_BEGIN_COLLECTION && !strcmp(parent, ipp->find->attr->name))
{
- while (ipp->curindex < ipp->current->num_values)
+ while (ipp->find->idx < ipp->find->attr->num_values)
{
- if ((childattr = ippFindNextAttribute(ipp->current->values[ipp->curindex].collection, child, type)) != NULL)
+ if ((childattr = ippFindNextAttribute(ipp->find->attr->values[ipp->find->idx].collection, child, type)) != NULL)
return (childattr);
- ipp->curindex ++;
- if (ipp->curindex < ipp->current->num_values && ipp->current->values[ipp->curindex].collection)
- ipp->current->values[ipp->curindex].collection->current = NULL;
+ ipp->find->idx ++;
+ if (ipp->find->idx < ipp->find->attr->num_values && ipp->find->attr->values[ipp->find->idx].collection)
+ ipp->find->attr->values[ipp->find->idx].collection->find->attr = NULL;
}
- ipp->prev = ipp->current;
- ipp->current = ipp->current->next;
- ipp->curindex = 0;
+ ipp->find->attr = ipp->find->attr->next;
+ ipp->find->idx = 0;
- if (!ipp->current)
+ if (!ipp->find->attr)
{
- ipp->atend = 1;
+ ipp->find->atend = true;
return (NULL);
}
}
- if (!ipp->current)
+ if (!ipp->find->attr)
{
- ipp->prev = NULL;
- ipp->current = ipp->attrs;
- ipp->curindex = 0;
+ ipp->find->attr = ipp->attrs;
+ ipp->find->idx = 0;
}
name = parent;
- attr = ipp->current;
+ attr = ipp->find->attr;
}
- else if (ipp->current)
+ else if (ipp->find->attr)
{
- ipp->prev = ipp->current;
- attr = ipp->current->next;
+ attr = ipp->find->attr->next;
}
else
{
- ipp->prev = NULL;
- attr = ipp->attrs;
+ attr = ipp->attrs;
}
for (; attr != NULL; ipp->prev = attr, attr = attr->next)
value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
- if (attr->name != NULL && _cups_strcasecmp(attr->name, name) == 0 &&
- (value_tag == type || type == IPP_TAG_ZERO || name == parent ||
- (value_tag == IPP_TAG_TEXTLANG && type == IPP_TAG_TEXT) ||
- (value_tag == IPP_TAG_NAMELANG && type == IPP_TAG_NAME)))
+ if (attr->name != NULL && _cups_strcasecmp(attr->name, name) == 0 && (value_tag == type || type == IPP_TAG_ZERO || name == parent || (value_tag == IPP_TAG_TEXTLANG && type == IPP_TAG_TEXT) || (value_tag == IPP_TAG_NAMELANG && type == IPP_TAG_NAME)))
{
- ipp->current = attr;
+ ipp->find->attr = attr;
if (name == parent && attr->value_tag == IPP_TAG_BEGIN_COLLECTION)
{
- int i; /* Looping var */
+ int i; // Looping var
for (i = 0; i < attr->num_values; i ++)
{
if ((childattr = ippFindAttribute(attr->values[i].collection, child, type)) != NULL)
{
- attr->values[0].collection->curindex = i;
+ attr->values[0].collection->find->idx = i;
return (childattr);
}
}
}
else
+ {
return (attr);
+ }
}
}
- ipp->current = NULL;
- ipp->prev = NULL;
- ipp->atend = 1;
+ // If we get this far, we didn't find it...
+ ipp->find->attr = NULL;
+ ipp->find->atend = true;
return (NULL);
}
-/*
- * 'ippFirstAttribute()' - Return the first attribute in the message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippFirstAttribute()' - Return the first attribute in the message.
+//
+// @deprecated@ @exclude all@
+//
-ipp_attribute_t * /* O - First attribute or @code NULL@ if none */
-ippFirstAttribute(ipp_t *ipp) /* I - IPP message */
+ipp_attribute_t * // O - First attribute or `NULL` if none
+ippFirstAttribute(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
-
- if (!ipp)
- return (NULL);
-
- /*
- * Return the first attribute...
- */
-
- return (ipp->current = ipp->attrs);
+ return (ippGetFirstAttribute(ipp));
}
-/*
- * 'ippGetBoolean()' - Get a boolean value for an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetBoolean()' - Get a boolean value for an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Boolean value or 0 on error */
-ippGetBoolean(ipp_attribute_t *attr, /* I - IPP attribute */
- int element) /* I - Value number (0-based) */
+int // O - Boolean value or 0 on error
+ippGetBoolean(ipp_attribute_t *attr, // I - IPP attribute
+ int element) // I - Value number (0-based)
{
- /*
- * Range check input...
- */
-
- if (!attr || attr->value_tag != IPP_TAG_BOOLEAN ||
- element < 0 || element >= attr->num_values)
+ // Range check input...
+ if (!attr || attr->value_tag != IPP_TAG_BOOLEAN || element < 0 || element >= attr->num_values)
return (0);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (attr->values[element].boolean);
}
-/*
- * 'ippGetCollection()' - Get a collection value for an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetCollection()' - Get a collection value for an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-ipp_t * /* O - Collection value or @code NULL@ on error */
+ipp_t * // O - Collection value or `NULL` on error
ippGetCollection(
- ipp_attribute_t *attr, /* I - IPP attribute */
- int element) /* I - Value number (0-based) */
+ ipp_attribute_t *attr, // I - IPP attribute
+ int element) // I - Value number (0-based)
{
- /*
- * Range check input...
- */
-
- if (!attr || attr->value_tag != IPP_TAG_BEGIN_COLLECTION ||
- element < 0 || element >= attr->num_values)
+ // Range check input...
+ if (!attr || attr->value_tag != IPP_TAG_BEGIN_COLLECTION || element < 0 || element >= attr->num_values)
return (NULL);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (attr->values[element].collection);
}
-/*
- * 'ippGetCount()' - Get the number of values in an attribute.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetCount()' - Get the number of values in an attribute.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Number of values or 0 on error */
-ippGetCount(ipp_attribute_t *attr) /* I - IPP attribute */
+int // O - Number of values or 0 on error
+ippGetCount(ipp_attribute_t *attr) // I - IPP attribute
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!attr)
return (0);
- /*
- * Return the number of values...
- */
-
+ // Return the number of values...
return (attr->num_values);
}
-/*
- * 'ippGetDate()' - Get a dateTime value for an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetDate()' - Get a dateTime value for an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-const ipp_uchar_t * /* O - dateTime value or @code NULL@ */
-ippGetDate(ipp_attribute_t *attr, /* I - IPP attribute */
- int element) /* I - Value number (0-based) */
+const ipp_uchar_t * // O - dateTime value or `NULL`
+ippGetDate(ipp_attribute_t *attr, // I - IPP attribute
+ int element) // I - Value number (0-based)
{
- /*
- * Range check input...
- */
-
- if (!attr || attr->value_tag != IPP_TAG_DATE ||
- element < 0 || element >= attr->num_values)
+ // Range check input...
+ if (!attr || attr->value_tag != IPP_TAG_DATE || element < 0 || element >= attr->num_values)
return (NULL);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (attr->values[element].date);
}
-/*
- * 'ippGetGroupTag()' - Get the group associated with an attribute.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetFirstAttribute()' - Return the first attribute in the message.
+//
+// @since CUPS 2.5@
+//
-ipp_tag_t /* O - Group tag or @code IPP_TAG_ZERO@ on error */
-ippGetGroupTag(ipp_attribute_t *attr) /* I - IPP attribute */
+ipp_attribute_t * // O - First attribute or `NULL` if none
+ippGetFirstAttribute(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
+ // Range check input...
+ if (!ipp)
+ return (NULL);
+
+ if (!ipp->find)
+ ipp->find = ipp->fstack;
+
+ ipp->find->attr = ipp->attrs;
+ ipp->find->idx = 0;
+ ipp->find->atend = ipp->find->attr == NULL;
+
+ // Return the first attribute...
+ return (ipp->find->attr);
+}
+
+
+//
+// 'ippGetGroupTag()' - Get the group associated with an attribute.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+ipp_tag_t // O - Group tag or `IPP_TAG_ZERO` on error
+ippGetGroupTag(ipp_attribute_t *attr) // I - IPP attribute
+{
+ // Range check input...
if (!attr)
return (IPP_TAG_ZERO);
- /*
- * Return the group...
- */
-
+ // Return the group...
return (attr->group_tag);
}
-/*
- * 'ippGetInteger()' - Get the integer/enum value for an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetInteger()' - Get the integer/enum value for an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Value or 0 on error */
-ippGetInteger(ipp_attribute_t *attr, /* I - IPP attribute */
- int element) /* I - Value number (0-based) */
+int // O - Value or 0 on error
+ippGetInteger(ipp_attribute_t *attr, // I - IPP attribute
+ int element) // I - Value number (0-based)
{
- /*
- * Range check input...
- */
-
- if (!attr || (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM) ||
- element < 0 || element >= attr->num_values)
+ // Range check input...
+ if (!attr || (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM) || element < 0 || element >= attr->num_values)
return (0);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (attr->values[element].integer);
}
-/*
- * 'ippGetName()' - Get the attribute name.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetLength()' - Compute the length of an IPP message.
+//
-const char * /* O - Attribute name or @code NULL@ for separators */
-ippGetName(ipp_attribute_t *attr) /* I - IPP attribute */
+size_t // O - Size of IPP message
+ippGetLength(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
+ return (ipp_length(ipp, 0));
+}
+
+//
+// 'ippGetName()' - Get the attribute name.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+const char * // O - Attribute name or `NULL` for separators
+ippGetName(ipp_attribute_t *attr) // I - IPP attribute
+{
+ // Range check input...
if (!attr)
return (NULL);
- /*
- * Return the name...
- */
-
+ // Return the name...
return (attr->name);
}
-/*
- * 'ippGetOctetString()' - Get an octetString value from an IPP attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'ippGetNextAttribute()' - Return the next attribute in the message.
+//
+// @since CUPS 2.5@
+//
-void * /* O - Pointer to octetString data */
-ippGetOctetString(
- ipp_attribute_t *attr, /* I - IPP attribute */
- int element, /* I - Value number (0-based) */
- int *datalen) /* O - Length of octetString data */
+ipp_attribute_t * // O - Next attribute or `NULL` if none
+ippGetNextAttribute(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
+ // Range check input...
+ if (!ipp || !ipp->find || !ipp->find->attr)
+ return (NULL);
+
+ ipp->find->attr = ipp->find->attr->next;
+ ipp->find->atend = ipp->find->attr == NULL;
+
+ // Return the next attribute...
+ return (ipp->find->attr);
+}
+
- if (!attr || attr->value_tag != IPP_TAG_STRING ||
- element < 0 || element >= attr->num_values)
+//
+// 'ippGetOctetString()' - Get an octetString value from an IPP attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+void * // O - Pointer to octetString data
+ippGetOctetString(
+ ipp_attribute_t *attr, // I - IPP attribute
+ int element, // I - Value number (0-based)
+ int *datalen) // O - Length of octetString data
+{
+ // Range check input...
+ if (!attr || attr->value_tag != IPP_TAG_STRING || element < 0 || element >= attr->num_values)
{
if (datalen)
*datalen = 0;
return (NULL);
}
- /*
- * Return the values...
- */
-
+ // Return the values...
if (datalen)
*datalen = attr->values[element].unknown.length;
}
-/*
- * 'ippGetOperation()' - Get the operation ID in an IPP message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetOperation()' - Get the operation ID in an IPP message.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-ipp_op_t /* O - Operation ID or 0 on error */
-ippGetOperation(ipp_t *ipp) /* I - IPP request message */
+ipp_op_t // O - Operation ID or 0 on error
+ippGetOperation(ipp_t *ipp) // I - IPP request message
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return ((ipp_op_t)0);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (ipp->request.op.operation_id);
}
-/*
- * 'ippGetRange()' - Get a rangeOfInteger value from an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetRange()' - Get a rangeOfInteger value from an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Lower value of range or 0 */
-ippGetRange(ipp_attribute_t *attr, /* I - IPP attribute */
- int element, /* I - Value number (0-based) */
- int *uppervalue)/* O - Upper value of range */
+int // O - Lower value of range or 0
+ippGetRange(ipp_attribute_t *attr, // I - IPP attribute
+ int element, // I - Value number (0-based)
+ int *uppervalue)// O - Upper value of range
{
- /*
- * Range check input...
- */
-
- if (!attr || attr->value_tag != IPP_TAG_RANGE ||
- element < 0 || element >= attr->num_values)
+ // Range check input...
+ if (!attr || attr->value_tag != IPP_TAG_RANGE || element < 0 || element >= attr->num_values)
{
if (uppervalue)
*uppervalue = 0;
return (0);
}
- /*
- * Return the values...
- */
-
+ // Return the values...
if (uppervalue)
*uppervalue = attr->values[element].range.upper;
}
-/*
- * 'ippGetRequestId()' - Get the request ID from an IPP message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetRequestId()' - Get the request ID from an IPP message.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Request ID or 0 on error */
-ippGetRequestId(ipp_t *ipp) /* I - IPP message */
+int // O - Request ID or 0 on error
+ippGetRequestId(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (0);
- /*
- * Return the request ID...
- */
-
+ // Return the request ID...
return (ipp->request.any.request_id);
}
-/*
- * 'ippGetResolution()' - Get a resolution value for an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetResolution()' - Get a resolution value for an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Horizontal/cross feed resolution or 0 */
+int // O - Horizontal/cross feed resolution or 0
ippGetResolution(
- ipp_attribute_t *attr, /* I - IPP attribute */
- int element, /* I - Value number (0-based) */
- int *yres, /* O - Vertical/feed resolution */
- ipp_res_t *units) /* O - Units for resolution */
+ ipp_attribute_t *attr, // I - IPP attribute
+ int element, // I - Value number (0-based)
+ int *yres, // O - Vertical/feed resolution
+ ipp_res_t *units) // O - Units for resolution
{
- /*
- * Range check input...
- */
-
- if (!attr || attr->value_tag != IPP_TAG_RESOLUTION ||
- element < 0 || element >= attr->num_values)
+ // Range check input...
+ if (!attr || attr->value_tag != IPP_TAG_RESOLUTION || element < 0 || element >= attr->num_values)
{
if (yres)
*yres = 0;
return (0);
}
- /*
- * Return the value...
- */
-
+ // Return the value...
if (yres)
*yres = attr->values[element].resolution.yres;
}
-/*
- * 'ippGetState()' - Get the IPP message state.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetState()' - Get the IPP message state.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-ipp_state_t /* O - IPP message state value */
-ippGetState(ipp_t *ipp) /* I - IPP message */
+ipp_state_t // O - IPP message state value
+ippGetState(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (IPP_STATE_IDLE);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (ipp->state);
}
-/*
- * 'ippGetStatusCode()' - Get the status code from an IPP response or event message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetStatusCode()' - Get the status code from an IPP response or event message.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-ipp_status_t /* O - Status code in IPP message */
-ippGetStatusCode(ipp_t *ipp) /* I - IPP response or event message */
+ipp_status_t // O - Status code in IPP message
+ippGetStatusCode(ipp_t *ipp) // I - IPP response or event message
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (IPP_STATUS_ERROR_INTERNAL);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (ipp->request.status.status_code);
}
-/*
- * 'ippGetString()' - Get the string and optionally the language code for an attribute.
- *
- * The @code element@ parameter specifies which value to get from 0 to
- * @code ippGetCount(attr)@ - 1.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetString()' - Get the string and optionally the language code for an attribute.
+//
+// The "element" parameter specifies which value to get from 0 to
+// @code ippGetCount(attr)@ - 1.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
const char *
-ippGetString(ipp_attribute_t *attr, /* I - IPP attribute */
- int element, /* I - Value number (0-based) */
- const char **language)/* O - Language code (@code NULL@ for don't care) */
+ippGetString(ipp_attribute_t *attr, // I - IPP attribute
+ int element, // I - Value number (0-based)
+ const char **language)// O - Language code (`NULL` for don't care)
{
- ipp_tag_t tag; /* Value tag */
-
+ ipp_tag_t tag; // Value tag
- /*
- * Range check input...
- */
+ // Range check input...
tag = ippGetValueTag(attr);
if (!attr || element < 0 || element >= attr->num_values || (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG && (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE)))
return (NULL);
- /*
- * Return the value...
- */
-
+ // Return the value...
if (language)
*language = attr->values[element].string.language;
}
-/*
- * 'ippGetValueTag()' - Get the value tag for an attribute.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetValueTag()' - Get the value tag for an attribute.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-ipp_tag_t /* O - Value tag or @code IPP_TAG_ZERO@ on error */
-ippGetValueTag(ipp_attribute_t *attr) /* I - IPP attribute */
+ipp_tag_t // O - Value tag or `IPP_TAG_ZERO` on error
+ippGetValueTag(ipp_attribute_t *attr) // I - IPP attribute
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!attr)
return (IPP_TAG_ZERO);
- /*
- * Return the value...
- */
-
+ // Return the value...
return (attr->value_tag & IPP_TAG_CUPS_MASK);
}
-/*
- * 'ippGetVersion()' - Get the major and minor version number from an IPP message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippGetVersion()' - Get the major and minor version number from an IPP message.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - Major version number or 0 on error */
-ippGetVersion(ipp_t *ipp, /* I - IPP message */
- int *minor) /* O - Minor version number or @code NULL@ for don't care */
+int // O - Major version number or 0 on error
+ippGetVersion(ipp_t *ipp, // I - IPP message
+ int *minor) // O - Minor version number or `NULL` for don't care
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
{
if (minor)
return (0);
}
- /*
- * Return the value...
- */
-
+ // Return the value...
if (minor)
*minor = ipp->request.any.version[1];
}
-/*
- * 'ippLength()' - Compute the length of an IPP message.
- */
+//
+// 'ippLength()' - Compute the length of an IPP message.
+//
+// @deprecated@ @exclude all@
+//
-size_t /* O - Size of IPP message */
-ippLength(ipp_t *ipp) /* I - IPP message */
+size_t // O - Size of IPP message
+ippLength(ipp_t *ipp) // I - IPP message
{
- return (ipp_length(ipp, 0));
+ return (ippGetLength(ipp));
}
-/*
- * 'ippNextAttribute()' - Return the next attribute in the message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippNextAttribute()' - Return the next attribute in the message.
+//
+// @deprecated@ @exclude all@
+//
-ipp_attribute_t * /* O - Next attribute or @code NULL@ if none */
-ippNextAttribute(ipp_t *ipp) /* I - IPP message */
+ipp_attribute_t * // O - Next attribute or `NULL` if none
+ippNextAttribute(ipp_t *ipp) // I - IPP message
{
- /*
- * Range check input...
- */
-
- if (!ipp || !ipp->current)
- return (NULL);
-
- /*
- * Return the next attribute...
- */
-
- return (ipp->current = ipp->current->next);
+ return (ippGetNextAttribute(ipp));
}
-/*
- * 'ippNew()' - Allocate a new IPP message.
- */
+//
+// 'ippNew()' - Allocate a new IPP message.
+//
-ipp_t * /* O - New IPP message */
+ipp_t * // O - New IPP message
ippNew(void)
{
- ipp_t *temp; /* New IPP message */
+ ipp_t *temp; // New IPP message
_cups_globals_t *cg = _cupsGlobals();
- /* Global data */
+ // Global data
DEBUG_puts("ippNew()");
if ((temp = (ipp_t *)calloc(1, sizeof(ipp_t))) != NULL)
{
- /*
- * Set default version - usually 2.0...
- */
-
+ // Set default version - usually 2.0...
DEBUG_printf("4debug_alloc: %p IPP message", (void *)temp);
if (cg->server_version == 0)
temp->request.any.version[0] = (ipp_uchar_t)(cg->server_version / 10);
temp->request.any.version[1] = (ipp_uchar_t)(cg->server_version % 10);
temp->use = 1;
+ temp->find = temp->fstack;
}
DEBUG_printf("1ippNew: Returning %p", (void *)temp);
}
-/*
- * 'ippNewRequest()' - Allocate a new IPP request message.
- *
- * The new request message is initialized with the "attributes-charset" and
- * "attributes-natural-language" attributes added. The
- * "attributes-natural-language" value is derived from the current locale.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ippNewRequest()' - Allocate a new IPP request message.
+//
+// The new request message is initialized with the "attributes-charset" and
+// "attributes-natural-language" attributes added. The
+// "attributes-natural-language" value is derived from the current locale.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ipp_t * /* O - IPP request message */
-ippNewRequest(ipp_op_t op) /* I - Operation code */
+ipp_t * // O - IPP request message
+ippNewRequest(ipp_op_t op) // I - Operation code
{
- ipp_t *request; /* IPP request message */
- cups_lang_t *language; /* Current language localization */
- static int request_id = 0; /* Current request ID */
+ ipp_t *request; // IPP request message
+ cups_lang_t *language; // Current language localization
+ static int request_id = 0; // Current request ID
static cups_mutex_t request_mutex = CUPS_MUTEX_INITIALIZER;
- /* Mutex for request ID */
+ // Mutex for request ID
DEBUG_printf("ippNewRequest(op=%02x(%s))", op, ippOpString(op));
- /*
- * Create a new IPP message...
- */
-
+ // Create a new IPP message...
if ((request = ippNew()) == NULL)
return (NULL);
- /*
- * Set the operation and request ID...
- */
-
+ // Set the operation and request ID...
cupsMutexLock(&request_mutex);
request->request.op.operation_id = op;
cupsMutexUnlock(&request_mutex);
- /*
- * Use UTF-8 as the character set...
- */
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
- "attributes-charset", NULL, "utf-8");
-
- /*
- * Get the language from the current locale...
- */
+ // Use UTF-8 as the character set...
+ ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_CHARSET), "attributes-charset", NULL, "utf-8");
+ // Get the language from the current locale...
language = cupsLangDefault();
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
- "attributes-natural-language", NULL, language->language);
-
- /*
- * Return the new request...
- */
+ ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_LANGUAGE), "attributes-natural-language", NULL, language->language);
+ // Return the new request...
return (request);
}
-/*
- * 'ippNewResponse()' - Allocate a new IPP response message.
- *
- * The new response message is initialized with the same "version-number",
- * "request-id", "attributes-charset", and "attributes-natural-language" as the
- * provided request message. If the "attributes-charset" or
- * "attributes-natural-language" attributes are missing from the request,
- * 'utf-8' and a value derived from the current locale are substituted,
- * respectively.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-ipp_t * /* O - IPP response message */
-ippNewResponse(ipp_t *request) /* I - IPP request message */
+//
+// 'ippNewResponse()' - Allocate a new IPP response message.
+//
+// The new response message is initialized with the same "version-number",
+// "request-id", "attributes-charset", and "attributes-natural-language" as the
+// provided request message. If the "attributes-charset" or
+// "attributes-natural-language" attributes are missing from the request,
+// 'utf-8' and a value derived from the current locale are substituted,
+// respectively.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+ipp_t * // O - IPP response message
+ippNewResponse(ipp_t *request) // I - IPP request message
{
- ipp_t *response; /* IPP response message */
- ipp_attribute_t *attr; /* Current attribute */
-
+ ipp_t *response; // IPP response message
+ ipp_attribute_t *attr; // Current attribute
- /*
- * Range check input...
- */
+ // Range check input...
if (!request)
return (NULL);
- /*
- * Create a new IPP message...
- */
-
+ // Create a new IPP message...
if ((response = ippNew()) == NULL)
return (NULL);
- /*
- * Copy the request values over to the response...
- */
-
+ // Copy the request values over to the response...
response->request.status.version[0] = request->request.op.version[0];
response->request.status.version[1] = request->request.op.version[1];
response->request.status.request_id = request->request.op.request_id;
- /*
- * The first attribute MUST be attributes-charset...
- */
-
+ // The first attribute MUST be attributes-charset...
attr = request->attrs;
- if (attr && attr->name && !strcmp(attr->name, "attributes-charset") &&
- attr->group_tag == IPP_TAG_OPERATION &&
- attr->value_tag == IPP_TAG_CHARSET &&
- attr->num_values == 1)
+ if (attr && attr->name && !strcmp(attr->name, "attributes-charset") && attr->group_tag == IPP_TAG_OPERATION && attr->value_tag == IPP_TAG_CHARSET && attr->num_values == 1)
{
- /*
- * Copy charset from request...
- */
-
- ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
- "attributes-charset", NULL, attr->values[0].string.text);
+ // Copy charset from request...
+ ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, attr->values[0].string.text);
}
else
{
- /*
- * Use "utf-8" as the default...
- */
-
- ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
- "attributes-charset", NULL, "utf-8");
+ // Use "utf-8" as the default...
+ ippAddString(response, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_CHARSET), "attributes-charset", NULL, "utf-8");
}
- /*
- * Then attributes-natural-language...
- */
-
+ // Then attributes-natural-language...
if (attr)
attr = attr->next;
- if (attr && attr->name &&
- !strcmp(attr->name, "attributes-natural-language") &&
- attr->group_tag == IPP_TAG_OPERATION &&
- attr->value_tag == IPP_TAG_LANGUAGE &&
- attr->num_values == 1)
+ if (attr && attr->name && !strcmp(attr->name, "attributes-natural-language") && attr->group_tag == IPP_TAG_OPERATION && attr->value_tag == IPP_TAG_LANGUAGE && attr->num_values == 1)
{
- /*
- * Copy language from request...
- */
-
- ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
- "attributes-natural-language", NULL,
- attr->values[0].string.text);
+ // Copy language from request...
+ ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, attr->values[0].string.text);
}
else
{
- /*
- * Use the language from the current locale...
- */
-
+ // Use the language from the current locale...
cups_lang_t *language = cupsLangDefault();
- /* Current locale */
+ // Current locale
- ippAddString(response, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
- "attributes-natural-language", NULL, language->language);
+ ippAddString(response, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_LANGUAGE), "attributes-natural-language", NULL, language->language);
}
return (response);
}
-/*
- * 'ippRead()' - Read data for an IPP message from a HTTP connection.
- */
+//
+// 'ippRead()' - Read data for an IPP message from a HTTP connection.
+//
-ipp_state_t /* O - Current state */
-ippRead(http_t *http, /* I - HTTP connection */
- ipp_t *ipp) /* I - IPP data */
+ipp_state_t // O - Current state
+ippRead(http_t *http, // I - HTTP connection
+ ipp_t *ipp) // I - IPP data
{
DEBUG_printf("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT, (void *)http, (void *)ipp, CUPS_LLCAST (http ? http->data_remaining : -1));
DEBUG_printf("2ippRead: http->state=%d, http->used=%d", http->state, http->used);
- return (ippReadIO(http, (ipp_iocb_t)ipp_read_http, http->blocking, NULL,
- ipp));
+ return (ippReadIO(http, (ipp_io_cb_t)ipp_read_http, http->blocking, NULL, ipp));
}
-/*
- * 'ippReadFile()' - Read data for an IPP message from a file.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ippReadFile()' - Read data for an IPP message from a file.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
-ipp_state_t /* O - Current state */
-ippReadFile(int fd, /* I - HTTP data */
- ipp_t *ipp) /* I - IPP data */
+ipp_state_t // O - Current state
+ippReadFile(int fd, // I - HTTP data
+ ipp_t *ipp) // I - IPP data
{
DEBUG_printf("ippReadFile(fd=%d, ipp=%p)", fd, (void *)ipp);
- return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
+ return (ippReadIO(&fd, (ipp_io_cb_t)ipp_read_file, 1, NULL, ipp));
}
-/*
- * 'ippReadIO()' - Read data for an IPP message.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ippReadIO()' - Read data for an IPP message.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ipp_state_t /* O - Current state */
-ippReadIO(void *src, /* I - Data source */
- ipp_iocb_t cb, /* I - Read callback function */
- int blocking, /* I - Use blocking IO? */
- ipp_t *parent, /* I - Parent request, if any */
- ipp_t *ipp) /* I - IPP data */
+ipp_state_t // O - Current state
+ippReadIO(void *src, // I - Data source
+ ipp_io_cb_t cb, // I - Read callback function
+ int blocking, // I - Use blocking IO?
+ ipp_t *parent, // I - Parent request, if any
+ ipp_t *ipp) // I - IPP data
{
- int n; /* Length of data */
- unsigned char *buffer, /* Data buffer */
+ int n; // Length of data
+ unsigned char *buffer, // Data buffer
string[IPP_MAX_TEXT],
- /* Small string buffer */
- *bufptr, /* Pointer into buffer */
- *bufend; /* End of buffer */
- ipp_attribute_t *attr = NULL; /* Current attribute */
- ipp_tag_t tag; /* Current tag */
- ipp_tag_t value_tag; /* Current value tag */
- _ipp_value_t *value; /* Current value */
+ // Small string buffer
+ *bufptr, // Pointer into buffer
+ *bufend; // End of buffer
+ ipp_attribute_t *attr = NULL; // Current attribute
+ ipp_tag_t tag; // Current tag
+ ipp_tag_t value_tag; // Current value tag
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)src, (void *)cb, blocking, (void *)parent, (void *)ipp);
switch (ipp->state)
{
case IPP_STATE_IDLE :
- ipp->state ++; /* Avoid common problem... */
+ ipp->state ++; // Avoid common problem...
case IPP_STATE_HEADER :
if (parent == NULL)
{
- /*
- * Get the request header...
- */
-
+ // Get the request header...
if ((*cb)(src, buffer, 8) < 8)
{
DEBUG_puts("1ippReadIO: Unable to read header.");
goto rollback;
}
- /*
- * Then copy the request header over...
- */
-
+ // Then copy the request header over...
ipp->request.any.version[0] = buffer[0];
ipp->request.any.version[1] = buffer[1];
- ipp->request.any.op_status = (buffer[2] << 8) | buffer[3];
- ipp->request.any.request_id = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
+ ipp->request.any.op_status = (buffer[2] << 8) | buffer[3];
+ ipp->request.any.request_id = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
DEBUG_printf("2ippReadIO: version=%d.%d", buffer[0], buffer[1]);
DEBUG_printf("2ippReadIO: op_status=%04x", ipp->request.any.op_status);
ipp->curtag = IPP_TAG_ZERO;
ipp->prev = ipp->last;
- /*
- * If blocking is disabled, stop here...
- */
-
+ // If blocking is disabled, stop here...
if (!blocking)
break;
DEBUG_printf("2ippReadIO: ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev);
- /*
- * Read this attribute...
- */
-
+ // Read this attribute...
tag = (ipp_tag_t)buffer[0];
if (tag == IPP_TAG_EXTENSION)
{
- /*
- * Read 32-bit "extension" tag...
- */
-
+ // Read 32-bit "extension" tag...
if ((*cb)(src, buffer, 4) < 4)
{
DEBUG_puts("1ippReadIO: Callback returned EOF/error");
if (tag & IPP_TAG_CUPS_CONST)
{
- /*
- * Fail if the high bit is set in the tag...
- */
-
+ // Fail if the high bit is set in the tag...
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP extension tag larger than 0x7FFFFFFF."), 1);
DEBUG_printf("1ippReadIO: bad tag 0x%x.", tag);
goto rollback;
if (tag == IPP_TAG_END)
{
- /*
- * No more attributes left...
- */
-
+ // No more attributes left...
DEBUG_puts("2ippReadIO: IPP_TAG_END.");
ipp->state = IPP_STATE_DATA;
}
else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
{
- /*
- * Group tag... Set the current group and continue...
- */
-
+ // Group tag... Set the current group and continue...
if (parent)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid group tag."), 1);
goto rollback;
}
else if (ipp->curtag == tag)
+ {
ipp->prev = ippAddSeparator(ipp);
+ }
else if (ipp->current)
+ {
ipp->prev = ipp->current;
+ }
ipp->curtag = tag;
ipp->current = NULL;
DEBUG_printf("2ippReadIO: value tag=%x(%s)", tag, ippTagString(tag));
- /*
- * Get the name...
- */
-
+ // Get the name...
if ((*cb)(src, buffer, 2) < 2)
{
DEBUG_puts("1ippReadIO: unable to read name length.");
}
else if (n == 0 && tag != IPP_TAG_MEMBERNAME && tag != IPP_TAG_END_COLLECTION)
{
- /*
- * More values for current attribute...
- */
-
+ // More values for current attribute...
if (ipp->current == NULL)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP attribute has no name."), 1);
attr = ipp->current;
value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
- /*
- * Make sure we aren't adding a new value of a different
- * type...
- */
-
+ // Make sure we aren't adding a new value of a different type...
if (value_tag == IPP_TAG_ZERO)
{
- /*
- * Setting the value of a collection member...
- */
-
+ // Setting the value of a collection member...
attr->value_tag = tag;
}
- else if (value_tag == IPP_TAG_TEXTLANG ||
- value_tag == IPP_TAG_NAMELANG ||
- (value_tag >= IPP_TAG_TEXT &&
- value_tag <= IPP_TAG_MIMETYPE))
+ else if (value_tag == IPP_TAG_TEXTLANG || value_tag == IPP_TAG_NAMELANG || (value_tag >= IPP_TAG_TEXT && value_tag <= IPP_TAG_MIMETYPE))
{
- /*
- * String values can sometimes come across in different
- * forms; accept sets of differing values...
- */
-
- if (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG &&
- (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) &&
- tag != IPP_TAG_NOVALUE)
+ // String values can sometimes come across in different forms; accept sets of differing values...
+ if (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG && (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) && tag != IPP_TAG_NOVALUE)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP 1setOf attribute with incompatible value "
- "tags."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP 1setOf attribute with incompatible value tags."), 1);
DEBUG_printf("1ippReadIO: 1setOf value tag %x(%s) != %x(%s)", value_tag, ippTagString(value_tag), tag, ippTagString(tag));
goto rollback;
}
ippSetValueTag(ipp, &attr, tag);
}
}
- else if (value_tag == IPP_TAG_INTEGER ||
- value_tag == IPP_TAG_RANGE)
+ else if (value_tag == IPP_TAG_INTEGER || value_tag == IPP_TAG_RANGE)
{
- /*
- * Integer and rangeOfInteger values can sometimes be mixed; accept
- * sets of differing values...
- */
-
+ // Integer and rangeOfInteger values can sometimes be mixed; accept sets of differing values...
if (tag != IPP_TAG_INTEGER && tag != IPP_TAG_RANGE)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP 1setOf attribute with incompatible value "
- "tags."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP 1setOf attribute with incompatible value tags."), 1);
DEBUG_printf("1ippReadIO: 1setOf value tag %x(%s) != %x(%s)", value_tag, ippTagString(value_tag), tag, ippTagString(tag));
goto rollback;
}
if (value_tag == IPP_TAG_INTEGER && tag == IPP_TAG_RANGE)
{
- /*
- * Convert integer values to rangeOfInteger values...
- */
-
+ // Convert integer values to rangeOfInteger values...
DEBUG_printf("1ippReadIO: Converting %s attribute to rangeOfInteger.", attr->name);
ippSetValueTag(ipp, &attr, IPP_TAG_RANGE);
}
}
else if (value_tag != tag)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP 1setOf attribute with incompatible value "
- "tags."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP 1setOf attribute with incompatible value tags."), 1);
DEBUG_printf("1ippReadIO: value tag %x(%s) != %x(%s)", value_tag, ippTagString(value_tag), tag, ippTagString(tag));
goto rollback;
}
- /*
- * Finally, reallocate the attribute array as needed...
- */
-
+ // Finally, reallocate the attribute array as needed...
if ((value = ipp_set_value(ipp, &attr, attr->num_values)) == NULL)
goto rollback;
}
else if (tag == IPP_TAG_MEMBERNAME)
{
- /*
- * Name must be length 0!
- */
-
+ // Name must be length 0!
if (n)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP member name is not empty."), 1);
}
else if (tag != IPP_TAG_END_COLLECTION)
{
- /*
- * New attribute; read the name and add it...
- */
-
+ // New attribute; read the name and add it...
if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: unable to read name.");
if (ipp->current)
ipp->prev = ipp->current;
- if ((attr = ipp->current = ipp_add_attr(ipp, (char *)buffer, ipp->curtag, tag,
- 1)) == NULL)
+ if ((attr = ipp->current = ipp_add_attr(ipp, (char *)buffer, ipp->curtag, tag, 1)) == NULL)
{
_cupsSetHTTPError(HTTP_STATUS_ERROR);
DEBUG_puts("1ippReadIO: unable to allocate attribute.");
if (n >= IPP_BUF_SIZE)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP value larger than 32767 bytes."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP value larger than 32767 bytes."), 1);
DEBUG_printf("1ippReadIO: bad value length %d.", n);
goto rollback;
}
if (n != 4)
{
if (tag == IPP_TAG_INTEGER)
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP integer value not 4 bytes."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP integer value not 4 bytes."), 1);
else
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP enum value not 4 bytes."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP enum value not 4 bytes."), 1);
DEBUG_printf("1ippReadIO: bad integer value length %d.", n);
goto rollback;
}
case IPP_TAG_BOOLEAN :
if (n != 1)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP boolean value not 1 byte."),
- 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP boolean value not 1 byte."), 1);
DEBUG_printf("1ippReadIO: bad boolean value length %d.", n);
goto rollback;
}
case IPP_TAG_NOTSETTABLE :
case IPP_TAG_DELETEATTR :
case IPP_TAG_ADMINDEFINE :
- /*
- * These value types are not supposed to have values, however
- * some vendors (Brother) do not implement IPP correctly and so
- * we need to map non-empty values to text...
- */
-
+ // These value types are not supposed to have values, however
+ // some vendors (Brother) do not implement IPP correctly and so
+ // we need to map non-empty values to text...
if (attr->value_tag == tag)
{
if (n == 0)
case IPP_TAG_RESOLUTION :
if (n != 9)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP resolution value not 9 bytes."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP resolution value not 9 bytes."), 1);
DEBUG_printf("1ippReadIO: bad resolution value length %d.", n);
goto rollback;
}
if (n < 4)
{
if (tag == IPP_TAG_TEXTLANG)
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP textWithLanguage value less than "
- "minimum 4 bytes."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP textWithLanguage value less than minimum 4 bytes."), 1);
else
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP nameWithLanguage value less than "
- "minimum 4 bytes."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP nameWithLanguage value less than minimum 4 bytes."), 1);
DEBUG_printf("1ippReadIO: bad stringWithLanguage value length %d.", n);
goto rollback;
}
if ((*cb)(src, buffer, (size_t)n) < n)
{
- DEBUG_puts("1ippReadIO: Unable to read string w/language "
- "value.");
+ DEBUG_puts("1ippReadIO: Unable to read string w/language value.");
goto rollback;
}
bufptr = buffer;
bufend = buffer + n;
- /*
- * text-with-language and name-with-language are composite
- * values:
- *
- * language-length
- * language
- * text-length
- * text
- */
-
+ // textWithLanguage and nameWithLanguage are composite
+ // values:
+ //
+ // language-length
+ // language
+ // text-length
+ // text
n = (bufptr[0] << 8) | bufptr[1];
if ((bufptr + 2 + n + 2) > bufend || n >= (int)sizeof(string))
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP language length overflows value."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP language length overflows value."), 1);
DEBUG_printf("1ippReadIO: bad language value length %d.", n);
goto rollback;
}
else if (n >= IPP_MAX_LANGUAGE)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP language length too large."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP language length too large."), 1);
DEBUG_printf("1ippReadIO: bad language value length %d.", n);
goto rollback;
}
if ((bufptr + 2 + n) > bufend)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP string length overflows value."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP string length overflows value."), 1);
DEBUG_printf("1ippReadIO: bad string value length %d.", n);
goto rollback;
}
break;
case IPP_TAG_BEGIN_COLLECTION :
- /*
- * Oh, boy, here comes a collection value, so read it...
- */
-
+ // Oh boy, here comes a collection value, so read it...
value->collection = ippNew();
if (n > 0)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP begCollection value not 0 bytes."), 1);
- DEBUG_puts("1ippReadIO: begCollection tag with value length "
- "> 0.");
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP begCollection value not 0 bytes."), 1);
+ DEBUG_puts("1ippReadIO: begCollection tag with value length > 0.");
goto rollback;
}
case IPP_TAG_END_COLLECTION :
if (n > 0)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP endCollection value not 0 bytes."), 1);
- DEBUG_puts("1ippReadIO: endCollection tag with value length "
- "> 0.");
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP endCollection value not 0 bytes."), 1);
+ DEBUG_puts("1ippReadIO: endCollection tag with value length > 0.");
goto rollback;
}
return (ipp->state = IPP_STATE_DATA);
case IPP_TAG_MEMBERNAME :
- /*
- * The value the name of the member in the collection, which
- * we need to carry over...
- */
-
+ // The value the name of the member in the collection, which we need to carry over...
if (!attr)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP memberName with no attribute."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP memberName with no attribute."), 1);
DEBUG_puts("1ippReadIO: Member name without attribute.");
goto rollback;
}
else if (n == 0)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP memberName value is empty."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP memberName value is empty."), 1);
DEBUG_puts("1ippReadIO: Empty member name value.");
goto rollback;
}
buffer[n] = '\0';
attr->name = _cupsStrAlloc((char *)buffer);
- /*
- * Since collection members are encoded differently than
- * regular attributes, make sure we don't start with an
- * empty value...
- */
-
+ // Since collection members are encoded differently than regular
+ // attributes, make sure we don't start with an empty value...
attr->num_values --;
DEBUG_printf("2ippReadIO: member name=\"%s\"", attr->name);
break;
case IPP_TAG_STRING :
- default : /* Other unsupported values */
+ default : // Other unsupported values
if (tag == IPP_TAG_STRING && n > IPP_MAX_LENGTH)
{
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP octetString length too large."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP octetString length too large."), 1);
DEBUG_printf("1ippReadIO: bad octetString value length %d.", n);
goto rollback;
}
}
}
else
+ {
value->unknown.data = NULL;
+ }
break;
}
- /*
- * If blocking is disabled, stop here...
- */
-
+ // If blocking is disabled, stop here...
if (!blocking)
break;
}
break;
default :
- break; /* anti-compiler-warning-code */
+ break; // anti-compiler-warning-code
}
DEBUG_printf("1ippReadIO: returning ipp->state=%d.", ipp->state);
}
-/*
- * 'ippSetBoolean()' - Set a boolean value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetBoolean(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- int boolvalue)/* I - Boolean value */
+//
+// 'ippRestore()' - Restore a previously saved find position.
+//
+// @since CUPS 2.5@
+//
+
+void
+ippRestore(ipp_t *ipp) // I - IPP message
{
- _ipp_value_t *value; /* Current value */
+ if (ipp)
+ {
+ if (ipp->find > ipp->fstack)
+ ipp->find --;
+ else
+ ipp->find = NULL;
+ }
+}
- /*
- * Range check input...
- */
+//
+// 'ippSave()' - Save the current find position.
+//
+// @since CUPS 2.5@
+//
+
+void
+ippSave(ipp_t *ipp) // I - IPP message
+{
+ if (ipp && ipp->find < (ipp->fstack + _IPP_MAX_FIND))
+ {
+ ipp->find[1] = ipp->find[0];
+ ipp->find ++;
+ }
+}
- if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_BOOLEAN ||
- element < 0 || element > (*attr)->num_values)
- return (0);
- /*
- * Set the value and return...
- */
+//
+// 'ippSetBoolean()' - Set a boolean value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetBoolean(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ int boolvalue)// I - Boolean value
+{
+ _ipp_value_t *value; // Current value
+
+
+ // Range check input...
+ if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_BOOLEAN || element < 0 || element > (*attr)->num_values)
+ return (0);
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
value->boolean = (char)boolvalue;
}
-/*
- * 'ippSetCollection()' - Set a collection value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ippSetCollection()' - Set a collection value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
ippSetCollection(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- ipp_t *colvalue) /* I - Collection value */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ ipp_t *colvalue) // I - Collection value
{
- _ipp_value_t *value; /* Current value */
+ _ipp_value_t *value; // Current value
- /*
- * Range check input...
- */
-
- if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_BEGIN_COLLECTION ||
- element < 0 || element > (*attr)->num_values || !colvalue)
+ // Range check input...
+ if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_BEGIN_COLLECTION || element < 0 || element > (*attr)->num_values || !colvalue)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
if (value->collection)
}
-/*
- * 'ippSetDate()' - Set a dateTime value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetDate(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- const ipp_uchar_t *datevalue)/* I - dateTime value */
+//
+// 'ippSetDate()' - Set a dateTime value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetDate(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ const ipp_uchar_t *datevalue)// I - dateTime value
{
- _ipp_value_t *value; /* Current value */
-
+ _ipp_value_t *value; // Current value
- /*
- * Range check input...
- */
+ // Range check input...
if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_DATE && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || !datevalue)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+ {
+ (*attr)->value_tag = IPP_TAG_DATE;
memcpy(value->date, datevalue, sizeof(value->date));
+ }
return (value != NULL);
}
-/*
- * 'ippSetGroupTag()' - Set the group tag of an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code group@ parameter specifies the IPP attribute group tag: none
- * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
- * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
- * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
- * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ippSetGroupTag()' - Set the group tag of an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "group" parameter specifies the IPP attribute group tag: none
+// (`IPP_TAG_ZERO`, for member attributes), document (`IPP_TAG_DOCUMENT`),
+// event notification (`IPP_TAG_EVENT_NOTIFICATION`), operation
+// (`IPP_TAG_OPERATION`), printer (`IPP_TAG_PRINTER`), subscription
+// (`IPP_TAG_SUBSCRIPTION`), or unsupported (`IPP_TAG_UNSUPPORTED_GROUP`).
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
ippSetGroupTag(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - Attribute */
- ipp_tag_t group_tag) /* I - Group tag */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - Attribute
+ ipp_tag_t group_tag) // I - Group tag
{
- /*
- * Range check input - group tag must be 0x01 to 0x0F, per RFC 8011...
- */
-
- if (!ipp || !attr || !*attr ||
- group_tag < IPP_TAG_ZERO || group_tag == IPP_TAG_END ||
- group_tag >= IPP_TAG_UNSUPPORTED_VALUE)
+ // Range check input - group tag must be 0x01 to 0x0F, per RFC 8011...
+ if (!ipp || !attr || !*attr || group_tag < IPP_TAG_ZERO || group_tag == IPP_TAG_END || group_tag >= IPP_TAG_UNSUPPORTED_VALUE)
return (0);
- /*
- * Set the group tag and return...
- */
-
+ // Set the group tag and return...
(*attr)->group_tag = group_tag;
return (1);
}
-/*
- * 'ippSetInteger()' - Set an integer or enum value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetInteger(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- int intvalue) /* I - Integer/enum value */
+//
+// 'ippSetInteger()' - Set an integer or enum value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetInteger(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ int intvalue) // I - Integer/enum value
{
- _ipp_value_t *value; /* Current value */
-
+ _ipp_value_t *value; // Current value
- /*
- * Range check input...
- */
+ // Range check input...
if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_INTEGER && (*attr)->value_tag != IPP_TAG_ENUM && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
if ((*attr)->value_tag != IPP_TAG_ENUM)
}
-/*
- * 'ippSetName()' - Set the name of an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetName(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- const char *name) /* I - Attribute name */
+//
+// 'ippSetName()' - Set the name of an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetName(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ const char *name) // I - Attribute name
{
- char *temp; /* Temporary name value */
-
+ char *temp; // Temporary name value
- /*
- * Range check input...
- */
+ // Range check input...
if (!ipp || !attr || !*attr)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((temp = _cupsStrAlloc(name)) != NULL)
{
if ((*attr)->name)
}
-/*
- * 'ippSetOctetString()' - Set an octetString value in an IPP attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ippSetOctetString()' - Set an octetString value in an IPP attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+int // O - 1 on success, 0 on failure
ippSetOctetString(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- const void *data, /* I - Pointer to octetString data */
- int datalen) /* I - Length of octetString data */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ const void *data, // I - Pointer to octetString data
+ int datalen) // I - Length of octetString data
{
- _ipp_value_t *value; /* Current value */
-
+ _ipp_value_t *value; // Current value
- /*
- * Range check input...
- */
+ // Range check input...
if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_STRING && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || datalen < 0 || datalen > IPP_MAX_LENGTH)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
if ((int)((*attr)->value_tag) & IPP_TAG_CUPS_CONST)
{
- /*
- * Just copy the pointer...
- */
-
+ // Just copy the pointer...
value->unknown.data = (void *)data;
value->unknown.length = datalen;
}
else
{
- /*
- * Copy the data...
- */
-
+ // Copy the data...
(*attr)->value_tag = IPP_TAG_STRING;
if (value->unknown.data)
{
- /*
- * Free previous data...
- */
-
+ // Free previous data...
free(value->unknown.data);
value->unknown.data = NULL;
if (datalen > 0)
{
- void *temp; /* Temporary data pointer */
+ void *temp; // Temporary data pointer
if ((temp = malloc((size_t)datalen)) != NULL)
{
value->unknown.length = datalen;
}
else
+ {
return (0);
+ }
}
}
}
}
-/*
- * 'ippSetOperation()' - Set the operation ID in an IPP request message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippSetOperation()' - Set the operation ID in an IPP request message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - 1 on success, 0 on failure */
-ippSetOperation(ipp_t *ipp, /* I - IPP request message */
- ipp_op_t op) /* I - Operation ID */
+int // O - 1 on success, 0 on failure
+ippSetOperation(ipp_t *ipp, // I - IPP request message
+ ipp_op_t op) // I - Operation ID
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (0);
- /*
- * Set the operation and return...
- */
-
+ // Set the operation and return...
ipp->request.op.operation_id = op;
return (1);
}
-/*
- * 'ippSetRange()' - Set a rangeOfInteger value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetRange(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- int lowervalue, /* I - Lower bound for range */
- int uppervalue) /* I - Upper bound for range */
+//
+// 'ippSetRange()' - Set a rangeOfInteger value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetRange(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ int lowervalue, // I - Lower bound for range
+ int uppervalue) // I - Upper bound for range
{
- _ipp_value_t *value; /* Current value */
-
+ _ipp_value_t *value; // Current value
- /*
- * Range check input...
- */
+ // Range check input...
if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_RANGE && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || lowervalue > uppervalue)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
(*attr)->value_tag = IPP_TAG_RANGE;
}
-/*
- * 'ippSetRequestId()' - Set the request ID in an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code request_id@ parameter must be greater than 0.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetRequestId(ipp_t *ipp, /* I - IPP message */
- int request_id) /* I - Request ID */
+//
+// 'ippSetRequestId()' - Set the request ID in an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The @code request_id@ parameter must be greater than 0.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetRequestId(ipp_t *ipp, // I - IPP message
+ int request_id) // I - Request ID
{
- /*
- * Range check input; not checking request_id values since ipptool wants to send
- * invalid values for conformance testing and a bad request_id does not affect the
- * encoding of a message...
- */
-
+ // Range check input; not checking request_id values since ipptool wants to
+ // send invalid values for conformance testing and a bad request_id does not
+ // affect the encoding of a message...
if (!ipp)
return (0);
- /*
- * Set the request ID and return...
- */
-
+ // Set the request ID and return...
ipp->request.any.request_id = request_id;
return (1);
}
-/*
- * 'ippSetResolution()' - Set a resolution value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ippSetResolution()' - Set a resolution value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
ippSetResolution(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- ipp_res_t unitsvalue, /* I - Resolution units */
- int xresvalue, /* I - Horizontal/cross feed resolution */
- int yresvalue) /* I - Vertical/feed resolution */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ ipp_res_t unitsvalue, // I - Resolution units
+ int xresvalue, // I - Horizontal/cross feed resolution
+ int yresvalue) // I - Vertical/feed resolution
{
- _ipp_value_t *value; /* Current value */
+ _ipp_value_t *value; // Current value
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp || !attr || !*attr || ((*attr)->value_tag != IPP_TAG_RESOLUTION && (*attr)->value_tag != IPP_TAG_NOVALUE && (*attr)->value_tag != IPP_TAG_UNKNOWN) || element < 0 || element > (*attr)->num_values || xresvalue <= 0 || yresvalue <= 0 || unitsvalue < IPP_RES_PER_INCH || unitsvalue > IPP_RES_PER_CM)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
(*attr)->value_tag = IPP_TAG_RESOLUTION;
}
-/*
- * 'ippSetState()' - Set the current state of the IPP message.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippSetState()' - Set the current state of the IPP message.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - 1 on success, 0 on failure */
-ippSetState(ipp_t *ipp, /* I - IPP message */
- ipp_state_t state) /* I - IPP state value */
+int // O - 1 on success, 0 on failure
+ippSetState(ipp_t *ipp, // I - IPP message
+ ipp_state_t state) // I - IPP state value
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (0);
- /*
- * Set the state and return...
- */
-
+ // Set the state and return...
ipp->state = state;
ipp->current = NULL;
}
-/*
- * 'ippSetStatusCode()' - Set the status code in an IPP response or event message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
+//
+// 'ippSetStatusCode()' - Set the status code in an IPP response or event message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
-int /* O - 1 on success, 0 on failure */
-ippSetStatusCode(ipp_t *ipp, /* I - IPP response or event message */
- ipp_status_t status) /* I - Status code */
+int // O - 1 on success, 0 on failure
+ippSetStatusCode(ipp_t *ipp, // I - IPP response or event message
+ ipp_status_t status) // I - Status code
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp)
return (0);
- /*
- * Set the status code and return...
- */
-
+ // Set the status code and return...
ipp->request.status.status_code = status;
return (1);
}
-/*
- * 'ippSetString()' - Set a string value in an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetString(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- const char *strvalue) /* I - String value */
+//
+// 'ippSetString()' - Set a string value in an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetString(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ const char *strvalue) // I - String value
{
- char *temp; /* Temporary string */
- _ipp_value_t *value; /* Current value */
- ipp_tag_t value_tag; /* Value tag */
-
+ char *temp; // Temporary string
+ _ipp_value_t *value; // Current value
+ ipp_tag_t value_tag; // Value tag
- /*
- * Range check input...
- */
+ // Range check input...
if (attr && *attr)
value_tag = (*attr)->value_tag & IPP_TAG_CUPS_MASK;
else
if (!ipp || !attr || !*attr || (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG && value_tag != IPP_TAG_NAMELANG && value_tag != IPP_TAG_NOVALUE && value_tag != IPP_TAG_UNKNOWN) || value_tag > IPP_TAG_MIMETYPE || element < 0 || element > (*attr)->num_values || !strvalue)
return (0);
- /*
- * Set the value and return...
- */
-
+ // Set the value and return...
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
{
if (value_tag == IPP_TAG_NOVALUE || value_tag == IPP_TAG_UNKNOWN)
value->string.language = (*attr)->values[0].string.language;
if ((int)((*attr)->value_tag) & IPP_TAG_CUPS_CONST)
+ {
value->string.text = (char *)strvalue;
+ }
else if ((temp = _cupsStrAlloc(strvalue)) != NULL)
{
if (value->string.text)
value->string.text = temp;
}
else
+ {
return (0);
+ }
}
return (value != NULL);
}
-/*
- * 'ippSetStringf()' - Set a formatted string value of an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * The @code format@ parameter uses formatting characters compatible with the
- * printf family of standard functions. Additional arguments follow it as
- * needed. The formatted string is truncated as needed to the maximum length of
- * the corresponding value type.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetStringf(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- const char *format, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
+//
+// 'ippSetStringf()' - Set a formatted string value of an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// The "format" parameter uses formatting characters compatible with the
+// printf family of standard functions. Additional arguments follow it as
+// needed. The formatted string is truncated as needed to the maximum length of
+// the corresponding value type.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetStringf(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ const char *format, // I - Printf-style format string
+ ...) // I - Additional arguments as needed
{
- int ret; /* Return value */
- va_list ap; /* Pointer to additional arguments */
+ int ret; // Return value
+ va_list ap; // Pointer to additional arguments
va_start(ap, format);
}
-/*
- * 'ippSetStringf()' - Set a formatted string value of an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * The @code element@ parameter specifies which value to set from 0 to
- * @code ippGetCount(attr)@.
- *
- * The @code format@ parameter uses formatting characters compatible with the
- * printf family of standard functions. Additional arguments follow it as
- * needed. The formatted string is truncated as needed to the maximum length of
- * the corresponding value type.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetStringfv(ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element, /* I - Value number (0-based) */
- const char *format, /* I - Printf-style format string */
- va_list ap) /* I - Pointer to additional arguments */
+//
+// 'ippSetStringf()' - Set a formatted string value of an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// The "element" parameter specifies which value to set from 0 to
+// @code ippGetCount(attr)@.
+//
+// The "format" parameter uses formatting characters compatible with the
+// printf family of standard functions. Additional arguments follow it as
+// needed. The formatted string is truncated as needed to the maximum length of
+// the corresponding value type.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetStringfv(ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element, // I - Value number (0-based)
+ const char *format, // I - Printf-style format string
+ va_list ap) // I - Pointer to additional arguments
{
- ipp_tag_t value_tag; /* Value tag */
+ ipp_tag_t value_tag; // Value tag
char buffer[IPP_MAX_TEXT + 4];
- /* Formatted text string */
- ssize_t bytes, /* Length of formatted value */
- max_bytes; /* Maximum number of bytes for value */
-
+ // Formatted text string
+ ssize_t bytes, // Length of formatted value
+ max_bytes; // Maximum number of bytes for value
- /*
- * Range check input...
- */
+ // Range check input...
if (attr && *attr)
value_tag = (*attr)->value_tag & IPP_TAG_CUPS_MASK;
else
if (!ipp || !attr || !*attr || (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG && value_tag != IPP_TAG_NAMELANG && value_tag != IPP_TAG_NOVALUE && value_tag != IPP_TAG_UNKNOWN) || value_tag > IPP_TAG_MIMETYPE || !format)
return (0);
- /*
- * Format the string...
- */
-
+ // Format the string...
if (!strcmp(format, "%s"))
{
- /*
- * Optimize the simple case...
- */
-
+ // Optimize the simple case...
const char *s = va_arg(ap, char *);
if (!s)
}
else
{
- /*
- * Do a full formatting of the message...
- */
-
+ // Do a full formatting of the message...
if ((bytes = vsnprintf(buffer, sizeof(buffer), format, ap)) < 0)
return (0);
}
- /*
- * Limit the length of the string...
- */
-
+ // Limit the length of the string...
switch (value_tag)
{
default :
if (bytes >= max_bytes)
{
- char *bufmax, /* Buffer at max_bytes */
- *bufptr; /* Pointer into buffer */
+ char *bufmax, // Buffer at max_bytes
+ *bufptr; // Pointer into buffer
bufptr = buffer + strlen(buffer) - 1;
bufmax = buffer + max_bytes - 1;
*bufptr = '\0';
}
- /*
- * Set the formatted string and return...
- */
-
+ // Set the formatted string and return...
return (ippSetString(ipp, attr, element, buffer));
}
-/*
- * 'ippSetValueTag()' - Set the value tag of an attribute.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The @code attr@ parameter may be modified as a result of setting the value.
- *
- * Integer (@code IPP_TAG_INTEGER@) values can be promoted to rangeOfInteger
- * (@code IPP_TAG_RANGE@) values, the various string tags can be promoted to name
- * (@code IPP_TAG_NAME@) or nameWithLanguage (@code IPP_TAG_NAMELANG@) values, text
- * (@code IPP_TAG_TEXT@) values can be promoted to textWithLanguage
- * (@code IPP_TAG_TEXTLANG@) values, and all values can be demoted to the various
- * out-of-band value tags such as no-value (@code IPP_TAG_NOVALUE@). All other changes
- * will be rejected.
- *
- * Promoting a string attribute to nameWithLanguage or textWithLanguage adds the language
- * code in the "attributes-natural-language" attribute or, if not present, the language
- * code for the current locale.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'ippSetValueTag()' - Set the value tag of an attribute.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The "attr" parameter may be modified as a result of setting the value.
+//
+// Integer (`IPP_TAG_INTEGER`) values can be promoted to rangeOfInteger
+// (`IPP_TAG_RANGE`) values, the various string tags can be promoted to name
+// (`IPP_TAG_NAME`) or nameWithLanguage (`IPP_TAG_NAMELANG`) values, text
+// (`IPP_TAG_TEXT`) values can be promoted to textWithLanguage
+// (`IPP_TAG_TEXTLANG`) values, and all values can be demoted to the various
+// out-of-band value tags such as no-value (`IPP_TAG_NOVALUE`). All other
+// changes will be rejected.
+//
+// Promoting a string attribute to nameWithLanguage or textWithLanguage adds the language
+// code in the "attributes-natural-language" attribute or, if not present, the language
+// code for the current locale.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
ippSetValueTag(
- ipp_t *ipp, /* I - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- ipp_tag_t value_tag) /* I - Value tag */
+ ipp_t *ipp, // I - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ ipp_tag_t value_tag) // I - Value tag
{
- int i; /* Looping var */
- _ipp_value_t *value; /* Current value */
- int integer; /* Current integer value */
- cups_lang_t *language; /* Current language */
- char code[32]; /* Language code */
- ipp_tag_t temp_tag; /* Temporary value tag */
-
+ int i; // Looping var
+ _ipp_value_t *value; // Current value
+ int integer; // Current integer value
+ cups_lang_t *language; // Current language
+ char code[32]; // Language code
+ ipp_tag_t temp_tag; // Temporary value tag
- /*
- * Range check input...
- */
+ // Range check input...
if (!ipp || !attr || !*attr)
return (0);
- /*
- * If there is no change, return immediately...
- */
+ // If there is no change, return immediately...
+ temp_tag = (ipp_tag_t)((int)((*attr)->value_tag) & IPP_TAG_CUPS_MASK);
- if (value_tag == (*attr)->value_tag)
+ if (value_tag == temp_tag)
return (1);
- /*
- * Otherwise implement changes as needed...
- */
-
- temp_tag = (ipp_tag_t)((int)((*attr)->value_tag) & IPP_TAG_CUPS_MASK);
-
+ // Otherwise implement changes as needed...
switch (value_tag)
{
case IPP_TAG_UNSUPPORTED_VALUE :
case IPP_TAG_NOTSETTABLE :
case IPP_TAG_DELETEATTR :
case IPP_TAG_ADMINDEFINE :
- /*
- * Free any existing values...
- */
-
+ // Free any existing values...
if ((*attr)->num_values > 0)
ipp_free_values(*attr, 0, (*attr)->num_values);
- /*
- * Set out-of-band value...
- */
-
+ // Set out-of-band value...
(*attr)->value_tag = value_tag;
break;
if (temp_tag != IPP_TAG_INTEGER)
return (0);
- for (i = (*attr)->num_values, value = (*attr)->values;
- i > 0;
- i --, value ++)
+ for (i = (*attr)->num_values, value = (*attr)->values; i > 0; i --, value ++)
{
integer = value->integer;
value->range.lower = value->range.upper = integer;
if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT)
return (0);
- if (ipp->attrs && ipp->attrs->next && ipp->attrs->next->name &&
- !strcmp(ipp->attrs->next->name, "attributes-natural-language") && (ipp->attrs->next->value_tag & IPP_TAG_CUPS_MASK) == IPP_TAG_LANGUAGE)
+ if (ipp->attrs && ipp->attrs->next && ipp->attrs->next->name && !strcmp(ipp->attrs->next->name, "attributes-natural-language") && (ipp->attrs->next->value_tag & IPP_TAG_CUPS_MASK) == IPP_TAG_LANGUAGE)
{
- /*
- * Use the language code from the IPP message...
- */
-
- (*attr)->values[0].string.language =
- _cupsStrAlloc(ipp->attrs->next->values[0].string.text);
+ // Use the language code from the IPP message...
+ (*attr)->values[0].string.language = _cupsStrAlloc(ipp->attrs->next->values[0].string.text);
}
else
{
- /*
- * Otherwise, use the language code corresponding to the locale...
- */
-
+ // Otherwise, use the language code corresponding to the locale...
language = cupsLangDefault();
- (*attr)->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language->language,
- code,
- sizeof(code)));
+ (*attr)->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language->language, code, sizeof(code)));
}
- for (i = (*attr)->num_values - 1, value = (*attr)->values + 1;
- i > 0;
- i --, value ++)
+ for (i = (*attr)->num_values - 1, value = (*attr)->values + 1; i > 0; i --, value ++)
value->string.language = (*attr)->values[0].string.language;
if ((int)(*attr)->value_tag & IPP_TAG_CUPS_CONST)
{
- /*
- * Make copies of all values...
- */
-
- for (i = (*attr)->num_values, value = (*attr)->values;
- i > 0;
- i --, value ++)
+ // Make copies of all values...
+ for (i = (*attr)->num_values, value = (*attr)->values; i > 0; i --, value ++)
value->string.text = _cupsStrAlloc(value->string.text);
}
case IPP_TAG_KEYWORD :
if (temp_tag == IPP_TAG_NAME || temp_tag == IPP_TAG_NAMELANG)
- break; /* Silently "allow" name -> keyword */
+ break; // Silently "allow" name -> keyword
default :
return (0);
}
-/*
- * 'ippSetVersion()' - Set the version number in an IPP message.
- *
- * The @code ipp@ parameter refers to an IPP message previously created using
- * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
- *
- * The valid version numbers are currently 1.0, 1.1, 2.0, 2.1, and 2.2.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int /* O - 1 on success, 0 on failure */
-ippSetVersion(ipp_t *ipp, /* I - IPP message */
- int major, /* I - Major version number (major.minor) */
- int minor) /* I - Minor version number (major.minor) */
+//
+// 'ippSetVersion()' - Set the version number in an IPP message.
+//
+// The "ipp" parameter refers to an IPP message previously created using
+// the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+//
+// The valid version numbers are currently 1.0, 1.1, 2.0, 2.1, and 2.2.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int // O - 1 on success, 0 on failure
+ippSetVersion(ipp_t *ipp, // I - IPP message
+ int major, // I - Major version number (major.minor)
+ int minor) // I - Minor version number (major.minor)
{
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp || major < 0 || minor < 0)
return (0);
- /*
- * Set the version number...
- */
-
+ // Set the version number...
ipp->request.any.version[0] = (ipp_uchar_t)major;
ipp->request.any.version[1] = (ipp_uchar_t)minor;
}
-/*
- * 'ippTimeToDate()' - Convert from time in seconds to RFC 2579 format.
- */
+//
+// 'ippTimeToDate()' - Convert from time in seconds to RFC 2579 format.
+//
-const ipp_uchar_t * /* O - RFC-2579 date/time data */
-ippTimeToDate(time_t t) /* I - Time in seconds */
+const ipp_uchar_t * // O - RFC-2579 date/time data
+ippTimeToDate(time_t t) // I - Time in seconds
{
- struct tm unixdate; /* UNIX unixdate/time info */
+ struct tm unixdate; // UNIX unixdate/time info
ipp_uchar_t *date = _cupsGlobals()->ipp_date;
- /* RFC-2579 date/time data */
-
-
- /*
- * RFC-2579 date/time format is:
- *
- * Byte(s) Description
- * ------- -----------
- * 0-1 Year (0 to 65535)
- * 2 Month (1 to 12)
- * 3 Day (1 to 31)
- * 4 Hours (0 to 23)
- * 5 Minutes (0 to 59)
- * 6 Seconds (0 to 60, 60 = "leap second")
- * 7 Deciseconds (0 to 9)
- * 8 +/- UTC
- * 9 UTC hours (0 to 11)
- * 10 UTC minutes (0 to 59)
- */
-
+ // RFC-2579 date/time data
+
+
+ // RFC-2579 date/time format is:
+ //
+ // Byte(s) Description
+ // ------- -----------
+ // 0-1 Year (0 to 65535)
+ // 2 Month (1 to 12)
+ // 3 Day (1 to 31)
+ // 4 Hours (0 to 23)
+ // 5 Minutes (0 to 59)
+ // 6 Seconds (0 to 60, 60 = "leap second")
+ // 7 Deciseconds (0 to 9)
+ // 8 +/- UTC
+ // 9 UTC hours (0 to 11)
+ // 10 UTC minutes (0 to 59)
gmtime_r(&t, &unixdate);
unixdate.tm_year += 1900;
}
-/*
- * 'ippValidateAttribute()' - Validate the contents of an attribute.
- *
- * This function validates the contents of an attribute based on the name and
- * value tag. 1 is returned if the attribute is valid, 0 otherwise. On
- * failure, @link cupsGetErrorString@ is set to a human-readable message.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'ippValidateAttribute()' - Validate the contents of an attribute.
+//
+// This function validates the contents of an attribute based on the name and
+// value tag. 1 is returned if the attribute is valid, 0 otherwise. On
+// failure, @link cupsGetErrorString@ is set to a human-readable message.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
-int /* O - 1 if valid, 0 otherwise */
+int // O - 1 if valid, 0 otherwise
ippValidateAttribute(
- ipp_attribute_t *attr) /* I - Attribute */
+ ipp_attribute_t *attr) // I - Attribute
{
- int i; /* Looping var */
- char scheme[64], /* Scheme from URI */
- userpass[256], /* Username/password from URI */
- hostname[256], /* Hostname from URI */
- resource[1024]; /* Resource from URI */
- int port, /* Port number from URI */
- uri_status; /* URI separation status */
- const char *ptr; /* Pointer into string */
- ipp_attribute_t *colattr; /* Collection attribute */
- regex_t re; /* Regular expression */
- ipp_uchar_t *date; /* Current date value */
-
-
- /*
- * Skip separators.
- */
-
+ int i, // Looping var
+ r; // regcomp() error code
+ char scheme[64], // Scheme from URI
+ userpass[256], // Username/password from URI
+ hostname[256], // Hostname from URI
+ resource[1024]; // Resource from URI
+ int port, // Port number from URI
+ uri_status; // URI separation status
+ const char *ptr; // Pointer into string
+ ipp_attribute_t *colattr; // Collection attribute
+ regex_t re; // Regular expression
+ ipp_uchar_t *date; // Current date value
+
+
+ // Skip separators.
if (!attr->name)
return (1);
- /*
- * Validate the attribute name.
- */
-
+ // Validate the attribute name.
for (ptr = attr->name; *ptr; ptr ++)
+ {
if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' && *ptr != '_')
break;
+ }
if (*ptr || ptr == attr->name)
{
case IPP_TAG_BOOLEAN :
for (i = 0; i < attr->num_values; i ++)
{
- if (attr->values[i].boolean != 0 &&
- attr->values[i].boolean != 1)
+ if (attr->values[i].boolean != 0 && attr->values[i].boolean != 1)
{
ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)."), attr->name, attr->values[i].boolean);
return (0);
ptr += 3;
}
else if (*ptr & 0x80)
+ {
break;
+ }
else if ((*ptr < ' ' && *ptr != '\n' && *ptr != '\r' && *ptr != '\t') || *ptr == 0x7f)
+ {
break;
+ }
}
if (*ptr)
ptr += 3;
}
else if (*ptr & 0x80)
+ {
break;
+ }
else if (*ptr < ' ' || *ptr == 0x7f)
+ {
break;
+ }
}
if (*ptr)
{
for (ptr = attr->values[i].string.text; *ptr; ptr ++)
{
- if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' &&
- *ptr != '_')
+ if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' && *ptr != '_')
break;
}
{
for (ptr ++; *ptr; ptr ++)
{
- if (!islower(*ptr & 255) && !isdigit(*ptr & 255) &&
- *ptr != '+' && *ptr != '-' && *ptr != '.')
+ if (!islower(*ptr & 255) && !isdigit(*ptr & 255) && *ptr != '+' && *ptr != '-' && *ptr != '.')
break;
}
}
{
for (ptr = attr->values[i].string.text; *ptr; ptr ++)
{
- if (!isprint(*ptr & 255) || isupper(*ptr & 255) ||
- isspace(*ptr & 255))
+ if (!isprint(*ptr & 255) || isupper(*ptr & 255) || isspace(*ptr & 255))
break;
}
break;
case IPP_TAG_LANGUAGE :
- /*
- * The following regular expression is derived from the ABNF for
- * language tags in RFC 4646. All I can say is that this is the
- * easiest way to check the values...
- */
-
- if ((i = regcomp(&re,
+ // The following regular expression is derived from the ABNF for
+ // language tags in RFC 4646. All I can say is that this is the
+ // easiest way to check the values...
+ if ((r = regcomp(&re,
"^("
"(([a-z]{2,3}(-[a-z][a-z][a-z]){0,3})|[a-z]{4,8})"
- /* language */
- "(-[a-z][a-z][a-z][a-z]){0,1}" /* script */
- "(-([a-z][a-z]|[0-9][0-9][0-9])){0,1}" /* region */
- "(-([a-z]{5,8}|[0-9][0-9][0-9]))*" /* variant */
- "(-[a-wy-z](-[a-z0-9]{2,8})+)*" /* extension */
- "(-x(-[a-z0-9]{1,8})+)*" /* privateuse */
+ // language
+ "(-[a-z][a-z][a-z][a-z]){0,1}" // script
+ "(-([a-z][a-z]|[0-9][0-9][0-9])){0,1}" // region
+ "(-([a-z]{5,8}|[0-9][0-9][0-9]))*" // variant
+ "(-[a-wy-z](-[a-z0-9]{2,8})+)*" // extension
+ "(-x(-[a-z0-9]{1,8})+)*" // privateuse
"|"
- "x(-[a-z0-9]{1,8})+" /* privateuse */
+ "x(-[a-z0-9]{1,8})+" // privateuse
"|"
- "[a-z]{1,3}(-[a-z][0-9]{2,8}){1,2}" /* grandfathered */
+ "[a-z]{1,3}(-[a-z][0-9]{2,8}){1,2}" // grandfathered
")$",
REG_NOSUB | REG_EXTENDED)) != 0)
{
- char temp[256]; /* Temporary error string */
+ char temp[256]; // Temporary error string
- regerror(i, &re, temp, sizeof(temp));
+ regerror(r, &re, temp, sizeof(temp));
ipp_set_error(IPP_STATUS_ERROR_INTERNAL, _("Unable to compile naturalLanguage regular expression: %s."), temp);
return (0);
}
break;
case IPP_TAG_MIMETYPE :
- /*
- * The following regular expression is derived from the ABNF for
- * MIME media types in RFC 2045 and 4288. All I can say is that this is
- * the easiest way to check the values...
- */
-
- if ((i = regcomp(&re,
+ // The following regular expression is derived from the ABNF for
+ // MIME media types in RFC 2045 and 4288. All I can say is that this is
+ // the easiest way to check the values...
+ if ((r = regcomp(&re,
"^"
- "[-a-zA-Z0-9!#$&.+^_]{1,127}" /* type-name */
+ "[-a-zA-Z0-9!#$&.+^_]{1,127}" // type-name
"/"
- "[-a-zA-Z0-9!#$&.+^_]{1,127}" /* subtype-name */
- "(;[-a-zA-Z0-9!#$&.+^_]{1,127}=" /* parameter= */
+ "[-a-zA-Z0-9!#$&.+^_]{1,127}" // subtype-name
+ "(;[-a-zA-Z0-9!#$&.+^_]{1,127}=" // parameter=
"([-a-zA-Z0-9!#$&.+^_]{1,127}|\"[^\"]*\"))*"
- /* value */
+ // value
"$",
REG_NOSUB | REG_EXTENDED)) != 0)
{
- char temp[256]; /* Temporary error string */
+ char temp[256]; // Temporary error string
- regerror(i, &re, temp, sizeof(temp));
+ regerror(r, &re, temp, sizeof(temp));
ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("Unable to compile mimeMediaType regular expression: %s."), temp);
return (0);
}
}
-/*
- * 'ippValidateAttributes()' - Validate all attributes in an IPP message.
- *
- * This function validates the contents of the IPP message, including each
- * attribute. Like @link ippValidateAttribute@, @link cupsGetErrorString@ is
- * set to a human-readable message on failure.
- *
- * @since CUPS 1.7/macOS 10.9@
- */
+//
+// 'ippValidateAttributes()' - Validate all attributes in an IPP message.
+//
+// This function validates the contents of the IPP message, including each
+// attribute. Like @link ippValidateAttribute@, @link cupsGetErrorString@ is
+// set to a human-readable message on failure.
+//
+// @since CUPS 1.7/macOS 10.9@
+//
-int /* O - 1 if valid, 0 otherwise */
-ippValidateAttributes(ipp_t *ipp) /* I - IPP message */
+int // O - 1 if valid, 0 otherwise
+ippValidateAttributes(ipp_t *ipp) // I - IPP message
{
- ipp_attribute_t *attr; /* Current attribute */
+ ipp_attribute_t *attr; // Current attribute
if (!ipp)
return (1);
for (attr = ipp->attrs; attr; attr = attr->next)
+ {
if (!ippValidateAttribute(attr))
return (0);
+ }
return (1);
}
-/*
- * 'ippWrite()' - Write data for an IPP message to a HTTP connection.
- */
+//
+// 'ippWrite()' - Write data for an IPP message to a HTTP connection.
+//
-ipp_state_t /* O - Current state */
-ippWrite(http_t *http, /* I - HTTP connection */
- ipp_t *ipp) /* I - IPP data */
+ipp_state_t // O - Current state
+ippWrite(http_t *http, // I - HTTP connection
+ ipp_t *ipp) // I - IPP data
{
DEBUG_printf("ippWrite(http=%p, ipp=%p)", (void *)http, (void *)ipp);
}
-/*
- * 'ippWriteFile()' - Write data for an IPP message to a file.
- *
- * @since CUPS 1.1.19/macOS 10.3@
- */
+//
+// 'ippWriteFile()' - Write data for an IPP message to a file.
+//
+// @since CUPS 1.1.19/macOS 10.3@
+//
-ipp_state_t /* O - Current state */
-ippWriteFile(int fd, /* I - HTTP data */
- ipp_t *ipp) /* I - IPP data */
+ipp_state_t // O - Current state
+ippWriteFile(int fd, // I - HTTP data
+ ipp_t *ipp) // I - IPP data
{
DEBUG_printf("ippWriteFile(fd=%d, ipp=%p)", fd, (void *)ipp);
}
-/*
- * 'ippWriteIO()' - Write data for an IPP message.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'ippWriteIO()' - Write data for an IPP message.
+//
+// @since CUPS 1.2/macOS 10.5@
+//
-ipp_state_t /* O - Current state */
-ippWriteIO(void *dst, /* I - Destination */
- ipp_iocb_t cb, /* I - Write callback function */
- int blocking, /* I - Use blocking IO? */
- ipp_t *parent, /* I - Parent IPP message */
- ipp_t *ipp) /* I - IPP data */
+ipp_state_t // O - Current state
+ippWriteIO(void *dst, // I - Destination
+ ipp_io_cb_t cb, // I - Write callback function
+ int blocking, // I - Use blocking IO?
+ ipp_t *parent, // I - Parent IPP message
+ ipp_t *ipp) // I - IPP data
{
- int i; /* Looping var */
- int n; /* Length of data */
- unsigned char *buffer, /* Data buffer */
- *bufptr; /* Pointer into buffer */
- ipp_attribute_t *attr; /* Current attribute */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ int n; // Length of data
+ unsigned char *buffer, // Data buffer
+ *bufptr; // Pointer into buffer
+ ipp_attribute_t *attr; // Current attribute
+ _ipp_value_t *value; // Current value
DEBUG_printf("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)dst, (void *)cb, blocking, (void *)parent, (void *)ipp);
switch (ipp->state)
{
case IPP_STATE_IDLE :
- ipp->state ++; /* Avoid common problem... */
+ ipp->state ++; // Avoid common problem...
case IPP_STATE_HEADER :
if (parent == NULL)
{
- /*
- * Send the request header:
- *
- * Version = 2 bytes
- * Operation/Status Code = 2 bytes
- * Request ID = 4 bytes
- * Total = 8 bytes
- */
-
+ // Send the request header:
+ //
+ // Version = 2 bytes
+ // Operation/Status Code = 2 bytes
+ // Request ID = 4 bytes
+ // Total = 8 bytes
bufptr = buffer;
*bufptr++ = ipp->request.any.version[0];
}
}
- /*
- * Reset the state engine to point to the first attribute
- * in the request/response, with no current group.
- */
-
+ // Reset the state engine to point to the first attribute
+ // in the request/response, with no current group.
ipp->state = IPP_STATE_ATTRIBUTE;
ipp->current = ipp->attrs;
ipp->curtag = IPP_TAG_ZERO;
DEBUG_printf("1ippWriteIO: ipp->current=%p", (void *)ipp->current);
- /*
- * If blocking is disabled, stop here...
- */
-
+ // If blocking is disabled, stop here...
if (!blocking)
break;
case IPP_STATE_ATTRIBUTE :
while (ipp->current != NULL)
{
- /*
- * Write this attribute...
- */
-
+ // Write this attribute...
bufptr = buffer;
attr = ipp->current;
{
if (ipp->curtag != attr->group_tag)
{
- /*
- * Send a group tag byte...
- */
-
+ // Send a group tag byte...
ipp->curtag = attr->group_tag;
if (attr->group_tag == IPP_TAG_ZERO)
*bufptr++ = (ipp_uchar_t)attr->group_tag;
}
else if (attr->group_tag == IPP_TAG_ZERO)
+ {
continue;
+ }
}
DEBUG_printf("1ippWriteIO: %s (%s%s)", attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag));
- /*
- * Write the attribute tag and name.
- *
- * The attribute name length does not include the trailing nul
- * character in the source string.
- *
- * Collection values (parent != NULL) are written differently...
- */
-
+ // Write the attribute tag and name.
+ //
+ // The attribute name length does not include the trailing nul
+ // character in the source string.
+ //
+ // Collection values (parent != NULL) are written differently...
if (parent == NULL)
{
- /*
- * Get the length of the attribute name, and make sure it won't
- * overflow the buffer...
- */
-
+ // Get the length of the attribute name, and make sure it won't overflow the buffer...
if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 8))
{
DEBUG_printf("1ippWriteIO: Attribute name too long (%d)", n);
return (IPP_STATE_ERROR);
}
- /*
- * Write the value tag, name length, and name string...
- */
-
+ // Write the value tag, name length, and name string...
DEBUG_printf("2ippWriteIO: writing value tag=%x(%s)", attr->value_tag, ippTagString(attr->value_tag));
DEBUG_printf("2ippWriteIO: writing name=%d,\"%s\"", n, attr->name);
*bufptr++ = (ipp_uchar_t)attr->value_tag;
}
else
+ {
*bufptr++ = (ipp_uchar_t)attr->value_tag;
+ }
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
}
else
{
- /*
- * Get the length of the attribute name, and make sure it won't
- * overflow the buffer...
- */
-
+ // Get the length of the attribute name, and make sure it won't overflow the buffer...
if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 12))
{
DEBUG_printf("1ippWriteIO: Attribute name too long (%d)", n);
return (IPP_STATE_ERROR);
}
- /*
- * Write the member name tag, name length, name string, value tag,
- * and empty name for the collection member attribute...
- */
-
+ // Write the member name tag, name length, name string, value tag,
+ // and empty name for the collection member attribute...
DEBUG_printf("2ippWriteIO: writing value tag=%x(memberName)", IPP_TAG_MEMBERNAME);
DEBUG_printf("2ippWriteIO: writing name=%d,\"%s\"", n, attr->name);
DEBUG_printf("2ippWriteIO: writing value tag=%x(%s)", attr->value_tag, ippTagString(attr->value_tag));
*bufptr++ = (ipp_uchar_t)attr->value_tag;
}
else
+ {
*bufptr++ = (ipp_uchar_t)attr->value_tag;
+ }
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Now write the attribute value(s)...
- */
-
+ // Now write the attribute value(s)...
switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
{
case IPP_TAG_UNSUPPORTED_VALUE :
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 9)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Integers and enumerations are both 4-byte signed
- * (twos-complement) values.
- *
- * Put the 2-byte length and 4-byte value into the buffer...
- */
-
+ // Integers and enumerations are both 4-byte signed
+ // (twos-complement) values.
+ //
+ // Put the 2-byte length and 4-byte value into the buffer...
*bufptr++ = 0;
*bufptr++ = 4;
*bufptr++ = (ipp_uchar_t)(value->integer >> 24);
break;
case IPP_TAG_BOOLEAN :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 6)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Boolean values are 1-byte; 0 = false, 1 = true.
- *
- * Put the 2-byte length and 1-byte value into the buffer...
- */
-
+ // Boolean values are 1-byte; 0 = false, 1 = true.
+ //
+ // Put the 2-byte length and 1-byte value into the buffer...
*bufptr++ = 0;
*bufptr++ = 1;
*bufptr++ = (ipp_uchar_t)value->boolean;
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
DEBUG_printf("2ippWriteIO: writing value tag=%x(%s)", attr->value_tag, ippTagString(attr->value_tag));
DEBUG_printf("2ippWriteIO: writing name=0,\"\"");
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
bufptr = buffer;
}
- /*
- * All simple strings consist of the 2-byte length and
- * character data without the trailing nul normally found
- * in C strings. Also, strings cannot be longer than IPP_MAX_LENGTH
- * bytes since the 2-byte length is a signed (twos-complement)
- * value.
- *
- * Put the 2-byte length and string characters in the buffer.
- */
-
+ // All simple strings consist of the 2-byte length and
+ // character data without the trailing nul normally found
+ // in C strings. Also, strings cannot be longer than IPP_MAX_LENGTH
+ // bytes since the 2-byte length is a signed (twos-complement)
+ // value.
+ //
+ // Put the 2-byte length and string characters in the buffer.
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
break;
case IPP_TAG_DATE :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 16)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Date values consist of a 2-byte length and an
- * 11-byte date/time structure defined by RFC 1903.
- *
- * Put the 2-byte length and 11-byte date/time
- * structure in the buffer.
- */
-
+ // Date values consist of a 2-byte length and an
+ // 11-byte date/time structure defined by RFC 1903.
+ //
+ // Put the 2-byte length and 11-byte date/time
+ // structure in the buffer.
*bufptr++ = 0;
*bufptr++ = 11;
memcpy(bufptr, value->date, 11);
break;
case IPP_TAG_RESOLUTION :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 14)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Resolution values consist of a 2-byte length,
- * 4-byte horizontal resolution value, 4-byte vertical
- * resolution value, and a 1-byte units value.
- *
- * Put the 2-byte length and resolution value data
- * into the buffer.
- */
-
+ // Resolution values consist of a 2-byte length,
+ // 4-byte horizontal resolution value, 4-byte vertical
+ // resolution value, and a 1-byte units value.
+ //
+ // Put the 2-byte length and resolution value data
+ // into the buffer.
*bufptr++ = 0;
*bufptr++ = 9;
*bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 24);
break;
case IPP_TAG_RANGE :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 13)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Range values consist of a 2-byte length,
- * 4-byte lower value, and 4-byte upper value.
- *
- * Put the 2-byte length and range value data
- * into the buffer.
- */
-
+ // Range values consist of a 2-byte length,
+ // 4-byte lower value, and 4-byte upper value.
+ //
+ // Put the 2-byte length and range value data
+ // into the buffer.
*bufptr++ = 0;
*bufptr++ = 8;
*bufptr++ = (ipp_uchar_t)(value->range.lower >> 24);
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
*bufptr++ = 0;
}
- /*
- * textWithLanguage and nameWithLanguage values consist
- * of a 2-byte length for both strings and their
- * individual lengths, a 2-byte length for the
- * character string, the character string without the
- * trailing nul, a 2-byte length for the character
- * set string, and the character set string without
- * the trailing nul.
- */
-
+ // textWithLanguage and nameWithLanguage values consist
+ // of a 2-byte length for both strings and their
+ // individual lengths, a 2-byte length for the
+ // character string, the character string without the
+ // trailing nul, a 2-byte length for the character
+ // set string, and the character set string without
+ // the trailing nul.
n = 4;
if (value->string.language != NULL)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
bufptr = buffer;
}
- /* Length of entire value */
+ // Length of entire value
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
- /* Length of language */
+ // Length of language
if (value->string.language != NULL)
n = (int)strlen(value->string.language);
else
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
- /* Language */
+ // Language
if (n > 0)
{
memcpy(bufptr, value->string.language, (size_t)n);
bufptr += n;
}
- /* Length of text */
+ // Length of text
if (value->string.text != NULL)
n = (int)strlen(value->string.text);
else
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
- /* Text */
+ // Text
if (n > 0)
{
memcpy(bufptr, value->string.text, (size_t)n);
break;
case IPP_TAG_BEGIN_COLLECTION :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
- /*
- * Collections are written with the begin-collection
- * tag first with a value of 0 length, followed by the
- * attributes in the collection, then the end-collection
- * value...
- */
-
+ // Collections are written with the begin-collection
+ // tag first with a value of 0 length, followed by the
+ // attributes in the collection, then the end-collection
+ // value...
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 5)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
*bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
- /*
- * Write a data length of 0 and flush the buffer...
- */
-
+ // Write a data length of 0 and flush the buffer...
*bufptr++ = 0;
*bufptr++ = 0;
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
bufptr = buffer;
- /*
- * Then write the collection attribute...
- */
-
+ // Then write the collection attribute...
value->collection->state = IPP_STATE_IDLE;
- if (ippWriteIO(dst, cb, 1, ipp,
- value->collection) == IPP_STATE_ERROR)
+ if (ippWriteIO(dst, cb, 1, ipp, value->collection) == IPP_STATE_ERROR)
{
DEBUG_puts("1ippWriteIO: Unable to write collection value");
_cupsBufferRelease((char *)buffer);
break;
default :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if (i)
{
- /*
- * Arrays and sets are done by sending additional
- * values with a zero-length name...
- */
-
+ // Arrays and sets are done by sending additional values with a zero-length name...
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
*bufptr++ = 0;
}
- /*
- * An unknown value might some new value that a
- * vendor has come up with. It consists of a
- * 2-byte length and the bytes in the unknown
- * value buffer.
- */
-
+ // An unknown value might some new value that a
+ // vendor has come up with. It consists of a
+ // 2-byte length and the bytes in the unknown
+ // value buffer.
n = value->unknown.length;
if (n > (IPP_BUF_SIZE - 2))
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
- DEBUG_puts("1ippWriteIO: Could not write IPP "
- "attribute...");
+ DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
bufptr = buffer;
}
- /* Length of unknown value */
+ // Length of unknown value
*bufptr++ = (ipp_uchar_t)(n >> 8);
*bufptr++ = (ipp_uchar_t)n;
- /* Value */
+ // Value
if (n > 0)
{
memcpy(bufptr, value->unknown.data, (size_t)n);
break;
}
- /*
- * Write the data out...
- */
-
+ // Write the data out...
if (bufptr > buffer)
{
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
DEBUG_printf("2ippWriteIO: wrote %d bytes", (int)(bufptr - buffer));
}
- /*
- * If blocking is disabled and we aren't at the end of the attribute
- * list, stop here...
- */
-
+ // If blocking is disabled and we aren't at the end of the attribute list, stop here...
if (!blocking && ipp->current)
break;
}
if (ipp->current == NULL)
{
- /*
- * Done with all of the attributes; add the end-of-attributes
- * tag or end-collection attribute...
- */
-
+ // Done with all of the attributes; add the end-of-attributes tag or end-collection attribute...
if (parent == NULL)
{
buffer[0] = IPP_TAG_END;
else
{
buffer[0] = IPP_TAG_END_COLLECTION;
- buffer[1] = 0; /* empty name */
+ buffer[1] = 0; // empty name
buffer[2] = 0;
- buffer[3] = 0; /* empty value */
+ buffer[3] = 0; // empty value
buffer[4] = 0;
n = 5;
}
break;
default :
- break; /* anti-compiler-warning-code */
+ break; // anti-compiler-warning-code
}
_cupsBufferRelease((char *)buffer);
}
-/*
- * 'ipp_add_attr()' - Add a new attribute to the message.
- */
+//
+// 'ipp_add_attr()' - Add a new attribute to the message.
+//
-static ipp_attribute_t * /* O - New attribute */
-ipp_add_attr(ipp_t *ipp, /* I - IPP message */
- const char *name, /* I - Attribute name or NULL */
- ipp_tag_t group_tag, /* I - Group tag or IPP_TAG_ZERO */
- ipp_tag_t value_tag, /* I - Value tag or IPP_TAG_ZERO */
- int num_values) /* I - Number of values */
+static ipp_attribute_t * // O - New attribute
+ipp_add_attr(ipp_t *ipp, // I - IPP message
+ const char *name, // I - Attribute name or NULL
+ ipp_tag_t group_tag, // I - Group tag or IPP_TAG_ZERO
+ ipp_tag_t value_tag, // I - Value tag or IPP_TAG_ZERO
+ int num_values) // I - Number of values
{
- int alloc_values; /* Number of values to allocate */
- ipp_attribute_t *attr; /* New attribute */
+ int alloc_values; // Number of values to allocate
+ ipp_attribute_t *attr; // New attribute
DEBUG_printf("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, num_values=%d)", (void *)ipp, name, group_tag, value_tag, num_values);
- /*
- * Range check input...
- */
-
+ // Range check input...
if (!ipp || num_values < 0)
return (NULL);
- /*
- * Allocate memory, rounding the allocation up as needed...
- */
-
+ // Allocate memory, rounding the allocation up as needed...
if (num_values <= 1)
alloc_values = 1;
else
if (attr)
{
- /*
- * Initialize attribute...
- */
-
+ // Initialize attribute...
DEBUG_printf("4debug_alloc: %p %s %s%s (%d values)", (void *)attr, name, num_values > 1 ? "1setOf " : "", ippTagString(value_tag), num_values);
if (name)
attr->value_tag = value_tag;
attr->num_values = num_values;
- /*
- * Add it to the end of the linked list...
- */
-
+ // Add it to the end of the linked list...
if (ipp->last)
ipp->last->next = attr;
else
}
-/*
- * 'ipp_free_values()' - Free attribute values.
- */
+//
+// 'ipp_free_values()' - Free attribute values.
+//
static void
-ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */
- int element,/* I - First value to free */
- int count) /* I - Number of values to free */
+ipp_free_values(ipp_attribute_t *attr, // I - Attribute to free values from
+ int element,// I - First value to free
+ int count) // I - Number of values to free
{
- int i; /* Looping var */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ _ipp_value_t *value; // Current value
DEBUG_printf("4ipp_free_values(attr=%p, element=%d, count=%d)", (void *)attr, element, count);
if (!(attr->value_tag & IPP_TAG_CUPS_CONST))
{
- /*
- * Free values as needed...
- */
-
+ // Free values as needed...
switch (attr->value_tag)
{
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
- if (element == 0 && count == attr->num_values &&
- attr->values[0].string.language)
+ if (element == 0 && count == attr->num_values && attr->values[0].string.language)
{
_cupsStrFree(attr->values[0].string.language);
attr->values[0].string.language = NULL;
}
- /* Fall through to other string values */
+ // Fall through to other string values
case IPP_TAG_TEXT :
case IPP_TAG_NAME :
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- for (i = count, value = attr->values + element;
- i > 0;
- i --, value ++)
+ for (i = count, value = attr->values + element; i > 0; i --, value ++)
{
_cupsStrFree(value->string.text);
value->string.text = NULL;
break;
case IPP_TAG_BEGIN_COLLECTION :
- for (i = count, value = attr->values + element;
- i > 0;
- i --, value ++)
+ for (i = count, value = attr->values + element; i > 0; i --, value ++)
{
ippDelete(value->collection);
value->collection = NULL;
case IPP_TAG_STRING :
default :
- for (i = count, value = attr->values + element;
- i > 0;
- i --, value ++)
+ for (i = count, value = attr->values + element; i > 0; i --, value ++)
{
if (value->unknown.data)
{
}
}
- /*
- * If we are not freeing values from the end, move the remaining values up...
- */
-
+ // If we are not freeing values from the end, move the remaining values up...
if ((element + count) < attr->num_values)
- memmove(attr->values + element, attr->values + element + count,
- (size_t)(attr->num_values - count - element) * sizeof(_ipp_value_t));
+ memmove(attr->values + element, attr->values + element + count, (size_t)(attr->num_values - count - element) * sizeof(_ipp_value_t));
attr->num_values -= count;
}
-/*
- * 'ipp_get_code()' - Convert a C locale/charset name into an IPP language/charset code.
- *
- * This typically converts strings of the form "ll_CC", "ll-REGION", and "CHARSET_NUMBER"
- * to "ll-cc", "ll-region", and "charset-number", respectively.
- */
+//
+// 'ipp_get_code()' - Convert a C locale/charset name into an IPP language/charset code.
+//
+// This typically converts strings of the form "ll_CC", "ll-REGION", and "CHARSET_NUMBER"
+// to "ll-cc", "ll-region", and "charset-number", respectively.
+//
-static char * /* O - Language code string */
-ipp_get_code(const char *value, /* I - Locale/charset string */
- char *buffer, /* I - String buffer */
- size_t bufsize) /* I - Size of string buffer */
+static char * // O - Language code string
+ipp_get_code(const char *value, // I - Locale/charset string
+ char *buffer, // I - String buffer
+ size_t bufsize) // I - Size of string buffer
{
- char *bufptr, /* Pointer into buffer */
- *bufend; /* End of buffer */
-
+ char *bufptr, // Pointer into buffer
+ *bufend; // End of buffer
- /*
- * Convert values to lowercase and change _ to - as needed...
- */
- for (bufptr = buffer, bufend = buffer + bufsize - 1;
- *value && bufptr < bufend;
- value ++)
+ // Convert values to lowercase and change _ to - as needed...
+ for (bufptr = buffer, bufend = buffer + bufsize - 1; *value && bufptr < bufend; value ++)
+ {
if (*value == '_')
*bufptr++ = '-';
else
*bufptr++ = (char)_cups_tolower(*value);
-
+ }
*bufptr = '\0';
- /*
- * Return the converted string...
- */
-
+ // Return the converted string...
return (buffer);
}
-/*
- * 'ipp_lang_code()' - Convert a C locale name into an IPP language code.
- *
- * This typically converts strings of the form "ll_CC" and "ll-REGION" to "ll-cc" and
- * "ll-region", respectively. It also converts the "C" (POSIX) locale to "en".
- */
+//
+// 'ipp_lang_code()' - Convert a C locale name into an IPP language code.
+//
+// This typically converts strings of the form "ll_CC" and "ll-REGION" to "ll-cc" and
+// "ll-region", respectively. It also converts the "C" (POSIX) locale to "en".
+//
-static char * /* O - Language code string */
-ipp_lang_code(const char *locale, /* I - Locale string */
- char *buffer, /* I - String buffer */
- size_t bufsize) /* I - Size of string buffer */
+static char * // O - Language code string
+ipp_lang_code(const char *locale, // I - Locale string
+ char *buffer, // I - String buffer
+ size_t bufsize) // I - Size of string buffer
{
- /*
- * Map POSIX ("C") locale to generic English, otherwise convert the locale string as-is.
- */
-
+ // Map POSIX ("C") locale to generic English, otherwise convert the locale string as-is.
if (!_cups_strcasecmp(locale, "c"))
{
cupsCopyString(buffer, "en", bufsize);
return (buffer);
}
else
+ {
return (ipp_get_code(locale, buffer, bufsize));
+ }
}
-/*
- * 'ipp_length()' - Compute the length of an IPP message or collection value.
- */
+//
+// 'ipp_length()' - Compute the length of an IPP message or collection value.
+//
-static size_t /* O - Size of IPP message */
-ipp_length(ipp_t *ipp, /* I - IPP message or collection */
- int collection) /* I - 1 if a collection, 0 otherwise */
+static size_t // O - Size of IPP message
+ipp_length(ipp_t *ipp, // I - IPP message or collection
+ int collection) // I - 1 if a collection, 0 otherwise
{
- int i; /* Looping var */
- size_t bytes; /* Number of bytes */
- ipp_attribute_t *attr; /* Current attribute */
- ipp_tag_t group; /* Current group */
- _ipp_value_t *value; /* Current value */
+ int i; // Looping var
+ size_t bytes; // Number of bytes
+ ipp_attribute_t *attr; // Current attribute
+ ipp_tag_t group; // Current group
+ _ipp_value_t *value; // Current value
DEBUG_printf("3ipp_length(ipp=%p, collection=%d)", (void *)ipp, collection);
return (0);
}
- /*
- * Start with 8 bytes for the IPP message header...
- */
-
+ // Start with 8 bytes for the IPP message header...
bytes = collection ? 0 : 8;
- /*
- * Then add the lengths of each attribute...
- */
-
+ // Then add the lengths of each attribute...
group = IPP_TAG_ZERO;
for (attr = ipp->attrs; attr != NULL; attr = attr->next)
if (group == IPP_TAG_ZERO)
continue;
- bytes ++; /* Group tag */
+ bytes ++; // Group tag
}
if (!attr->name)
DEBUG_printf("5ipp_length: attr->name=\"%s\", attr->num_values=%d, bytes=" CUPS_LLFMT, attr->name, attr->num_values, CUPS_LLCAST bytes);
if ((attr->value_tag & ~IPP_TAG_CUPS_CONST) < IPP_TAG_EXTENSION)
- bytes += (size_t)attr->num_values;/* Value tag for each value */
+ bytes += (size_t)attr->num_values;// Value tag for each value
else
bytes += (size_t)(5 * attr->num_values);
- /* Value tag for each value */
+ // Value tag for each value
bytes += (size_t)(2 * attr->num_values);
- /* Name lengths */
- bytes += strlen(attr->name); /* Name */
+ // Name lengths
+ bytes += strlen(attr->name); // Name
bytes += (size_t)(2 * attr->num_values);
- /* Value lengths */
+ // Value lengths
if (collection)
- bytes += 5; /* Add membername overhead */
+ bytes += 5; // Add membername overhead
switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
{
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
+ {
if (value->string.text)
bytes += strlen(value->string.text);
+ }
break;
case IPP_TAG_DATE :
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
bytes += (size_t)(4 * attr->num_values);
- /* Charset + text length */
+ // Charset + text length
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
{
if (value->string.language)
bytes += strlen(value->string.language);
break;
case IPP_TAG_BEGIN_COLLECTION :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
bytes += ipp_length(value->collection, 1);
break;
default :
- for (i = 0, value = attr->values;
- i < attr->num_values;
- i ++, value ++)
+ for (i = 0, value = attr->values; i < attr->num_values; i ++, value ++)
bytes += (size_t)value->unknown.length;
break;
}
}
- /*
- * Finally, add 1 byte for the "end of attributes" tag or 5 bytes
- * for the "end of collection" tag and return...
- */
-
+ // Finally, add 1 byte for the "end of attributes" tag or 5 bytes for the "end of collection" tag and return...
if (collection)
bytes += 5;
else
}
-/*
- * 'ipp_read_http()' - Semi-blocking read on a HTTP connection...
- */
+//
+// 'ipp_read_http()' - Semi-blocking read on a HTTP connection...
+//
-static ssize_t /* O - Number of bytes read */
-ipp_read_http(http_t *http, /* I - Client connection */
- ipp_uchar_t *buffer, /* O - Buffer for data */
- size_t length) /* I - Total length */
+static ssize_t // O - Number of bytes read
+ipp_read_http(http_t *http, // I - Client connection
+ ipp_uchar_t *buffer, // O - Buffer for data
+ size_t length) // I - Total length
{
- ssize_t tbytes, /* Total bytes read */
- bytes; /* Bytes read this pass */
+ ssize_t tbytes, // Total bytes read
+ bytes; // Bytes read this pass
DEBUG_printf("7ipp_read_http(http=%p, buffer=%p, length=%d)", (void *)http, (void *)buffer, (int)length);
- /*
- * Loop until all bytes are read...
- */
-
- for (tbytes = 0, bytes = 0;
- tbytes < (int)length;
- tbytes += bytes, buffer += bytes)
+ // Loop until all bytes are read...
+ for (tbytes = 0, bytes = 0; tbytes < (int)length; tbytes += bytes, buffer += bytes)
{
DEBUG_printf("9ipp_read_http: tbytes=" CUPS_LLFMT ", http->state=%d", CUPS_LLCAST tbytes, http->state);
if (http->used == 0 && !http->blocking)
{
- /*
- * Wait up to 10 seconds for more data on non-blocking sockets...
- */
-
+ // Wait up to 10 seconds for more data on non-blocking sockets...
if (!httpWait(http, 10000))
{
- /*
- * Signal no data...
- */
-
+ // Signal no data...
bytes = -1;
break;
}
}
else if (http->used == 0 && http->timeout_value > 0)
{
- /*
- * Wait up to timeout seconds for more data on blocking sockets...
- */
-
+ // Wait up to timeout seconds for more data on blocking sockets...
if (!httpWait(http, (int)(1000 * http->timeout_value)))
{
- /*
- * Signal no data...
- */
-
+ // Signal no data...
bytes = -1;
break;
}
break;
bytes = 0;
-#endif /* _WIN32 */
+#endif // _WIN32
}
else if (bytes == 0)
+ {
break;
+ }
}
- /*
- * Return the number of bytes read...
- */
-
+ // Return the number of bytes read...
if (tbytes == 0 && bytes < 0)
tbytes = -1;
}
-/*
- * 'ipp_read_file()' - Read IPP data from a file.
- */
+//
+// 'ipp_read_file()' - Read IPP data from a file.
+//
-static ssize_t /* O - Number of bytes read */
-ipp_read_file(int *fd, /* I - File descriptor */
- ipp_uchar_t *buffer, /* O - Read buffer */
- size_t length) /* I - Number of bytes to read */
+static ssize_t // O - Number of bytes read
+ipp_read_file(int *fd, // I - File descriptor
+ ipp_uchar_t *buffer, // O - Read buffer
+ size_t length) // I - Number of bytes to read
{
#ifdef _WIN32
return ((ssize_t)read(*fd, buffer, (unsigned)length));
#else
return (read(*fd, buffer, length));
-#endif /* _WIN32 */
+#endif // _WIN32
}
-/*
- * 'ipp_set_error()' - Set a formatted, localized error string.
- */
+//
+// 'ipp_set_error()' - Set a formatted, localized error string.
+//
static void
-ipp_set_error(ipp_status_t status, /* I - Status code */
- const char *format, /* I - Printf-style error string */
- ...) /* I - Additional arguments as needed */
+ipp_set_error(ipp_status_t status, // I - Status code
+ const char *format, // I - Printf-style error string
+ ...) // I - Additional arguments as needed
{
- va_list ap; /* Pointer to additional args */
- char buffer[2048]; /* Message buffer */
+ va_list ap; // Pointer to additional args
+ char buffer[2048]; // Message buffer
cups_lang_t *lang = cupsLangDefault();
- /* Current language */
+ // Current language
va_start(ap, format);
}
-/*
- * 'ipp_set_value()' - Get the value element from an attribute, expanding it as
- * needed.
- */
+//
+// 'ipp_set_value()' - Get the value element from an attribute, expanding it as
+// needed.
+//
-static _ipp_value_t * /* O - IPP value element or NULL on error */
-ipp_set_value(ipp_t *ipp, /* IO - IPP message */
- ipp_attribute_t **attr, /* IO - IPP attribute */
- int element) /* I - Value number (0-based) */
+static _ipp_value_t * // O - IPP value element or NULL on error
+ipp_set_value(ipp_t *ipp, // IO - IPP message
+ ipp_attribute_t **attr, // IO - IPP attribute
+ int element) // I - Value number (0-based)
{
- ipp_attribute_t *temp, /* New attribute pointer */
- *current, /* Current attribute in list */
- *prev; /* Previous attribute in list */
- int alloc_values; /* Allocated values */
-
+ ipp_attribute_t *temp, // New attribute pointer
+ *current, // Current attribute in list
+ *prev; // Previous attribute in list
+ int alloc_values; // Allocated values
- /*
- * If we are setting an existing value element, return it...
- */
+ // If we are setting an existing value element, return it...
temp = *attr;
if (temp->num_values <= 1)
alloc_values = 1;
else
- alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) &
- ~(IPP_MAX_VALUES - 1);
+ alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
if (element < alloc_values)
{
return (temp->values + element);
}
- /*
- * Otherwise re-allocate the attribute - we allocate in groups of IPP_MAX_VALUE
- * values when num_values > 1.
- */
-
+ // Otherwise re-allocate the attribute - we allocate in groups of IPP_MAX_VALUE values when num_values > 1.
if (alloc_values < IPP_MAX_VALUES)
alloc_values = IPP_MAX_VALUES;
else
DEBUG_printf("4ipp_set_value: Reallocating for up to %d values.", alloc_values);
- /*
- * Reallocate memory...
- */
-
+ // Reallocate memory...
if ((temp = realloc(temp, sizeof(ipp_attribute_t) + (size_t)(alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
{
_cupsSetHTTPError(HTTP_STATUS_ERROR);
return (NULL);
}
- /*
- * Zero the new memory...
- */
-
+ // Zero the new memory...
memset(temp->values + temp->num_values, 0, (size_t)(alloc_values - temp->num_values) * sizeof(_ipp_value_t));
if (temp != *attr)
{
- /*
- * Reset pointers in the list...
- */
-
+ // Reset pointers in the list...
#ifndef __clang_analyzer__
DEBUG_printf("4debug_free: %p %s", (void *)*attr, temp->name);
-#endif /* !__clang_analyzer__ */
+#endif // !__clang_analyzer__
DEBUG_printf("4debug_alloc: %p %s %s%s (%d)", (void *)temp, temp->name, temp->num_values > 1 ? "1setOf " : "", ippTagString(temp->value_tag), temp->num_values);
if (ipp->current == *attr && ipp->prev)
{
- /*
- * Use current "previous" pointer...
- */
-
+ // Use current "previous" pointer...
prev = ipp->prev;
}
else
{
- /*
- * Find this attribute in the linked list...
- */
-
- for (prev = NULL, current = ipp->attrs;
- current && current != *attr;
- prev = current, current = current->next);
+ // Find this attribute in the linked list...
+ for (prev = NULL, current = ipp->attrs; current && current != *attr; prev = current, current = current->next)
+ ; // Loop until we find the attribute
if (!current)
{
- /*
- * This is a serious error!
- */
-
+ // This is a serious error!
*attr = temp;
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
- _("IPP attribute is not a member of the message."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP attribute is not a member of the message."), 1);
DEBUG_puts("4ipp_set_value: Unable to find attribute in message.");
return (NULL);
}
*attr = temp;
}
- /*
- * Return the value element...
- */
-
+ // Return the value element...
if (element >= temp->num_values)
temp->num_values = element + 1;
}
-/*
- * 'ipp_write_file()' - Write IPP data to a file.
- */
+//
+// 'ipp_write_file()' - Write IPP data to a file.
+//
-static ssize_t /* O - Number of bytes written */
-ipp_write_file(int *fd, /* I - File descriptor */
- ipp_uchar_t *buffer, /* I - Data to write */
- size_t length) /* I - Number of bytes to write */
+static ssize_t // O - Number of bytes written
+ipp_write_file(int *fd, // I - File descriptor
+ ipp_uchar_t *buffer, // I - Data to write
+ size_t length) // I - Number of bytes to write
{
#ifdef _WIN32
return ((ssize_t)write(*fd, buffer, (unsigned)length));
#else
return (write(*fd, buffer, length));
-#endif /* _WIN32 */
+#endif // _WIN32
}
-/*
- * Internet Printing Protocol definitions for CUPS.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Internet Printing Protocol definitions for CUPS.
+//
+// Copyright © 2023 by OpenPrinting.
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_IPP_H_
# define _CUPS_IPP_H_
-
-/*
- * Include necessary headers...
- */
-
# include "http.h"
# include <stdarg.h>
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * IPP version string...
- */
-
-# define IPP_VERSION "\002\001"
-
-/*
- * IPP registered port number...
- *
- * Note: Applications should never use IPP_PORT, but instead use the
- * ippPort() function to allow overrides via the IPP_PORT environment
- * variable and services file if needed!
- */
-
-# define IPP_PORT 631
-
-/*
- * Common limits...
- */
-
-# define IPP_MAX_CHARSET 64 /* Maximum length of charset values w/nul */
-# define IPP_MAX_KEYWORD 256 /* Maximum length of keyword values w/nul */
-# define IPP_MAX_LANGUAGE 64 /* Maximum length of naturalLanguage values w/nul */
-# define IPP_MAX_LENGTH 32767 /* Maximum size of any single value */
-# define IPP_MAX_MIMETYPE 256 /* Maximum length of mimeMediaType values w/nul */
-# define IPP_MAX_NAME 256 /* Maximum length of common name values w/nul */
-# define IPP_MAX_OCTETSTRING 1023 /* Maximum length of octetString values w/o nul */
-# define IPP_MAX_TEXT 1024 /* Maximum length of text values w/nul */
-# define IPP_MAX_URI 1024 /* Maximum length of uri values w/nul */
-# define IPP_MAX_URISCHEME 64 /* Maximum length of uriScheme values w/nul */
-# define IPP_MAX_VALUES 8 /* Power-of-2 allocation increment */
-
-/*
- * Macro to flag a text string attribute as "const" (static storage) vs.
- * allocated.
- */
+//
+// Constants...
+//
# define IPP_CONST_TAG(x) (ipp_tag_t)(IPP_TAG_CUPS_CONST | (x))
+ // Flag a text string attribute as "const" (static storage) vs. allocated.
+# define IPP_MAX_CHARSET 64 // Maximum length of charset values w/nul
+# define IPP_MAX_KEYWORD 256 // Maximum length of keyword values w/nul
+# define IPP_MAX_LANGUAGE 64 // Maximum length of naturalLanguage values w/nul
+# define IPP_MAX_LENGTH 32767 // Maximum size of any single value
+# define IPP_MAX_MIMETYPE 256 // Maximum length of mimeMediaType values w/nul
+# define IPP_MAX_NAME 256 // Maximum length of common name values w/nul
+# define IPP_MAX_OCTETSTRING 1023 // Maximum length of octetString values w/o nul
+# define IPP_MAX_TEXT 1024 // Maximum length of text values w/nul
+# define IPP_MAX_URI 1024 // Maximum length of uri values w/nul
+# define IPP_MAX_URISCHEME 64 // Maximum length of uriScheme values w/nul
+# define IPP_MAX_VALUES 8 // Power-of-2 allocation increment
+# define IPP_PORT 631 // Registered port number; use @link ippGetPort@ instead
+# define IPP_VERSION "\002\001"
+ // IPP version string...
-/*
- * Types and structures...
- */
+//
+// Types and structures...
+//
-typedef enum ipp_dstate_e /**** Document states @exclude all@ ****/
+typedef enum ipp_dstate_e // Document states @exclude all@
{
- IPP_DSTATE_PENDING = 3, /* Document is pending */
- IPP_DSTATE_PROCESSING = 5, /* Document is processing */
- IPP_DSTATE_CANCELED = 7, /* Document is canceled */
- IPP_DSTATE_ABORTED, /* Document is aborted */
- IPP_DSTATE_COMPLETED /* Document is completed */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_DOCUMENT_PENDING IPP_DSTATE_PENDING
-# define IPP_DOCUMENT_PROCESSING IPP_DSTATE_PROCESSING
-# define IPP_DOCUMENT_CANCELED IPP_DSTATE_CANCELED
-# define IPP_DOCUMENT_ABORTED IPP_DSTATE_ABORTED
-# define IPP_DOCUMENT_COMPLETED IPP_DSTATE_COMPLETED
-# endif /* !_CUPS_NO_DEPRECATED */
+ IPP_DSTATE_PENDING = 3, // Document is pending
+ IPP_DSTATE_PROCESSING = 5, // Document is processing
+ IPP_DSTATE_CANCELED = 7, // Document is canceled
+ IPP_DSTATE_ABORTED, // Document is aborted
+ IPP_DSTATE_COMPLETED // Document is completed
} ipp_dstate_t;
-typedef enum ipp_finishings_e /**** Finishings values ****/
+typedef enum ipp_finishings_e // Finishings values
{
- IPP_FINISHINGS_NONE = 3, /* No finishing */
- IPP_FINISHINGS_STAPLE, /* Staple (any location/method) */
- IPP_FINISHINGS_PUNCH, /* Punch (any location/count) */
- IPP_FINISHINGS_COVER, /* Add cover */
- IPP_FINISHINGS_BIND, /* Bind */
- IPP_FINISHINGS_SADDLE_STITCH, /* Staple interior */
- IPP_FINISHINGS_EDGE_STITCH, /* Stitch along any side */
- IPP_FINISHINGS_FOLD, /* Fold (any type) */
- IPP_FINISHINGS_TRIM, /* Trim (any type) */
- IPP_FINISHINGS_BALE, /* Bale (any type) */
- IPP_FINISHINGS_BOOKLET_MAKER, /* Fold to make booklet */
- IPP_FINISHINGS_JOG_OFFSET, /* Offset for binding (any type) */
- IPP_FINISHINGS_COAT, /* Apply protective liquid or powder coating */
- IPP_FINISHINGS_LAMINATE, /* Apply protective (solid) material */
- IPP_FINISHINGS_STAPLE_TOP_LEFT = 20, /* Staple top left corner */
- IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, /* Staple bottom left corner */
- IPP_FINISHINGS_STAPLE_TOP_RIGHT, /* Staple top right corner */
- IPP_FINISHINGS_STAPLE_BOTTOM_RIGHT, /* Staple bottom right corner */
- IPP_FINISHINGS_EDGE_STITCH_LEFT, /* Stitch along left side */
- IPP_FINISHINGS_EDGE_STITCH_TOP, /* Stitch along top edge */
- IPP_FINISHINGS_EDGE_STITCH_RIGHT, /* Stitch along right side */
- IPP_FINISHINGS_EDGE_STITCH_BOTTOM, /* Stitch along bottom edge */
- IPP_FINISHINGS_STAPLE_DUAL_LEFT, /* Two staples on left */
- IPP_FINISHINGS_STAPLE_DUAL_TOP, /* Two staples on top */
- IPP_FINISHINGS_STAPLE_DUAL_RIGHT, /* Two staples on right */
- IPP_FINISHINGS_STAPLE_DUAL_BOTTOM, /* Two staples on bottom */
- IPP_FINISHINGS_STAPLE_TRIPLE_LEFT, /* Three staples on left */
- IPP_FINISHINGS_STAPLE_TRIPLE_TOP, /* Three staples on top */
- IPP_FINISHINGS_STAPLE_TRIPLE_RIGHT, /* Three staples on right */
- IPP_FINISHINGS_STAPLE_TRIPLE_BOTTOM, /* Three staples on bottom */
- IPP_FINISHINGS_BIND_LEFT = 50, /* Bind on left */
- IPP_FINISHINGS_BIND_TOP, /* Bind on top */
- IPP_FINISHINGS_BIND_RIGHT, /* Bind on right */
- IPP_FINISHINGS_BIND_BOTTOM, /* Bind on bottom */
- IPP_FINISHINGS_TRIM_AFTER_PAGES = 60, /* Trim output after each page */
- IPP_FINISHINGS_TRIM_AFTER_DOCUMENTS, /* Trim output after each document */
- IPP_FINISHINGS_TRIM_AFTER_COPIES, /* Trim output after each copy */
- IPP_FINISHINGS_TRIM_AFTER_JOB, /* Trim output after job */
- IPP_FINISHINGS_PUNCH_TOP_LEFT = 70, /* Punch 1 hole top left */
- IPP_FINISHINGS_PUNCH_BOTTOM_LEFT, /* Punch 1 hole bottom left */
- IPP_FINISHINGS_PUNCH_TOP_RIGHT, /* Punch 1 hole top right */
- IPP_FINISHINGS_PUNCH_BOTTOM_RIGHT, /* Punch 1 hole bottom right */
- IPP_FINISHINGS_PUNCH_DUAL_LEFT, /* Punch 2 holes left side */
- IPP_FINISHINGS_PUNCH_DUAL_TOP, /* Punch 2 holes top edge */
- IPP_FINISHINGS_PUNCH_DUAL_RIGHT, /* Punch 2 holes right side */
- IPP_FINISHINGS_PUNCH_DUAL_BOTTOM, /* Punch 2 holes bottom edge */
- IPP_FINISHINGS_PUNCH_TRIPLE_LEFT, /* Punch 3 holes left side */
- IPP_FINISHINGS_PUNCH_TRIPLE_TOP, /* Punch 3 holes top edge */
- IPP_FINISHINGS_PUNCH_TRIPLE_RIGHT, /* Punch 3 holes right side */
- IPP_FINISHINGS_PUNCH_TRIPLE_BOTTOM, /* Punch 3 holes bottom edge */
- IPP_FINISHINGS_PUNCH_QUAD_LEFT, /* Punch 4 holes left side */
- IPP_FINISHINGS_PUNCH_QUAD_TOP, /* Punch 4 holes top edge */
- IPP_FINISHINGS_PUNCH_QUAD_RIGHT, /* Punch 4 holes right side */
- IPP_FINISHINGS_PUNCH_QUAD_BOTTOM, /* Punch 4 holes bottom edge */
- IPP_FINISHINGS_PUNCH_MULTIPLE_LEFT, /* Punch multiple holes left side */
- IPP_FINISHINGS_PUNCH_MULTIPLE_TOP, /* Punch multiple holes top edge */
- IPP_FINISHINGS_PUNCH_MULTIPLE_RIGHT, /* Punch multiple holes right side */
- IPP_FINISHINGS_PUNCH_MULTIPLE_BOTTOM, /* Punch multiple holes bottom edge */
- IPP_FINISHINGS_FOLD_ACCORDION = 90, /* Accordion-fold the paper vertically into four sections */
- IPP_FINISHINGS_FOLD_DOUBLE_GATE, /* Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically */
- IPP_FINISHINGS_FOLD_GATE, /* Fold the top and bottom quarters of the paper towards the midline */
- IPP_FINISHINGS_FOLD_HALF, /* Fold the paper in half vertically */
- IPP_FINISHINGS_FOLD_HALF_Z, /* Fold the paper in half horizontally, then Z-fold the paper vertically */
- IPP_FINISHINGS_FOLD_LEFT_GATE, /* Fold the top quarter of the paper towards the midline */
+ IPP_FINISHINGS_NONE = 3, // No finishing
+ IPP_FINISHINGS_STAPLE, // Staple (any location/method)
+ IPP_FINISHINGS_PUNCH, // Punch (any location/count)
+ IPP_FINISHINGS_COVER, // Add cover
+ IPP_FINISHINGS_BIND, // Bind
+ IPP_FINISHINGS_SADDLE_STITCH, // Staple interior
+ IPP_FINISHINGS_EDGE_STITCH, // Stitch along any side
+ IPP_FINISHINGS_FOLD, // Fold (any type)
+ IPP_FINISHINGS_TRIM, // Trim (any type)
+ IPP_FINISHINGS_BALE, // Bale (any type)
+ IPP_FINISHINGS_BOOKLET_MAKER, // Fold to make booklet
+ IPP_FINISHINGS_JOG_OFFSET, // Offset for binding (any type)
+ IPP_FINISHINGS_COAT, // Apply protective liquid or powder coating
+ IPP_FINISHINGS_LAMINATE, // Apply protective (solid) material
+ IPP_FINISHINGS_STAPLE_TOP_LEFT = 20, // Staple top left corner
+ IPP_FINISHINGS_STAPLE_BOTTOM_LEFT, // Staple bottom left corner
+ IPP_FINISHINGS_STAPLE_TOP_RIGHT, // Staple top right corner
+ IPP_FINISHINGS_STAPLE_BOTTOM_RIGHT, // Staple bottom right corner
+ IPP_FINISHINGS_EDGE_STITCH_LEFT, // Stitch along left side
+ IPP_FINISHINGS_EDGE_STITCH_TOP, // Stitch along top edge
+ IPP_FINISHINGS_EDGE_STITCH_RIGHT, // Stitch along right side
+ IPP_FINISHINGS_EDGE_STITCH_BOTTOM, // Stitch along bottom edge
+ IPP_FINISHINGS_STAPLE_DUAL_LEFT, // Two staples on left
+ IPP_FINISHINGS_STAPLE_DUAL_TOP, // Two staples on top
+ IPP_FINISHINGS_STAPLE_DUAL_RIGHT, // Two staples on right
+ IPP_FINISHINGS_STAPLE_DUAL_BOTTOM, // Two staples on bottom
+ IPP_FINISHINGS_STAPLE_TRIPLE_LEFT, // Three staples on left
+ IPP_FINISHINGS_STAPLE_TRIPLE_TOP, // Three staples on top
+ IPP_FINISHINGS_STAPLE_TRIPLE_RIGHT, // Three staples on right
+ IPP_FINISHINGS_STAPLE_TRIPLE_BOTTOM, // Three staples on bottom
+ IPP_FINISHINGS_BIND_LEFT = 50, // Bind on left
+ IPP_FINISHINGS_BIND_TOP, // Bind on top
+ IPP_FINISHINGS_BIND_RIGHT, // Bind on right
+ IPP_FINISHINGS_BIND_BOTTOM, // Bind on bottom
+ IPP_FINISHINGS_TRIM_AFTER_PAGES = 60, // Trim output after each page
+ IPP_FINISHINGS_TRIM_AFTER_DOCUMENTS, // Trim output after each document
+ IPP_FINISHINGS_TRIM_AFTER_COPIES, // Trim output after each copy
+ IPP_FINISHINGS_TRIM_AFTER_JOB, // Trim output after job
+ IPP_FINISHINGS_PUNCH_TOP_LEFT = 70, // Punch 1 hole top left
+ IPP_FINISHINGS_PUNCH_BOTTOM_LEFT, // Punch 1 hole bottom left
+ IPP_FINISHINGS_PUNCH_TOP_RIGHT, // Punch 1 hole top right
+ IPP_FINISHINGS_PUNCH_BOTTOM_RIGHT, // Punch 1 hole bottom right
+ IPP_FINISHINGS_PUNCH_DUAL_LEFT, // Punch 2 holes left side
+ IPP_FINISHINGS_PUNCH_DUAL_TOP, // Punch 2 holes top edge
+ IPP_FINISHINGS_PUNCH_DUAL_RIGHT, // Punch 2 holes right side
+ IPP_FINISHINGS_PUNCH_DUAL_BOTTOM, // Punch 2 holes bottom edge
+ IPP_FINISHINGS_PUNCH_TRIPLE_LEFT, // Punch 3 holes left side
+ IPP_FINISHINGS_PUNCH_TRIPLE_TOP, // Punch 3 holes top edge
+ IPP_FINISHINGS_PUNCH_TRIPLE_RIGHT, // Punch 3 holes right side
+ IPP_FINISHINGS_PUNCH_TRIPLE_BOTTOM, // Punch 3 holes bottom edge
+ IPP_FINISHINGS_PUNCH_QUAD_LEFT, // Punch 4 holes left side
+ IPP_FINISHINGS_PUNCH_QUAD_TOP, // Punch 4 holes top edge
+ IPP_FINISHINGS_PUNCH_QUAD_RIGHT, // Punch 4 holes right side
+ IPP_FINISHINGS_PUNCH_QUAD_BOTTOM, // Punch 4 holes bottom edge
+ IPP_FINISHINGS_PUNCH_MULTIPLE_LEFT, // Punch multiple holes left side
+ IPP_FINISHINGS_PUNCH_MULTIPLE_TOP, // Punch multiple holes top edge
+ IPP_FINISHINGS_PUNCH_MULTIPLE_RIGHT, // Punch multiple holes right side
+ IPP_FINISHINGS_PUNCH_MULTIPLE_BOTTOM, // Punch multiple holes bottom edge
+ IPP_FINISHINGS_FOLD_ACCORDION = 90, // Accordion-fold the paper vertically into four sections
+ IPP_FINISHINGS_FOLD_DOUBLE_GATE, // Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically
+ IPP_FINISHINGS_FOLD_GATE, // Fold the top and bottom quarters of the paper towards the midline
+ IPP_FINISHINGS_FOLD_HALF, // Fold the paper in half vertically
+ IPP_FINISHINGS_FOLD_HALF_Z, // Fold the paper in half horizontally, then Z-fold the paper vertically
+ IPP_FINISHINGS_FOLD_LEFT_GATE, // Fold the top quarter of the paper towards the midline
IPP_FINISHINGS_FOLD_LETTER, /* Fold the paper into three sections vertically; sometimes also known as a C fold*/
- IPP_FINISHINGS_FOLD_PARALLEL, /* Fold the paper in half vertically two times, yielding four sections */
- IPP_FINISHINGS_FOLD_POSTER, /* Fold the paper in half horizontally and vertically; sometimes also called a cross fold */
- IPP_FINISHINGS_FOLD_RIGHT_GATE, /* Fold the bottom quarter of the paper towards the midline */
- IPP_FINISHINGS_FOLD_Z, /* Fold the paper vertically into three sections, forming a Z */
- IPP_FINISHINGS_FOLD_ENGINEERING_Z, /* Fold the paper vertically into two small sections and one larger, forming an elongated Z */
+ IPP_FINISHINGS_FOLD_PARALLEL, // Fold the paper in half vertically two times, yielding four sections
+ IPP_FINISHINGS_FOLD_POSTER, // Fold the paper in half horizontally and vertically; sometimes also called a cross fold
+ IPP_FINISHINGS_FOLD_RIGHT_GATE, // Fold the bottom quarter of the paper towards the midline
+ IPP_FINISHINGS_FOLD_Z, // Fold the paper vertically into three sections, forming a Z
+ IPP_FINISHINGS_FOLD_ENGINEERING_Z, // Fold the paper vertically into two small sections and one larger, forming an elongated Z
- /* CUPS extensions for finishings (pre-standard versions of values above) */
+ // CUPS extensions for finishings (pre-standard versions of values above)
IPP_FINISHINGS_CUPS_PUNCH_TOP_LEFT = 0x40000046,
- /* Punch 1 hole top left @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_BOTTOM_LEFT,/* Punch 1 hole bottom left @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_TOP_RIGHT, /* Punch 1 hole top right @exclude all@ */
+ // Punch 1 hole top left @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_BOTTOM_LEFT,// Punch 1 hole bottom left @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_TOP_RIGHT, // Punch 1 hole top right @exclude all@
IPP_FINISHINGS_CUPS_PUNCH_BOTTOM_RIGHT,
- /* Punch 1 hole bottom right @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_DUAL_LEFT, /* Punch 2 holes left side @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_DUAL_TOP, /* Punch 2 holes top edge @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_DUAL_RIGHT, /* Punch 2 holes right side @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_DUAL_BOTTOM,/* Punch 2 holes bottom edge @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_TRIPLE_LEFT,/* Punch 3 holes left side @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_TRIPLE_TOP, /* Punch 3 holes top edge @exclude all@ */
+ // Punch 1 hole bottom right @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_DUAL_LEFT, // Punch 2 holes left side @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_DUAL_TOP, // Punch 2 holes top edge @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_DUAL_RIGHT, // Punch 2 holes right side @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_DUAL_BOTTOM,// Punch 2 holes bottom edge @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_TRIPLE_LEFT,// Punch 3 holes left side @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_TRIPLE_TOP, // Punch 3 holes top edge @exclude all@
IPP_FINISHINGS_CUPS_PUNCH_TRIPLE_RIGHT,
- /* Punch 3 holes right side @exclude all@ */
+ // Punch 3 holes right side @exclude all@
IPP_FINISHINGS_CUPS_PUNCH_TRIPLE_BOTTOM,
- /* Punch 3 holes bottom edge @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_QUAD_LEFT, /* Punch 4 holes left side @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_QUAD_TOP, /* Punch 4 holes top edge @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_QUAD_RIGHT, /* Punch 4 holes right side @exclude all@ */
- IPP_FINISHINGS_CUPS_PUNCH_QUAD_BOTTOM,/* Punch 4 holes bottom edge @exclude all@ */
+ // Punch 3 holes bottom edge @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_QUAD_LEFT, // Punch 4 holes left side @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_QUAD_TOP, // Punch 4 holes top edge @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_QUAD_RIGHT, // Punch 4 holes right side @exclude all@
+ IPP_FINISHINGS_CUPS_PUNCH_QUAD_BOTTOM,// Punch 4 holes bottom edge @exclude all@
IPP_FINISHINGS_CUPS_FOLD_ACCORDION = 0x4000005A,
- /* Accordion-fold the paper vertically into four sections @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_DOUBLE_GATE, /* Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_GATE, /* Fold the top and bottom quarters of the paper towards the midline @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_HALF, /* Fold the paper in half vertically @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_HALF_Z, /* Fold the paper in half horizontally, then Z-fold the paper vertically @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_LEFT_GATE, /* Fold the top quarter of the paper towards the midline @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_LETTER, /* Fold the paper into three sections vertically; sometimes also known as a C fold @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_PARALLEL, /* Fold the paper in half vertically two times, yielding four sections @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_POSTER, /* Fold the paper in half horizontally and vertically; sometimes also called a cross fold @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_RIGHT_GATE, /* Fold the bottom quarter of the paper towards the midline @exclude all@ */
- IPP_FINISHINGS_CUPS_FOLD_Z /* Fold the paper vertically into three sections, forming a Z @exclude all@ */
+ // Accordion-fold the paper vertically into four sections @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_DOUBLE_GATE, // Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_GATE, // Fold the top and bottom quarters of the paper towards the midline @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_HALF, // Fold the paper in half vertically @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_HALF_Z, // Fold the paper in half horizontally, then Z-fold the paper vertically @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_LEFT_GATE, // Fold the top quarter of the paper towards the midline @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_LETTER, // Fold the paper into three sections vertically; sometimes also known as a C fold @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_PARALLEL, // Fold the paper in half vertically two times, yielding four sections @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_POSTER, // Fold the paper in half horizontally and vertically; sometimes also called a cross fold @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_RIGHT_GATE, // Fold the bottom quarter of the paper towards the midline @exclude all@
+ IPP_FINISHINGS_CUPS_FOLD_Z // Fold the paper vertically into three sections, forming a Z @exclude all@
} ipp_finishings_t;
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_FINISHINGS_CUPS_FOLD_ACCORDIAN IPP_FINISHINGS_CUPS_FOLD_ACCORDION
-# define IPP_FINISHINGS_FOLD_ACCORDIAN IPP_FINISHINGS_FOLD_ACCORDION
-# define IPP_FINISHINGS_JOB_OFFSET IPP_FINISHINGS_JOG_OFFSET
- /* Long-time misspellings... */
-typedef enum ipp_finishings_e ipp_finish_t;
-# endif /* !_CUPS_NO_DEPRECATED */
-
-typedef enum ipp_jcollate_e /**** Job collation types @deprecated@ @exclude all@ ****/
+
+typedef enum ipp_jcollate_e // Job collation types @deprecated@ @exclude all@
{
IPP_JCOLLATE_UNCOLLATED_SHEETS = 3,
IPP_JCOLLATE_COLLATED_DOCUMENTS,
IPP_JCOLLATE_UNCOLLATED_DOCUMENTS
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_JOB_UNCOLLATED_SHEETS IPP_JCOLLATE_UNCOLLATED_SHEETS
-# define IPP_JOB_COLLATED_DOCUMENTS IPP_JCOLLATE_COLLATED_DOCUMENTS
-# define IPP_JOB_UNCOLLATED_DOCUMENTS IPP_JCOLLATE_UNCOLLATED_DOCUMENTS
-# endif /* !_CUPS_NO_DEPRECATED */
} ipp_jcollate_t;
-typedef enum ipp_jstate_e /**** Job states ****/
+typedef enum ipp_jstate_e // Job states
{
- IPP_JSTATE_PENDING = 3, /* Job is waiting to be printed */
- IPP_JSTATE_HELD, /* Job is held for printing */
- IPP_JSTATE_PROCESSING, /* Job is currently printing */
- IPP_JSTATE_STOPPED, /* Job has been stopped */
- IPP_JSTATE_CANCELED, /* Job has been canceled */
- IPP_JSTATE_ABORTED, /* Job has aborted due to error */
- IPP_JSTATE_COMPLETED /* Job has completed successfully */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_JOB_PENDING IPP_JSTATE_PENDING
-# define IPP_JOB_HELD IPP_JSTATE_HELD
-# define IPP_JOB_PROCESSING IPP_JSTATE_PROCESSING
-# define IPP_JOB_STOPPED IPP_JSTATE_STOPPED
-# define IPP_JOB_CANCELED IPP_JSTATE_CANCELED
-# define IPP_JOB_ABORTED IPP_JSTATE_ABORTED
-# define IPP_JOB_COMPLETED IPP_JSTATE_COMPLETED
- /* Legacy name for canceled state */
-# define IPP_JOB_CANCELLED IPP_JSTATE_CANCELED
-# endif /* !_CUPS_NO_DEPRECATED */
+ IPP_JSTATE_PENDING = 3, // Job is waiting to be printed
+ IPP_JSTATE_HELD, // Job is held for printing
+ IPP_JSTATE_PROCESSING, // Job is currently printing
+ IPP_JSTATE_STOPPED, // Job has been stopped
+ IPP_JSTATE_CANCELED, // Job has been canceled
+ IPP_JSTATE_ABORTED, // Job has aborted due to error
+ IPP_JSTATE_COMPLETED // Job has completed successfully
} ipp_jstate_t;
-typedef enum ipp_op_e /**** IPP operations ****/
+typedef enum ipp_op_e // IPP operations
{
- IPP_OP_CUPS_INVALID = -1, /* Invalid operation name for @link ippOpValue@ */
- IPP_OP_CUPS_NONE = 0, /* No operation @private@ */
- IPP_OP_PRINT_JOB = 0x0002, /* Print-Job: Print a single file */
- IPP_OP_PRINT_URI, /* Print-URI: Print a single URL @exclude all@ */
- IPP_OP_VALIDATE_JOB, /* Validate-Job: Validate job values prior to submission */
- IPP_OP_CREATE_JOB, /* Create-Job: Create an empty print job */
- IPP_OP_SEND_DOCUMENT, /* Send-Document: Add a file to a job */
- IPP_OP_SEND_URI, /* Send-URI: Add a URL to a job @exclude all@ */
- IPP_OP_CANCEL_JOB, /* Cancel-Job: Cancel a job */
- IPP_OP_GET_JOB_ATTRIBUTES, /* Get-Job-Attribute: Get information about a job */
- IPP_OP_GET_JOBS, /* Get-Jobs: Get a list of jobs */
- IPP_OP_GET_PRINTER_ATTRIBUTES, /* Get-Printer-Attributes: Get information about a printer */
- IPP_OP_HOLD_JOB, /* Hold-Job: Hold a job for printing */
- IPP_OP_RELEASE_JOB, /* Release-Job: Release a job for printing */
- IPP_OP_RESTART_JOB, /* Restart-Job: Reprint a job @deprecated@ */
- IPP_OP_PAUSE_PRINTER = 0x0010, /* Pause-Printer: Stop a printer */
- IPP_OP_RESUME_PRINTER, /* Resume-Printer: Start a printer */
- IPP_OP_PURGE_JOBS, /* Purge-Jobs: Delete all jobs @deprecated@ @exclude all@ */
- IPP_OP_SET_PRINTER_ATTRIBUTES, /* Set-Printer-Attributes: Set printer values */
- IPP_OP_SET_JOB_ATTRIBUTES, /* Set-Job-Attributes: Set job values */
- IPP_OP_GET_PRINTER_SUPPORTED_VALUES, /* Get-Printer-Supported-Values: Get supported values */
- IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS, /* Create-Printer-Subscriptions: Create one or more printer subscriptions @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_CREATE_JOB_SUBSCRIPTIONS, /* Create-Job-Subscriptions: Create one of more job subscriptions @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES, /* Get-Subscription-Attributes: Get subscription information @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_GET_SUBSCRIPTIONS, /* Get-Subscriptions: Get list of subscriptions @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_RENEW_SUBSCRIPTION, /* Renew-Subscription: Renew a printer subscription @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_CANCEL_SUBSCRIPTION, /* Cancel-Subscription: Cancel a subscription @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_GET_NOTIFICATIONS, /* Get-Notifications: Get notification events @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_SEND_NOTIFICATIONS, /* Send-Notifications: Send notification events @private@ */
- IPP_OP_GET_RESOURCE_ATTRIBUTES, /* Get-Resource-Attributes: Get resource information @private@ */
- IPP_OP_GET_RESOURCE_DATA, /* Get-Resource-Data: Get resource data @private@ @deprecated@ */
- IPP_OP_GET_RESOURCES, /* Get-Resources: Get list of resources @private@ */
- IPP_OP_GET_PRINT_SUPPORT_FILES, /* Get-Printer-Support-Files: Get printer support files @private@ */
- IPP_OP_ENABLE_PRINTER, /* Enable-Printer: Accept new jobs for a printer */
- IPP_OP_DISABLE_PRINTER, /* Disable-Printer: Reject new jobs for a printer */
+ IPP_OP_CUPS_INVALID = -1, // Invalid operation name for @link ippOpValue@
+ IPP_OP_CUPS_NONE = 0, // No operation @private@
+ IPP_OP_PRINT_JOB = 0x0002, // Print-Job: Print a single file
+ IPP_OP_PRINT_URI, // Print-URI: Print a single URL @exclude all@
+ IPP_OP_VALIDATE_JOB, // Validate-Job: Validate job values prior to submission
+ IPP_OP_CREATE_JOB, // Create-Job: Create an empty print job
+ IPP_OP_SEND_DOCUMENT, // Send-Document: Add a file to a job
+ IPP_OP_SEND_URI, // Send-URI: Add a URL to a job @exclude all@
+ IPP_OP_CANCEL_JOB, // Cancel-Job: Cancel a job
+ IPP_OP_GET_JOB_ATTRIBUTES, // Get-Job-Attribute: Get information about a job
+ IPP_OP_GET_JOBS, // Get-Jobs: Get a list of jobs
+ IPP_OP_GET_PRINTER_ATTRIBUTES, // Get-Printer-Attributes: Get information about a printer
+ IPP_OP_HOLD_JOB, // Hold-Job: Hold a job for printing
+ IPP_OP_RELEASE_JOB, // Release-Job: Release a job for printing
+ IPP_OP_RESTART_JOB, // Restart-Job: Reprint a job @deprecated@
+ IPP_OP_PAUSE_PRINTER = 0x0010, // Pause-Printer: Stop a printer
+ IPP_OP_RESUME_PRINTER, // Resume-Printer: Start a printer
+ IPP_OP_PURGE_JOBS, // Purge-Jobs: Delete all jobs @deprecated@ @exclude all@
+ IPP_OP_SET_PRINTER_ATTRIBUTES, // Set-Printer-Attributes: Set printer values
+ IPP_OP_SET_JOB_ATTRIBUTES, // Set-Job-Attributes: Set job values
+ IPP_OP_GET_PRINTER_SUPPORTED_VALUES, // Get-Printer-Supported-Values: Get supported values
+ IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS, // Create-Printer-Subscriptions: Create one or more printer subscriptions @since CUPS 1.2/macOS 10.5@
+ IPP_OP_CREATE_JOB_SUBSCRIPTIONS, // Create-Job-Subscriptions: Create one of more job subscriptions @since CUPS 1.2/macOS 10.5@
+ IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES, // Get-Subscription-Attributes: Get subscription information @since CUPS 1.2/macOS 10.5@
+ IPP_OP_GET_SUBSCRIPTIONS, // Get-Subscriptions: Get list of subscriptions @since CUPS 1.2/macOS 10.5@
+ IPP_OP_RENEW_SUBSCRIPTION, // Renew-Subscription: Renew a printer subscription @since CUPS 1.2/macOS 10.5@
+ IPP_OP_CANCEL_SUBSCRIPTION, // Cancel-Subscription: Cancel a subscription @since CUPS 1.2/macOS 10.5@
+ IPP_OP_GET_NOTIFICATIONS, // Get-Notifications: Get notification events @since CUPS 1.2/macOS 10.5@
+ IPP_OP_SEND_NOTIFICATIONS, // Send-Notifications: Send notification events @private@
+ IPP_OP_GET_RESOURCE_ATTRIBUTES, // Get-Resource-Attributes: Get resource information @private@
+ IPP_OP_GET_RESOURCE_DATA, // Get-Resource-Data: Get resource data @private@ @deprecated@
+ IPP_OP_GET_RESOURCES, // Get-Resources: Get list of resources @private@
+ IPP_OP_GET_PRINT_SUPPORT_FILES, // Get-Printer-Support-Files: Get printer support files @private@
+ IPP_OP_ENABLE_PRINTER, // Enable-Printer: Accept new jobs for a printer
+ IPP_OP_DISABLE_PRINTER, // Disable-Printer: Reject new jobs for a printer
IPP_OP_PAUSE_PRINTER_AFTER_CURRENT_JOB,
- /* Pause-Printer-After-Current-Job: Stop printer after the current job */
- IPP_OP_HOLD_NEW_JOBS, /* Hold-New-Jobs: Hold new jobs */
- IPP_OP_RELEASE_HELD_NEW_JOBS, /* Release-Held-New-Jobs: Release new jobs that were previously held */
- IPP_OP_DEACTIVATE_PRINTER, /* Deactivate-Printer: Stop a printer and do not accept jobs @deprecated@ @exclude all@ */
- IPP_OP_ACTIVATE_PRINTER, /* Activate-Printer: Start a printer and accept jobs @deprecated@ @exclude all@ */
- IPP_OP_RESTART_PRINTER, /* Restart-Printer: Restart a printer @exclude all@ */
- IPP_OP_SHUTDOWN_PRINTER, /* Shutdown-Printer: Turn a printer off @exclude all@ */
- IPP_OP_STARTUP_PRINTER, /* Startup-Printer: Turn a printer on @exclude all@ */
+ // Pause-Printer-After-Current-Job: Stop printer after the current job
+ IPP_OP_HOLD_NEW_JOBS, // Hold-New-Jobs: Hold new jobs
+ IPP_OP_RELEASE_HELD_NEW_JOBS, // Release-Held-New-Jobs: Release new jobs that were previously held
+ IPP_OP_DEACTIVATE_PRINTER, // Deactivate-Printer: Stop a printer and do not accept jobs @deprecated@ @exclude all@
+ IPP_OP_ACTIVATE_PRINTER, // Activate-Printer: Start a printer and accept jobs @deprecated@ @exclude all@
+ IPP_OP_RESTART_PRINTER, // Restart-Printer: Restart a printer @exclude all@
+ IPP_OP_SHUTDOWN_PRINTER, // Shutdown-Printer: Turn a printer off @exclude all@
+ IPP_OP_STARTUP_PRINTER, // Startup-Printer: Turn a printer on @exclude all@
IPP_OP_REPROCESS_JOB, /* Reprocess-Job: Reprint a job @deprecated@ @exclude all@*/
- IPP_OP_CANCEL_CURRENT_JOB, /* Cancel-Current-Job: Cancel the current job */
- IPP_OP_SUSPEND_CURRENT_JOB, /* Suspend-Current-Job: Suspend the current job */
- IPP_OP_RESUME_JOB, /* Resume-Job: Resume the current job */
- IPP_OP_PROMOTE_JOB, /* Promote-Job: Promote a job to print sooner */
- IPP_OP_SCHEDULE_JOB_AFTER, /* Schedule-Job-After: Schedule a job to print after another */
- IPP_OP_CANCEL_DOCUMENT = 0x0033, /* Cancel-Document: Cancel a document @exclude all@ */
- IPP_OP_GET_DOCUMENT_ATTRIBUTES, /* Get-Document-Attributes: Get document information @exclude all@ */
- IPP_OP_GET_DOCUMENTS, /* Get-Documents: Get a list of documents in a job @exclude all@ */
- IPP_OP_DELETE_DOCUMENT, /* Delete-Document: Delete a document @deprecated@ @exclude all@ */
- IPP_OP_SET_DOCUMENT_ATTRIBUTES, /* Set-Document-Attributes: Set document values @exclude all@ */
- IPP_OP_CANCEL_JOBS, /* Cancel-Jobs: Cancel all jobs (administrative) */
- IPP_OP_CANCEL_MY_JOBS, /* Cancel-My-Jobs: Cancel a user's jobs */
- IPP_OP_RESUBMIT_JOB, /* Resubmit-Job: Copy and reprint a job @exclude all@ */
- IPP_OP_CLOSE_JOB, /* Close-Job: Close a job and start printing */
- IPP_OP_IDENTIFY_PRINTER, /* Identify-Printer: Make the printer beep, flash, or display a message for identification */
- IPP_OP_VALIDATE_DOCUMENT, /* Validate-Document: Validate document values prior to submission @exclude all@ */
- IPP_OP_ADD_DOCUMENT_IMAGES, /* Add-Document-Images: Add image(s) from the specified scanner source @exclude all@ */
- IPP_OP_ACKNOWLEDGE_DOCUMENT, /* Acknowledge-Document: Acknowledge processing of a document @exclude all@ */
- IPP_OP_ACKNOWLEDGE_IDENTIFY_PRINTER, /* Acknowledge-Identify-Printer: Acknowledge action on an Identify-Printer request @exclude all@ */
- IPP_OP_ACKNOWLEDGE_JOB, /* Acknowledge-Job: Acknowledge processing of a job @exclude all@ */
- IPP_OP_FETCH_DOCUMENT, /* Fetch-Document: Fetch a document for processing @exclude all@ */
- IPP_OP_FETCH_JOB, /* Fetch-Job: Fetch a job for processing @exclude all@ */
- IPP_OP_GET_OUTPUT_DEVICE_ATTRIBUTES, /* Get-Output-Device-Attributes: Get printer information for a specific output device @exclude all@ */
- IPP_OP_UPDATE_ACTIVE_JOBS, /* Update-Active-Jobs: Update the list of active jobs that a proxy has processed @exclude all@ */
- IPP_OP_DEREGISTER_OUTPUT_DEVICE, /* Deregister-Output-Device: Remove an output device @exclude all@ */
- IPP_OP_UPDATE_DOCUMENT_STATUS, /* Update-Document-Status: Update document values @exclude all@ */
- IPP_OP_UPDATE_JOB_STATUS, /* Update-Job-Status: Update job values @exclude all@ */
+ IPP_OP_CANCEL_CURRENT_JOB, // Cancel-Current-Job: Cancel the current job
+ IPP_OP_SUSPEND_CURRENT_JOB, // Suspend-Current-Job: Suspend the current job
+ IPP_OP_RESUME_JOB, // Resume-Job: Resume the current job
+ IPP_OP_PROMOTE_JOB, // Promote-Job: Promote a job to print sooner
+ IPP_OP_SCHEDULE_JOB_AFTER, // Schedule-Job-After: Schedule a job to print after another
+ IPP_OP_CANCEL_DOCUMENT = 0x0033, // Cancel-Document: Cancel a document @exclude all@
+ IPP_OP_GET_DOCUMENT_ATTRIBUTES, // Get-Document-Attributes: Get document information @exclude all@
+ IPP_OP_GET_DOCUMENTS, // Get-Documents: Get a list of documents in a job @exclude all@
+ IPP_OP_DELETE_DOCUMENT, // Delete-Document: Delete a document @deprecated@ @exclude all@
+ IPP_OP_SET_DOCUMENT_ATTRIBUTES, // Set-Document-Attributes: Set document values @exclude all@
+ IPP_OP_CANCEL_JOBS, // Cancel-Jobs: Cancel all jobs (administrative)
+ IPP_OP_CANCEL_MY_JOBS, // Cancel-My-Jobs: Cancel a user's jobs
+ IPP_OP_RESUBMIT_JOB, // Resubmit-Job: Copy and reprint a job @exclude all@
+ IPP_OP_CLOSE_JOB, // Close-Job: Close a job and start printing
+ IPP_OP_IDENTIFY_PRINTER, // Identify-Printer: Make the printer beep, flash, or display a message for identification
+ IPP_OP_VALIDATE_DOCUMENT, // Validate-Document: Validate document values prior to submission @exclude all@
+ IPP_OP_ADD_DOCUMENT_IMAGES, // Add-Document-Images: Add image(s) from the specified scanner source @exclude all@
+ IPP_OP_ACKNOWLEDGE_DOCUMENT, // Acknowledge-Document: Acknowledge processing of a document @exclude all@
+ IPP_OP_ACKNOWLEDGE_IDENTIFY_PRINTER, // Acknowledge-Identify-Printer: Acknowledge action on an Identify-Printer request @exclude all@
+ IPP_OP_ACKNOWLEDGE_JOB, // Acknowledge-Job: Acknowledge processing of a job @exclude all@
+ IPP_OP_FETCH_DOCUMENT, // Fetch-Document: Fetch a document for processing @exclude all@
+ IPP_OP_FETCH_JOB, // Fetch-Job: Fetch a job for processing @exclude all@
+ IPP_OP_GET_OUTPUT_DEVICE_ATTRIBUTES, // Get-Output-Device-Attributes: Get printer information for a specific output device @exclude all@
+ IPP_OP_UPDATE_ACTIVE_JOBS, // Update-Active-Jobs: Update the list of active jobs that a proxy has processed @exclude all@
+ IPP_OP_DEREGISTER_OUTPUT_DEVICE, // Deregister-Output-Device: Remove an output device @exclude all@
+ IPP_OP_UPDATE_DOCUMENT_STATUS, // Update-Document-Status: Update document values @exclude all@
+ IPP_OP_UPDATE_JOB_STATUS, // Update-Job-Status: Update job values @exclude all@
IPP_OP_UPDATE_OUTPUT_DEVICE_ATTRIBUTES,
- /* Update-Output-Device-Attributes: Update output device values @exclude all@ */
- IPP_OP_GET_NEXT_DOCUMENT_DATA, /* Get-Next-Document-Data: Scan more document data @exclude all@ */
- IPP_OP_ALLOCATE_PRINTER_RESOURCES, /* Allocate-Printer-Resources: Use resources for a printer. */
- IPP_OP_CREATE_PRINTER, /* Create-Printer: Create a new service. */
- IPP_OP_DEALLOCATE_PRINTER_RESOURCES, /* Deallocate-Printer-Resources: Stop using resources for a printer. */
- IPP_OP_DELETE_PRINTER, /* Delete-Printer: Delete an existing service. */
- IPP_OP_GET_PRINTERS, /* Get-Printers: Get a list of services. */
- IPP_OP_SHUTDOWN_ONE_PRINTER, /* Shutdown-One-Printer: Shutdown a service. */
- IPP_OP_STARTUP_ONE_PRINTER, /* Startup-One-Printer: Start a service. */
- IPP_OP_CANCEL_RESOURCE, /* Cancel-Resource: Uninstall a resource. */
- IPP_OP_CREATE_RESOURCE, /* Create-Resource: Create a new (empty) resource. */
- IPP_OP_INSTALL_RESOURCE, /* Install-Resource: Install a resource. */
- IPP_OP_SEND_RESOURCE_DATA, /* Send-Resource-Data: Upload the data for a resource. */
- IPP_OP_SET_RESOURCE_ATTRIBUTES, /* Set-Resource-Attributes: Set resource object attributes. */
- IPP_OP_CREATE_RESOURCE_SUBSCRIPTIONS, /* Create-Resource-Subscriptions: Create event subscriptions for a resource. */
- IPP_OP_CREATE_SYSTEM_SUBSCRIPTIONS, /* Create-System-Subscriptions: Create event subscriptions for a system. */
- IPP_OP_DISABLE_ALL_PRINTERS, /* Disable-All-Printers: Stop accepting new jobs on all services. */
- IPP_OP_ENABLE_ALL_PRINTERS, /* Enable-All-Printers: Start accepting new jobs on all services. */
- IPP_OP_GET_SYSTEM_ATTRIBUTES, /* Get-System-Attributes: Get system object attributes. */
- IPP_OP_GET_SYSTEM_SUPPORTED_VALUES, /* Get-System-Supported-Values: Get supported values for system object attributes. */
- IPP_OP_PAUSE_ALL_PRINTERS, /* Pause-All-Printers: Stop all services immediately. */
+ // Update-Output-Device-Attributes: Update output device values @exclude all@
+ IPP_OP_GET_NEXT_DOCUMENT_DATA, // Get-Next-Document-Data: Scan more document data @exclude all@
+ IPP_OP_ALLOCATE_PRINTER_RESOURCES, // Allocate-Printer-Resources: Use resources for a printer.
+ IPP_OP_CREATE_PRINTER, // Create-Printer: Create a new service.
+ IPP_OP_DEALLOCATE_PRINTER_RESOURCES, // Deallocate-Printer-Resources: Stop using resources for a printer.
+ IPP_OP_DELETE_PRINTER, // Delete-Printer: Delete an existing service.
+ IPP_OP_GET_PRINTERS, // Get-Printers: Get a list of services.
+ IPP_OP_SHUTDOWN_ONE_PRINTER, // Shutdown-One-Printer: Shutdown a service.
+ IPP_OP_STARTUP_ONE_PRINTER, // Startup-One-Printer: Start a service.
+ IPP_OP_CANCEL_RESOURCE, // Cancel-Resource: Uninstall a resource.
+ IPP_OP_CREATE_RESOURCE, // Create-Resource: Create a new (empty) resource.
+ IPP_OP_INSTALL_RESOURCE, // Install-Resource: Install a resource.
+ IPP_OP_SEND_RESOURCE_DATA, // Send-Resource-Data: Upload the data for a resource.
+ IPP_OP_SET_RESOURCE_ATTRIBUTES, // Set-Resource-Attributes: Set resource object attributes.
+ IPP_OP_CREATE_RESOURCE_SUBSCRIPTIONS, // Create-Resource-Subscriptions: Create event subscriptions for a resource.
+ IPP_OP_CREATE_SYSTEM_SUBSCRIPTIONS, // Create-System-Subscriptions: Create event subscriptions for a system.
+ IPP_OP_DISABLE_ALL_PRINTERS, // Disable-All-Printers: Stop accepting new jobs on all services.
+ IPP_OP_ENABLE_ALL_PRINTERS, // Enable-All-Printers: Start accepting new jobs on all services.
+ IPP_OP_GET_SYSTEM_ATTRIBUTES, // Get-System-Attributes: Get system object attributes.
+ IPP_OP_GET_SYSTEM_SUPPORTED_VALUES, // Get-System-Supported-Values: Get supported values for system object attributes.
+ IPP_OP_PAUSE_ALL_PRINTERS, // Pause-All-Printers: Stop all services immediately.
IPP_OP_PAUSE_ALL_PRINTERS_AFTER_CURRENT_JOB,
- /* Pause-All-Printers-After-Current-Job: Stop all services after processing the current jobs. */
- IPP_OP_REGISTER_OUTPUT_DEVICE, /* Register-Output-Device: Register a remote service. */
- IPP_OP_RESTART_SYSTEM, /* Restart-System: Restart all services. */
- IPP_OP_RESUME_ALL_PRINTERS, /* Resume-All-Printers: Start job processing on all services. */
- IPP_OP_SET_SYSTEM_ATTRIBUTES, /* Set-System-Attributes: Set system object attributes. */
- IPP_OP_SHUTDOWN_ALL_PRINTERS, /* Shutdown-All-Printers: Shutdown all services. */
- IPP_OP_STARTUP_ALL_PRINTERS, /* Startup-All-Printers: Startup all services. */
-
- IPP_OP_PRIVATE = 0x4000, /* Reserved @private@ */
- IPP_OP_CUPS_GET_DEFAULT, /* CUPS-Get-Default: Get the default printer */
- IPP_OP_CUPS_GET_PRINTERS, /* CUPS-Get-Printers: Get a list of printers and/or classes */
- IPP_OP_CUPS_ADD_MODIFY_PRINTER, /* CUPS-Add-Modify-Printer: Add or modify a printer */
- IPP_OP_CUPS_DELETE_PRINTER, /* CUPS-Delete-Printer: Delete a printer */
- IPP_OP_CUPS_GET_CLASSES, /* CUPS-Get-Classes: Get a list of classes @deprecated@ @exclude all@ */
- IPP_OP_CUPS_ADD_MODIFY_CLASS, /* CUPS-Add-Modify-Class: Add or modify a class */
- IPP_OP_CUPS_DELETE_CLASS, /* CUPS-Delete-Class: Delete a class */
- IPP_OP_CUPS_ACCEPT_JOBS, /* CUPS-Accept-Jobs: Accept new jobs on a printer @exclude all@ */
- IPP_OP_CUPS_REJECT_JOBS, /* CUPS-Reject-Jobs: Reject new jobs on a printer @exclude all@ */
- IPP_OP_CUPS_SET_DEFAULT, /* CUPS-Set-Default: Set the default printer */
- IPP_OP_CUPS_GET_DEVICES, /* CUPS-Get-Devices: Get a list of supported devices @deprecated@ */
- IPP_OP_CUPS_GET_PPDS, /* CUPS-Get-PPDs: Get a list of supported drivers @deprecated@ */
- IPP_OP_CUPS_MOVE_JOB, /* CUPS-Move-Job: Move a job to a different printer */
- IPP_OP_CUPS_AUTHENTICATE_JOB, /* CUPS-Authenticate-Job: Authenticate a job @since CUPS 1.2/macOS 10.5@ */
- IPP_OP_CUPS_GET_PPD, /* CUPS-Get-PPD: Get a PPD file @deprecated@ */
- IPP_OP_CUPS_GET_DOCUMENT = 0x4027, /* CUPS-Get-Document: Get a document file @since CUPS 1.4/macOS 10.6@ */
- IPP_OP_CUPS_CREATE_LOCAL_PRINTER /* CUPS-Create-Local-Printer: Create a local (temporary) printer @since CUPS 2.2@ */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_PRINT_JOB IPP_OP_PRINT_JOB
-# define IPP_PRINT_URI IPP_OP_PRINT_URI
-# define IPP_VALIDATE_JOB IPP_OP_VALIDATE_JOB
-# define IPP_CREATE_JOB IPP_OP_CREATE_JOB
-# define IPP_SEND_DOCUMENT IPP_OP_SEND_DOCUMENT
-# define IPP_SEND_URI IPP_OP_SEND_URI
-# define IPP_CANCEL_JOB IPP_OP_CANCEL_JOB
-# define IPP_GET_JOB_ATTRIBUTES IPP_OP_GET_JOB_ATTRIBUTES
-# define IPP_GET_JOBS IPP_OP_GET_JOBS
-# define IPP_GET_PRINTER_ATTRIBUTES IPP_OP_GET_PRINTER_ATTRIBUTES
-# define IPP_HOLD_JOB IPP_OP_HOLD_JOB
-# define IPP_RELEASE_JOB IPP_OP_RELEASE_JOB
-# define IPP_RESTART_JOB IPP_OP_RESTART_JOB
-# define IPP_PAUSE_PRINTER IPP_OP_PAUSE_PRINTER
-# define IPP_RESUME_PRINTER IPP_OP_RESUME_PRINTER
-# define IPP_PURGE_JOBS IPP_OP_PURGE_JOBS
-# define IPP_SET_PRINTER_ATTRIBUTES IPP_OP_SET_PRINTER_ATTRIBUTES
-# define IPP_SET_JOB_ATTRIBUTES IPP_OP_SET_JOB_ATTRIBUTES
-# define IPP_GET_PRINTER_SUPPORTED_VALUES IPP_OP_GET_PRINTER_SUPPORTED_VALUES
-# define IPP_CREATE_PRINTER_SUBSCRIPTION IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS
-# define IPP_CREATE_JOB_SUBSCRIPTION IPP_OP_CREATE_JOB_SUBSCRIPTIONS
-# define IPP_OP_CREATE_PRINTER_SUBSCRIPTION IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS
-# define IPP_OP_CREATE_JOB_SUBSCRIPTION IPP_OP_CREATE_JOB_SUBSCRIPTIONS
-# define IPP_GET_SUBSCRIPTION_ATTRIBUTES IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES
-# define IPP_GET_SUBSCRIPTIONS IPP_OP_GET_SUBSCRIPTIONS
-# define IPP_RENEW_SUBSCRIPTION IPP_OP_RENEW_SUBSCRIPTION
-# define IPP_CANCEL_SUBSCRIPTION IPP_OP_CANCEL_SUBSCRIPTION
-# define IPP_GET_NOTIFICATIONS IPP_OP_GET_NOTIFICATIONS
-# define IPP_SEND_NOTIFICATIONS IPP_OP_SEND_NOTIFICATIONS
-# define IPP_GET_RESOURCE_ATTRIBUTES IPP_OP_GET_RESOURCE_ATTRIBUTES
-# define IPP_GET_RESOURCE_DATA IPP_OP_GET_RESOURCE_DATA
-# define IPP_GET_RESOURCES IPP_OP_GET_RESOURCES
-# define IPP_GET_PRINT_SUPPORT_FILES IPP_OP_GET_PRINT_SUPPORT_FILES
-# define IPP_ENABLE_PRINTER IPP_OP_ENABLE_PRINTER
-# define IPP_DISABLE_PRINTER IPP_OP_DISABLE_PRINTER
-# define IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB IPP_OP_PAUSE_PRINTER_AFTER_CURRENT_JOB
-# define IPP_HOLD_NEW_JOBS IPP_OP_HOLD_NEW_JOBS
-# define IPP_RELEASE_HELD_NEW_JOBS IPP_OP_RELEASE_HELD_NEW_JOBS
-# define IPP_DEACTIVATE_PRINTER IPP_OP_DEACTIVATE_PRINTER
-# define IPP_ACTIVATE_PRINTER IPP_OP_ACTIVATE_PRINTER
-# define IPP_RESTART_PRINTER IPP_OP_RESTART_PRINTER
-# define IPP_SHUTDOWN_PRINTER IPP_OP_SHUTDOWN_PRINTER
-# define IPP_STARTUP_PRINTER IPP_OP_STARTUP_PRINTER
-# define IPP_REPROCESS_JOB IPP_OP_REPROCESS_JOB
-# define IPP_CANCEL_CURRENT_JOB IPP_OP_CANCEL_CURRENT_JOB
-# define IPP_SUSPEND_CURRENT_JOB IPP_OP_SUSPEND_CURRENT_JOB
-# define IPP_RESUME_JOB IPP_OP_RESUME_JOB
-# define IPP_PROMOTE_JOB IPP_OP_PROMOTE_JOB
-# define IPP_SCHEDULE_JOB_AFTER IPP_OP_SCHEDULE_JOB_AFTER
-# define IPP_CANCEL_DOCUMENT IPP_OP_CANCEL_DOCUMENT
-# define IPP_GET_DOCUMENT_ATTRIBUTES IPP_OP_GET_DOCUMENT_ATTRIBUTES
-# define IPP_GET_DOCUMENTS IPP_OP_GET_DOCUMENTS
-# define IPP_DELETE_DOCUMENT IPP_OP_DELETE_DOCUMENT
-# define IPP_SET_DOCUMENT_ATTRIBUTES IPP_OP_SET_DOCUMENT_ATTRIBUTES
-# define IPP_CANCEL_JOBS IPP_OP_CANCEL_JOBS
-# define IPP_CANCEL_MY_JOBS IPP_OP_CANCEL_MY_JOBS
-# define IPP_RESUBMIT_JOB IPP_OP_RESUBMIT_JOB
-# define IPP_CLOSE_JOB IPP_OP_CLOSE_JOB
-# define IPP_IDENTIFY_PRINTER IPP_OP_IDENTIFY_PRINTER
-# define IPP_VALIDATE_DOCUMENT IPP_OP_VALIDATE_DOCUMENT
-# define IPP_OP_SEND_HARDCOPY_DOCUMENT IPP_OP_ADD_DOCUMENT_IMAGES
-# define IPP_PRIVATE IPP_OP_PRIVATE
-# define CUPS_GET_DEFAULT IPP_OP_CUPS_GET_DEFAULT
-# define CUPS_GET_PRINTERS IPP_OP_CUPS_GET_PRINTERS
-# define CUPS_ADD_MODIFY_PRINTER IPP_OP_CUPS_ADD_MODIFY_PRINTER
-# define CUPS_DELETE_PRINTER IPP_OP_CUPS_DELETE_PRINTER
-# define CUPS_GET_CLASSES IPP_OP_CUPS_GET_CLASSES
-# define CUPS_ADD_MODIFY_CLASS IPP_OP_CUPS_ADD_MODIFY_CLASS
-# define CUPS_DELETE_CLASS IPP_OP_CUPS_DELETE_CLASS
-# define CUPS_ACCEPT_JOBS IPP_OP_CUPS_ACCEPT_JOBS
-# define CUPS_REJECT_JOBS IPP_OP_CUPS_REJECT_JOBS
-# define CUPS_SET_DEFAULT IPP_OP_CUPS_SET_DEFAULT
-# define CUPS_GET_DEVICES IPP_OP_CUPS_GET_DEVICES
-# define CUPS_GET_PPDS IPP_OP_CUPS_GET_PPDS
-# define CUPS_MOVE_JOB IPP_OP_CUPS_MOVE_JOB
-# define CUPS_AUTHENTICATE_JOB IPP_OP_CUPS_AUTHENTICATE_JOB
-# define CUPS_GET_PPD IPP_OP_CUPS_GET_PPD
-# define CUPS_GET_DOCUMENT IPP_OP_CUPS_GET_DOCUMENT
- /* Legacy names */
-# define CUPS_ADD_PRINTER IPP_OP_CUPS_ADD_MODIFY_PRINTER
-# define CUPS_ADD_CLASS IPP_OP_CUPS_ADD_MODIFY_CLASS
-# endif /* !_CUPS_NO_DEPRECATED */
+ // Pause-All-Printers-After-Current-Job: Stop all services after processing the current jobs.
+ IPP_OP_REGISTER_OUTPUT_DEVICE, // Register-Output-Device: Register a remote service.
+ IPP_OP_RESTART_SYSTEM, // Restart-System: Restart all services.
+ IPP_OP_RESUME_ALL_PRINTERS, // Resume-All-Printers: Start job processing on all services.
+ IPP_OP_SET_SYSTEM_ATTRIBUTES, // Set-System-Attributes: Set system object attributes.
+ IPP_OP_SHUTDOWN_ALL_PRINTERS, // Shutdown-All-Printers: Shutdown all services.
+ IPP_OP_STARTUP_ALL_PRINTERS, // Startup-All-Printers: Startup all services.
+
+ IPP_OP_PRIVATE = 0x4000, // Reserved @private@
+ IPP_OP_CUPS_GET_DEFAULT, // CUPS-Get-Default: Get the default printer
+ IPP_OP_CUPS_GET_PRINTERS, // CUPS-Get-Printers: Get a list of printers and/or classes
+ IPP_OP_CUPS_ADD_MODIFY_PRINTER, // CUPS-Add-Modify-Printer: Add or modify a printer
+ IPP_OP_CUPS_DELETE_PRINTER, // CUPS-Delete-Printer: Delete a printer
+ IPP_OP_CUPS_GET_CLASSES, // CUPS-Get-Classes: Get a list of classes @deprecated@ @exclude all@
+ IPP_OP_CUPS_ADD_MODIFY_CLASS, // CUPS-Add-Modify-Class: Add or modify a class
+ IPP_OP_CUPS_DELETE_CLASS, // CUPS-Delete-Class: Delete a class
+ IPP_OP_CUPS_ACCEPT_JOBS, // CUPS-Accept-Jobs: Accept new jobs on a printer @exclude all@
+ IPP_OP_CUPS_REJECT_JOBS, // CUPS-Reject-Jobs: Reject new jobs on a printer @exclude all@
+ IPP_OP_CUPS_SET_DEFAULT, // CUPS-Set-Default: Set the default printer
+ IPP_OP_CUPS_GET_DEVICES, // CUPS-Get-Devices: Get a list of supported devices @deprecated@
+ IPP_OP_CUPS_GET_PPDS, // CUPS-Get-PPDs: Get a list of supported drivers @deprecated@
+ IPP_OP_CUPS_MOVE_JOB, // CUPS-Move-Job: Move a job to a different printer
+ IPP_OP_CUPS_AUTHENTICATE_JOB, // CUPS-Authenticate-Job: Authenticate a job @since CUPS 1.2/macOS 10.5@
+ IPP_OP_CUPS_GET_PPD, // CUPS-Get-PPD: Get a PPD file @deprecated@
+ IPP_OP_CUPS_GET_DOCUMENT = 0x4027, // CUPS-Get-Document: Get a document file @since CUPS 1.4/macOS 10.6@
+ IPP_OP_CUPS_CREATE_LOCAL_PRINTER // CUPS-Create-Local-Printer: Create a local (temporary) printer @since CUPS 2.2@
} ipp_op_t;
-typedef enum ipp_orient_e /**** Orientation values ****/
+typedef enum ipp_orient_e // Orientation values
{
- IPP_ORIENT_PORTRAIT = 3, /* No rotation */
- IPP_ORIENT_LANDSCAPE, /* 90 degrees counter-clockwise */
- IPP_ORIENT_REVERSE_LANDSCAPE, /* 90 degrees clockwise */
- IPP_ORIENT_REVERSE_PORTRAIT, /* 180 degrees */
- IPP_ORIENT_NONE /* No rotation */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_PORTRAIT IPP_ORIENT_PORTRAIT
-# define IPP_LANDSCAPE IPP_ORIENT_LANDSCAPE
-# define IPP_REVERSE_LANDSCAPE IPP_ORIENT_REVERSE_LANDSCAPE
-# define IPP_REVERSE_PORTRAIT IPP_ORIENT_REVERSE_PORTRAIT
-# endif /* !_CUPS_NO_DEPRECATED */
+ IPP_ORIENT_PORTRAIT = 3, // No rotation
+ IPP_ORIENT_LANDSCAPE, // 90 degrees counter-clockwise
+ IPP_ORIENT_REVERSE_LANDSCAPE, // 90 degrees clockwise
+ IPP_ORIENT_REVERSE_PORTRAIT, // 180 degrees
+ IPP_ORIENT_NONE // No rotation
} ipp_orient_t;
-typedef enum ipp_pstate_e /**** Printer state values ****/
+typedef enum ipp_pstate_e // Printer state values
{
- IPP_PSTATE_IDLE = 3, /* Printer is idle */
- IPP_PSTATE_PROCESSING, /* Printer is working */
- IPP_PSTATE_STOPPED /* Printer is stopped */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_PRINTER_IDLE IPP_PSTATE_IDLE
-# define IPP_PRINTER_PROCESSING IPP_PSTATE_PROCESSING
-# define IPP_PRINTER_STOPPED IPP_PSTATE_STOPPED
-# endif /* _CUPS_NO_DEPRECATED */
+ IPP_PSTATE_IDLE = 3, // Printer is idle
+ IPP_PSTATE_PROCESSING, // Printer is working
+ IPP_PSTATE_STOPPED // Printer is stopped
} ipp_pstate_t;
-typedef enum ipp_quality_e /**** Print quality values ****/
+typedef enum ipp_quality_e // Print quality values
{
- IPP_QUALITY_DRAFT = 3, /* Draft quality */
- IPP_QUALITY_NORMAL, /* Normal quality */
- IPP_QUALITY_HIGH /* High quality */
+ IPP_QUALITY_DRAFT = 3, // Draft quality
+ IPP_QUALITY_NORMAL, // Normal quality
+ IPP_QUALITY_HIGH // High quality
} ipp_quality_t;
-typedef enum ipp_res_e /**** Resolution units ****/
+typedef enum ipp_res_e // Resolution units
{
- IPP_RES_PER_INCH = 3, /* Pixels per inch */
- IPP_RES_PER_CM /* Pixels per centimeter */
+ IPP_RES_PER_INCH = 3, // Pixels per inch
+ IPP_RES_PER_CM // Pixels per centimeter
} ipp_res_t;
-typedef enum ipp_rstate_e /**** resource-state values ****/
+typedef enum ipp_rstate_e // resource-state values
{
- IPP_RSTATE_PENDING = 3, /* Resource is created but has no data yet. */
- IPP_RSTATE_AVAILABLE, /* Resource is available for installation. */
- IPP_RSTATE_INSTALLED, /* Resource is installed. */
- IPP_RSTATE_CANCELED, /* Resource has been canceled and is pending deletion. */
- IPP_RSTATE_ABORTED /* Resource has been aborted and is pending deletion. */
+ IPP_RSTATE_PENDING = 3, // Resource is created but has no data yet.
+ IPP_RSTATE_AVAILABLE, // Resource is available for installation.
+ IPP_RSTATE_INSTALLED, // Resource is installed.
+ IPP_RSTATE_CANCELED, // Resource has been canceled and is pending deletion.
+ IPP_RSTATE_ABORTED // Resource has been aborted and is pending deletion.
} ipp_rstate_t;
-typedef enum ipp_sstate_e /**** system-state values ****/
+typedef enum ipp_sstate_e // system-state values
{
- IPP_SSTATE_IDLE = 3, /* At least one printer is idle and none are processing a job. */
- IPP_SSTATE_PROCESSING, /* At least one printer is processing a job. */
- IPP_SSTATE_STOPPED /* All printers are stopped. */
+ IPP_SSTATE_IDLE = 3, // At least one printer is idle and none are processing a job.
+ IPP_SSTATE_PROCESSING, // At least one printer is processing a job.
+ IPP_SSTATE_STOPPED // All printers are stopped.
} ipp_sstate_t;
-typedef enum ipp_state_e /**** ipp_t state values ****/
+typedef enum ipp_state_e // ipp_t state values
{
- IPP_STATE_ERROR = -1, /* An error occurred */
- IPP_STATE_IDLE, /* Nothing is happening/request completed */
- IPP_STATE_HEADER, /* The request header needs to be sent/received */
- IPP_STATE_ATTRIBUTE, /* One or more attributes need to be sent/received */
- IPP_STATE_DATA /* IPP request data needs to be sent/received */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_ERROR IPP_STATE_ERROR
-# define IPP_IDLE IPP_STATE_IDLE
-# define IPP_HEADER IPP_STATE_HEADER
-# define IPP_ATTRIBUTE IPP_STATE_ATTRIBUTE
-# define IPP_DATA IPP_STATE_DATA
-# endif /* !_CUPS_NO_DEPRECATED */
+ IPP_STATE_ERROR = -1, // An error occurred
+ IPP_STATE_IDLE, // Nothing is happening/request completed
+ IPP_STATE_HEADER, // The request header needs to be sent/received
+ IPP_STATE_ATTRIBUTE, // One or more attributes need to be sent/received
+ IPP_STATE_DATA // IPP request data needs to be sent/received
} ipp_state_t;
-typedef enum ipp_status_e /**** IPP status code values ****/
+typedef enum ipp_status_e // IPP status code values
{
- IPP_STATUS_CUPS_INVALID = -1, /* Invalid status name for @link ippErrorValue@ */
- IPP_STATUS_OK = 0x0000, /* successful-ok */
- IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED, /* successful-ok-ignored-or-substituted-attributes */
- IPP_STATUS_OK_CONFLICTING, /* successful-ok-conflicting-attributes */
- IPP_STATUS_OK_IGNORED_SUBSCRIPTIONS, /* successful-ok-ignored-subscriptions */
- IPP_STATUS_OK_IGNORED_NOTIFICATIONS, /* successful-ok-ignored-notifications @private@ */
- IPP_STATUS_OK_TOO_MANY_EVENTS, /* successful-ok-too-many-events */
- IPP_STATUS_OK_BUT_CANCEL_SUBSCRIPTION,/* successful-ok-but-cancel-subscription @private@ */
- IPP_STATUS_OK_EVENTS_COMPLETE, /* successful-ok-events-complete */
+ IPP_STATUS_CUPS_INVALID = -1, // Invalid status name for @link ippErrorValue@
+ IPP_STATUS_OK = 0x0000, // successful-ok
+ IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED, // successful-ok-ignored-or-substituted-attributes
+ IPP_STATUS_OK_CONFLICTING, // successful-ok-conflicting-attributes
+ IPP_STATUS_OK_IGNORED_SUBSCRIPTIONS, // successful-ok-ignored-subscriptions
+ IPP_STATUS_OK_IGNORED_NOTIFICATIONS, // successful-ok-ignored-notifications @private@
+ IPP_STATUS_OK_TOO_MANY_EVENTS, // successful-ok-too-many-events
+ IPP_STATUS_OK_BUT_CANCEL_SUBSCRIPTION,// successful-ok-but-cancel-subscription @private@
+ IPP_STATUS_OK_EVENTS_COMPLETE, // successful-ok-events-complete
IPP_STATUS_REDIRECTION_OTHER_SITE = 0x0200,
- /* redirection-other-site @private@ */
- IPP_STATUS_CUPS_SEE_OTHER = 0x0280, /* cups-see-other @private@ */
- IPP_STATUS_ERROR_BAD_REQUEST = 0x0400,/* client-error-bad-request */
- IPP_STATUS_ERROR_FORBIDDEN, /* client-error-forbidden */
- IPP_STATUS_ERROR_NOT_AUTHENTICATED, /* client-error-not-authenticated */
- IPP_STATUS_ERROR_NOT_AUTHORIZED, /* client-error-not-authorized */
- IPP_STATUS_ERROR_NOT_POSSIBLE, /* client-error-not-possible */
- IPP_STATUS_ERROR_TIMEOUT, /* client-error-timeout */
- IPP_STATUS_ERROR_NOT_FOUND, /* client-error-not-found */
- IPP_STATUS_ERROR_GONE, /* client-error-gone */
- IPP_STATUS_ERROR_REQUEST_ENTITY, /* client-error-request-entity-too-large */
- IPP_STATUS_ERROR_REQUEST_VALUE, /* client-error-request-value-too-long */
+ // redirection-other-site @private@
+ IPP_STATUS_CUPS_SEE_OTHER = 0x0280, // cups-see-other @private@
+ IPP_STATUS_ERROR_BAD_REQUEST = 0x0400,// client-error-bad-request
+ IPP_STATUS_ERROR_FORBIDDEN, // client-error-forbidden
+ IPP_STATUS_ERROR_NOT_AUTHENTICATED, // client-error-not-authenticated
+ IPP_STATUS_ERROR_NOT_AUTHORIZED, // client-error-not-authorized
+ IPP_STATUS_ERROR_NOT_POSSIBLE, // client-error-not-possible
+ IPP_STATUS_ERROR_TIMEOUT, // client-error-timeout
+ IPP_STATUS_ERROR_NOT_FOUND, // client-error-not-found
+ IPP_STATUS_ERROR_GONE, // client-error-gone
+ IPP_STATUS_ERROR_REQUEST_ENTITY, // client-error-request-entity-too-large
+ IPP_STATUS_ERROR_REQUEST_VALUE, // client-error-request-value-too-long
IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED,
- /* client-error-document-format-not-supported */
- IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,/* client-error-attributes-or-values-not-supported */
- IPP_STATUS_ERROR_URI_SCHEME, /* client-error-uri-scheme-not-supported */
- IPP_STATUS_ERROR_CHARSET, /* client-error-charset-not-supported */
- IPP_STATUS_ERROR_CONFLICTING, /* client-error-conflicting-attributes */
+ // client-error-document-format-not-supported
+ IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,// client-error-attributes-or-values-not-supported
+ IPP_STATUS_ERROR_URI_SCHEME, // client-error-uri-scheme-not-supported
+ IPP_STATUS_ERROR_CHARSET, // client-error-charset-not-supported
+ IPP_STATUS_ERROR_CONFLICTING, // client-error-conflicting-attributes
IPP_STATUS_ERROR_COMPRESSION_NOT_SUPPORTED,
- /* client-error-compression-not-supported */
- IPP_STATUS_ERROR_COMPRESSION_ERROR, /* client-error-compression-error */
+ // client-error-compression-not-supported
+ IPP_STATUS_ERROR_COMPRESSION_ERROR, // client-error-compression-error
IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR,
- /* client-error-document-format-error */
- IPP_STATUS_ERROR_DOCUMENT_ACCESS, /* client-error-document-access-error */
+ // client-error-document-format-error
+ IPP_STATUS_ERROR_DOCUMENT_ACCESS, // client-error-document-access-error
IPP_STATUS_ERROR_ATTRIBUTES_NOT_SETTABLE,
- /* client-error-attributes-not-settable */
+ // client-error-attributes-not-settable
IPP_STATUS_ERROR_IGNORED_ALL_SUBSCRIPTIONS,
- /* client-error-ignored-all-subscriptions */
+ // client-error-ignored-all-subscriptions
IPP_STATUS_ERROR_TOO_MANY_SUBSCRIPTIONS,
- /* client-error-too-many-subscriptions */
+ // client-error-too-many-subscriptions
IPP_STATUS_ERROR_IGNORED_ALL_NOTIFICATIONS,
- /* client-error-ignored-all-notifications @private@ */
+ // client-error-ignored-all-notifications @private@
IPP_STATUS_ERROR_PRINT_SUPPORT_FILE_NOT_FOUND,
- /* client-error-print-support-file-not-found @private@ */
- IPP_STATUS_ERROR_DOCUMENT_PASSWORD, /* client-error-document-password-error */
- IPP_STATUS_ERROR_DOCUMENT_PERMISSION, /* client-error-document-permission-error */
- IPP_STATUS_ERROR_DOCUMENT_SECURITY, /* client-error-document-security-error */
- IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE,/* client-error-document-unprintable-error */
- IPP_STATUS_ERROR_ACCOUNT_INFO_NEEDED, /* client-error-account-info-needed */
- IPP_STATUS_ERROR_ACCOUNT_CLOSED, /* client-error-account-closed */
+ // client-error-print-support-file-not-found @private@
+ IPP_STATUS_ERROR_DOCUMENT_PASSWORD, // client-error-document-password-error
+ IPP_STATUS_ERROR_DOCUMENT_PERMISSION, // client-error-document-permission-error
+ IPP_STATUS_ERROR_DOCUMENT_SECURITY, // client-error-document-security-error
+ IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE,// client-error-document-unprintable-error
+ IPP_STATUS_ERROR_ACCOUNT_INFO_NEEDED, // client-error-account-info-needed
+ IPP_STATUS_ERROR_ACCOUNT_CLOSED, // client-error-account-closed
IPP_STATUS_ERROR_ACCOUNT_LIMIT_REACHED,
- /* client-error-account-limit-reached */
+ // client-error-account-limit-reached
IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED,
- /* client-error-account-authorization-failed */
- IPP_STATUS_ERROR_NOT_FETCHABLE, /* client-error-not-fetchable */
+ // client-error-account-authorization-failed
+ IPP_STATUS_ERROR_NOT_FETCHABLE, // client-error-not-fetchable
- /* Legacy status codes for paid printing */
+ // Legacy status codes for paid printing
IPP_STATUS_ERROR_CUPS_ACCOUNT_INFO_NEEDED = 0x049C,
- /* cups-error-account-info-needed @deprecated@ */
- IPP_STATUS_ERROR_CUPS_ACCOUNT_CLOSED, /* cups-error-account-closed @deprecate@ */
+ // cups-error-account-info-needed @deprecated@
+ IPP_STATUS_ERROR_CUPS_ACCOUNT_CLOSED, // cups-error-account-closed @deprecate@
IPP_STATUS_ERROR_CUPS_ACCOUNT_LIMIT_REACHED,
- /* cups-error-account-limit-reached @deprecated@ */
+ // cups-error-account-limit-reached @deprecated@
IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED,
- /* cups-error-account-authorization-failed @deprecated@ */
+ // cups-error-account-authorization-failed @deprecated@
- IPP_STATUS_ERROR_INTERNAL = 0x0500, /* server-error-internal-error */
+ IPP_STATUS_ERROR_INTERNAL = 0x0500, // server-error-internal-error
IPP_STATUS_ERROR_OPERATION_NOT_SUPPORTED,
- /* server-error-operation-not-supported */
- IPP_STATUS_ERROR_SERVICE_UNAVAILABLE, /* server-error-service-unavailable */
+ // server-error-operation-not-supported
+ IPP_STATUS_ERROR_SERVICE_UNAVAILABLE, // server-error-service-unavailable
IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED,
- /* server-error-version-not-supported */
- IPP_STATUS_ERROR_DEVICE, /* server-error-device-error */
- IPP_STATUS_ERROR_TEMPORARY, /* server-error-temporary-error */
- IPP_STATUS_ERROR_NOT_ACCEPTING_JOBS, /* server-error-not-accepting-jobs */
- IPP_STATUS_ERROR_BUSY, /* server-error-busy */
- IPP_STATUS_ERROR_JOB_CANCELED, /* server-error-job-canceled */
+ // server-error-version-not-supported
+ IPP_STATUS_ERROR_DEVICE, // server-error-device-error
+ IPP_STATUS_ERROR_TEMPORARY, // server-error-temporary-error
+ IPP_STATUS_ERROR_NOT_ACCEPTING_JOBS, // server-error-not-accepting-jobs
+ IPP_STATUS_ERROR_BUSY, // server-error-busy
+ IPP_STATUS_ERROR_JOB_CANCELED, // server-error-job-canceled
IPP_STATUS_ERROR_MULTIPLE_JOBS_NOT_SUPPORTED,
- /* server-error-multiple-document-jobs-not-supported */
+ // server-error-multiple-document-jobs-not-supported
IPP_STATUS_ERROR_PRINTER_IS_DEACTIVATED,
- /* server-error-printer-is-deactivated */
- IPP_STATUS_ERROR_TOO_MANY_JOBS, /* server-error-too-many-jobs */
- IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS, /* server-error-too-many-documents */
+ // server-error-printer-is-deactivated
+ IPP_STATUS_ERROR_TOO_MANY_JOBS, // server-error-too-many-jobs
+ IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS, // server-error-too-many-documents
- /* These are internal and never sent over the wire... */
+ // These are internal and never sent over the wire...
IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED = 0x1000,
- /* cups-authentication-canceled - Authentication canceled by user @since CUPS 1.5/macOS 10.7@ */
- IPP_STATUS_ERROR_CUPS_PKI, /* cups-pki-error - Error negotiating a secure connection @since CUPS 1.5/macOS 10.7@ */
- IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED/* cups-upgrade-required - TLS upgrade required @since CUPS 1.5/macOS 10.7@ */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_OK IPP_STATUS_OK
-# define IPP_OK_SUBST IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED
-# define IPP_OK_CONFLICT IPP_STATUS_OK_CONFLICTING
-# define IPP_OK_IGNORED_SUBSCRIPTIONS IPP_STATUS_OK_IGNORED_SUBSCRIPTIONS
-# define IPP_OK_IGNORED_NOTIFICATIONS IPP_STATUS_OK_IGNORED_NOTIFICATIONS
-# define IPP_OK_TOO_MANY_EVENTS IPP_STATUS_OK_TOO_MANY_EVENTS
-# define IPP_OK_BUT_CANCEL_SUBSCRIPTION IPP_STATUS_OK_BUT_CANCEL_SUBSCRIPTION
-# define IPP_OK_EVENTS_COMPLETE IPP_STATUS_OK_EVENTS_COMPLETE
-# define IPP_REDIRECTION_OTHER_SITE IPP_STATUS_REDIRECTION_OTHER_SITE
-# define CUPS_SEE_OTHER IPP_STATUS_CUPS_SEE_OTHER
-# define IPP_BAD_REQUEST IPP_STATUS_ERROR_BAD_REQUEST
-# define IPP_FORBIDDEN IPP_STATUS_ERROR_FORBIDDEN
-# define IPP_NOT_AUTHENTICATED IPP_STATUS_ERROR_NOT_AUTHENTICATED
-# define IPP_NOT_AUTHORIZED IPP_STATUS_ERROR_NOT_AUTHORIZED
-# define IPP_NOT_POSSIBLE IPP_STATUS_ERROR_NOT_POSSIBLE
-# define IPP_TIMEOUT IPP_STATUS_ERROR_TIMEOUT
-# define IPP_NOT_FOUND IPP_STATUS_ERROR_NOT_FOUND
-# define IPP_GONE IPP_STATUS_ERROR_GONE
-# define IPP_REQUEST_ENTITY IPP_STATUS_ERROR_REQUEST_ENTITY
-# define IPP_REQUEST_VALUE IPP_STATUS_ERROR_REQUEST_VALUE
-# define IPP_DOCUMENT_FORMAT IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED
-# define IPP_ATTRIBUTES IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES
-# define IPP_URI_SCHEME IPP_STATUS_ERROR_URI_SCHEME
-# define IPP_CHARSET IPP_STATUS_ERROR_CHARSET
-# define IPP_CONFLICT IPP_STATUS_ERROR_CONFLICTING
-# define IPP_COMPRESSION_NOT_SUPPORTED IPP_STATUS_ERROR_COMPRESSION_NOT_SUPPORTED
-# define IPP_COMPRESSION_ERROR IPP_STATUS_ERROR_COMPRESSION_ERROR
-# define IPP_DOCUMENT_FORMAT_ERROR IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR
-# define IPP_DOCUMENT_ACCESS_ERROR IPP_STATUS_ERROR_DOCUMENT_ACCESS
-# define IPP_ATTRIBUTES_NOT_SETTABLE IPP_STATUS_ERROR_ATTRIBUTES_NOT_SETTABLE
-# define IPP_IGNORED_ALL_SUBSCRIPTIONS IPP_STATUS_ERROR_IGNORED_ALL_SUBSCRIPTIONS
-# define IPP_TOO_MANY_SUBSCRIPTIONS IPP_STATUS_ERROR_TOO_MANY_SUBSCRIPTIONS
-# define IPP_IGNORED_ALL_NOTIFICATIONS IPP_STATUS_ERROR_IGNORED_ALL_NOTIFICATIONS
-# define IPP_PRINT_SUPPORT_FILE_NOT_FOUND IPP_STATUS_ERROR_PRINT_SUPPORT_FILE_NOT_FOUND
-# define IPP_DOCUMENT_PASSWORD_ERROR IPP_STATUS_ERROR_DOCUMENT_PASSWORD
-# define IPP_DOCUMENT_PERMISSION_ERROR IPP_STATUS_ERROR_DOCUMENT_PERMISSION
-# define IPP_DOCUMENT_SECURITY_ERROR IPP_STATUS_ERROR_DOCUMENT_SECURITY
-# define IPP_DOCUMENT_UNPRINTABLE_ERROR IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE
-# define IPP_INTERNAL_ERROR IPP_STATUS_ERROR_INTERNAL
-# define IPP_OPERATION_NOT_SUPPORTED IPP_STATUS_ERROR_OPERATION_NOT_SUPPORTED
-# define IPP_SERVICE_UNAVAILABLE IPP_STATUS_ERROR_SERVICE_UNAVAILABLE
-# define IPP_VERSION_NOT_SUPPORTED IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED
-# define IPP_DEVICE_ERROR IPP_STATUS_ERROR_DEVICE
-# define IPP_TEMPORARY_ERROR IPP_STATUS_ERROR_TEMPORARY
-# define IPP_NOT_ACCEPTING IPP_STATUS_ERROR_NOT_ACCEPTING_JOBS
-# define IPP_PRINTER_BUSY IPP_STATUS_ERROR_BUSY
-# define IPP_ERROR_JOB_CANCELED IPP_STATUS_ERROR_JOB_CANCELED
-# define IPP_MULTIPLE_JOBS_NOT_SUPPORTED IPP_STATUS_ERROR_MULTIPLE_JOBS_NOT_SUPPORTED
-# define IPP_PRINTER_IS_DEACTIVATED IPP_STATUS_ERROR_PRINTER_IS_DEACTIVATED
-# define IPP_TOO_MANY_JOBS IPP_STATUS_ERROR_TOO_MANY_JOBS
-# define IPP_TOO_MANY_DOCUMENTS IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS
-# define IPP_AUTHENTICATION_CANCELED IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED
-# define IPP_PKI_ERROR IPP_STATUS_ERROR_CUPS_PKI
-# define IPP_UPGRADE_REQUIRED IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED
- /* Legacy name for canceled status */
-# define IPP_ERROR_JOB_CANCELLED IPP_STATUS_ERROR_JOB_CANCELED
-# endif /* _CUPS_NO_DEPRECATED */
+ // cups-authentication-canceled - Authentication canceled by user @since CUPS 1.5/macOS 10.7@
+ IPP_STATUS_ERROR_CUPS_PKI, // cups-pki-error - Error negotiating a secure connection @since CUPS 1.5/macOS 10.7@
+ IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED// cups-upgrade-required - TLS upgrade required @since CUPS 1.5/macOS 10.7@
} ipp_status_t;
-typedef enum ipp_tag_e /**** Value and group tag values for attributes ****/
+typedef enum ipp_tag_e // Value and group tag values for attributes
{
- IPP_TAG_CUPS_INVALID = -1, /* Invalid tag name for @link ippTagValue@ */
- IPP_TAG_ZERO = 0x00, /* Zero tag - used for separators */
- IPP_TAG_OPERATION, /* Operation group */
- IPP_TAG_JOB, /* Job group */
- IPP_TAG_END, /* End-of-attributes */
- IPP_TAG_PRINTER, /* Printer group */
- IPP_TAG_UNSUPPORTED_GROUP, /* Unsupported attributes group */
- IPP_TAG_SUBSCRIPTION, /* Subscription group */
- IPP_TAG_EVENT_NOTIFICATION, /* Event group */
- IPP_TAG_RESOURCE, /* Resource group */
- IPP_TAG_DOCUMENT, /* Document group */
- IPP_TAG_SYSTEM, /* System group */
- IPP_TAG_UNSUPPORTED_VALUE = 0x10, /* Unsupported value */
- IPP_TAG_DEFAULT, /* Default value */
- IPP_TAG_UNKNOWN, /* Unknown value */
- IPP_TAG_NOVALUE, /* No-value value */
- IPP_TAG_NOTSETTABLE = 0x15, /* Not-settable value */
- IPP_TAG_DELETEATTR, /* Delete-attribute value */
- IPP_TAG_ADMINDEFINE, /* Admin-defined value */
- IPP_TAG_INTEGER = 0x21, /* Integer value */
- IPP_TAG_BOOLEAN, /* Boolean value */
- IPP_TAG_ENUM, /* Enumeration value */
- IPP_TAG_STRING = 0x30, /* Octet string value */
- IPP_TAG_DATE, /* Date/time value */
- IPP_TAG_RESOLUTION, /* Resolution value */
- IPP_TAG_RANGE, /* Range value */
- IPP_TAG_BEGIN_COLLECTION, /* Beginning of collection value @exclude all@ */
- IPP_TAG_TEXTLANG, /* Text-with-language value */
- IPP_TAG_NAMELANG, /* Name-with-language value */
- IPP_TAG_END_COLLECTION, /* End of collection value @exclude all@ */
- IPP_TAG_TEXT = 0x41, /* Text value */
- IPP_TAG_NAME, /* Name value */
- IPP_TAG_RESERVED_STRING, /* Reserved for future string value @private@ */
- IPP_TAG_KEYWORD, /* Keyword value */
- IPP_TAG_URI, /* URI value */
- IPP_TAG_URISCHEME, /* URI scheme value */
- IPP_TAG_CHARSET, /* Character set value */
- IPP_TAG_LANGUAGE, /* Language value */
- IPP_TAG_MIMETYPE, /* MIME media type value */
- IPP_TAG_MEMBERNAME, /* Collection member name value @exclude all@ */
- IPP_TAG_EXTENSION = 0x7f, /* Extension point for 32-bit tags @exclude all@ */
- IPP_TAG_CUPS_MASK = 0x7fffffff, /* Mask for copied attribute values @private@ */
- /* The following expression is used to avoid compiler warnings with +/-0x80000000 */
- IPP_TAG_CUPS_CONST = -0x7fffffff-1 /* Bitflag for copied/const attribute values @private@ */
-
-# ifndef _CUPS_NO_DEPRECATED
-# define IPP_TAG_MASK IPP_TAG_CUPS_MASK
-# define IPP_TAG_COPY IPP_TAG_CUPS_CONST
-# endif /* !_CUPS_NO_DEPRECATED */
+ IPP_TAG_CUPS_INVALID = -1, // Invalid tag name for @link ippTagValue@
+ IPP_TAG_ZERO = 0x00, // Zero tag - used for separators
+ IPP_TAG_OPERATION, // Operation group
+ IPP_TAG_JOB, // Job group
+ IPP_TAG_END, // End-of-attributes
+ IPP_TAG_PRINTER, // Printer group
+ IPP_TAG_UNSUPPORTED_GROUP, // Unsupported attributes group
+ IPP_TAG_SUBSCRIPTION, // Subscription group
+ IPP_TAG_EVENT_NOTIFICATION, // Event group
+ IPP_TAG_RESOURCE, // Resource group
+ IPP_TAG_DOCUMENT, // Document group
+ IPP_TAG_SYSTEM, // System group
+ IPP_TAG_UNSUPPORTED_VALUE = 0x10, // Unsupported value
+ IPP_TAG_DEFAULT, // Default value
+ IPP_TAG_UNKNOWN, // Unknown value
+ IPP_TAG_NOVALUE, // No-value value
+ IPP_TAG_NOTSETTABLE = 0x15, // Not-settable value
+ IPP_TAG_DELETEATTR, // Delete-attribute value
+ IPP_TAG_ADMINDEFINE, // Admin-defined value
+ IPP_TAG_INTEGER = 0x21, // Integer value
+ IPP_TAG_BOOLEAN, // Boolean value
+ IPP_TAG_ENUM, // Enumeration value
+ IPP_TAG_STRING = 0x30, // Octet string value
+ IPP_TAG_DATE, // Date/time value
+ IPP_TAG_RESOLUTION, // Resolution value
+ IPP_TAG_RANGE, // Range value
+ IPP_TAG_BEGIN_COLLECTION, // Beginning of collection value @exclude all@
+ IPP_TAG_TEXTLANG, // Text-with-language value
+ IPP_TAG_NAMELANG, // Name-with-language value
+ IPP_TAG_END_COLLECTION, // End of collection value @exclude all@
+ IPP_TAG_TEXT = 0x41, // Text value
+ IPP_TAG_NAME, // Name value
+ IPP_TAG_RESERVED_STRING, // Reserved for future string value @private@
+ IPP_TAG_KEYWORD, // Keyword value
+ IPP_TAG_URI, // URI value
+ IPP_TAG_URISCHEME, // URI scheme value
+ IPP_TAG_CHARSET, // Character set value
+ IPP_TAG_LANGUAGE, // Language value
+ IPP_TAG_MIMETYPE, // MIME media type value
+ IPP_TAG_MEMBERNAME, // Collection member name value @exclude all@
+ IPP_TAG_EXTENSION = 0x7f, // Extension point for 32-bit tags @exclude all@
+ IPP_TAG_CUPS_MASK = 0x7fffffff, // Mask for copied attribute values @private@
+ // The following expression is used to avoid compiler warnings with +/-0x80000000
+ IPP_TAG_CUPS_CONST = -0x7fffffff-1 // Bitflag for copied/const attribute values @private@
} ipp_tag_t;
-typedef unsigned char ipp_uchar_t; /**** Unsigned 8-bit integer/character @exclude all@ ****/
-typedef struct _ipp_s ipp_t; /**** IPP request/response data ****/
+typedef unsigned char ipp_uchar_t; // Unsigned 8-bit integer/character @exclude all@
+typedef struct _ipp_s ipp_t; // IPP request/response data
typedef struct _ipp_attribute_s ipp_attribute_t;
- /**** IPP attribute ****/
-
-/**** New in CUPS 1.2/macOS 10.5 ****/
-typedef ssize_t (*ipp_iocb_t)(void *context, ipp_uchar_t *buffer, size_t bytes);
- /**** ippReadIO/ippWriteIO callback function @since CUPS 1.2/macOS 10.5@ ****/
-
-/**** New in CUPS 1.6/macOS 10.8 ****/
-typedef int (*ipp_copycb_t)(void *context, ipp_t *dst, ipp_attribute_t *attr);
- /**** ippCopyAttributes callback function @since CUPS 1.6/macOS 10.8 ****/
-
-
-/*
- * Prototypes...
- */
-
-extern ipp_attribute_t *ippAddBoolean(ipp_t *ipp, ipp_tag_t group,
- const char *name, char value) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddBooleans(ipp_t *ipp, ipp_tag_t group,
- const char *name, int num_values,
- const char *values) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group,
- const char *name, const ipp_uchar_t *value) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name,
- int value) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name,
- int num_values, const int *values) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group,
- const char *name, int lower, int upper) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddRanges(ipp_t *ipp, ipp_tag_t group,
- const char *name, int num_values,
- const int *lower, const int *upper) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddResolution(ipp_t *ipp, ipp_tag_t group,
- const char *name, ipp_res_t units,
- int xres, int yres) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddResolutions(ipp_t *ipp, ipp_tag_t group,
- const char *name, int num_values,
- ipp_res_t units, const int *xres,
- const int *yres) _CUPS_PUBLIC;
+ // IPP attribute
+
+typedef int (*ipp_copy_cb_t)(void *context, ipp_t *dst, ipp_attribute_t *attr);
+ // ippCopyAttributes callback function @since CUPS 1.6/macOS 10.8
+#define ipp_copycb_t ipp_copy_cb_t // Old name
+
+typedef struct _ipp_file_s ipp_file_t; // IPP data file
+typedef bool (*ipp_fattr_cb_t)(ipp_file_t *file, void *cb_data, const char *name);
+ // IPP data file attribute callback
+typedef bool (*ipp_ferror_cb_t)(ipp_file_t *file, void *cb_data, const char *error);
+ // IPP data file error callback
+typedef bool (*ipp_ftoken_cb_t)(ipp_file_t *file, void *cb_data, const char *token);
+ // IPP data file token callback
+
+typedef ssize_t (*ipp_io_cb_t)(void *context, ipp_uchar_t *buffer, size_t bytes);
+ // ippReadIO/ippWriteIO callback function @since CUPS 1.2/macOS 10.5@
+#define ipp_iocb_t ipp_io_cb_t // Old name
+
+
+//
+// Functions...
+//
+
+extern ipp_attribute_t *ippAddBoolean(ipp_t *ipp, ipp_tag_t group, const char *name, char value) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddBooleans(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const char *values) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddCollection(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_t *value) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddCollections(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const ipp_t **values) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group, const char *name, const ipp_uchar_t *value) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, int value) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, int num_values, const int *values) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddOctetString(ipp_t *ipp, ipp_tag_t group, const char *name, const void *data, int datalen) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddOutOfBand(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group, const char *name, int lower, int upper) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddRanges(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const int *lower, const int *upper) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddResolution(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_res_t units, int xres, int yres) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddResolutions(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, ipp_res_t units, const int *xres, const int *yres) _CUPS_PUBLIC;
extern ipp_attribute_t *ippAddSeparator(ipp_t *ipp) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name,
- const char *language, const char *value) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name,
- int num_values, const char *language,
- const char * const *values) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, const char *language, const char *value) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddStringf(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, const char *language, const char *format, ...) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddStringfv(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, const char *language, const char *format, va_list ap) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, int num_values, const char *language, const char * const *values) _CUPS_PUBLIC;
+extern size_t ippAttributeString(ipp_attribute_t *attr, char *buffer, size_t bufsize) _CUPS_PUBLIC;
+
+extern int ippContainsInteger(ipp_attribute_t *attr, int value) _CUPS_PUBLIC;
+extern int ippContainsString(ipp_attribute_t *attr, const char *value) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippCopyAttribute(ipp_t *dst, ipp_attribute_t *attr, int quickcopy) _CUPS_PUBLIC;
+extern int ippCopyAttributes(ipp_t *dst, ipp_t *src, int quickcopy, ipp_copy_cb_t cb, void *context) _CUPS_PUBLIC;
+extern cups_array_t *ippCreateRequestedArray(ipp_t *request) _CUPS_PUBLIC;
+
extern time_t ippDateToTime(const ipp_uchar_t *date) _CUPS_PUBLIC;
extern void ippDelete(ipp_t *ipp) _CUPS_PUBLIC;
+extern void ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr) _CUPS_PUBLIC;
+extern int ippDeleteValues(ipp_t *ipp, ipp_attribute_t **attr, int element, int count) _CUPS_PUBLIC;
+
+extern const char *ippEnumString(const char *attrname, int enumvalue) _CUPS_PUBLIC;
+extern int ippEnumValue(const char *attrname, const char *enumstring) _CUPS_PUBLIC;
extern const char *ippErrorString(ipp_status_t error) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, const char *name,
- ipp_tag_t value_tag) _CUPS_PUBLIC;
-extern ipp_attribute_t *ippFindNextAttribute(ipp_t *ipp, const char *name,
- ipp_tag_t value_tag) _CUPS_PUBLIC;
-extern size_t ippLength(ipp_t *ipp) _CUPS_PUBLIC;
+extern ipp_status_t ippErrorValue(const char *name) _CUPS_PUBLIC;
+
+extern bool ippFileClose(ipp_file_t *file) _CUPS_PUBLIC;
+extern bool ippFileDelete(ipp_file_t *file) _CUPS_PUBLIC;
+extern size_t ippFileExpandVars(ipp_file_t *file, char *dst, const char *src, size_t dstsize) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippFileGetAttribute(ipp_file_t *file, const char *name, ipp_tag_t value_tag) _CUPS_PUBLIC;
+extern ipp_t *ippFileGetAttributes(ipp_file_t *file) _CUPS_PUBLIC;
+extern const char *ippFileGetFilename(ipp_file_t *file) _CUPS_PUBLIC;
+extern int ippFileGetLineNumber(ipp_file_t *file) _CUPS_PUBLIC;
+extern const char *ippFileGetVar(ipp_file_t *file, const char *name) _CUPS_PUBLIC;
+extern ipp_file_t *ippFileNew(ipp_file_t *parent, ipp_fattr_cb_t attr_cb, ipp_ferror_cb_t error_cb, void *cb_data) _CUPS_PUBLIC;
+extern bool ippFileOpen(ipp_file_t *file, const char *filename, const char *mode) _CUPS_PUBLIC;
+extern bool ippFileRead(ipp_file_t *file, ipp_ftoken_cb_t token_cb, bool with_groups) _CUPS_PUBLIC;
+extern ipp_t *ippFileReadCollection(ipp_file_t *file) _CUPS_PUBLIC;
+extern bool ippFileReadToken(ipp_file_t *file, char *token, size_t tokensize) _CUPS_PUBLIC;
+extern bool ippFileRestorePosition(ipp_file_t *file) _CUPS_PUBLIC;
+extern bool ippFileSavePosition(ipp_file_t *file) _CUPS_PUBLIC;
+extern bool ippFileSetAttributes(ipp_file_t *file, ipp_t *attrs) _CUPS_PUBLIC;
+extern bool ippFileSetGroupTag(ipp_file_t *file, ipp_tag_t group_tag) _CUPS_PUBLIC;
+extern bool ippFileSetVar(ipp_file_t *file, const char *name, const char *value) _CUPS_PUBLIC;
+extern bool ippFileSetVarf(ipp_file_t *file, const char *name, const char *value, ...) _CUPS_FORMAT(3,4) _CUPS_PUBLIC;
+extern bool ippFileWriteAttributes(ipp_file_t *file, ipp_t *ipp, bool with_groups) _CUPS_PUBLIC;
+extern bool ippFileWriteComment(ipp_file_t *file, const char *comment, ...) _CUPS_FORMAT(2,3) _CUPS_PUBLIC;
+extern bool ippFileWriteToken(ipp_file_t *file, const char *token) _CUPS_PUBLIC;
+extern bool ippFileWriteTokenf(ipp_file_t *file, const char *token, ...) _CUPS_FORMAT(2,3) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, const char *name, ipp_tag_t value_tag) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippFindNextAttribute(ipp_t *ipp, const char *name, ipp_tag_t value_tag) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippFirstAttribute(ipp_t *ipp) _CUPS_DEPRECATED_MSG("Use ippGetFirstAttribute instead.");
+
+extern int ippGetBoolean(ipp_attribute_t *attr, int element) _CUPS_PUBLIC;
+extern ipp_t *ippGetCollection(ipp_attribute_t *attr, int element) _CUPS_PUBLIC;
+extern int ippGetCount(ipp_attribute_t *attr) _CUPS_PUBLIC;
+extern const ipp_uchar_t *ippGetDate(ipp_attribute_t *attr, int element) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippGetFirstAttribute(ipp_t *ipp) _CUPS_PUBLIC;
+extern ipp_tag_t ippGetGroupTag(ipp_attribute_t *attr) _CUPS_PUBLIC;
+extern int ippGetInteger(ipp_attribute_t *attr, int element) _CUPS_PUBLIC;
+extern size_t ippGetLength(ipp_t *ipp) _CUPS_PUBLIC;
+extern const char *ippGetName(ipp_attribute_t *attr) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippGetNextAttribute(ipp_t *ipp) _CUPS_PUBLIC;
+extern void *ippGetOctetString(ipp_attribute_t *attr, int element, int *datalen) _CUPS_PUBLIC;
+extern ipp_op_t ippGetOperation(ipp_t *ipp) _CUPS_PUBLIC;
+extern int ippGetPort(void) _CUPS_PUBLIC;
+extern int ippGetRange(ipp_attribute_t *attr, int element, int *upper) _CUPS_PUBLIC;
+extern int ippGetRequestId(ipp_t *ipp) _CUPS_PUBLIC;
+extern int ippGetResolution(ipp_attribute_t *attr, int element, int *yres, ipp_res_t *units) _CUPS_PUBLIC;
+extern ipp_state_t ippGetState(ipp_t *ipp) _CUPS_PUBLIC;
+extern ipp_status_t ippGetStatusCode(ipp_t *ipp) _CUPS_PUBLIC;
+extern const char *ippGetString(ipp_attribute_t *attr, int element, const char **language) _CUPS_PUBLIC;
+extern ipp_tag_t ippGetValueTag(ipp_attribute_t *attr) _CUPS_PUBLIC;
+extern int ippGetVersion(ipp_t *ipp, int *minor) _CUPS_PUBLIC;
+
+extern size_t ippLength(ipp_t *ipp) _CUPS_DEPRECATED_MSG("Use ippGetLength instead.");
+
extern ipp_t *ippNew(void) _CUPS_PUBLIC;
+extern ipp_t *ippNewRequest(ipp_op_t op) _CUPS_PUBLIC;
+extern ipp_t *ippNewResponse(ipp_t *request) _CUPS_PUBLIC;
+extern ipp_attribute_t *ippNextAttribute(ipp_t *ipp) _CUPS_DEPRECATED_MSG("Use ippGetNextAttribute instead.");
+
+extern const char *ippOpString(ipp_op_t op) _CUPS_PUBLIC;
+extern ipp_op_t ippOpValue(const char *name) _CUPS_PUBLIC;
+
+extern int ippPort(void) _CUPS_DEPRECATED_MSG("Use ippGetPort instead.");
+
extern ipp_state_t ippRead(http_t *http, ipp_t *ipp) _CUPS_PUBLIC;
+extern ipp_state_t ippReadFile(int fd, ipp_t *ipp) _CUPS_PUBLIC;
+extern ipp_state_t ippReadIO(void *src, ipp_io_cb_t cb, int blocking, ipp_t *parent, ipp_t *ipp) _CUPS_PUBLIC;
+extern void ippRestore(ipp_t *ipp) _CUPS_PUBLIC;
+
+extern void ippSave(ipp_t *ipp) _CUPS_PUBLIC;
+extern int ippSetBoolean(ipp_t *ipp, ipp_attribute_t **attr, int element, int boolvalue) _CUPS_PUBLIC;
+extern int ippSetCollection(ipp_t *ipp, ipp_attribute_t **attr, int element, ipp_t *colvalue) _CUPS_PUBLIC;
+extern int ippSetDate(ipp_t *ipp, ipp_attribute_t **attr, int element, const ipp_uchar_t *datevalue) _CUPS_PUBLIC;
+extern int ippSetGroupTag(ipp_t *ipp, ipp_attribute_t **attr, ipp_tag_t group_tag) _CUPS_PUBLIC;
+extern int ippSetInteger(ipp_t *ipp, ipp_attribute_t **attr, int element, int intvalue) _CUPS_PUBLIC;
+extern int ippSetName(ipp_t *ipp, ipp_attribute_t **attr, const char *name) _CUPS_PUBLIC;
+extern int ippSetOctetString(ipp_t *ipp, ipp_attribute_t **attr, int element, const void *data, int datalen) _CUPS_PUBLIC;
+extern int ippSetOperation(ipp_t *ipp, ipp_op_t op) _CUPS_PUBLIC;
+extern void ippSetPort(int p) _CUPS_PUBLIC;
+extern int ippSetRange(ipp_t *ipp, ipp_attribute_t **attr, int element, int lowervalue, int uppervalue) _CUPS_PUBLIC;
+extern int ippSetRequestId(ipp_t *ipp, int request_id) _CUPS_PUBLIC;
+extern int ippSetResolution(ipp_t *ipp, ipp_attribute_t **attr, int element, ipp_res_t unitsvalue, int xresvalue, int yresvalue) _CUPS_PUBLIC;
+extern int ippSetState(ipp_t *ipp, ipp_state_t state) _CUPS_PUBLIC;
+extern int ippSetStatusCode(ipp_t *ipp, ipp_status_t status) _CUPS_PUBLIC;
+extern int ippSetString(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *strvalue) _CUPS_PUBLIC;
+extern int ippSetStringf(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *format, ...) _CUPS_PUBLIC;
+extern int ippSetStringfv(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *format, va_list ap) _CUPS_PUBLIC;
+extern int ippSetValueTag(ipp_t *ipp, ipp_attribute_t **attr, ipp_tag_t value_tag) _CUPS_PUBLIC;
+extern int ippSetVersion(ipp_t *ipp, int major, int minor) _CUPS_PUBLIC;
+extern const char *ippStateString(ipp_state_t state) _CUPS_PUBLIC;
+
+extern const char *ippTagString(ipp_tag_t tag) _CUPS_PUBLIC;
+extern ipp_tag_t ippTagValue(const char *name) _CUPS_PUBLIC;
extern const ipp_uchar_t *ippTimeToDate(time_t t) _CUPS_PUBLIC;
+
+extern int ippValidateAttribute(ipp_attribute_t *attr) _CUPS_PUBLIC;
+extern int ippValidateAttributes(ipp_t *ipp) _CUPS_PUBLIC;
+
extern ipp_state_t ippWrite(http_t *http, ipp_t *ipp) _CUPS_PUBLIC;
-extern int ippPort(void) _CUPS_PUBLIC;
-extern void ippSetPort(int p) _CUPS_PUBLIC;
+extern ipp_state_t ippWriteFile(int fd, ipp_t *ipp) _CUPS_PUBLIC;
+extern ipp_state_t ippWriteIO(void *dst, ipp_io_cb_t cb, int blocking, ipp_t *parent, ipp_t *ipp) _CUPS_PUBLIC;
-/**** New in CUPS 1.1.19 ****/
-extern ipp_attribute_t *ippAddCollection(ipp_t *ipp, ipp_tag_t group,
- const char *name, ipp_t *value) _CUPS_API_1_1_19;
-extern ipp_attribute_t *ippAddCollections(ipp_t *ipp, ipp_tag_t group,
- const char *name, int num_values,
- const ipp_t **values) _CUPS_API_1_1_19;
-extern void ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr) _CUPS_API_1_1_19;
-extern ipp_state_t ippReadFile(int fd, ipp_t *ipp) _CUPS_API_1_1_19;
-extern ipp_state_t ippWriteFile(int fd, ipp_t *ipp) _CUPS_API_1_1_19;
-
-/**** New in CUPS 1.2/macOS 10.5 ****/
-extern ipp_attribute_t *ippAddOctetString(ipp_t *ipp, ipp_tag_t group,
- const char *name,
- const void *data, int datalen) _CUPS_API_1_2;
-extern ipp_status_t ippErrorValue(const char *name) _CUPS_API_1_2;
-extern ipp_t *ippNewRequest(ipp_op_t op) _CUPS_API_1_2;
-extern const char *ippOpString(ipp_op_t op) _CUPS_API_1_2;
-extern ipp_op_t ippOpValue(const char *name) _CUPS_API_1_2;
-extern ipp_state_t ippReadIO(void *src, ipp_iocb_t cb, int blocking,
- ipp_t *parent, ipp_t *ipp) _CUPS_API_1_2;
-extern ipp_state_t ippWriteIO(void *dst, ipp_iocb_t cb, int blocking,
- ipp_t *parent, ipp_t *ipp) _CUPS_API_1_2;
-
-/**** New in CUPS 1.4/macOS 10.6 ****/
-extern const char *ippTagString(ipp_tag_t tag) _CUPS_API_1_4;
-extern ipp_tag_t ippTagValue(const char *name) _CUPS_API_1_4;
-
-/**** New in CUPS 1.6/macOS 10.8 ****/
-extern ipp_attribute_t *ippAddOutOfBand(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name)
- _CUPS_API_1_6;
-extern size_t ippAttributeString(ipp_attribute_t *attr, char *buffer,
- size_t bufsize) _CUPS_API_1_6;
-extern ipp_attribute_t *ippCopyAttribute(ipp_t *dst, ipp_attribute_t *attr,
- int quickcopy) _CUPS_API_1_6;
-extern int ippCopyAttributes(ipp_t *dst, ipp_t *src,
- int quickcopy, ipp_copycb_t cb,
- void *context) _CUPS_API_1_6;
-extern int ippDeleteValues(ipp_t *ipp, ipp_attribute_t **attr,
- int element, int count) _CUPS_API_1_6;
-extern const char *ippEnumString(const char *attrname, int enumvalue)
- _CUPS_API_1_6;
-extern int ippEnumValue(const char *attrname,
- const char *enumstring) _CUPS_API_1_6;
-extern ipp_attribute_t *ippFirstAttribute(ipp_t *ipp) _CUPS_API_1_6;
-extern int ippGetBoolean(ipp_attribute_t *attr, int element)
- _CUPS_API_1_6;
-extern ipp_t *ippGetCollection(ipp_attribute_t *attr,
- int element) _CUPS_API_1_6;
-extern int ippGetCount(ipp_attribute_t *attr) _CUPS_API_1_6;
-extern const ipp_uchar_t *ippGetDate(ipp_attribute_t *attr, int element)
- _CUPS_API_1_6;
-extern ipp_tag_t ippGetGroupTag(ipp_attribute_t *attr) _CUPS_API_1_6;
-extern int ippGetInteger(ipp_attribute_t *attr, int element)
- _CUPS_API_1_6;
-extern const char *ippGetName(ipp_attribute_t *attr) _CUPS_API_1_6;
-extern ipp_op_t ippGetOperation(ipp_t *ipp) _CUPS_API_1_6;
-extern int ippGetRange(ipp_attribute_t *attr, int element,
- int *upper) _CUPS_API_1_6;
-extern int ippGetRequestId(ipp_t *ipp) _CUPS_API_1_6;
-extern int ippGetResolution(ipp_attribute_t *attr, int element,
- int *yres, ipp_res_t *units)
- _CUPS_API_1_6;
-extern ipp_state_t ippGetState(ipp_t *ipp) _CUPS_API_1_6;
-extern ipp_status_t ippGetStatusCode(ipp_t *ipp) _CUPS_API_1_6;
-extern const char *ippGetString(ipp_attribute_t *attr, int element,
- const char **language) _CUPS_API_1_6;
-extern ipp_tag_t ippGetValueTag(ipp_attribute_t *attr) _CUPS_API_1_6;
-extern int ippGetVersion(ipp_t *ipp, int *minor) _CUPS_API_1_6;
-extern ipp_attribute_t *ippNextAttribute(ipp_t *ipp) _CUPS_API_1_6;
-extern int ippSetBoolean(ipp_t *ipp, ipp_attribute_t **attr,
- int element, int boolvalue) _CUPS_API_1_6;
-extern int ippSetCollection(ipp_t *ipp, ipp_attribute_t **attr,
- int element, ipp_t *colvalue)
- _CUPS_API_1_6;
-extern int ippSetDate(ipp_t *ipp, ipp_attribute_t **attr,
- int element, const ipp_uchar_t *datevalue)
- _CUPS_API_1_6;
-extern int ippSetGroupTag(ipp_t *ipp, ipp_attribute_t **attr,
- ipp_tag_t group_tag) _CUPS_API_1_6;
-extern int ippSetInteger(ipp_t *ipp, ipp_attribute_t **attr,
- int element, int intvalue) _CUPS_API_1_6;
-extern int ippSetName(ipp_t *ipp, ipp_attribute_t **attr,
- const char *name) _CUPS_API_1_6;
-extern int ippSetOperation(ipp_t *ipp, ipp_op_t op) _CUPS_API_1_6;
-extern int ippSetRange(ipp_t *ipp, ipp_attribute_t **attr,
- int element, int lowervalue, int uppervalue)
- _CUPS_API_1_6;
-extern int ippSetRequestId(ipp_t *ipp, int request_id)
- _CUPS_API_1_6;
-extern int ippSetResolution(ipp_t *ipp, ipp_attribute_t **attr,
- int element, ipp_res_t unitsvalue,
- int xresvalue, int yresvalue)
- _CUPS_API_1_6;
-extern int ippSetState(ipp_t *ipp, ipp_state_t state)
- _CUPS_API_1_6;
-extern int ippSetStatusCode(ipp_t *ipp, ipp_status_t status)
- _CUPS_API_1_6;
-extern int ippSetString(ipp_t *ipp, ipp_attribute_t **attr,
- int element, const char *strvalue)
- _CUPS_API_1_6;
-extern int ippSetValueTag(ipp_t *ipp, ipp_attribute_t **attr,
- ipp_tag_t value_tag) _CUPS_API_1_6;
-extern int ippSetVersion(ipp_t *ipp, int major, int minor)
- _CUPS_API_1_6;
-
-/**** New in CUPS 1.7 ****/
-extern ipp_attribute_t *ippAddStringf(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name,
- const char *language, const char *format,
- ...) _CUPS_API_1_7;
-extern ipp_attribute_t *ippAddStringfv(ipp_t *ipp, ipp_tag_t group,
- ipp_tag_t value_tag, const char *name,
- const char *language,
- const char *format, va_list ap)
- _CUPS_API_1_7;
-extern int ippContainsInteger(ipp_attribute_t *attr, int value)
- _CUPS_API_1_7;
-extern int ippContainsString(ipp_attribute_t *attr,
- const char *value) _CUPS_API_1_7;
-extern cups_array_t *ippCreateRequestedArray(ipp_t *request) _CUPS_API_1_7;
-extern void *ippGetOctetString(ipp_attribute_t *attr, int element,
- int *datalen) _CUPS_API_1_7;
-extern ipp_t *ippNewResponse(ipp_t *request) _CUPS_API_1_7;
-extern int ippSetOctetString(ipp_t *ipp, ipp_attribute_t **attr,
- int element, const void *data,
- int datalen) _CUPS_API_1_7;
-extern int ippSetStringf(ipp_t *ipp, ipp_attribute_t **attr,
- int element, const char *format,
- ...) _CUPS_API_1_7;
-extern int ippSetStringfv(ipp_t *ipp, ipp_attribute_t **attr,
- int element, const char *format,
- va_list ap) _CUPS_API_1_7;
-extern int ippValidateAttribute(ipp_attribute_t *attr)
- _CUPS_API_1_7;
-extern int ippValidateAttributes(ipp_t *ipp) _CUPS_API_1_7;
-
-
-/**** New in CUPS 2.0 ****/
-extern const char *ippStateString(ipp_state_t state) _CUPS_API_2_0;
-
-
-/*
- * C++ magic...
- */
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-#endif /* !_CUPS_IPP_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_IPP_H_
/*
- * '_cupsRasterErrorString()' - Return the last error from a raster function.
+ * 'cupsRasterGetErrorString()' - Return the last error from a raster function.
*
* If there are no recent errors, NULL is returned.
*
- * @since CUPS 1.3/macOS 10.5@
+ * @since CUPS 2.5@
*/
const char * /* O - Last error */
-_cupsRasterErrorString(void)
+cupsRasterGetErrorString(void)
{
_cups_globals_t *cg = _cupsGlobals();
/* Thread globals */
-/*
- * Raster file routines for CUPS.
- *
- * Copyright 2007-2019 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
- *
- * This file is part of the CUPS Imaging library.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Raster file routines for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#include "raster-private.h"
#include "debug-internal.h"
#ifdef HAVE_STDINT_H
# include <stdint.h>
-#endif /* HAVE_STDINT_H */
+#endif // HAVE_STDINT_H
-/*
- * Private structures...
- */
+//
+// Private structures...
+//
typedef void (*_cups_copyfunc_t)(void *dst, const void *src, size_t bytes);
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
static const char * const apple_media_types[] =
-{ /* media-type values for Apple Raster */
+{ // media-type values for Apple Raster
"auto",
"stationery",
"transparency",
#ifdef DEBUG
static const char * const cups_modes[] =
-{ /* Open modes */
+{ // Open modes
"CUPS_RASTER_READ",
"CUPS_RASTER_WRITE",
"CUPS_RASTER_WRITE_COMPRESSED",
"CUPS_RASTER_WRITE_PWG",
"CUPS_RASTER_WRITE_APPLE"
};
-#endif /* DEBUG */
+#endif // DEBUG
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static ssize_t cups_raster_io(cups_raster_t *r, unsigned char *buf, size_t bytes);
static ssize_t cups_raster_read(cups_raster_t *r, unsigned char *buf, size_t bytes);
static void cups_swap_copy(unsigned char *dst, const unsigned char *src, size_t bytes);
-/*
- * '_cupsRasterColorSpaceString()' - Return the colorspace name for a
- * cupsColorSpace value.
- */
+//
+// '_cupsRasterColorSpaceString()' - Return the colorspace name for a
+// cupsColorSpace value.
+//
const char *
_cupsRasterColorSpaceString(
- cups_cspace_t cspace) /* I - cupsColorSpace value */
+ cups_cspace_t cspace) // I - cupsColorSpace value
{
static const char * const cups_color_spaces[] =
- { /* Color spaces */
+ { // Color spaces
"W",
"RGB",
"RGBA",
}
-/*
- * '_cupsRasterDelete()' - Free a raster stream.
- *
- * The file descriptor associated with the raster stream must be closed
- * separately as needed.
- */
+//
+// '_cupsRasterDelete()' - Free a raster stream.
+//
+// The file descriptor associated with the raster stream must be closed
+// separately as needed.
+//
void
-_cupsRasterDelete(cups_raster_t *r) /* I - Stream to free */
+_cupsRasterDelete(cups_raster_t *r) // I - Stream to free
{
if (r != NULL)
{
}
-/*
- * '_cupsRasterInitPWGHeader()' - Initialize a page header for PWG Raster output.
- *
- * The "media" argument specifies the media to use.
- *
- * The "type" argument specifies a "pwg-raster-document-type-supported" value
- * that controls the color space and bit depth of the raster data.
- *
- * The "xres" and "yres" arguments specify the raster resolution in dots per
- * inch.
- *
- * The "sheet_back" argument specifies a "pwg-raster-document-sheet-back" value
- * to apply for the back side of a page. Pass @code NULL@ for the front side.
- *
- * @since CUPS 2.2/macOS 10.12@
- */
-
-int /* O - 1 on success, 0 on failure */
+//
+// 'cupsRasterInitHeader()' - Initialize a page header for PWG Raster output.
+//
+// The "media" argument specifies the media to use. The "optimize", "quality",
+// "intent", "orientation", and "sides" arguments specify additional IPP Job
+// Template attribute values that are reflected in the raster header.
+//
+// The "type" argument specifies a "pwg-raster-document-type-supported" value
+// that controls the color space and bit depth of the raster data. Supported
+// values include:
+//
+// - "adobe-rgb_8": 8-bit per component (24-bit) AdobeRGB
+// - "adobe-rgb_16": 16-bit per component (48-bit) AdobeRGB
+// - "black_1": 1-bit black (K)
+// - "black_8": 8-bit black (K)
+// - "black_16": 16-bit black (K)
+// - "cmyk_8": 8-bit per component (32-bit) CMYK
+// - "cmyk_16": 16-bit per component (64-bit) CMYK
+// - "device1_8" to "device15_8": 8-bit per component DeviceN
+// - "device1_16" to "device15_16": 16-bit per component DeviceN
+// - "rgb_8": 8-bit per component (24-bit) DeviceRGB
+// - "rgb_16": 16-bit per component (32-bit) DeviceRGB
+// - "sgray_1": 1-bit sGray
+// - "sgray_8": 8-bit sGray
+// - "sgray_16": 16-bit sGray
+// - "srgb_8": 8-bit per component (24-bit) sRGB
+// - "srgb_16": 16-bit per component (48-bit) sRGB
+//
+// The "xres" and "yres" arguments specify the raster resolution in dots per
+// inch.
+//
+// The "sheet_back" argument specifies a "pwg-raster-document-sheet-back" value
+// to apply for the back side of a page. Pass `NULL` for the front side.
+//
+// @since CUPS 2.5@
+//
+
+bool // O - `true` on success, `false` on failure
+cupsRasterInitHeader(
+ cups_page_header2_t *h, // I - Page header
+ cups_media_t *media, // I - Media information
+ const char *optimize, // I - IPP "print-content-optimize" value
+ ipp_quality_t quality, // I - IPP "print-quality" value
+ const char *intent, // I - IPP "print-rendering-intent" value
+ ipp_orient_t orientation, // I - IPP "orientation-requested" value
+ const char *sides, // I - IPP "sides" value
+ const char *type, // I - PWG raster type string
+ int xdpi, // I - Cross-feed direction (horizontal) resolution
+ int ydpi, // I - Feed direction (vertical) resolution
+ const char *sheet_back) // I - Transform for back side or `NULL` for none
+{
+ unsigned i; // Looping var
+ static const char * const media_positions[] =
+ { // "media-source" to MediaPosition mapping
+ "auto",
+ "main",
+ "alternate",
+ "large-capacity",
+ "manual",
+ "envelope",
+ "disc",
+ "photo",
+ "hagaki",
+ "main-roll",
+ "alternate-roll",
+ "top",
+ "middle",
+ "bottom",
+ "side",
+ "left",
+ "right",
+ "center",
+ "rear",
+ "by-pass-tray",
+ "tray-1",
+ "tray-2",
+ "tray-3",
+ "tray-4",
+ "tray-5",
+ "tray-6",
+ "tray-7",
+ "tray-8",
+ "tray-9",
+ "tray-10",
+ "tray-11",
+ "tray-12",
+ "tray-13",
+ "tray-14",
+ "tray-15",
+ "tray-16",
+ "tray-17",
+ "tray-18",
+ "tray-19",
+ "tray-20",
+ "roll-1",
+ "roll-2",
+ "roll-3",
+ "roll-4",
+ "roll-5",
+ "roll-6",
+ "roll-7",
+ "roll-8",
+ "roll-9",
+ "roll-10"
+ };
+
+
+ if (!h || !media || !type || xdpi <= 0 || ydpi <= 0)
+ {
+ _cupsRasterAddError("%s", strerror(EINVAL));
+ return (false);
+ }
+
+ // Initialize the page header...
+ memset(h, 0, sizeof(cups_page_header_t));
+
+ cupsCopyString(h->MediaClass, "PwgRaster", sizeof(h->MediaClass));
+ cupsCopyString(h->MediaColor, media->color, sizeof(h->MediaColor));
+ cupsCopyString(h->MediaType, media->type, sizeof(h->MediaType));
+
+ for (i = 0; i < (sizeof(media_positions) / sizeof(media_positions[0])); i ++)
+ {
+ if (!strcmp(media->source, media_positions[i]))
+ {
+ h->MediaPosition = i;
+ break;
+ }
+ }
+
+ if (optimize)
+ cupsCopyString(h->OutputType, optimize, sizeof(h->OutputType));
+
+ switch (orientation)
+ {
+ default :
+ h->Orientation = CUPS_ORIENT_0;
+ break;
+ case IPP_ORIENT_LANDSCAPE :
+ h->Orientation = CUPS_ORIENT_90;
+ break;
+ case IPP_ORIENT_REVERSE_PORTRAIT :
+ h->Orientation = CUPS_ORIENT_180;
+ break;
+ case IPP_ORIENT_REVERSE_LANDSCAPE :
+ h->Orientation = CUPS_ORIENT_270;
+ break;
+ }
+
+ cupsCopyString(h->cupsPageSizeName, media->media, sizeof(h->cupsPageSizeName));
+
+ if (intent)
+ cupsCopyString(h->cupsRenderingIntent, intent, sizeof(h->cupsRenderingIntent));
+
+ h->cupsInteger[CUPS_RASTER_PWG_PrintQuality] = (unsigned)quality;
+
+ h->PageSize[0] = (unsigned)(72 * media->width / 2540);
+ h->PageSize[1] = (unsigned)(72 * media->length / 2540);
+
+ // This never gets written but is needed for some applications
+ h->cupsPageSize[0] = 72.0f * media->width / 2540.0f;
+ h->cupsPageSize[1] = 72.0f * media->length / 2540.0f;
+
+ h->ImagingBoundingBox[0] = (unsigned)(72 * media->left / 2540);
+ h->ImagingBoundingBox[1] = (unsigned)(72 * media->bottom / 2540);
+ h->ImagingBoundingBox[2] = (unsigned)(72 * (media->width - media->right) / 2540);
+ h->ImagingBoundingBox[3] = (unsigned)(72 * (media->length - media->top) / 2540);
+
+ h->HWResolution[0] = (unsigned)xdpi;
+ h->HWResolution[1] = (unsigned)ydpi;
+
+ h->cupsWidth = (unsigned)(media->width * xdpi / 2540);
+ h->cupsHeight = (unsigned)(media->length * ydpi / 2540);
+
+ if (h->cupsWidth > 0x00ffffff || h->cupsHeight > 0x00ffffff)
+ {
+ _cupsRasterAddError("Raster dimensions too large.");
+ return (false);
+ }
+
+ h->cupsInteger[CUPS_RASTER_PWG_ImageBoxBottom] = (unsigned)(ydpi * (media->length - media->bottom) / 2540);
+ h->cupsInteger[CUPS_RASTER_PWG_ImageBoxLeft] = (unsigned)(xdpi * media->left / 2540);
+ h->cupsInteger[CUPS_RASTER_PWG_ImageBoxRight] = (unsigned)(xdpi * (media->width - media->right) / 2540 - 1);
+ h->cupsInteger[CUPS_RASTER_PWG_ImageBoxTop] = (unsigned)(ydpi * media->top / 2540 - 1);
+
+ // Colorspace and bytes per line...
+ if (!strcmp(type, "adobe-rgb_8"))
+ {
+ h->cupsBitsPerColor = 8;
+ h->cupsBitsPerPixel = 24;
+ h->cupsColorSpace = CUPS_CSPACE_ADOBERGB;
+ }
+ else if (!strcmp(type, "adobe-rgb_16"))
+ {
+ h->cupsBitsPerColor = 16;
+ h->cupsBitsPerPixel = 48;
+ h->cupsColorSpace = CUPS_CSPACE_ADOBERGB;
+ }
+ else if (!strcmp(type, "black_1"))
+ {
+ h->cupsBitsPerColor = 1;
+ h->cupsBitsPerPixel = 1;
+ h->cupsColorSpace = CUPS_CSPACE_K;
+ }
+ else if (!strcmp(type, "black_8"))
+ {
+ h->cupsBitsPerColor = 8;
+ h->cupsBitsPerPixel = 8;
+ h->cupsColorSpace = CUPS_CSPACE_K;
+ }
+ else if (!strcmp(type, "black_16"))
+ {
+ h->cupsBitsPerColor = 16;
+ h->cupsBitsPerPixel = 16;
+ h->cupsColorSpace = CUPS_CSPACE_K;
+ }
+ else if (!strcmp(type, "cmyk_8"))
+ {
+ h->cupsBitsPerColor = 8;
+ h->cupsBitsPerPixel = 32;
+ h->cupsColorSpace = CUPS_CSPACE_CMYK;
+ }
+ else if (!strcmp(type, "cmyk_16"))
+ {
+ h->cupsBitsPerColor = 16;
+ h->cupsBitsPerPixel = 64;
+ h->cupsColorSpace = CUPS_CSPACE_CMYK;
+ }
+ else if (!strncmp(type, "device", 6) && type[6] >= '1' && type[6] <= '9')
+ {
+ int ncolors, bits; // Number of colors and bits
+
+ if (sscanf(type, "device%d_%d", &ncolors, &bits) != 2 || ncolors > 15 || (bits != 8 && bits != 16))
+ {
+ _cupsRasterAddError("Unsupported raster type \'%s\'.", type);
+ return (false);
+ }
+
+ h->cupsBitsPerColor = (unsigned)bits;
+ h->cupsBitsPerPixel = (unsigned)(ncolors * bits);
+ h->cupsColorSpace = (cups_cspace_t)(CUPS_CSPACE_DEVICE1 + ncolors - 1);
+ }
+ else if (!strcmp(type, "rgb_8"))
+ {
+ h->cupsBitsPerColor = 8;
+ h->cupsBitsPerPixel = 24;
+ h->cupsColorSpace = CUPS_CSPACE_RGB;
+ }
+ else if (!strcmp(type, "rgb_16"))
+ {
+ h->cupsBitsPerColor = 16;
+ h->cupsBitsPerPixel = 48;
+ h->cupsColorSpace = CUPS_CSPACE_RGB;
+ }
+ else if (!strcmp(type, "sgray_1"))
+ {
+ h->cupsBitsPerColor = 1;
+ h->cupsBitsPerPixel = 1;
+ h->cupsColorSpace = CUPS_CSPACE_SW;
+ }
+ else if (!strcmp(type, "sgray_8"))
+ {
+ h->cupsBitsPerColor = 8;
+ h->cupsBitsPerPixel = 8;
+ h->cupsColorSpace = CUPS_CSPACE_SW;
+ }
+ else if (!strcmp(type, "sgray_16"))
+ {
+ h->cupsBitsPerColor = 16;
+ h->cupsBitsPerPixel = 16;
+ h->cupsColorSpace = CUPS_CSPACE_SW;
+ }
+ else if (!strcmp(type, "srgb_8"))
+ {
+ h->cupsBitsPerColor = 8;
+ h->cupsBitsPerPixel = 24;
+ h->cupsColorSpace = CUPS_CSPACE_SRGB;
+ }
+ else if (!strcmp(type, "srgb_16"))
+ {
+ h->cupsBitsPerColor = 16;
+ h->cupsBitsPerPixel = 48;
+ h->cupsColorSpace = CUPS_CSPACE_SRGB;
+ }
+ else
+ {
+ _cupsRasterAddError("Unsupported raster type \'%s\'.", type);
+ return (false);
+ }
+
+ h->cupsColorOrder = CUPS_ORDER_CHUNKED;
+ h->cupsNumColors = h->cupsBitsPerPixel / h->cupsBitsPerColor;
+ h->cupsBytesPerLine = (h->cupsWidth * h->cupsBitsPerPixel + 7) / 8;
+
+ // Duplex support...
+ h->cupsInteger[CUPS_RASTER_PWG_CrossFeedTransform] = 1;
+ h->cupsInteger[CUPS_RASTER_PWG_FeedTransform] = 1;
+
+ if (sides)
+ {
+ if (!strcmp(sides, "two-sided-long-edge"))
+ {
+ h->Duplex = 1;
+ }
+ else if (!strcmp(sides, "two-sided-short-edge"))
+ {
+ h->Duplex = 1;
+ h->Tumble = 1;
+ }
+ else if (strcmp(sides, "one-sided"))
+ {
+ _cupsRasterAddError("Unsupported sides value '%s'.", sides);
+ return (false);
+ }
+
+ if (sheet_back)
+ {
+ if (!strcmp(sheet_back, "flipped"))
+ {
+ if (h->Tumble)
+ h->cupsInteger[CUPS_RASTER_PWG_CrossFeedTransform] = 0xffffffffU;
+ else
+ h->cupsInteger[CUPS_RASTER_PWG_FeedTransform] = 0xffffffffU;
+ }
+ else if ((!strcmp(sheet_back, "manual-tumble") && h->Tumble) || (!strcmp(sheet_back, "rotated") || !h->Tumble))
+ {
+ h->cupsInteger[CUPS_RASTER_PWG_CrossFeedTransform] = 0xffffffffU;
+ h->cupsInteger[CUPS_RASTER_PWG_FeedTransform] = 0xffffffffU;
+ }
+ else if (strcmp(sheet_back, "normal"))
+ {
+ _cupsRasterAddError("Unsupported sheet_back value '%s'.", sheet_back);
+ return (false);
+ }
+ }
+ }
+
+ return (true);
+}
+
+
+//
+// '_cupsRasterInitPWGHeader()' - Initialize a page header for PWG Raster output.
+//
+// The "media" argument specifies the media to use.
+//
+// The "type" argument specifies a "pwg-raster-document-type-supported" value
+// that controls the color space and bit depth of the raster data.
+//
+// The "xres" and "yres" arguments specify the raster resolution in dots per
+// inch.
+//
+// The "sheet_back" argument specifies a "pwg-raster-document-sheet-back" value
+// to apply for the back side of a page. Pass `NULL` for the front side.
+//
+// @since CUPS 2.2/macOS 10.12@
+//
+
+int // O - 1 on success, 0 on failure
_cupsRasterInitPWGHeader(
- cups_page_header2_t *h, /* I - Page header */
- pwg_media_t *media, /* I - PWG media information */
- const char *type, /* I - PWG raster type string */
- int xdpi, /* I - Cross-feed direction (horizontal) resolution */
- int ydpi, /* I - Feed direction (vertical) resolution */
- const char *sides, /* I - IPP "sides" option value */
- const char *sheet_back) /* I - Transform for back side or @code NULL@ for none */
+ cups_page_header2_t *h, // I - Page header
+ pwg_media_t *media, // I - PWG media information
+ const char *type, // I - PWG raster type string
+ int xdpi, // I - Cross-feed direction (horizontal) resolution
+ int ydpi, // I - Feed direction (vertical) resolution
+ const char *sides, // I - IPP "sides" option value
+ const char *sheet_back) // I - Transform for back side or `NULL` for none
{
if (!h || !media || !type || xdpi <= 0 || ydpi <= 0)
{
return (0);
}
- /*
- * Initialize the page header...
- */
-
+ // Initialize the page header...
memset(h, 0, sizeof(cups_page_header2_t));
cupsCopyString(h->cupsPageSizeName, media->pwg, sizeof(h->cupsPageSizeName));
h->PageSize[0] = (unsigned)(72 * media->width / 2540);
h->PageSize[1] = (unsigned)(72 * media->length / 2540);
- /* This never gets written but is needed for some applications */
+ // This never gets written but is needed for some applications
h->cupsPageSize[0] = 72.0f * media->width / 2540.0f;
h->cupsPageSize[1] = 72.0f * media->length / 2540.0f;
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxRight] = h->cupsWidth;
h->cupsInteger[CUPS_RASTER_PWG_ImageBoxBottom] = h->cupsHeight;
- /*
- * Colorspace and bytes per line...
- */
-
+ // Colorspace and bytes per line...
if (!strcmp(type, "adobe-rgb_8"))
{
h->cupsBitsPerColor = 8;
}
else if (!strncmp(type, "device", 6) && type[6] >= '1' && type[6] <= '9')
{
- int ncolors, bits; /* Number of colors and bits */
+ int ncolors, bits; // Number of colors and bits
if (sscanf(type, "device%d_%d", &ncolors, &bits) != 2 || ncolors > 15 || (bits != 8 && bits != 16))
h->cupsNumColors = h->cupsBitsPerPixel / h->cupsBitsPerColor;
h->cupsBytesPerLine = (h->cupsWidth * h->cupsBitsPerPixel + 7) / 8;
- /*
- * Duplex support...
- */
-
+ // Duplex support...
h->cupsInteger[CUPS_RASTER_PWG_CrossFeedTransform] = 1;
h->cupsInteger[CUPS_RASTER_PWG_FeedTransform] = 1;
}
-/*
- * '_cupsRasterNew()' - Create a raster stream using a callback function.
- *
- * This function associates a raster stream with the given callback function and
- * context pointer.
- *
- * When writing raster data, the @code CUPS_RASTER_WRITE@,
- * @code CUPS_RASTER_WRITE_COMPRESS@, or @code CUPS_RASTER_WRITE_PWG@ mode can
- * be used - compressed and PWG output is generally 25-50% smaller but adds a
- * 100-300% execution time overhead.
- */
+//
+// '_cupsRasterNew()' - Create a raster stream using a callback function.
+//
+// This function associates a raster stream with the given callback function and
+// context pointer.
+//
+// When writing raster data, the `CUPS_RASTER_WRITE`,
+// `CUPS_RASTER_WRITE_COMPRESS`, or `CUPS_RASTER_WRITE_PWG` mode can
+// be used - compressed and PWG output is generally 25-50% smaller but adds a
+// 100-300% execution time overhead.
+//
-cups_raster_t * /* O - New stream */
+cups_raster_t * // O - New stream
_cupsRasterNew(
- cups_raster_iocb_t iocb, /* I - Read/write callback */
- void *ctx, /* I - Context pointer for callback */
- cups_mode_t mode) /* I - Mode - @code CUPS_RASTER_READ@,
- @code CUPS_RASTER_WRITE@,
- @code CUPS_RASTER_WRITE_COMPRESSED@,
- or @code CUPS_RASTER_WRITE_PWG@ */
+ cups_raster_cb_t iocb, // I - Read/write callback
+ void *ctx, // I - Context pointer for callback
+ cups_raster_mode_t mode) // I - Mode - `CUPS_RASTER_READ`, `CUPS_RASTER_WRITE`, `CUPS_RASTER_WRITE_COMPRESSED`, or `CUPS_RASTER_WRITE_PWG`
{
- cups_raster_t *r; /* New stream */
+ cups_raster_t *r; // New stream
DEBUG_printf("_cupsRasterOpenIO(iocb=%p, ctx=%p, mode=%s)", (void *)iocb, ctx, cups_modes[mode]);
if ((r = calloc(1, sizeof(cups_raster_t))) == NULL)
{
- _cupsRasterAddError("Unable to allocate memory for raster stream: %s\n",
- strerror(errno));
+ _cupsRasterAddError("Unable to allocate memory for raster stream: %s\n", strerror(errno));
DEBUG_puts("1_cupsRasterOpenIO: Returning NULL.");
return (NULL);
}
if (mode == CUPS_RASTER_READ)
{
- /*
- * Open for read - get sync word...
- */
-
- if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) !=
- sizeof(r->sync))
+ // Open for read - get sync word...
+ if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) != sizeof(r->sync))
{
- _cupsRasterAddError("Unable to read header from raster stream: %s\n",
- strerror(errno));
+ _cupsRasterAddError("Unable to read header from raster stream: %s\n", strerror(errno));
free(r);
DEBUG_puts("1_cupsRasterOpenIO: Unable to read header, returning NULL.");
return (NULL);
}
- if (r->sync != CUPS_RASTER_SYNC &&
- r->sync != CUPS_RASTER_REVSYNC &&
- r->sync != CUPS_RASTER_SYNCv1 &&
- r->sync != CUPS_RASTER_REVSYNCv1 &&
- r->sync != CUPS_RASTER_SYNCv2 &&
- r->sync != CUPS_RASTER_REVSYNCv2 &&
- r->sync != CUPS_RASTER_SYNCapple &&
- r->sync != CUPS_RASTER_REVSYNCapple)
+ if (r->sync != CUPS_RASTER_SYNC && r->sync != CUPS_RASTER_REVSYNC && r->sync != CUPS_RASTER_SYNCv1 && r->sync != CUPS_RASTER_REVSYNCv1 && r->sync != CUPS_RASTER_SYNCv2 && r->sync != CUPS_RASTER_REVSYNCv2 && r->sync != CUPS_RASTER_SYNCapple && r->sync != CUPS_RASTER_REVSYNCapple)
{
_cupsRasterAddError("Unknown raster format %08x!\n", r->sync);
free(r);
return (NULL);
}
- if (r->sync == CUPS_RASTER_SYNCv2 ||
- r->sync == CUPS_RASTER_REVSYNCv2 ||
- r->sync == CUPS_RASTER_SYNCapple ||
- r->sync == CUPS_RASTER_REVSYNCapple)
+ if (r->sync == CUPS_RASTER_SYNCv2 || r->sync == CUPS_RASTER_REVSYNCv2 || r->sync == CUPS_RASTER_SYNCapple || r->sync == CUPS_RASTER_REVSYNCapple)
r->compressed = 1;
DEBUG_printf("1_cupsRasterOpenIO: sync=%08x", r->sync);
- if (r->sync == CUPS_RASTER_REVSYNC ||
- r->sync == CUPS_RASTER_REVSYNCv1 ||
- r->sync == CUPS_RASTER_REVSYNCv2 ||
- r->sync == CUPS_RASTER_REVSYNCapple)
+ if (r->sync == CUPS_RASTER_REVSYNC || r->sync == CUPS_RASTER_REVSYNCv1 || r->sync == CUPS_RASTER_REVSYNCv2 || r->sync == CUPS_RASTER_REVSYNCapple)
r->swapped = 1;
- if (r->sync == CUPS_RASTER_SYNCapple ||
- r->sync == CUPS_RASTER_REVSYNCapple)
+ if (r->sync == CUPS_RASTER_SYNCapple || r->sync == CUPS_RASTER_REVSYNCapple)
{
- unsigned char header[8]; /* File header */
+ unsigned char header[8]; // File header
- if (cups_raster_io(r, (unsigned char *)header, sizeof(header)) !=
- sizeof(header))
+ if (cups_raster_io(r, (unsigned char *)header, sizeof(header)) != sizeof(header))
{
- _cupsRasterAddError("Unable to read header from raster stream: %s\n",
- strerror(errno));
+ _cupsRasterAddError("Unable to read header from raster stream: %s\n", strerror(errno));
free(r);
DEBUG_puts("1_cupsRasterOpenIO: Unable to read header, returning NULL.");
return (NULL);
#ifdef DEBUG
r->iostart = r->iocount;
-#endif /* DEBUG */
+#endif // DEBUG
}
else
{
- /*
- * Open for write - put sync word...
- */
-
+ // Open for write - put sync word...
switch (mode)
{
default :
if (cups_raster_io(r, (unsigned char *)&(r->sync), sizeof(r->sync)) < (ssize_t)sizeof(r->sync))
{
- _cupsRasterAddError("Unable to write raster stream header: %s\n",
- strerror(errno));
+ _cupsRasterAddError("Unable to write raster stream header: %s\n", strerror(errno));
free(r);
DEBUG_puts("1_cupsRasterOpenIO: Unable to write header, returning NULL.");
return (NULL);
}
-/*
- * '_cupsRasterReadHeader()' - Read a raster page header.
- */
+//
+// '_cupsRasterReadHeader()' - Read a raster page header.
+//
-unsigned /* O - 1 on success, 0 on fail */
+unsigned // O - 1 on success, 0 on fail
_cupsRasterReadHeader(
- cups_raster_t *r) /* I - Raster stream */
+ cups_raster_t *r) // I - Raster stream
{
- size_t len; /* Length for read/swap */
+ size_t len; // Length for read/swap
DEBUG_printf("3_cupsRasterReadHeader(r=%p), r->mode=%s", (void *)r, r ? cups_modes[r->mode] : "");
memset(&(r->header), 0, sizeof(r->header));
- /*
- * Read the header...
- */
-
+ // Read the header...
switch (r->sync)
{
default :
- /*
- * Get the length of the raster header...
- */
-
+ // Get the length of the raster header...
if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1)
len = sizeof(cups_page_header_t);
else
DEBUG_printf("4_cupsRasterReadHeader: len=%d", (int)len);
- /*
- * Read it...
- */
-
+ // Read it...
if (cups_raster_read(r, (unsigned char *)&(r->header), len) < (ssize_t)len)
{
DEBUG_printf("4_cupsRasterReadHeader: EOF, r->iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount);
return (0);
}
- /*
- * Swap bytes as needed...
- */
-
+ // Swap bytes as needed...
if (r->swapped)
{
- unsigned *s, /* Current word */
- temp; /* Temporary copy */
-
+ unsigned *s, // Current word
+ temp; // Temporary copy
DEBUG_puts("4_cupsRasterReadHeader: Swapping header bytes.");
- for (len = 81, s = &(r->header.AdvanceDistance);
- len > 0;
- len --, s ++)
+ for (len = 81, s = &(r->header.AdvanceDistance); len > 0; len --, s ++)
{
temp = *s;
- *s = ((temp & 0xff) << 24) |
- ((temp & 0xff00) << 8) |
- ((temp & 0xff0000) >> 8) |
- ((temp & 0xff000000) >> 24);
+ *s = ((temp & 0xff) << 24) | ((temp & 0xff00) << 8) | ((temp & 0xff0000) >> 8) | ((temp & 0xff000000) >> 24);
DEBUG_printf("4_cupsRasterReadHeader: %08x => %08x", temp, *s);
}
case CUPS_RASTER_SYNCapple :
case CUPS_RASTER_REVSYNCapple :
{
- unsigned char appleheader[32]; /* Raw header */
+ unsigned char appleheader[32]; // Raw header
static const unsigned rawcspace[] =
{
CUPS_CSPACE_SW,
}
cupsCopyString(r->header.MediaClass, "PwgRaster", sizeof(r->header.MediaClass));
- /* PwgRaster */
+ // PwgRaster
r->header.cupsBitsPerPixel = appleheader[0];
r->header.cupsColorSpace = appleheader[1] >= (sizeof(rawcspace) / sizeof(rawcspace[0])) ? CUPS_CSPACE_DEVICE1 : rawcspace[appleheader[1]];
r->header.cupsNumColors = appleheader[1] >= (sizeof(rawnumcolors) / sizeof(rawnumcolors[0])) ? 1 : rawnumcolors[appleheader[1]];
break;
}
- /*
- * Update the header and row count...
- */
-
+ // Update the header and row count...
if (!cups_raster_update(r))
return (0);
}
-/*
- * '_cupsRasterReadPixels()' - Read raster pixels.
- *
- * For best performance, filters should read one or more whole lines.
- * The "cupsBytesPerLine" value from the page header can be used to allocate
- * the line buffer and as the number of bytes to read.
- */
+//
+// '_cupsRasterReadPixels()' - Read raster pixels.
+//
+// For best performance, filters should read one or more whole lines.
+// The "cupsBytesPerLine" value from the page header can be used to allocate
+// the line buffer and as the number of bytes to read.
+//
-unsigned /* O - Number of bytes read */
+unsigned // O - Number of bytes read
_cupsRasterReadPixels(
- cups_raster_t *r, /* I - Raster stream */
- unsigned char *p, /* I - Pointer to pixel buffer */
- unsigned len) /* I - Number of bytes to read */
+ cups_raster_t *r, // I - Raster stream
+ unsigned char *p, // I - Pointer to pixel buffer
+ unsigned len) // I - Number of bytes to read
{
- ssize_t bytes; /* Bytes read */
- unsigned cupsBytesPerLine; /* cupsBytesPerLine value */
- unsigned remaining; /* Bytes remaining */
- unsigned char *ptr, /* Pointer to read buffer */
- byte, /* Byte from file */
- *temp; /* Pointer into buffer */
- unsigned count; /* Repetition count */
+ ssize_t bytes; // Bytes read
+ unsigned cupsBytesPerLine; // cupsBytesPerLine value
+ unsigned remaining; // Bytes remaining
+ unsigned char *ptr, // Pointer to read buffer
+ byte, // Byte from file
+ *temp; // Pointer into buffer
+ unsigned count; // Repetition count
DEBUG_printf("_cupsRasterReadPixels(r=%p, p=%p, len=%u)", (void *)r, (void *)p, len);
if (!r->compressed)
{
- /*
- * Read without compression...
- */
-
+ // Read without compression...
r->remaining -= len / r->header.cupsBytesPerLine;
if (cups_raster_io(r, p, len) < (ssize_t)len)
return (0);
}
- /*
- * Swap bytes as needed...
- */
-
+ // Swap bytes as needed...
if (r->swapped &&
(r->header.cupsBitsPerColor == 16 ||
r->header.cupsBitsPerPixel == 12 ||
r->header.cupsBitsPerPixel == 16))
cups_swap(p, len);
- /*
- * Return...
- */
-
+ // Return...
DEBUG_printf("1_cupsRasterReadPixels: Returning %u", len);
return (len);
}
- /*
- * Read compressed data...
- */
-
+ // Read compressed data...
remaining = len;
cupsBytesPerLine = r->header.cupsBytesPerLine;
{
if (r->count == 0)
{
- /*
- * Need to read a new row...
- */
-
+ // Need to read a new row...
if (remaining == cupsBytesPerLine)
ptr = p;
else
ptr = r->pixels;
- /*
- * Read using a modified PackBits compression...
- */
-
+ // Read using a modified PackBits compression...
if (!cups_raster_read(r, &byte, 1))
{
DEBUG_puts("1_cupsRasterReadPixels: Read error, returning 0.");
while (bytes > 0)
{
- /*
- * Get a new repeat count...
- */
-
+ // Get a new repeat count...
if (!cups_raster_read(r, &byte, 1))
{
DEBUG_puts("1_cupsRasterReadPixels: Read error, returning 0.");
if (byte == 128)
{
- /*
- * Clear to end of line...
- */
-
+ // Clear to end of line...
switch (r->header.cupsColorSpace)
{
case CUPS_CSPACE_W :
}
else if (byte & 128)
{
- /*
- * Copy N literal pixels...
- */
-
+ // Copy N literal pixels...
count = (unsigned)(257 - byte) * r->bpp;
if (count > (unsigned)bytes)
}
else
{
- /*
- * Repeat the next N bytes...
- */
-
+ // Repeat the next N bytes...
count = ((unsigned)byte + 1) * r->bpp;
if (count > (unsigned)bytes)
count = (unsigned)bytes;
}
}
- /*
- * Swap bytes as needed...
- */
-
+ // Swap bytes as needed...
if ((r->header.cupsBitsPerColor == 16 ||
r->header.cupsBitsPerPixel == 12 ||
r->header.cupsBitsPerPixel == 16) &&
cups_swap(ptr, (size_t)cupsBytesPerLine);
}
- /*
- * Update pointers...
- */
-
+ // Update pointers...
if (remaining >= cupsBytesPerLine)
{
bytes = (ssize_t)cupsBytesPerLine;
r->pcurrent = r->pixels + bytes;
}
- /*
- * Copy data as needed...
- */
-
+ // Copy data as needed...
if (ptr != p)
memcpy(p, ptr, (size_t)bytes);
}
else
{
- /*
- * Copy fragment from buffer...
- */
-
+ // Copy fragment from buffer...
if ((unsigned)(bytes = (int)(r->pend - r->pcurrent)) > remaining)
bytes = (ssize_t)remaining;
}
-/*
- * '_cupsRasterWriteHeader()' - Write a raster page header.
- */
+//
+// '_cupsRasterWriteHeader()' - Write a raster page header.
+//
-unsigned /* O - 1 on success, 0 on failure */
+unsigned // O - 1 on success, 0 on failure
_cupsRasterWriteHeader(
- cups_raster_t *r) /* I - Raster stream */
+ cups_raster_t *r) // I - Raster stream
{
DEBUG_printf("_cupsRasterWriteHeader(r=%p)", (void *)r);
DEBUG_printf("1_cupsRasterWriteHeader: cupsWidth=%u", r->header.cupsWidth);
DEBUG_printf("1_cupsRasterWriteHeader: cupsHeight=%u", r->header.cupsHeight);
- /*
- * Compute the number of raster lines in the page image...
- */
-
+ // Compute the number of raster lines in the page image...
if (!cups_raster_update(r))
{
DEBUG_puts("1_cupsRasterWriteHeader: Unable to update parameters, returning 0.");
else
r->rowheight = 1;
- /*
- * Write the raster header...
- */
-
+ // Write the raster header...
if (r->mode == CUPS_RASTER_WRITE_PWG)
{
- /*
- * PWG raster data is always network byte order with much of the page header
- * zeroed.
- */
-
- cups_page_header2_t fh; /* File page header */
+ // PWG raster data is always network byte order with much of the page header zeroed.
+ cups_page_header2_t fh; // File page header
memset(&fh, 0, sizeof(fh));
cupsCopyString(fh.MediaClass, "PwgRaster", sizeof(fh.MediaClass));
}
else if (r->mode == CUPS_RASTER_WRITE_APPLE)
{
- /*
- * Raw raster data is always network byte order with most of the page header
- * zeroed.
- */
-
- int i; /* Looping var */
- unsigned char appleheader[32];/* Raw page header */
+ // Raw raster data is always network byte order with most of the page header zeroed.
+ int i; // Looping var
+ unsigned char appleheader[32];// Raw page header
unsigned height = r->header.cupsHeight * r->rowheight;
- /* Computed page height */
+ // Computed page height
if (r->apple_page_count == 0xffffffffU)
{
- /*
- * Write raw page count from raster page header...
- */
-
+ // Write raw page count from raster page header...
r->apple_page_count = r->header.cupsInteger[0];
appleheader[0] = 'A';
}
-/*
- * '_cupsRasterWritePixels()' - Write raster pixels.
- *
- * For best performance, filters should write one or more whole lines.
- * The "cupsBytesPerLine" value from the page header can be used to allocate
- * the line buffer and as the number of bytes to write.
- */
+//
+// '_cupsRasterWritePixels()' - Write raster pixels.
+//
+// For best performance, filters should write one or more whole lines.
+// The "cupsBytesPerLine" value from the page header can be used to allocate
+// the line buffer and as the number of bytes to write.
+//
-unsigned /* O - Number of bytes written */
+unsigned // O - Number of bytes written
_cupsRasterWritePixels(
- cups_raster_t *r, /* I - Raster stream */
- unsigned char *p, /* I - Bytes to write */
- unsigned len) /* I - Number of bytes to write */
+ cups_raster_t *r, // I - Raster stream
+ unsigned char *p, // I - Bytes to write
+ unsigned len) // I - Number of bytes to write
{
- ssize_t bytes; /* Bytes read */
- unsigned remaining; /* Bytes remaining */
+ ssize_t bytes; // Bytes read
+ unsigned remaining; // Bytes remaining
DEBUG_printf("_cupsRasterWritePixels(r=%p, p=%p, len=%u), remaining=%u", (void *)r, (void *)p, len, r->remaining);
if (!r->compressed)
{
- /*
- * Without compression, just write the raster data raw unless the data needs
- * to be swapped...
- */
-
+ // Without compression, just write the raster data raw unless the data needs to be swapped...
r->remaining -= len / r->header.cupsBytesPerLine;
if (r->swapped &&
r->header.cupsBitsPerPixel == 12 ||
r->header.cupsBitsPerPixel == 16))
{
- unsigned char *bufptr; /* Pointer into write buffer */
-
- /*
- * Allocate a write buffer as needed...
- */
+ unsigned char *bufptr; // Pointer into write buffer
+ // Allocate a write buffer as needed...
if ((size_t)len > r->bufsize)
{
if (r->buffer)
r->bufsize = len;
}
- /*
- * Byte swap the pixels and write them...
- */
-
+ // Byte swap the pixels and write them...
cups_swap_copy(r->buffer, p, len);
bytes = cups_raster_io(r, r->buffer, len);
return (len);
}
- /*
- * Otherwise, compress each line...
- */
-
+ // Otherwise, compress each line...
for (remaining = len; remaining > 0; remaining -= (unsigned)bytes, p += bytes)
{
- /*
- * Figure out the number of remaining bytes on the current line...
- */
-
+ // Figure out the number of remaining bytes on the current line...
if ((bytes = (ssize_t)remaining) > (ssize_t)(r->pend - r->pcurrent))
bytes = (ssize_t)(r->pend - r->pcurrent);
if (r->count > 0)
{
- /*
- * Check to see if this line is the same as the previous line...
- */
-
+ // Check to see if this line is the same as the previous line...
if (memcmp(p, r->pcurrent, (size_t)bytes))
{
if (cups_raster_write(r, r->pixels) <= 0)
}
else
{
- /*
- * Mark more bytes as the same...
- */
-
+ // Mark more bytes as the same...
r->pcurrent += bytes;
if (r->pcurrent >= r->pend)
{
- /*
- * Increase the repeat count...
- */
-
+ // Increase the repeat count...
r->count += r->rowheight;
r->pcurrent = r->pixels;
- /*
- * Flush out this line if it is the last one...
- */
-
+ // Flush out this line if it is the last one...
r->remaining --;
if (r->remaining == 0)
if (r->count == 0)
{
- /*
- * Copy the raster data to the buffer...
- */
-
+ // Copy the raster data to the buffer...
memcpy(r->pcurrent, p, (size_t)bytes);
r->pcurrent += bytes;
if (r->pcurrent >= r->pend)
{
- /*
- * Increase the repeat count...
- */
-
+ // Increase the repeat count...
r->count += r->rowheight;
r->pcurrent = r->pixels;
- /*
- * Flush out this line if it is the last one...
- */
-
+ // Flush out this line if it is the last one...
r->remaining --;
if (r->remaining == 0)
}
-/*
- * 'cups_raster_io()' - Read/write bytes from a context, handling interruptions.
- */
+//
+// 'cups_raster_io()' - Read/write bytes from a context, handling interruptions.
+//
-static ssize_t /* O - Bytes read/write or -1 */
-cups_raster_io(cups_raster_t *r, /* I - Raster stream */
- unsigned char *buf, /* I - Buffer for read/write */
- size_t bytes) /* I - Number of bytes to read/write */
+static ssize_t // O - Bytes read/write or -1
+cups_raster_io(cups_raster_t *r, // I - Raster stream
+ unsigned char *buf, // I - Buffer for read/write
+ size_t bytes) // I - Number of bytes to read/write
{
- ssize_t count, /* Number of bytes read/written */
- total; /* Total bytes read/written */
+ ssize_t count, // Number of bytes read/written
+ total; // Total bytes read/written
DEBUG_printf("5cups_raster_io(r=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)r, (void *)buf, CUPS_LLCAST bytes);
#ifdef DEBUG
r->iocount += (size_t)count;
-#endif /* DEBUG */
+#endif // DEBUG
}
DEBUG_printf("6cups_raster_io: iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount);
}
-/*
- * 'cups_raster_read()' - Read through the raster buffer.
- */
+//
+// 'cups_raster_read()' - Read through the raster buffer.
+//
-static ssize_t /* O - Number of bytes read */
-cups_raster_read(cups_raster_t *r, /* I - Raster stream */
- unsigned char *buf, /* I - Buffer */
- size_t bytes) /* I - Number of bytes to read */
+static ssize_t // O - Number of bytes read
+cups_raster_read(cups_raster_t *r, // I - Raster stream
+ unsigned char *buf, // I - Buffer
+ size_t bytes) // I - Number of bytes to read
{
- ssize_t count, /* Number of bytes read */
- remaining, /* Remaining bytes in buffer */
- total; /* Total bytes read */
+ ssize_t count, // Number of bytes read
+ remaining, // Remaining bytes in buffer
+ total; // Total bytes read
DEBUG_printf("4cups_raster_read(r=%p, buf=%p, bytes=" CUPS_LLFMT "), offset=" CUPS_LLFMT, (void *)r, (void *)buf, CUPS_LLCAST bytes, CUPS_LLCAST (r->iostart + (ssize_t)(r->bufptr - r->buffer)));
if (!r->compressed)
return (cups_raster_io(r, buf, bytes));
- /*
- * Allocate a read buffer as needed...
- */
-
+ // Allocate a read buffer as needed...
count = (ssize_t)(2 * r->header.cupsBytesPerLine);
if (count < 65536)
count = 65536;
if ((size_t)count > r->bufsize)
{
ssize_t offset = r->bufptr - r->buffer;
- /* Offset to current start of buffer */
- ssize_t end = r->bufend - r->buffer;/* Offset to current end of buffer */
- unsigned char *rptr; /* Pointer in read buffer */
+ // Offset to current start of buffer
+ ssize_t end = r->bufend - r->buffer;// Offset to current end of buffer
+ unsigned char *rptr; // Pointer in read buffer
if (r->buffer)
rptr = realloc(r->buffer, (size_t)count);
r->bufsize = (size_t)count;
}
- /*
- * Loop until we have read everything...
- */
-
+ // Loop until we have read everything...
for (total = 0, remaining = (int)(r->bufend - r->bufptr);
total < (ssize_t)bytes;
total += count, buf += count)
{
if (count < 16)
{
- /*
- * Read into the raster buffer and then copy...
- */
-
+ // Read into the raster buffer and then copy...
#ifdef DEBUG
r->iostart += (size_t)(r->bufend - r->buffer);
-#endif /* DEBUG */
+#endif // DEBUG
remaining = (*r->iocb)(r->ctx, r->buffer, r->bufsize);
if (remaining <= 0)
#ifdef DEBUG
r->iocount += (size_t)remaining;
-#endif /* DEBUG */
+#endif // DEBUG
}
else
{
- /*
- * Read directly into "buf"...
- */
-
+ // Read directly into "buf"...
count = (*r->iocb)(r->ctx, buf, (size_t)count);
if (count <= 0)
#ifdef DEBUG
r->iostart += (size_t)count;
r->iocount += (size_t)count;
-#endif /* DEBUG */
+#endif // DEBUG
continue;
}
}
- /*
- * Copy bytes from raster buffer to "buf"...
- */
-
+ // Copy bytes from raster buffer to "buf"...
if (count > remaining)
count = remaining;
if (count == 1)
{
- /*
- * Copy 1 byte...
- */
-
+ // Copy 1 byte...
*buf = *(r->bufptr)++;
remaining --;
}
else if (count < 128)
{
- /*
- * Copy up to 127 bytes without using memcpy(); this is
- * faster because it avoids an extra function call and is
- * often further optimized by the compiler...
- */
-
- unsigned char *bufptr; /* Temporary buffer pointer */
+ // Copy up to 127 bytes without using memcpy(); this is faster because it
+ // avoids an extra function call and is often further optimized by the
+ // compiler...
+ unsigned char *bufptr; // Temporary buffer pointer
remaining -= count;
}
else
{
- /*
- * Use memcpy() for a large read...
- */
-
+ // Use memcpy() for a large read...
memcpy(buf, r->bufptr, (size_t)count);
r->bufptr += count;
remaining -= count;
}
-/*
- * 'cups_raster_update()' - Update the raster header and row count for the
- * current page.
- */
+//
+// 'cups_raster_update()' - Update the raster header and row count for the
+// current page.
+//
-static int /* O - 1 on success, 0 on failure */
-cups_raster_update(cups_raster_t *r) /* I - Raster stream */
+static int // O - 1 on success, 0 on failure
+cups_raster_update(cups_raster_t *r) // I - Raster stream
{
if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1 ||
r->header.cupsNumColors == 0)
{
- /*
- * Set the "cupsNumColors" field according to the colorspace...
- */
-
+ // Set the "cupsNumColors" field according to the colorspace...
switch (r->header.cupsColorSpace)
{
case CUPS_CSPACE_W :
break;
default :
- /* Unknown color space */
+ // Unknown color space
return (0);
}
}
- /*
- * Set the number of bytes per pixel/color...
- */
-
+ // Set the number of bytes per pixel/color...
if (r->header.cupsColorOrder == CUPS_ORDER_CHUNKED)
r->bpp = (r->header.cupsBitsPerPixel + 7) / 8;
else
if (r->bpp == 0)
r->bpp = 1;
- /*
- * Set the number of remaining rows...
- */
-
+ // Set the number of remaining rows...
if (r->header.cupsColorOrder == CUPS_ORDER_PLANAR)
r->remaining = r->header.cupsHeight * r->header.cupsNumColors;
else
r->remaining = r->header.cupsHeight;
- /*
- * Allocate the compression buffer...
- */
-
+ // Allocate the compression buffer...
if (r->compressed)
{
if (r->pixels != NULL)
}
-/*
- * 'cups_raster_write()' - Write a row of compressed raster data...
- */
+//
+// 'cups_raster_write()' - Write a row of compressed raster data...
+//
-static ssize_t /* O - Number of bytes written */
+static ssize_t // O - Number of bytes written
cups_raster_write(
- cups_raster_t *r, /* I - Raster stream */
- const unsigned char *pixels) /* I - Pixel data to write */
+ cups_raster_t *r, // I - Raster stream
+ const unsigned char *pixels) // I - Pixel data to write
{
- const unsigned char *start, /* Start of sequence */
- *ptr, /* Current pointer in sequence */
- *pend, /* End of raster buffer */
- *plast; /* Pointer to last pixel */
- unsigned char *wptr; /* Pointer into write buffer */
- unsigned bpp, /* Bytes per pixel */
- count; /* Count */
- _cups_copyfunc_t cf; /* Copy function */
+ const unsigned char *start, // Start of sequence
+ *ptr, // Current pointer in sequence
+ *pend, // End of raster buffer
+ *plast; // Pointer to last pixel
+ unsigned char *wptr; // Pointer into write buffer
+ unsigned bpp, // Bytes per pixel
+ count; // Count
+ _cups_copyfunc_t cf; // Copy function
DEBUG_printf("3cups_raster_write(r=%p, pixels=%p)", (void *)r, (void *)pixels);
- /*
- * Determine whether we need to swap bytes...
- */
-
+ // Determine whether we need to swap bytes...
if (r->swapped && (r->header.cupsBitsPerColor == 16 || r->header.cupsBitsPerPixel == 12 || r->header.cupsBitsPerPixel == 16))
{
DEBUG_puts("4cups_raster_write: Swapping bytes when writing.");
else
cf = (_cups_copyfunc_t)memcpy;
- /*
- * Allocate a write buffer as needed...
- */
-
+ // Allocate a write buffer as needed...
count = r->header.cupsBytesPerLine * 2;
if (count < 65536)
count = 65536;
r->bufsize = count;
}
- /*
- * Write the row repeat count...
- */
-
+ // Write the row repeat count...
bpp = r->bpp;
pend = pixels + r->header.cupsBytesPerLine;
plast = pend - bpp;
wptr = r->buffer;
*wptr++ = (unsigned char)(r->count - 1);
- /*
- * Write using a modified PackBits compression...
- */
-
+ // Write using a modified PackBits compression...
for (ptr = pixels; ptr < pend;)
{
start = ptr;
if (ptr == pend)
{
- /*
- * Encode a single pixel at the end...
- */
-
+ // Encode a single pixel at the end...
*wptr++ = 0;
(*cf)(wptr, start, bpp);
wptr += bpp;
}
else if (!memcmp(start, ptr, bpp))
{
- /*
- * Encode a sequence of repeating pixels...
- */
-
+ // Encode a sequence of repeating pixels...
for (count = 2; count < 128 && ptr < plast; count ++, ptr += bpp)
if (memcmp(ptr, ptr + bpp, bpp))
break;
}
else
{
- /*
- * Encode a sequence of non-repeating pixels...
- */
-
+ // Encode a sequence of non-repeating pixels...
for (count = 1; count < 128 && ptr < plast; count ++, ptr += bpp)
if (!memcmp(ptr, ptr + bpp, bpp))
break;
}
-/*
- * 'cups_swap()' - Swap bytes in raster data...
- */
+//
+// 'cups_swap()' - Swap bytes in raster data...
+//
static void
-cups_swap(unsigned char *buf, /* I - Buffer to swap */
- size_t bytes) /* I - Number of bytes to swap */
+cups_swap(unsigned char *buf, // I - Buffer to swap
+ size_t bytes) // I - Number of bytes to swap
{
- unsigned char even, odd; /* Temporary variables */
+ unsigned char even, odd; // Temporary variables
bytes /= 2;
}
-/*
- * 'cups_swap_copy()' - Copy and swap bytes in raster data...
- */
+//
+// 'cups_swap_copy()' - Copy and swap bytes in raster data...
+//
static void
cups_swap_copy(
- unsigned char *dst, /* I - Destination */
- const unsigned char *src, /* I - Source */
- size_t bytes) /* I - Number of bytes to swap */
+ unsigned char *dst, // I - Destination
+ const unsigned char *src, // I - Source
+ size_t bytes) // I - Number of bytes to swap
{
bytes /= 2;
*
* If there are no recent errors, `NULL` is returned.
*
- * @since CUPS 1.3/macOS 10.5@
+ * @deprecated@ @exclude all@
*/
const char * /* O - Last error or `NULL` */
cupsRasterErrorString(void)
{
- return (_cupsRasterErrorString());
+ return (cupsRasterGetErrorString());
}
* inch.
*
* The "sheet_back" argument specifies a "pwg-raster-document-sheet-back" value
- * to apply for the back side of a page. Pass @code NULL@ for the front side.
+ * to apply for the back side of a page. Pass `NULL` for the front side.
*
- * @since CUPS 2.2/macOS 10.12@
+ * @deprecated@ @exclude all@
*/
int /* O - 1 on success, 0 on failure */
int xdpi, /* I - Cross-feed direction (horizontal) resolution */
int ydpi, /* I - Feed direction (vertical) resolution */
const char *sides, /* I - IPP "sides" option value */
- const char *sheet_back) /* I - Transform for back side or @code NULL@ for none */
+ const char *sheet_back) /* I - Transform for back side or `NULL` for none */
{
return (_cupsRasterInitPWGHeader(h, media, type, xdpi, ydpi, sides, sheet_back));
}
* image processor (RIP) filters that generate raster data, "fd" will be 1
* (stdout).
*
- * When writing raster data, the @code CUPS_RASTER_WRITE@,
- * @code CUPS_RASTER_WRITE_COMPRESS@, or @code CUPS_RASTER_WRITE_PWG@ mode can
+ * When writing raster data, the `CUPS_RASTER_WRITE`,
+ * `CUPS_RASTER_WRITE_COMPRESS`, or `CUPS_RASTER_WRITE_PWG` mode can
* be used - compressed and PWG output is generally 25-50% smaller but adds a
* 100-300% execution time overhead.
*/
cups_raster_t * /* O - New stream */
cupsRasterOpen(int fd, /* I - File descriptor */
- cups_mode_t mode) /* I - Mode - @code CUPS_RASTER_READ@,
- @code CUPS_RASTER_WRITE@,
- @code CUPS_RASTER_WRITE_COMPRESSED@,
- or @code CUPS_RASTER_WRITE_PWG@ */
+ cups_mode_t mode) /* I - Mode - `CUPS_RASTER_READ`,
+ `CUPS_RASTER_WRITE`,
+ `CUPS_RASTER_WRITE_COMPRESSED`,
+ or `CUPS_RASTER_WRITE_PWG` */
{
if (mode == CUPS_RASTER_READ)
return (_cupsRasterNew(cups_read_fd, (void *)((intptr_t)fd), mode));
* This function associates a raster stream with the given callback function and
* context pointer.
*
- * When writing raster data, the @code CUPS_RASTER_WRITE@,
- * @code CUPS_RASTER_WRITE_COMPRESS@, or @code CUPS_RASTER_WRITE_PWG@ mode can
+ * When writing raster data, the `CUPS_RASTER_WRITE`,
+ * `CUPS_RASTER_WRITE_COMPRESS`, or `CUPS_RASTER_WRITE_PWG` mode can
* be used - compressed and PWG output is generally 25-50% smaller but adds a
* 100-300% execution time overhead.
*/
cups_raster_t * /* O - New stream */
cupsRasterOpenIO(
- cups_raster_iocb_t iocb, /* I - Read/write callback */
+ cups_raster_cb_t iocb, /* I - Read/write callback */
void *ctx, /* I - Context pointer for callback */
- cups_mode_t mode) /* I - Mode - @code CUPS_RASTER_READ@,
- @code CUPS_RASTER_WRITE@,
- @code CUPS_RASTER_WRITE_COMPRESSED@,
- or @code CUPS_RASTER_WRITE_PWG@ */
+ cups_raster_mode_t mode) /* I - Mode - `CUPS_RASTER_READ`,
+ `CUPS_RASTER_WRITE`,
+ `CUPS_RASTER_WRITE_COMPRESSED`,
+ or `CUPS_RASTER_WRITE_PWG` */
{
return (_cupsRasterNew(iocb, ctx, mode));
}
--- /dev/null
+//
+// Raster test page generator for CUPS.
+//
+// Copyright © 2020-2023 by OpenPrinting
+// Copyright © 2017-2019 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "raster-private.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+
+//
+// 'cupsRasterWriteTest()' - Write a series of raster test pages.
+//
+// This function writes a series of raster test pages to the specified raster
+// stream. You must call @link cupsRasterInitPWGHeader@ to create the raster
+// page header and call @link cupsRasterOpen@ or @link cupsRasterOpenIO@ to create
+// a stream for writing prior to calling this function.
+//
+// Each page consists of a black border (1/4 to 1/2" in width depending on the
+// media size) with the text "TEST-PAGE ####" repeated down the page in
+// different shades of gray or colors. When generating multiple pages, the
+// proper back side transforms are applied for duplex printing as needed.
+//
+
+static bool // O - `true` on success, `false` on failure
+cupsRasterWriteTest(
+ cups_raster_t *ras, // I - Raster stream
+ cups_page_header2_t *header, // I - Raster page header (front side)
+ cups_page_header2_t *back_header, // I - Raster page header (back side)
+ const char *sheet_back, // I - Back side transform needed
+ ipp_orient_t orientation, // I - Output orientation
+ int num_copies, // I - Number of copies
+ int num_pages) // I - Number of pages
+{
+ int copy, // Current copy number
+ page; // Current page number
+ char pagestr[5], // Page number string
+ output[8][101]; // Output image
+ unsigned char *line, // Line of raster data
+ *bline, // Border line in raster data
+ *lineptr, // Pointer into line
+ *lineend, // Pointer to end of line
+ black, // Black pixel
+ white; // White pixel
+ unsigned bpp, // Bytes per pixel
+ x, y, // Current position on page
+ xcount, ycount, // Current count for X and Y
+ xrep, yrep, // Repeat count for X and Y
+ xborder, // X border
+ yborder, // Y border
+ xoff, yoff, // X and Y offsets
+ xend, yend, // End X and Y values
+ yend2, // End Y value for solid border
+ rows; // Number of rows
+ int col, row, // Column and row in output
+ color; // Template color
+ ipp_orient_t porientation; // Current page orientation
+ bool pflip; // Current page (vertical) flip
+ const char *outptr; // Pointer into output image line
+ const unsigned char *colorptr; // Current color
+ static const unsigned char colors[][3] =
+ { // Colors for test
+ { 0, 0, 0 },
+ { 63, 63, 63 },
+ { 127, 127, 127 },
+ { 191, 191, 191 },
+ { 255, 0, 0 },
+ { 255, 127, 0 },
+ { 255, 191, 0 },
+ { 255, 255, 0 },
+ { 191, 255, 0 },
+ { 0, 255, 0 },
+ { 0, 255, 191 },
+ { 0, 255, 255 },
+ { 0, 191, 255 },
+ { 0, 0, 255 },
+ { 127, 0, 255 },
+ { 255, 0, 255 }
+ };
+ static const char * const test_page[] =
+ { // "TEST-PAGE" template
+ " TTTTT EEEEE SSSSS TTTTT PPPPP AAAAA GGGGG EEEEE ",
+ " T E S S T P P A A G E ",
+ " T E S T P P A A G E ",
+ " T EEEE SSSSS T ----- PPPPP AAAAA G GG EEEE ",
+ " T E S T P A A G G E ",
+ " T E S S T P A A G G E ",
+ " T EEEEE SSSSS T P A A GGGGG EEEEE ",
+ " "
+ };
+ static const char * const digits[] = // Digits template
+ {
+ "00000 1 22222 33333 4 55555 6666 77777 88888 99999 ",
+ "0 0 1 2 3 4 4 5 6 7 8 8 9 9 ",
+ "0 0 1 2 3 4 4 5 6 7 8 8 9 9 ",
+ "0 0 0 1 22222 3333 44444 55555 66666 7 88888 99999 ",
+ "0 0 1 2 3 4 5 6 6 7 8 8 9 ",
+ "0 0 1 2 3 4 5 6 6 7 8 8 9 ",
+ "00000 1 22222 33333 4 55555 66666 7 88888 9999 ",
+ " "
+ };
+
+
+ // Update the page header->..
+ header->cupsInteger[CUPS_RASTER_PWG_TotalPageCount] = (unsigned)(num_copies * num_pages);
+
+ // Calculate the border sizes and offsets...
+ if (header->cupsWidth > (2 * header->HWResolution[0]) && header->cupsHeight > (2 * header->HWResolution[1]))
+ {
+ xborder = header->HWResolution[0] / 2;
+ yborder = header->HWResolution[1] / 2;
+ }
+ else
+ {
+ xborder = header->HWResolution[0] / 4;
+ yborder = header->HWResolution[1] / 4;
+ }
+
+ if (orientation == IPP_ORIENT_PORTRAIT || orientation == IPP_ORIENT_REVERSE_PORTRAIT)
+ {
+ xrep = (header->cupsWidth - 2 * xborder) / 100;
+ yrep = xrep * header->HWResolution[1] / header->HWResolution[0];
+ rows = (header->cupsHeight - 3 * yborder) / yrep / 8;
+ xoff = (header->cupsWidth - 100 * xrep) / 2;
+
+ if (rows)
+ yoff = (header->cupsHeight - rows * 8 * yrep) / 2;
+ else
+ yoff = yborder + yrep / 2;
+ }
+ else
+ {
+ yrep = (header->cupsHeight - 2 * yborder) / 100;
+ xrep = yrep * header->HWResolution[0] / header->HWResolution[1];
+ rows = (header->cupsWidth - 3 * xborder) / xrep / 8;
+ yoff = (header->cupsHeight - 100 * yrep) / 2;
+
+ if (rows)
+ xoff = (header->cupsWidth - rows * 8 * xrep) / 2;
+ else
+ xoff = xborder + xrep / 2;
+ }
+
+ xend = header->cupsWidth - xoff;
+ yend = header->cupsHeight - yoff;
+ yend2 = header->cupsHeight - yborder;
+
+ // Allocate memory for the raster output...
+ if ((line = malloc(header->cupsBytesPerLine)) == NULL)
+ {
+ _cupsRasterAddError("Unable to allocate %u bytes for line: %s", header->cupsBytesPerLine, strerror(errno));
+ return (false);
+ }
+
+ if ((bline = malloc(header->cupsBytesPerLine)) == NULL)
+ {
+ _cupsRasterAddError("Unable to allocate %u bytes for line: %s", header->cupsBytesPerLine, strerror(errno));
+ free(line);
+ return (false);
+ }
+
+ switch (header->cupsColorSpace)
+ {
+ default :
+ black = 0x00;
+ white = 0xff;
+ break;
+
+ case CUPS_CSPACE_K :
+ case CUPS_CSPACE_CMYK :
+ black = 0xff;
+ white = 0x00;
+ break;
+ }
+
+ bpp = header->cupsBitsPerPixel / 8;
+ lineend = line + header->cupsBytesPerLine;
+
+ // Loop to create all copies and pages...
+ for (copy = 0; copy < num_copies; copy ++)
+ {
+ for (page = 0; page < num_pages; page ++)
+ {
+ // Format the output rows for "TEST-PAGE ####"
+ memset(output, 0, sizeof(output));
+ snprintf(pagestr, sizeof(pagestr), "%04d", page + 1);
+
+ for (row = 0; row < 8; row ++)
+ {
+ // Base "TEST-PAGE"
+ memcpy(output[row], test_page[row], 72);
+ for (col = 0; col < 4; col ++)
+ memcpy(output[row] + 72 + col * 7, digits[row] + (pagestr[col] - '0') * 7, 7);
+ }
+
+ // Start the page and show the borders...
+ if (page & 1)
+ cupsRasterWriteHeader2(ras, back_header);
+ else
+ cupsRasterWriteHeader2(ras, header);
+
+ if (bpp == 4)
+ {
+ // 32-bit CMYK output
+ for (lineptr = line; lineptr < lineend;)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ }
+ }
+ else if (bpp == 8)
+ {
+ // 64-bit CMYK output
+ for (lineptr = line; lineptr < lineend;)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ *lineptr++ = 0xff;
+ }
+ }
+ else
+ {
+ // 1/8/16/24/32-bit bitmap/grayscale/color output...
+ memset(line, black, header->cupsBytesPerLine);
+ }
+
+ for (y = 0; y < yborder; y ++)
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+
+ memset(bline, white, header->cupsBytesPerLine);
+ if (bpp == 4)
+ {
+ // 32-bit CMYK output
+ for (lineptr = bline, xcount = xborder; xcount > 0; xcount --)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ }
+
+ for (lineptr = bline + header->cupsBytesPerLine - xborder * 4, xcount = xborder; xcount > 0; xcount --)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ }
+ }
+ else if (bpp == 8)
+ {
+ // 64-bit CMYK output
+ for (lineptr = bline, xcount = xborder; xcount > 0; xcount --)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ *lineptr++ = 0xff;
+ }
+
+ for (lineptr = bline + header->cupsBytesPerLine - xborder * 8, xcount = xborder; xcount > 0; xcount --)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ *lineptr++ = 0xff;
+ }
+ }
+ else if (bpp)
+ {
+ // 8/16/24/32-bit grayscale/color output...
+ memset(bline, black, xborder * bpp);
+ memset(bline + header->cupsBytesPerLine - xborder * bpp, black, xborder * bpp);
+ }
+ else
+ {
+ // Bitmap output...
+ if (xborder >= 8)
+ {
+ memset(bline, black, xborder / 8);
+ memset(bline + header->cupsBytesPerLine - xborder / 8, black, xborder / 8);
+ }
+ if (xborder & 7)
+ {
+ // Capture partial pixels
+ bline[xborder / 8] ^= (0xff << (xborder & 7)) & 0xff;
+ bline[header->cupsBytesPerLine - xborder / 8 - 1] ^= 0xff >> (xborder & 7);
+ }
+ }
+
+ for (; y < yoff; y ++)
+ cupsRasterWritePixels(ras, bline, header->cupsBytesPerLine);
+
+ // Generate the interior lines...
+ if (header->Duplex && (page & 1) != 0)
+ {
+ // Update orientation for back side
+ if (!strcmp(sheet_back, "normal"))
+ {
+ porientation = orientation;
+ pflip = false;
+ }
+ else if (!strcmp(sheet_back, "rotated"))
+ {
+ if (header->Tumble)
+ porientation = orientation;
+ else
+ porientation = (ipp_orient_t)(9 - orientation);
+
+ pflip = false;
+ }
+ else if (!strcmp(sheet_back, "manual-tumble"))
+ {
+ if (header->Tumble)
+ porientation = (ipp_orient_t)(9 - orientation);
+ else
+ porientation = orientation;
+
+ pflip = false;
+ }
+ else // flipped
+ {
+ porientation = orientation;
+ pflip = true;
+ }
+ }
+ else
+ {
+ // Use front side orientation
+ porientation = orientation;
+ pflip = false;
+ }
+
+ if (pflip)
+ {
+ // Draw the test image from bottom to top
+ switch (porientation)
+ {
+ default :
+ case IPP_ORIENT_PORTRAIT :
+ color = (int)rows - 1;
+ if (bpp <= 2)
+ color &= 3;
+ else
+ color &= 15;
+
+ for (row = 7; y < yend;)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ // Format the current line in the output row...
+ memcpy(line, bline, header->cupsBytesPerLine);
+ colorptr = colors[color];
+
+ for (outptr = output[row], x = xoff; *outptr; outptr ++, x += xrep)
+ {
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ if (*outptr == ' ')
+ continue;
+
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+
+ // Next row in the output image...
+ row --;
+ if (row < 0)
+ {
+ // New row of text with a new color/gray shade...
+ row = 7;
+ color --;
+ if (color < 0)
+ {
+ if (bpp > 2)
+ color = 15;
+ else
+ color = 3;
+ }
+ }
+ }
+ break;
+
+ case IPP_ORIENT_LANDSCAPE :
+ for (col = 99; col >= 0; col --)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ memcpy(line, bline, header->cupsBytesPerLine);
+
+ color = (int)rows - 1;
+ if (bpp <= 2)
+ color &= 3;
+ else
+ color &= 15;
+
+ for (row = (rows - 1) & 7, x = xoff; x < xend; x += xrep)
+ {
+ // Format the current line in the output row...
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ colorptr = colors[color];
+
+ if (output[row][col] != ' ')
+ {
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ // Next row in the output image...
+ row --;
+ if (row < 0)
+ {
+ // New row of text with a new color/gray shade...
+ row = 7;
+ color --;
+ if (color < 0)
+ {
+ if (bpp > 2)
+ color = 15;
+ else
+ color = 3;
+ }
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+ }
+ break;
+
+ case IPP_ORIENT_REVERSE_PORTRAIT :
+ for (row = 0, color = 0; y < yend;)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ // Format the current line in the output row...
+ memcpy(line, bline, header->cupsBytesPerLine);
+ colorptr = colors[color];
+
+ for (outptr = output[row] + 99, x = xoff; outptr >= output[row]; outptr --, x += xrep)
+ {
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ if (*outptr == ' ')
+ continue;
+
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+
+ // Next row in the output image...
+ row ++;
+ if (row >= 8)
+ {
+ // New row of text with a new color/gray shade...
+ row = 0;
+ color ++;
+ if ((bpp > 2 && color >= 16) || (bpp <= 2 && color >= 4))
+ color = 0;
+ }
+ }
+ break;
+ case IPP_ORIENT_REVERSE_LANDSCAPE :
+ for (col = 0; col < 100; col ++)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ memcpy(line, bline, header->cupsBytesPerLine);
+
+ color = 0;
+
+ for (row = 0, x = xoff; x < xend; x += xrep)
+ {
+ // Format the current line in the output row...
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ colorptr = colors[color];
+
+ if (output[row][col] != ' ')
+ {
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ // Next row in the output image...
+ row ++;
+ if (row > 7)
+ {
+ // New row of text with a new color/gray shade...
+ row = 0;
+ color ++;
+ if ((bpp > 2 && color >= 16) || (bpp <= 2 && color >= 4))
+ color = 0;
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+ }
+ break;
+ }
+ }
+ else
+ {
+ // Draw the test image from top to bottom
+ switch (porientation)
+ {
+ default :
+ case IPP_ORIENT_PORTRAIT :
+ for (row = 0, color = 0; y < yend;)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ // Format the current line in the output row...
+ memcpy(line, bline, header->cupsBytesPerLine);
+ colorptr = colors[color];
+
+ for (outptr = output[row], x = xoff; *outptr; outptr ++, x += xrep)
+ {
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ if (*outptr == ' ')
+ continue;
+
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+
+ // Next row in the output image...
+ row ++;
+ if (row >= 8)
+ {
+ // New row of text with a new color/gray shade...
+ row = 0;
+ color ++;
+ if ((bpp > 2 && color >= 16) || (bpp <= 2 && color >= 4))
+ color = 0;
+ }
+ }
+ break;
+
+ case IPP_ORIENT_LANDSCAPE :
+ for (col = 0; col < 100; col ++)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ memcpy(line, bline, header->cupsBytesPerLine);
+
+ color = (int)rows - 1;
+ if (bpp <= 2)
+ color &= 3;
+ else
+ color &= 15;
+
+ for (row = 7, x = xoff; x < xend; x += xrep)
+ {
+ // Format the current line in the output row...
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ colorptr = colors[color];
+
+ if (output[row][col] != ' ')
+ {
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ // Next row in the output image...
+ row --;
+ if (row < 0)
+ {
+ // New row of text with a new color/gray shade...
+ row = 7;
+ color --;
+ if (color < 0)
+ {
+ if (bpp > 2)
+ color = 15;
+ else
+ color = 3;
+ }
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+ }
+ break;
+
+ case IPP_ORIENT_REVERSE_PORTRAIT :
+ color = (int)rows - 1;
+ if (bpp <= 2)
+ color &= 3;
+ else
+ color &= 15;
+
+ for (row = 7; y < yend;)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ // Format the current line in the output row...
+ memcpy(line, bline, header->cupsBytesPerLine);
+ colorptr = colors[color];
+
+ for (outptr = output[row] + 99, x = xoff; outptr >= output[row]; outptr --, x += xrep)
+ {
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ if (*outptr == ' ')
+ continue;
+
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+
+ // Next row in the output image...
+ row --;
+ if (row < 0)
+ {
+ // New row of text with a new color/gray shade...
+ row = 7;
+ color --;
+ if (color < 0)
+ {
+ if (bpp > 2)
+ color = 15;
+ else
+ color = 3;
+ }
+ }
+ }
+ break;
+ case IPP_ORIENT_REVERSE_LANDSCAPE :
+ for (col = 99; col >= 0; col --)
+ {
+ // Write N scan lines...
+ for (ycount = yrep; ycount > 0 && y < yend; ycount --, y ++)
+ {
+ memcpy(line, bline, header->cupsBytesPerLine);
+
+ color = 0;
+
+ for (row = 0, x = xoff; x < xend; x += xrep)
+ {
+ // Format the current line in the output row...
+ unsigned char bit, // Current bit
+ pattern;// Shading pattern
+
+ colorptr = colors[color];
+
+ if (output[row][col] != ' ')
+ {
+ switch (bpp)
+ {
+ case 0 : // 1-bit bitmap output
+ if (*colorptr < 63)
+ {
+ pattern = 0xff;
+ }
+ else if (*colorptr < 127)
+ {
+ pattern = (y & 1) ? 0x55 : 0xff;
+ }
+ else if (*colorptr < 191)
+ {
+ pattern = (y & 1) ? 0x55 : 0xaa;
+ }
+ else if (y & 1)
+ {
+ break;
+ }
+ else
+ {
+ pattern = 0xaa;
+ }
+
+ lineptr = line + x / 8;
+ bit = 0x80 >> (x & 7);
+
+ for (xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr ^= bit & pattern;
+ if (bit > 1)
+ {
+ bit /= 2;
+ }
+ else
+ {
+ bit = 0x80;
+ lineptr ++;
+ }
+ }
+ break;
+ case 1 : // 8-bit grayscale/black
+ if (black)
+ memset(line + x, 255 - *colorptr, xrep);
+ else
+ memset(line + x, *colorptr, xrep);
+ break;
+ case 2 : // 16-bit grayscale/black
+ if (black)
+ memset(line + 2 * x, 255 - *colorptr, 2 * xrep);
+ else
+ memset(line + 2 * x, *colorptr, 2 * xrep);
+ break;
+ case 3 : // 24-bit RGB
+ for (lineptr = line + 3 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 4 : // 32-bit CMYK
+ for (lineptr = line + 4 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ case 6 : // 24-bit RGB
+ for (lineptr = line + 6 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[0];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[1];
+ *lineptr++ = colorptr[2];
+ *lineptr++ = colorptr[2];
+ }
+ break;
+ case 8 : // 64-bit CMYK
+ for (lineptr = line + 8 * x, xcount = xrep; xcount > 0; xcount --)
+ {
+ if (color < 4)
+ {
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ }
+ else
+ {
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[0];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[1];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 255 - colorptr[2];
+ *lineptr++ = 0;
+ *lineptr++ = 0;
+ }
+ }
+ break;
+ }
+ }
+
+ // Next row in the output image...
+ row ++;
+ if (row > 7)
+ {
+ // New row of text with a new color/gray shade...
+ row = 0;
+ color ++;
+ if ((bpp > 2 && color >= 16) || (bpp <= 2 && color >= 4))
+ color = 0;
+ }
+ }
+
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+ }
+ break;
+ }
+ }
+
+ // Write out the last of the border lines
+ for (; y < yend2; y ++)
+ cupsRasterWritePixels(ras, bline, header->cupsBytesPerLine);
+
+ if (bpp == 4)
+ {
+ // 32-bit CMYK output
+ for (lineptr = line; lineptr < lineend;)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ }
+ }
+ else if (bpp == 8)
+ {
+ // 64-bit CMYK output
+ for (lineptr = line; lineptr < lineend;)
+ {
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0x00;
+ *lineptr++ = 0xff;
+ *lineptr++ = 0xff;
+ }
+ }
+ else
+ {
+ // 1/8/16/24/32-bit bitmap/grayscale/color output...
+ memset(line, black, header->cupsBytesPerLine);
+ }
+
+ for (; y < header->cupsHeight; y ++)
+ cupsRasterWritePixels(ras, line, header->cupsBytesPerLine);
+ }
+ }
+
+ // Free memory and return...
+ free(line);
+ free(bline);
+
+ return (true);
+}
-/*
- * Raster file definitions for CUPS.
- *
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
- *
- * This file is part of the CUPS Imaging library.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// Raster file definitions for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2018 by Apple Inc.
+// Copyright © 1997-2006 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_RASTER_H_
# define _CUPS_RASTER_H_
-
-/*
- * Include necessary headers...
- */
-
# include "cups.h"
-
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Every non-PostScript printer driver that supports raster images
- * should use the application/vnd.cups-raster image file format.
- * Since both the PostScript RIP (pstoraster, based on GNU/GPL
- * Ghostscript) and Image RIP (imagetoraster, located in the filter
- * directory) use it, using this format saves you a lot of work.
- * Also, the PostScript RIP passes any printer options that are in
- * a PS file to your driver this way as well...
- */
-/*
- * Constants...
- */
+//
+// Constants...
+//
-# define CUPS_RASTER_SYNC 0x52615333 /* RaS3 */
-# define CUPS_RASTER_REVSYNC 0x33536152 /* 3SaR */
+# define CUPS_RASTER_SYNC 0x52615333 // RaS3
+# define CUPS_RASTER_REVSYNC 0x33536152 // 3SaR
-# define CUPS_RASTER_SYNCv1 0x52615374 /* RaSt */
-# define CUPS_RASTER_REVSYNCv1 0x74536152 /* tSaR */
+# define CUPS_RASTER_SYNCv1 0x52615374 // RaSt
+# define CUPS_RASTER_REVSYNCv1 0x74536152 // tSaR
-# define CUPS_RASTER_SYNCv2 0x52615332 /* RaS2 */
-# define CUPS_RASTER_REVSYNCv2 0x32536152 /* 2SaR */
+# define CUPS_RASTER_SYNCv2 0x52615332 // RaS2
+# define CUPS_RASTER_REVSYNCv2 0x32536152 // 2SaR
-# define CUPS_RASTER_SYNCapple 0x554E4952 /* UNIR */
-# define CUPS_RASTER_REVSYNCapple 0x52494E55 /* RINU */
+# define CUPS_RASTER_SYNCapple 0x554E4952 // UNIR
+# define CUPS_RASTER_REVSYNCapple 0x52494E55 // RINU
# define CUPS_RASTER_SYNC_PWG CUPS_RASTER_SYNCv2
-/*
- * The following definition can be used to determine if the
- * colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
- * defined...
- */
+//
+// The following definition can be used to determine if the
+// colorimetric colorspaces (CIEXYZ, CIELAB, and ICCn) are
+// defined...
+//
# define CUPS_RASTER_HAVE_COLORIMETRIC 1
-/*
- * The following definition can be used to determine if the
- * device colorspaces (DEVICEn) are defined...
- */
+//
+// The following definition can be used to determine if the
+// device colorspaces (DEVICEn) are defined...
+//
# define CUPS_RASTER_HAVE_DEVICE 1
-/*
- * The following definition can be used to determine if PWG Raster is supported.
- */
+//
+// The following definition can be used to determine if PWG Raster is supported.
+//
# define CUPS_RASTER_HAVE_PWGRASTER 1
-/*
- * The following definition can be used to determine if Apple Raster is
- * supported (beta).
- */
+//
+// The following definition can be used to determine if Apple Raster is
+// supported (beta).
+//
# define CUPS_RASTER_HAVE_APPLERASTER 1
-/*
- * The following PWG 5102.4 definitions specify indices into the
- * cupsInteger[] array in the raster header.
- */
+//
+// The following PWG 5102.4 definitions specify indices into the
+// cupsInteger[] array in the raster header.
+//
# define CUPS_RASTER_PWG_TotalPageCount 0
# define CUPS_RASTER_PWG_CrossFeedTransform 1
# define CUPS_RASTER_PWG_VendorLength 15
+//
+// Types...
+//
-
-/*
- * Types...
- */
-
-typedef enum cups_adv_e /**** AdvanceMedia attribute values ****/
+typedef enum cups_adv_e // AdvanceMedia attribute values
{
- CUPS_ADVANCE_NONE = 0, /* Never advance the roll */
- CUPS_ADVANCE_FILE = 1, /* Advance the roll after this file */
- CUPS_ADVANCE_JOB = 2, /* Advance the roll after this job */
- CUPS_ADVANCE_SET = 3, /* Advance the roll after this set */
- CUPS_ADVANCE_PAGE = 4 /* Advance the roll after this page */
+ CUPS_ADVANCE_NONE = 0, // Never advance the roll
+ CUPS_ADVANCE_FILE = 1, // Advance the roll after this file
+ CUPS_ADVANCE_JOB = 2, // Advance the roll after this job
+ CUPS_ADVANCE_SET = 3, // Advance the roll after this set
+ CUPS_ADVANCE_PAGE = 4 // Advance the roll after this page
} cups_adv_t;
-typedef enum cups_bool_e /**** Boolean type ****/
+typedef enum cups_bool_e // Boolean type
{
- CUPS_FALSE = 0, /* Logical false */
- CUPS_TRUE = 1 /* Logical true */
+ CUPS_FALSE = 0, // Logical false
+ CUPS_TRUE = 1 // Logical true
} cups_bool_t;
-typedef enum cups_cspace_e /**** cupsColorSpace attribute values ****/
+typedef enum cups_cspace_e // cupsColorSpace attribute values
{
- CUPS_CSPACE_W = 0, /* Luminance (DeviceGray, gamma 2.2 by default) */
- CUPS_CSPACE_RGB = 1, /* Red, green, blue (DeviceRGB, sRGB by default) */
- CUPS_CSPACE_RGBA = 2, /* Red, green, blue, alpha (DeviceRGB, sRGB by default) */
- CUPS_CSPACE_K = 3, /* Black (DeviceK) */
- CUPS_CSPACE_CMY = 4, /* Cyan, magenta, yellow (DeviceCMY) */
- CUPS_CSPACE_YMC = 5, /* Yellow, magenta, cyan @deprecated@ */
- CUPS_CSPACE_CMYK = 6, /* Cyan, magenta, yellow, black (DeviceCMYK) */
- CUPS_CSPACE_YMCK = 7, /* Yellow, magenta, cyan, black @deprecated@ */
- CUPS_CSPACE_KCMY = 8, /* Black, cyan, magenta, yellow @deprecated@ */
- CUPS_CSPACE_KCMYcm = 9, /* Black, cyan, magenta, yellow, light-cyan, light-magenta @deprecated@ */
- CUPS_CSPACE_GMCK = 10, /* Gold, magenta, yellow, black @deprecated@ */
- CUPS_CSPACE_GMCS = 11, /* Gold, magenta, yellow, silver @deprecated@ */
- CUPS_CSPACE_WHITE = 12, /* White ink (as black) @deprecated@ */
- CUPS_CSPACE_GOLD = 13, /* Gold foil @deprecated@ */
- CUPS_CSPACE_SILVER = 14, /* Silver foil @deprecated@ */
-
- CUPS_CSPACE_CIEXYZ = 15, /* CIE XYZ @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_CIELab = 16, /* CIE Lab @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_RGBW = 17, /* Red, green, blue, white (DeviceRGB, sRGB by default) @since CUPS 1.2/macOS 10.5@ */
- CUPS_CSPACE_SW = 18, /* Luminance (gamma 2.2) @since CUPS 1.4.5@ */
- CUPS_CSPACE_SRGB = 19, /* Red, green, blue (sRGB) @since CUPS 1.4.5@ */
- CUPS_CSPACE_ADOBERGB = 20, /* Red, green, blue (Adobe RGB) @since CUPS 1.4.5@ */
-
- CUPS_CSPACE_ICC1 = 32, /* ICC-based, 1 color @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC2 = 33, /* ICC-based, 2 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC3 = 34, /* ICC-based, 3 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC4 = 35, /* ICC-based, 4 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC5 = 36, /* ICC-based, 5 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC6 = 37, /* ICC-based, 6 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC7 = 38, /* ICC-based, 7 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC8 = 39, /* ICC-based, 8 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICC9 = 40, /* ICC-based, 9 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICCA = 41, /* ICC-based, 10 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICCB = 42, /* ICC-based, 11 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICCC = 43, /* ICC-based, 12 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICCD = 44, /* ICC-based, 13 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICCE = 45, /* ICC-based, 14 colors @since CUPS 1.1.19/macOS 10.3@ */
- CUPS_CSPACE_ICCF = 46, /* ICC-based, 15 colors @since CUPS 1.1.19/macOS 10.3@ */
-
- CUPS_CSPACE_DEVICE1 = 48, /* DeviceN, 1 color @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE2 = 49, /* DeviceN, 2 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE3 = 50, /* DeviceN, 3 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE4 = 51, /* DeviceN, 4 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE5 = 52, /* DeviceN, 5 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE6 = 53, /* DeviceN, 6 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE7 = 54, /* DeviceN, 7 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE8 = 55, /* DeviceN, 8 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICE9 = 56, /* DeviceN, 9 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICEA = 57, /* DeviceN, 10 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICEB = 58, /* DeviceN, 11 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICEC = 59, /* DeviceN, 12 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICED = 60, /* DeviceN, 13 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICEE = 61, /* DeviceN, 14 colors @since CUPS 1.4.5@ */
- CUPS_CSPACE_DEVICEF = 62 /* DeviceN, 15 colors @since CUPS 1.4.5@ */
+ CUPS_CSPACE_W = 0, // Luminance (DeviceGray, gamma 2.2 by default)
+ CUPS_CSPACE_RGB = 1, // Red, green, blue (DeviceRGB, sRGB by default)
+ CUPS_CSPACE_RGBA = 2, // Red, green, blue, alpha (DeviceRGB, sRGB by default)
+ CUPS_CSPACE_K = 3, // Black (DeviceK)
+ CUPS_CSPACE_CMY = 4, // Cyan, magenta, yellow (DeviceCMY)
+ CUPS_CSPACE_YMC = 5, // Yellow, magenta, cyan @deprecated@
+ CUPS_CSPACE_CMYK = 6, // Cyan, magenta, yellow, black (DeviceCMYK)
+ CUPS_CSPACE_YMCK = 7, // Yellow, magenta, cyan, black @deprecated@
+ CUPS_CSPACE_KCMY = 8, // Black, cyan, magenta, yellow @deprecated@
+ CUPS_CSPACE_KCMYcm = 9, // Black, cyan, magenta, yellow, light-cyan, light-magenta @deprecated@
+ CUPS_CSPACE_GMCK = 10, // Gold, magenta, yellow, black @deprecated@
+ CUPS_CSPACE_GMCS = 11, // Gold, magenta, yellow, silver @deprecated@
+ CUPS_CSPACE_WHITE = 12, // White ink (as black) @deprecated@
+ CUPS_CSPACE_GOLD = 13, // Gold foil @deprecated@
+ CUPS_CSPACE_SILVER = 14, // Silver foil @deprecated@
+
+ CUPS_CSPACE_CIEXYZ = 15, // CIE XYZ @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_CIELab = 16, // CIE Lab @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_RGBW = 17, // Red, green, blue, white (DeviceRGB, sRGB by default) @since CUPS 1.2/macOS 10.5@
+ CUPS_CSPACE_SW = 18, // Luminance (gamma 2.2) @since CUPS 1.4.5@
+ CUPS_CSPACE_SRGB = 19, // Red, green, blue (sRGB) @since CUPS 1.4.5@
+ CUPS_CSPACE_ADOBERGB = 20, // Red, green, blue (Adobe RGB) @since CUPS 1.4.5@
+
+ CUPS_CSPACE_ICC1 = 32, // ICC-based, 1 color @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC2 = 33, // ICC-based, 2 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC3 = 34, // ICC-based, 3 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC4 = 35, // ICC-based, 4 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC5 = 36, // ICC-based, 5 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC6 = 37, // ICC-based, 6 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC7 = 38, // ICC-based, 7 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC8 = 39, // ICC-based, 8 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICC9 = 40, // ICC-based, 9 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICCA = 41, // ICC-based, 10 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICCB = 42, // ICC-based, 11 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICCC = 43, // ICC-based, 12 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICCD = 44, // ICC-based, 13 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICCE = 45, // ICC-based, 14 colors @since CUPS 1.1.19/macOS 10.3@
+ CUPS_CSPACE_ICCF = 46, // ICC-based, 15 colors @since CUPS 1.1.19/macOS 10.3@
+
+ CUPS_CSPACE_DEVICE1 = 48, // DeviceN, 1 color @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE2 = 49, // DeviceN, 2 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE3 = 50, // DeviceN, 3 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE4 = 51, // DeviceN, 4 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE5 = 52, // DeviceN, 5 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE6 = 53, // DeviceN, 6 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE7 = 54, // DeviceN, 7 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE8 = 55, // DeviceN, 8 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICE9 = 56, // DeviceN, 9 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICEA = 57, // DeviceN, 10 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICEB = 58, // DeviceN, 11 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICEC = 59, // DeviceN, 12 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICED = 60, // DeviceN, 13 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICEE = 61, // DeviceN, 14 colors @since CUPS 1.4.5@
+ CUPS_CSPACE_DEVICEF = 62 // DeviceN, 15 colors @since CUPS 1.4.5@
} cups_cspace_t;
-typedef enum cups_cut_e /**** CutMedia attribute values ****/
+typedef enum cups_cut_e // CutMedia attribute values
{
- CUPS_CUT_NONE = 0, /* Never cut the roll */
- CUPS_CUT_FILE = 1, /* Cut the roll after this file */
- CUPS_CUT_JOB = 2, /* Cut the roll after this job */
- CUPS_CUT_SET = 3, /* Cut the roll after this set */
- CUPS_CUT_PAGE = 4 /* Cut the roll after this page */
+ CUPS_CUT_NONE = 0, // Never cut the roll
+ CUPS_CUT_FILE = 1, // Cut the roll after this file
+ CUPS_CUT_JOB = 2, // Cut the roll after this job
+ CUPS_CUT_SET = 3, // Cut the roll after this set
+ CUPS_CUT_PAGE = 4 // Cut the roll after this page
} cups_cut_t;
-typedef enum cups_edge_e /**** LeadingEdge attribute values ****/
+typedef enum cups_edge_e // LeadingEdge attribute values
{
- CUPS_EDGE_TOP = 0, /* Leading edge is the top of the page */
- CUPS_EDGE_RIGHT = 1, /* Leading edge is the right of the page */
- CUPS_EDGE_BOTTOM = 2, /* Leading edge is the bottom of the page */
- CUPS_EDGE_LEFT = 3 /* Leading edge is the left of the page */
+ CUPS_EDGE_TOP = 0, // Leading edge is the top of the page
+ CUPS_EDGE_RIGHT = 1, // Leading edge is the right of the page
+ CUPS_EDGE_BOTTOM = 2, // Leading edge is the bottom of the page
+ CUPS_EDGE_LEFT = 3 // Leading edge is the left of the page
} cups_edge_t;
-typedef enum cups_jog_e /**** Jog attribute values ****/
+typedef enum cups_jog_e // Jog attribute values
{
- CUPS_JOG_NONE = 0, /* Never move pages */
- CUPS_JOG_FILE = 1, /* Move pages after this file */
- CUPS_JOG_JOB = 2, /* Move pages after this job */
- CUPS_JOG_SET = 3 /* Move pages after this set */
+ CUPS_JOG_NONE = 0, // Never move pages
+ CUPS_JOG_FILE = 1, // Move pages after this file
+ CUPS_JOG_JOB = 2, // Move pages after this job
+ CUPS_JOG_SET = 3 // Move pages after this set
} cups_jog_t;
-enum cups_mode_e /**** cupsRasterOpen modes ****/
+enum cups_raster_mode_e // cupsRasterOpen modes
{
- CUPS_RASTER_READ = 0, /* Open stream for reading */
- CUPS_RASTER_WRITE = 1, /* Open stream for writing */
- CUPS_RASTER_WRITE_COMPRESSED = 2, /* Open stream for compressed writing @since CUPS 1.3/macOS 10.5@ */
- CUPS_RASTER_WRITE_PWG = 3, /* Open stream for compressed writing in PWG Raster mode @since CUPS 1.5/macOS 10.7@ */
- CUPS_RASTER_WRITE_APPLE = 4 /* Open stream for compressed writing in AppleRaster mode (beta) @private@ */
+ CUPS_RASTER_READ = 0, // Open stream for reading
+ CUPS_RASTER_WRITE = 1, // Open stream for writing
+ CUPS_RASTER_WRITE_COMPRESSED = 2, // Open stream for compressed writing @since CUPS 1.3/macOS 10.5@
+ CUPS_RASTER_WRITE_PWG = 3, // Open stream for compressed writing in PWG Raster mode @since CUPS 1.5/macOS 10.7@
+ CUPS_RASTER_WRITE_APPLE = 4 // Open stream for compressed writing in AppleRaster mode (beta) @private@
};
-typedef enum cups_mode_e cups_mode_t; /**** cupsRasterOpen modes ****/
+typedef enum cups_raster_mode_e cups_raster_mode_t;
+ // cupsRasterOpen modes
+#define cups_mode_t cups_raster_mode_t // Old name
-typedef enum cups_order_e /**** cupsColorOrder attribute values ****/
+typedef enum cups_order_e // cupsColorOrder attribute values
{
- CUPS_ORDER_CHUNKED = 0, /* CMYK CMYK CMYK ... */
- CUPS_ORDER_BANDED = 1, /* CCC MMM YYY KKK ... */
- CUPS_ORDER_PLANAR = 2 /* CCC ... MMM ... YYY ... KKK ... */
+ CUPS_ORDER_CHUNKED = 0, // CMYK CMYK CMYK ...
+ CUPS_ORDER_BANDED = 1, // CCC MMM YYY KKK ...
+ CUPS_ORDER_PLANAR = 2 // CCC ... MMM ... YYY ... KKK ...
} cups_order_t;
-typedef enum cups_orient_e /**** Orientation attribute values ****/
+typedef enum cups_orient_e // Orientation attribute values
{
- CUPS_ORIENT_0 = 0, /* Don't rotate the page */
- CUPS_ORIENT_90 = 1, /* Rotate the page counter-clockwise */
- CUPS_ORIENT_180 = 2, /* Turn the page upside down */
- CUPS_ORIENT_270 = 3 /* Rotate the page clockwise */
+ CUPS_ORIENT_0 = 0, // Don't rotate the page
+ CUPS_ORIENT_90 = 1, // Rotate the page counter-clockwise
+ CUPS_ORIENT_180 = 2, // Turn the page upside down
+ CUPS_ORIENT_270 = 3 // Rotate the page clockwise
} cups_orient_t;
-/*
- * The page header structure contains the standard PostScript page device
- * dictionary, along with some CUPS-specific parameters that are provided
- * by the RIPs...
- *
- * The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
- * (from CUPS 1.2 and higher) page header, for binary compatibility.
- */
+//
+// The page header structure contains the standard PostScript page device
+// dictionary, along with some CUPS-specific parameters that are provided
+// by the RIPs...
+//
+// The API supports a "version 1" (from CUPS 1.0 and 1.1) and a "version 2"
+// (from CUPS 1.2 and higher) page header, for binary compatibility.
+//
-typedef struct cups_page_header_s /**** Version 1 page header @deprecated@ ****/
+typedef struct cups_page_header_s // Version 1 page header @deprecated@
{
- /**** Standard Page Device Dictionary String Values ****/
- char MediaClass[64]; /* MediaClass string */
- char MediaColor[64]; /* MediaColor string */
- char MediaType[64]; /* MediaType string */
- char OutputType[64]; /* OutputType string */
-
- /**** Standard Page Device Dictionary Integer Values ****/
- unsigned AdvanceDistance; /* AdvanceDistance value in points */
- cups_adv_t AdvanceMedia; /* AdvanceMedia value (@link cups_adv_t@) */
- cups_bool_t Collate; /* Collated copies value */
- cups_cut_t CutMedia; /* CutMedia value (@link cups_cut_t@) */
- cups_bool_t Duplex; /* Duplexed (double-sided) value */
- unsigned HWResolution[2]; /* Resolution in dots-per-inch */
- unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points, left, bottom, right, top) */
- cups_bool_t InsertSheet; /* InsertSheet value */
- cups_jog_t Jog; /* Jog value (@link cups_jog_t@) */
- cups_edge_t LeadingEdge; /* LeadingEdge value (@link cups_edge_t@) */
- unsigned Margins[2]; /* Lower-lefthand margins in points */
- cups_bool_t ManualFeed; /* ManualFeed value */
- unsigned MediaPosition; /* MediaPosition value */
- unsigned MediaWeight; /* MediaWeight value in grams/m^2 */
- cups_bool_t MirrorPrint; /* MirrorPrint value */
- cups_bool_t NegativePrint; /* NegativePrint value */
- unsigned NumCopies; /* Number of copies to produce */
- cups_orient_t Orientation; /* Orientation value (@link cups_orient_t@) */
- cups_bool_t OutputFaceUp; /* OutputFaceUp value */
- unsigned PageSize[2]; /* Width and length of page in points */
- cups_bool_t Separations; /* Separations value */
- cups_bool_t TraySwitch; /* TraySwitch value */
- cups_bool_t Tumble; /* Tumble value */
-
- /**** CUPS Page Device Dictionary Values ****/
- unsigned cupsWidth; /* Width of page image in pixels */
- unsigned cupsHeight; /* Height of page image in pixels */
- unsigned cupsMediaType; /* Media type code */
- unsigned cupsBitsPerColor; /* Number of bits for each color */
- unsigned cupsBitsPerPixel; /* Number of bits for each pixel */
- unsigned cupsBytesPerLine; /* Number of bytes per line */
- cups_order_t cupsColorOrder; /* Order of colors */
- cups_cspace_t cupsColorSpace; /* True colorspace */
- unsigned cupsCompression; /* Device compression to use */
- unsigned cupsRowCount; /* Rows per band */
- unsigned cupsRowFeed; /* Feed between bands */
- unsigned cupsRowStep; /* Spacing between lines */
+ // Standard Page Device Dictionary String Values
+ char MediaClass[64]; // MediaClass string
+ char MediaColor[64]; // MediaColor string
+ char MediaType[64]; // MediaType string
+ char OutputType[64]; // OutputType string
+
+ // Standard Page Device Dictionary Integer Values
+ unsigned AdvanceDistance; // AdvanceDistance value in points
+ cups_adv_t AdvanceMedia; // AdvanceMedia value (@link cups_adv_t@)
+ cups_bool_t Collate; // Collated copies value
+ cups_cut_t CutMedia; // CutMedia value (@link cups_cut_t@)
+ cups_bool_t Duplex; // Duplexed (double-sided) value
+ unsigned HWResolution[2]; // Resolution in dots-per-inch
+ unsigned ImagingBoundingBox[4]; // Pixel region that is painted (points, left, bottom, right, top)
+ cups_bool_t InsertSheet; // InsertSheet value
+ cups_jog_t Jog; // Jog value (@link cups_jog_t@)
+ cups_edge_t LeadingEdge; // LeadingEdge value (@link cups_edge_t@)
+ unsigned Margins[2]; // Lower-lefthand margins in points
+ cups_bool_t ManualFeed; // ManualFeed value
+ unsigned MediaPosition; // MediaPosition value
+ unsigned MediaWeight; // MediaWeight value in grams/m^2
+ cups_bool_t MirrorPrint; // MirrorPrint value
+ cups_bool_t NegativePrint; // NegativePrint value
+ unsigned NumCopies; // Number of copies to produce
+ cups_orient_t Orientation; // Orientation value (@link cups_orient_t@)
+ cups_bool_t OutputFaceUp; // OutputFaceUp value
+ unsigned PageSize[2]; // Width and length of page in points
+ cups_bool_t Separations; // Separations value
+ cups_bool_t TraySwitch; // TraySwitch value
+ cups_bool_t Tumble; // Tumble value
+
+ // CUPS Page Device Dictionary Values
+ unsigned cupsWidth; // Width of page image in pixels
+ unsigned cupsHeight; // Height of page image in pixels
+ unsigned cupsMediaType; // Media type code
+ unsigned cupsBitsPerColor; // Number of bits for each color
+ unsigned cupsBitsPerPixel; // Number of bits for each pixel
+ unsigned cupsBytesPerLine; // Number of bytes per line
+ cups_order_t cupsColorOrder; // Order of colors
+ cups_cspace_t cupsColorSpace; // True colorspace
+ unsigned cupsCompression; // Device compression to use
+ unsigned cupsRowCount; // Rows per band
+ unsigned cupsRowFeed; // Feed between bands
+ unsigned cupsRowStep; // Spacing between lines
} cups_page_header_t;
-/**** New in CUPS 1.2 ****/
-typedef struct cups_page_header2_s /**** Version 2 page header @since CUPS 1.2/macOS 10.5@ ****/
+typedef struct cups_page_header2_s // Version 2 page header @since CUPS 1.2/macOS 10.5@
{
- /**** Standard Page Device Dictionary String Values ****/
- char MediaClass[64]; /* MediaClass string */
- char MediaColor[64]; /* MediaColor string */
- char MediaType[64]; /* MediaType string */
- char OutputType[64]; /* OutputType string */
-
- /**** Standard Page Device Dictionary Integer Values ****/
- unsigned AdvanceDistance; /* AdvanceDistance value in points */
- cups_adv_t AdvanceMedia; /* AdvanceMedia value (@link cups_adv_t@) */
- cups_bool_t Collate; /* Collated copies value */
- cups_cut_t CutMedia; /* CutMedia value (@link cups_cut_t@) */
- cups_bool_t Duplex; /* Duplexed (double-sided) value */
- unsigned HWResolution[2]; /* Resolution in dots-per-inch */
- unsigned ImagingBoundingBox[4]; /* Pixel region that is painted (points, left, bottom, right, top) */
- cups_bool_t InsertSheet; /* InsertSheet value */
- cups_jog_t Jog; /* Jog value (@link cups_jog_t@) */
- cups_edge_t LeadingEdge; /* LeadingEdge value (@link cups_edge_t@) */
- unsigned Margins[2]; /* Lower-lefthand margins in points */
- cups_bool_t ManualFeed; /* ManualFeed value */
- unsigned MediaPosition; /* MediaPosition value */
- unsigned MediaWeight; /* MediaWeight value in grams/m^2 */
- cups_bool_t MirrorPrint; /* MirrorPrint value */
- cups_bool_t NegativePrint; /* NegativePrint value */
- unsigned NumCopies; /* Number of copies to produce */
- cups_orient_t Orientation; /* Orientation value (@link cups_orient_t@) */
- cups_bool_t OutputFaceUp; /* OutputFaceUp value */
- unsigned PageSize[2]; /* Width and length of page in points */
- cups_bool_t Separations; /* Separations value */
- cups_bool_t TraySwitch; /* TraySwitch value */
- cups_bool_t Tumble; /* Tumble value */
-
- /**** CUPS Page Device Dictionary Values ****/
- unsigned cupsWidth; /* Width of page image in pixels */
- unsigned cupsHeight; /* Height of page image in pixels */
- unsigned cupsMediaType; /* Media type code */
- unsigned cupsBitsPerColor; /* Number of bits for each color */
- unsigned cupsBitsPerPixel; /* Number of bits for each pixel */
- unsigned cupsBytesPerLine; /* Number of bytes per line */
- cups_order_t cupsColorOrder; /* Order of colors */
- cups_cspace_t cupsColorSpace; /* True colorspace */
- unsigned cupsCompression; /* Device compression to use */
- unsigned cupsRowCount; /* Rows per band */
- unsigned cupsRowFeed; /* Feed between bands */
- unsigned cupsRowStep; /* Spacing between lines */
-
- /**** Version 2 Dictionary Values ****/
- unsigned cupsNumColors; /* Number of color components @since CUPS 1.2/macOS 10.5@ */
+ // Standard Page Device Dictionary String Values
+ char MediaClass[64]; // MediaClass string
+ char MediaColor[64]; // MediaColor string
+ char MediaType[64]; // MediaType string
+ char OutputType[64]; // OutputType string
+
+ // Standard Page Device Dictionary Integer Values
+ unsigned AdvanceDistance; // AdvanceDistance value in points
+ cups_adv_t AdvanceMedia; // AdvanceMedia value (@link cups_adv_t@)
+ cups_bool_t Collate; // Collated copies value
+ cups_cut_t CutMedia; // CutMedia value (@link cups_cut_t@)
+ cups_bool_t Duplex; // Duplexed (double-sided) value
+ unsigned HWResolution[2]; // Resolution in dots-per-inch
+ unsigned ImagingBoundingBox[4]; // Pixel region that is painted (points, left, bottom, right, top)
+ cups_bool_t InsertSheet; // InsertSheet value
+ cups_jog_t Jog; // Jog value (@link cups_jog_t@)
+ cups_edge_t LeadingEdge; // LeadingEdge value (@link cups_edge_t@)
+ unsigned Margins[2]; // Lower-lefthand margins in points
+ cups_bool_t ManualFeed; // ManualFeed value
+ unsigned MediaPosition; // MediaPosition value
+ unsigned MediaWeight; // MediaWeight value in grams/m^2
+ cups_bool_t MirrorPrint; // MirrorPrint value
+ cups_bool_t NegativePrint; // NegativePrint value
+ unsigned NumCopies; // Number of copies to produce
+ cups_orient_t Orientation; // Orientation value (@link cups_orient_t@)
+ cups_bool_t OutputFaceUp; // OutputFaceUp value
+ unsigned PageSize[2]; // Width and length of page in points
+ cups_bool_t Separations; // Separations value
+ cups_bool_t TraySwitch; // TraySwitch value
+ cups_bool_t Tumble; // Tumble value
+
+ // CUPS Page Device Dictionary Values
+ unsigned cupsWidth; // Width of page image in pixels
+ unsigned cupsHeight; // Height of page image in pixels
+ unsigned cupsMediaType; // Media type code
+ unsigned cupsBitsPerColor; // Number of bits for each color
+ unsigned cupsBitsPerPixel; // Number of bits for each pixel
+ unsigned cupsBytesPerLine; // Number of bytes per line
+ cups_order_t cupsColorOrder; // Order of colors
+ cups_cspace_t cupsColorSpace; // True colorspace
+ unsigned cupsCompression; // Device compression to use
+ unsigned cupsRowCount; // Rows per band
+ unsigned cupsRowFeed; // Feed between bands
+ unsigned cupsRowStep; // Spacing between lines
+
+ // Version 2 Dictionary Values
+ unsigned cupsNumColors; // Number of color components @since CUPS 1.2/macOS 10.5@
float cupsBorderlessScalingFactor;
- /* Scaling that was applied to page data @since CUPS 1.2/macOS 10.5@ */
+ // Scaling that was applied to page data @since CUPS 1.2/macOS 10.5@
float cupsPageSize[2]; /* Floating point PageSize (scaling *
* factor not applied) @since CUPS 1.2/macOS 10.5@ */
float cupsImagingBBox[4]; /* Floating point ImagingBoundingBox
* (scaling factor not applied, left,
* bottom, right, top) @since CUPS 1.2/macOS 10.5@ */
- unsigned cupsInteger[16]; /* User-defined integer values @since CUPS 1.2/macOS 10.5@ */
- float cupsReal[16]; /* User-defined floating-point values @since CUPS 1.2/macOS 10.5@ */
- char cupsString[16][64]; /* User-defined string values @since CUPS 1.2/macOS 10.5@ */
- char cupsMarkerType[64]; /* Ink/toner type @since CUPS 1.2/macOS 10.5@ */
- char cupsRenderingIntent[64];/* Color rendering intent @since CUPS 1.2/macOS 10.5@ */
- char cupsPageSizeName[64]; /* PageSize name @since CUPS 1.2/macOS 10.5@ */
+ unsigned cupsInteger[16]; // User-defined integer values @since CUPS 1.2/macOS 10.5@
+ float cupsReal[16]; // User-defined floating-point values @since CUPS 1.2/macOS 10.5@
+ char cupsString[16][64]; // User-defined string values @since CUPS 1.2/macOS 10.5@
+ char cupsMarkerType[64]; // Ink/toner type @since CUPS 1.2/macOS 10.5@
+ char cupsRenderingIntent[64];// Color rendering intent @since CUPS 1.2/macOS 10.5@
+ char cupsPageSizeName[64]; // PageSize name @since CUPS 1.2/macOS 10.5@
} cups_page_header2_t;
typedef struct _cups_raster_s cups_raster_t;
- /**** Raster stream data ****/
-
-/**** New in CUPS 1.5 ****/
-typedef ssize_t (*cups_raster_iocb_t)(void *ctx, unsigned char *buffer, size_t length);
- /**** cupsRasterOpenIO callback function
- *
- * This function is specified when
- * creating a raster stream with
- * @link cupsRasterOpenIO@ and handles
- * generic reading and writing of raster
- * data. It must return -1 on error or
- * the number of bytes specified by
- * "length" on success.
- ****/
-
-
-/*
- * Prototypes...
- */
+ // Raster stream data
+
+typedef ssize_t (*cups_raster_cb_t)(void *ctx, unsigned char *buffer, size_t length);
+ // cupsRasterOpenIO callback function
+# define cups_raster_iocb_t cups_raster_cb_t
+ // Old name
+
+//
+// Functions...
+//
extern void cupsRasterClose(cups_raster_t *r) _CUPS_PUBLIC;
-extern cups_raster_t *cupsRasterOpen(int fd, cups_mode_t mode) _CUPS_PUBLIC;
+extern const char *cupsRasterErrorString(void) _CUPS_DEPRECATED_MSG("Use cupsRasterGetErrorString instead.");
+extern const char *cupsRasterGetErrorString(void) _CUPS_PUBLIC;
+extern bool cupsRasterInitHeader(cups_page_header2_t *h, cups_media_t *media, const char *optimize, ipp_quality_t quality, const char *intent, ipp_orient_t orientation, const char *sides, const char *type, int xdpi, int ydpi, const char *sheet_back) _CUPS_PUBLIC;
+extern int cupsRasterInitPWGHeader(cups_page_header2_t *h, pwg_media_t *media, const char *type, int xdpi, int ydpi, const char *sides, const char *sheet_back) _CUPS_DEPRECATED_MSG("Use cupsRasterInitHeader instead.");
+extern cups_raster_t *cupsRasterOpen(int fd, cups_raster_mode_t mode) _CUPS_PUBLIC;
+extern cups_raster_t *cupsRasterOpenIO(cups_raster_cb_t iocb, void *ctx, cups_raster_mode_t mode) _CUPS_PUBLIC;
extern unsigned cupsRasterReadHeader(cups_raster_t *r, cups_page_header_t *h) _CUPS_DEPRECATED_MSG("Use cupsRasterReadHeader2 instead.") _CUPS_PUBLIC;
+extern unsigned cupsRasterReadHeader2(cups_raster_t *r, cups_page_header2_t *h) _CUPS_PUBLIC;
extern unsigned cupsRasterReadPixels(cups_raster_t *r, unsigned char *p, unsigned len) _CUPS_PUBLIC;
extern unsigned cupsRasterWriteHeader(cups_raster_t *r, cups_page_header_t *h) _CUPS_DEPRECATED_MSG("Use cupsRasterWriteHeader2 instead.") _CUPS_PUBLIC;
+extern unsigned cupsRasterWriteHeader2(cups_raster_t *r, cups_page_header2_t *h) _CUPS_PUBLIC;
extern unsigned cupsRasterWritePixels(cups_raster_t *r, unsigned char *p, unsigned len) _CUPS_PUBLIC;
-/**** New in CUPS 1.2 ****/
-extern unsigned cupsRasterReadHeader2(cups_raster_t *r, cups_page_header2_t *h) _CUPS_API_1_2;
-extern unsigned cupsRasterWriteHeader2(cups_raster_t *r, cups_page_header2_t *h) _CUPS_API_1_2;
-
-/**** New in CUPS 1.3 ****/
-extern const char *cupsRasterErrorString(void) _CUPS_API_1_3;
-
-/**** New in CUPS 1.5 ****/
-extern cups_raster_t *cupsRasterOpenIO(cups_raster_iocb_t iocb, void *ctx, cups_mode_t mode) _CUPS_API_1_5;
-
-/**** New in CUPS 2.2/macOS 10.12 ****/
-extern int cupsRasterInitPWGHeader(cups_page_header2_t *h, pwg_media_t *media, const char *type, int xdpi, int ydpi, const char *sides, const char *sheet_back) _CUPS_API_2_2;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_RASTER_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_RASTER_H_
static void browse_cb(cups_dnssd_browse_t *browse, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *name, const char *regtype, const char *domain);
static void error_cb(void *cb_data, const char *message);
static void query_cb(cups_dnssd_query_t *query, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, uint16_t rrtype, const void *qdata, uint16_t qlen);
-static void resolve_cb(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, size_t num_txt, cups_option_t *txt);
+static void resolve_cb(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, int num_txt, cups_option_t *txt);
static void service_cb(cups_dnssd_service_t *service, void *cb_data, cups_dnssd_flags_t flags);
static void usage(const char *arg);
const char *fullname, // I - Full service name
const char *host, // I - Hostname
uint16_t port, // I - Port number
- size_t num_txt, // I - Number of key/value pairs in TXT record
+ int num_txt, // I - Number of key/value pairs in TXT record
cups_option_t *txt) // I - Key/value pairs
{
testdata_t *data = (testdata_t *)cb_data;
// Test data
- size_t i; // Looping var
+ int i; // Looping var
char message[2048], // Message string
*mptr; // Pointer into message string
const char *prefix = " txt="; // Prefix string
-/*
- * IPP test program for CUPS.
- *
- * Copyright © 2022-2023 by OpenPrinting.
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2005 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// IPP unit test program for libcups.
+//
+// Copyright © 2021-2022 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2005 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#include "file.h"
#include "string-private.h"
#include "ipp-private.h"
+#include "test-internal.h"
#ifdef _WIN32
# include <io.h>
#else
# include <unistd.h>
# include <fcntl.h>
-#endif /* _WIN32 */
+#endif // _WIN32
-/*
- * Local types...
- */
+//
+// Local types...
+//
typedef struct _ippdata_t
{
- size_t rpos, /* Read position */
- wused, /* Bytes used */
- wsize; /* Max size of buffer */
- ipp_uchar_t *wbuffer; /* Buffer */
+ size_t rpos, // Read position
+ wused, // Bytes used
+ wsize; // Max size of buffer
+ ipp_uchar_t *wbuffer; // Buffer
} _ippdata_t;
-/*
- * Local globals...
- */
+//
+// Local globals...
+//
-static ipp_uchar_t collection[] = /* Collection buffer */
+static ipp_uchar_t collection[] = // Collection buffer
{
- 0x01, 0x01, /* IPP version */
- 0x00, 0x02, /* Print-Job operation */
+ 0x01, 0x01, // IPP version
+ 0x00, 0x02, // Print-Job operation
0x00, 0x00, 0x00, 0x01,
- /* Request ID */
+ // Request ID
IPP_TAG_OPERATION,
IPP_TAG_CHARSET,
- 0x00, 0x12, /* Name length + name */
+ 0x00, 0x12, // Name length + name
'a','t','t','r','i','b','u','t','e','s','-',
'c','h','a','r','s','e','t',
- 0x00, 0x05, /* Value length + value */
+ 0x00, 0x05, // Value length + value
'u','t','f','-','8',
IPP_TAG_LANGUAGE,
- 0x00, 0x1b, /* Name length + name */
+ 0x00, 0x1b, // Name length + name
'a','t','t','r','i','b','u','t','e','s','-',
'n','a','t','u','r','a','l','-','l','a','n',
'g','u','a','g','e',
- 0x00, 0x02, /* Value length + value */
+ 0x00, 0x02, // Value length + value
'e','n',
IPP_TAG_URI,
- 0x00, 0x0b, /* Name length + name */
+ 0x00, 0x0b, // Name length + name
'p','r','i','n','t','e','r','-','u','r','i',
- 0x00, 0x1c, /* Value length + value */
+ 0x00, 0x1c, // Value length + value
'i','p','p',':','/','/','l','o','c','a','l',
'h','o','s','t','/','p','r','i','n','t','e',
'r','s','/','f','o','o',
- IPP_TAG_JOB, /* job group tag */
+ IPP_TAG_JOB, // job group tag
IPP_TAG_BEGIN_COLLECTION,
- /* begCollection tag */
- 0x00, 0x09, /* Name length + name */
+ // begCollection tag
+ 0x00, 0x09, // Name length + name
'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l',
- 0x00, 0x00, /* No value */
- IPP_TAG_MEMBERNAME, /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0a, /* Value length + value */
+ 0x00, 0x00, // No value
+ IPP_TAG_MEMBERNAME, // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0a, // Value length + value
'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
IPP_TAG_BEGIN_COLLECTION,
- /* begCollection tag */
- 0x00, 0x00, /* Name length + name */
- 0x00, 0x00, /* No value */
+ // begCollection tag
+ 0x00, 0x00, // Name length + name
+ 0x00, 0x00, // No value
IPP_TAG_MEMBERNAME,
- /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0b, /* Value length + value */
+ // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0b, // Value length + value
'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x04, /* Value length + value */
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x00, // No name
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x54, 0x56,
IPP_TAG_MEMBERNAME,
- /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0b, /* Value length + value */
+ // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0b, // Value length + value
'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x04, /* Value length + value */
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x00, // No name
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x6d, 0x24,
IPP_TAG_END_COLLECTION,
- /* endCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
- IPP_TAG_MEMBERNAME, /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0b, /* Value length + value */
+ // endCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
+ IPP_TAG_MEMBERNAME, // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0b, // Value length + value
'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 'o', 'r',
- IPP_TAG_KEYWORD, /* keyword tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x04, /* Value length + value */
+ IPP_TAG_KEYWORD, // keyword tag
+ 0x00, 0x00, // No name
+ 0x00, 0x04, // Value length + value
'b', 'l', 'u', 'e',
- IPP_TAG_MEMBERNAME, /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0a, /* Value length + value */
+ IPP_TAG_MEMBERNAME, // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0a, // Value length + value
'm', 'e', 'd', 'i', 'a', '-', 't', 'y', 'p', 'e',
- IPP_TAG_KEYWORD, /* keyword tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x05, /* Value length + value */
+ IPP_TAG_KEYWORD, // keyword tag
+ 0x00, 0x00, // No name
+ 0x00, 0x05, // Value length + value
'p', 'l', 'a', 'i', 'n',
IPP_TAG_END_COLLECTION,
- /* endCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
+ // endCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
IPP_TAG_BEGIN_COLLECTION,
- /* begCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
- IPP_TAG_MEMBERNAME, /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0a, /* Value length + value */
+ // begCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
+ IPP_TAG_MEMBERNAME, // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0a, // Value length + value
'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
IPP_TAG_BEGIN_COLLECTION,
- /* begCollection tag */
- 0x00, 0x00, /* Name length + name */
- 0x00, 0x00, /* No value */
+ // begCollection tag
+ 0x00, 0x00, // Name length + name
+ 0x00, 0x00, // No value
IPP_TAG_MEMBERNAME,
- /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0b, /* Value length + value */
+ // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0b, // Value length + value
'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x04, /* Value length + value */
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x00, // No name
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x52, 0x08,
IPP_TAG_MEMBERNAME,
- /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0b, /* Value length + value */
+ // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0b, // Value length + value
'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x04, /* Value length + value */
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x00, // No name
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x74, 0x04,
IPP_TAG_END_COLLECTION,
- /* endCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
- IPP_TAG_MEMBERNAME, /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0b, /* Value length + value */
+ // endCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
+ IPP_TAG_MEMBERNAME, // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0b, // Value length + value
'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 'o', 'r',
- IPP_TAG_KEYWORD, /* keyword tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x05, /* Value length + value */
+ IPP_TAG_KEYWORD, // keyword tag
+ 0x00, 0x00, // No name
+ 0x00, 0x05, // Value length + value
'p', 'l', 'a', 'i', 'd',
- IPP_TAG_MEMBERNAME, /* memberAttrName tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x0a, /* Value length + value */
+ IPP_TAG_MEMBERNAME, // memberAttrName tag
+ 0x00, 0x00, // No name
+ 0x00, 0x0a, // Value length + value
'm', 'e', 'd', 'i', 'a', '-', 't', 'y', 'p', 'e',
- IPP_TAG_KEYWORD, /* keyword tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x06, /* Value length + value */
+ IPP_TAG_KEYWORD, // keyword tag
+ 0x00, 0x00, // No name
+ 0x00, 0x06, // Value length + value
'g', 'l', 'o', 's', 's', 'y',
IPP_TAG_END_COLLECTION,
- /* endCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
+ // endCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
- IPP_TAG_END /* end tag */
+ IPP_TAG_END // end tag
};
-static ipp_uchar_t bad_collection[] = /* Collection buffer (bad encoding) */
+static ipp_uchar_t bad_collection[] = // Collection buffer (bad encoding)
{
- 0x01, 0x01, /* IPP version */
- 0x00, 0x02, /* Print-Job operation */
+ 0x01, 0x01, // IPP version
+ 0x00, 0x02, // Print-Job operation
0x00, 0x00, 0x00, 0x01,
- /* Request ID */
+ // Request ID
IPP_TAG_OPERATION,
IPP_TAG_CHARSET,
- 0x00, 0x12, /* Name length + name */
+ 0x00, 0x12, // Name length + name
'a','t','t','r','i','b','u','t','e','s','-',
'c','h','a','r','s','e','t',
- 0x00, 0x05, /* Value length + value */
+ 0x00, 0x05, // Value length + value
'u','t','f','-','8',
IPP_TAG_LANGUAGE,
- 0x00, 0x1b, /* Name length + name */
+ 0x00, 0x1b, // Name length + name
'a','t','t','r','i','b','u','t','e','s','-',
'n','a','t','u','r','a','l','-','l','a','n',
'g','u','a','g','e',
- 0x00, 0x02, /* Value length + value */
+ 0x00, 0x02, // Value length + value
'e','n',
IPP_TAG_URI,
- 0x00, 0x0b, /* Name length + name */
+ 0x00, 0x0b, // Name length + name
'p','r','i','n','t','e','r','-','u','r','i',
- 0x00, 0x1c, /* Value length + value */
+ 0x00, 0x1c, // Value length + value
'i','p','p',':','/','/','l','o','c','a','l',
'h','o','s','t','/','p','r','i','n','t','e',
'r','s','/','f','o','o',
- IPP_TAG_JOB, /* job group tag */
+ IPP_TAG_JOB, // job group tag
IPP_TAG_BEGIN_COLLECTION,
- /* begCollection tag */
- 0x00, 0x09, /* Name length + name */
+ // begCollection tag
+ 0x00, 0x09, // Name length + name
'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l',
- 0x00, 0x00, /* No value */
+ 0x00, 0x00, // No value
IPP_TAG_BEGIN_COLLECTION,
- /* begCollection tag */
- 0x00, 0x0a, /* Name length + name */
+ // begCollection tag
+ 0x00, 0x0a, // Name length + name
'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
- 0x00, 0x00, /* No value */
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x0b, /* Name length + name */
+ 0x00, 0x00, // No value
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x0b, // Name length + name
'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
- 0x00, 0x04, /* Value length + value */
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x54, 0x56,
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x0b, /* Name length + name */
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x0b, // Name length + name
'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
- 0x00, 0x04, /* Value length + value */
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x6d, 0x24,
IPP_TAG_END_COLLECTION,
- /* endCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
+ // endCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
IPP_TAG_END_COLLECTION,
- /* endCollection tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x00, /* No value */
+ // endCollection tag
+ 0x00, 0x00, // No name
+ 0x00, 0x00, // No value
- IPP_TAG_END /* end tag */
+ IPP_TAG_END // end tag
};
-static ipp_uchar_t mixed[] = /* Mixed value buffer */
+static ipp_uchar_t mixed[] = // Mixed value buffer
{
- 0x01, 0x01, /* IPP version */
- 0x00, 0x02, /* Print-Job operation */
+ 0x01, 0x01, // IPP version
+ 0x00, 0x02, // Print-Job operation
0x00, 0x00, 0x00, 0x01,
- /* Request ID */
+ // Request ID
IPP_TAG_OPERATION,
- IPP_TAG_INTEGER, /* integer tag */
- 0x00, 0x1f, /* Name length + name */
+ IPP_TAG_INTEGER, // integer tag
+ 0x00, 0x1f, // Name length + name
'n', 'o', 't', 'i', 'f', 'y', '-', 'l', 'e', 'a', 's', 'e',
'-', 'd', 'u', 'r', 'a', 't', 'i', 'o', 'n', '-', 's', 'u',
'p', 'p', 'o', 'r', 't', 'e', 'd',
- 0x00, 0x04, /* Value length + value */
+ 0x00, 0x04, // Value length + value
0x00, 0x00, 0x00, 0x01,
- IPP_TAG_RANGE, /* rangeOfInteger tag */
- 0x00, 0x00, /* No name */
- 0x00, 0x08, /* Value length + value */
+ IPP_TAG_RANGE, // rangeOfInteger tag
+ 0x00, 0x00, // No name
+ 0x00, 0x08, // Value length + value
0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x20,
- IPP_TAG_END /* end tag */
+ IPP_TAG_END // end tag
};
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
-void hex_dump(const char *title, ipp_uchar_t *buffer, size_t bytes);
void print_attributes(ipp_t *ipp, int indent);
ssize_t read_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes);
ssize_t read_hex(cups_file_t *fp, ipp_uchar_t *buffer, size_t bytes);
-int token_cb(_ipp_file_t *f, _ipp_vars_t *v, void *user_data, const char *token);
+bool token_cb(ipp_file_t *f, void *user_data, const char *token);
ssize_t write_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes);
-/*
- * 'main()' - Main entry.
- */
+//
+// 'main()' - Main entry.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- _ippdata_t data; /* IPP buffer */
- ipp_uchar_t buffer[8192]; /* Write buffer data */
- ipp_t *cols[2], /* Collections */
- *size; /* media-size collection */
- ipp_t *request; /* Request */
- ipp_attribute_t *media_col, /* media-col attribute */
- *media_size, /* media-size attribute */
- *attr; /* Other attribute */
- ipp_state_t state; /* State */
- size_t length; /* Length of data */
- cups_file_t *fp; /* File pointer */
- size_t i; /* Looping var */
- int status; /* Status of tests (0 = success, 1 = fail) */
+ _ippdata_t data; // IPP buffer
+ ipp_uchar_t buffer[8192]; // Write buffer data
+ ipp_t *cols[2], // Collections
+ *size; // media-size collection
+ ipp_t *request; // Request
+ ipp_attribute_t *media_col, // media-col attribute
+ *media_size, // media-size attribute
+ *attr; // Other attribute
+ ipp_state_t state; // State
+ size_t length; // Length of data
+ cups_file_t *fp; // File pointer
+ size_t i; // Looping var
+ int status; // Status of tests (0 = success, 1 = fail)
#ifdef DEBUG
- const char *name; /* Option name */
-#endif /* DEBUG */
- static const char * const test_strings[] =
- { /* Test strings */
- "one-string",
- "two-string",
- "red-string",
- "blue-string"
- };
+ const char *name; // Option name
+#endif // DEBUG
status = 0;
if (argc == 1)
{
- /*
- * Test request generation code...
- */
-
- printf("Create Sample Request: ");
+ // Test request generation code...
+ testBegin("Create Sample Request");
request = ippNew();
request->request.op.version[0] = 0x01;
ippDelete(cols[0]);
ippDelete(cols[1]);
- length = ippLength(request);
+ length = ippGetLength(request);
if (length != sizeof(collection))
{
- printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
+ testEndMessage(false, "wrong ippGetLength(), %d instead of %d bytes",
(int)length, (int)sizeof(collection));
status = 1;
}
else
- puts("PASS");
-
- /*
- * Write test #1...
- */
+ testEnd(true);
- printf("Write Sample to Memory: ");
+ // Write test #1...
+ testBegin("Write Sample to Memory");
data.wused = 0;
data.wsize = sizeof(buffer);
data.wbuffer = buffer;
- while ((state = ippWriteIO(&data, (ipp_iocb_t)write_cb, 1, NULL,
+ while ((state = ippWriteIO(&data, (ipp_io_cb_t)write_cb, 1, NULL,
request)) != IPP_STATE_DATA)
if (state == IPP_STATE_ERROR)
break;
if (state != IPP_STATE_DATA)
{
- printf("FAIL - %d bytes written.\n", (int)data.wused);
+ testEndMessage(false, "%d bytes written", (int)data.wused);
status = 1;
}
else if (data.wused != sizeof(collection))
{
- printf("FAIL - wrote %d bytes, expected %d bytes!\n", (int)data.wused,
+ testEndMessage(false, "wrote %d bytes, expected %d bytes", (int)data.wused,
(int)sizeof(collection));
- hex_dump("Bytes Written", data.wbuffer, data.wused);
- hex_dump("Baseline", collection, sizeof(collection));
+ testError("Bytes Written");
+ testHexDump(data.wbuffer, data.wused);
+ testError("Baseline");
+ testHexDump(collection, sizeof(collection));
status = 1;
}
else if (memcmp(data.wbuffer, collection, data.wused))
if (data.wbuffer[i] != collection[i])
break;
- printf("FAIL - output does not match baseline at 0x%04x!\n", (unsigned)i);
- hex_dump("Bytes Written", data.wbuffer, data.wused);
- hex_dump("Baseline", collection, sizeof(collection));
+ testEndMessage(false, "output does not match baseline at 0x%04x", (unsigned)i);
+ testError("Bytes Written");
+ testHexDump(data.wbuffer, data.wused);
+ testError("Baseline");
+ testHexDump(collection, sizeof(collection));
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
ippDelete(request);
- /*
- * Read the data back in and confirm...
- */
-
- printf("Read Sample from Memory: ");
+ // Read the data back in and confirm...
+ testBegin("Read Sample from Memory");
- request = ippNew();
+ request = ippNew();
data.rpos = 0;
- while ((state = ippReadIO(&data, (ipp_iocb_t)read_cb, 1, NULL,
+ while ((state = ippReadIO(&data, (ipp_io_cb_t)read_cb, 1, NULL,
request)) != IPP_STATE_DATA)
+ {
if (state == IPP_STATE_ERROR)
break;
+ }
- length = ippLength(request);
+ length = ippGetLength(request);
if (state != IPP_STATE_DATA)
{
- printf("FAIL - %d bytes read.\n", (int)data.rpos);
+ testEndMessage(false, "%d bytes read", (int)data.rpos);
status = 1;
}
else if (data.rpos != data.wused)
{
- printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data.rpos,
+ testEndMessage(false, "read %d bytes, expected %d bytes", (int)data.rpos,
(int)data.wused);
print_attributes(request, 8);
status = 1;
}
else if (length != sizeof(collection))
{
- printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
+ testEndMessage(false, "wrong ippLength(), %d instead of %d bytes",
(int)length, (int)sizeof(collection));
print_attributes(request, 8);
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
- fputs("ippFindAttribute(media-col): ", stdout);
+ testBegin("ippFindAttribute(media-col)");
if ((media_col = ippFindAttribute(request, "media-col",
IPP_TAG_BEGIN_COLLECTION)) == NULL)
{
if ((media_col = ippFindAttribute(request, "media-col",
IPP_TAG_ZERO)) == NULL)
- puts("FAIL (not found)");
+ testEndMessage(false, "not found");
else
- printf("FAIL (wrong type - %s)\n", ippTagString(media_col->value_tag));
+ testEndMessage(false, "wrong type - %s", ippTagString(media_col->value_tag));
status = 1;
}
else if (media_col->num_values != 2)
{
- printf("FAIL (wrong count - %d)\n", media_col->num_values);
+ testEndMessage(false, "wrong count - %d", media_col->num_values);
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
if (media_col)
{
- fputs("ippFindAttribute(media-size 1): ", stdout);
+ testBegin("ippFindAttribute(media-size 1)");
if ((media_size = ippFindAttribute(media_col->values[0].collection,
"media-size",
IPP_TAG_BEGIN_COLLECTION)) == NULL)
if ((media_size = ippFindAttribute(media_col->values[0].collection,
"media-col",
IPP_TAG_ZERO)) == NULL)
- puts("FAIL (not found)");
+ testEndMessage(false, "not found");
else
- printf("FAIL (wrong type - %s)\n",
+ testEndMessage(false, "wrong type - %s",
ippTagString(media_size->value_tag));
status = 1;
{
if ((attr = ippFindAttribute(media_size->values[0].collection,
"x-dimension", IPP_TAG_ZERO)) == NULL)
- puts("FAIL (missing x-dimension)");
+ testEndMessage(false, "missing x-dimension");
else
- printf("FAIL (wrong type for x-dimension - %s)\n",
+ testEndMessage(false, "wrong type for x-dimension - %s",
ippTagString(attr->value_tag));
status = 1;
}
else if (attr->values[0].integer != 21590)
{
- printf("FAIL (wrong value for x-dimension - %d)\n",
+ testEndMessage(false, "wrong value for x-dimension - %d",
attr->values[0].integer);
status = 1;
}
{
if ((attr = ippFindAttribute(media_size->values[0].collection,
"y-dimension", IPP_TAG_ZERO)) == NULL)
- puts("FAIL (missing y-dimension)");
+ testEndMessage(false, "missing y-dimension");
else
- printf("FAIL (wrong type for y-dimension - %s)\n",
+ testEndMessage(false, "wrong type for y-dimension - %s",
ippTagString(attr->value_tag));
status = 1;
}
else if (attr->values[0].integer != 27940)
{
- printf("FAIL (wrong value for y-dimension - %d)\n",
+ testEndMessage(false, "wrong value for y-dimension - %d",
attr->values[0].integer);
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
}
- fputs("ippFindAttribute(media-size 2): ", stdout);
+ testBegin("ippFindAttribute(media-size 2)");
if ((media_size = ippFindAttribute(media_col->values[1].collection,
"media-size",
IPP_TAG_BEGIN_COLLECTION)) == NULL)
if ((media_size = ippFindAttribute(media_col->values[1].collection,
"media-col",
IPP_TAG_ZERO)) == NULL)
- puts("FAIL (not found)");
+ testEndMessage(false, "not found");
else
- printf("FAIL (wrong type - %s)\n",
+ testEndMessage(false, "wrong type - %s",
ippTagString(media_size->value_tag));
status = 1;
{
if ((attr = ippFindAttribute(media_size->values[0].collection,
"x-dimension", IPP_TAG_ZERO)) == NULL)
- puts("FAIL (missing x-dimension)");
+ testEndMessage(false, "missing x-dimension");
else
- printf("FAIL (wrong type for x-dimension - %s)\n",
+ testEndMessage(false, "wrong type for x-dimension - %s",
ippTagString(attr->value_tag));
status = 1;
}
else if (attr->values[0].integer != 21000)
{
- printf("FAIL (wrong value for x-dimension - %d)\n",
+ testEndMessage(false, "wrong value for x-dimension - %d",
attr->values[0].integer);
status = 1;
}
{
if ((attr = ippFindAttribute(media_size->values[0].collection,
"y-dimension", IPP_TAG_ZERO)) == NULL)
- puts("FAIL (missing y-dimension)");
+ testEndMessage(false, "missing y-dimension");
else
- printf("FAIL (wrong type for y-dimension - %s)\n",
+ testEndMessage(false, "wrong type for y-dimension - %s",
ippTagString(attr->value_tag));
status = 1;
}
else if (attr->values[0].integer != 29700)
{
- printf("FAIL (wrong value for y-dimension - %d)\n",
+ testEndMessage(false, "wrong value for y-dimension - %d",
attr->values[0].integer);
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
}
}
- /*
- * Test hierarchical find...
- */
-
- fputs("ippFindAttribute(media-col/media-size/x-dimension): ", stdout);
+ // Test hierarchical find...
+ testBegin("ippFindAttribute(media-col/media-size/x-dimension)");
if ((attr = ippFindAttribute(request, "media-col/media-size/x-dimension", IPP_TAG_INTEGER)) != NULL)
{
if (ippGetInteger(attr, 0) != 21590)
{
- printf("FAIL (wrong value for x-dimension - %d)\n", ippGetInteger(attr, 0));
+ testEndMessage(false, "wrong value for x-dimension - %d", ippGetInteger(attr, 0));
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
}
else
{
- puts("FAIL (not found)");
+ testEndMessage(false, "not found");
status = 1;
}
- fputs("ippFindNextAttribute(media-col/media-size/x-dimension): ", stdout);
+ testBegin("ippFindNextAttribute(media-col/media-size/x-dimension)");
if ((attr = ippFindNextAttribute(request, "media-col/media-size/x-dimension", IPP_TAG_INTEGER)) != NULL)
{
if (ippGetInteger(attr, 0) != 21000)
{
- printf("FAIL (wrong value for x-dimension - %d)\n", ippGetInteger(attr, 0));
+ testEndMessage(false, "wrong value for x-dimension - %d", ippGetInteger(attr, 0));
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
}
else
{
- puts("FAIL (not found)");
+ testEndMessage(false, "not found");
status = 1;
}
- fputs("ippFindNextAttribute(media-col/media-size/x-dimension) again: ", stdout);
+ testBegin("ippFindNextAttribute(media-col/media-size/x-dimension) again");
if ((attr = ippFindNextAttribute(request, "media-col/media-size/x-dimension", IPP_TAG_INTEGER)) != NULL)
{
- printf("FAIL (got %d, expected nothing)\n", ippGetInteger(attr, 0));
+ testEndMessage(false, "got %d, expected nothing", ippGetInteger(attr, 0));
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
ippDelete(request);
- /*
- * Read the bad collection data and confirm we get an error...
- */
-
- fputs("Read Bad Collection from Memory: ", stdout);
+ // Read the bad collection data and confirm we get an error...
+ testBegin("Read Bad Collection from Memory");
request = ippNew();
data.rpos = 0;
data.wsize = sizeof(bad_collection);
data.wbuffer = bad_collection;
- while ((state = ippReadIO(&data, (ipp_iocb_t)read_cb, 1, NULL, request)) != IPP_STATE_DATA)
+ while ((state = ippReadIO(&data, (ipp_io_cb_t)read_cb, 1, NULL, request)) != IPP_STATE_DATA)
if (state == IPP_STATE_ERROR)
break;
+ ippDelete(request);
+
if (state != IPP_STATE_ERROR)
- puts("FAIL (read successful)");
+ testEndMessage(false, "read successful");
else
- puts("PASS");
+ testEnd(true);
- /*
- * Read the mixed data and confirm we converted everything to rangeOfInteger
- * values...
- */
-
- fputs("Read Mixed integer/rangeOfInteger from Memory: ", stdout);
+ // Read the mixed data and confirm we converted everything to rangeOfInteger
+ // values...
+ testBegin("Read Mixed integer/rangeOfInteger from Memory");
request = ippNew();
data.rpos = 0;
data.wsize = sizeof(mixed);
data.wbuffer = mixed;
- while ((state = ippReadIO(&data, (ipp_iocb_t)read_cb, 1, NULL,
+ while ((state = ippReadIO(&data, (ipp_io_cb_t)read_cb, 1, NULL,
request)) != IPP_STATE_DATA)
if (state == IPP_STATE_ERROR)
break;
- length = ippLength(request);
+ length = ippGetLength(request);
if (state != IPP_STATE_DATA)
{
- printf("FAIL - %d bytes read.\n", (int)data.rpos);
+ testEndMessage(false, "%d bytes read", (int)data.rpos);
status = 1;
}
else if (data.rpos != sizeof(mixed))
{
- printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data.rpos,
+ testEndMessage(false, "read %d bytes, expected %d bytes", (int)data.rpos,
(int)sizeof(mixed));
print_attributes(request, 8);
status = 1;
}
else if (length != (sizeof(mixed) + 4))
{
- printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
+ testEndMessage(false, "wrong ippLength(), %d instead of %d bytes",
(int)length, (int)sizeof(mixed) + 4);
print_attributes(request, 8);
status = 1;
}
else
- puts("PASS");
+ testEnd(true);
- fputs("ippFindAttribute(notify-lease-duration-supported): ", stdout);
+ testBegin("ippFindAttribute(notify-lease-duration-supported)");
if ((attr = ippFindAttribute(request, "notify-lease-duration-supported",
IPP_TAG_ZERO)) == NULL)
{
- puts("FAIL (not found)");
+ testEndMessage(false, "not found");
status = 1;
}
else if (attr->value_tag != IPP_TAG_RANGE)
{
- printf("FAIL (wrong type - %s)\n", ippTagString(attr->value_tag));
+ testEndMessage(false, "wrong type - %s", ippTagString(attr->value_tag));
status = 1;
}
else if (attr->num_values != 2)
{
- printf("FAIL (wrong count - %d)\n", attr->num_values);
+ testEndMessage(false, "wrong count - %d", attr->num_values);
status = 1;
}
else if (attr->values[0].range.lower != 1 ||
attr->values[1].range.lower != 16 ||
attr->values[1].range.upper != 32)
{
- printf("FAIL (wrong values - %d,%d and %d,%d)\n",
+ testEndMessage(false, "wrong values - %d,%d and %d,%d",
attr->values[0].range.lower,
attr->values[0].range.upper,
attr->values[1].range.lower,
status = 1;
}
else
- puts("PASS");
-
- fputs("ippDeleteValues: ", stdout);
- attr = ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "test-strings", 4, NULL, test_strings);
- if (ippGetCount(attr) != 4)
- {
- printf("FAIL (got %d values, expected 4 values)\n", ippGetCount(attr));
- status = 1;
- }
- else if (!ippDeleteValues(request, &attr, 3, 1))
- {
- puts("FAIL (returned 0)");
- status = 1;
- }
- else if (ippGetCount(attr) != 3)
- {
- printf("FAIL (got %d values, expected 3 values)\n", ippGetCount(attr));
- status = 1;
- }
- else
- {
- puts("PASS");
- }
+ testEnd(true);
ippDelete(request);
#ifdef DEBUG
- /*
- * Test that private option array is sorted...
- */
-
- fputs("_ippCheckOptions: ", stdout);
+ // Test that private option array is sorted...
+ testBegin("_ippCheckOptions");
if ((name = _ippCheckOptions()) == NULL)
- puts("PASS");
+ {
+ testEnd(true);
+ }
else
{
- printf("FAIL (\"%s\" out of order)\n", name);
+ testEndMessage(false, "\"%s\" out of order", name);
status = 1;
}
-#endif /* DEBUG */
-
- /*
- * Test _ippFindOption() private API...
- */
+#endif // DEBUG
- fputs("_ippFindOption(\"printer-type\"): ", stdout);
+ // Test _ippFindOption() private API...
+ testBegin("_ippFindOption(\"printer-type\")");
if (_ippFindOption("printer-type"))
- puts("PASS");
+ testEnd(true);
else
{
- puts("FAIL");
+ testEnd(false);
status = 1;
}
-
- /*
- * Summarize...
- */
-
- putchar('\n');
-
- if (status)
- puts("Core IPP tests failed.");
- else
- puts("Core IPP tests passed.");
}
else
{
- /*
- * Read IPP files...
- */
-
+ // Read IPP files...
for (i = 1; i < (size_t)argc; i ++)
{
if (strlen(argv[i]) > 5 && !strcmp(argv[i] + strlen(argv[i]) - 5, ".test"))
{
- /*
- * Read an ASCII IPP message...
- */
+ // Read an ASCII IPP message...
+ ipp_file_t *file; // IPP data file
- _ipp_vars_t v; /* IPP variables */
+ file = ippFileNew(NULL, NULL, NULL, NULL);
+ request = ippNew();
- _ippVarsInit(&v, NULL, NULL, token_cb);
- request = _ippFileParse(&v, argv[i], NULL);
- _ippVarsDeinit(&v);
+ ippFileOpen(file, argv[i], "r");
+ ippFileRead(file, token_cb, true);
+ ippFileDelete(file);
}
else if (strlen(argv[i]) > 4 && !strcmp(argv[i] + strlen(argv[i]) - 4, ".hex"))
{
- /*
- * Read a hex-encoded IPP message...
- */
-
+ // Read a hex-encoded IPP message...
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
printf("Unable to open \"%s\" - %s\n", argv[i], strerror(errno));
}
request = ippNew();
- while ((state = ippReadIO(fp, (ipp_iocb_t)read_hex, 1, NULL, request)) == IPP_STATE_ATTRIBUTE);
+ while ((state = ippReadIO(fp, (ipp_io_cb_t)read_hex, 1, NULL, request)) == IPP_STATE_ATTRIBUTE);
if (state != IPP_STATE_DATA)
{
}
else
{
- /*
- * Read a raw (binary) IPP message...
- */
-
+ // Read a raw (binary) IPP message...
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
printf("Unable to open \"%s\" - %s\n", argv[i], strerror(errno));
}
request = ippNew();
- while ((state = ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL,
+ while ((state = ippReadIO(fp, (ipp_io_cb_t)cupsFileRead, 1, NULL,
request)) == IPP_STATE_ATTRIBUTE);
if (state != IPP_STATE_DATA)
}
-/*
- * 'hex_dump()' - Produce a hex dump of a buffer.
- */
-
-void
-hex_dump(const char *title, /* I - Title */
- ipp_uchar_t *buffer, /* I - Buffer to dump */
- size_t bytes) /* I - Number of bytes */
-{
- size_t i, j; /* Looping vars */
- int ch; /* Current ASCII char */
-
-
- /*
- * Show lines of 16 bytes at a time...
- */
-
- printf(" %s:\n", title);
-
- for (i = 0; i < bytes; i += 16)
- {
- /*
- * Show the offset...
- */
-
- printf(" %04x ", (unsigned)i);
-
- /*
- * Then up to 16 bytes in hex...
- */
-
- for (j = 0; j < 16; j ++)
- if ((i + j) < bytes)
- printf(" %02x", buffer[i + j]);
- else
- printf(" ");
-
- /*
- * Then the ASCII representation of the bytes...
- */
-
- putchar(' ');
- putchar(' ');
-
- for (j = 0; j < 16 && (i + j) < bytes; j ++)
- {
- ch = buffer[i + j] & 127;
-
- if (ch < ' ' || ch == 127)
- putchar('.');
- else
- putchar(ch);
- }
-
- putchar('\n');
- }
-}
-
-
-/*
- * 'print_attributes()' - Print the attributes in a request...
- */
+//
+// 'print_attributes()' - Print the attributes in a request...
+//
void
-print_attributes(ipp_t *ipp, /* I - IPP request */
- int indent) /* I - Indentation */
+print_attributes(ipp_t *ipp, // I - IPP request
+ int indent) // I - Indentation
{
- ipp_tag_t group; /* Current group */
- ipp_attribute_t *attr; /* Current attribute */
- char buffer[2048]; /* Value string */
+ ipp_tag_t group; // Current group
+ ipp_attribute_t *attr; // Current attribute
+ char buffer[2048]; // Value string
for (group = IPP_TAG_ZERO, attr = ipp->attrs; attr; attr = attr->next)
{
group = attr->group_tag;
- printf("\n%*s%s:\n\n", indent - 4, "", ippTagString(group));
+ testError("\n%*s%s:\n", indent - 4, "", ippTagString(group));
}
ippAttributeString(attr, buffer, sizeof(buffer));
- printf("%*s%s (%s%s): %s\n", indent, "", attr->name ? attr->name : "(null)", attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), buffer);
+ testError("%*s%s (%s%s): %s\n", indent, "", attr->name ? attr->name : "(null)", attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), buffer);
}
}
-/*
- * 'read_cb()' - Read data from a buffer.
- */
+//
+// 'read_cb()' - Read data from a buffer.
+//
-ssize_t /* O - Number of bytes read */
-read_cb(_ippdata_t *data, /* I - Data */
- ipp_uchar_t *buffer, /* O - Buffer to read */
- size_t bytes) /* I - Number of bytes to read */
+ssize_t // O - Number of bytes read
+read_cb(_ippdata_t *data, // I - Data
+ ipp_uchar_t *buffer, // O - Buffer to read
+ size_t bytes) // I - Number of bytes to read
{
- size_t count; /* Number of bytes */
-
+ size_t count; // Number of bytes
- /*
- * Copy bytes from the data buffer to the read buffer...
- */
+ // Copy bytes from the data buffer to the read buffer...
if ((count = data->wsize - data->rpos) > bytes)
count = bytes;
memcpy(buffer, data->wbuffer + data->rpos, count);
data->rpos += count;
- /*
- * Return the number of bytes read...
- */
-
+ // Return the number of bytes read...
return ((ssize_t)count);
}
-/*
- * 'read_hex()' - Read a hex dump of an IPP request.
- */
+//
+// 'read_hex()' - Read a hex dump of an IPP request.
+//
-ssize_t /* O - Number of bytes read */
-read_hex(cups_file_t *fp, /* I - File to read from */
- ipp_uchar_t *buffer, /* I - Buffer to read */
- size_t bytes) /* I - Number of bytes to read */
+ssize_t // O - Number of bytes read
+read_hex(cups_file_t *fp, // I - File to read from
+ ipp_uchar_t *buffer, // I - Buffer to read
+ size_t bytes) // I - Number of bytes to read
{
- size_t total = 0; /* Total bytes read */
- static char hex[256] = ""; /* Line from file */
- static char *hexptr = NULL; /* Pointer in line */
+ size_t total = 0; // Total bytes read
+ static char hex[256] = ""; // Line from file
+ static char *hexptr = NULL; // Pointer in line
while (total < bytes)
}
-/*
- * 'token_cb()' - Token callback for ASCII IPP data file parser.
- */
+//
+// 'token_cb()' - Token callback for ASCII IPP data file parser.
+//
-int /* O - 1 on success, 0 on failure */
-token_cb(_ipp_file_t *f, /* I - IPP file data */
- _ipp_vars_t *v, /* I - IPP variables */
- void *user_data, /* I - User data pointer */
- const char *token) /* I - Token string */
+bool // O - `true` on success, `false` on failure
+token_cb(ipp_file_t *f, // I - IPP file data
+ void *user_data, // I - User data pointer
+ const char *token) // I - Token string
{
- (void)v;
(void)user_data;
- if (!token)
- {
- f->attrs = ippNew();
- f->group_tag = IPP_TAG_PRINTER;
- }
- else
+ // TODO: Add a custom directive to test this.
+ if (strcasecmp(token, "TEST"))
{
- fprintf(stderr, "Unknown directive \"%s\" on line %d of \"%s\".\n", token, f->linenum, f->filename);
- return (0);
+ fprintf(stderr, "Unknown directive '%s' on line %d of '%s'.\n", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- return (1);
+ return (true);
}
-/*
- * 'write_cb()' - Write data into a buffer.
- */
+//
+// 'write_cb()' - Write data into a buffer.
+//
-ssize_t /* O - Number of bytes written */
-write_cb(_ippdata_t *data, /* I - Data */
- ipp_uchar_t *buffer, /* I - Buffer to write */
- size_t bytes) /* I - Number of bytes to write */
+ssize_t // O - Number of bytes written
+write_cb(_ippdata_t *data, // I - Data
+ ipp_uchar_t *buffer, // I - Buffer to write
+ size_t bytes) // I - Number of bytes to write
{
- size_t count; /* Number of bytes */
+ size_t count; // Number of bytes
- /*
- * Loop until all bytes are written...
- */
-
+ // Loop until all bytes are written...
if ((count = data->wsize - data->wused) > bytes)
count = bytes;
memcpy(data->wbuffer + data->wused, buffer, count);
data->wused += count;
- /*
- * Return the number of bytes written...
- */
-
+ // Return the number of bytes written...
return ((ssize_t)count);
}
--- /dev/null
+//
+// Raster test page generator unit test for CUPS.
+//
+// Copyright © 2020-2023 by OpenPrinting
+// Copyright © 2017-2019 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+#include "raster-testpage.h"
+#include "test-internal.h"
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+//
+// Local functions...
+//
+
+static void usage(void);
+
+
+//
+// 'main()' - Generate a test raster file.
+//
+
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
+{
+ int i; // Looping var
+ int ret = 0; // Exit status
+ const char *opt; // Current option
+ const char *filename = NULL,
+ // Output filename
+ *media_name = "na_letter_8.5x11in",
+ // Media size name
+ *sheet_back = "normal",
+ // Back side transform
+ *sides = "one-sided",
+ // Duplex mode
+ *type = "srgb_8";
+ // Output type
+ int xres = 300, // Horizontal resolution
+ yres = 300, // Vertical resolution
+ num_copies = 1, // Number of copies
+ num_pages = 2; // Number of pages
+ ipp_orient_t orientation = IPP_ORIENT_PORTRAIT;
+ // Output orientation
+ int fd; // File descriptor
+ cups_raster_t *ras; // Raster stream
+ cups_page_header2_t header; // Page header (front side)
+ cups_page_header2_t back_header; // Page header (back side)
+ pwg_media_t *pwg; // Media size
+ cups_media_t media; // Media information
+ static const char * const sheet_backs[4] =
+ { // Back side values
+ "normal",
+ "flipped",
+ "manual-tumble",
+ "rotated"
+ };
+
+
+ // Parse command-line options...
+ if (argc > 1)
+ {
+ for (i = 1; i < argc; i ++)
+ {
+ if (!strcmp(argv[i], "--help"))
+ {
+ usage();
+ return (0);
+ }
+ else if (!strncmp(argv[i], "--", 2))
+ {
+ fprintf(stderr, "testtestpage: Unknown option '%s'.\n", argv[i]);
+ usage();
+ return (1);
+ }
+ else if (argv[i][0] == '-')
+ {
+ for (opt = argv[i] + 1; *opt; opt ++)
+ {
+ switch (*opt)
+ {
+ case 'b' : // -b SHEET-BACK
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testtestpage: Expected sheet-back after '-b'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ if (strcmp(argv[i], "normal") && strcmp(argv[i], "flip") && strcmp(argv[i], "rotate") && strcmp(argv[i], "manual-tumble"))
+ {
+ fprintf(stderr, "testtestpage: Unexpected sheet-back '-b %s'.\n", argv[i]);
+ usage();
+ return (1);
+ }
+
+ sheet_back = argv[i];
+ break;
+
+ case 'c' : // -c NUM-COPIES
+ i ++;
+ if (i >= argc || !isdigit(argv[i][0] & 255))
+ {
+ fputs("testtestpage: Expected number of copies after '-c'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ num_copies = atoi(argv[i]);
+ break;
+
+ case 'm' : // -m MEDIA-NAME
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testtestpage: Expected media size name after '-m'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ media_name = argv[i];
+ break;
+
+ case 'n' : // -n NUM-PAGES
+ i ++;
+ if (i >= argc || !isdigit(argv[i][0] & 255))
+ {
+ fputs("testtestpage: Expected number of pages after '-p'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ num_pages = atoi(argv[i]);
+ break;
+
+ case 'o' : // -o ORIENTATION
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testtestpage: Expected orientation after '-o'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ if (!strcmp(argv[i], "portrait"))
+ orientation = IPP_ORIENT_PORTRAIT;
+ else if (!strcmp(argv[i], "landscape"))
+ orientation = IPP_ORIENT_LANDSCAPE;
+ else if (!strcmp(argv[i], "reverse-portrait"))
+ orientation = IPP_ORIENT_REVERSE_PORTRAIT;
+ else if (!strcmp(argv[i], "reverse-landscape"))
+ orientation = IPP_ORIENT_REVERSE_LANDSCAPE;
+ else
+ {
+ fprintf(stderr, "testtestpage: Unexpected orientation '-o %s'.\n", argv[i]);
+ usage();
+ return (1);
+ }
+ break;
+
+ case 'r' : // -r RES or -r XRESxYRES
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testtestpage: Expected resolution after '-r'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ switch (sscanf(argv[i], "%dx%d", &xres, &yres))
+ {
+ case 0 :
+ fprintf(stderr, "testtestpage: Unexpected resolution '-r %s'.\n", argv[i]);
+ usage();
+ return (1);
+ case 1 :
+ yres = xres;
+ break;
+ }
+ break;
+
+ case 's' : // -s SIDES
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testtestpage: Expected sides after '-s'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ if (strcmp(argv[i], "one-sided") && strcmp(argv[i], "two-sided-long-edge") && strcmp(argv[i], "two-sided-short-edge"))
+ {
+ fprintf(stderr, "testtestpage: Unexpected sides '-s %s'.\n", argv[i]);
+ usage();
+ return (1);
+ }
+
+ sides = argv[i];
+ break;
+
+ case 't' : // -t TYPE
+ i ++;
+ if (i >= argc)
+ {
+ fputs("testtestpage: Expected type after '-t'.\n", stderr);
+ usage();
+ return (1);
+ }
+
+ if (!strcmp(argv[i], "color"))
+ type = "srgb_8";
+ else if (!strcmp(argv[i], "gray"))
+ type = "sgray_8";
+ else if (strcmp(argv[i], "black_1") && strcmp(argv[i], "black_8") && strcmp(argv[i], "black_16") && strcmp(argv[i], "cmyk_8") && strcmp(argv[i], "cmyk_16") && strcmp(argv[i], "sgray_8") && strcmp(argv[i], "sgray_16") && strcmp(argv[i], "srgb_8") && strcmp(argv[i], "srgb_16"))
+ {
+ fprintf(stderr, "testtestpage: Unexpected sheet-back '-b %s'.\n", argv[i]);
+ usage();
+ return (1);
+ }
+ else
+ type = argv[i];
+ break;
+
+ default :
+ fprintf(stderr, "testtestpage: Unknown option '-%c'.\n", *opt);
+ usage();
+ return (1);
+ }
+ }
+ }
+ else if (!filename)
+ {
+ filename = argv[i];
+ }
+ else
+ {
+ fprintf(stderr, "testtestpage: Unknown option '%s'.\n", argv[i]);
+ usage();
+ return (1);
+ }
+
+ if ((pwg = pwgMediaForPWG(media_name)) == NULL)
+ {
+ fprintf(stderr, "testtestpage: Unable to lookup media '%s'.\n", media_name);
+ return (1);
+ }
+
+ if (filename)
+ {
+ if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
+ {
+ fprintf(stderr, "testtestpage: Unable to create '%s': %s\n", filename, strerror(errno));
+ return (1);
+ }
+ }
+ else
+ fd = 1;
+
+ if ((ras = cupsRasterOpen(fd, CUPS_RASTER_WRITE_PWG)) == NULL)
+ {
+ fprintf(stderr, "testtestpage: Unable to open raster stream for '%s': %s\n", filename ? filename : "(stdout)", cupsGetErrorString());
+ close(fd);
+ return (1);
+ }
+
+ memset(&media, 0, sizeof(media));
+ cupsCopyString(media.media, pwg->pwg, sizeof(media.media));
+ media.width = pwg->width;
+ media.length = pwg->length;
+
+ cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, orientation, sides, type, xres, yres, NULL);
+ cupsRasterInitHeader(&back_header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, orientation, sides, type, xres, yres, sheet_back);
+ cupsRasterWriteTest(ras, &header, &back_header, sheet_back, orientation, num_copies, num_pages);
+ cupsRasterClose(ras);
+ }
+ }
+ else
+ {
+ // Do unit tests...
+ testBegin("open(test.pwg)");
+ if ((fd = open("test.pwg", O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
+ {
+ testEndMessage(false, "%s", strerror(errno));
+ return (1);
+ }
+ testEnd(true);
+
+ testBegin("cupsRasterOpen");
+ if ((ras = cupsRasterOpen(fd, CUPS_RASTER_WRITE_PWG)) == NULL)
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ close(fd);
+ return (1);
+ }
+ testEnd(true);
+
+ pwg = pwgMediaForPWG("na_letter_8.5x11in");
+
+ memset(&media, 0, sizeof(media));
+ cupsCopyString(media.media, pwg->pwg, sizeof(media.media));
+ media.width = pwg->width;
+ media.length = pwg->length;
+
+ for (orientation = IPP_ORIENT_PORTRAIT; orientation <= IPP_ORIENT_REVERSE_PORTRAIT; orientation ++)
+ {
+ testBegin("cupsRasterInitHeader(black_1)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "black_1", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ if (orientation == IPP_ORIENT_PORTRAIT)
+ {
+ testBegin("cupsRasterWriteTest(2,3)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 2, 3))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+ }
+ else
+ {
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+ }
+
+ testBegin("cupsRasterInitHeader(black_8)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "black_8", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(black_16)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "black_16", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(srgb_8)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "srgb_8", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(srgb_16)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "srgb_16", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(sgray_1)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "sgray_1", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(sgray_8)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "sgray_8", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(cmyk_8)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "cmyk_8", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(cmyk_16)");
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, IPP_ORIENT_PORTRAIT, "one-sided", "cmyk_16", 300, 300, "normal"))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,1)");
+ if (cupsRasterWriteTest(ras, &header, &header, "normal", orientation, 1, 1))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+ }
+
+ for (i = 0; i < 4; i ++)
+ {
+ for (orientation = IPP_ORIENT_PORTRAIT; orientation <= IPP_ORIENT_REVERSE_PORTRAIT; orientation ++)
+ {
+ testBegin("cupsRasterInitHeader(black_1, %d, %s)", (int)orientation, sheet_backs[i]);
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, orientation, "two-sided-long-edge", "black_1", 300, 300, sheet_backs[i]))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,2)");
+ if (cupsRasterWriteTest(ras, &header, &back_header, sheet_backs[i], orientation, 1, 2))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(black_8, %d, %s)", (int)orientation, sheet_backs[i]);
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, orientation, "two-sided-long-edge", "black_8", 300, 300, sheet_backs[i]))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,2)");
+ if (cupsRasterWriteTest(ras, &header, &back_header, sheet_backs[i], orientation, 1, 2))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(srgb_8, %d, %s)", (int)orientation, sheet_backs[i]);
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, orientation, "two-sided-long-edge", "srgb_8", 300, 300, sheet_backs[i]))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,2)");
+ if (cupsRasterWriteTest(ras, &header, &back_header, sheet_backs[i], orientation, 1, 2))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterInitHeader(cmyk_8, %d, %s)", (int)orientation, sheet_backs[i]);
+ if (cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, orientation, "two-sided-long-edge", "cmyk_8", 300, 300, sheet_backs[i]))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+
+ testBegin("cupsRasterWriteTest(1,2)");
+ if (cupsRasterWriteTest(ras, &header, &back_header, sheet_backs[i], orientation, 1, 2))
+ {
+ testEnd(true);
+ }
+ else
+ {
+ testEndMessage(false, "%s", cupsRasterErrorString());
+ ret = 1;
+ }
+ }
+ }
+ cupsRasterClose(ras);
+ }
+
+ return (ret);
+}
+
+
+//
+// 'usage()' - Show program usage.
+//
+
+static void
+usage(void)
+{
+ puts("Usage: ./testtestpage [OPTIONS] [FILENAME]");
+ puts("Options:");
+ puts("-b SHEET-BACK Specify the back side transform for duplex output (normal, flip, manual-tumble, or rotate)");
+ puts("-c NUM-COPIES Specify the number of copies (default 1)");
+ puts("-m MEDIA-SIZE-NAME Specify the PWG media size name (default 'na_letter_8.5x11in')");
+ puts("-n NUM-PAGES Specify the number of pages (default 2)");
+ puts("-o ORIENTATION Specify the orientation (portrait, landscape, reverse-landscape, reverse-portrait)");
+ puts("-r RESOLUTION Specify the output resolution (NNN or NNNxNNN)");
+ puts("-t TYPE Specify the output color space and bit depth");
+}
cups_credusage_t usage_bit; // Current usage
- DEBUG_printf("cupsCreateCredentials(path=\"%s\", ca_cert=%s, purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p, root_name=\"%s\", expiration_date=%ld)", path, ca_cert ? "true" : "false", purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, alt_names, root_name, (long)expiration_date);
+ DEBUG_printf("cupsCreateCredentials(path=\"%s\", ca_cert=%s, purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p, root_name=\"%s\", expiration_date=%ld)", path, ca_cert ? "true" : "false", purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, (void *)alt_names, root_name, (long)expiration_date);
// Filenames...
if (!path)
cups_credusage_t usage_bit; // Current usage
- DEBUG_printf("cupsCreateCredentialsRequest(path=\"%s\", purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p)", path, purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, alt_names);
+ DEBUG_printf("cupsCreateCredentialsRequest(path=\"%s\", purpose=0x%x, type=%d, usage=0x%x, organization=\"%s\", org_unit=\"%s\", locality=\"%s\", state_province=\"%s\", country=\"%s\", common_name=\"%s\", num_alt_names=%u, alt_names=%p)", path, purpose, type, usage, organization, org_unit, locality, state_province, country, common_name, (unsigned)num_alt_names, (void *)alt_names);
// Filenames...
if (!path)
// Range check input...
- DEBUG_printf("cupsGetCredentialsInfo(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize);
+ DEBUG_printf("cupsGetCredentialsInfo(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", (void *)credentials, (void *)buffer, CUPS_LLCAST bufsize);
if (buffer)
*buffer = '\0';
saw_san = false; // Saw NID_subject_alt_name?
- DEBUG_printf("cupsSignCredentialsRequest(path=\"%s\", common_name=\"%s\", request=\"%s\", root_name=\"%s\", allowed_purpose=0x%x, allowed_usage=0x%x, cb=%p, cb_data=%p, expiration_date=%ld)", path, common_name, request, root_name, allowed_purpose, allowed_usage, cb, cb_data, (long)expiration_date);
+ DEBUG_printf("cupsSignCredentialsRequest(path=\"%s\", common_name=\"%s\", request=\"%s\", root_name=\"%s\", allowed_purpose=0x%x, allowed_usage=0x%x, cb=%p, cb_data=%p, expiration_date=%ld)", path, common_name, request, root_name, allowed_purpose, allowed_usage, (void *)cb, cb_data, (long)expiration_date);
// Filenames...
if (!path)
STACK_OF(X509) *chain; // Certificate chain
- DEBUG_printf("httpCopyCredentials(http=%p)", http);
+ DEBUG_printf("httpCopyCredentials(http=%p)", (void *)http);
if (http && http->tls)
{
// Get the chain of certificates for the remote end...
chain = SSL_get_peer_cert_chain(http->tls);
- DEBUG_printf("1httpCopyCredentials: chain=%p", chain);
+ DEBUG_printf("1httpCopyCredentials: chain=%p", (void *)chain);
if (chain)
{
}
}
- DEBUG_printf("1_httpCreateCredentials: Returning %p.", hcreds);
+ DEBUG_printf("1_httpCreateCredentials: Returning %p.", (void *)hcreds);
return (hcreds);
}
};
- DEBUG_printf("3_httpTLSStart(http=%p)", http);
+ DEBUG_printf("3_httpTLSStart(http=%p)", (void *)http);
if (tls_options < 0)
{
*/
msg = ippNew();
- while ((state = ippReadFile(0, msg)) != IPP_DATA)
+ while ((state = ippReadFile(0, msg)) != IPP_STATE_DATA)
{
- if (state <= IPP_IDLE)
+ if (state <= IPP_STATE_IDLE)
break;
}
fprintf(stderr, "DEBUG: state=%d\n", state);
- if (state == IPP_ERROR)
+ if (state == IPP_STATE_ERROR)
fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr);
- if (state <= IPP_IDLE)
+ if (state <= IPP_STATE_IDLE)
{
/*
* Out of messages, free memory and then exit...
*/
event = ippNew();
- while ((state = ippReadFile(0, event)) != IPP_DATA)
+ while ((state = ippReadFile(0, event)) != IPP_STATE_DATA)
{
- if (state <= IPP_IDLE)
+ if (state <= IPP_STATE_IDLE)
break;
}
- if (state == IPP_ERROR)
+ if (state == IPP_STATE_ERROR)
fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr);
- if (state <= IPP_IDLE)
+ if (state <= IPP_STATE_IDLE)
break;
/*
for (;;)
{
event = ippNew();
- while ((state = ippReadFile(0, event)) != IPP_DATA)
+ while ((state = ippReadFile(0, event)) != IPP_STATE_DATA)
{
- if (state <= IPP_IDLE)
+ if (state <= IPP_STATE_IDLE)
break;
}
- if (state == IPP_ERROR)
+ if (state == IPP_STATE_ERROR)
fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr);
- if (state <= IPP_IDLE)
+ if (state <= IPP_STATE_IDLE)
{
ippDelete(event);
return (0);
cupsd_authmask_t temp; /* New host/domain mask */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddIPMask(masks=%p(%p), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)", masks, *masks, address[0], address[1], address[2], address[3], netmask[0], netmask[1], netmask[2], netmask[3]);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddIPMask(masks=%p(%p), address=%x:%x:%x:%x, netmask=%x:%x:%x:%x)", (void *)masks, (void *)*masks, address[0], address[1], address[2], address[3], netmask[0], netmask[1], netmask[2], netmask[3]);
temp.type = CUPSD_AUTH_IP;
memcpy(temp.mask.ip.address, address, sizeof(temp.mask.ip.address));
cupsdAddName(cupsd_location_t *loc, /* I - Location to add to */
char *name) /* I - Name to add */
{
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddName(loc=%p, name=\"%s\")", loc, name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddName(loc=%p, name=\"%s\")", (void *)loc, name);
if (!loc->names)
loc->names = cupsArrayNew3(NULL, NULL, NULL, 0,
*ifptr; /* Pointer to end of name */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddNameMask(masks=%p(%p), name=\"%s\")", masks, *masks, name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddNameMask(masks=%p(%p), name=\"%s\")", (void *)masks, (void *)*masks, name);
if (!_cups_strcasecmp(name, "@LOCAL"))
{
con->best = cupsdFindBest(con->uri, httpGetState(con->http));
con->type = CUPSD_AUTH_NONE;
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "con->uri=\"%s\", con->best=%p(%s)", con->uri, con->best, con->best ? con->best->location : "");
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "con->uri=\"%s\", con->best=%p(%s)", con->uri, (void *)con->best, con->best ? con->best->location : "");
if (con->best && con->best->type != CUPSD_AUTH_NONE)
{
#endif /* HAVE_MBR_UID_TO_UUID */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckGroup(username=\"%s\", user=%p, groupname=\"%s\")", username, user, groupname);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckGroup(username=\"%s\", user=%p, groupname=\"%s\")", username, (void *)user, groupname);
/*
* Validate input...
};
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: con->uri=\"%s\", con->best=%p(%s)", con->uri, con->best, con->best ? con->best->location ? con->best->location : "(null)" : "");
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: con->uri=\"%s\", con->best=%p(%s)", con->uri, (void *)con->best, con->best ? con->best->location ? con->best->location : "(null)" : "");
if (owner)
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdIsAuthorized: owner=\"%s\"", owner);
static int // O - 1 if authorized, 0 otherwise
check_admin_access(cupsd_client_t *con) // I - Client connection
{
+ (void)con;
+
#if defined(HAVE_LIBAPPARMOR) && defined(HAVE_LIBSNAPDGLIB)
/*
* If the client accesses locally via domain socket, find out whether it
i = 0;
if (c->printers[i]->accepting &&
- (c->printers[i]->state == IPP_PRINTER_IDLE ||
+ (c->printers[i]->state == IPP_PSTATE_IDLE ||
((c->printers[i]->type & CUPS_PRINTER_REMOTE) && !c->printers[i]->job)))
{
c->last_printer = i;
p = cupsdAddClass(value);
p->accepting = 1;
- p->state = IPP_PRINTER_IDLE;
+ p->state = IPP_PSTATE_IDLE;
if (!_cups_strcasecmp(line, "<DefaultClass"))
DefaultPrinter = p;
{
cupsdSetString(&temp->make_model, "Remote Printer on unknown");
- temp->state = IPP_PRINTER_STOPPED;
+ temp->state = IPP_PSTATE_STOPPED;
temp->type |= CUPS_PRINTER_REMOTE;
cupsdSetString(&temp->location, "Location Unknown");
*/
if (!_cups_strcasecmp(value, "idle"))
- p->state = IPP_PRINTER_IDLE;
+ p->state = IPP_PSTATE_IDLE;
else if (!_cups_strcasecmp(value, "stopped"))
{
- p->state = IPP_PRINTER_STOPPED;
+ p->state = IPP_PSTATE_STOPPED;
for (i = 0 ; i < p->num_reasons; i ++)
if (!strcmp("paused", p->reasons[i]))
if (pclass->location)
cupsFilePutConf(fp, "Location", pclass->location);
- if (pclass->state == IPP_PRINTER_STOPPED)
+ if (pclass->state == IPP_PSTATE_STOPPED)
cupsFilePuts(fp, "State Stopped\n");
else
cupsFilePuts(fp, "State Idle\n");
#endif /* HAVE_TCPD_H */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAcceptClient(lis=%p(%d)) Clients=%d", lis, lis->fd, cupsArrayGetCount(Clients));
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAcceptClient(lis=%p(%d)) Clients=%d", (void *)lis, lis->fd, cupsArrayGetCount(Clients));
/*
* Make sure we don't have a full set of clients already...
status = HTTP_STATUS_CONTINUE;
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "cupsdReadClient: error=%d, used=%d, state=%s, data_encoding=HTTP_ENCODING_%s, data_remaining=" CUPS_LLFMT ", request=%p(%s), file=%d", httpGetError(con->http), (int)httpGetReady(con->http), httpStateString(httpGetState(con->http)), httpIsChunked(con->http) ? "CHUNKED" : "LENGTH", CUPS_LLCAST httpGetRemaining(con->http), con->request, con->request ? ippStateString(ippGetState(con->request)) : "", con->file);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "cupsdReadClient: error=%d, used=%d, state=%s, data_encoding=HTTP_ENCODING_%s, data_remaining=" CUPS_LLFMT ", request=%p(%s), file=%d", httpGetError(con->http), (int)httpGetReady(con->http), httpStateString(httpGetState(con->http)), httpIsChunked(con->http) ? "CHUNKED" : "LENGTH", CUPS_LLCAST httpGetRemaining(con->http), (void *)con->request, con->request ? ippStateString(ippGetState(con->request)) : "", con->file);
if (httpGetError(con->http) == EPIPE && !httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
{
con->request->request.op.version[1],
ippOpString(con->request->request.op.operation_id),
con->request->request.op.request_id);
- con->bytes += (off_t)ippLength(con->request);
+ con->bytes += (off_t)ippGetLength(con->request);
}
}
ipp_state_t ipp_state; /* IPP state value */
- cupsdLogClient(con, CUPSD_LOG_DEBUG, "con->http=%p", con->http);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG, "con->http=%p", (void *)con->http);
cupsdLogClient(con, CUPSD_LOG_DEBUG,
"cupsdWriteClient "
"error=%d, "
httpStateString(httpGetState(con->http)),
httpIsChunked(con->http) ? "CHUNKED" : "LENGTH",
CUPS_LLCAST httpGetLength2(con->http),
- con->response,
+ (void *)con->response,
con->response ? ippStateString(ippGetState(con->request)) : "",
con->pipe_pid, con->file);
if (*ptr == '\0')
return (1);
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "check_if_modified: filestats=%p(" CUPS_LLFMT ", %d)) If-Modified-Since=\"%s\"", filestats, CUPS_LLCAST filestats->st_size, (int)filestats->st_mtime, ptr);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "check_if_modified: filestats=%p(" CUPS_LLFMT ", %d)) If-Modified-Since=\"%s\"", (void *)filestats, CUPS_LLCAST filestats->st_size, (int)filestats->st_mtime, ptr);
while (*ptr != '\0')
{
}
}
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "get_file: filestats=%p, filename=%p, len=" CUPS_LLFMT ", returning \"%s\".", filestats, filename, CUPS_LLCAST len, status ? "(null)" : filename);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "get_file: filestats=%p, filename=%p, len=" CUPS_LLFMT ", returning \"%s\".", (void *)filestats, (void *)filename, CUPS_LLCAST len, status ? "(null)" : filename);
if (status)
return (NULL);
if (!type || _cups_strcasecmp(type->super, "application"))
{
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, filestats, type ? type->super : "unknown", type ? type->type : "unknown");
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, (void *)filestats, type ? type->super : "unknown", type ? type->type : "unknown");
return (0);
}
if (options)
cupsdSetStringf(&con->options, " %s", options);
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 1.", filename, filestats, type->super, type->type);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 1.", filename, (void *)filestats, type->super, type->type);
return (1);
}
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, filestats, type->super, type->type);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "is_cgi: filename=\"%s\", filestats=%p, type=%s/%s, returning 0.", filename, (void *)filestats, type->super, type->type);
return (0);
}
* be consistent with Apache...
*/
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "pipe_command: infile=%d, outfile=%p, command=\"%s\", options=\"%s\", root=%d", infile, outfile, command, options ? options : "(null)", root);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "pipe_command: infile=%d, outfile=%p, command=\"%s\", options=\"%s\", root=%d", infile, (void *)outfile, command, options ? options : "(null)", root);
argv[0] = command;
{
con->file = open(filename, O_RDONLY);
- cupsdLogClient(con, CUPSD_LOG_DEBUG2, "write_file: code=%d, filename=\"%s\" (%d), type=\"%s\", filestats=%p.", code, filename, con->file, type ? type : "(null)", filestats);
+ cupsdLogClient(con, CUPSD_LOG_DEBUG2, "write_file: code=%d, filename=\"%s\" (%d), type=\"%s\", filestats=%p.", code, filename, con->file, type ? type : "(null)", (void *)filestats);
if (con->file < 0)
return (0);
cupsdAddString(&(p->job_attrs), "notify-user-data");
cupsdLogMessage(CUPSD_LOG_INFO, "<Limit Create-Job Print-Job Print-URI Validate-Job>");
- po = cupsdAddPolicyOp(p, NULL, IPP_CREATE_JOB);
- cupsdAddPolicyOp(p, po, IPP_PRINT_JOB);
- cupsdAddPolicyOp(p, po, IPP_PRINT_URI);
- cupsdAddPolicyOp(p, po, IPP_VALIDATE_JOB);
+ po = cupsdAddPolicyOp(p, NULL, IPP_OP_CREATE_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_PRINT_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_PRINT_URI);
+ cupsdAddPolicyOp(p, po, IPP_OP_VALIDATE_JOB);
cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po->order_type = CUPSD_AUTH_ALLOW;
cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
cupsdLogMessage(CUPSD_LOG_INFO, "<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job>");
- po = cupsdAddPolicyOp(p, NULL, IPP_SEND_DOCUMENT);
- cupsdAddPolicyOp(p, po, IPP_SEND_URI);
- cupsdAddPolicyOp(p, po, IPP_HOLD_JOB);
- cupsdAddPolicyOp(p, po, IPP_RELEASE_JOB);
- cupsdAddPolicyOp(p, po, IPP_RESTART_JOB);
- cupsdAddPolicyOp(p, po, IPP_PURGE_JOBS);
- cupsdAddPolicyOp(p, po, IPP_SET_JOB_ATTRIBUTES);
- cupsdAddPolicyOp(p, po, IPP_CREATE_JOB_SUBSCRIPTION);
- cupsdAddPolicyOp(p, po, IPP_RENEW_SUBSCRIPTION);
- cupsdAddPolicyOp(p, po, IPP_CANCEL_SUBSCRIPTION);
- cupsdAddPolicyOp(p, po, IPP_GET_NOTIFICATIONS);
- cupsdAddPolicyOp(p, po, IPP_REPROCESS_JOB);
- cupsdAddPolicyOp(p, po, IPP_CANCEL_CURRENT_JOB);
- cupsdAddPolicyOp(p, po, IPP_SUSPEND_CURRENT_JOB);
- cupsdAddPolicyOp(p, po, IPP_RESUME_JOB);
- cupsdAddPolicyOp(p, po, IPP_CANCEL_MY_JOBS);
- cupsdAddPolicyOp(p, po, IPP_CLOSE_JOB);
- cupsdAddPolicyOp(p, po, CUPS_MOVE_JOB);
+ po = cupsdAddPolicyOp(p, NULL, IPP_OP_SEND_DOCUMENT);
+ cupsdAddPolicyOp(p, po, IPP_OP_SEND_URI);
+ cupsdAddPolicyOp(p, po, IPP_OP_HOLD_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_RELEASE_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_RESTART_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_PURGE_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_SET_JOB_ATTRIBUTES);
+ cupsdAddPolicyOp(p, po, IPP_OP_CREATE_JOB_SUBSCRIPTIONS);
+ cupsdAddPolicyOp(p, po, IPP_OP_RENEW_SUBSCRIPTION);
+ cupsdAddPolicyOp(p, po, IPP_OP_CANCEL_SUBSCRIPTION);
+ cupsdAddPolicyOp(p, po, IPP_OP_GET_NOTIFICATIONS);
+ cupsdAddPolicyOp(p, po, IPP_OP_REPROCESS_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_CANCEL_CURRENT_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_SUSPEND_CURRENT_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_RESUME_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_CANCEL_MY_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_CLOSE_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_MOVE_JOB);
cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po->order_type = CUPSD_AUTH_ALLOW;
cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
cupsdLogMessage(CUPSD_LOG_INFO, "<Limit CUPS-Authenticate-Job>");
- po = cupsdAddPolicyOp(p, NULL, CUPS_GET_DOCUMENT);
+ po = cupsdAddPolicyOp(p, NULL, IPP_OP_CUPS_GET_DOCUMENT);
cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po->order_type = CUPSD_AUTH_ALLOW;
cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
cupsdLogMessage(CUPSD_LOG_INFO, "<Limit Pause-Printer Resume-Printer Set-Printer-Attributes Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Add-Printer CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>");
- po = cupsdAddPolicyOp(p, NULL, IPP_PAUSE_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_RESUME_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_SET_PRINTER_ATTRIBUTES);
- cupsdAddPolicyOp(p, po, IPP_ENABLE_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_DISABLE_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB);
- cupsdAddPolicyOp(p, po, IPP_HOLD_NEW_JOBS);
- cupsdAddPolicyOp(p, po, IPP_RELEASE_HELD_NEW_JOBS);
- cupsdAddPolicyOp(p, po, IPP_DEACTIVATE_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_ACTIVATE_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_RESTART_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_SHUTDOWN_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_STARTUP_PRINTER);
- cupsdAddPolicyOp(p, po, IPP_PROMOTE_JOB);
- cupsdAddPolicyOp(p, po, IPP_SCHEDULE_JOB_AFTER);
- cupsdAddPolicyOp(p, po, IPP_CANCEL_JOBS);
- cupsdAddPolicyOp(p, po, CUPS_ADD_PRINTER);
- cupsdAddPolicyOp(p, po, CUPS_DELETE_PRINTER);
- cupsdAddPolicyOp(p, po, CUPS_ADD_CLASS);
- cupsdAddPolicyOp(p, po, CUPS_DELETE_CLASS);
- cupsdAddPolicyOp(p, po, CUPS_ACCEPT_JOBS);
- cupsdAddPolicyOp(p, po, CUPS_REJECT_JOBS);
- cupsdAddPolicyOp(p, po, CUPS_SET_DEFAULT);
+ po = cupsdAddPolicyOp(p, NULL, IPP_OP_PAUSE_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_RESUME_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_SET_PRINTER_ATTRIBUTES);
+ cupsdAddPolicyOp(p, po, IPP_OP_ENABLE_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_DISABLE_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_PAUSE_PRINTER_AFTER_CURRENT_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_HOLD_NEW_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_RELEASE_HELD_NEW_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_DEACTIVATE_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_ACTIVATE_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_RESTART_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_SHUTDOWN_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_STARTUP_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_PROMOTE_JOB);
+ cupsdAddPolicyOp(p, po, IPP_OP_SCHEDULE_JOB_AFTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_CANCEL_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_ADD_MODIFY_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_DELETE_PRINTER);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_ADD_MODIFY_CLASS);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_DELETE_CLASS);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_ACCEPT_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_REJECT_JOBS);
+ cupsdAddPolicyOp(p, po, IPP_OP_CUPS_SET_DEFAULT);
cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po->order_type = CUPSD_AUTH_ALLOW;
cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
cupsdLogMessage(CUPSD_LOG_INFO, "<Limit Cancel-Job>");
- po = cupsdAddPolicyOp(p, NULL, IPP_CANCEL_JOB);
+ po = cupsdAddPolicyOp(p, NULL, IPP_OP_CANCEL_JOB);
cupsdLogMessage(CUPSD_LOG_INFO, "Order Deny,Allow");
po->order_type = CUPSD_AUTH_ALLOW;
cupsdLogMessage(CUPSD_LOG_INFO, "</Limit>");
cupsdLogMessage(CUPSD_LOG_INFO, "<Limit CUPS-Authenticate-Job>");
- po = cupsdAddPolicyOp(p, NULL, CUPS_AUTHENTICATE_JOB);
+ po = cupsdAddPolicyOp(p, NULL, IPP_OP_CUPS_AUTHENTICATE_JOB);
cupsdLogMessage(CUPSD_LOG_INFO, "AuthType Default");
po->type = CUPSD_AUTH_DEFAULT;
if (cupsArrayCount(pol->ops) > 1)
{
- if ((op = cupsdFindPolicyOp(pol, IPP_VALIDATE_JOB)) == NULL ||
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_VALIDATE_JOB)) == NULL ||
op->op == IPP_ANY_OPERATION)
{
- if ((op = cupsdFindPolicyOp(pol, IPP_PRINT_JOB)) != NULL &&
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_PRINT_JOB)) != NULL &&
op->op != IPP_ANY_OPERATION)
{
/*
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Validate-Job defined in policy %s - using Print-Job's policy.", pol->name);
- cupsdAddPolicyOp(pol, op, IPP_VALIDATE_JOB);
+ cupsdAddPolicyOp(pol, op, IPP_OP_VALIDATE_JOB);
}
else
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Validate-Job defined in policy %s and no suitable template found.", pol->name);
}
- if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_JOBS)) == NULL ||
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_CANCEL_JOBS)) == NULL ||
op->op == IPP_ANY_OPERATION)
{
- if ((op = cupsdFindPolicyOp(pol, IPP_PAUSE_PRINTER)) != NULL &&
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_PAUSE_PRINTER)) != NULL &&
op->op != IPP_ANY_OPERATION)
{
/*
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Cancel-Jobs defined in policy %s - using Pause-Printer's policy.", pol->name);
- cupsdAddPolicyOp(pol, op, IPP_CANCEL_JOBS);
+ cupsdAddPolicyOp(pol, op, IPP_OP_CANCEL_JOBS);
}
else
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Cancel-Jobs defined in policy %s and no suitable template found.", pol->name);
}
- if ((op = cupsdFindPolicyOp(pol, IPP_CANCEL_MY_JOBS)) == NULL ||
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_CANCEL_MY_JOBS)) == NULL ||
op->op == IPP_ANY_OPERATION)
{
- if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_SEND_DOCUMENT)) != NULL &&
op->op != IPP_ANY_OPERATION)
{
/*
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Cancel-My-Jobs defined in policy %s - using Send-Document's policy.", pol->name);
- cupsdAddPolicyOp(pol, op, IPP_CANCEL_MY_JOBS);
+ cupsdAddPolicyOp(pol, op, IPP_OP_CANCEL_MY_JOBS);
}
else
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Cancel-My-Jobs defined in policy %s and no suitable template found.", pol->name);
}
- if ((op = cupsdFindPolicyOp(pol, IPP_CLOSE_JOB)) == NULL ||
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_CLOSE_JOB)) == NULL ||
op->op == IPP_ANY_OPERATION)
{
- if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_SEND_DOCUMENT)) != NULL &&
op->op != IPP_ANY_OPERATION)
{
/*
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Close-Job defined in policy %s - using Send-Document's policy.", pol->name);
- cupsdAddPolicyOp(pol, op, IPP_CLOSE_JOB);
+ cupsdAddPolicyOp(pol, op, IPP_OP_CLOSE_JOB);
}
else
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for Close-Job defined in policy %s and no suitable template found.", pol->name);
}
- if ((op = cupsdFindPolicyOp(pol, CUPS_GET_DOCUMENT)) == NULL ||
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_CUPS_GET_DOCUMENT)) == NULL ||
op->op == IPP_ANY_OPERATION)
{
- if ((op = cupsdFindPolicyOp(pol, IPP_SEND_DOCUMENT)) != NULL &&
+ if ((op = cupsdFindPolicyOp(pol, IPP_OP_SEND_DOCUMENT)) != NULL &&
op->op != IPP_ANY_OPERATION)
{
/*
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for CUPS-Get-Document defined in policy %s - using Send-Document's policy.", pol->name);
- cupsdAddPolicyOp(pol, op, CUPS_GET_DOCUMENT);
+ cupsdAddPolicyOp(pol, op, IPP_OP_CUPS_GET_DOCUMENT);
}
else
cupsdLogMessage(CUPSD_LOG_WARN, "No limit for CUPS-Get-Document defined in policy %s and no suitable template found.", pol->name);
if (getenv("SOFTWARE"))
puts("Content-Type: application/ipp\n");
- cupsdSendIPPHeader(IPP_OK, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_OK, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language", "en-US");
{
snprintf(message, sizeof(message), "Bad PPD name \"%s\".", name);
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
if (request_id)
{
- cupsdSendIPPHeader(IPP_OK, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_OK, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
{
snprintf(message, sizeof(message), "PPD \"%s\" not found.", name);
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
snprintf(message, sizeof(message), "Unable to access \"%s\" - %s",
line, strerror(errno));
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
if (request_id)
{
- cupsdSendIPPHeader(IPP_OK, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_OK, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
if (request_id)
{
- cupsdSendIPPHeader(IPP_OK, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_OK, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
{
if (request_id)
{
- cupsdSendIPPHeader(IPP_OK, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_OK, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
{
snprintf(buffer, sizeof(buffer), "PPD \"%s\" not found.", name);
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
{
snprintf(message, sizeof(message), "Bad PPD name \"%s\".", name);
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
snprintf(message, sizeof(message), "Unable to open \"%s\" - %s",
buffer, strerror(errno));
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
if (request_id)
{
- cupsdSendIPPHeader(IPP_OK, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_OK, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language",
if (!sent_header && request_id)
{
- cupsdSendIPPHeader(IPP_NOT_FOUND, request_id);
+ cupsdSendIPPHeader(IPP_STATUS_ERROR_NOT_FOUND, request_id);
cupsdSendIPPGroup(IPP_TAG_OPERATION);
cupsdSendIPPString(IPP_TAG_CHARSET, "attributes-charset", "utf-8");
cupsdSendIPPString(IPP_TAG_LANGUAGE, "attributes-natural-language", "en-US");
* Connect to the server...
*/
- http = httpConnect2(cupsGetServer(), ippPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL);
+ http = httpConnect2(cupsGetServer(), ippGetPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL);
if (!http)
{
syslog(LOG_ERR, "Unable to connect to server: %s", strerror(errno));
* Try connecting to the local server...
*/
- if ((http = httpConnect2(cupsGetServer(), ippPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
+ if ((http = httpConnect2(cupsGetServer(), ippGetPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
{
syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsGetServer(),
strerror(errno));
* Try connecting to the local server...
*/
- if ((http = httpConnect2(cupsGetServer(), ippPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
+ if ((http = httpConnect2(cupsGetServer(), ippGetPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
{
syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsGetServer(),
strerror(errno));
exit(1);
}
- request = ippNewRequest(CUPS_GET_DOCUMENT);
+ request = ippNewRequest(IPP_OP_CUPS_GET_DOCUMENT);
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", (int)jobid);
httpClose(http);
- if (cupsGetError() != IPP_OK)
+ if (cupsGetError() != IPP_STATUS_OK)
{
_cupsLangPrintf(stderr, _("cupsfilter: Unable to get job file - %s"),
cupsGetErrorString());
*/
cupsdLogMessage(CUPSD_LOG_DEBUG,
- "cupsdDeregisterPrinter(p=%p(%s), removeit=%d)", p, p->name,
+ "cupsdDeregisterPrinter(p=%p(%s), removeit=%d)", (void *)p, p->name,
removeit);
if (!Browsing || !p->shared ||
void
cupsdRegisterPrinter(cupsd_printer_t *p)/* I - Printer */
{
- cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdRegisterPrinter(p=%p(%s))", p,
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdRegisterPrinter(p=%p(%s))", (void *)p,
p->name);
if (!Browsing || !BrowseLocalProtocols ||
{
cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "dnssdDeregisterPrinter(p=%p(%s), clear_name=%d)", p, p->name,
+ "dnssdDeregisterPrinter(p=%p(%s), clear_name=%d)", (void *)p, p->name,
clear_name);
if (p->ipp_srv)
if ((auth = cupsdFindBest(resource, HTTP_STATE_POST)) == NULL ||
auth->type == CUPSD_AUTH_NONE)
- auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB);
+ auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_OP_PRINT_JOB);
if (auth)
{
int valid = 1; /* Valid request? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdProcessIPPRequest(%p[%d]): operation_id=%04x(%s)", con, con->number, con->request->request.op.operation_id, ippOpString(con->request->request.op.operation_id));
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdProcessIPPRequest(%p[%d]): operation_id=%04x(%s)", (void *)con, con->number, con->request->request.op.operation_id, ippOpString(con->request->request.op.operation_id));
if (LogLevel >= CUPSD_LOG_DEBUG2)
{
*/
attr = con->request->attrs;
- if (attr && attr->name && !strcmp(attr->name, "attributes-charset") && (attr->value_tag & IPP_TAG_MASK) == IPP_TAG_CHARSET && attr->group_tag == IPP_TAG_OPERATION)
+ if (attr && attr->name && !strcmp(attr->name, "attributes-charset") && (attr->value_tag & IPP_TAG_CUPS_MASK) == IPP_TAG_CHARSET && attr->group_tag == IPP_TAG_OPERATION)
charset = attr;
else
charset = NULL;
if (attr)
attr = attr->next;
- if (attr && attr->name && !strcmp(attr->name, "attributes-natural-language") && (attr->value_tag & IPP_TAG_MASK) == IPP_TAG_LANGUAGE && attr->group_tag == IPP_TAG_OPERATION)
+ if (attr && attr->name && !strcmp(attr->name, "attributes-natural-language") && (attr->value_tag & IPP_TAG_CUPS_MASK) == IPP_TAG_LANGUAGE && attr->group_tag == IPP_TAG_OPERATION)
{
language = attr;
uri = attr;
else if ((attr = ippFindAttribute(con->request, "job-uri", IPP_TAG_URI)) != NULL && attr->group_tag == IPP_TAG_OPERATION)
uri = attr;
- else if (con->request->request.op.operation_id == CUPS_GET_PPD && (attr = ippFindAttribute(con->request, "ppd-name", IPP_TAG_NAME)) != NULL && attr->group_tag == IPP_TAG_OPERATION)
+ else if (con->request->request.op.operation_id == IPP_OP_CUPS_GET_PPD && (attr = ippFindAttribute(con->request, "ppd-name", IPP_TAG_NAME)) != NULL && attr->group_tag == IPP_TAG_OPERATION)
uri = attr;
else
uri = NULL;
}
else if (!charset || !language ||
(!uri &&
- con->request->request.op.operation_id != CUPS_GET_DEFAULT &&
- con->request->request.op.operation_id != CUPS_GET_PRINTERS &&
- con->request->request.op.operation_id != CUPS_GET_CLASSES &&
- con->request->request.op.operation_id != CUPS_GET_DEVICES &&
- con->request->request.op.operation_id != CUPS_GET_PPDS))
+ con->request->request.op.operation_id != IPP_OP_CUPS_GET_DEFAULT &&
+ con->request->request.op.operation_id != IPP_OP_CUPS_GET_PRINTERS &&
+ con->request->request.op.operation_id != IPP_OP_CUPS_GET_CLASSES &&
+ con->request->request.op.operation_id != IPP_OP_CUPS_GET_DEVICES &&
+ con->request->request.op.operation_id != IPP_OP_CUPS_GET_PPDS))
{
/*
* Return an error, since attributes-charset,
cupsdLogMessage(CUPSD_LOG_DEBUG, "End of attributes...");
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Missing required attributes."));
}
else
cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "accept_jobs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "accept_jobs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
int need_restart_job; /* Need to restart job? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_class(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_class(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* No, return an error...
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The printer-uri must be of the form "
"\"ipp://HOSTNAME/classes/CLASSNAME\"."));
return;
* No, return an error...
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The printer-uri \"%s\" contains invalid characters."),
uri->values[0].string.text);
return;
* Yes, return an error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("A printer named \"%s\" already exists."),
resource + 9);
return;
* Cannot re-share remote printers.
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Cannot change printer-is-shared for remote queues."));
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Cannot change printer-is-shared for remote queues."));
if (!modify)
cupsdDeletePrinter(pclass, 0);
if ((attr = ippFindAttribute(con->request, "printer-state",
IPP_TAG_ENUM)) != NULL)
{
- if (attr->values[0].integer != IPP_PRINTER_IDLE &&
- attr->values[0].integer != IPP_PRINTER_STOPPED)
+ if (attr->values[0].integer != IPP_PSTATE_IDLE &&
+ attr->values[0].integer != IPP_PSTATE_STOPPED)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Attempt to set %s printer-state to bad value %d."),
pclass->name, attr->values[0].integer);
if (!modify)
cupsdLogMessage(CUPSD_LOG_INFO, "Setting %s printer-state to %d (was %d.)",
pclass->name, attr->values[0].integer, pclass->state);
- if (attr->values[0].integer == IPP_PRINTER_STOPPED)
+ if (attr->values[0].integer == IPP_PSTATE_STOPPED)
cupsdStopPrinter(pclass, 0);
else
{
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
if (!modify)
cupsdDeletePrinter(pclass, 0);
}
else if (dtype & CUPS_PRINTER_CLASS)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Nested classes are not allowed."));
if (!modify)
cupsdDeletePrinter(pclass, 0);
* Reset the current job to a "pending" status...
*/
- cupsdSetJobState(pclass->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+ cupsdSetJobState(pclass->job, IPP_JSTATE_PENDING, CUPSD_JOB_FORCE,
"Job restarted because the class was modified.");
}
pclass->name, get_username(con));
}
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"add_file(con=%p[%d], job=%d, filetype=%s/%s, "
- "compression=%d)", con, con ? con->number : -1, job->id,
+ "compression=%d)", (void *)con, con ? con->number : -1, job->id,
filetype->super, filetype->type, compression);
/*
if (!compressions || !filetypes)
{
- cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE,
+ cupsdSetJobState(job, IPP_JSTATE_ABORTED, CUPSD_JOB_PURGE,
"Job aborted because the scheduler ran out of memory.");
if (con)
- send_ipp_status(con, IPP_INTERNAL_ERROR,
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL,
_("Unable to allocate memory for file types."));
return (-1);
cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
- con, con->number, printer, printer->name,
- filetype, filetype ? filetype->super : "none",
+ (void *)con, con->number, (void *)printer, printer->name,
+ (void *)filetype, filetype ? filetype->super : "none",
filetype ? filetype->type : "none");
/*
_cups_strcasecmp(con->http->hostname, "localhost") &&
_cups_strcasecmp(con->http->hostname, ServerName))
{
- send_ipp_status(con, IPP_NOT_AUTHORIZED,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_AUTHORIZED,
_("The printer or class is not shared."));
return (NULL);
}
if (!printer->accepting)
{
- send_ipp_status(con, IPP_NOT_ACCEPTING,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_ACCEPTING_JOBS,
_("Destination \"%s\" is not accepting jobs."),
printer->name);
return (NULL);
if (StrictConformance)
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("The '%s' Job Status attribute cannot be supplied in a job creation request."), readonly[i]);
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("The '%s' Job Status attribute cannot be supplied in a job creation request."), readonly[i]);
return (NULL);
}
* Missing a required attribute...
*/
- send_ipp_status(con, IPP_CONFLICT,
+ send_ipp_status(con, IPP_STATUS_ERROR_CONFLICTING,
_("The \"%s\" attribute is required for print jobs."),
mandatory);
return (NULL);
snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
filetype->type);
- send_ipp_status(con, IPP_DOCUMENT_FORMAT,
+ send_ipp_status(con, IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED,
_("Unsupported format \"%s\"."), mimetype);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
{
if (attr->values[0].integer < 1 || attr->values[0].integer > MaxCopies)
{
- send_ipp_status(con, IPP_ATTRIBUTES, _("Bad copies value %d."),
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Bad copies value %d."),
attr->values[0].integer);
ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER,
"copies", attr->values[0].integer);
if (attr->value_tag != IPP_TAG_KEYWORD &&
attr->value_tag != IPP_TAG_NAME)
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value type."));
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-sheets value type."));
return (NULL);
}
if (attr->num_values > 2)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Too many job-sheets values (%d > 2)."),
attr->num_values);
return (NULL);
if (strcmp(attr->values[i].string.text, "none") &&
!cupsdFindBanner(attr->values[i].string.text))
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-sheets value \"%s\"."),
attr->values[i].string.text);
return (NULL);
}
attr->values[0].integer != 9 &&
attr->values[0].integer != 16)
{
- send_ipp_status(con, IPP_ATTRIBUTES, _("Bad number-up value %d."),
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Bad number-up value %d."),
attr->values[0].integer);
ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER,
"number-up", attr->values[0].integer);
if (attr->values[i].range.lower < lowerpagerange ||
attr->values[i].range.lower > attr->values[i].range.upper)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Bad page-ranges values %d-%d."),
attr->values[i].range.lower,
attr->values[i].range.upper);
(media_col = ippFindAttribute(con->request, "media-col",
IPP_TAG_BEGIN_COLLECTION)) != NULL)
{
- send_ipp_status(con, IPP_OK_SUBST, _("Unsupported margins."));
+ send_ipp_status(con, IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED, _("Unsupported margins."));
unsup_col = ippNew();
if ((media_margin = ippFindAttribute(media_col->values[0].collection,
if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Too many active jobs."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Too many active jobs."));
return (NULL);
}
if ((i = check_quotas(con, printer)) < 0)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Quota limit reached."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Quota limit reached."));
return (NULL);
}
else if (i == 0)
{
- send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Not allowed to print."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_AUTHORIZED, _("Not allowed to print."));
return (NULL);
}
attr->value_tag != IPP_TAG_NAMELANG) ||
attr->num_values != 1)
{
- send_ipp_status(con, IPP_ATTRIBUTES,
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,
_("Bad job-name value: Wrong type or count."));
if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
}
else if (!ippValidateAttribute(attr))
{
- send_ipp_status(con, IPP_ATTRIBUTES, _("Bad job-name value: %s"),
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Bad job-name value: %s"),
cupsGetErrorString());
if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
{
- send_ipp_status(con, IPP_INTERNAL_ERROR,
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL,
_("Unable to add job for destination \"%s\"."),
printer->name);
return (NULL);
ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id);
job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM,
- "job-state", IPP_JOB_STOPPED);
+ "job-state", IPP_JSTATE_STOPPED);
job->state_value = (ipp_jstate_t)job->state->values[0].integer;
job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD,
"job-state-reasons", NULL, "job-incoming");
else
cupsdSetJobHoldUntil(job, "indefinite", 0);
- job->state->values[0].integer = IPP_JOB_HELD;
- job->state_value = IPP_JOB_HELD;
+ job->state->values[0].integer = IPP_JSTATE_HELD;
+ job->state_value = IPP_JSTATE_HELD;
ippSetString(job->attrs, &job->reasons, 0, "job-held-on-create");
}
cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0);
- job->state->values[0].integer = IPP_JOB_HELD;
- job->state_value = IPP_JOB_HELD;
+ job->state->values[0].integer = IPP_JSTATE_HELD;
+ job->state_value = IPP_JSTATE_HELD;
ippSetString(job->attrs, &job->reasons, 0, "job-hold-until-specified");
}
- else if (job->attrs->request.op.operation_id == IPP_CREATE_JOB)
+ else if (job->attrs->request.op.operation_id == IPP_OP_CREATE_JOB)
{
job->hold_until = time(NULL) + MultipleOperationTimeout;
- job->state->values[0].integer = IPP_JOB_HELD;
- job->state_value = IPP_JOB_HELD;
+ job->state->values[0].integer = IPP_JSTATE_HELD;
+ job->state_value = IPP_JSTATE_HELD;
}
else
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
ippSetString(job->attrs, &job->reasons, 0, "none");
}
if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0)
{
- cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE,
+ cupsdSetJobState(job, IPP_JSTATE_ABORTED, CUPSD_JOB_PURGE,
"Aborting job because the start banner could not be "
"copied.");
return (NULL);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_TEXT, "job-state-message", NULL, "");
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, job->reasons->values[0].string.text);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
/*
* Add any job subscriptions...
host, sizeof(host), &port,
resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Bad notify-recipient-uri \"%s\"."), recipient);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_URI_SCHEME);
+ "notify-status-code", IPP_STATUS_ERROR_URI_SCHEME);
return;
}
snprintf(notifier, sizeof(notifier), "%s/notifier/%s", ServerBin, scheme);
if (access(notifier, X_OK) || stat(notifier, &info) || !S_ISREG(info.st_mode))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("notify-recipient-uri URI \"%s\" uses unknown "
"scheme."), recipient);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_URI_SCHEME);
+ "notify-status-code", IPP_STATUS_ERROR_URI_SCHEME);
return;
}
if (!strcmp(scheme, "rss") && !check_rss_recipient(recipient))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("notify-recipient-uri URI \"%s\" is already used."),
recipient);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_ATTRIBUTES);
+ "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
return;
}
}
if (strcmp(pullmethod, "ippget"))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Bad notify-pull-method \"%s\"."), pullmethod);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_ATTRIBUTES);
+ "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
return;
}
}
strcmp(attr->values[0].string.text, "us-ascii") &&
strcmp(attr->values[0].string.text, "utf-8"))
{
- send_ipp_status(con, IPP_CHARSET,
+ send_ipp_status(con, IPP_STATUS_ERROR_CHARSET,
_("Character set \"%s\" not supported."),
attr->values[0].string.text);
return;
(attr->value_tag != IPP_TAG_LANGUAGE ||
strcmp(attr->values[0].string.text, DefaultLanguage)))
{
- send_ipp_status(con, IPP_CHARSET,
+ send_ipp_status(con, IPP_STATUS_ERROR_CHARSET,
_("Language \"%s\" not supported."),
attr->values[0].string.text);
return;
{
if (attr->num_values > 1 || attr->values[0].unknown.length > 63)
{
- send_ipp_status(con, IPP_REQUEST_VALUE,
+ send_ipp_status(con, IPP_STATUS_ERROR_REQUEST_VALUE,
_("The notify-user-data value is too large "
"(%d > 63 octets)."),
attr->values[0].unknown.length);
}
else if (!strcmp(attr->name, "notify-lease-duration"))
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The notify-lease-duration attribute cannot be "
"used with job subscriptions."));
return;
set_port_monitor; /* Did we set the port monitor? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_printer(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_printer(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* No, return an error...
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The printer-uri must be of the form "
"\"ipp://HOSTNAME/printers/PRINTERNAME\"."));
return;
* No, return an error...
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The printer-uri \"%s\" contains invalid characters."),
uri->values[0].string.text);
return;
* Yes, return an error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("A class named \"%s\" already exists."),
resource + 10);
return;
if (uri_status < HTTP_URI_STATUS_OK)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Bad device-uri \"%s\"."),
attr->values[0].string.text);
if (!modify)
cupsdDeletePrinter(printer, 0);
* File devices are disabled and the URL is not file:/dev/null...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("File device URIs have been disabled. "
"To enable, see the FileDevice directive in "
"\"%s/cups-files.conf\"."),
* Could not find device in list!
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Bad device-uri scheme \"%s\"."), scheme);
if (!modify)
cupsdDeletePrinter(printer, 0);
if (!supported || i >= supported->num_values)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad port-monitor \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Bad port-monitor \"%s\"."),
attr->values[0].string.text);
if (!modify)
cupsdDeletePrinter(printer, 0);
printer->num_auth_info_required == 1 &&
!strcmp(printer->auth_info_required[0], "negotiate"))
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Cannot share a remote Kerberized printer."));
if (!modify)
cupsdDeletePrinter(printer, 0);
* Cannot re-share remote printers.
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Cannot change printer-is-shared for remote queues."));
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Cannot change printer-is-shared for remote queues."));
if (!modify)
cupsdDeletePrinter(printer, 0);
if ((attr = ippFindAttribute(con->request, "printer-state",
IPP_TAG_ENUM)) != NULL)
{
- if (attr->values[0].integer != IPP_PRINTER_IDLE &&
- attr->values[0].integer != IPP_PRINTER_STOPPED)
+ if (attr->values[0].integer != IPP_PSTATE_IDLE &&
+ attr->values[0].integer != IPP_PSTATE_STOPPED)
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad printer-state value %d."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad printer-state value %d."),
attr->values[0].integer);
if (!modify)
cupsdDeletePrinter(printer, 0);
cupsdLogMessage(CUPSD_LOG_INFO, "Setting %s printer-state to %d (was %d.)",
printer->name, attr->values[0].integer, printer->state);
- if (attr->values[0].integer == IPP_PRINTER_STOPPED)
+ if (attr->values[0].integer == IPP_PSTATE_STOPPED)
cupsdStopPrinter(printer, 0);
else
{
if (attr->num_values >
(int)(sizeof(printer->reasons) / sizeof(printer->reasons[0])))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Too many printer-state-reasons values (%d > %d)."),
attr->num_values,
(int)(sizeof(printer->reasons) /
printer->num_reasons ++;
if (!strcmp(attr->values[i].string.text, "paused") &&
- printer->state != IPP_PRINTER_STOPPED)
+ printer->state != IPP_PSTATE_STOPPED)
{
cupsdLogMessage(CUPSD_LOG_INFO,
"Setting %s printer-state to %d (was %d.)",
- printer->name, IPP_PRINTER_STOPPED, printer->state);
+ printer->name, IPP_PSTATE_STOPPED, printer->state);
cupsdStopPrinter(printer, 0);
}
}
if (copy_file(srcfile, dstfile, ConfigFilePerm))
{
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to copy PPD file - %s"), strerror(errno));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("Unable to copy PPD file - %s"), strerror(errno));
if (!modify)
cupsdDeletePrinter(printer, 0);
// Create IPP Everywhere PPD...
if (!printer->device_uri || (strncmp(printer->device_uri, "dnssd://", 8) && strncmp(printer->device_uri, "ipp://", 6) && strncmp(printer->device_uri, "ipps://", 7) && strncmp(printer->device_uri, "ippusb://", 9)))
{
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("IPP Everywhere driver requires an IPP connection."));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("IPP Everywhere driver requires an IPP connection."));
if (!modify)
cupsdDeletePrinter(printer, 0);
* Restart the current job...
*/
- cupsdSetJobState(printer->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+ cupsdSetJobState(printer->job, IPP_JSTATE_PENDING, CUPSD_JOB_FORCE,
"Job restarted because the printer was modified.");
}
printer->name, get_username(con));
}
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
{
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"add_printer_state_reasons(%p[%d], %p[%s])",
- con, con->number, p, p->name);
+ (void *)con, con->number, (void *)p, p->name);
if (p->num_reasons == 0)
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_queued_job_count(%p[%d], %p[%s])",
- con, con->number, p, p->name);
+ (void *)con, con->number, (void *)p, p->name);
count = cupsdGetPrinterJobCount(p->name);
cupsdLogMessage(CUPSD_LOG_DEBUG2, "authenticate_job(%p[%d], %s)",
- con, con->number, uri->values[0].string.text);
+ (void *)con, con->number, uri->values[0].string.text);
/*
* Start with "everything is OK" status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
/*
* See if we have a job URI or a printer URI...
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
* See if the job has been completed...
*/
- if (job->state_value != IPP_JOB_HELD)
+ if (job->state_value != IPP_JSTATE_HELD)
{
/*
* Return a "not-possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is not held for authentication."),
jobid);
return;
!strcmp(printer->auth_info_required[0], "negotiate"))
send_http_error(con, HTTP_STATUS_UNAUTHORIZED, printer);
else
- send_ipp_status(con, IPP_NOT_AUTHORIZED,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_AUTHORIZED,
_("No authentication information provided."));
return;
}
cupsd_job_t *job; /* Job */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_all_jobs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_all_jobs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
switch (con->request->request.op.operation_id)
{
- case IPP_PURGE_JOBS :
+ case IPP_OP_PURGE_JOBS :
/*
* Get the username (if any) for the jobs we want to cancel (only if
* "my-jobs" is specified...
username = attr->values[0].string.text;
else
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Missing requesting-user-name attribute."));
return;
}
purge = CUPSD_JOB_PURGE;
break;
- case IPP_CANCEL_MY_JOBS :
+ case IPP_OP_CANCEL_MY_JOBS :
if (con->username[0])
username = con->username;
else if ((attr = ippFindAttribute(con->request, "requesting-user-name",
username = attr->values[0].string.text;
else
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Missing requesting-user-name attribute."));
return;
}
if (strcmp(uri->name, "printer-uri"))
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The printer-uri attribute is required."));
return;
}
if ((!strncmp(resource, "/printers/", 10) && resource[10]) ||
(!strncmp(resource, "/classes/", 9) && resource[9]))
{
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL)
break;
- if (con->request->request.op.operation_id == IPP_CANCEL_MY_JOBS &&
+ if (con->request->request.op.operation_id == IPP_OP_CANCEL_MY_JOBS &&
_cups_strcasecmp(job->username, username))
break;
}
if (i < job_ids->num_values)
{
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
job_ids->values[i].integer);
return;
}
{
job = cupsdFindJob(job_ids->values[i].integer);
- cupsdSetJobState(job, IPP_JOB_CANCELED, purge,
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, purge,
purge == CUPSD_JOB_PURGE ? "Job purged by user." :
"Job canceled by user.");
}
_cups_strcasecmp(job->dest, printer->name))
break;
- if (con->request->request.op.operation_id == IPP_CANCEL_MY_JOBS &&
+ if (con->request->request.op.operation_id == IPP_OP_CANCEL_MY_JOBS &&
_cups_strcasecmp(job->username, username))
break;
}
if (i < job_ids->num_values)
{
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
job_ids->values[i].integer);
return;
}
{
job = cupsdFindJob(job_ids->values[i].integer);
- cupsdSetJobState(job, IPP_JOB_CANCELED, purge,
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, purge,
purge == CUPSD_JOB_PURGE ? "Job purged by user." :
"Job canceled by user.");
}
}
}
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
cupsdCheckJobs();
}
cupsd_jobaction_t purge; /* Purge the job? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_job(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_job(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
- if (job->state_value <= IPP_JOB_PROCESSING &&
+ if (job->state_value <= IPP_JSTATE_PROCESSING &&
!_cups_strcasecmp(job->dest, printer->name))
break;
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
- if (job->state_value == IPP_JOB_STOPPED &&
+ if (job->state_value == IPP_JSTATE_STOPPED &&
!_cups_strcasecmp(job->dest, printer->name))
break;
jobid = job->id;
else
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("No active jobs on %s."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("No active jobs on %s."),
printer->name);
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
* we can't cancel...
*/
- if (job->state_value >= IPP_JOB_CANCELED && purge != CUPSD_JOB_PURGE)
+ if (job->state_value >= IPP_JSTATE_CANCELED && purge != CUPSD_JOB_PURGE)
{
switch (job->state_value)
{
- case IPP_JOB_CANCELED :
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ case IPP_JSTATE_CANCELED :
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is already canceled - can\'t cancel."),
jobid);
break;
- case IPP_JOB_ABORTED :
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ case IPP_JSTATE_ABORTED :
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is already aborted - can\'t cancel."),
jobid);
break;
default :
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is already completed - can\'t cancel."),
jobid);
break;
* Cancel the job and return...
*/
- cupsdSetJobState(job, IPP_JOB_CANCELED, purge,
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, purge,
purge == CUPSD_JOB_PURGE ? "Job purged by \"%s\"" :
"Job canceled by \"%s\"",
username);
cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Canceled by \"%s\".", jobid,
username);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cancel_subscription(con=%p[%d], sub_id=%d)",
- con, con->number, sub_id);
+ (void *)con, con->number, sub_id);
/*
* Is the subscription ID valid?
* Bad subscription ID...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("Subscription #%d does not exist."), sub_id);
return;
}
cupsdDeleteSubscription(sub, 1);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "check_quotas(%p[%d], %p[%s])",
- con, con->number, p, p->name);
+ (void *)con, con->number, (void *)p, p->name);
/*
* Figure out who is printing...
username[256]; /* User name */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "close_job(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "close_job(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* job-uri is not supported by Close-Job!
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Close-Job doesn't support the job-uri attribute."));
return;
}
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
attr->values[0].integer);
return;
}
if (cupsdTimeoutJob(job))
return;
- if (job->state_value == IPP_JOB_STOPPED)
+ if (job->state_value == IPP_JSTATE_STOPPED)
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
}
- else if (job->state_value == IPP_JOB_HELD)
+ else if (job->state_value == IPP_JSTATE_HELD)
{
if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
IPP_TAG_KEYWORD)) == NULL)
if (!attr || !strcmp(attr->values[0].string.text, "no-hold"))
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
}
}
ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", (int)job->state_value);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
/*
* Start the job if necessary...
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"copy_attrs(to=%p, from=%p, ra=%p, group=%x, quickcopy=%d)",
- to, from, ra, group, quickcopy);
+ (void *)to, (void *)from, (void *)ra, group, quickcopy);
if (!to || !from)
return;
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"copy_banner(con=%p[%d], job=%p[%d], name=\"%s\")",
- con, con ? con->number : -1, job, job->id,
+ (void *)con, con ? con->number : -1, (void *)job, job->id,
name ? name : "(null)");
/*
/* cupsProtocol attribute */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_model(con=%p, from=\"%s\", to=\"%s\")", con, from, to);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_model(con=%p, from=\"%s\", to=\"%s\")", (void *)con, from, to);
/*
* Run cups-driverd to get the PPD file...
if (!cupsdStartProcess(buffer, argv, envp, -1, temppipe[1], CGIPipes[1],
-1, -1, 0, DefaultProfile, NULL, &temppid))
{
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to run cups-driverd: %s"), strerror(errno));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("Unable to run cups-driverd: %s"), strerror(errno));
close(tempfd);
unlink(tempfile);
*/
cupsdLogMessage(CUPSD_LOG_ERROR, "copy_model: empty PPD file");
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("cups-driverd failed to get PPD file - see error_log for details."));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("cups-driverd failed to get PPD file - see error_log for details."));
unlink(tempfile);
return (-1);
}
if ((dst = cupsdCreateConfFile(to, ConfigFilePerm)) == NULL)
{
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to save PPD file: %s"), strerror(errno));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("Unable to save PPD file: %s"), strerror(errno));
cupsFreeOptions(num_defaults, defaults);
cupsFileClose(src);
unlink(tempfile);
if (cupsdCloseCreatedConfFile(dst, to))
{
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to commit PPD file: %s"), strerror(errno));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("Unable to commit PPD file: %s"), strerror(errno));
return (-1);
}
else
"job-more-info", NULL, job_uri);
}
- if (job->state_value > IPP_JOB_PROCESSING &&
+ if (job->state_value > IPP_JSTATE_PROCESSING &&
(!exclude || !cupsArrayFind(exclude, "job-preserved")) &&
(!ra || cupsArrayFind(ra, "job-preserved")))
ippAddBoolean(con->response, IPP_TAG_JOB, "job-preserved",
copy_attrs(con->response, printer->attrs, ra, IPP_TAG_ZERO, 0, NULL);
if (printer->ppd_attrs)
copy_attrs(con->response, printer->ppd_attrs, ra, IPP_TAG_ZERO, 0, NULL);
- copy_attrs(con->response, CommonData, ra, IPP_TAG_ZERO, IPP_TAG_COPY, NULL);
+ copy_attrs(con->response, CommonData, ra, IPP_TAG_ZERO, IPP_TAG_CUPS_CONST, NULL);
cupsRWUnlock(&printer->lock);
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"copy_subscription_attrs(con=%p, sub=%p, ra=%p, exclude=%p)",
- con, sub, ra, exclude);
+ (void *)con, (void *)sub, (void *)ra, (void *)exclude);
/*
* Copy the subscription attributes to the response using the
};
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
{
if (StrictConformance)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("The '%s' operation attribute cannot be supplied in a "
"Create-Job request."), forbidden_attrs[i]);
return;
* Is the destination valid?
*/
- cupsdLogMessage(CUPSD_LOG_DEBUG, "create_subscriptions(con=%p(%d), uri=\"%s\")", con, con->number, uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "create_subscriptions(con=%p(%d), uri=\"%s\")", (void *)con, con->number, uri->values[0].string.text);
httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
sizeof(scheme), userpass, sizeof(userpass), host,
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
if (!attr)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("No subscription attributes in request."));
return;
}
* Process the subscription attributes in the request...
*/
- con->response->request.status.status_code = IPP_BAD_REQUEST;
+ con->response->request.status.status_code = IPP_STATUS_ERROR_BAD_REQUEST;
while (attr)
{
host, sizeof(host), &port,
resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Bad notify-recipient-uri \"%s\"."), recipient);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_URI_SCHEME);
+ "notify-status-code", IPP_STATUS_ERROR_URI_SCHEME);
return;
}
scheme);
if (access(notifier, X_OK) || !strcmp(scheme, ".") || !strcmp(scheme, ".."))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("notify-recipient-uri URI \"%s\" uses unknown "
"scheme."), recipient);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_URI_SCHEME);
+ "notify-status-code", IPP_STATUS_ERROR_URI_SCHEME);
return;
}
if (!strcmp(scheme, "rss") && !check_rss_recipient(recipient))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("notify-recipient-uri URI \"%s\" is already used."),
recipient);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_ATTRIBUTES);
+ "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
return;
}
}
if (strcmp(pullmethod, "ippget"))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Bad notify-pull-method \"%s\"."), pullmethod);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
- "notify-status-code", IPP_ATTRIBUTES);
+ "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
return;
}
}
strcmp(attr->values[0].string.text, "us-ascii") &&
strcmp(attr->values[0].string.text, "utf-8"))
{
- send_ipp_status(con, IPP_CHARSET,
+ send_ipp_status(con, IPP_STATUS_ERROR_CHARSET,
_("Character set \"%s\" not supported."),
attr->values[0].string.text);
return;
(attr->value_tag != IPP_TAG_LANGUAGE ||
strcmp(attr->values[0].string.text, DefaultLanguage)))
{
- send_ipp_status(con, IPP_CHARSET,
+ send_ipp_status(con, IPP_STATUS_ERROR_CHARSET,
_("Language \"%s\" not supported."),
attr->values[0].string.text);
return;
{
if (attr->num_values > 1 || attr->values[0].unknown.length > 63)
{
- send_ipp_status(con, IPP_REQUEST_VALUE,
+ send_ipp_status(con, IPP_STATUS_ERROR_REQUEST_VALUE,
_("The notify-user-data value is too large "
"(%d > 63 octets)."),
attr->values[0].unknown.length);
if (httpSeparateURI(HTTP_URI_CODING_ALL, temp, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad notify-user-data \"%s\"."), temp);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Bad notify-user-data \"%s\"."), temp);
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM, "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
return;
}
mask = CUPSD_EVENT_PRINTER_STATE_CHANGED;
else
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("notify-events not specified."));
return;
}
{
if ((job = cupsdFindJob(jobid)) == NULL)
{
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
jobid);
return;
}
if ((sub = cupsdAddSubscription(mask, printer, job, recipient, 0)) == NULL)
{
- send_ipp_status(con, IPP_TOO_MANY_SUBSCRIPTIONS,
+ send_ipp_status(con, IPP_STATUS_ERROR_TOO_MANY_SUBSCRIPTIONS,
_("There are too many subscriptions."));
return;
}
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
"notify-subscription-id", sub->id);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
if (attr)
attr = attr->next;
int temporary; /* Temporary queue? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "delete_printer(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "delete_printer(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Return with no errors...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cups_array_t *ra; /* Requested attributes array */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_default(%p[%d])", con, con->number);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_default(%p[%d])", (void *)con, con->number);
/*
* Check policy...
cupsArrayDelete(ra);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
else
- send_ipp_status(con, IPP_NOT_FOUND, _("No default printer."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("No default printer."));
}
/* String for included schemes */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_devices(%p[%d])", con, con->number);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_devices(%p[%d])", (void *)con, con->number);
/*
* Check policy...
* went wrong...
*/
- send_ipp_status(con, IPP_INTERNAL_ERROR,
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL,
_("cups-deviced failed to execute."));
}
}
format[1024]; /* Format for document */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_document(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_document(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
if ((attr = ippFindAttribute(con->request, "document-number",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Missing document-number attribute."));
return;
}
if ((docnum = attr->values[0].integer) < 1 || docnum > job->num_files ||
attr->num_values > 1)
{
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("Document #%d does not exist in job #%d."), docnum,
jobid);
return;
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to open document %d in job %d - %s", docnum, jobid,
strerror(errno));
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("Unable to open document #%d in job #%d."), docnum,
jobid);
return;
*exclude; /* Private attributes array */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_job_attrs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_job_attrs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
copy_job_attrs(con, job, ra, exclude);
cupsArrayDelete(ra);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_policy_t *policy; /* Current policy */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", con, con->number,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", (void *)con, con->number,
uri->values[0].string.text);
/*
if (strcmp(uri->name, "printer-uri"))
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("No printer-uri in request."));
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("No printer-uri in request."));
return;
}
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
if ((attr = ippFindAttribute(con->request, "which-jobs",
IPP_TAG_KEYWORD)) != NULL && job_ids)
{
- send_ipp_status(con, IPP_CONFLICT,
+ send_ipp_status(con, IPP_STATUS_ERROR_CONFLICTING,
_("The %s attribute cannot be provided with job-ids."),
"which-jobs");
return;
else if (!attr || !strcmp(attr->values[0].string.text, "not-completed"))
{
job_comparison = -1;
- job_state = IPP_JOB_STOPPED;
+ job_state = IPP_JSTATE_STOPPED;
list = ActiveJobs;
}
else if (!strcmp(attr->values[0].string.text, "completed"))
{
job_comparison = 1;
- job_state = IPP_JOB_CANCELED;
+ job_state = IPP_JSTATE_CANCELED;
list = cupsdGetCompletedJobs(printer);
delete_list = 1;
}
else if (!strcmp(attr->values[0].string.text, "aborted"))
{
job_comparison = 0;
- job_state = IPP_JOB_ABORTED;
+ job_state = IPP_JSTATE_ABORTED;
list = cupsdGetCompletedJobs(printer);
delete_list = 1;
}
else if (!strcmp(attr->values[0].string.text, "all"))
{
job_comparison = 1;
- job_state = IPP_JOB_PENDING;
+ job_state = IPP_JSTATE_PENDING;
list = Jobs;
}
else if (!strcmp(attr->values[0].string.text, "canceled"))
{
job_comparison = 0;
- job_state = IPP_JOB_CANCELED;
+ job_state = IPP_JSTATE_CANCELED;
list = cupsdGetCompletedJobs(printer);
delete_list = 1;
}
else if (!strcmp(attr->values[0].string.text, "pending"))
{
job_comparison = 0;
- job_state = IPP_JOB_PENDING;
+ job_state = IPP_JSTATE_PENDING;
list = ActiveJobs;
}
else if (!strcmp(attr->values[0].string.text, "pending-held"))
{
job_comparison = 0;
- job_state = IPP_JOB_HELD;
+ job_state = IPP_JSTATE_HELD;
list = ActiveJobs;
}
else if (!strcmp(attr->values[0].string.text, "processing"))
{
job_comparison = 0;
- job_state = IPP_JOB_PROCESSING;
+ job_state = IPP_JSTATE_PROCESSING;
list = PrintingJobs;
}
else if (!strcmp(attr->values[0].string.text, "processing-stopped"))
{
job_comparison = 0;
- job_state = IPP_JOB_STOPPED;
+ job_state = IPP_JSTATE_STOPPED;
list = ActiveJobs;
}
else
{
- send_ipp_status(con, IPP_ATTRIBUTES,
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,
_("The which-jobs value \"%s\" is not supported."),
attr->values[0].string.text);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
{
if (job_ids)
{
- send_ipp_status(con, IPP_CONFLICT,
+ send_ipp_status(con, IPP_STATUS_ERROR_CONFLICTING,
_("The %s attribute cannot be provided with job-ids."),
"limit");
return;
{
if (job_ids)
{
- send_ipp_status(con, IPP_CONFLICT,
+ send_ipp_status(con, IPP_STATUS_ERROR_CONFLICTING,
_("The %s attribute cannot be provided with job-ids."),
"first-index");
return;
{
if (job_ids)
{
- send_ipp_status(con, IPP_CONFLICT,
+ send_ipp_status(con, IPP_STATUS_ERROR_CONFLICTING,
_("The %s attribute cannot be provided with job-ids."),
"first-job-id");
return;
if ((attr = ippFindAttribute(con->request, "my-jobs", IPP_TAG_BOOLEAN)) != NULL && job_ids)
{
- send_ipp_status(con, IPP_CONFLICT,
+ send_ipp_status(con, IPP_STATUS_ERROR_CONFLICTING,
_("The %s attribute cannot be provided with job-ids."),
"my-jobs");
return;
if (i < job_ids->num_values)
{
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
job_ids->values[i].integer);
cupsArrayDelete(ra);
return;
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"get_jobs: job->id=%d, dest=\"%s\", username=\"%s\", "
"state_value=%d, attrs=%p", job->id, job->dest,
- job->username, job->state_value, job->attrs);
+ job->username, job->state_value, (void *)job->attrs);
if (!job->dest || !job->username)
cupsdLoadJob(job);
if (delete_list)
cupsArrayDelete(list);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_notifications(con=%p[%d])",
- con, con->number);
+ (void *)con, con->number);
/*
* Get subscription attributes...
if (!ids)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Missing notify-subscription-ids attribute."));
return;
}
* Bad subscription ID...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Subscription #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Subscription #%d does not exist."),
ids->values[i].integer);
return;
}
* Check the subscription type and update the interval accordingly.
*/
- if (sub->job && sub->job->state_value == IPP_JOB_PROCESSING &&
+ if (sub->job && sub->job->state_value == IPP_JSTATE_PROCESSING &&
interval > 10)
interval = 10;
- else if (sub->job && sub->job->state_value >= IPP_JOB_STOPPED)
+ else if (sub->job && sub->job->state_value >= IPP_JSTATE_STOPPED)
interval = 0;
- else if (sub->dest && sub->dest->state == IPP_PRINTER_PROCESSING &&
+ else if (sub->dest && sub->dest->state == IPP_PSTATE_PROCESSING &&
interval > 30)
interval = 30;
}
*/
con->response->request.status.status_code =
- interval ? IPP_OK : IPP_OK_EVENTS_COMPLETE;
+ interval ? IPP_STATUS_OK : IPP_STATUS_OK_EVENTS_COMPLETE;
for (i = 0; i < ids->num_values; i ++)
{
cups_ptype_t dtype; /* Destination type */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppd(%p[%d], %p[%s=%s])", con,
- con->number, uri, uri->name, uri->values[0].string.text);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppd(%p[%d], %p[%s=%s])", (void *)con,
+ con->number, (void *)uri, uri->name, uri->values[0].string.text);
if (!strcmp(ippGetName(uri), "ppd-name"))
{
* went wrong...
*/
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("cups-driverd failed to execute."));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("cups-driverd failed to execute."));
}
}
else if (!strcmp(ippGetName(uri), "printer-uri") && cupsdValidateDest(ippGetString(uri, 0, NULL), &dtype, &dest))
/* String for included schemes */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppds(%p[%d])", con, con->number);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppds(%p[%d])", (void *)con, con->number);
/*
* Check policy...
* went wrong...
*/
- send_ipp_status(con, IPP_INTERNAL_ERROR,
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL,
_("cups-driverd failed to execute."));
}
}
cups_array_t *ra; /* Requested attributes array */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_attrs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_attrs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
cupsArrayDelete(ra);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_printer_t *printer; /* Printer/class */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_supported(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_supported(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ADMINDEFINE,
"printer-organizational-unit", 0);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
int local; /* Local connection? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printers(%p[%d], %x)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printers(%p[%d], %x)", (void *)con,
con->number, type);
/*
if (!Printers || !cupsArrayCount(Printers))
{
- send_ipp_status(con, IPP_NOT_FOUND, _("No destinations added."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("No destinations added."));
return;
}
cupsArrayDelete(ra);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"get_subscription_attrs(con=%p[%d], sub_id=%d)",
- con, con->number, sub_id);
+ (void *)con, con->number, sub_id);
/*
* Expire subscriptions as needed...
* Bad subscription ID...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Subscription #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Subscription #%d does not exist."),
sub_id);
return;
}
cupsArrayDelete(ra);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"get_subscriptions(con=%p[%d], uri=%s)",
- con, con->number, uri->values[0].string.text);
+ (void *)con, con->number, uri->values[0].string.text);
/*
* Is the destination valid?
if (!job)
{
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
job_id);
return;
}
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
if (!job)
{
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."),
attr->values[0].integer);
return;
}
cupsArrayDelete(ra);
if (count)
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
else
- send_ipp_status(con, IPP_NOT_FOUND, _("No subscriptions found."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("No subscriptions found."));
}
cupsd_job_t *job; /* Job information */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_job(%p[%d], %s)", con, con->number,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_job(%p[%d], %s)", (void *)con, con->number,
uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
* See if the job is in a state that allows holding...
*/
- if (job->state_value > IPP_JOB_STOPPED)
+ if (job->state_value > IPP_JSTATE_STOPPED)
{
/*
* Return a "not-possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is finished and cannot be altered."),
job->id);
return;
when = "indefinite";
cupsdSetJobHoldUntil(job, when, 1);
- cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".",
+ cupsdSetJobState(job, IPP_JSTATE_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".",
username);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_new_jobs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_new_jobs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
*dprinter; /* Destination printer */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "move_job(%p[%d], %s)", con, con->number,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "move_job(%p[%d], %s)", (void *)con, con->number,
uri->values[0].string.text);
/*
* Need job-printer-uri...
*/
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("job-printer-uri attribute missing."));
return;
}
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("Job #%d does not exist."), attr->values[0].integer);
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
else
* See if the job has been completed...
*/
- if (job->state_value > IPP_JOB_STOPPED)
+ if (job->state_value > IPP_JSTATE_STOPPED)
{
/*
* Return a "not-possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is finished and cannot be altered."),
job->id);
return;
*/
if (_cups_strcasecmp(job->dest, src) ||
- job->state_value > IPP_JOB_STOPPED)
+ job->state_value > IPP_JSTATE_STOPPED)
continue;
/*
* Return with "everything is OK" status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
int compression; /* Document compression */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "print_job(%p[%d], %s)", con, con->number,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "print_job(%p[%d], %s)", (void *)con, con->number,
uri->values[0].string.text);
/*
#endif /* HAVE_LIBZ */
)
{
- send_ipp_status(con, IPP_ATTRIBUTES,
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,
_("Unsupported compression \"%s\"."),
attr->values[0].string.text);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
if (!con->filename)
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("No file in print request."));
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("No file in print request."));
return;
}
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
if (sscanf(format->values[0].string.text, "%15[^/]/%255[^;]", super,
type) != 2)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Bad document-format \"%s\"."),
format->values[0].string.text);
return;
if (sscanf(default_format, "%15[^/]/%255[^;]", super, type) != 2)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Bad document-format \"%s\"."),
default_format);
return;
}
else if (!filetype)
{
- send_ipp_status(con, IPP_DOCUMENT_FORMAT,
+ send_ipp_status(con, IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED,
_("Unsupported document-format \"%s\"."),
format ? format->values[0].string.text :
"application/octet-stream");
{
cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to rename job document file \"%s\": %s", filename, strerror(errno));
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to rename job document file."));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("Unable to rename job document file."));
return;
}
ipp_attribute_t *attr; /* printer-state-message text */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "reject_jobs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "reject_jobs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_held_new_jobs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_held_new_jobs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_job_t *job; /* Job information */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_job(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_job(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
* See if job is "held"...
*/
- if (job->state_value != IPP_JOB_HELD)
+ if (job->state_value != IPP_JSTATE_HELD)
{
/*
* Nope - return a "not possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not held."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Job #%d is not held."), jobid);
return;
}
cupsdLogJob(job, CUPSD_LOG_INFO, "Released by \"%s\".", username);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
cupsdCheckJobs();
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"renew_subscription(con=%p[%d], sub_id=%d)",
- con, con->number, sub_id);
+ (void *)con, con->number, sub_id);
/*
* Is the subscription ID valid?
* Bad subscription ID...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Subscription #%d does not exist."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Subscription #%d does not exist."),
sub_id);
return;
}
* Job subscriptions cannot be renewed...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job subscriptions cannot be renewed."));
return;
}
cupsdMarkDirty(CUPSD_DIRTY_SUBSCRIPTIONS);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
"notify-lease-duration", sub->lease);
int port; /* Port portion of URI */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "restart_job(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "restart_job(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
* See if job is in any of the "completed" states...
*/
- if (job->state_value <= IPP_JOB_PROCESSING)
+ if (job->state_value <= IPP_JSTATE_PROCESSING)
{
/*
* Nope - return a "not possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not complete."),
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Job #%d is not complete."),
jobid);
return;
}
* Nope - return a "not possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d cannot be restarted - no files."), jobid);
return;
}
"Restarted by \"%s\" with job-hold-until=%s.",
username, attr->values[0].string.text);
cupsdSetJobHoldUntil(job, attr->values[0].string.text, 1);
- cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT,
+ cupsdSetJobState(job, IPP_JSTATE_HELD, CUPSD_JOB_DEFAULT,
"Job restarted by user with job-hold-until=%s",
attr->values[0].string.text);
}
cupsdLogJob(job, CUPSD_LOG_INFO, "Restarted by \"%s\".", username);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
int start_job; /* Start the job? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_document(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "send_document(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
#endif /* HAVE_LIBZ */
)
{
- send_ipp_status(con, IPP_ATTRIBUTES, _("Unsupported compression \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported compression \"%s\"."),
attr->values[0].string.text);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
"compression", NULL, attr->values[0].string.text);
if ((attr = ippFindAttribute(con->request, "last-document",
IPP_TAG_BOOLEAN)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Missing last-document attribute in request."));
return;
}
if (job->num_files > 0 && attr->values[0].boolean)
goto last_document;
- send_ipp_status(con, IPP_BAD_REQUEST, _("No file in print request."));
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("No file in print request."));
return;
}
if (sscanf(format->values[0].string.text, "%15[^/]/%255[^;]",
super, type) != 2)
{
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad document-format \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad document-format \"%s\"."),
format->values[0].string.text);
return;
}
if (sscanf(default_format, "%15[^/]/%255[^;]", super, type) != 2)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Bad document-format-default \"%s\"."), default_format);
return;
}
}
else if (!filetype)
{
- send_ipp_status(con, IPP_DOCUMENT_FORMAT,
+ send_ipp_status(con, IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED,
_("Unsupported document-format \"%s/%s\"."), super, type);
cupsdLogMessage(CUPSD_LOG_INFO,
"Hint: Do you have the raw file printing rules enabled?");
snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
filetype->type);
- send_ipp_status(con, IPP_DOCUMENT_FORMAT,
+ send_ipp_status(con, IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED,
_("Unsupported document-format \"%s\"."), mimetype);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
{
cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to rename job document file \"%s\": %s", filename, strerror(errno));
- send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to rename job document file."));
+ send_ipp_status(con, IPP_STATUS_ERROR_INTERNAL, _("Unable to rename job document file."));
return;
}
if (cupsdTimeoutJob(job))
return;
- if (job->state_value == IPP_JOB_STOPPED)
+ if (job->state_value == IPP_JSTATE_STOPPED)
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
ippSetString(job->attrs, &job->reasons, 0, "none");
}
- else if (job->state_value == IPP_JOB_HELD)
+ else if (job->state_value == IPP_JSTATE_HELD)
{
if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
IPP_TAG_KEYWORD)) == NULL)
if (!attr || !strcmp(attr->values[0].string.text, "no-hold"))
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
ippSetString(job->attrs, &job->reasons, 0, "none");
}
if (!attr || !strcmp(attr->values[0].string.text, "no-hold"))
{
- job->state->values[0].integer = IPP_JOB_HELD;
- job->state_value = IPP_JOB_HELD;
+ job->state->values[0].integer = IPP_JSTATE_HELD;
+ job->state_value = IPP_JSTATE_HELD;
job->hold_until = time(NULL) + MultipleOperationTimeout;
ippSetString(job->attrs, &job->reasons, 0, "job-incoming");
ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", (int)job->state_value);
ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, job->reasons->values[0].string.text);
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
/*
* Start the job if necessary...
printer->num_auth_info_required > 0 &&
!strcmp(printer->auth_info_required[0], "negotiate") &&
con->request &&
- (con->request->request.op.operation_id == IPP_PRINT_JOB ||
- con->request->request.op.operation_id == IPP_CREATE_JOB ||
- con->request->request.op.operation_id == CUPS_AUTHENTICATE_JOB))
+ (con->request->request.op.operation_id == IPP_OP_PRINT_JOB ||
+ con->request->request.op.operation_id == IPP_OP_CREATE_JOB ||
+ con->request->request.op.operation_id == IPP_OP_CUPS_AUTHENTICATE_JOB))
{
/*
* Creating and authenticating jobs requires Kerberos...
auth = cupsdFindPolicyOp(printer->op_policy_ptr,
con->request ?
con->request->request.op.operation_id :
- IPP_PRINT_JOB);
+ IPP_OP_PRINT_JOB);
if (auth)
{
*oldprinter; /* Old default printer */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_default(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_default(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
int check_jobs; /* Check jobs? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_job_attrs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_job_attrs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Start with "everything is OK" status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
/*
* See if we have a job URI or a printer URI...
if ((attr = ippFindAttribute(con->request, "job-id",
IPP_TAG_INTEGER)) == NULL)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Got a printer-uri attribute but no job-id."));
return;
}
* Not a valid URI!
*/
- send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST, _("Bad job-uri \"%s\"."),
uri->values[0].string.text);
return;
}
* Nope - return a "not found" error...
*/
- send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND, _("Job #%d does not exist."), jobid);
return;
}
* See if the job has been completed...
*/
- if (job->state_value > IPP_JOB_STOPPED)
+ if (job->state_value > IPP_JSTATE_STOPPED)
{
/*
* Return a "not-possible" error...
*/
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job #%d is finished and cannot be altered."), jobid);
return;
}
* Read-only attrs!
*/
- send_ipp_status(con, IPP_ATTRIBUTES_NOT_SETTABLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_NOT_SETTABLE,
_("%s cannot be changed."), attr->name);
attr2 = ippCopyAttribute(con->response, attr, 0);
check_jobs = 1;
}
else
- cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".", username);
+ cupsdSetJobState(job, IPP_JSTATE_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".", username);
event |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE;
}
if (attr->value_tag != IPP_TAG_INTEGER)
{
- send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-priority value."));
+ send_ipp_status(con, IPP_STATUS_ERROR_REQUEST_VALUE, _("Bad job-priority value."));
attr2 = ippCopyAttribute(con->response, attr, 0);
ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
}
- else if (job->state_value >= IPP_JOB_PROCESSING)
+ else if (job->state_value >= IPP_JSTATE_PROCESSING)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job is completed and cannot be changed."));
return;
}
- else if (con->response->request.status.status_code == IPP_OK)
+ else if (con->response->request.status.status_code == IPP_STATUS_OK)
{
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-priority to %d",
attr->values[0].integer);
if (attr->value_tag != IPP_TAG_ENUM)
{
- send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-state value."));
+ send_ipp_status(con, IPP_STATUS_ERROR_REQUEST_VALUE, _("Bad job-state value."));
attr2 = ippCopyAttribute(con->response, attr, 0);
ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
{
switch (attr->values[0].integer)
{
- case IPP_JOB_PENDING :
- case IPP_JOB_HELD :
- if (job->state_value > IPP_JOB_HELD)
+ case IPP_JSTATE_PENDING :
+ case IPP_JSTATE_HELD :
+ if (job->state_value > IPP_JSTATE_HELD)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job state cannot be changed."));
return;
}
- else if (con->response->request.status.status_code == IPP_OK)
+ else if (con->response->request.status.status_code == IPP_STATUS_OK)
{
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d",
attr->values[0].integer);
}
break;
- case IPP_JOB_PROCESSING :
- case IPP_JOB_STOPPED :
+ case IPP_JSTATE_PROCESSING :
+ case IPP_JSTATE_STOPPED :
if (job->state_value != (ipp_jstate_t)attr->values[0].integer)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job state cannot be changed."));
return;
}
break;
- case IPP_JOB_CANCELED :
- case IPP_JOB_ABORTED :
- case IPP_JOB_COMPLETED :
- if (job->state_value > IPP_JOB_PROCESSING)
+ case IPP_JSTATE_CANCELED :
+ case IPP_JSTATE_ABORTED :
+ case IPP_JSTATE_COMPLETED :
+ if (job->state_value > IPP_JSTATE_PROCESSING)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Job state cannot be changed."));
return;
}
- else if (con->response->request.status.status_code == IPP_OK)
+ else if (con->response->request.status.status_code == IPP_STATUS_OK)
{
cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d",
attr->values[0].integer);
}
}
}
- else if (con->response->request.status.status_code != IPP_OK)
+ else if (con->response->request.status.status_code != IPP_STATUS_OK)
continue;
else if ((attr2 = ippFindAttribute(job->attrs, attr->name,
IPP_TAG_ZERO)) != NULL)
if (event & CUPSD_EVENT_JOB_STATE)
cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job,
- job->state_value == IPP_JOB_HELD ?
+ job->state_value == IPP_JSTATE_HELD ?
"Job held by user." : "Job restarted by user.");
if (event & CUPSD_EVENT_JOB_CONFIG_CHANGED)
int changed = 0; /* Was anything changed? */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_printer_attrs(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_printer_attrs(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
printer->name, get_username(con));
}
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
}
else
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Unknown printer-op-policy \"%s\"."),
attr->values[0].string.text);
return (0);
strcmp(attr->values[0].string.text, "retry-job") &&
strcmp(attr->values[0].string.text, "stop-printer"))))
{
- send_ipp_status(con, IPP_NOT_POSSIBLE,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE,
_("Unknown printer-error-policy \"%s\"."),
attr->values[0].string.text);
return (0);
cupsd_printer_t *printer; /* Printer data */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_printer(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_printer(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
if ((i = check_quotas(con, printer)) < 0)
{
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Quota limit reached."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Quota limit reached."));
return;
}
else if (i == 0)
{
- send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Not allowed to print."));
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_AUTHORIZED, _("Not allowed to print."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
ipp_attribute_t *attr; /* printer-state-message attribute */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "stop_printer(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "stop_printer(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_printer_t *printer; /* Printer */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_job(%p[%d], %s)", con,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_job(%p[%d], %s)", (void *)con,
con->number, uri->values[0].string.text);
/*
#endif /* HAVE_LIBZ */
)
{
- send_ipp_status(con, IPP_ATTRIBUTES,
+ send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,
_("Unsupported 'compression' value \"%s\"."),
attr->values[0].string.text);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
if (sscanf(format->values[0].string.text, "%15[^/]/%255[^;]",
super, type) != 2)
{
- send_ipp_status(con, IPP_BAD_REQUEST,
+ send_ipp_status(con, IPP_STATUS_ERROR_BAD_REQUEST,
_("Bad 'document-format' value \"%s\"."),
format->values[0].string.text);
return;
{
cupsdLogMessage(CUPSD_LOG_INFO,
"Hint: Do you have the raw file printing rules enabled?");
- send_ipp_status(con, IPP_DOCUMENT_FORMAT,
+ send_ipp_status(con, IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED,
_("Unsupported 'document-format' value \"%s\"."),
format->values[0].string.text);
ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
* Bad URI...
*/
- send_ipp_status(con, IPP_NOT_FOUND,
+ send_ipp_status(con, IPP_STATUS_ERROR_NOT_FOUND,
_("The printer or class does not exist."));
return;
}
* Everything was ok, so return OK status...
*/
- con->response->request.status.status_code = IPP_OK;
+ con->response->request.status.status_code = IPP_STATUS_OK;
}
cupsd_printer_t *printer; /* Printer for job */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=" CUPS_LLFMT ")", job->id, con ? con->number : 0, owner ? owner : "(null)", username, CUPS_LLCAST userlen);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "validate_user(job=%d, con=%d, owner=\"%s\", username=%p, userlen=" CUPS_LLFMT ")", job->id, con ? con->number : 0, owner ? owner : "(null)", (void *)username, CUPS_LLCAST userlen);
/*
* Validate input...
*
* We unload the job attributes when they are not needed to reduce overall
* memory consumption. We don't unload jobs where job->state_value <
- * IPP_JOB_STOPPED, job->printer != NULL, or job->access_time is recent.
+ * IPP_JSTATE_STOPPED, job->printer != NULL, or job->access_time is recent.
*
* STARTING OF JOBS (start_job)
*
*/
if (purge)
- cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_PURGE,
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, CUPSD_JOB_PURGE,
"Job purged by user.");
- else if (job->state_value < IPP_JOB_CANCELED)
- cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT,
+ else if (job->state_value < IPP_JSTATE_CANCELED)
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, CUPSD_JOB_DEFAULT,
"Job canceled by user.");
}
}
"cupsdCheckJobs: Job %d - dest=\"%s\", printer=%p, "
"state=%d, cancel_time=%ld, hold_until=%ld, kill_time=%ld, "
"pending_cost=%d, pending_timeout=%ld", job->id, job->dest,
- job->printer, job->state_value, (long)job->cancel_time,
+ (void *)job->printer, job->state_value, (long)job->cancel_time,
(long)job->hold_until, (long)job->kill_time,
job->pending_cost, (long)job->pending_timeout);
cancel_after = attr ? ippGetInteger(attr, 0) : MaxJobTime;
if (job->completed)
- cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_FORCE, "Marking stuck job as completed after %d seconds.", cancel_after);
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, CUPSD_JOB_FORCE, "Marking stuck job as completed after %d seconds.", cancel_after);
else
- cupsdSetJobState(job, IPP_JOB_CANCELED, CUPSD_JOB_DEFAULT, "Canceling stuck job after %d seconds.", cancel_after);
+ cupsdSetJobState(job, IPP_JSTATE_CANCELED, CUPSD_JOB_DEFAULT, "Canceling stuck job after %d seconds.", cancel_after);
continue;
}
* Start held jobs if they are ready...
*/
- if (job->state_value == IPP_JOB_HELD &&
+ if (job->state_value == IPP_JSTATE_HELD &&
job->hold_until &&
job->hold_until < curtime)
{
con;
con = (cupsd_client_t *)cupsArrayNext(Clients))
if (con->request &&
- con->request->request.op.operation_id == IPP_SEND_DOCUMENT)
+ con->request->request.op.operation_id == IPP_OP_SEND_DOCUMENT)
break;
if (con)
if (cupsdTimeoutJob(job))
continue;
- cupsdSetJobState(job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT, "Job submission timed out.");
+ cupsdSetJobState(job, IPP_JSTATE_PENDING, CUPSD_JOB_DEFAULT, "Job submission timed out.");
cupsdLogJob(job, CUPSD_LOG_ERROR, "Job submission timed out.");
}
else
- cupsdSetJobState(job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT, "Job hold expired.");
+ cupsdSetJobState(job, IPP_JSTATE_PENDING, CUPSD_JOB_DEFAULT, "Job hold expired.");
}
/*
* Start pending jobs if the destination is available...
*/
- if (job->state_value == IPP_JOB_PENDING && !NeedReload &&
+ if (job->state_value == IPP_JSTATE_PENDING && !NeedReload &&
(!Sleeping || ACPower) && !DoingShutdown && !job->printer)
{
printer = cupsdFindDest(job->dest);
pclass = printer;
- if (pclass->state == IPP_PRINTER_STOPPED)
+ if (pclass->state == IPP_PSTATE_STOPPED)
printer = NULL;
else if (pclass->type & CUPS_PRINTER_REMOTE)
break;
* cancel the job...
*/
- cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE,
+ cupsdSetJobState(job, IPP_JSTATE_ABORTED, CUPSD_JOB_PURGE,
"Job aborted because the destination printer/class "
"has gone away.");
}
cupsdMarkDirty(CUPSD_DIRTY_JOBS);
}
- if (!printer->job && printer->state == IPP_PRINTER_IDLE)
+ if (!printer->job && printer->state == IPP_PSTATE_IDLE)
{
/*
* Start the job...
if (job->num_files > 0 && ((job->file_time && job->file_time < JobHistoryUpdate) || !JobHistoryUpdate))
JobHistoryUpdate = job->file_time;
- if (job->state_value >= IPP_JOB_CANCELED && !job->printer)
+ if (job->state_value >= IPP_JSTATE_CANCELED && !job->printer)
{
/*
* Expire old jobs (or job files)...
ipp_attribute_t *attr; /* Current attribute */
const char *ptr, /* Pointer into value */
*abort_message; /* Abort message */
- ipp_jstate_t abort_state = IPP_JOB_STOPPED;
+ ipp_jstate_t abort_state = IPP_JSTATE_STOPPED;
/* New job state on abort */
struct stat backinfo; /* Backend file information */
int backroot; /* Run backend as root? */
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdContinueJob(job=%p(%d)): current_file=%d, num_files=%d",
- job, job->id, job->current_file, job->num_files);
+ (void *)job, job->id, job->current_file, job->num_files);
/*
* Figure out what filters are required to convert from
job->current_file);
abort_message = "Aborting job because it cannot be printed.";
- abort_state = IPP_JOB_ABORTED;
+ abort_state = IPP_JSTATE_ABORTED;
ippSetString(job->attrs, &job->reasons, 0, "document-unprintable-error");
cupsArrayCount(filters), MAX_FILTERS);
abort_message = "Aborting job because it needs too many filters to print.";
- abort_state = IPP_JOB_ABORTED;
+ abort_state = IPP_JSTATE_ABORTED;
ippSetString(job->attrs, &job->reasons, 0, "document-unprintable-error");
*/
cupsdSetJobState(job, abort_state, CUPSD_JOB_DEFAULT, "%s", abort_message);
- cupsdSetPrinterState(job->printer, IPP_PRINTER_IDLE, 0);
+ cupsdSetPrinterState(job->printer, IPP_PSTATE_IDLE, 0);
update_job_attrs(job, 0);
if (job->history)
for (job = (cupsd_job_t *)cupsArrayFirst(Jobs);
job;
job = (cupsd_job_t *)cupsArrayNext(Jobs))
- if ((!p || !_cups_strcasecmp(p->name, job->dest)) && job->state_value >= IPP_JOB_STOPPED && job->completed_time)
+ if ((!p || !_cups_strcasecmp(p->name, job->dest)) && job->state_value >= IPP_JSTATE_STOPPED && job->completed_time)
cupsArrayAdd(list, job);
return (list);
if (job->attrs)
{
- if (job->state_value > IPP_JOB_STOPPED)
+ if (job->state_value > IPP_JSTATE_STOPPED)
job->access_time = time(NULL);
return (1);
if ((fp = cupsdOpenConfFile(jobfile)) == NULL)
goto error;
- if (ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, job->attrs) != IPP_DATA)
+ if (ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, job->attrs) != IPP_STATE_DATA)
{
cupsdLogJob(job, CUPSD_LOG_ERROR,
"Unable to read job control file \"%s\".", jobfile);
if ((attr = ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER)) != NULL)
job->creation_time = attr->values[0].integer;
- if (job->state_value >= IPP_JOB_CANCELED && (attr = ippFindAttribute(job->attrs, "time-at-completed", IPP_TAG_INTEGER)) != NULL)
+ if (job->state_value >= IPP_JSTATE_CANCELED && (attr = ippFindAttribute(job->attrs, "time-at-completed", IPP_TAG_INTEGER)) != NULL)
{
job->completed_time = attr->values[0].integer;
switch (job->state_value)
{
default :
- case IPP_JOB_PENDING :
- if (destptr->state == IPP_PRINTER_STOPPED)
+ case IPP_JSTATE_PENDING :
+ if (destptr->state == IPP_PSTATE_STOPPED)
reason = "printer-stopped";
else
reason = "none";
break;
- case IPP_JOB_HELD :
+ case IPP_JSTATE_HELD :
if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
IPP_TAG_ZERO)) != NULL &&
(attr->value_tag == IPP_TAG_NAME ||
reason = "job-incoming";
break;
- case IPP_JOB_PROCESSING :
+ case IPP_JSTATE_PROCESSING :
reason = "job-printing";
break;
- case IPP_JOB_STOPPED :
+ case IPP_JSTATE_STOPPED :
reason = "job-stopped";
break;
- case IPP_JOB_CANCELED :
+ case IPP_JSTATE_CANCELED :
reason = "job-canceled-by-user";
break;
- case IPP_JOB_ABORTED :
+ case IPP_JSTATE_ABORTED :
reason = "aborted-by-system";
break;
- case IPP_JOB_COMPLETED :
+ case IPP_JSTATE_COMPLETED :
reason = "job-completed-successfully";
break;
}
job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD,
"job-state-reasons", NULL, reason);
}
- else if (job->state_value == IPP_JOB_PENDING)
+ else if (job->state_value == IPP_JSTATE_PENDING)
{
- if (destptr->state == IPP_PRINTER_STOPPED)
+ if (destptr->state == IPP_PSTATE_STOPPED)
ippSetString(job->attrs, &job->reasons, 0, "printer-stopped");
else
ippSetString(job->attrs, &job->reasons, 0, "none");
* Set the job hold-until time and state...
*/
- if (job->state_value == IPP_JOB_HELD)
+ if (job->state_value == IPP_JSTATE_HELD)
{
if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
IPP_TAG_KEYWORD)) == NULL)
cupsdSetJobHoldUntil(job, attr->values[0].string.text, CUPSD_JOB_DEFAULT);
else
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
}
}
- else if (job->state_value == IPP_JOB_PROCESSING)
+ else if (job->state_value == IPP_JSTATE_PROCESSING)
{
- job->state->values[0].integer = IPP_JOB_PENDING;
- job->state_value = IPP_JOB_PENDING;
+ job->state->values[0].integer = IPP_JSTATE_PENDING;
+ job->state_value = IPP_JSTATE_PENDING;
}
if ((attr = ippFindAttribute(job->attrs, "job-k-octets", IPP_TAG_INTEGER)) != NULL)
* Load authentication information as needed...
*/
- if (job->state_value < IPP_JOB_STOPPED)
+ if (job->state_value < IPP_JSTATE_STOPPED)
{
snprintf(jobfile, sizeof(jobfile), "%s/a%05d", RequestRoot, job->id);
* Don't move completed jobs...
*/
- if (job->state_value > IPP_JOB_STOPPED)
+ if (job->state_value > IPP_JSTATE_STOPPED)
return;
/*
* Change the destination information...
*/
- if (job->state_value > IPP_JOB_HELD)
- cupsdSetJobState(job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT,
+ if (job->state_value > IPP_JSTATE_HELD)
+ cupsdSetJobState(job, IPP_JSTATE_PENDING, CUPSD_JOB_DEFAULT,
"Stopping job prior to move.");
cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, oldp, job,
void
cupsdReleaseJob(cupsd_job_t *job) /* I - Job */
{
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReleaseJob(job=%p(%d))", job,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdReleaseJob(job=%p(%d))", (void *)job,
job->id);
- if (job->state_value == IPP_JOB_HELD)
+ if (job->state_value == IPP_JSTATE_HELD)
{
/*
* Add trailing banner as needed...
if (job->pending_timeout)
cupsdTimeoutJob(job);
- cupsdSetJobState(job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT,
+ cupsdSetJobState(job, IPP_JSTATE_PENDING, CUPSD_JOB_DEFAULT,
"Job released by user.");
}
}
void
cupsdRestartJob(cupsd_job_t *job) /* I - Job */
{
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdRestartJob(job=%p(%d))", job,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdRestartJob(job=%p(%d))", (void *)job,
job->id);
- if (job->state_value == IPP_JOB_STOPPED || job->num_files)
- cupsdSetJobState(job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT,
+ if (job->state_value == IPP_JSTATE_STOPPED || job->num_files)
+ cupsdSetJobState(job, IPP_JSTATE_PENDING, CUPSD_JOB_DEFAULT,
"Job restarted by user.");
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdSaveJob(job=%p(%d)): job->attrs=%p",
- job, job->id, job->attrs);
+ (void *)job, job->id, (void *)job->attrs);
if (job->printer && job->printer->temporary)
{
fchown(cupsFileNumber(fp), RunUser, Group);
- job->attrs->state = IPP_IDLE;
+ job->attrs->state = IPP_STATE_IDLE;
if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
- job->attrs) != IPP_DATA)
+ job->attrs) != IPP_STATE_DATA)
{
cupsdLogJob(job, CUPSD_LOG_ERROR, "Unable to write job control file.");
cupsFileClose(fp);
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdSetJobHoldUntil(job=%p(%d), when=\"%s\", update=%d)",
- job, job->id, when, update);
+ (void *)job, job->id, when, update);
if (update)
{
* Don't change completed jobs...
*/
- if (job->state_value >= IPP_JOB_PROCESSING)
+ if (job->state_value >= IPP_JSTATE_PROCESSING)
return;
/*
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdSetJobState(job=%p(%d), state=%d, newstate=%d, "
- "action=%d, message=\"%s\")", job, job->id, job->state_value,
+ "action=%d, message=\"%s\")", (void *)job, job->id, job->state_value,
newstate, action, message ? message : "(null)");
* Stop any processes that are working on the current job...
*/
- if (oldstate == IPP_JOB_PROCESSING)
+ if (oldstate == IPP_JSTATE_PROCESSING)
stop_job(job, action);
/*
switch (newstate)
{
- case IPP_JOB_PENDING :
+ case IPP_JSTATE_PENDING :
/*
* Update job-hold-until as needed...
*/
default :
break;
- case IPP_JOB_ABORTED :
- case IPP_JOB_CANCELED :
- case IPP_JOB_COMPLETED :
+ case IPP_JSTATE_ABORTED :
+ case IPP_JSTATE_CANCELED :
+ case IPP_JSTATE_COMPLETED :
set_time(job, "time-at-completed");
ippSetString(job->attrs, &job->reasons, 0, "processing-to-stop-point");
break;
vsnprintf(buffer, sizeof(buffer), message, ap);
va_end(ap);
- if (newstate > IPP_JOB_STOPPED)
+ if (newstate > IPP_JSTATE_STOPPED)
cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, "%s", buffer);
else
cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, "%s", buffer);
- if (newstate == IPP_JOB_STOPPED || newstate == IPP_JOB_ABORTED)
+ if (newstate == IPP_JSTATE_STOPPED || newstate == IPP_JSTATE_ABORTED)
cupsdLogJob(job, CUPSD_LOG_ERROR, "%s", buffer);
else
cupsdLogJob(job, CUPSD_LOG_INFO, "%s", buffer);
switch (newstate)
{
- case IPP_JOB_PROCESSING :
+ case IPP_JSTATE_PROCESSING :
/*
* Add the job to the "printing" list...
*/
set_time(job, "time-at-processing");
- case IPP_JOB_PENDING :
- case IPP_JOB_HELD :
- case IPP_JOB_STOPPED :
+ case IPP_JSTATE_PENDING :
+ case IPP_JSTATE_HELD :
+ case IPP_JSTATE_STOPPED :
/*
* Make sure the job is in the active list...
*/
cupsdMarkDirty(CUPSD_DIRTY_JOBS);
break;
- case IPP_JOB_ABORTED :
- case IPP_JOB_CANCELED :
- case IPP_JOB_COMPLETED :
- if (newstate == IPP_JOB_CANCELED)
+ case IPP_JSTATE_ABORTED :
+ case IPP_JSTATE_CANCELED :
+ case IPP_JSTATE_COMPLETED :
+ if (newstate == IPP_JSTATE_CANCELED)
{
/*
* Remove the job from the active list if there are no processes still
{
if (job->completed)
{
- cupsdSetJobState(job, IPP_JOB_COMPLETED, CUPSD_JOB_FORCE, NULL);
+ cupsdSetJobState(job, IPP_JSTATE_COMPLETED, CUPSD_JOB_FORCE, NULL);
}
else
{
if (kill_delay)
job->kill_time = time(NULL) + kill_delay;
- cupsdSetJobState(job, IPP_JOB_PENDING, action, NULL);
+ cupsdSetJobState(job, IPP_JSTATE_PENDING, action, NULL);
}
}
}
for (job = (cupsd_job_t *)cupsArrayFirst(Jobs);
job;
job = (cupsd_job_t *)cupsArrayNext(Jobs))
- if (job->attrs && job->state_value >= IPP_JOB_STOPPED && !job->printer &&
+ if (job->attrs && job->state_value >= IPP_JSTATE_STOPPED && !job->printer &&
job->access_time < expire)
{
if (job->dirty)
job;
job = (cupsd_job_t *)cupsArrayNext(Jobs))
{
- if (job->state_value >= IPP_JOB_CANCELED &&
+ if (job->state_value >= IPP_JSTATE_CANCELED &&
(attr = ippFindAttribute(job->attrs, "time-at-completed",
IPP_TAG_INTEGER)) != NULL)
{
{
snprintf(temp, sizeof(temp), "[Job %d] printer-state=%d(%s)", job->id,
printer->state,
- printer->state == IPP_PRINTER_IDLE ? "idle" :
- printer->state == IPP_PRINTER_PROCESSING ? "processing" :
+ printer->state == IPP_PSTATE_IDLE ? "idle" :
+ printer->state == IPP_PSTATE_PROCESSING ? "processing" :
"stopped");
cupsdWriteErrorLog(CUPSD_LOG_DEBUG, temp);
char scheme[255]; /* Device URI scheme */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "finalize_job(job=%p(%d))", job, job->id);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "finalize_job(job=%p(%d))", (void *)job, job->id);
sscanf(job->printer->device_uri, "%254[^:]", scheme);
/*
* Process the exit status...
*/
- if (job->printer->state == IPP_PRINTER_PROCESSING)
- printer_state = IPP_PRINTER_IDLE;
+ if (job->printer->state == IPP_PSTATE_PROCESSING)
+ printer_state = IPP_PSTATE_IDLE;
else
printer_state = job->printer->state;
switch (job_state = job->state_value)
{
- case IPP_JOB_PENDING :
+ case IPP_JSTATE_PENDING :
message = "Job paused.";
break;
- case IPP_JOB_HELD :
+ case IPP_JSTATE_HELD :
message = "Job held.";
break;
default :
- case IPP_JOB_PROCESSING :
- case IPP_JOB_COMPLETED :
- job_state = IPP_JOB_COMPLETED;
+ case IPP_JSTATE_PROCESSING :
+ case IPP_JSTATE_COMPLETED :
+ job_state = IPP_JSTATE_COMPLETED;
message = "Job completed.";
if (!job->status)
"job-completed-successfully");
break;
- case IPP_JOB_STOPPED :
+ case IPP_JSTATE_STOPPED :
message = "Job stopped.";
ippSetString(job->attrs, &job->reasons, 0, "job-stopped");
break;
- case IPP_JOB_CANCELED :
+ case IPP_JSTATE_CANCELED :
message = "Job canceled.";
ippSetString(job->attrs, &job->reasons, 0, "job-canceled-by-user");
break;
- case IPP_JOB_ABORTED :
+ case IPP_JSTATE_ABORTED :
message = "Job aborted.";
break;
}
* another printer...
*/
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_PENDING;
+ job_state = IPP_JSTATE_PENDING;
message = "Retrying job on another printer.";
ippSetString(job->attrs, &job->reasons, 0,
* and we'll retry on the same printer...
*/
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_PENDING;
+ job_state = IPP_JSTATE_PENDING;
message = "Retrying job on same printer.";
ippSetString(job->attrs, &job->reasons, 0, "none");
else if ((job->printer->type & CUPS_PRINTER_FAX) ||
!strcmp(job->printer->error_policy, "retry-job"))
{
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
/*
* The job was queued on a fax or the error policy is "retry-job" -
snprintf(buffer, sizeof(buffer),
"Job aborted after %d unsuccessful attempts.",
JobRetryLimit);
- job_state = IPP_JOB_ABORTED;
+ job_state = IPP_JSTATE_ABORTED;
message = buffer;
ippSetString(job->attrs, &job->reasons, 0, "aborted-by-system");
JobRetryInterval);
job->hold_until = time(NULL) + JobRetryInterval;
- job_state = IPP_JOB_HELD;
+ job_state = IPP_JSTATE_HELD;
message = buffer;
ippSetString(job->attrs, &job->reasons, 0,
}
}
else if (!strcmp(job->printer->error_policy, "abort-job") &&
- job_state == IPP_JOB_COMPLETED)
+ job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_ABORTED;
+ job_state = IPP_JSTATE_ABORTED;
if (ErrorLog)
{
ippSetString(job->attrs, &job->reasons, 0, "aborted-by-system");
}
- else if (job->state_value == IPP_JOB_PROCESSING)
+ else if (job->state_value == IPP_JSTATE_PROCESSING)
{
- job_state = IPP_JOB_PENDING;
- printer_state = IPP_PRINTER_STOPPED;
+ job_state = IPP_JSTATE_PENDING;
+ printer_state = IPP_PSTATE_STOPPED;
if (ErrorLog)
{
* Cancel the job...
*/
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_CANCELED;
+ job_state = IPP_JSTATE_CANCELED;
message = "Job canceled at printer.";
ippSetString(job->attrs, &job->reasons, 0, "canceled-at-device");
break;
case CUPS_BACKEND_HOLD :
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
/*
* Hold the job...
message = "Job held indefinitely - account authorization failed.";
}
- job_state = IPP_JOB_HELD;
+ job_state = IPP_JSTATE_HELD;
}
break;
break;
}
- printer_state = IPP_PRINTER_STOPPED;
+ printer_state = IPP_PSTATE_STOPPED;
if (ErrorLog)
{
else
message = "Printer stopped due to backend errors.";
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_PENDING;
+ job_state = IPP_JSTATE_PENDING;
ippSetString(job->attrs, &job->reasons, 0, "resources-are-not-ready");
}
* Hold the job for authentication...
*/
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
cupsdSetJobHoldUntil(job, "auth-info-required", 1);
- job_state = IPP_JOB_HELD;
+ job_state = IPP_JSTATE_HELD;
message = "Job held for authentication.";
if (strncmp(job->reasons->values[0].string.text, "account-", 8))
break;
case CUPS_BACKEND_RETRY :
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
/*
* Hold the job if the number of retries is less than the
snprintf(buffer, sizeof(buffer),
"Job aborted after %d unsuccessful attempts.",
JobRetryLimit);
- job_state = IPP_JOB_ABORTED;
+ job_state = IPP_JSTATE_ABORTED;
message = buffer;
ippSetString(job->attrs, &job->reasons, 0, "aborted-by-system");
JobRetryInterval);
job->hold_until = time(NULL) + JobRetryInterval;
- job_state = IPP_JOB_HELD;
+ job_state = IPP_JSTATE_HELD;
message = buffer;
ippSetString(job->attrs, &job->reasons, 0,
* Mark the job as pending and retry on the same printer...
*/
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_PENDING;
+ job_state = IPP_JSTATE_PENDING;
message = "Retrying job on same printer.";
ippSetString(job->attrs, &job->reasons, 0, "none");
* Filter had errors; stop job...
*/
- if (job_state == IPP_JOB_COMPLETED)
+ if (job_state == IPP_JSTATE_COMPLETED)
{
- job_state = IPP_JOB_STOPPED;
+ job_state = IPP_JSTATE_STOPPED;
if (ErrorLog)
{
cupsdSetJobState(job, job_state, CUPSD_JOB_DEFAULT, "%s", message);
cupsdSetPrinterState(job->printer, printer_state,
- printer_state == IPP_PRINTER_STOPPED);
+ printer_state == IPP_PSTATE_STOPPED);
update_job_attrs(job, 0);
if (job->history)
{
if (job->status &&
- (job->state_value == IPP_JOB_ABORTED ||
- job->state_value == IPP_JOB_STOPPED))
+ (job->state_value == IPP_JSTATE_ABORTED ||
+ job->state_value == IPP_JSTATE_STOPPED))
dump_job_history(job);
else
free_job_history(job);
{
cupsArrayAdd(Jobs, job);
- if (job->state_value <= IPP_JOB_STOPPED && cupsdLoadJob(job))
+ if (job->state_value <= IPP_JSTATE_STOPPED && cupsdLoadJob(job))
cupsArrayAdd(ActiveJobs, job);
- else if (job->state_value > IPP_JOB_STOPPED)
+ else if (job->state_value > IPP_JSTATE_STOPPED)
{
if (!job->completed_time || !job->creation_time || !job->name || !job->koctets)
{
{
job->state_value = (ipp_jstate_t)atoi(value);
- if (job->state_value < IPP_JOB_PENDING)
- job->state_value = IPP_JOB_PENDING;
- else if (job->state_value > IPP_JOB_COMPLETED)
- job->state_value = IPP_JOB_COMPLETED;
+ if (job->state_value < IPP_JSTATE_PENDING)
+ job->state_value = IPP_JSTATE_PENDING;
+ else if (job->state_value > IPP_JSTATE_COMPLETED)
+ job->state_value = IPP_JSTATE_COMPLETED;
}
else if (!_cups_strcasecmp(line, "Name"))
{
cupsArrayAdd(Jobs, job);
- if (job->state_value <= IPP_JOB_STOPPED)
+ if (job->state_value <= IPP_JSTATE_STOPPED)
cupsArrayAdd(ActiveJobs, job);
else
unload_job(job);
cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job(job=%p(%d), printer=%p(%s))",
- job, job->id, printer, printer->name);
+ (void *)job, job->id, (void *)printer, printer->name);
/*
* Make sure we have some files around before we try to print...
if (job->num_files == 0)
{
ippSetString(job->attrs, &job->reasons, 0, "aborted-by-system");
- cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_DEFAULT,
+ cupsdSetJobState(job, IPP_JSTATE_ABORTED, CUPSD_JOB_DEFAULT,
"Aborting job because it has no files.");
return;
}
ippSetString(job->attrs, &job->printer_message, 0, "");
ippSetString(job->attrs, &job->reasons, 0, "job-printing");
- cupsdSetJobState(job, IPP_JOB_PROCESSING, CUPSD_JOB_DEFAULT, NULL);
- cupsdSetPrinterState(printer, IPP_PRINTER_PROCESSING, 0);
+ cupsdSetJobState(job, IPP_JSTATE_PROCESSING, CUPSD_JOB_DEFAULT, NULL);
+ cupsdSetPrinterState(printer, IPP_PSTATE_PROCESSING, 0);
cupsdSetPrinterReasons(printer, "-cups-remote-pending,"
"cups-remote-pending-held,"
"cups-remote-processing,"
cupsdLogJob(job, CUPSD_LOG_DEBUG,
"Unable to create job status pipes - %s.", strerror(errno));
- cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
+ cupsdSetJobState(job, IPP_JSTATE_STOPPED, CUPSD_JOB_DEFAULT,
"Job stopped because the scheduler could not create the "
"job status pipes.");
cupsdLogJob(job, CUPSD_LOG_DEBUG,
"Unable to create back-channel pipes - %s.", strerror(errno));
- cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
+ cupsdSetJobState(job, IPP_JSTATE_STOPPED, CUPSD_JOB_DEFAULT,
"Job stopped because the scheduler could not create the "
"back-channel pipes.");
cupsdLogJob(job, CUPSD_LOG_DEBUG,
"Unable to create side-channel pipes - %s.", strerror(errno));
- cupsdSetJobState(job, IPP_JOB_STOPPED, CUPSD_JOB_DEFAULT,
+ cupsdSetJobState(job, IPP_JSTATE_STOPPED, CUPSD_JOB_DEFAULT,
"Job stopped because the scheduler could not create the "
"side-channel pipes.");
int i; /* Looping var */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "stop_job(job=%p(%d), action=%d)", job,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "stop_job(job=%p(%d), action=%d)", (void *)job,
job->id, action);
FilterLevel -= job->cost;
* Try printing another job...
*/
- if (printer->state != IPP_PRINTER_STOPPED)
+ if (printer->state != IPP_PSTATE_STOPPED)
cupsdCheckJobs();
}
}
* Copy or clear the printer-state-message value as needed...
*/
- if (job->state_value != IPP_JOB_PROCESSING &&
+ if (job->state_value != IPP_JSTATE_PROCESSING &&
job->status_level == CUPSD_LOG_INFO)
{
ippSetString(job->attrs, &job->printer_message, 0, "");
return (1);
if (con->request && con->response &&
- (con->response->request.status.status_code < IPP_REDIRECTION_OTHER_SITE ||
- con->response->request.status.status_code == IPP_NOT_FOUND))
+ (con->response->request.status.status_code < IPP_STATUS_REDIRECTION_OTHER_SITE ||
+ con->response->request.status.status_code == IPP_STATUS_ERROR_NOT_FOUND))
{
/*
* Check successful requests...
};
- if ((op <= IPP_SCHEDULE_JOB_AFTER && standard_ops[op] > AccessLogLevel) ||
- (op >= CUPS_GET_DEFAULT && op <= CUPS_GET_PPD &&
- cups_ops[op - CUPS_GET_DEFAULT] > AccessLogLevel))
+ if ((op <= IPP_OP_SCHEDULE_JOB_AFTER && standard_ops[op] > AccessLogLevel) ||
+ (op >= IPP_OP_CUPS_GET_DEFAULT && op <= IPP_OP_CUPS_GET_PPD &&
+ cups_ops[op - IPP_OP_CUPS_GET_DEFAULT] > AccessLogLevel))
return (1);
}
}
job->status = -status; /* Backend failed */
if (job->current_file < job->num_files)
- cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_FORCE, "Canceling multi-file job due to backend failure.");
+ cupsdSetJobState(job, IPP_JSTATE_ABORTED, CUPSD_JOB_FORCE, "Canceling multi-file job due to backend failure.");
}
}
- if (job->state_value == IPP_JOB_PROCESSING &&
+ if (job->state_value == IPP_JSTATE_PROCESSING &&
job->status_level > CUPSD_LOG_ERROR &&
(job->filters[i] || !WIFEXITED(status)))
{
* filters are done, and if so move to the next file.
*/
- if (job->state_value >= IPP_JOB_CANCELED)
+ if (job->state_value >= IPP_JSTATE_CANCELED)
{
/*
* Remove the job from the active list if there are no processes still
why = "kill unresponsive jobs";
}
- if (job->state_value == IPP_JOB_HELD && job->hold_until < timeout)
+ if (job->state_value == IPP_JSTATE_HELD && job->hold_until < timeout)
{
timeout = job->hold_until;
why = "release held jobs";
}
- if (job->state_value == IPP_JOB_PENDING && timeout > (now + 10))
+ if (job->state_value == IPP_JSTATE_PENDING && timeout > (now + 10))
{
timeout = now + 10;
why = "start pending jobs";
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddPolicyOp(p=%p, po=%p, op=%x(%s))",
- p, po, op, ippOpString(op));
+ (void *)p, (void *)po, op, ippOpString(op));
if (!p)
return (NULL);
if (!p || !con)
{
- cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdCheckPolicy: p=%p, con=%p.", p, con);
+ cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdCheckPolicy: p=%p, con=%p.", (void *)p, (void *)con);
return (HTTP_STATUS_SERVER_ERROR);
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFindPolicyOp(p=%p, op=%x(%s))",
- p, op, ippOpString(op));
+ (void *)p, op, ippOpString(op));
/*
* Range check...
#ifdef DEBUG
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdGetPrivateAttrs(policy=%p(%s), con=%p(%d), "
- "printer=%p(%s), owner=\"%s\")", policy, policy ? policy->name : "", con,
- con->number, printer, printer ? printer->name : "", owner);
+ "printer=%p(%s), owner=\"%s\")", (void *)policy, policy ? policy->name : "", (void *)con,
+ con->number, (void *)printer, printer ? printer->name : "", owner);
#endif /* DEBUG */
if (!policy)
{
- cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdGetPrivateAttrs: policy=%p, con=%p, printer=%p, owner=\"%s\", DefaultPolicyPtr=%p: This should never happen, please report a bug.", policy, con, printer, owner, DefaultPolicyPtr);
+ cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdGetPrivateAttrs: policy=%p, con=%p, printer=%p, owner=\"%s\", DefaultPolicyPtr=%p: This should never happen, please report a bug.", (void *)policy, (void *)con, (void *)printer, owner, (void *)DefaultPolicyPtr);
policy = DefaultPolicyPtr;
}
switch (con->request->request.op.operation_id)
{
- case IPP_GET_SUBSCRIPTIONS :
- case IPP_GET_SUBSCRIPTION_ATTRIBUTES :
- case IPP_GET_NOTIFICATIONS :
+ case IPP_OP_GET_SUBSCRIPTIONS :
+ case IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES :
+ case IPP_OP_GET_NOTIFICATIONS :
access_ptr = policy->sub_access;
attrs_ptr = policy->sub_attrs;
break;
cupsdSetDeviceURI(p, "file:///dev/null");
p->config_time = time(NULL);
- p->state = IPP_PRINTER_STOPPED;
+ p->state = IPP_PSTATE_STOPPED;
p->state_time = time(NULL);
p->accepting = 0;
p->shared = DefaultShared;
};
static const int orients[4] =/* orientation-requested-supported values */
{
- IPP_PORTRAIT,
- IPP_LANDSCAPE,
- IPP_REVERSE_LANDSCAPE,
- IPP_REVERSE_PORTRAIT
+ IPP_ORIENT_PORTRAIT,
+ IPP_ORIENT_LANDSCAPE,
+ IPP_ORIENT_REVERSE_LANDSCAPE,
+ IPP_ORIENT_REVERSE_PORTRAIT
};
static const char * const holds[] = /* job-hold-until-supported values */
{
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdDeletePrinter(p=%p(%s), update=%d)",
- p, p->name, update);
+ (void *)p, p->name, update);
/*
* Save the current position in the Printers array...
* Stop printing on this printer...
*/
- cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update);
+ cupsdSetPrinterState(p, IPP_PSTATE_STOPPED, update);
- p->state = IPP_PRINTER_STOPPED; /* Force for browsed printers */
+ p->state = IPP_PSTATE_STOPPED; /* Force for browsed printers */
if (p->job)
- cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+ cupsdSetJobState(p->job, IPP_JSTATE_PENDING, CUPSD_JOB_FORCE,
update ? "Job stopped due to printer being deleted." :
"Job stopped.");
p = cupsdAddPrinter(value);
p->accepting = 1;
- p->state = IPP_PRINTER_IDLE;
+ p->state = IPP_PSTATE_IDLE;
/*
* Set the default printer as needed...
}
}
- if (strncmp(p->device_uri, "file:", 5) && p->state != IPP_PRINTER_STOPPED)
+ if (strncmp(p->device_uri, "file:", 5) && p->state != IPP_PSTATE_STOPPED)
{
/*
* See if the backend exists...
* Backend does not exist, stop printer...
*/
- p->state = IPP_PRINTER_STOPPED;
+ p->state = IPP_PSTATE_STOPPED;
snprintf(p->state_message, sizeof(p->state_message), "Backend %s does not exist!", line);
}
}
*/
if (value && !_cups_strcasecmp(value, "idle"))
- p->state = IPP_PRINTER_IDLE;
+ p->state = IPP_PSTATE_IDLE;
else if (value && !_cups_strcasecmp(value, "stopped"))
{
- p->state = IPP_PRINTER_STOPPED;
+ p->state = IPP_PSTATE_STOPPED;
for (i = 0 ; i < p->num_reasons; i ++)
if (!strcmp("paused", p->reasons[i]))
if (printer->port_monitor)
cupsFilePutConf(fp, "PortMonitor", printer->port_monitor);
- if (printer->state == IPP_PRINTER_STOPPED)
+ if (printer->state == IPP_PSTATE_STOPPED)
{
cupsFilePuts(fp, "State Stopped\n");
if ((auth = cupsdFindBest(resource, HTTP_STATE_POST)) == NULL ||
auth->type == CUPSD_AUTH_NONE)
- auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB);
+ auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_OP_PRINT_JOB);
if (auth)
{
cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdSetPrinterReasons(p=%p(%s),s=\"%s\"", p, p->name, s);
+ "cupsdSetPrinterReasons(p=%p(%s),s=\"%s\"", (void *)p, p->name, s);
if (s[0] == '-' || s[0] == '+')
{
if (i < p->num_reasons)
memmove(p->reasons + i, p->reasons + i + 1, (size_t)(p->num_reasons - i) * sizeof(char *));
- if (!strcmp(reason, "paused") && p->state == IPP_PRINTER_STOPPED)
- cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
+ if (!strcmp(reason, "paused") && p->state == IPP_PSTATE_STOPPED)
+ cupsdSetPrinterState(p, IPP_PSTATE_IDLE, 1);
if (!strcmp(reason, "cups-waiting-for-job-completed") && p->job)
p->job->completed = 0;
p->num_reasons ++;
changed = 1;
- if (!strcmp(reason, "paused") && p->state != IPP_PRINTER_STOPPED)
- cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, 1);
+ if (!strcmp(reason, "paused") && p->state != IPP_PSTATE_STOPPED)
+ cupsdSetPrinterState(p, IPP_PSTATE_STOPPED, 1);
if (!strcmp(reason, "cups-waiting-for-job-completed") && p->job)
p->job->completed = 1;
if (old_state != s)
{
- cupsdAddEvent(s == IPP_PRINTER_STOPPED ? CUPSD_EVENT_PRINTER_STOPPED :
+ cupsdAddEvent(s == IPP_PSTATE_STOPPED ? CUPSD_EVENT_PRINTER_STOPPED :
CUPSD_EVENT_PRINTER_STATE, p, NULL,
"%s \"%s\" state changed to %s.",
(p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer",
- p->name, printer_states[p->state - IPP_PRINTER_IDLE]);
+ p->name, printer_states[p->state - IPP_PSTATE_IDLE]);
/*
* Let the browse code know this needs to be updated...
* Set/clear the paused reason as needed...
*/
- if (s == IPP_PRINTER_STOPPED)
+ if (s == IPP_PSTATE_STOPPED)
cupsdSetPrinterReasons(p, "+paused");
else
cupsdSetPrinterReasons(p, "-paused");
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
- if (job->reasons && job->state_value == IPP_JOB_PENDING &&
+ if (job->reasons && job->state_value == IPP_JSTATE_PENDING &&
!_cups_strcasecmp(job->dest, p->name))
ippSetString(job->attrs, &job->reasons, 0,
- s == IPP_PRINTER_STOPPED ? "printer-stopped" : "none");
+ s == IPP_PSTATE_STOPPED ? "printer-stopped" : "none");
}
/*
* Clear the message for the queue when going to processing...
*/
- if (s == IPP_PRINTER_PROCESSING)
+ if (s == IPP_PSTATE_PROCESSING)
p->state_message[0] = '\0';
/*
*/
if (update &&
- (old_state == IPP_PRINTER_STOPPED) != (s == IPP_PRINTER_STOPPED))
+ (old_state == IPP_PSTATE_STOPPED) != (s == IPP_PSTATE_STOPPED))
dirty_printer(p);
}
* Set the printer state...
*/
- cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update);
+ cupsdSetPrinterState(p, IPP_PSTATE_STOPPED, update);
/*
* See if we have a job printing on this printer...
*/
- if (p->job && p->job->state_value == IPP_JOB_PROCESSING)
- cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT,
+ if (p->job && p->job->state_value == IPP_JSTATE_PROCESSING)
+ cupsdSetJobState(p->job, IPP_JSTATE_PENDING, CUPSD_JOB_DEFAULT,
"Job stopped due to printer being paused.");
}
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"add_printer_filter(p=%p(%s), filtertype=%p(%s/%s), "
- "filter=\"%s\")", p, p->name, filtertype, filtertype->super,
+ "filter=\"%s\")", (void *)p, p->name, (void *)filtertype, filtertype->super,
filtertype->type, filter);
/*
extern void cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s,
int update);
#define cupsdStartPrinter(p,u) cupsdSetPrinterState((p), \
- IPP_PRINTER_IDLE, (u))
+ IPP_PSTATE_IDLE, (u))
extern void cupsdStopPrinter(cupsd_printer_t *p, int update);
extern int cupsdUpdatePrinterPPD(cupsd_printer_t *p,
int num_keywords,
cupsCopyString(name, "unknown", namelen);
}
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFinishProcess(pid=%d, name=%p, namelen=" CUPS_LLFMT ", job_id=%p(%d)) = \"%s\"", pid, name, CUPS_LLCAST namelen, job_id, job_id ? *job_id : 0, name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFinishProcess(pid=%d, name=%p, namelen=" CUPS_LLFMT ", job_id=%p(%d)) = \"%s\"", pid, (void *)name, CUPS_LLCAST namelen, (void *)job_id, job_id ? *job_id : 0, name);
return (name);
}
"cupsdStartProcess(command=\"%s\", argv=%p, envp=%p, "
"infd=%d, outfd=%d, errfd=%d, backfd=%d, sidefd=%d, root=%d, "
"profile=%p, job=%p(%d), pid=%p) = %d",
- command, argv, envp, infd, outfd, errfd, backfd, sidefd,
- root, profile, job, job ? job->id : 0, pid, *pid);
+ command, (void *)argv, (void *)envp, infd, outfd, errfd, backfd, sidefd,
+ root, (void *)profile, (void *)job, job ? job->id : 0, (void *)pid, *pid);
return (*pid);
}
dstptr = dst;
dstend = dst + dstsize - 2;
- while (*src && dstptr < dstend)
+ if (src)
{
- ch = *src++;
+ while (*src && dstptr < dstend)
+ {
+ ch = *src++;
- if (ch == '/' && !*src)
- break; /* Don't add trailing slash */
+ if (ch == '/' && !*src)
+ break; /* Don't add trailing slash */
- if (strchr(".?*()[]^$\\\"", ch))
- *dstptr++ = '\\';
+ if (strchr(".?*()[]^$\\\"", ch))
+ *dstptr++ = '\\';
- *dstptr++ = (char)ch;
+ *dstptr++ = (char)ch;
+ }
}
*dstptr = '\0';
* This job is too old to count towards the quota, ignore it...
*/
- if (JobAutoPurge && !job->printer && job->state_value > IPP_JOB_STOPPED)
+ if (JobAutoPurge && !job->printer && job->state_value > IPP_JSTATE_STOPPED)
cupsdDeleteJob(job, CUPSD_JOB_PURGE);
continue;
// Range check input...
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddSelect(fd=%d, read_cb=%p, write_cb=%p, data=%p)", fd, read_cb, write_cb, data);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddSelect(fd=%d, read_cb=%p, write_cb=%p, data=%p)", fd, (void *)read_cb, (void *)write_cb, (void *)data);
if (fd < 0)
return (0);
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdAddEvent(event=%s, dest=%p(%s), job=%p(%d), text=\"%s\", ...)",
- cupsdEventName(event), dest, dest ? dest->name : "",
- job, job ? job->id : 0, text);
+ cupsdEventName(event), (void *)dest, dest ? dest->name : "",
+ (void *)job, job ? job->id : 0, text);
/*
* Keep track of events with any OS-supplied notification mechanisms...
ippAddInteger(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_ENUM, "printer-state", (int)dest->state);
if (dest->num_reasons == 0)
- ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "printer-state-reasons", NULL, dest->state == IPP_PRINTER_STOPPED ? "paused" : "none");
+ ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "printer-state-reasons", NULL, dest->state == IPP_PSTATE_STOPPED ? "paused" : "none");
else
ippAddStrings(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "printer-state-reasons", dest->num_reasons, NULL, (const char * const *)dest->reasons);
switch (job->state_value)
{
- case IPP_JOB_PENDING :
- if (dest && dest->state == IPP_PRINTER_STOPPED)
+ case IPP_JSTATE_PENDING :
+ if (dest && dest->state == IPP_PSTATE_STOPPED)
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "printer-stopped");
else
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "none");
break;
- case IPP_JOB_HELD :
+ case IPP_JSTATE_HELD :
if (ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_KEYWORD) != NULL ||
ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME) != NULL)
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-hold-until-specified");
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-incoming");
break;
- case IPP_JOB_PROCESSING :
+ case IPP_JSTATE_PROCESSING :
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-printing");
break;
- case IPP_JOB_STOPPED :
+ case IPP_JSTATE_STOPPED :
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-stopped");
break;
- case IPP_JOB_CANCELED :
+ case IPP_JSTATE_CANCELED :
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-canceled-by-user");
break;
- case IPP_JOB_ABORTED :
+ case IPP_JSTATE_ABORTED :
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "aborted-by-system");
break;
- case IPP_JOB_COMPLETED :
+ case IPP_JSTATE_COMPLETED :
ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-completed-successfully");
break;
}
cupsdLogMessage(CUPSD_LOG_DEBUG,
"cupsdAddSubscription(mask=%x, dest=%p(%s), job=%p(%d), "
"uri=\"%s\")",
- mask, dest, dest ? dest->name : "", job, job ? job->id : 0,
+ mask, (void *)dest, dest ? dest->name : "", (void *)job, job ? job->id : 0,
uri ? uri : "(null)");
if (!Subscriptions)
else if (event & CUPSD_EVENT_JOB_CREATED)
what = "JobQueuedLocal";
else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
- job->state_value == IPP_JOB_PROCESSING)
+ job->state_value == IPP_JSTATE_PROCESSING)
what = "JobStartedLocal";
else
return;
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsd_send_notification(sub=%p(%d), event=%p(%s))",
- sub, sub->id, event, cupsdEventName(event->event));
+ (void *)sub, sub->id, (void *)event, cupsdEventName(event->event));
/*
* Allocate the events array as needed...
if (sub->pipe < 0)
break;
- event->attrs->state = IPP_IDLE;
+ event->attrs->state = IPP_STATE_IDLE;
- while ((state = ippWriteFile(sub->pipe, event->attrs)) != IPP_DATA)
- if (state == IPP_ERROR)
+ while ((state = ippWriteFile(sub->pipe, event->attrs)) != IPP_STATE_DATA)
+ if (state == IPP_STATE_ERROR)
break;
- if (state == IPP_ERROR)
+ if (state == IPP_STATE_ERROR)
{
if (errno == EPIPE)
{
requests = 100;
children = 5;
server = (char *)cupsServer();
- port = ippPort();
+ port = ippGetPort();
encryption = HTTP_ENCRYPTION_IF_REQUESTED;
verbose = 0;
opstring = NULL;
int op; /* Current operation */
static ipp_op_t ops[5] = /* Operations to test... */
{
- IPP_PRINT_JOB,
- CUPS_GET_DEFAULT,
- CUPS_GET_PRINTERS,
- CUPS_GET_CLASSES,
- IPP_GET_JOBS
+ IPP_OP_PRINT_JOB,
+ IPP_OP_CUPS_GET_DEFAULT,
+ IPP_OP_CUPS_GET_PRINTERS,
+ IPP_OP_CUPS_GET_CLASSES,
+ IPP_OP_GET_JOBS
};
switch (op)
{
- case IPP_GET_JOBS :
+ case IPP_OP_GET_JOBS :
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost/printers/");
ippDelete(cupsDoRequest(http, request, "/"));
break;
- case IPP_PRINT_JOB :
+ case IPP_OP_PRINT_JOB :
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost/printers/test");
ippDelete(cupsDoFileRequest(http, request, "/printers/test",
switch (cupsGetError())
{
- case IPP_OK :
- case IPP_NOT_FOUND :
+ case IPP_STATUS_OK :
+ case IPP_STATUS_ERROR_NOT_FOUND :
if (verbose)
{
printf("succeeded: %s (%.6f)\n", cupsGetErrorString(), reqtime);
* Connect to the server...
*/
- if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
- cupsEncryption())) == NULL)
+ if ((http = httpConnect2(cupsGetServer(), ippGetPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
{
perror(cupsServer());
return (1);
if (strstr(uri, "/jobs/"))
{
- request = ippNewRequest(IPP_CREATE_JOB_SUBSCRIPTION);
+ request = ippNewRequest(IPP_OP_CREATE_JOB_SUBSCRIPTIONS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
}
else
{
- request = ippNewRequest(IPP_CREATE_PRINTER_SUBSCRIPTION);
+ request = ippNewRequest(IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
uri);
}
"notify-pull-method", NULL, "ippget");
response = cupsDoRequest(http, request, uri);
- if (cupsGetError() >= IPP_BAD_REQUEST)
+ if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
{
fprintf(stderr, "Create-%s-Subscription: %s\n",
strstr(uri, "/jobs") ? "Job" : "Printer", cupsGetErrorString());
printf("\nGet-Notifications(%d,%d):", subscription_id, sequence_number);
fflush(stdout);
- request = ippNewRequest(IPP_GET_NOTIFICATIONS);
+ request = ippNewRequest(IPP_OP_GET_NOTIFICATIONS);
if (strstr(uri, "/jobs/"))
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
printf(" %s\n", ippErrorString(cupsGetError()));
- if (cupsGetError() >= IPP_BAD_REQUEST)
+ if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
fprintf(stderr, "Get-Notifications: %s\n", cupsGetErrorString());
else if (response)
{
printf("\nCancel-Subscription:");
fflush(stdout);
- request = ippNewRequest(IPP_CANCEL_SUBSCRIPTION);
+ request = ippNewRequest(IPP_OP_CANCEL_SUBSCRIPTION);
if (strstr(uri, "/jobs/"))
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
printf(" %s\n", ippErrorString(cupsGetError()));
- if (cupsGetError() >= IPP_BAD_REQUEST)
+ if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
fprintf(stderr, "Cancel-Subscription: %s\n", cupsGetErrorString());
/*
* Setup to cancel individual print jobs...
*/
- op = IPP_CANCEL_JOB;
+ op = IPP_OP_CANCEL_JOB;
purge = 0;
dest = NULL;
user = NULL;
break;
case 'a' : /* Cancel all jobs */
- op = purge ? IPP_PURGE_JOBS : IPP_CANCEL_JOBS;
+ op = purge ? IPP_OP_PURGE_JOBS : IPP_OP_CANCEL_JOBS;
break;
case 'h' : /* Connect to host */
break;
case 'u' : /* Username */
- op = IPP_CANCEL_MY_JOBS;
+ op = IPP_OP_CANCEL_MY_JOBS;
if (opt[1] != '\0')
{
case 'x' : /* Purge job(s) */
purge = 1;
- if (op == IPP_CANCEL_JOBS)
- op = IPP_PURGE_JOBS;
+ if (op == IPP_OP_CANCEL_JOBS)
+ op = IPP_OP_PURGE_JOBS;
break;
default :
*/
dest = NULL;
- op = IPP_CANCEL_JOB;
+ op = IPP_OP_CANCEL_JOB;
job_id = atoi(job + 1);
}
else if (isdigit(argv[i][0] & 255))
*/
dest = NULL;
- op = IPP_CANCEL_JOB;
+ op = IPP_OP_CANCEL_JOB;
job_id = atoi(argv[i]);
}
else
"requesting-user-name", NULL, user);
ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1);
- if (op == IPP_CANCEL_JOBS)
- op = IPP_CANCEL_MY_JOBS;
+ if (op == IPP_OP_CANCEL_JOBS)
+ op = IPP_OP_CANCEL_MY_JOBS;
}
else
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
if (purge)
{
- if (op == IPP_CANCEL_JOB)
+ if (op == IPP_OP_CANCEL_JOB)
ippAddBoolean(request, IPP_TAG_OPERATION, "purge-job", (char)purge);
else
ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", (char)purge);
* Do the request and get back a response...
*/
- if (op == IPP_CANCEL_JOBS && (!user || _cups_strcasecmp(user, cupsGetUser())))
+ if (op == IPP_OP_CANCEL_JOBS && (!user || _cups_strcasecmp(user, cupsGetUser())))
response = cupsDoRequest(http, request, "/admin/");
else
response = cupsDoRequest(http, request, "/jobs/");
if (response == NULL ||
- response->request.status.status_code > IPP_OK_CONFLICT)
+ response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, _("%s: %s failed: %s"), argv[0],
- op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
+ op == IPP_OP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
cupsGetErrorString());
ippDelete(response);
}
}
- if (num_dests == 0 && op != IPP_CANCEL_JOB)
+ if (num_dests == 0 && op != IPP_OP_CANCEL_JOB)
{
/*
* Open a connection to the server...
response = cupsDoRequest(http, request, "/admin/");
if (response == NULL ||
- response->request.status.status_code > IPP_OK_CONFLICT)
+ response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, _("%s: %s failed: %s"), argv[0],
- op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
+ op == IPP_OP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
cupsGetErrorString());
ippDelete(response);
cancel = 0;
if (!strcmp(command, "cupsaccept"))
- op = CUPS_ACCEPT_JOBS;
+ op = IPP_OP_CUPS_ACCEPT_JOBS;
else if (!strcmp(command, "cupsreject"))
- op = CUPS_REJECT_JOBS;
+ op = IPP_OP_CUPS_REJECT_JOBS;
else if (!strcmp(command, "cupsdisable"))
- op = IPP_PAUSE_PRINTER;
+ op = IPP_OP_PAUSE_PRINTER;
else if (!strcmp(command, "cupsenable"))
- op = IPP_RESUME_PRINTER;
+ op = IPP_OP_RESUME_PRINTER;
else
{
_cupsLangPrintf(stderr, _("%s: Don't know what to do."), command);
if (!strcmp(argv[i], "--help"))
usage(command);
else if (!strcmp(argv[i], "--hold"))
- op = IPP_HOLD_NEW_JOBS;
+ op = IPP_OP_HOLD_NEW_JOBS;
else if (!strcmp(argv[i], "--release"))
- op = IPP_RELEASE_HELD_NEW_JOBS;
+ op = IPP_OP_RELEASE_HELD_NEW_JOBS;
else if (argv[i][0] == '-')
{
for (opt = argv[i] + 1; *opt; opt ++)
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/admin/"));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr,
_("%s: Operation failed: %s"),
* printer-uri
*/
- request = ippNewRequest(IPP_PURGE_JOBS);
+ request = ippNewRequest(IPP_OP_PURGE_JOBS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/admin/"));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (1);
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);
char uri[HTTP_MAX_URI]; /* URI for job */
- request = ippNewRequest(IPP_RESTART_JOB);
+ request = ippNewRequest(IPP_OP_RESTART_JOB);
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
"name."), command);
return (1);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (1);
if (num_options == 0)
return (0);
- request = ippNewRequest(IPP_SET_JOB_ATTRIBUTES);
+ request = ippNewRequest(IPP_OP_SET_JOB_ATTRIBUTES);
snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id);
"name."), command);
return (1);
}
- else if (cupsGetError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (1);
const char *exclude_schemes) /* I - List of schemes to exclude */
{
if (cupsGetDevices(CUPS_HTTP_DEFAULT, timeout, include_schemes,
- exclude_schemes, device_cb, &long_status) != IPP_OK)
+ exclude_schemes, device_cb, &long_status) != IPP_STATUS_OK)
{
_cupsLangPrintf(stderr, "lpinfo: %s", cupsGetErrorString());
return (1);
* Build a CUPS_GET_PPDS request...
*/
- request = ippNewRequest(CUPS_GET_PPDS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PPDS);
if (device_id)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_TEXT, "ppd-device-id",
* Loop through the device list and display them...
*/
- if (response->request.status.status_code > IPP_OK_CONFLICT)
+ if (response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "lpinfo: %s", cupsGetErrorString());
ippDelete(response);
* requesting-user-name
*/
- request = ippNewRequest(CUPS_MOVE_JOB);
+ request = ippNewRequest(IPP_OP_CUPS_MOVE_JOB);
if (jobid)
{
ippDelete(cupsDoRequest(http, request, "/jobs"));
- if (cupsGetError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "lpmove: %s", cupsGetErrorString());
return (1);
* requesting-user-name
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
* requesting-user-name
*/
- request = ippNewRequest(CUPS_GET_CLASSES);
+ request = ippNewRequest(IPP_OP_CUPS_GET_CLASSES);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", sizeof(cattrs) / sizeof(cattrs[0]),
if (response)
{
- if (response->request.status.status_code > IPP_OK_CONFLICT)
+ if (response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
{
_cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
* requested-attributes
*/
- request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+ request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, printer_uri);
* requesting-user-name
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
* which-jobs
*/
- request = ippNewRequest(IPP_GET_JOBS);
+ request = ippNewRequest(IPP_OP_GET_JOBS);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost/");
* requesting-user-name
*/
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_CUPS_GET_PRINTERS);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
printer = NULL;
ptime = 0;
ptype = CUPS_PRINTER_LOCAL;
- pstate = IPP_PRINTER_IDLE;
+ pstate = IPP_PSTATE_IDLE;
message = NULL;
description = NULL;
location = NULL;
if (match_list(printers, printer))
{
/*
- * If the printer state is "IPP_PRINTER_PROCESSING", then grab the
+ * If the printer state is "IPP_PSTATE_PROCESSING", then grab the
* current job for the printer.
*/
- if (pstate == IPP_PRINTER_PROCESSING)
+ if (pstate == IPP_PSTATE_PROCESSING)
{
/*
* Build an IPP_GET_JOBS request, which requires the following
* requested-attributes
*/
- request = ippNewRequest(IPP_GET_JOBS);
-
- request->request.op.operation_id = IPP_GET_JOBS;
- request->request.op.request_id = 1;
+ request = ippNewRequest(IPP_OP_GET_JOBS);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
* Get the current active job on this queue...
*/
- ipp_jstate_t jobstate = IPP_JOB_PENDING;
+ ipp_jstate_t jobstate = IPP_JSTATE_PENDING;
jobid = 0;
for (jobattr = jobs->attrs; jobattr; jobattr = jobattr->next)
{
if (!jobattr->name)
{
- if (jobstate == IPP_JOB_PROCESSING)
+ if (jobstate == IPP_JSTATE_PROCESSING)
break;
else
continue;
jobstate = (ipp_jstate_t)jobattr->values[0].integer;
}
- if (jobstate != IPP_JOB_PROCESSING)
+ if (jobstate != IPP_JSTATE_PROCESSING)
jobid = 0;
ippDelete(jobs);
switch (pstate)
{
- case IPP_PRINTER_IDLE :
+ case IPP_PSTATE_IDLE :
if (ippContainsString(reasons, "hold-new-jobs"))
_cupsLangPrintf(stdout, _("printer %s is holding new jobs. enabled since %s"), printer, printer_state_time);
else
_cupsLangPrintf(stdout, _("printer %s is idle. enabled since %s"), printer, printer_state_time);
break;
- case IPP_PRINTER_PROCESSING :
+ case IPP_PSTATE_PROCESSING :
_cupsLangPrintf(stdout, _("printer %s now printing %s-%d. enabled since %s"), printer, printer, jobid, printer_state_time);
break;
- case IPP_PRINTER_STOPPED :
+ case IPP_PSTATE_STOPPED :
_cupsLangPrintf(stdout, _("printer %s disabled since %s -"), printer, printer_state_time);
break;
}
- if ((message && *message) || pstate == IPP_PRINTER_STOPPED)
+ if ((message && *message) || pstate == IPP_PSTATE_STOPPED)
{
if (message && *message)
_cupsLangPrintf(stdout, "\t%s", message);
{
switch (pstate)
{
- case IPP_PRINTER_IDLE :
+ case IPP_PSTATE_IDLE :
_cupsLangPrintf(stdout,
_("printer %s/%s is idle. "
"enabled since %s"),
printer, dests[i].instance,
printer_state_time);
break;
- case IPP_PRINTER_PROCESSING :
+ case IPP_PSTATE_PROCESSING :
_cupsLangPrintf(stdout,
_("printer %s/%s now printing %s-%d. "
"enabled since %s"),
printer, dests[i].instance, printer, jobid,
printer_state_time);
break;
- case IPP_PRINTER_STOPPED :
+ case IPP_PSTATE_STOPPED :
_cupsLangPrintf(stdout,
_("printer %s/%s disabled since %s -"),
printer, dests[i].instance,
break;
}
- if ((message && *message) || pstate == IPP_PRINTER_STOPPED)
+ if ((message && *message) || pstate == IPP_PSTATE_STOPPED)
{
if (message && *message)
_cupsLangPrintf(stdout, "\t%s", message);
-/*
- * IPP Everywhere printer application for CUPS.
- *
- * Copyright © 2021-2023 by OpenPrinting.
- * Copyright © 2020 by the IEEE-ISTO Printer Working Group.
- * Copyright © 2010-2021 by Apple Inc.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- *
- * Note: This program began life as the "ippserver" sample code that first
- * appeared in CUPS 1.4. The name has been changed in order to distinguish it
- * from the PWG's much more ambitious "ippserver" program, which supports
- * different kinds of IPP services and multiple services per instance - the
- * "ippeveprinter" program exposes a single print service conforming to the
- * current IPP Everywhere specification, thus the new name.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// IPP Everywhere printer application for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2020 by the IEEE-ISTO Printer Working Group.
+// Copyright © 2010-2021 by Apple Inc.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+// Note: This program began life as the "ippserver" sample code that first
+// appeared in CUPS 1.4. The name has been changed in order to distinguish it
+// from the PWG's much more ambitious "ippserver" program, which supports
+// different kinds of IPP services and multiple services per instance - the
+// "ippeveprinter" program exposes a single print service conforming to the
+// current IPP Everywhere specification, thus the new name.
+//
#include <cups/cups-private.h>
-#include <cups/debug-private.h>
-#if !CUPS_LITE
-# include <cups/ppd-private.h>
-#endif /* !CUPS_LITE */
+#include <cups/dnssd.h>
#include <limits.h>
-#include <fcntl.h>
#include <sys/stat.h>
#ifdef _WIN32
+# include <fcntl.h>
# include <io.h>
# include <process.h>
# define WEXITSTATUS(s) (s)
extern char **environ;
# include <spawn.h>
+# include <sys/fcntl.h>
# include <sys/wait.h>
# include <poll.h>
-#endif /* _WIN32 */
+#endif // _WIN32
#ifndef O_BINARY
-# define O_BINARY 0 /* Windows "binary file" nonsense */
-#endif /* !O_BINARY */
-
-#ifdef HAVE_MDNSRESPONDER
-# include <dns_sd.h>
-#elif defined(HAVE_AVAHI)
-# include <avahi-client/client.h>
-# include <avahi-client/publish.h>
-# include <avahi-common/alternative.h>
-# include <avahi-common/error.h>
-# include <avahi-common/malloc.h>
-# include <avahi-common/thread-watch.h>
-#endif /* HAVE_MDNSRESPONDER */
+# define O_BINARY 0 // Windows "binary file" nonsense
+#endif // !O_BINARY
#ifdef HAVE_SYS_MOUNT_H
# include <sys/mount.h>
-#endif /* HAVE_SYS_MOUNT_H */
+#endif // HAVE_SYS_MOUNT_H
#ifdef HAVE_SYS_STATFS_H
# include <sys/statfs.h>
-#endif /* HAVE_SYS_STATFS_H */
+#endif // HAVE_SYS_STATFS_H
#ifdef HAVE_SYS_STATVFS_H
# include <sys/statvfs.h>
-#endif /* HAVE_SYS_STATVFS_H */
+#endif // HAVE_SYS_STATVFS_H
#ifdef HAVE_SYS_VFS_H
# include <sys/vfs.h>
-#endif /* HAVE_SYS_VFS_H */
+#endif // HAVE_SYS_VFS_H
#if HAVE_LIBPAM
# ifdef HAVE_PAM_PAM_APPL_H
# include <pam/pam_appl.h>
# else
# include <security/pam_appl.h>
-# endif /* HAVE_PAM_PAM_APPL_H */
-#endif /* HAVE_LIBPAM */
+# endif // HAVE_PAM_PAM_APPL_H
+#endif // HAVE_LIBPAM
#include "printer-png.h"
#include "printer-lg-png.h"
#include "printer-sm-png.h"
-/*
- * Constants...
- */
+//
+// Constants...
+//
-enum ippeve_preason_e /* printer-state-reasons bit values */
+enum ippeve_preason_e // printer-state-reasons bit values
{
- IPPEVE_PREASON_NONE = 0x0000, /* none */
- IPPEVE_PREASON_OTHER = 0x0001, /* other */
- IPPEVE_PREASON_COVER_OPEN = 0x0002, /* cover-open */
+ IPPEVE_PREASON_NONE = 0x0000, // none
+ IPPEVE_PREASON_OTHER = 0x0001, // other
+ IPPEVE_PREASON_COVER_OPEN = 0x0002, // cover-open
IPPEVE_PREASON_INPUT_TRAY_MISSING = 0x0004,
- /* input-tray-missing */
+ // input-tray-missing
IPPEVE_PREASON_MARKER_SUPPLY_EMPTY = 0x0008,
- /* marker-supply-empty */
+ // marker-supply-empty
IPPEVE_PREASON_MARKER_SUPPLY_LOW = 0x0010,
- /* marker-supply-low */
+ // marker-supply-low
IPPEVE_PREASON_MARKER_WASTE_ALMOST_FULL = 0x0020,
- /* marker-waste-almost-full */
+ // marker-waste-almost-full
IPPEVE_PREASON_MARKER_WASTE_FULL = 0x0040,
- /* marker-waste-full */
- IPPEVE_PREASON_MEDIA_EMPTY = 0x0080, /* media-empty */
- IPPEVE_PREASON_MEDIA_JAM = 0x0100, /* media-jam */
- IPPEVE_PREASON_MEDIA_LOW = 0x0200, /* media-low */
- IPPEVE_PREASON_MEDIA_NEEDED = 0x0400, /* media-needed */
+ // marker-waste-full
+ IPPEVE_PREASON_MEDIA_EMPTY = 0x0080, // media-empty
+ IPPEVE_PREASON_MEDIA_JAM = 0x0100, // media-jam
+ IPPEVE_PREASON_MEDIA_LOW = 0x0200, // media-low
+ IPPEVE_PREASON_MEDIA_NEEDED = 0x0400, // media-needed
IPPEVE_PREASON_MOVING_TO_PAUSED = 0x0800,
- /* moving-to-paused */
- IPPEVE_PREASON_PAUSED = 0x1000, /* paused */
- IPPEVE_PREASON_SPOOL_AREA_FULL = 0x2000,/* spool-area-full */
- IPPEVE_PREASON_TONER_EMPTY = 0x4000, /* toner-empty */
- IPPEVE_PREASON_TONER_LOW = 0x8000 /* toner-low */
+ // moving-to-paused
+ IPPEVE_PREASON_PAUSED = 0x1000, // paused
+ IPPEVE_PREASON_SPOOL_AREA_FULL = 0x2000,// spool-area-full
+ IPPEVE_PREASON_TONER_EMPTY = 0x4000, // toner-empty
+ IPPEVE_PREASON_TONER_LOW = 0x8000 // toner-low
};
-typedef unsigned int ippeve_preason_t; /* Bitfield for printer-state-reasons */
+typedef unsigned int ippeve_preason_t; // Bitfield for printer-state-reasons
static const char * const ippeve_preason_strings[] =
-{ /* Strings for each bit */
- /* "none" is implied for no bits set */
+{ // Strings for each bit
+ // "none" is implied for no bits set
"other",
"cover-open",
"input-tray-missing",
};
-/*
- * URL scheme for web resources...
- */
+//
+// URL scheme for web resources...
+//
#define WEB_SCHEME "https"
-/*
- * Structures...
- */
-
-#ifdef HAVE_MDNSRESPONDER
-typedef DNSServiceRef ippeve_srv_t; /* Service reference */
-typedef TXTRecordRef ippeve_txt_t; /* TXT record */
-
-#elif defined(HAVE_AVAHI)
-typedef AvahiEntryGroup *ippeve_srv_t; /* Service reference */
-typedef AvahiStringList *ippeve_txt_t; /* TXT record */
-
-#else
-typedef void *ippeve_srv_t; /* Service reference */
-typedef void *ippeve_txt_t; /* TXT record */
-#endif /* HAVE_MDNSRESPONDER */
+//
+// Structures...
+//
#if HAVE_LIBPAM
-typedef struct ippeve_authdata_s /* Authentication data */
+typedef struct ippeve_authdata_s // Authentication data
{
- char username[HTTP_MAX_VALUE], /* Username string */
- *password; /* Password string */
+ char username[HTTP_MAX_VALUE], // Username string
+ *password; // Password string
} ippeve_authdata_t;
-#endif /* HAVE_LIBPAM */
+#endif // HAVE_LIBPAM
-typedef struct ippeve_filter_s /**** Attribute filter ****/
+typedef struct ippeve_filter_s // Attribute filter
{
- cups_array_t *ra; /* Requested attributes */
- ipp_tag_t group_tag; /* Group to copy */
+ cups_array_t *ra; // Requested attributes
+ ipp_tag_t group_tag; // Group to copy
} ippeve_filter_t;
typedef struct ippeve_job_s ippeve_job_t;
-typedef struct ippeve_printer_s /**** Printer data ****/
+typedef struct ippeve_printer_s // Printer data
{
- /* TODO: One IPv4 and one IPv6 listener are really not sufficient */
- int ipv4, /* IPv4 listener */
- ipv6; /* IPv6 listener */
-#ifdef HAVE_MDNSRESPONDER
- ippeve_srv_t ipp_ref, /* DNS-SD IPP service */
- ipps_ref, /* DNS-SD IPPS service */
- http_ref, /* DNS-SD HTTP service */
- printer_ref; /* DNS-SD LPD service */
-#elif defined(HAVE_AVAHI)
- ippeve_srv_t dnssd_ref; /* DNS-SD services */
-#endif /* HAVE_MDNSRESPONDER */
- char *dnssd_subtypes;/* DNS-SD subtypes */
- int dnssd_collision;/* Name collision? */
- char *dnssd_name, /* printer-dns-sd-name */
- *name, /* printer-name */
- *icons[3], /* Icon filenames */
- *strings, /* Strings filename */
- *directory, /* Spool directory */
- *hostname, /* Hostname */
- *device_uri, /* Device URI (if any) */
- *output_format, /* Output format */
-#if !CUPS_LITE
- *ppdfile, /* PPD file (if any) */
-#endif /* !CUPS_LITE */
- *command; /* Command to run with job file */
- int port; /* Port */
- int web_forms; /* Enable web interface forms? */
- size_t urilen; /* Length of printer URI */
- ipp_t *attrs; /* Static attributes */
- time_t start_time; /* Startup time */
- time_t config_time; /* printer-config-change-time */
- ipp_pstate_t state; /* printer-state value */
- ippeve_preason_t state_reasons; /* printer-state-reasons values */
- time_t state_time; /* printer-state-change-time */
- cups_array_t *jobs; /* Jobs */
- ippeve_job_t *active_job; /* Current active/pending job */
- int next_job_id; /* Next job-id value */
- cups_rwlock_t rwlock; /* Printer lock */
+ // TODO: One IPv4 and one IPv6 listener are really not sufficient
+ int ipv4, // IPv4 listener
+ ipv6; // IPv6 listener
+ cups_dnssd_t *dnssd; // DNS-SD context
+ cups_dnssd_service_t *services; // DNS-SD services
+ char *dnssd_subtypes;// DNS-SD subtypes
+ int dnssd_collision;// Name collision?
+ char *dnssd_name, // printer-dns-sd-name
+ *name, // printer-name
+ *icons[3], // Icon filenames
+ *strings, // Strings filename
+ *directory, // Spool directory
+ *hostname, // Hostname
+ *device_uri, // Device URI (if any)
+ *output_format, // Output format
+ *command; // Command to run with job file
+ int port; // Port
+ bool web_forms; // Enable web interface forms?
+ size_t urilen; // Length of printer URI
+ ipp_t *attrs; // Static attributes
+ time_t start_time; // Startup time
+ time_t config_time; // printer-config-change-time
+ ipp_pstate_t state; // printer-state value
+ ippeve_preason_t state_reasons; // printer-state-reasons values
+ time_t state_time; // printer-state-change-time
+ cups_array_t *jobs; // Jobs
+ ippeve_job_t *active_job; // Current active/pending job
+ int next_job_id; // Next job-id value
+ cups_rwlock_t rwlock; // Printer lock
} ippeve_printer_t;
-struct ippeve_job_s /**** Job data ****/
+struct ippeve_job_s // Job data
{
- int id; /* Job ID */
- const char *name, /* job-name */
- *username, /* job-originating-user-name */
- *format; /* document-format */
- ipp_jstate_t state; /* job-state value */
- char *message; /* job-state-message value */
- int msglevel; /* job-state-message log level (0=error, 1=info) */
- time_t created, /* time-at-creation value */
- processing, /* time-at-processing value */
- completed; /* time-at-completed value */
- int impressions, /* job-impressions value */
- impcompleted; /* job-impressions-completed value */
- ipp_t *attrs; /* Static attributes */
- int cancel; /* Non-zero when job canceled */
- char *filename; /* Print file name */
- int fd; /* Print file descriptor */
- ippeve_printer_t *printer; /* Printer */
+ int id; // Job ID
+ const char *name, // job-name
+ *username, // job-originating-user-name
+ *format; // document-format
+ ipp_jstate_t state; // job-state value
+ char *message; // job-state-message value
+ int msglevel; // job-state-message log level (0=error, 1=info)
+ time_t created, // time-at-creation value
+ processing, // time-at-processing value
+ completed; // time-at-completed value
+ int impressions, // job-impressions value
+ impcompleted; // job-impressions-completed value
+ ipp_t *attrs; // Static attributes
+ int cancel; // Non-zero when job canceled
+ char *filename; // Print file name
+ int fd; // Print file descriptor
+ ippeve_printer_t *printer; // Printer
};
-typedef struct ippeve_client_s /**** Client data ****/
+typedef struct ippeve_client_s // Client data
{
- http_t *http; /* HTTP connection */
- ipp_t *request, /* IPP request */
- *response; /* IPP response */
- time_t start; /* Request start time */
- http_state_t operation; /* Request operation */
- ipp_op_t operation_id; /* IPP operation-id */
- char uri[1024], /* Request URI */
- *options, /* URI options */
+ http_t *http; // HTTP connection
+ ipp_t *request, // IPP request
+ *response; // IPP response
+ time_t start; // Request start time
+ http_state_t operation; // Request operation
+ ipp_op_t operation_id; // IPP operation-id
+ char uri[1024], // Request URI
+ *options, // URI options
host_field[HTTP_MAX_VALUE];
- /* Host: header */
- int host_port; /* Port number from Host: header */
- http_addr_t addr; /* Client address */
- char hostname[256], /* Client hostname */
+ // Host: header
+ int host_port; // Port number from Host: header
+ http_addr_t addr; // Client address
+ char hostname[256], // Client hostname
username[HTTP_MAX_VALUE];
- /* Authenticated username, if any */
- ippeve_printer_t *printer; /* Printer */
- ippeve_job_t *job; /* Current job, if any */
+ // Authenticated username, if any
+ ippeve_printer_t *printer; // Printer
+ ippeve_job_t *job; // Current job, if any
} ippeve_client_t;
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static http_status_t authenticate_request(ippeve_client_t *client);
static void clean_jobs(ippeve_printer_t *printer);
static int compare_jobs(ippeve_job_t *a, ippeve_job_t *b);
-static void copy_attributes(ipp_t *to, ipp_t *from, cups_array_t *ra, ipp_tag_t group_tag, int quickcopy);
+static void copy_attributes(ipp_t *to, ipp_t *from, cups_array_t *ra, ipp_tag_t group_tag, bool quickcopy);
static void copy_job_attributes(ippeve_client_t *client, ippeve_job_t *job, cups_array_t *ra);
static ippeve_client_t *create_client(ippeve_printer_t *printer, int sock);
static ippeve_job_t *create_job(ippeve_client_t *client);
static int create_job_file(ippeve_job_t *job, char *fname, size_t fnamesize, const char *dir, const char *ext);
static int create_listener(const char *name, int port, int family);
-static ipp_t *create_media_col(const char *media, const char *source, const char *type, int width, int length, int bottom, int left, int right, int top);
+static ipp_t *create_media_col(const char *media, const char *source, const char *type, ipp_t *media_size, int bottom, int left, int right, int top);
static ipp_t *create_media_size(int width, int length);
+static ipp_t *create_media_size_range(int min_width, int max_width, int min_length, int max_length);
static ippeve_printer_t *create_printer(const char *servername, int serverport, const char *name, const char *location, const char *icons, const char *strings, cups_array_t *docformats, const char *subtypes, const char *directory, const char *command, const char *device_uri, const char *output_format, ipp_t *attrs);
static void debug_attributes(const char *title, ipp_t *ipp, int response);
static void delete_client(ippeve_client_t *client);
static void delete_job(ippeve_job_t *job);
static void delete_printer(ippeve_printer_t *printer);
-#ifdef HAVE_MDNSRESPONDER
-static void DNSSD_API dnssd_callback(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode, const char *name, const char *regtype, const char *domain, ippeve_printer_t *printer);
-#elif defined(HAVE_AVAHI)
-static void dnssd_callback(AvahiEntryGroup *p, AvahiEntryGroupState state, void *context);
-static void dnssd_client_cb(AvahiClient *c, AvahiClientState state, void *userdata);
-#endif /* HAVE_MDNSRESPONDER */
-static void dnssd_init(void);
+static void dnssd_callback(cups_dnssd_service_t *service, ippeve_printer_t *printer, cups_dnssd_flags_t flags);
static int filter_cb(ippeve_filter_t *filter, ipp_t *dst, ipp_attribute_t *attr);
static ippeve_job_t *find_job(ippeve_client_t *client);
static void finish_document_data(ippeve_client_t *client, ippeve_job_t *job);
static void finish_document_uri(ippeve_client_t *client, ippeve_job_t *job);
static void flush_document_data(ippeve_client_t *client);
-static int have_document_data(ippeve_client_t *client);
-static void html_escape(ippeve_client_t *client, const char *s, size_t slen);
-static void html_footer(ippeve_client_t *client);
-static void html_header(ippeve_client_t *client, const char *title, int refresh);
-static void html_printf(ippeve_client_t *client, const char *format, ...) _CUPS_FORMAT(2, 3);
+static bool have_document_data(ippeve_client_t *client);
+static bool html_escape(ippeve_client_t *client, const char *s, size_t slen);
+static bool html_footer(ippeve_client_t *client);
+static bool html_header(ippeve_client_t *client, const char *title, int refresh);
+static bool html_printf(ippeve_client_t *client, const char *format, ...) _CUPS_FORMAT(2, 3);
static void ipp_cancel_job(ippeve_client_t *client);
static void ipp_cancel_my_jobs(ippeve_client_t *client);
static void ipp_close_job(ippeve_client_t *client);
static void ipp_validate_job(ippeve_client_t *client);
static ipp_t *load_ippserver_attributes(const char *servername, int serverport, const char *filename, cups_array_t *docformats);
static ipp_t *load_legacy_attributes(const char *make, const char *model, int ppm, int ppm_color, int duplex, cups_array_t *docformats);
-#if !CUPS_LITE
-static ipp_t *load_ppd_attributes(const char *ppdfile, cups_array_t *docformats);
-#endif /* !CUPS_LITE */
#if HAVE_LIBPAM
static int pam_func(int, const struct pam_message **, struct pam_response **, void *);
-#endif /* HAVE_LIBPAM */
+#endif // HAVE_LIBPAM
static int parse_options(ippeve_client_t *client, cups_option_t **options);
static void process_attr_message(ippeve_job_t *job, char *message);
static void *process_client(ippeve_client_t *client);
static int process_ipp(ippeve_client_t *client);
static void *process_job(ippeve_job_t *job);
static void process_state_message(ippeve_job_t *job, char *message);
-static int register_printer(ippeve_printer_t *printer);
-static int respond_http(ippeve_client_t *client, http_status_t code, const char *content_coding, const char *type, size_t length);
+static bool register_printer(ippeve_printer_t *printer);
+static bool respond_http(ippeve_client_t *client, http_status_t code, const char *content_coding, const char *type, size_t length);
static void respond_ignored(ippeve_client_t *client, ipp_attribute_t *attr);
static void respond_ipp(ippeve_client_t *client, ipp_status_t status, const char *message, ...) _CUPS_FORMAT(3, 4);
static void respond_unsupported(ippeve_client_t *client, ipp_attribute_t *attr);
#endif // !_WIN32
static char *time_string(time_t tv, char *buffer, size_t bufsize);
static void usage(int status) _CUPS_NORETURN;
-static int valid_doc_attributes(ippeve_client_t *client);
-static int valid_job_attributes(ippeve_client_t *client);
+static bool valid_doc_attributes(ippeve_client_t *client);
+static bool valid_job_attributes(ippeve_client_t *client);
-/*
- * Globals...
- */
+//
+// Globals...
+//
-#ifdef HAVE_MDNSRESPONDER
-static DNSServiceRef DNSSDMaster = NULL;
-#elif defined(HAVE_AVAHI)
-static AvahiThreadedPoll *DNSSDMaster = NULL;
-static AvahiClient *DNSSDClient = NULL;
-#endif /* HAVE_MDNSRESPONDER */
-
-static int KeepFiles = 0, /* Keep spooled job files? */
- MaxVersion = 20,/* Maximum IPP version (20 = 2.0, 11 = 1.1, etc.) */
- Verbosity = 0; /* Verbosity level */
+static int KeepFiles = 0, // Keep spooled job files?
+ MaxVersion = 20,// Maximum IPP version (20 = 2.0, 11 = 1.1, etc.)
+ Verbosity = 0; // Verbosity level
static const char *PAMService = NULL;
- /* PAM service */
+ // PAM service
#ifndef _WIN32
-static int StopPrinter = 0;/* Stop the printer server? */
+static int StopPrinter = 0;// Stop the printer server?
#endif // !_WIN32
-/*
- * 'main()' - Main entry to the sample server.
- */
+//
+// 'main()' - Main entry to the sample server.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line args */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line args
+ char *argv[]) // I - Command-line arguments
{
- int i; /* Looping var */
- const char *opt, /* Current option character */
- *attrfile = NULL, /* ippserver attributes file */
- *command = NULL, /* Command to run with job files */
- *device_uri = NULL, /* Device URI */
- *output_format = NULL, /* Output format */
- *icon = NULL, /* Icon file */
- *keypath = NULL, /* Keychain path */
- *location = "", /* Location of printer */
- *make = "Example", /* Manufacturer */
- *model = "Printer", /* Model */
- *name = NULL, /* Printer name */
-#if !CUPS_LITE
- *ppdfile = NULL, /* PPD file */
-#endif /* !CUPS_LITE */
- *strings = NULL, /* Strings file */
- *subtypes = "_print"; /* DNS-SD service subtype */
- int legacy = 0, /* Legacy mode? */
- duplex = 0, /* Duplex mode */
- ppm = 10, /* Pages per minute for mono */
- ppm_color = 0, /* Pages per minute for color */
- web_forms = 1; /* Enable website forms? */
- ipp_t *attrs = NULL; /* Printer attributes */
- char directory[1024] = ""; /* Spool directory */
- cups_array_t *docformats = NULL; /* Supported formats */
- const char *servername = NULL; /* Server host name */
- int serverport = 0; /* Server port number (0 = auto) */
- ippeve_printer_t *printer; /* Printer object */
-
-
- /*
- * Parse command-line arguments...
- */
-
+ int i; // Looping var
+ const char *opt, // Current option character
+ *attrfile = NULL, // ippserver attributes file
+ *command = NULL, // Command to run with job files
+ *device_uri = NULL, // Device URI
+ *output_format = NULL, // Output format
+ *icon = NULL, // Icon file
+ *keypath = NULL, // Keychain path
+ *location = "", // Location of printer
+ *make = "Example", // Manufacturer
+ *model = "Printer", // Model
+ *name = NULL, // Printer name
+ *strings = NULL, // Strings file
+ *subtypes = "_print"; // DNS-SD service subtype
+ bool legacy = false, // Legacy mode?
+ duplex = false, // Duplex mode
+ web_forms = true; // Enable web site forms?
+ int ppm = 10, // Pages per minute for mono
+ ppm_color = 0; // Pages per minute for color
+ ipp_t *attrs = NULL; // Printer attributes
+ char directory[1024] = ""; // Spool directory
+ cups_array_t *docformats = NULL; // Supported formats
+ const char *servername = NULL; // Server host name
+ int serverport = 0; // Server port number (0 = auto)
+ ippeve_printer_t *printer; // Printer object
+
+
+ _cupsSetLocale(argv);
+
+ // Parse command-line arguments...
for (i = 1; i < argc; i ++)
{
if (!strcmp(argv[i], "--help"))
}
else if (!strcmp(argv[i], "--no-web-forms"))
{
- web_forms = 0;
+ web_forms = false;
}
else if (!strcmp(argv[i], "--pam-service"))
{
{
switch (*opt)
{
- case '2' : /* -2 (enable 2-sided printing) */
- duplex = 1;
- legacy = 1;
+ case '2' : // -2 (enable 2-sided printing)
+ duplex = true;
+ legacy = true;
break;
- case 'A' : /* -A (enable authentication) */
+ case 'A' : // -A (enable authentication)
if (!PAMService)
PAMService = "cups";
break;
- case 'D' : /* -D device-uri */
+ case 'D' : // -D device-uri
i ++;
if (i >= argc)
usage(1);
device_uri = argv[i];
break;
- case 'F' : /* -F output/format */
+ case 'F' : // -F output/format
i ++;
if (i >= argc)
usage(1);
output_format = argv[i];
break;
- case 'K' : /* -K keypath */
+ case 'K' : // -K keypath
i ++;
if (i >= argc)
usage(1);
keypath = argv[i];
break;
- case 'M' : /* -M manufacturer */
+ case 'M' : // -M manufacturer
i ++;
if (i >= argc)
usage(1);
make = argv[i];
- legacy = 1;
+ legacy = true;
break;
-#if !CUPS_LITE
- case 'P' : /* -P filename.ppd */
- i ++;
- if (i >= argc)
- usage(1);
-
- ppdfile = argv[i];
- break;
-#endif /* !CUPS_LITE */
-
- case 'S' : /* -S filename.strings */
+ case 'S' : // -S filename.strings
i ++;
if (i >= argc)
usage(1);
strings = argv[i];
break;
- case 'V' : /* -V max-version */
+ case 'V' : // -V max-version
i ++;
if (i >= argc)
usage(1);
usage(1);
break;
- case 'a' : /* -a attributes-file */
+ case 'a' : // -a attributes-file
i ++;
if (i >= argc)
usage(1);
attrfile = argv[i];
break;
- case 'c' : /* -c command */
+ case 'c' : // -c command
i ++;
if (i >= argc)
usage(1);
command = argv[i];
break;
- case 'd' : /* -d spool-directory */
+ case 'd' : // -d spool-directory
i ++;
if (i >= argc)
usage(1);
cupsCopyString(directory, argv[i], sizeof(directory));
break;
- case 'f' : /* -f type/subtype[,...] */
+ case 'f' : // -f type/subtype[,...]
i ++;
if (i >= argc)
usage(1);
docformats = cupsArrayNewStrings(argv[i], ',');
- legacy = 1;
+ legacy = true;
break;
- case 'i' : /* -i icon.png */
+ case 'i' : // -i icon.png
i ++;
if (i >= argc)
usage(1);
icon = argv[i];
break;
- case 'k' : /* -k (keep files) */
+ case 'k' : // -k (keep files)
KeepFiles = 1;
break;
- case 'l' : /* -l location */
+ case 'l' : // -l location
i ++;
if (i >= argc)
usage(1);
location = argv[i];
break;
- case 'm' : /* -m model */
+ case 'm' : // -m model
i ++;
if (i >= argc)
usage(1);
model = argv[i];
- legacy = 1;
+ legacy = true;
break;
- case 'n' : /* -n hostname */
+ case 'n' : // -n hostname
i ++;
if (i >= argc)
usage(1);
servername = argv[i];
break;
- case 'p' : /* -p port */
+ case 'p' : // -p port
i ++;
if (i >= argc || !isdigit(argv[i][0] & 255))
usage(1);
serverport = atoi(argv[i]);
break;
- case 'r' : /* -r subtype */
+ case 'r' : // -r subtype
i ++;
if (i >= argc)
usage(1);
subtypes = argv[i];
break;
- case 's' : /* -s speed[,color-speed] */
+ case 's' : // -s speed[,color-speed]
i ++;
if (i >= argc)
usage(1);
if (sscanf(argv[i], "%d,%d", &ppm, &ppm_color) < 1)
usage(1);
- legacy = 1;
+ legacy = true;
break;
- case 'v' : /* -v (be verbose) */
+ case 'v' : // -v (be verbose)
Verbosity ++;
break;
- default : /* Unknown */
+ default : // Unknown
_cupsLangPrintf(stderr, _("%s: Unknown option \"-%c\"."), argv[0], *opt);
usage(1);
}
if (!name)
usage(1);
-#if CUPS_LITE
if (attrfile != NULL && legacy)
usage(1);
-#else
- if (((ppdfile != NULL) + (attrfile != NULL) + legacy) > 1)
- usage(1);
-#endif /* CUPS_LITE */
-
- /*
- * Apply defaults as needed...
- */
+ // Apply defaults as needed...
if (!directory[0])
{
- const char *tmpdir; /* Temporary directory */
+ const char *tmpdir; // Temporary directory
#ifdef _WIN32
if ((tmpdir = getenv("TEMP")) == NULL)
#else
if ((tmpdir = getenv("TMPDIR")) == NULL)
tmpdir = "/tmp";
-#endif /* _WIN32 */
+#endif // _WIN32
snprintf(directory, sizeof(directory), "%s/ippeveprinter.%d", tmpdir, (int)getpid());
_cupsLangPrintf(stderr, _("Using spool directory \"%s\"."), directory);
}
- /*
- * Initialize DNS-SD...
- */
-
- dnssd_init();
-
- /*
- * Create the printer...
- */
-
- if (!docformats)
- docformats = cupsArrayNewStrings(ppm_color > 0 ? "image/jpeg,image/pwg-raster,image/urf": "image/pwg-raster,image/urf", ',');
-
+ // Create the printer...
if (attrfile)
attrs = load_ippserver_attributes(servername, serverport, attrfile, docformats);
-#if !CUPS_LITE
- else if (ppdfile)
- {
- attrs = load_ppd_attributes(ppdfile, docformats);
-
- if (!command)
- command = "ippeveps";
-
- if (!output_format)
- output_format = "application/postscript";
- }
-#endif /* !CUPS_LITE */
else
attrs = load_legacy_attributes(make, model, ppm, ppm_color, duplex, docformats);
+ if (!docformats && !ippFindAttribute(attrs, "document-format-supported", IPP_TAG_MIMETYPE))
+ docformats = cupsArrayNewStrings(ppm_color > 0 ? "image/jpeg,image/pwg-raster,image/urf": "image/pwg-raster,image/urf", ',');
+
if ((printer = create_printer(servername, serverport, name, location, icon, strings, docformats, subtypes, directory, command, device_uri, output_format, attrs)) == NULL)
return (1);
printer->web_forms = web_forms;
-#if !CUPS_LITE
- if (ppdfile)
- printer->ppdfile = strdup(ppdfile);
-#endif /* !CUPS_LITE */
-
cupsSetServerCredentials(keypath, printer->hostname, 1);
- /*
- * Run the print service...
- */
-
+ // Run the print service...
run_printer(printer);
- /*
- * Destroy the printer and exit...
- */
-
+ // Destroy the printer and exit...
delete_printer(printer);
return (0);
}
-/*
- * 'authenticate_request()' - Try to authenticate the request.
- */
+//
+// 'authenticate_request()' - Try to authenticate the request.
+//
-static http_status_t /* O - HTTP_STATUS_CONTINUE to keep going, otherwise status to return */
+static http_status_t // O - HTTP_STATUS_CONTINUE to keep going, otherwise status to return
authenticate_request(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
#if HAVE_LIBPAM
- /*
- * If PAM isn't enabled, return 'continue' now...
- */
-
- const char *authorization; /* Pointer into Authorization string */
- int userlen; /* Username:password length */
- pam_handle_t *pamh; /* PAM authentication handle */
- int pamerr; /* PAM error code */
- struct pam_conv pamdata; /* PAM conversation data */
- ippeve_authdata_t data; /* Authentication data */
+ // If PAM isn't enabled, return 'continue' now...
+ const char *authorization; // Pointer into Authorization string
+ int userlen; // Username:password length
+ pam_handle_t *pamh; // PAM authentication handle
+ int pamerr; // PAM error code
+ struct pam_conv pamdata; // PAM conversation data
+ ippeve_authdata_t data; // Authentication data
if (!PAMService)
return (HTTP_STATUS_CONTINUE);
- /*
- * Try authenticating using PAM...
- */
-
+ // Try authenticating using PAM...
authorization = httpGetField(client->http, HTTP_FIELD_AUTHORIZATION);
if (!*authorization)
return (HTTP_STATUS_CONTINUE);
#else
- /*
- * No authentication support built-in, return 'continue'...
- */
+ // No authentication support built-in, return 'continue'...
+ (void)client;
return (HTTP_STATUS_CONTINUE);
-#endif /* HAVE_LIBPAM */
+#endif // HAVE_LIBPAM
}
-/*
- * 'clean_jobs()' - Clean out old (completed) jobs.
- */
+//
+// 'clean_jobs()' - Clean out old (completed) jobs.
+//
static void
-clean_jobs(ippeve_printer_t *printer) /* I - Printer */
+clean_jobs(ippeve_printer_t *printer) // I - Printer
{
- ippeve_job_t *job; /* Current job */
- time_t cleantime; /* Clean time */
+ ippeve_job_t *job; // Current job
+ time_t cleantime; // Clean time
- if (cupsArrayCount(printer->jobs) == 0)
+ if (cupsArrayGetCount(printer->jobs) == 0)
return;
cleantime = time(NULL) - 60;
cupsRWLockWrite(&(printer->rwlock));
- for (job = (ippeve_job_t *)cupsArrayFirst(printer->jobs);
+ for (job = (ippeve_job_t *)cupsArrayGetFirst(printer->jobs);
job;
- job = (ippeve_job_t *)cupsArrayNext(printer->jobs))
+ job = (ippeve_job_t *)cupsArrayGetNext(printer->jobs))
if (job->completed && job->completed < cleantime)
{
cupsArrayRemove(printer->jobs, job);
}
-/*
- * 'compare_jobs()' - Compare two jobs.
- */
+//
+// 'compare_jobs()' - Compare two jobs.
+//
-static int /* O - Result of comparison */
-compare_jobs(ippeve_job_t *a, /* I - First job */
- ippeve_job_t *b) /* I - Second job */
+static int // O - Result of comparison
+compare_jobs(ippeve_job_t *a, // I - First job
+ ippeve_job_t *b) // I - Second job
{
return (b->id - a->id);
}
-/*
- * 'copy_attributes()' - Copy attributes from one request to another.
- */
+//
+// 'copy_attributes()' - Copy attributes from one request to another.
+//
static void
-copy_attributes(ipp_t *to, /* I - Destination request */
- ipp_t *from, /* I - Source request */
- cups_array_t *ra, /* I - Requested attributes */
- ipp_tag_t group_tag, /* I - Group to copy */
- int quickcopy) /* I - Do a quick copy? */
+copy_attributes(ipp_t *to, // I - Destination request
+ ipp_t *from, // I - Source request
+ cups_array_t *ra, // I - Requested attributes
+ ipp_tag_t group_tag, // I - Group to copy
+ bool quickcopy) // I - Do a quick copy?
{
- ippeve_filter_t filter; /* Filter data */
+ ippeve_filter_t filter; // Filter data
filter.ra = ra;
filter.group_tag = group_tag;
- ippCopyAttributes(to, from, quickcopy, (ipp_copycb_t)filter_cb, &filter);
+ ippCopyAttributes(to, from, quickcopy, (ipp_copy_cb_t)filter_cb, &filter);
}
-/*
- * 'copy_job_attrs()' - Copy job attributes to the response.
- */
+//
+// 'copy_job_attrs()' - Copy job attributes to the response.
+//
static void
copy_job_attributes(
- ippeve_client_t *client, /* I - Client */
- ippeve_job_t *job, /* I - Job */
- cups_array_t *ra) /* I - requested-attributes */
+ ippeve_client_t *client, // I - Client
+ ippeve_job_t *job, // I - Job
+ cups_array_t *ra) // I - requested-attributes
{
copy_attributes(client->response, job->attrs, ra, IPP_TAG_JOB, 0);
}
-/*
- * 'create_client()' - Accept a new network connection and create a client
- * object.
- */
+//
+// 'create_client()' - Accept a new network connection and create a client
+// object.
+//
-static ippeve_client_t * /* O - Client */
-create_client(ippeve_printer_t *printer, /* I - Printer */
- int sock) /* I - Listen socket */
+static ippeve_client_t * // O - Client
+create_client(ippeve_printer_t *printer, // I - Printer
+ int sock) // I - Listen socket
{
- ippeve_client_t *client; /* Client */
+ ippeve_client_t *client; // Client
if ((client = calloc(1, sizeof(ippeve_client_t))) == NULL)
client->printer = printer;
- /*
- * Accept the client and get the remote address...
- */
-
+ // Accept the client and get the remote address...
if ((client->http = httpAcceptConnection(sock, 1)) == NULL)
{
perror("Unable to accept client connection");
}
-/*
- * 'create_job()' - Create a new job object from a Print-Job or Create-Job
- * request.
- */
+//
+// 'create_job()' - Create a new job object from a Print-Job or Create-Job
+// request.
+//
-static ippeve_job_t * /* O - Job */
-create_job(ippeve_client_t *client) /* I - Client */
+static ippeve_job_t * // O - Job
+create_job(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job */
- ipp_attribute_t *attr; /* Job attribute */
- char uri[1024], /* job-uri value */
- uuid[64]; /* job-uuid value */
+ ippeve_job_t *job; // Job
+ ipp_attribute_t *attr; // Job attribute
+ char uri[1024], // job-uri value
+ uuid[64]; // job-uuid value
cupsRWLockWrite(&(client->printer->rwlock));
if (client->printer->active_job &&
client->printer->active_job->state < IPP_JSTATE_CANCELED)
{
- /*
- * Only accept a single job at a time...
- */
-
+ // Only accept a single job at a time...
cupsRWUnlock(&(client->printer->rwlock));
return (NULL);
}
- /*
- * Allocate and initialize the job object...
- */
-
+ // Allocate and initialize the job object...
if ((job = calloc(1, sizeof(ippeve_job_t))) == NULL)
{
perror("Unable to allocate memory for job");
job->state = IPP_JSTATE_HELD;
job->fd = -1;
- /*
- * Copy all of the job attributes...
- */
-
+ // Copy all of the job attributes...
copy_attributes(job->attrs, client->request, NULL, IPP_TAG_JOB, 0);
- /*
- * Get the requesting-user-name, document format, and priority...
- */
-
+ // Get the requesting-user-name, document format, and priority...
if ((attr = ippFindAttribute(client->request, "requesting-user-name", IPP_TAG_NAME)) != NULL)
job->username = ippGetString(attr, 0, NULL);
else
if ((attr = ippFindAttribute(client->request, "job-name", IPP_TAG_NAME)) != NULL)
job->name = ippGetString(attr, 0, NULL);
- /*
- * Add job description attributes and add to the jobs array...
- */
-
+ // Add job description attributes and add to the jobs array...
job->id = client->printer->next_job_id ++;
if ((attr = ippFindAttribute(client->request, "printer-uri", IPP_TAG_URI)) != NULL)
}
else
{
- char printer_uri[1024]; /* job-printer-uri value */
+ char printer_uri[1024]; // job-printer-uri value
httpAssembleURI(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri), "ipp", NULL, client->printer->hostname, client->printer->port, "/ipp/print");
ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL, printer_uri);
}
-/*
- * 'create_job_file()' - Create a file for the document in a job.
- */
+//
+// 'create_job_file()' - Create a file for the document in a job.
+//
-static int /* O - File descriptor or -1 on error */
+static int // O - File descriptor or -1 on error
create_job_file(
- ippeve_job_t *job, /* I - Job */
- char *fname, /* I - Filename buffer */
- size_t fnamesize, /* I - Size of filename buffer */
- const char *directory, /* I - Directory to store in */
- const char *ext) /* I - Extension (`NULL` for default) */
+ ippeve_job_t *job, // I - Job
+ char *fname, // I - Filename buffer
+ size_t fnamesize, // I - Size of filename buffer
+ const char *directory, // I - Directory to store in
+ const char *ext) // I - Extension (`NULL` for default)
{
- char name[256], /* "Safe" filename */
- *nameptr; /* Pointer into filename */
- const char *job_name; /* job-name value */
-
+ char name[256], // "Safe" filename
+ *nameptr; // Pointer into filename
+ const char *job_name; // job-name value
- /*
- * Make a name from the job-name attribute...
- */
+ // Make a name from the job-name attribute...
if ((job_name = ippGetString(ippFindAttribute(job->attrs, "job-name", IPP_TAG_NAME), 0, NULL)) == NULL)
job_name = "untitled";
*nameptr = '\0';
- /*
- * Figure out the extension...
- */
-
+ // Figure out the extension...
if (!ext)
{
if (!strcasecmp(job->format, "image/jpeg"))
ext = "dat";
}
- /*
- * Create a filename with the job-id, job-name, and document-format (extension)...
- */
-
+ // Create a filename with the job-id, job-name, and document-format (extension)...
snprintf(fname, fnamesize, "%s/%d-%s.%s", directory, job->id, name, ext);
return (open(fname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666));
}
-/*
- * 'create_listener()' - Create a listener socket.
- */
+//
+// 'create_listener()' - Create a listener socket.
+//
-static int /* O - Listener socket or -1 on error */
-create_listener(const char *name, /* I - Host name (`NULL` for any address) */
- int port, /* I - Port number */
- int family) /* I - Address family */
+static int // O - Listener socket or -1 on error
+create_listener(const char *name, // I - Host name (`NULL` for any address)
+ int port, // I - Port number
+ int family) // I - Address family
{
- int sock; /* Listener socket */
- http_addrlist_t *addrlist; /* Listen address */
- char service[255]; /* Service port */
+ int sock; // Listener socket
+ http_addrlist_t *addrlist; // Listen address
+ char service[255]; // Service port
snprintf(service, sizeof(service), "%d", port);
}
-/*
- * 'create_media_col()' - Create a media-col value.
- */
-
-static ipp_t * /* O - media-col collection */
-create_media_col(const char *media, /* I - Media name */
- const char *source, /* I - Media source, if any */
- const char *type, /* I - Media type, if any */
- int width, /* I - x-dimension in 2540ths */
- int length, /* I - y-dimension in 2540ths */
- int bottom, /* I - Bottom margin in 2540ths */
- int left, /* I - Left margin in 2540ths */
- int right, /* I - Right margin in 2540ths */
- int top) /* I - Top margin in 2540ths */
+//
+// 'create_media_col()' - Create a media-col value.
+//
+
+static ipp_t * // O - media-col collection
+create_media_col(const char *media, // I - Media name
+ const char *source, // I - Media source, if any
+ const char *type, // I - Media type, if any
+ ipp_t *media_size,// I - media-size collection value
+ int bottom, // I - Bottom margin in 2540ths
+ int left, // I - Left margin in 2540ths
+ int right, // I - Right margin in 2540ths
+ int top) // I - Top margin in 2540ths
{
- ipp_t *media_col = ippNew(), /* media-col value */
- *media_size = create_media_size(width, length);
- /* media-size value */
- char media_key[256]; /* media-key value */
- const char *media_key_suffix = ""; /* media-key suffix */
+ ipp_t *media_col = ippNew(); // media-col value
+ char media_key[256]; // media-key value
+ const char *media_key_suffix = ""; // media-key suffix
if (bottom == 0 && left == 0 && right == 0 && top == 0)
media_key_suffix = "_borderless";
- if (type && source)
- snprintf(media_key, sizeof(media_key), "%s_%s_%s%s", media, source, type, media_key_suffix);
- else if (type)
- snprintf(media_key, sizeof(media_key), "%s__%s%s", media, type, media_key_suffix);
- else if (source)
- snprintf(media_key, sizeof(media_key), "%s_%s%s", media, source, media_key_suffix);
- else
- snprintf(media_key, sizeof(media_key), "%s%s", media, media_key_suffix);
+ if (media)
+ {
+ if (type && source)
+ snprintf(media_key, sizeof(media_key), "%s_%s_%s%s", media, source, type, media_key_suffix);
+ else if (type)
+ snprintf(media_key, sizeof(media_key), "%s__%s%s", media, type, media_key_suffix);
+ else if (source)
+ snprintf(media_key, sizeof(media_key), "%s_%s%s", media, source, media_key_suffix);
+ else
+ snprintf(media_key, sizeof(media_key), "%s%s", media, media_key_suffix);
- ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-key", NULL, media_key);
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-key", NULL, media_key);
+ }
ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size);
- ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-size-name", NULL, media);
+ if (media)
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-size-name", NULL, media);
if (bottom >= 0)
ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin", bottom);
if (left >= 0)
}
-/*
- * 'create_media_size()' - Create a media-size value.
- */
+//
+// 'create_media_size()' - Create a media-size value.
+//
+
+static ipp_t * // O - media-col collection
+create_media_size(int width, // I - x-dimension in 2540ths
+ int length) // I - y-dimension in 2540ths
+{
+ ipp_t *media_size = ippNew(); // media-size value
+
+
+ ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER, "x-dimension", width);
+ ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER, "y-dimension", length);
+
+ return (media_size);
+}
+
+
+//
+// 'create_media_size_range()' - Create a ranged media-size value.
+//
-static ipp_t * /* O - media-col collection */
-create_media_size(int width, /* I - x-dimension in 2540ths */
- int length) /* I - y-dimension in 2540ths */
+static ipp_t * // O - media-col collection
+create_media_size_range(int min_width, // I - Minimum x-dimension in 2540ths
+ int max_width, // I - Maximum x-dimension in 2540ths
+ int min_length, // I - Minimum x-dimension in 2540ths
+ int max_length) // I - Maximum y-dimension in 2540ths
{
- ipp_t *media_size = ippNew(); /* media-size value */
+ ipp_t *media_size = ippNew(); // media-size value
- ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "x-dimension", width);
- ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension", length);
+ ippAddRange(media_size, IPP_TAG_ZERO, "x-dimension", min_width, max_width);
+ ippAddRange(media_size, IPP_TAG_ZERO, "y-dimension", min_length, max_length);
return (media_size);
}
-/*
- * 'create_printer()' - Create, register, and listen for connections to a
- * printer object.
- */
+//
+// 'create_printer()' - Create, register, and listen for connections to a
+// printer object.
+//
-static ippeve_printer_t * /* O - Printer */
+static ippeve_printer_t * // O - Printer
create_printer(
- const char *servername, /* I - Server hostname (NULL for default) */
- int serverport, /* I - Server port */
- const char *name, /* I - printer-name */
- const char *location, /* I - printer-location */
- const char *icons, /* I - printer-icons */
- const char *strings, /* I - printer-strings-uri */
- cups_array_t *docformats, /* I - document-format-supported */
- const char *subtypes, /* I - DNS-SD service subtype(s) */
- const char *directory, /* I - Spool directory */
- const char *command, /* I - Command to run on job files, if any */
- const char *device_uri, /* I - Output device, if any */
- const char *output_format, /* I - Output format, if any */
- ipp_t *attrs) /* I - Capability attributes */
+ const char *servername, // I - Server hostname (NULL for default)
+ int serverport, // I - Server port
+ const char *name, // I - printer-name
+ const char *location, // I - printer-location
+ const char *icons, // I - printer-icons
+ const char *strings, // I - printer-strings-uri
+ cups_array_t *docformats, // I - document-format-supported
+ const char *subtypes, // I - DNS-SD service subtype(s)
+ const char *directory, // I - Spool directory
+ const char *command, // I - Command to run on job files, if any
+ const char *device_uri, // I - Output device, if any
+ const char *output_format, // I - Output format, if any
+ ipp_t *attrs) // I - Capability attributes
{
- ippeve_printer_t *printer; /* Printer */
- int i; /* Looping var */
+ ippeve_printer_t *printer; // Printer
+ int i; // Looping var
#ifndef _WIN32
- char path[1024]; /* Full path to command */
-#endif /* !_WIN32 */
- unsigned char sha256[32]; /* SHA-256 digest/sum */
- char uuid_data[1024],/* Data to hash for printer-uuid */
- uuid[128], /* printer-uuid */
- *iconsptr; /* Pointer into icons string */
- int k_supported; /* Maximum file size supported */
- int num_formats; /* Number of supported document formats */
- const char *formats[100], /* Supported document formats */
- *format; /* Current format */
- int num_sup_attrs; /* Number of supported attributes */
- const char *sup_attrs[100];/* Supported attributes */
+ char path[1024]; // Full path to command
+#endif // !_WIN32
+ unsigned char sha256[32]; // SHA-256 digest/sum
+ char uuid_data[1024],// Data to hash for printer-uuid
+ uuid[128], // printer-uuid
+ *iconsptr; // Pointer into icons string
+ int k_supported; // Maximum file size supported
+ size_t num_formats = 0;// Number of supported document formats
+ const char *formats[100], // Supported document formats
+ *format; // Current format
+ size_t num_sup_attrs; // Number of supported attributes
+ const char *sup_attrs[100];// Supported attributes
char xxx_supported[256];
- /* Name of -supported attribute */
- _cups_globals_t *cg = _cupsGlobals();
- /* Global path values */
+ // Name of -supported attribute
#ifdef HAVE_STATVFS
- struct statvfs spoolinfo; /* FS info for spool directory */
- double spoolsize; /* FS size */
+ struct statvfs spoolinfo; // FS info for spool directory
+ double spoolsize; // FS size
#elif defined(HAVE_STATFS)
- struct statfs spoolinfo; /* FS info for spool directory */
- double spoolsize; /* FS size */
-#endif /* HAVE_STATVFS */
- static const char * const versions[] =/* ipp-versions-supported values */
+ struct statfs spoolinfo; // FS info for spool directory
+ double spoolsize; // FS size
+#endif // HAVE_STATVFS
+ static const char * const versions[] =// ipp-versions-supported values
{
"1.1",
"2.0"
};
- static const char * const features[] =/* ipp-features-supported values */
+ static const char * const features[] =// ipp-features-supported values
{
"ipp-everywhere"
};
- static const int ops[] = /* operations-supported values */
+ static const int ops[] = // operations-supported values
{
IPP_OP_PRINT_JOB,
IPP_OP_PRINT_URI,
IPP_OP_CLOSE_JOB,
IPP_OP_IDENTIFY_PRINTER
};
- static const char * const charsets[] =/* charset-supported values */
+ static const char * const charsets[] =// charset-supported values
{
"us-ascii",
"utf-8"
};
- static const char * const compressions[] =/* compression-supported values */
+ static const char * const compressions[] =// compression-supported values
{
-#ifdef HAVE_LIBZ
"deflate",
"gzip",
-#endif /* HAVE_LIBZ */
"none"
};
static const char * const identify_actions[] =
"sound"
};
static const char * const job_creation[] =
- { /* job-creation-attributes-supported values */
+ { // job-creation-attributes-supported values
"copies",
"document-access",
"document-charset",
"y-side2-image-shift"
};
static const char * const media_col_supported[] =
- { /* media-col-supported values */
+ { // media-col-supported values
"media-bottom-margin",
"media-left-margin",
"media-right-margin",
"media-type"
};
static const char * const multiple_document_handling[] =
- { /* multiple-document-handling-supported values */
+ { // multiple-document-handling-supported values
"separate-documents-uncollated-copies",
"separate-documents-collated-copies"
};
static const char * const reference_uri_schemes_supported[] =
- { /* reference-uri-schemes-supported */
+ { // reference-uri-schemes-supported
"file",
"ftp",
"http",
"https"
};
static const char * const uri_authentication_supported[] =
- { /* uri-authentication-supported values */
+ { // uri-authentication-supported values
"none",
"none"
};
static const char * const uri_authentication_basic[] =
- { /* uri-authentication-supported values with authentication */
+ { // uri-authentication-supported values with authentication
"basic",
"basic"
};
static const char * const uri_security_supported[] =
- { /* uri-security-supported values */
+ { // uri-security-supported values
"none",
"tls"
};
static const char * const which_jobs[] =
- { /* which-jobs-supported values */
+ { // which-jobs-supported values
"completed",
"not-completed",
"aborted",
#ifndef _WIN32
- /*
- * If a command was specified, make sure it exists and is executable...
- */
-
- if (command)
+ // If a command was specified, make sure it exists and is executable...
+ if (command && access(command, X_OK))
{
- if (*command == '/' || !strncmp(command, "./", 2))
+ if (cupsFileFind(command, getenv("PATH"), true, path, sizeof(path)))
{
- if (access(command, X_OK))
- {
- _cupsLangPrintf(stderr, _("Unable to execute command \"%s\": %s"), command, strerror(errno));
- return (NULL);
- }
+ // Found the command in the current path...
+ command = path;
}
else
{
- snprintf(path, sizeof(path), "%s/command/%s", cg->cups_serverbin, command);
-
- if (access(path, X_OK))
- {
- _cupsLangPrintf(stderr, _("Unable to execute command \"%s\": %s"), path, strerror(errno));
- return (NULL);
- }
-
- command = path;
+ // No command...
+ _cupsLangPrintf(stderr, _("Unable to execute command \"%s\": %s"), command, strerror(errno));
+ return (NULL);
}
}
-#endif /* !_WIN32 */
-
- /*
- * Allocate memory for the printer...
- */
+#endif // !_WIN32
+ // Allocate memory for the printer...
if ((printer = calloc(1, sizeof(ippeve_printer_t))) == NULL)
{
- _cupsLangPrintError(NULL, _("Unable to allocate memory for printer"));
+ _cupsLangPrintf(stderr, _("Unable to allocate memory for printer: %s"), strerror(errno));
return (NULL);
}
printer->ipv4 = -1;
printer->ipv6 = -1;
printer->name = strdup(name);
+ printer->dnssd = cupsDNSSDNew(NULL, NULL);
printer->dnssd_name = strdup(name);
printer->dnssd_subtypes = subtypes ? strdup(subtypes) : NULL;
printer->command = command ? strdup(command) : NULL;
printer->state = IPP_PSTATE_IDLE;
printer->state_reasons = IPPEVE_PREASON_NONE;
printer->state_time = printer->start_time;
- printer->jobs = cupsArrayNew((cups_array_func_t)compare_jobs, NULL);
+ printer->jobs = cupsArrayNew3((cups_array_cb_t)compare_jobs, NULL, NULL, 0, NULL, NULL);
printer->next_job_id = 1;
if (printer->icons[0])
{
- /*
- * Extract up to 3 icons...
- */
-
+ // Extract up to 3 icons...
for (i = 1, iconsptr = strchr(printer->icons[0], ','); iconsptr && i < 3; i ++, iconsptr = strchr(iconsptr, ','))
{
*iconsptr++ = '\0';
}
if (iconsptr)
- *iconsptr = '\0'; /* Strip any icons after the third... */
+ *iconsptr = '\0'; // Strip any icons after the third...
while (i < 3)
{
}
else
{
- char temp[1024], /* Temporary string */
- *tempptr; /* Pointer into temporary string */
-
-#ifdef HAVE_AVAHI
- const char *avahi_name = avahi_client_get_host_name_fqdn(DNSSDClient);
-
- if (avahi_name)
- cupsCopyString(temp, avahi_name, sizeof(temp));
- else
-#endif /* HAVE_AVAHI */
-
- if ((tempptr = strstr(httpGetHostname(NULL, temp, sizeof(temp)), ".lan")) != NULL && !tempptr[5])
- cupsCopyString(tempptr, ".local", sizeof(temp) - (size_t)(tempptr - temp));
+ char temp[1024]; // Temporary string
- printer->hostname = strdup(temp);
+ printer->hostname = strdup(cupsDNSSDCopyHostName(printer->dnssd, temp, sizeof(temp)));
}
cupsRWInit(&(printer->rwlock));
- /*
- * Create the listener sockets...
- */
-
+ // Create the listener sockets...
if (printer->port)
{
if ((printer->ipv4 = create_listener(servername, printer->port, AF_INET)) < 0)
else
{
#ifdef _WIN32
- /*
- * Windows is almost always used as a single user system, so use a default
- * port number of 8631.
- */
-
+ // Windows is almost always used as a single user system, so use a default
+ // port number of 8631.
serverport = 8631;
#else
- /*
- * Use 8000 + UID mod 1000 for the default port number...
- */
-
+ // Use 8000 + UID mod 1000 for the default port number...
serverport = 8000 + ((int)getuid() % 1000);
-#endif /* _WIN32 */
+#endif // _WIN32
while (serverport < 10000)
{
goto bad_printer;
}
- /*
- * Prepare values for the printer attributes...
- */
-
+ // Prepare values for the printer attributes...
snprintf(uuid_data, sizeof(uuid_data), "_IPPEVEPRINTER_:%s:%d:%s", printer->hostname, printer->port, printer->name);
cupsHashData("sha2-256", (unsigned char *)uuid_data, strlen(uuid_data), sha256, sizeof(sha256));
snprintf(uuid, sizeof(uuid), "urn:uuid:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", sha256[0], sha256[1], sha256[3], sha256[4], sha256[5], sha256[6], (sha256[10] & 15) | 0x30, sha256[11], (sha256[15] & 0x3f) | 0x40, sha256[16], sha256[20], sha256[21], sha256[25], sha256[26], sha256[30], sha256[31]);
fprintf(stderr, "printer-uuid=\"%s\"\n", uuid);
}
- /*
- * Get the maximum spool size based on the size of the filesystem used for
- * the spool directory. If the host OS doesn't support the statfs call
- * or the filesystem is larger than 2TiB, always report INT_MAX.
- */
-
+ // Get the maximum spool size based on the size of the filesystem used for
+ // the spool directory. If the host OS doesn't support the statfs call
+ // or the filesystem is larger than 2TiB, always report INT_MAX.
#ifdef HAVE_STATVFS
if (statvfs(printer->directory, &spoolinfo))
k_supported = INT_MAX;
#else
k_supported = INT_MAX;
-#endif /* HAVE_STATVFS */
-
- /*
- * Assemble the final list of document formats...
- */
+#endif // HAVE_STATVFS
- if (!cupsArrayFind(docformats, (void *)"application/octet-stream"))
- cupsArrayAdd(docformats, (void *)"application/octet-stream");
-
- for (num_formats = 0, format = (const char *)cupsArrayFirst(docformats); format && num_formats < (int)(sizeof(formats) / sizeof(formats[0])); format = (const char *)cupsArrayNext(docformats))
- formats[num_formats ++] = format;
+ // Assemble the final list of document formats...
+ if (docformats)
+ {
+ if (!cupsArrayFind(docformats, (void *)"application/octet-stream"))
+ cupsArrayAdd(docformats, (void *)"application/octet-stream");
- /*
- * Get the list of attributes that can be used when creating a job...
- */
+ for (format = (const char *)cupsArrayGetFirst(docformats); format && num_formats < (sizeof(formats) / sizeof(formats[0])); format = (const char *)cupsArrayGetNext(docformats))
+ formats[num_formats ++] = format;
+ }
+ // Get the list of attributes that can be used when creating a job...
num_sup_attrs = 0;
sup_attrs[num_sup_attrs ++] = "document-access";
sup_attrs[num_sup_attrs ++] = "document-charset";
sup_attrs[num_sup_attrs ++] = job_creation[i];
}
- /*
- * Fill out the rest of the printer attributes.
- */
-
+ // Fill out the rest of the printer attributes.
printer->attrs = attrs;
- /* charset-configured */
+ // charset-configured
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_CHARSET), "charset-configured", NULL, "utf-8");
- /* charset-supported */
+ // charset-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_CHARSET), "charset-supported", sizeof(charsets) / sizeof(charsets[0]), NULL, charsets);
- /* compression-supported */
+ // compression-supported
if (!ippFindAttribute(printer->attrs, "compression-supported", IPP_TAG_ZERO))
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "compression-supported", (int)(sizeof(compressions) / sizeof(compressions[0])), NULL, compressions);
- /* document-format-default */
- ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_MIMETYPE), "document-format-default", NULL, "application/octet-stream");
+ if (docformats)
+ {
+ // document-format-default
+ if (!ippFindAttribute(printer->attrs, "document-format-default", IPP_TAG_MIMETYPE))
+ ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_MIMETYPE), "document-format-default", NULL, "application/octet-stream");
- /* document-format-supported */
- ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", num_formats, NULL, formats);
+ // document-format-supported
+ if (!ippFindAttribute(printer->attrs, "document-format-supported", IPP_TAG_MIMETYPE))
+ ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_MIMETYPE, "document-format-supported", num_formats, NULL, formats);
+ }
- /* generated-natural-language-supported */
+ // generated-natural-language-supported
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_LANGUAGE), "generated-natural-language-supported", NULL, "en");
- /* identify-actions-default */
+ // identify-actions-default
ippAddString (printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "identify-actions-default", NULL, "sound");
- /* identify-actions-supported */
+ // identify-actions-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "identify-actions-supported", sizeof(identify_actions) / sizeof(identify_actions[0]), NULL, identify_actions);
- /* ipp-features-supported */
+ // ipp-features-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "ipp-features-supported", sizeof(features) / sizeof(features[0]), NULL, features);
- /* ipp-versions-supported */
+ // ipp-versions-supported
if (MaxVersion == 11)
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "ipp-versions-supported", NULL, "1.1");
else
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "ipp-versions-supported", (int)(sizeof(versions) / sizeof(versions[0])), NULL, versions);
- /* job-creation-attributes-supported */
+ // job-creation-attributes-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "job-creation-attributes-supported", num_sup_attrs, NULL, sup_attrs);
- /* job-ids-supported */
+ // job-ids-supported
ippAddBoolean(printer->attrs, IPP_TAG_PRINTER, "job-ids-supported", 1);
- /* job-k-octets-supported */
+ // job-k-octets-supported
ippAddRange(printer->attrs, IPP_TAG_PRINTER, "job-k-octets-supported", 0, k_supported);
- /* job-priority-default */
+ // job-priority-default
ippAddInteger(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "job-priority-default", 50);
- /* job-priority-supported */
+ // job-priority-supported
ippAddInteger(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "job-priority-supported", 1);
- /* job-sheets-default */
+ // job-sheets-default
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_NAME), "job-sheets-default", NULL, "none");
- /* job-sheets-supported */
+ // job-sheets-supported
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_NAME), "job-sheets-supported", NULL, "none");
- /* media-col-supported */
+ // media-col-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-col-supported", (int)(sizeof(media_col_supported) / sizeof(media_col_supported[0])), NULL, media_col_supported);
- /* multiple-document-handling-supported */
+ // multiple-document-handling-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "multiple-document-handling-supported", sizeof(multiple_document_handling) / sizeof(multiple_document_handling[0]), NULL, multiple_document_handling);
- /* multiple-document-jobs-supported */
+ // multiple-document-jobs-supported
ippAddBoolean(printer->attrs, IPP_TAG_PRINTER, "multiple-document-jobs-supported", 0);
- /* multiple-operation-time-out */
+ // multiple-operation-time-out
ippAddInteger(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "multiple-operation-time-out", 60);
- /* multiple-operation-time-out-action */
+ // multiple-operation-time-out-action
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "multiple-operation-time-out-action", NULL, "abort-job");
- /* natural-language-configured */
+ // natural-language-configured
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_LANGUAGE), "natural-language-configured", NULL, "en");
- /* operations-supported */
+ // operations-supported
ippAddIntegers(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "operations-supported", sizeof(ops) / sizeof(ops[0]), ops);
- /* pdl-override-supported */
+ // pdl-override-supported
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pdl-override-supported", NULL, "attempted");
- /* preferred-attributes-supported */
+ // preferred-attributes-supported
ippAddBoolean(printer->attrs, IPP_TAG_PRINTER, "preferred-attributes-supported", 0);
- /* printer-get-attributes-supported */
+ // printer-get-attributes-supported
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "printer-get-attributes-supported", NULL, "document-format");
- /* printer-geo-location */
+ // printer-geo-location
ippAddOutOfBand(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_UNKNOWN, "printer-geo-location");
- /* printer-is-accepting-jobs */
+ // printer-is-accepting-jobs
ippAddBoolean(printer->attrs, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
- /* printer-info */
+ // printer-info
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info", NULL, name);
- /* printer-location */
+ // printer-location
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-location", NULL, location);
- /* printer-name */
+ // printer-name
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, name);
- /* printer-organization */
+ // printer-organization
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_TEXT), "printer-organization", NULL, "");
- /* printer-organizational-unit */
+ // printer-organizational-unit
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_TEXT), "printer-organizational-unit", NULL, "");
- /* printer-strings-languages-supported */
+ // printer-strings-languages-supported
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_LANGUAGE, "printer-strings-languages-supported", NULL, "en");
- /* printer-uuid */
+ // printer-uuid
ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-uuid", NULL, uuid);
- /* reference-uri-scheme-supported */
+ // reference-uri-scheme-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_URISCHEME), "reference-uri-schemes-supported", (int)(sizeof(reference_uri_schemes_supported) / sizeof(reference_uri_schemes_supported[0])), NULL, reference_uri_schemes_supported);
- /* uri-authentication-supported */
+ // uri-authentication-supported
if (PAMService)
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "uri-authentication-supported", 2, NULL, uri_authentication_basic);
else
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "uri-authentication-supported", 2, NULL, uri_authentication_supported);
- /* uri-security-supported */
+ // uri-security-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "uri-security-supported", 2, NULL, uri_security_supported);
- /* which-jobs-supported */
+ // which-jobs-supported
ippAddStrings(printer->attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "which-jobs-supported", sizeof(which_jobs) / sizeof(which_jobs[0]), NULL, which_jobs);
debug_attributes("Printer", printer->attrs, 0);
- /*
- * Register the printer with DNS-SD...
- */
-
+ // Register the printer with DNS-SD...
if (!register_printer(printer))
goto bad_printer;
- /*
- * Return it!
- */
-
+ // Return it!
return (printer);
- /*
- * If we get here we were unable to create the printer...
- */
-
+ // If we get here we were unable to create the printer...
bad_printer:
delete_printer(printer);
}
-/*
- * 'debug_attributes()' - Print attributes in a request or response.
- */
+//
+// 'debug_attributes()' - Print attributes in a request or response.
+//
static void
-debug_attributes(const char *title, /* I - Title */
- ipp_t *ipp, /* I - Request/response */
- int type) /* I - 0 = object, 1 = request, 2 = response */
+debug_attributes(const char *title, // I - Title
+ ipp_t *ipp, // I - Request/response
+ int type) // I - 0 = object, 1 = request, 2 = response
{
- ipp_tag_t group_tag; /* Current group */
- ipp_attribute_t *attr; /* Current attribute */
- char buffer[2048]; /* String buffer for value */
- int major, minor; /* Version */
+ ipp_tag_t group_tag; // Current group
+ ipp_attribute_t *attr; // Current attribute
+ char buffer[2048]; // String buffer for value
+ int major, minor; // Version
if (Verbosity <= 1)
ippErrorString(ippGetStatusCode(ipp)), ippGetStatusCode(ipp));
fprintf(stderr, " request-id=%d\n\n", ippGetRequestId(ipp));
- for (attr = ippFirstAttribute(ipp), group_tag = IPP_TAG_ZERO;
+ for (attr = ippGetFirstAttribute(ipp), group_tag = IPP_TAG_ZERO;
attr;
- attr = ippNextAttribute(ipp))
+ attr = ippGetNextAttribute(ipp))
{
if (ippGetGroupTag(attr) != group_tag)
{
}
-/*
- * 'delete_client()' - Close the socket and free all memory used by a client
- * object.
- */
+//
+// 'delete_client()' - Close the socket and free all memory used by a client
+// object.
+//
static void
-delete_client(ippeve_client_t *client) /* I - Client */
+delete_client(ippeve_client_t *client) // I - Client
{
if (Verbosity)
fprintf(stderr, "Closing connection from %s\n", client->hostname);
- /*
- * Flush pending writes before closing...
- */
-
+ // Flush pending writes before closing...
httpFlushWrite(client->http);
- /*
- * Free memory...
- */
-
+ // Free memory...
httpClose(client->http);
ippDelete(client->request);
}
-/*
- * 'delete_job()' - Remove from the printer and free all memory used by a job
- * object.
- */
+//
+// 'delete_job()' - Remove from the printer and free all memory used by a job
+// object.
+//
static void
-delete_job(ippeve_job_t *job) /* I - Job */
+delete_job(ippeve_job_t *job) // I - Job
{
if (Verbosity)
fprintf(stderr, "[Job %d] Removing job from history.\n", job->id);
}
-/*
- * 'delete_printer()' - Unregister, close listen sockets, and free all memory
- * used by a printer object.
- */
+//
+// 'delete_printer()' - Unregister, close listen sockets, and free all memory
+// used by a printer object.
+//
static void
-delete_printer(ippeve_printer_t *printer) /* I - Printer */
+delete_printer(
+ ippeve_printer_t *printer) // I - Printer
{
if (printer->ipv4 >= 0)
close(printer->ipv4);
if (printer->ipv6 >= 0)
close(printer->ipv6);
-#if HAVE_MDNSRESPONDER
- if (printer->printer_ref)
- DNSServiceRefDeallocate(printer->printer_ref);
- if (printer->ipp_ref)
- DNSServiceRefDeallocate(printer->ipp_ref);
- if (printer->ipps_ref)
- DNSServiceRefDeallocate(printer->ipps_ref);
- if (printer->http_ref)
- DNSServiceRefDeallocate(printer->http_ref);
-#elif defined(HAVE_AVAHI)
- avahi_threaded_poll_lock(DNSSDMaster);
-
- if (printer->dnssd_ref)
- avahi_entry_group_free(printer->dnssd_ref);
-
- avahi_threaded_poll_unlock(DNSSDMaster);
-#endif /* HAVE_MDNSRESPONDER */
+ cupsDNSSDDelete(printer->dnssd);
if (printer->dnssd_name)
free(printer->dnssd_name);
free(printer->command);
if (printer->device_uri)
free(printer->device_uri);
-#if !CUPS_LITE
- if (printer->ppdfile)
- free(printer->ppdfile);
-#endif /* !CUPS_LITE */
if (printer->directory)
free(printer->directory);
if (printer->hostname)
}
-#ifdef HAVE_MDNSRESPONDER
-/*
- * 'dnssd_callback()' - Handle DNS-SD registration events.
- */
-
-static void DNSSD_API
-dnssd_callback(
- DNSServiceRef sdRef, /* I - Service reference */
- DNSServiceFlags flags, /* I - Status flags */
- DNSServiceErrorType errorCode, /* I - Error, if any */
- const char *name, /* I - Service name */
- const char *regtype, /* I - Service type */
- const char *domain, /* I - Domain for service */
- ippeve_printer_t *printer) /* I - Printer */
-{
- (void)sdRef;
- (void)flags;
- (void)domain;
- (void)name;
-
- if (errorCode == kDNSServiceErr_NameConflict)
- {
- fputs("DNS-SD service name collision detected.\n", stderr);
- printer->dnssd_collision = 1;
- }
- else if (errorCode)
- {
- fprintf(stderr, "DNSServiceRegister for %s failed with error %d.\n", regtype, (int)errorCode);
- return;
- }
-}
-
-
-#elif defined(HAVE_AVAHI)
-/*
- * 'dnssd_callback()' - Handle DNS-SD registration events.
- */
+//
+// 'dnssd_callback()' - Handle DNS-SD registration events.
+//
static void
dnssd_callback(
- AvahiEntryGroup *srv, /* I - Service */
- AvahiEntryGroupState state, /* I - Registration state */
- void *context) /* I - Printer */
+ cups_dnssd_service_t *service, // I - Service registration
+ ippeve_printer_t *printer, // I - Printer
+ cups_dnssd_flags_t flags) // I - Status flags
{
- ippeve_printer_t *printer = (ippeve_printer_t *)context;
- /* Printer */
-
+ (void)service;
- (void)srv;
-
- if (state == AVAHI_ENTRY_GROUP_COLLISION)
+ if (flags & CUPS_DNSSD_FLAGS_COLLISION)
{
fputs("DNS-SD service name collision detected.\n", stderr);
printer->dnssd_collision = 1;
}
-/*
- * 'dnssd_client_cb()' - Client callback for Avahi.
- *
- * Called whenever the client or server state changes...
- */
-
-static void
-dnssd_client_cb(
- AvahiClient *c, /* I - Client */
- AvahiClientState state, /* I - Current state */
- void *userdata) /* I - User data (printer) */
-{
- if (!c)
- return;
-
- if (state == AVAHI_CLIENT_FAILURE)
- {
- if (avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED)
- {
- fputs("Avahi server crashed, exiting.\n", stderr);
- exit(1);
- }
- }
- else
- {
- fprintf(stderr, "Ignored Avahi state %d.\n", state);
- }
-}
-#endif /* HAVE_MDNSRESPONDER */
-
-
-/*
- * 'dnssd_init()' - Initialize the DNS-SD service connections...
- */
-
-static void
-dnssd_init(void)
-{
-#ifdef HAVE_MDNSRESPONDER
- if (DNSServiceCreateConnection(&DNSSDMaster) != kDNSServiceErr_NoError)
- {
- fputs("Error: Unable to initialize DNS-SD.\n", stderr);
- exit(1);
- }
-
-#elif defined(HAVE_AVAHI)
- int error; /* Error code, if any */
-
- if ((DNSSDMaster = avahi_threaded_poll_new()) == NULL)
- {
- fputs("Error: Unable to initialize DNS-SD.\n", stderr);
- exit(1);
- }
-
- if ((DNSSDClient = avahi_client_new(avahi_threaded_poll_get(DNSSDMaster), AVAHI_CLIENT_NO_FAIL, dnssd_client_cb, NULL, &error)) == NULL)
- {
- fputs("Error: Unable to initialize DNS-SD.\n", stderr);
- exit(1);
- }
-
- avahi_threaded_poll_start(DNSSDMaster);
-#endif /* HAVE_MDNSRESPONDER */
-}
-
-
-/*
- * 'filter_cb()' - Filter printer attributes based on the requested array.
- */
+//
+// 'filter_cb()' - Filter printer attributes based on the requested array.
+//
-static int /* O - 1 to copy, 0 to ignore */
-filter_cb(ippeve_filter_t *filter, /* I - Filter parameters */
- ipp_t *dst, /* I - Destination (unused) */
- ipp_attribute_t *attr) /* I - Source attribute */
+static int // O - 1 to copy, 0 to ignore
+filter_cb(ippeve_filter_t *filter, // I - Filter parameters
+ ipp_t *dst, // I - Destination (unused)
+ ipp_attribute_t *attr) // I - Source attribute
{
- /*
- * Filter attributes as needed...
- */
-
-#ifndef _WIN32 /* Avoid MS compiler bug */
+ // Filter attributes as needed...
+#ifndef _WIN32 // Avoid MS compiler bug
(void)dst;
-#endif /* !_WIN32 */
+#endif // !_WIN32
ipp_tag_t group = ippGetGroupTag(attr);
const char *name = ippGetName(attr);
}
-/*
- * 'find_job()' - Find a job specified in a request.
- */
+//
+// 'find_job()' - Find a job specified in a request.
+//
-static ippeve_job_t * /* O - Job or NULL */
-find_job(ippeve_client_t *client) /* I - Client */
+static ippeve_job_t * // O - Job or NULL
+find_job(ippeve_client_t *client) // I - Client
{
- ipp_attribute_t *attr; /* job-id or job-uri attribute */
- ippeve_job_t key, /* Job search key */
- *job; /* Matching job, if any */
+ ipp_attribute_t *attr; // job-id or job-uri attribute
+ ippeve_job_t key, // Job search key
+ *job; // Matching job, if any
if ((attr = ippFindAttribute(client->request, "job-uri", IPP_TAG_URI)) != NULL)
{
const char *uri = ippGetString(attr, 0, NULL);
- /* URI value */
+ // URI value
const char *uriptr = strrchr(uri, '/');
- /* Pointer to the last slash in the URI */
+ // Pointer to the last slash in the URI
if (uriptr && isdigit(uriptr[1] & 255))
key.id = atoi(uriptr + 1);
}
-/*
- * 'finish_document()' - Finish receiving a document file and start processing.
- */
+//
+// 'finish_document()' - Finish receiving a document file and start processing.
+//
static void
finish_document_data(
- ippeve_client_t *client, /* I - Client */
- ippeve_job_t *job) /* I - Job */
+ ippeve_client_t *client, // I - Client
+ ippeve_job_t *job) // I - Job
{
- char filename[1024], /* Filename buffer */
- buffer[4096]; /* Copy buffer */
- ssize_t bytes; /* Bytes read */
- cups_array_t *ra; /* Attributes to send in response */
- cups_thread_t t; /* Thread */
+ char filename[1024], // Filename buffer
+ buffer[4096]; // Copy buffer
+ ssize_t bytes; // Bytes read
+ cups_array_t *ra; // Attributes to send in response
+ cups_thread_t t; // Thread
- /*
- * Create a file for the request data...
- *
- * TODO: Update code to support piping large raster data to the print command.
- */
-
+ // Create a file for the request data...
+ //
+ // TODO: Update code to support piping large raster data to the print command.
if ((job->fd = create_job_file(job, filename, sizeof(filename), client->printer->directory, NULL)) < 0)
{
respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to create print file: %s", strerror(errno));
if (Verbosity)
fprintf(stderr, "Created job file \"%s\", format \"%s\".\n", filename, job->format);
- while ((bytes = httpRead2(client->http, buffer, sizeof(buffer))) > 0)
+ while ((bytes = httpRead(client->http, buffer, sizeof(buffer))) > 0)
{
if (write(job->fd, buffer, (size_t)bytes) < bytes)
{
- int error = errno; /* Write error */
+ int error = errno; // Write error
close(job->fd);
job->fd = -1;
if (bytes < 0)
{
- /*
- * Got an error while reading the print data, so abort this job.
- */
-
+ // Got an error while reading the print data, so abort this job.
close(job->fd);
job->fd = -1;
if (close(job->fd))
{
- int error = errno; /* Write error */
+ int error = errno; // Write error
job->fd = -1;
job->filename = strdup(filename);
job->state = IPP_JSTATE_PENDING;
- /*
- * Process the job...
- */
-
+ // Process the job...
t = cupsThreadCreate((cups_thread_func_t)process_job, job);
if (t)
goto abort_job;
}
- /*
- * Return the job info...
- */
-
+ // Return the job info...
respond_ipp(client, IPP_STATUS_OK, NULL);
- ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ ra = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
cupsArrayAdd(ra, "job-id");
cupsArrayAdd(ra, "job-state");
cupsArrayAdd(ra, "job-state-message");
cupsArrayDelete(ra);
return;
- /*
- * If we get here we had to abort the job...
- */
-
+ // If we get here we had to abort the job...
abort_job:
job->state = IPP_JSTATE_ABORTED;
job->completed = time(NULL);
- ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ ra = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
cupsArrayAdd(ra, "job-id");
cupsArrayAdd(ra, "job-state");
cupsArrayAdd(ra, "job-state-reasons");
}
-/*
- * 'finish_uri()' - Finish fetching a document URI and start processing.
- */
+//
+// 'finish_uri()' - Finish fetching a document URI and start processing.
+//
static void
finish_document_uri(
- ippeve_client_t *client, /* I - Client */
- ippeve_job_t *job) /* I - Job */
+ ippeve_client_t *client, // I - Client
+ ippeve_job_t *job) // I - Job
{
- ipp_attribute_t *uri; /* document-uri */
- char scheme[256], /* URI scheme */
- userpass[256], /* Username and password info */
- hostname[256], /* Hostname */
- resource[1024]; /* Resource path */
- int port; /* Port number */
- http_uri_status_t uri_status; /* URI decode status */
- http_encryption_t encryption; /* Encryption to use, if any */
- http_t *http; /* Connection for http/https URIs */
- http_status_t status; /* Access status for http/https URIs */
- int infile; /* Input file for local file URIs */
- char filename[1024], /* Filename buffer */
- buffer[4096]; /* Copy buffer */
- ssize_t bytes; /* Bytes read */
- ipp_attribute_t *attr; /* Current attribute */
- cups_array_t *ra; /* Attributes to send in response */
-
-
- /*
- * Do we have a file to print?
- */
-
+ ipp_attribute_t *uri; // document-uri
+ char scheme[256], // URI scheme
+ userpass[256], // Username and password info
+ hostname[256], // Hostname
+ resource[1024]; // Resource path
+ int port; // Port number
+ http_uri_status_t uri_status; // URI decode status
+ http_encryption_t encryption; // Encryption to use, if any
+ http_t *http; // Connection for http/https URIs
+ http_status_t status; // Access status for http/https URIs
+ int infile; // Input file for local file URIs
+ char filename[1024], // Filename buffer
+ buffer[4096]; // Copy buffer
+ ssize_t bytes; // Bytes read
+ ipp_attribute_t *attr; // Current attribute
+ cups_array_t *ra; // Attributes to send in response
+
+
+ // Do we have a file to print?
if (have_document_data(client))
{
flush_document_data(client);
goto abort_job;
}
- /*
- * Do we have a document URI?
- */
-
+ // Do we have a document URI?
if ((uri = ippFindAttribute(client->request, "document-uri", IPP_TAG_URI)) == NULL)
{
respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "Missing document-uri.");
goto abort_job;
}
- if (!strcmp(scheme, "file") && access(resource, R_OK))
- {
- respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to access URI: %s", strerror(errno));
-
- goto abort_job;
- }
-
- /*
- * Get the document format for the job...
- */
-
+ // Get the document format for the job...
cupsRWLockWrite(&(client->printer->rwlock));
if ((attr = ippFindAttribute(job->attrs, "document-format", IPP_TAG_MIMETYPE)) != NULL)
else
job->format = "application/octet-stream";
- /*
- * Create a file for the request data...
- */
-
+ // Create a file for the request data...
if ((job->fd = create_job_file(job, filename, sizeof(filename), client->printer->directory, NULL)) < 0)
{
cupsRWUnlock(&(client->printer->rwlock));
}
else if (bytes > 0 && write(job->fd, buffer, (size_t)bytes) < bytes)
{
- int error = errno; /* Write error */
+ int error = errno; // Write error
close(job->fd);
job->fd = -1;
httpClearFields(http);
httpSetField(http, HTTP_FIELD_ACCEPT_LANGUAGE, "en");
- if (httpGet(http, resource))
+ if (!httpWriteRequest(http, "GET", resource))
{
respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to GET URI: %s", strerror(errno));
if (status != HTTP_STATUS_OK)
{
- respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to GET URI: %s", httpStatus(status));
+ respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to GET URI: %s", httpStatusString(status));
close(job->fd);
job->fd = -1;
goto abort_job;
}
- while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0)
+ while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0)
{
if (write(job->fd, buffer, (size_t)bytes) < bytes)
{
- int error = errno; /* Write error */
+ int error = errno; // Write error
close(job->fd);
job->fd = -1;
if (close(job->fd))
{
- int error = errno; /* Write error */
+ int error = errno; // Write error
job->fd = -1;
cupsRWUnlock(&(client->printer->rwlock));
- /*
- * Process the job...
- */
-
+ // Process the job...
process_job(job);
- /*
- * Return the job info...
- */
-
+ // Return the job info...
respond_ipp(client, IPP_STATUS_OK, NULL);
- ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ ra = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
cupsArrayAdd(ra, "job-id");
cupsArrayAdd(ra, "job-state");
cupsArrayAdd(ra, "job-state-reasons");
cupsArrayDelete(ra);
return;
- /*
- * If we get here we had to abort the job...
- */
-
+ // If we get here we had to abort the job...
abort_job:
job->state = IPP_JSTATE_ABORTED;
job->completed = time(NULL);
- ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ ra = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
cupsArrayAdd(ra, "job-id");
cupsArrayAdd(ra, "job-state");
cupsArrayAdd(ra, "job-state-reasons");
}
-/*
- * 'flush_document_data()' - Safely flush remaining document data.
- */
+//
+// 'flush_document_data()' - Safely flush remaining document data.
+//
static void
flush_document_data(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- char buffer[8192]; /* Read buffer */
+ char buffer[8192]; // Read buffer
if (httpGetState(client->http) == HTTP_STATE_POST_RECV)
{
- while (httpRead2(client->http, buffer, sizeof(buffer)) > 0);
+ while (httpRead(client->http, buffer, sizeof(buffer)) > 0);
}
}
-/*
- * 'have_document_data()' - Determine whether we have more document data.
- */
+//
+// 'have_document_data()' - Determine whether we have more document data.
+//
-static int /* O - 1 if data is present, 0 otherwise */
+static bool // O - `true` if data is present, `false` otherwise
have_document_data(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- char temp; /* Data */
+ char temp; // Data
if (httpGetState(client->http) != HTTP_STATE_POST_RECV)
- return (0);
+ return (false);
else
return (httpPeek(client->http, &temp, 1) > 0);
}
-/*
- * 'html_escape()' - Write a HTML-safe string.
- */
+//
+// 'html_escape()' - Write a HTML-safe string.
+//
-static void
-html_escape(ippeve_client_t *client, /* I - Client */
- const char *s, /* I - String to write */
- size_t slen) /* I - Number of characters to write */
+static bool // O - `true` on success, `false` on error
+html_escape(ippeve_client_t *client, // I - Client
+ const char *s, // I - String to write
+ size_t slen) // I - Number of characters to write
{
- const char *start, /* Start of segment */
- *end; /* End of string */
+ const char *start, // Start of segment
+ *end; // End of string
start = s;
if (*s == '&' || *s == '<')
{
if (s > start)
- httpWrite2(client->http, start, (size_t)(s - start));
+ {
+ if (httpWrite(client->http, start, (size_t)(s - start)) < 0)
+ return (false);
+ }
if (*s == '&')
- httpWrite2(client->http, "&", 5);
- else
- httpWrite2(client->http, "<", 4);
+ {
+ if (httpWrite(client->http, "&", 5) < 0)
+ return (false);
+ }
+ else if (httpWrite(client->http, "<", 4) < 0)
+ return (false);
start = s + 1;
}
}
if (s > start)
- httpWrite2(client->http, start, (size_t)(s - start));
+ {
+ if (httpWrite(client->http, start, (size_t)(s - start)) < 0)
+ return (false);
+ }
+
+ return (true);
}
-/*
- * 'html_footer()' - Show the web interface footer.
- *
- * This function also writes the trailing 0-length chunk.
- */
+//
+// 'html_footer()' - Show the web interface footer.
+//
+// This function also writes the trailing 0-length chunk.
+//
-static void
-html_footer(ippeve_client_t *client) /* I - Client */
+static bool // O - `true` on success, `false` on error
+html_footer(ippeve_client_t *client) // I - Client
{
- html_printf(client,
- "</div>\n"
- "</body>\n"
- "</html>\n");
- httpWrite2(client->http, "", 0);
+ if (!html_printf(client,
+ "</div>\n"
+ "</body>\n"
+ "</html>\n"))
+ return (false);
+
+ return (httpWrite(client->http, "", 0) >= 0);
}
-/*
- * 'html_header()' - Show the web interface header and title.
- */
+//
+// 'html_header()' - Show the web interface header and title.
+//
-static void
-html_header(ippeve_client_t *client, /* I - Client */
- const char *title, /* I - Title */
- int refresh) /* I - Refresh timer, if any */
+static bool // O - `true` on success, `false` on error
+html_header(ippeve_client_t *client, // I - Client
+ const char *title, // I - Title
+ int refresh) // I - Refresh timer, if any
{
- html_printf(client,
- "<!doctype html>\n"
- "<html>\n"
- "<head>\n"
- "<title>%s</title>\n"
- "<link rel=\"shortcut icon\" href=\"/icon.png\" type=\"image/png\">\n"
- "<link rel=\"apple-touch-icon\" href=\"/icon.png\" type=\"image/png\">\n"
- "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\">\n", title);
+ bool ret = true; // Return value
+
+ ret &= html_printf(client,
+ "<!doctype html>\n"
+ "<html>\n"
+ "<head>\n"
+ "<title>%s</title>\n"
+ "<link rel=\"shortcut icon\" href=\"/icon.png\" type=\"image/png\">\n"
+ "<link rel=\"apple-touch-icon\" href=\"/icon.png\" type=\"image/png\">\n"
+ "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\">\n", title);
if (refresh > 0)
- html_printf(client, "<meta http-equiv=\"refresh\" content=\"%d\">\n", refresh);
- html_printf(client,
- "<meta name=\"viewport\" content=\"width=device-width\">\n"
- "<style>\n"
- "body { font-family: sans-serif; margin: 0; }\n"
- "div.body { padding: 0px 10px 10px; }\n"
- "span.badge { background: #090; border-radius: 5px; color: #fff; padding: 5px 10px; }\n"
- "span.bar { box-shadow: 0px 1px 5px #333; font-size: 75%%; }\n"
- "table.form { border-collapse: collapse; margin-left: auto; margin-right: auto; margin-top: 10px; width: auto; }\n"
- "table.form td, table.form th { padding: 5px 2px; }\n"
- "table.form td.meter { border-right: solid 1px #ccc; padding: 0px; width: 400px; }\n"
- "table.form th { text-align: right; }\n"
- "table.striped { border-bottom: solid thin black; border-collapse: collapse; width: 100%%; }\n"
- "table.striped tr:nth-child(even) { background: #fcfcfc; }\n"
- "table.striped tr:nth-child(odd) { background: #f0f0f0; }\n"
- "table.striped th { background: white; border-bottom: solid thin black; text-align: left; vertical-align: bottom; }\n"
- "table.striped td { margin: 0; padding: 5px; vertical-align: top; }\n"
- "table.nav { border-collapse: collapse; width: 100%%; }\n"
- "table.nav td { margin: 0; text-align: center; }\n"
- "td.nav a, td.nav a:active, td.nav a:hover, td.nav a:hover:link, td.nav a:hover:link:visited, td.nav a:link, td.nav a:link:visited, td.nav a:visited { background: inherit; color: inherit; font-size: 80%%; text-decoration: none; }\n"
- "td.nav { background: #333; color: #fff; padding: 4px 8px; width: 33%%; }\n"
- "td.nav.sel { background: #fff; color: #000; font-weight: bold; }\n"
- "td.nav:hover { background: #666; color: #fff; }\n"
- "td.nav:active { background: #000; color: #ff0; }\n"
- "</style>\n"
- "</head>\n"
- "<body>\n"
- "<table class=\"nav\"><tr>"
- "<td class=\"nav%s\"><a href=\"/\">Status</a></td>"
- "<td class=\"nav%s\"><a href=\"/supplies\">Supplies</a></td>"
- "<td class=\"nav%s\"><a href=\"/media\">Media</a></td>"
- "</tr></table>\n"
- "<div class=\"body\">\n", !strcmp(client->uri, "/") ? " sel" : "", !strcmp(client->uri, "/supplies") ? " sel" : "", !strcmp(client->uri, "/media") ? " sel" : "");
+ ret &= html_printf(client, "<meta http-equiv=\"refresh\" content=\"%d\">\n", refresh);
+ ret &= html_printf(client,
+ "<meta name=\"viewport\" content=\"width=device-width\">\n"
+ "<style>\n"
+ "body { font-family: sans-serif; margin: 0; }\n"
+ "div.body { padding: 0px 10px 10px; }\n"
+ "span.badge { background: #090; border-radius: 5px; color: #fff; padding: 5px 10px; }\n"
+ "span.bar { box-shadow: 0px 1px 5px #333; font-size: 75%%; }\n"
+ "table.form { border-collapse: collapse; margin-left: auto; margin-right: auto; margin-top: 10px; width: auto; }\n"
+ "table.form td, table.form th { padding: 5px 2px; }\n"
+ "table.form td.meter { border-right: solid 1px #ccc; padding: 0px; width: 400px; }\n"
+ "table.form th { text-align: right; }\n"
+ "table.striped { border-bottom: solid thin black; border-collapse: collapse; width: 100%%; }\n"
+ "table.striped tr:nth-child(even) { background: #fcfcfc; }\n"
+ "table.striped tr:nth-child(odd) { background: #f0f0f0; }\n"
+ "table.striped th { background: white; border-bottom: solid thin black; text-align: left; vertical-align: bottom; }\n"
+ "table.striped td { margin: 0; padding: 5px; vertical-align: top; }\n"
+ "table.nav { border-collapse: collapse; width: 100%%; }\n"
+ "table.nav td { margin: 0; text-align: center; }\n"
+ "td.nav a, td.nav a:active, td.nav a:hover, td.nav a:hover:link, td.nav a:hover:link:visited, td.nav a:link, td.nav a:link:visited, td.nav a:visited { background: inherit; color: inherit; font-size: 80%%; text-decoration: none; }\n"
+ "td.nav { background: #333; color: #fff; padding: 4px 8px; width: 33%%; }\n"
+ "td.nav.sel { background: #fff; color: #000; font-weight: bold; }\n"
+ "td.nav:hover { background: #666; color: #fff; }\n"
+ "td.nav:active { background: #000; color: #ff0; }\n"
+ "</style>\n"
+ "</head>\n"
+ "<body>\n"
+ "<table class=\"nav\"><tr>"
+ "<td class=\"nav%s\"><a href=\"/\">Status</a></td>"
+ "<td class=\"nav%s\"><a href=\"/supplies\">Supplies</a></td>"
+ "<td class=\"nav%s\"><a href=\"/media\">Media</a></td>"
+ "</tr></table>\n"
+ "<div class=\"body\">\n", !strcmp(client->uri, "/") ? " sel" : "", !strcmp(client->uri, "/supplies") ? " sel" : "", !strcmp(client->uri, "/media") ? " sel" : "");
+
+ return (ret);
}
-/*
- * 'html_printf()' - Send formatted text to the client, quoting as needed.
- */
+//
+// 'html_printf()' - Send formatted text to the client, quoting as needed.
+//
-static void
-html_printf(ippeve_client_t *client, /* I - Client */
- const char *format, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
+static bool // O - `true` on success, `false` on error
+html_printf(ippeve_client_t *client, // I - Client
+ const char *format, // I - Printf-style format string
+ ...) // I - Additional arguments as needed
{
- va_list ap; /* Pointer to arguments */
- const char *start; /* Start of string */
- char size, /* Size character (h, l, L) */
- type; /* Format type character */
- int width, /* Width of field */
- prec; /* Number of characters of precision */
- char tformat[100], /* Temporary format string for sprintf() */
- *tptr, /* Pointer into temporary format */
- temp[1024]; /* Buffer for formatted numbers */
- char *s; /* Pointer to string */
-
-
- /*
- * Loop through the format string, formatting as needed...
- */
-
+ bool ret = false; // Return value
+ va_list ap; // Pointer to arguments
+ const char *start; // Start of string
+ char size, // Size character (h, l, L)
+ type; // Format type character
+ int width, // Width of field
+ prec; // Number of characters of precision
+ char tformat[100], // Temporary format string for sprintf()
+ *tptr, // Pointer into temporary format
+ temp[1024]; // Buffer for formatted numbers
+ char *s; // Pointer to string
+
+
+ // Loop through the format string, formatting as needed...
va_start(ap, format);
start = format;
if (*format == '%')
{
if (format > start)
- httpWrite2(client->http, start, (size_t)(format - start));
+ {
+ if (httpWrite(client->http, start, (size_t)(format - start)) < 0)
+ goto error;
+ }
tptr = tformat;
*tptr++ = *format++;
if (*format == '%')
{
- httpWrite2(client->http, "%", 1);
+ if (httpWrite(client->http, "%", 1) < 0)
+ goto error;
+
format ++;
start = format;
continue;
if (*format == '*')
{
- /*
- * Get width from argument...
- */
-
+ // Get width from argument...
format ++;
width = va_arg(ap, int);
if (*format == '*')
{
- /*
- * Get precision from argument...
- */
-
+ // Get precision from argument...
format ++;
prec = va_arg(ap, int);
else
size = 0;
-
if (!*format)
{
start = format;
switch (type)
{
- case 'E' : /* Floating point formats */
+ case 'E' : // Floating point formats
case 'G' :
case 'e' :
case 'f' :
snprintf(temp, sizeof(temp), tformat, va_arg(ap, double));
- httpWrite2(client->http, temp, strlen(temp));
+ if (httpWrite(client->http, temp, strlen(temp)) < 0)
+ goto error;
break;
- case 'B' : /* Integer formats */
+ case 'B' : // Integer formats
case 'X' :
case 'b' :
case 'd' :
if (size == 'L')
snprintf(temp, sizeof(temp), tformat, va_arg(ap, long long));
else
-# endif /* HAVE_LONG_LONG */
+# endif // HAVE_LONG_LONG
if (size == 'l')
snprintf(temp, sizeof(temp), tformat, va_arg(ap, long));
else
snprintf(temp, sizeof(temp), tformat, va_arg(ap, int));
- httpWrite2(client->http, temp, strlen(temp));
+ if (httpWrite(client->http, temp, strlen(temp)) < 0)
+ goto error;
break;
- case 'p' : /* Pointer value */
+ case 'p' : // Pointer value
if ((size_t)(width + 2) > sizeof(temp))
break;
snprintf(temp, sizeof(temp), tformat, va_arg(ap, void *));
- httpWrite2(client->http, temp, strlen(temp));
+ if (httpWrite(client->http, temp, strlen(temp)) < 0)
+ goto error;
break;
- case 'c' : /* Character or character array */
+ case 'c' : // Character or character array
if (width <= 1)
{
temp[0] = (char)va_arg(ap, int);
html_escape(client, va_arg(ap, char *), (size_t)width);
break;
- case 's' : /* String */
+ case 's' : // String
if ((s = va_arg(ap, char *)) == NULL)
s = "(null)";
}
if (format > start)
- httpWrite2(client->http, start, (size_t)(format - start));
+ {
+ if (httpWrite(client->http, start, (size_t)(format - start)) < 0)
+ goto error;
+ }
+
+ ret = true;
+
+ error:
va_end(ap);
+
+ return (ret);
}
-/*
- * 'ipp_cancel_job()' - Cancel a job.
- */
+//
+// 'ipp_cancel_job()' - Cancel a job.
+//
static void
-ipp_cancel_job(ippeve_client_t *client) /* I - Client */
+ipp_cancel_job(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job information */
-
+ ippeve_job_t *job; // Job information
- /*
- * Get the job...
- */
+ // Get the job...
if ((job = find_job(client)) == NULL)
{
respond_ipp(client, IPP_STATUS_ERROR_NOT_FOUND, "Job does not exist.");
return;
}
- /*
- * See if the job is already completed, canceled, or aborted; if so,
- * we can't cancel...
- */
-
+ // See if the job is already completed, canceled, or aborted; if so, we can't cancel...
switch (job->state)
{
case IPP_JSTATE_CANCELED :
break;
default :
- /*
- * Cancel the job...
- */
-
+ // Cancel the job...
cupsRWLockWrite(&(client->printer->rwlock));
if (job->state == IPP_JSTATE_PROCESSING ||
}
-/*
- * 'ipp_cancel_my_jobs()' - Cancel all jobs.
- *
- * Note: Since ippeveprinter doesn't do spooling, this really just cancels the
- * current job.
- */
+//
+// 'ipp_cancel_my_jobs()' - Cancel all jobs.
+//
+// Note: Since ippeveprinter doesn't do spooling, this really just cancels the
+// current job.
+//
static void
ipp_cancel_my_jobs(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job information */
+ ippeve_job_t *job; // Job information
cupsRWLockWrite(&client->printer->rwlock);
if ((job = client->printer->active_job) != NULL)
{
- /*
- * See if the job is already completed, canceled, or aborted; if so,
- * we can't cancel...
- */
-
+ // See if the job is already completed, canceled, or aborted; if so, we can't cancel...
if (job->state < IPP_JSTATE_CANCELED)
{
- /*
- * Cancel the job...
- */
-
+ // Cancel the job...
if (job->state == IPP_JSTATE_PROCESSING || (job->state == IPP_JSTATE_HELD && job->fd >= 0))
{
job->cancel = 1;
}
-/*
- * 'ipp_close_job()' - Close an open job.
- */
+//
+// 'ipp_close_job()' - Close an open job.
+//
static void
-ipp_close_job(ippeve_client_t *client) /* I - Client */
+ipp_close_job(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job information */
+ ippeve_job_t *job; // Job information
- /*
- * Get the job...
- */
-
+ // Get the job...
if ((job = find_job(client)) == NULL)
{
respond_ipp(client, IPP_STATUS_ERROR_NOT_FOUND, "Job does not exist.");
return;
}
- /*
- * See if the job is already completed, canceled, or aborted; if so,
- * we can't cancel...
- */
-
+ // See if the job is already completed, canceled, or aborted; if so, we can't cancel...
switch (job->state)
{
case IPP_JSTATE_CANCELED :
}
-/*
- * 'ipp_create_job()' - Create a job object.
- */
+//
+// 'ipp_create_job()' - Create a job object.
+//
static void
-ipp_create_job(ippeve_client_t *client) /* I - Client */
+ipp_create_job(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* New job */
- cups_array_t *ra; /* Attributes to send in response */
+ ippeve_job_t *job; // New job
+ cups_array_t *ra; // Attributes to send in response
- /*
- * Do we have a file to print?
- */
-
+ // Do we have a file to print?
if (have_document_data(client))
{
flush_document_data(client);
return;
}
- /*
- * Validate print job attributes...
- */
-
+ // Validate print job attributes...
if (!valid_job_attributes(client))
return;
- /*
- * Create the job...
- */
-
+ // Create the job...
if ((job = create_job(client)) == NULL)
{
- respond_ipp(client, IPP_STATUS_ERROR_BUSY,
- "Currently printing another job.");
+ respond_ipp(client, IPP_STATUS_ERROR_BUSY, "Currently printing another job.");
return;
}
- /*
- * Return the job info...
- */
-
+ // Return the job info...
respond_ipp(client, IPP_STATUS_OK, NULL);
- ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ ra = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
cupsArrayAdd(ra, "job-id");
cupsArrayAdd(ra, "job-state");
cupsArrayAdd(ra, "job-state-message");
}
-/*
- * 'ipp_get_job_attributes()' - Get the attributes for a job object.
- */
+//
+// 'ipp_get_job_attributes()' - Get the attributes for a job object.
+//
static void
ipp_get_job_attributes(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job */
- cups_array_t *ra; /* requested-attributes */
+ ippeve_job_t *job; // Job
+ cups_array_t *ra; // requested-attributes
if ((job = find_job(client)) == NULL)
}
-/*
- * 'ipp_get_jobs()' - Get a list of job objects.
- */
+//
+// 'ipp_get_jobs()' - Get a list of job objects.
+//
static void
-ipp_get_jobs(ippeve_client_t *client) /* I - Client */
+ipp_get_jobs(ippeve_client_t *client) // I - Client
{
- ipp_attribute_t *attr; /* Current attribute */
+ ipp_attribute_t *attr; // Current attribute
const char *which_jobs = NULL;
- /* which-jobs values */
- int job_comparison; /* Job comparison */
- ipp_jstate_t job_state; /* job-state value */
- int first_job_id, /* First job ID */
- limit, /* Maximum number of jobs to return */
- count; /* Number of jobs that match */
- const char *username; /* Username */
- ippeve_job_t *job; /* Current job pointer */
- cups_array_t *ra; /* Requested attributes array */
-
+ // which-jobs values
+ int job_comparison; // Job comparison
+ ipp_jstate_t job_state; // job-state value
+ int first_job_id, // First job ID
+ limit, // Maximum number of jobs to return
+ count; // Number of jobs that match
+ const char *username; // Username
+ ippeve_job_t *job; // Current job pointer
+ cups_array_t *ra; // Requested attributes array
- /*
- * See if the "which-jobs" attribute have been specified...
- */
- if ((attr = ippFindAttribute(client->request, "which-jobs",
- IPP_TAG_KEYWORD)) != NULL)
+ // See if the "which-jobs" attribute have been specified...
+ if ((attr = ippFindAttribute(client->request, "which-jobs", IPP_TAG_KEYWORD)) != NULL)
{
which_jobs = ippGetString(attr, 0, NULL);
fprintf(stderr, "%s Get-Jobs which-jobs=%s", client->hostname, which_jobs);
return;
}
- /*
- * See if they want to limit the number of jobs reported...
- */
-
- if ((attr = ippFindAttribute(client->request, "limit",
- IPP_TAG_INTEGER)) != NULL)
+ // See if they want to limit the number of jobs reported...
+ if ((attr = ippFindAttribute(client->request, "limit", IPP_TAG_INTEGER)) != NULL)
{
limit = ippGetInteger(attr, 0);
fprintf(stderr, "%s Get-Jobs limit=%d", client->hostname, limit);
}
else
+ {
limit = 0;
+ }
- if ((attr = ippFindAttribute(client->request, "first-job-id",
- IPP_TAG_INTEGER)) != NULL)
+ if ((attr = ippFindAttribute(client->request, "first-job-id", IPP_TAG_INTEGER)) != NULL)
{
first_job_id = ippGetInteger(attr, 0);
fprintf(stderr, "%s Get-Jobs first-job-id=%d", client->hostname, first_job_id);
}
else
+ {
first_job_id = 1;
+ }
- /*
- * See if we only want to see jobs for a specific user...
- */
-
+ // See if we only want to see jobs for a specific user...
username = NULL;
- if ((attr = ippFindAttribute(client->request, "my-jobs",
- IPP_TAG_BOOLEAN)) != NULL)
+ if ((attr = ippFindAttribute(client->request, "my-jobs", IPP_TAG_BOOLEAN)) != NULL)
{
int my_jobs = ippGetBoolean(attr, 0);
if (my_jobs)
{
- if ((attr = ippFindAttribute(client->request, "requesting-user-name",
- IPP_TAG_NAME)) == NULL)
+ if ((attr = ippFindAttribute(client->request, "requesting-user-name", IPP_TAG_NAME)) == NULL)
{
- respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST,
- "Need requesting-user-name with my-jobs.");
+ respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "Need requesting-user-name with my-jobs.");
return;
}
}
}
- /*
- * OK, build a list of jobs for this printer...
- */
-
+ // OK, build a list of jobs for this printer...
ra = ippCreateRequestedArray(client->request);
respond_ipp(client, IPP_STATUS_OK, NULL);
cupsRWLockRead(&(client->printer->rwlock));
- for (count = 0, job = (ippeve_job_t *)cupsArrayFirst(client->printer->jobs);
- (limit <= 0 || count < limit) && job;
- job = (ippeve_job_t *)cupsArrayNext(client->printer->jobs))
+ for (count = 0, job = (ippeve_job_t *)cupsArrayGetFirst(client->printer->jobs); (limit <= 0 || count < limit) && job; job = (ippeve_job_t *)cupsArrayGetNext(client->printer->jobs))
{
- /*
- * Filter out jobs that don't match...
- */
-
+ // Filter out jobs that don't match...
if ((job_comparison < 0 && job->state > job_state) ||
(job_comparison == 0 && job->state != job_state) ||
(job_comparison > 0 && job->state < job_state) ||
job->id < first_job_id ||
- (username && job->username &&
- strcasecmp(username, job->username)))
+ (username && job->username && strcasecmp(username, job->username)))
continue;
if (count > 0)
}
-/*
- * 'ipp_get_printer_attributes()' - Get the attributes for a printer object.
- */
+//
+// 'ipp_get_printer_attributes()' - Get the attributes for a printer object.
+//
static void
ipp_get_printer_attributes(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- cups_array_t *ra; /* Requested attributes array */
- ippeve_printer_t *printer; /* Printer */
+ cups_array_t *ra; // Requested attributes array
+ ippeve_printer_t *printer; // Printer
- /*
- * Send the attributes...
- */
-
+ // Send the attributes...
ra = ippCreateRequestedArray(client->request);
printer = client->printer;
if (!ra || cupsArrayFind(ra, "printer-icons"))
{
- char uris[3][1024]; /* Buffers for URIs */
- const char *values[3]; /* Values for attribute */
+ char uris[3][1024]; // Buffers for URIs
+ const char *values[3]; // Values for attribute
httpAssembleURI(HTTP_URI_CODING_ALL, uris[0], sizeof(uris[0]), WEB_SCHEME, NULL, client->host_field, client->host_port, "/icon-sm.png");
httpAssembleURI(HTTP_URI_CODING_ALL, uris[1], sizeof(uris[1]), WEB_SCHEME, NULL, client->host_field, client->host_port, "/icon.png");
if (!ra || cupsArrayFind(ra, "printer-more-info"))
{
- char uri[1024]; /* URI value */
+ char uri[1024]; // URI value
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), WEB_SCHEME, NULL, client->host_field, client->host_port, "/");
ippAddString(client->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-more-info", NULL, uri);
}
else
{
- ipp_attribute_t *attr = NULL; /* printer-state-reasons */
- ippeve_preason_t bit; /* Reason bit */
- int i; /* Looping var */
- char reason[32]; /* Reason string */
+ ipp_attribute_t *attr = NULL; // printer-state-reasons
+ ippeve_preason_t bit; // Reason bit
+ int i; // Looping var
+ char reason[32]; // Reason string
for (i = 0, bit = 1; i < (int)(sizeof(ippeve_preason_strings) / sizeof(ippeve_preason_strings[0])); i ++, bit *= 2)
{
if (!ra || cupsArrayFind(ra, "printer-strings-uri"))
{
- char uri[1024]; /* URI value */
+ char uri[1024]; // URI value
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), WEB_SCHEME, NULL, client->host_field, client->host_port, "/en.strings");
ippAddString(client->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-strings-uri", NULL, uri);
if (!ra || cupsArrayFind(ra, "printer-supply-info-uri"))
{
- char uri[1024]; /* URI value */
+ char uri[1024]; // URI value
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), WEB_SCHEME, NULL, client->host_field, client->host_port, "/supplies");
ippAddString(client->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-supply-info-uri", NULL, uri);
if (!ra || cupsArrayFind(ra, "printer-uri-supported"))
{
- char uris[2][1024]; /* Buffers for URIs */
- const char *values[2]; /* Values for attribute */
- int num_values = 0; /* Number of values */
+ char uris[2][1024]; // Buffers for URIs
+ const char *values[2]; // Values for attribute
+ size_t num_values = 0; // Number of values
httpAssembleURI(HTTP_URI_CODING_ALL, uris[0], sizeof(uris[0]), "ipp", NULL, client->host_field, client->host_port, "/ipp/print");
values[num_values ++] = uris[0];
}
-/*
- * 'ipp_identify_printer()' - Beep or display a message.
- */
+//
+// 'ipp_identify_printer()' - Beep or display a message.
+//
static void
ipp_identify_printer(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- ipp_attribute_t *actions, /* identify-actions */
- *message; /* message */
+ ipp_attribute_t *actions, // identify-actions
+ *message; // message
actions = ippFindAttribute(client->request, "identify-actions", IPP_TAG_KEYWORD);
if (!actions || ippContainsString(actions, "sound"))
{
#ifdef __APPLE__
- pid_t pid; /* Process ID for "afplay" utility */
+ pid_t pid; // Process ID for "afplay" utility
static const char * const afplay[3] =
- { /* Arguments for "afplay" utility */
+ { // Arguments for "afplay" utility
"/usr/bin/afplay",
"/System/Library/Sounds/Ping.aiff",
NULL
#else
putchar(0x07);
fflush(stdout);
-#endif /* __APPLE__ */
+#endif // __APPLE__
}
if (ippContainsString(actions, "display"))
}
-/*
- * 'ipp_print_job()' - Create a job object with an attached document.
- */
+//
+// 'ipp_print_job()' - Create a job object with an attached document.
+//
static void
-ipp_print_job(ippeve_client_t *client) /* I - Client */
+ipp_print_job(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* New job */
-
+ ippeve_job_t *job; // New job
- /*
- * Validate print job attributes...
- */
+ // Validate print job attributes...
if (!valid_job_attributes(client))
{
flush_document_data(client);
return;
}
- /*
- * Do we have a file to print?
- */
-
+ // Do we have a file to print?
if (!have_document_data(client))
{
respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "No file in request.");
return;
}
- /*
- * Create the job...
- */
-
+ // Create the job...
if ((job = create_job(client)) == NULL)
{
respond_ipp(client, IPP_STATUS_ERROR_BUSY, "Currently printing another job.");
return;
}
- /*
- * Then finish getting the document data and process things...
- */
-
+ // Then finish getting the document data and process things...
finish_document_data(client, job);
}
-/*
- * 'ipp_print_uri()' - Create a job object with a referenced document.
- */
+//
+// 'ipp_print_uri()' - Create a job object with a referenced document.
+//
static void
-ipp_print_uri(ippeve_client_t *client) /* I - Client */
+ipp_print_uri(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* New job */
-
+ ippeve_job_t *job; // New job
- /*
- * Validate print job attributes...
- */
+ // Validate print job attributes...
if (!valid_job_attributes(client))
{
flush_document_data(client);
return;
}
- /*
- * Create the job...
- */
-
+ // Create the job...
if ((job = create_job(client)) == NULL)
{
respond_ipp(client, IPP_STATUS_ERROR_BUSY, "Currently printing another job.");
return;
}
- /*
- * Then finish getting the document data and process things...
- */
-
+ // Then finish getting the document data and process things...
finish_document_uri(client, job);
}
-/*
- * 'ipp_send_document()' - Add an attached document to a job object created with
- * Create-Job.
- */
+//
+// 'ipp_send_document()' - Add an attached document to a job object created with
+// Create-Job.
+//
static void
ipp_send_document(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job information */
- ipp_attribute_t *attr; /* Current attribute */
- int have_data; /* Have document data? */
+ ippeve_job_t *job; // Job information
+ ipp_attribute_t *attr; // Current attribute
+ int have_data; // Have document data?
- /*
- * Get the job...
- */
-
+ // Get the job...
if ((job = find_job(client)) == NULL)
{
flush_document_data(client);
return;
}
- /*
- * See if we already have a document for this job or the job has already
- * in a terminating state...
- */
-
+ // See if we already have a document for this job or the job has already in a terminating state...
have_data = have_document_data(client);
if ((job->filename || job->fd >= 0) && have_data)
return;
}
- /*
- * Make sure we have the "last-document" operation attribute...
- */
-
+ // Make sure we have the "last-document" operation attribute...
if ((attr = ippFindAttribute(client->request, "last-document", IPP_TAG_ZERO)) == NULL)
{
flush_document_data(client);
return;
}
- /*
- * Validate document attributes...
- */
-
+ // Validate document attributes...
if (have_data && !valid_doc_attributes(client))
{
flush_document_data(client);
if (!have_data && !job->filename)
job->state = IPP_JSTATE_ABORTED;
- /*
- * Then finish getting the document data and process things...
- */
-
+ // Then finish getting the document data and process things...
cupsRWLockWrite(&(client->printer->rwlock));
copy_attributes(job->attrs, client->request, NULL, IPP_TAG_JOB, 0);
}
-/*
- * 'ipp_send_uri()' - Add a referenced document to a job object created with
- * Create-Job.
- */
+//
+// 'ipp_send_uri()' - Add a referenced document to a job object created with
+// Create-Job.
+//
static void
-ipp_send_uri(ippeve_client_t *client) /* I - Client */
+ipp_send_uri(ippeve_client_t *client) // I - Client
{
- ippeve_job_t *job; /* Job information */
- ipp_attribute_t *attr; /* Current attribute */
-
+ ippeve_job_t *job; // Job information
+ ipp_attribute_t *attr; // Current attribute
- /*
- * Get the job...
- */
+ // Get the job...
if ((job = find_job(client)) == NULL)
{
respond_ipp(client, IPP_STATUS_ERROR_NOT_FOUND, "Job does not exist.");
return;
}
- /*
- * See if we already have a document for this job or the job has already
- * in a non-terminating state...
- */
-
+ // See if we already have a document for this job or the job has already in a non-terminating state...
if (job->filename || job->fd >= 0)
{
respond_ipp(client, IPP_STATUS_ERROR_MULTIPLE_JOBS_NOT_SUPPORTED, "Multiple document jobs are not supported.");
return;
}
- /*
- * Validate document attributes...
- */
-
+ // Validate document attributes...
if (!valid_doc_attributes(client))
{
flush_document_data(client);
return;
}
- /*
- * Then finish getting the document data and process things...
- */
-
+ // Then finish getting the document data and process things...
cupsRWLockWrite(&(client->printer->rwlock));
copy_attributes(job->attrs, client->request, NULL, IPP_TAG_JOB, 0);
}
-/*
- * 'ipp_validate_job()' - Validate job creation attributes.
- */
+//
+// 'ipp_validate_job()' - Validate job creation attributes.
+//
static void
-ipp_validate_job(ippeve_client_t *client) /* I - Client */
+ipp_validate_job(ippeve_client_t *client) // I - Client
{
if (valid_job_attributes(client))
respond_ipp(client, IPP_STATUS_OK, NULL);
}
-/*
- * 'ippserver_attr_cb()' - Determine whether an attribute should be loaded.
- */
+//
+// 'ippserver_attr_cb()' - Determine whether an attribute should be loaded.
+//
-static int /* O - 1 to use, 0 to ignore */
+static bool // O - `true` to use, `false` to ignore
ippserver_attr_cb(
- _ipp_file_t *f, /* I - IPP file */
- void *user_data, /* I - User data pointer (unused) */
- const char *attr) /* I - Attribute name */
+ ipp_file_t *f, // I - IPP file
+ void *user_data, // I - User data pointer (unused)
+ const char *attr) // I - Attribute name
{
- int i, /* Current element */
- result; /* Result of comparison */
+ int i, // Current element
+ result; // Result of comparison
static const char * const ignored[] =
- { /* Ignored attributes */
+ { // Ignored attributes
"attributes-charset",
"attributes-natural-language",
"charset-configured",
"job-ids-supported",
"job-k-octets-supported",
"job-settable-attributes-supported",
+ "media-col-supported",
"multiple-document-jobs-supported",
"multiple-operation-time-out",
"multiple-operation-time-out-action",
}
-/*
- * 'ippserver_error_cb()' - Log an error message.
- */
+//
+// 'ippserver_error_cb()' - Log an error message.
+//
-static int /* O - 1 to continue, 0 to stop */
+static bool // O - `true` to continue, `false` to stop
ippserver_error_cb(
- _ipp_file_t *f, /* I - IPP file data */
- void *user_data, /* I - User data pointer (unused) */
- const char *error) /* I - Error message */
+ ipp_file_t *f, // I - IPP file data
+ void *user_data, // I - User data pointer (unused)
+ const char *error) // I - Error message
{
(void)f;
(void)user_data;
_cupsLangPrintf(stderr, "%s\n", error);
- return (1);
-}
-
-
-/*
- * 'ippserver_token_cb()' - Process ippserver-specific config file tokens.
- */
-
-static int /* O - 1 to continue, 0 to stop */
-ippserver_token_cb(
- _ipp_file_t *f, /* I - IPP file data */
- _ipp_vars_t *vars, /* I - IPP variables */
- void *user_data, /* I - User data pointer (unused) */
- const char *token) /* I - Current token */
-{
- (void)vars;
- (void)user_data;
-
- if (!token)
- {
- /*
- * NULL token means do the initial setup - create an empty IPP message and
- * return...
- */
-
- f->attrs = ippNew();
- f->group_tag = IPP_TAG_PRINTER;
- }
- else
- {
- _cupsLangPrintf(stderr, _("Unknown directive \"%s\" on line %d of \"%s\" ignored."), token, f->linenum, f->filename);
- }
-
- return (1);
+ return (false);
}
-/*
- * 'load_ippserver_attributes()' - Load IPP attributes from an ippserver file.
- */
+//
+// 'load_ippserver_attributes()' - Load IPP attributes from an ippserver file.
+//
-static ipp_t * /* O - IPP attributes or `NULL` on error */
+static ipp_t * // O - IPP attributes or `NULL` on error
load_ippserver_attributes(
- const char *servername, /* I - Server name or `NULL` for default */
- int serverport, /* I - Server port number */
- const char *filename, /* I - ippserver attribute filename */
- cups_array_t *docformats) /* I - document-format-supported values */
+ const char *servername, // I - Server name or `NULL` for default
+ int serverport, // I - Server port number
+ const char *filename, // I - ippserver attribute filename
+ cups_array_t *docformats) // I - document-format-supported values
{
- ipp_t *attrs; /* IPP attributes */
- _ipp_vars_t vars; /* IPP variables */
- char temp[256]; /* Temporary string */
+ ipp_file_t *file; // IPP data file
+ ipp_t *attrs; // IPP attributes
+ char temp[256]; // Temporary string
- (void)docformats; /* for now */
+ (void)docformats; // for now
- /*
- * Setup callbacks and variables for the printer configuration file...
- *
- * The following additional variables are supported:
- *
- * - SERVERNAME: The host name of the server.
- * - SERVERPORT: The default port of the server.
- */
+ // Setup callbacks and variables for the printer configuration file...
+ //
+ // The following additional variables are supported:
+ //
+ // - SERVERNAME: The host name of the server.
+ // - SERVERPORT: The default port of the server.
+ attrs = ippNew();
+ file = ippFileNew(NULL, (ipp_fattr_cb_t)ippserver_attr_cb, (ipp_ferror_cb_t)ippserver_error_cb, NULL);
- _ippVarsInit(&vars, (_ipp_fattr_cb_t)ippserver_attr_cb, (_ipp_ferror_cb_t)ippserver_error_cb, (_ipp_ftoken_cb_t)ippserver_token_cb);
+ ippFileSetAttributes(file, attrs);
+ ippFileSetGroupTag(file, IPP_TAG_PRINTER);
if (servername)
{
- _ippVarsSet(&vars, "SERVERNAME", servername);
+ ippFileSetVar(file, "SERVERNAME", servername);
}
else
{
httpGetHostname(NULL, temp, sizeof(temp));
- _ippVarsSet(&vars, "SERVERNAME", temp);
+ ippFileSetVar(file, "SERVERNAME", temp);
}
snprintf(temp, sizeof(temp), "%d", serverport);
- _ippVarsSet(&vars, "SERVERPORT", temp);
+ ippFileSetVar(file, "SERVERPORT", temp);
- /*
- * Load attributes and values for the printer...
- */
+ // Load attributes and values for the printer...
+ ippFileOpen(file, filename, "r");
+ ippFileRead(file, NULL, false);
- attrs = _ippFileParse(&vars, filename, NULL);
-
- /*
- * Free memory and return...
- */
-
- _ippVarsDeinit(&vars);
+ // Free memory and return...
+ ippFileDelete(file);
return (attrs);
}
-/*
- * 'load_legacy_attributes()' - Load IPP attributes using the old ippserver
- * options.
- */
+//
+// 'load_legacy_attributes()' - Load IPP attributes using the old ippserver
+// options.
+//
-static ipp_t * /* O - IPP attributes or `NULL` on error */
+static ipp_t * // O - IPP attributes or `NULL` on error
load_legacy_attributes(
- const char *make, /* I - Manufacturer name */
- const char *model, /* I - Model name */
- int ppm, /* I - pages-per-minute */
- int ppm_color, /* I - pages-per-minute-color */
- int duplex, /* I - Duplex support? */
- cups_array_t *docformats) /* I - document-format-supported values */
+ const char *make, // I - Manufacturer name
+ const char *model, // I - Model name
+ int ppm, // I - pages-per-minute
+ int ppm_color, // I - pages-per-minute-color
+ int duplex, // I - Duplex support?
+ cups_array_t *docformats) // I - document-format-supported values
{
- int i; /* Looping var */
- ipp_t *attrs, /* IPP attributes */
- *col; /* Collection value */
- ipp_attribute_t *attr; /* Current attribute */
- char device_id[1024],/* printer-device-id */
- *ptr, /* Pointer into device ID */
- make_model[128];/* printer-make-and-model */
- const char *format, /* Current document format */
- *prefix; /* Prefix for device ID */
- int num_media; /* Number of media */
- const char * const *media; /* List of media */
- int num_ready; /* Number of loaded media */
- const char * const *ready; /* List of loaded media */
- pwg_media_t *pwg; /* PWG media size information */
+ size_t i; // Looping var
+ ipp_t *attrs, // IPP attributes
+ *col; // Collection value
+ ipp_attribute_t *attr; // Current attribute
+ char device_id[1024],// printer-device-id
+ *ptr, // Pointer into device ID
+ make_model[128];// printer-make-and-model
+ const char *format, // Current document format
+ *prefix; // Prefix for device ID
+ size_t num_media; // Number of media
+ const char * const *media; // List of media
+ size_t num_ready; // Number of loaded media
+ const char * const *ready; // List of loaded media
+ pwg_media_t *pwg; // PWG media size information
static const char * const media_supported[] =
- { /* media-supported values */
- "na_letter_8.5x11in", /* Letter */
- "na_legal_8.5x14in", /* Legal */
- "iso_a4_210x297mm", /* A4 */
- "na_number-10_4.125x9.5in", /* #10 Envelope */
- "iso_dl_110x220mm" /* DL Envelope */
+ { // media-supported values
+ "na_letter_8.5x11in", // Letter
+ "na_legal_8.5x14in", // Legal
+ "iso_a4_210x297mm", // A4
+ "na_number-10_4.125x9.5in", // #10 Envelope
+ "iso_dl_110x220mm" // DL Envelope
};
static const char * const media_supported_color[] =
- { /* media-supported values */
- "na_letter_8.5x11in", /* Letter */
- "na_legal_8.5x14in", /* Legal */
- "iso_a4_210x297mm", /* A4 */
- "na_number-10_4.125x9.5in", /* #10 Envelope */
- "iso_dl_110x220mm", /* DL Envelope */
- "na_index-3x5_3x5in", /* Photo 3x5 */
- "oe_photo-l_3.5x5in", /* Photo L */
- "na_index-4x6_4x6in", /* Photo 4x6 */
- "iso_a6_105x148mm", /* A6 */
- "na_5x7_5x7in", /* Photo 5x7 aka 2L */
- "iso_a5_148x210mm", /* A5 */
+ { // media-supported values
+ "na_letter_8.5x11in", // Letter
+ "na_legal_8.5x14in", // Legal
+ "iso_a4_210x297mm", // A4
+ "na_number-10_4.125x9.5in", // #10 Envelope
+ "iso_dl_110x220mm", // DL Envelope
+ "na_index-3x5_3x5in", // Photo 3x5
+ "oe_photo-l_3.5x5in", // Photo L
+ "na_index-4x6_4x6in", // Photo 4x6
+ "iso_a6_105x148mm", // A6
+ "na_5x7_5x7in", // Photo 5x7 aka 2L
+ "iso_a5_148x210mm", // A5
+ "roll_min_4x1in", // Roll
+ "roll_max_8.5x39.6in" // Roll
};
static const char * const media_ready[] =
- { /* media-ready values */
- "na_letter_8.5x11in", /* Letter */
- "na_number-10_4.125x9.5in" /* #10 */
+ { // media-ready values
+ "na_letter_8.5x11in", // Letter
+ "na_number-10_4.125x9.5in" // #10
};
static const char * const media_ready_color[] =
- { /* media-ready values */
- "na_letter_8.5x11in", /* Letter */
- "na_index-4x6_4x6in" /* Photo 4x6 */
+ { // media-ready values
+ "na_letter_8.5x11in", // Letter
+ "na_index-4x6_4x6in", // Photo 4x6
+ "roll_current_8.5x0in" // 8.5" roll
};
static const char * const media_source_supported[] =
- { /* media-source-supported values */
+ { // media-source-supported values
"auto",
"main",
"manual",
- "by-pass-tray" /* AKA multi-purpose tray */
+ "by-pass-tray" // AKA multi-purpose tray
};
static const char * const media_source_supported_color[] =
- { /* media-source-supported values */
+ { // media-source-supported values
"auto",
"main",
- "photo"
+ "photo",
+ "roll"
};
static const char * const media_type_supported[] =
- { /* media-type-supported values */
+ { // media-type-supported values
"auto",
"cardstock",
"envelope",
"transparency"
};
static const char * const media_type_supported_color[] =
- { /* media-type-supported values */
+ { // media-type-supported values
"auto",
"cardstock",
"envelope",
"photographic-semi-gloss"
};
static const int media_bottom_margin_supported[] =
- { /* media-bottom-margin-supported values */
- 635 /* 1/4" */
+ { // media-bottom-margin-supported values
+ 635 // 1/4"
};
static const int media_bottom_margin_supported_color[] =
- { /* media-bottom/top-margin-supported values */
- 0, /* Borderless */
- 1168 /* 0.46" (common HP inkjet bottom margin) */
+ { // media-bottom/top-margin-supported values
+ 0, // Borderless
+ 1168 // 0.46" (common HP inkjet bottom margin)
};
static const int media_lr_margin_supported[] =
- { /* media-left/right-margin-supported values */
- 340, /* 3.4mm (historical HP PCL A4 margin) */
- 635 /* 1/4" */
+ { // media-left/right-margin-supported values
+ 340, // 3.4mm (historical HP PCL A4 margin)
+ 635 // 1/4"
};
static const int media_lr_margin_supported_color[] =
- { /* media-left/right-margin-supported values */
- 0, /* Borderless */
- 340, /* 3.4mm (historical HP PCL A4 margin) */
- 635 /* 1/4" */
+ { // media-left/right-margin-supported values
+ 0, // Borderless
+ 340, // 3.4mm (historical HP PCL A4 margin)
+ 635 // 1/4"
};
static const int media_top_margin_supported[] =
- { /* media-top-margin-supported values */
- 635 /* 1/4" */
+ { // media-top-margin-supported values
+ 635 // 1/4"
};
static const int media_top_margin_supported_color[] =
- { /* media-top/top-margin-supported values */
- 0, /* Borderless */
- 102 /* 0.04" (common HP inkjet top margin */
+ { // media-top/top-margin-supported values
+ 0, // Borderless
+ 102 // 0.04" (common HP inkjet top margin
};
static const int orientation_requested_supported[4] =
- { /* orientation-requested-supported values */
+ { // orientation-requested-supported values
IPP_ORIENT_PORTRAIT,
IPP_ORIENT_LANDSCAPE,
IPP_ORIENT_REVERSE_LANDSCAPE,
IPP_ORIENT_REVERSE_PORTRAIT
};
static const char * const overrides_supported[] =
- { /* overrides-supported values */
+ { // overrides-supported values
"document-numbers",
"media",
"media-col",
"pages"
};
static const char * const print_color_mode_supported[] =
- { /* print-color-mode-supported values */
+ { // print-color-mode-supported values
"monochrome"
};
static const char * const print_color_mode_supported_color[] =
- { /* print-color-mode-supported values */
+ { // print-color-mode-supported values
"auto",
"color",
"monochrome"
};
static const int print_quality_supported[] =
- { /* print-quality-supported values */
+ { // print-quality-supported values
IPP_QUALITY_DRAFT,
IPP_QUALITY_NORMAL,
IPP_QUALITY_HIGH
};
static const char * const printer_input_tray[] =
- { /* printer-input-tray values */
+ { // printer-input-tray values
"type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=-2;level=-2;status=0;name=auto",
"type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=250;level=100;status=0;name=main",
"type=sheetFeedManual;mediafeed=0;mediaxfeed=0;maxcapacity=1;level=-2;status=0;name=manual",
"type=sheetFeedAutoNonRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=25;level=-2;status=0;name=by-pass-tray"
};
static const char * const printer_input_tray_color[] =
- { /* printer-input-tray values */
+ { // printer-input-tray values
"type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=-2;level=-2;status=0;name=auto",
"type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=250;level=-2;status=0;name=main",
- "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=25;level=-2;status=0;name=photo"
+ "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=25;level=-2;status=0;name=photo",
+ "type=continuousRoll;mediafeed=0;mediaxfeed=0;maxcapacity=100;level=-2;status=0;name=roll"
};
static const char * const printer_supply[] =
- { /* printer-supply values */
+ { // printer-supply values
"index=1;class=receptacleThatIsFilled;type=wasteToner;unit=percent;"
"maxcapacity=100;level=25;colorantname=unknown;",
"index=2;class=supplyThatIsConsumed;type=toner;unit=percent;"
"maxcapacity=100;level=75;colorantname=black;"
};
static const char * const printer_supply_color[] =
- { /* printer-supply values */
+ { // printer-supply values
"index=1;class=receptacleThatIsFilled;type=wasteInk;unit=percent;"
"maxcapacity=100;level=25;colorantname=unknown;",
"index=2;class=supplyThatIsConsumed;type=ink;unit=percent;"
"maxcapacity=100;level=67;colorantname=yellow;"
};
static const char * const printer_supply_description[] =
- { /* printer-supply-description values */
+ { // printer-supply-description values
"Toner Waste Tank",
"Black Toner"
};
static const char * const printer_supply_description_color[] =
- { /* printer-supply-description values */
+ { // printer-supply-description values
"Ink Waste Tank",
"Black Ink",
"Cyan Ink",
"srgb_16"
};
static const char * const sides_supported[] =
- { /* sides-supported values */
+ { // sides-supported values
"one-sided",
"two-sided-long-edge",
"two-sided-short-edge"
};
static const char * const urf_supported[] =
- { /* urf-supported values */
+ { // urf-supported values
"CP1",
"IS1-4-5-19",
"MT1-2-3-4-5-6",
"W8"
};
static const char * const urf_supported_color[] =
- { /* urf-supported values */
+ { // urf-supported values
"CP1",
"IS1-4-5-7-19",
"MT1-2-3-4-5-6-8-9-10-11-12-13",
"W8"
};
static const char * const urf_supported_color_duplex[] =
- { /* urf-supported values */
+ { // urf-supported values
"CP1",
"IS1-4-5-7-19",
"MT1-2-3-4-5-6-8-9-10-11-12-13",
"DM3"
};
static const char * const urf_supported_duplex[] =
- { /* urf-supported values */
+ { // urf-supported values
"CP1",
"IS1-4-5-19",
"MT1-2-3-4-5-6",
ready = media_ready;
}
- /* color-supported */
+ // color-supported
ippAddBoolean(attrs, IPP_TAG_PRINTER, "color-supported", ppm_color > 0);
- /* copies-default */
+ // copies-default
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "copies-default", 1);
- /* copies-supported */
+ // copies-supported
ippAddRange(attrs, IPP_TAG_PRINTER, "copies-supported", 1, (cupsArrayFind(docformats, (void *)"application/pdf") != NULL || cupsArrayFind(docformats, (void *)"image/jpeg") != NULL) ? 999 : 1);
- /* document-password-supported */
+ // document-password-supported
if (cupsArrayFind(docformats, (void *)"application/pdf"))
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "document-password-supported", 1023);
- /* finishing-template-supported */
+ // finishing-template-supported
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishing-template-supported", NULL, "none");
- /* finishings-col-database */
+ // finishings-col-database
col = ippNew();
ippAddString(col, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishing-template", NULL, "none");
ippAddCollection(attrs, IPP_TAG_PRINTER, "finishings-col-database", col);
ippDelete(col);
- /* finishings-col-default */
+ // finishings-col-default
col = ippNew();
ippAddString(col, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishing-template", NULL, "none");
ippAddCollection(attrs, IPP_TAG_PRINTER, "finishings-col-default", col);
ippDelete(col);
- /* finishings-col-ready */
+ // finishings-col-ready
col = ippNew();
ippAddString(col, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishing-template", NULL, "none");
ippAddCollection(attrs, IPP_TAG_PRINTER, "finishings-col-ready", col);
ippDelete(col);
- /* finishings-col-supported */
+ // finishings-col-supported
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishings-col-supported", NULL, "finishing-template");
- /* finishings-default */
+ // finishings-default
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-default", IPP_FINISHINGS_NONE);
- /* finishings-ready */
+ // finishings-ready
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-ready", IPP_FINISHINGS_NONE);
- /* finishings-supported */
+ // finishings-supported
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-supported", IPP_FINISHINGS_NONE);
- /* media-bottom-margin-supported */
+ // media-bottom-margin-supported
if (ppm_color > 0)
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin-supported", (int)(sizeof(media_bottom_margin_supported) / sizeof(media_bottom_margin_supported[0])), media_bottom_margin_supported);
else
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin-supported", (int)(sizeof(media_bottom_margin_supported_color) / sizeof(media_bottom_margin_supported_color[0])), media_bottom_margin_supported_color);
- /* media-col-database and media-col-default */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-col-database", num_media, NULL);
- for (i = 0; i < num_media; i ++)
+ // media-col-database and media-col-default
+ for (i = 0, attr = NULL; i < num_media; i ++)
{
- int bottom, left, /* media-xxx-margins */
+ int bottom, left, // media-xxx-margins
right, top;
- const char *source; /* media-source, if any */
+ const char *source; // media-source, if any
pwg = pwgMediaForPWG(media[i]);
if (pwg->width < 21000 && pwg->length < 21000)
{
- source = "photo"; /* Photo size media from photo tray */
- bottom = /* Borderless margins */
+ source = "photo"; // Photo size media from photo tray
+ bottom = // Borderless margins
left =
right =
top = 0;
}
else if (pwg->width < 21000)
{
- source = "by-pass-tray"; /* Envelopes from multi-purpose tray */
+ source = "by-pass-tray"; // Envelopes from multi-purpose tray
bottom = ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0];
- left = /* Left/right margins are standard */
+ left = // Left/right margins are standard
right = media_lr_margin_supported[1];
top = ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0];
}
else if (pwg->width == 21000)
{
- source = NULL; /* A4 from any tray */
+ source = NULL; // A4 from any tray
bottom = ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0];
- left = /* Left/right margins are reduced */
+ left = // Left/right margins are reduced
right = media_lr_margin_supported[0];
top = ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0];
}
else
{
- source = NULL; /* Other size media from any tray */
+ source = NULL; // Other size media from any tray
bottom = ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0];
- left = /* Left/right margins are standard */
+ left = // Left/right margins are standard
right = media_lr_margin_supported[1];
top = ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0];
}
- col = create_media_col(media[i], source, NULL, pwg->width, pwg->length, bottom, left, right, top);
- ippSetCollection(attrs, &attr, i, col);
+ if (!strncmp(media[i], "roll_min_", 9) && i < (num_media - 1))
+ {
+ // Roll min/max range...
+ pwg_media_t *pwg2; // Max size
+ ipp_t *media_size; // media-size member attribute
+
+ i ++;
+ pwg2 = pwgMediaForPWG(media[i]);
+
+ media_size = ippNew();
+ ippAddRange(media_size, IPP_TAG_ZERO, "x-dimension", pwg->width, pwg2->width);
+ ippAddRange(media_size, IPP_TAG_ZERO, "y-dimension", pwg->length, pwg2->length);
+
+ col = create_media_col(NULL, source, NULL, media_size, bottom, left, right, top);
+ }
+ else
+ {
+ // Sheet size
+ col = create_media_col(media[i], source, NULL, create_media_size(pwg->width, pwg->length), bottom, left, right, top);
+ }
+
+ if (attr)
+ ippSetCollection(attrs, &attr, ippGetCount(attr), col);
+ else
+ attr = ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-database", col);
ippDelete(col);
}
- /* media-col-default */
+ // media-col-default
pwg = pwgMediaForPWG(ready[0]);
if (pwg->width == 21000)
- col = create_media_col(ready[0], "main", "stationery", pwg->width, pwg->length, ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0], media_lr_margin_supported[0], media_lr_margin_supported[0], ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0]);
+ col = create_media_col(ready[0], "main", "stationery", create_media_size(pwg->width, pwg->length), ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0], media_lr_margin_supported[0], media_lr_margin_supported[0], ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0]);
else
- col = create_media_col(ready[0], "main", "stationery", pwg->width, pwg->length, ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0], media_lr_margin_supported[1], media_lr_margin_supported[1], ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0]);
+ col = create_media_col(ready[0], "main", "stationery", create_media_size(pwg->width, pwg->length), ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0], media_lr_margin_supported[1], media_lr_margin_supported[1], ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0]);
ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-default", col);
ippDelete(col);
- /* media-col-ready */
+ // media-col-ready
attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-col-ready", num_ready, NULL);
for (i = 0; i < num_ready; i ++)
{
- int bottom, left, /* media-xxx-margins */
+ int bottom, left, // media-xxx-margins
right, top;
- const char *source, /* media-source */
- *type; /* media-type */
+ const char *source, // media-source
+ *type; // media-type
pwg = pwgMediaForPWG(ready[i]);
if (pwg->width < 21000 && pwg->length < 21000)
{
- source = "photo"; /* Photo size media from photo tray */
- type = "photographic-glossy"; /* Glossy photo paper */
- bottom = /* Borderless margins */
+ source = "photo"; // Photo size media from photo tray
+ type = "photographic-glossy"; // Glossy photo paper
+ bottom = // Borderless margins
left =
right =
top = 0;
}
else if (pwg->width < 21000)
{
- source = "by-pass-tray"; /* Envelopes from multi-purpose tray */
- type = "envelope"; /* Envelope */
+ source = "by-pass-tray"; // Envelopes from multi-purpose tray
+ type = "envelope"; // Envelope
bottom = ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0];
- left = /* Left/right margins are standard */
+ left = // Left/right margins are standard
right = media_lr_margin_supported[1];
top = ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0];
}
else if (pwg->width == 21000)
{
- source = "main"; /* A4 from main tray */
- type = "stationery"; /* Plain paper */
+ source = "main"; // A4 from main tray
+ type = "stationery"; // Plain paper
bottom = ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0];
- left = /* Left/right margins are reduced */
+ left = // Left/right margins are reduced
right = media_lr_margin_supported[0];
top = ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0];
}
else
{
- source = "main"; /* A4 from main tray */
- type = "stationery"; /* Plain paper */
+ source = "main"; // A4 from main tray
+ type = "stationery"; // Plain paper
bottom = ppm_color > 0 ? media_bottom_margin_supported_color[1] : media_bottom_margin_supported[0];
- left = /* Left/right margins are standard */
+ left = // Left/right margins are standard
right = media_lr_margin_supported[1];
top = ppm_color > 0 ? media_top_margin_supported_color[1] : media_top_margin_supported[0];
}
- col = create_media_col(ready[i], source, type, pwg->width, pwg->length, bottom, left, right, top);
+ col = create_media_col(ready[i], source, type, create_media_size(pwg->width, pwg->length), bottom, left, right, top);
ippSetCollection(attrs, &attr, i, col);
ippDelete(col);
}
- /* media-default */
+ // media-default
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-default", NULL, media[0]);
- /* media-left/right-margin-supported */
+ // media-left/right-margin-supported
if (ppm_color > 0)
{
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin-supported", (int)(sizeof(media_lr_margin_supported_color) / sizeof(media_lr_margin_supported_color[0])), media_lr_margin_supported_color);
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin-supported", (int)(sizeof(media_lr_margin_supported) / sizeof(media_lr_margin_supported[0])), media_lr_margin_supported);
}
- /* media-ready */
+ // media-ready
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-ready", num_ready, NULL, ready);
- /* media-supported */
+ // media-supported
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-supported", num_media, NULL, media);
- /* media-size-supported */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-size-supported", num_media, NULL);
- for (i = 0; i < num_media; i ++)
+ // media-size-supported
+ for (i = 0, attr = NULL; i < num_media; i ++)
{
pwg = pwgMediaForPWG(media[i]);
- col = create_media_size(pwg->width, pwg->length);
- ippSetCollection(attrs, &attr, i, col);
+ if (!strncmp(media[i], "roll_min_", 9) && i < (num_media - 1))
+ {
+ // Roll min/max range...
+ pwg_media_t *pwg2; // Max size
+
+ i ++;
+ pwg2 = pwgMediaForPWG(media[i]);
+
+ col = create_media_size_range(pwg->width, pwg2->width, pwg->length, pwg2->length);
+ }
+ else
+ {
+ // Sheet size...
+ col = create_media_size(pwg->width, pwg->length);
+ }
+
+ if (attr)
+ ippSetCollection(attrs, &attr, ippGetCount(attr), col);
+ else
+ attr = ippAddCollection(attrs, IPP_TAG_PRINTER, "media-size-supported", col);
+
ippDelete(col);
}
- /* media-source-supported */
+ // media-source-supported
if (ppm_color > 0)
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-source-supported", (int)(sizeof(media_source_supported_color) / sizeof(media_source_supported_color[0])), NULL, media_source_supported_color);
else
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-source-supported", (int)(sizeof(media_source_supported) / sizeof(media_source_supported[0])), NULL, media_source_supported);
- /* media-top-margin-supported */
+ // media-top-margin-supported
if (ppm_color > 0)
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin-supported", (int)(sizeof(media_top_margin_supported) / sizeof(media_top_margin_supported[0])), media_top_margin_supported);
else
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin-supported", (int)(sizeof(media_top_margin_supported_color) / sizeof(media_top_margin_supported_color[0])), media_top_margin_supported_color);
- /* media-type-supported */
+ // media-type-supported
if (ppm_color > 0)
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-type-supported", (int)(sizeof(media_type_supported_color) / sizeof(media_type_supported_color[0])), NULL, media_type_supported_color);
else
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-type-supported", (int)(sizeof(media_type_supported) / sizeof(media_type_supported[0])), NULL, media_type_supported);
- /* orientation-requested-default */
+ // orientation-requested-default
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-default", IPP_ORIENT_PORTRAIT);
- /* orientation-requested-supported */
+ // orientation-requested-supported
if (cupsArrayFind(docformats, (void *)"application/pdf") || cupsArrayFind(docformats, (void *)"image/jpeg"))
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-supported", (int)(sizeof(orientation_requested_supported) / sizeof(orientation_requested_supported[0])), orientation_requested_supported);
else
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-supported", IPP_ORIENT_PORTRAIT);
- /* output-bin-default */
+ // output-bin-default
if (ppm_color > 0)
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-default", NULL, "face-up");
else
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-default", NULL, "face-down");
- /* output-bin-supported */
+ // output-bin-supported
if (ppm_color > 0)
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-supported", NULL, "face-up");
else
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-supported", NULL, "face-down");
- /* overrides-supported */
+ // overrides-supported
if (cupsArrayFind(docformats, (void *)"application/pdf"))
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "overrides-supported", (int)(sizeof(overrides_supported) / sizeof(overrides_supported[0])), NULL, overrides_supported);
- /* page-ranges-supported */
+ // page-ranges-supported
ippAddBoolean(attrs, IPP_TAG_PRINTER, "page-ranges-supported", cupsArrayFind(docformats, (void *)"application/pdf") != NULL);
- /* pages-per-minute */
+ // pages-per-minute
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute", ppm);
- /* pages-per-minute-color */
+ // pages-per-minute-color
if (ppm_color > 0)
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute-color", ppm_color);
- /* print-color-mode-default */
+ // print-color-mode-default
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-default", NULL, ppm_color > 0 ? "auto" : "monochrome");
- /* print-color-mode-supported */
+ // print-color-mode-supported
if (ppm_color > 0)
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-supported", (int)(sizeof(print_color_mode_supported_color) / sizeof(print_color_mode_supported_color[0])), NULL, print_color_mode_supported_color);
else
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-supported", (int)(sizeof(print_color_mode_supported) / sizeof(print_color_mode_supported[0])), NULL, print_color_mode_supported);
- /* print-content-optimize-default */
+ // print-content-optimize-default
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-content-optimize-default", NULL, "auto");
- /* print-content-optimize-supported */
+ // print-content-optimize-supported
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-content-optimize-supported", NULL, "auto");
- /* print-quality-default */
+ // print-quality-default
ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default", IPP_QUALITY_NORMAL);
- /* print-quality-supported */
+ // print-quality-supported
ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-supported", (int)(sizeof(print_quality_supported) / sizeof(print_quality_supported[0])), print_quality_supported);
- /* print-rendering-intent-default */
+ // print-rendering-intent-default
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-rendering-intent-default", NULL, "auto");
- /* print-rendering-intent-supported */
+ // print-rendering-intent-supported
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-rendering-intent-supported", NULL, "auto");
- /* printer-device-id */
+ // printer-device-id
snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;", make, model);
ptr = device_id + strlen(device_id);
prefix = "CMD:";
- for (format = (const char *)cupsArrayFirst(docformats); format; format = (const char *)cupsArrayNext(docformats))
+ for (format = (const char *)cupsArrayGetFirst(docformats); format; format = (const char *)cupsArrayGetNext(docformats))
{
if (!strcasecmp(format, "application/pdf"))
snprintf(ptr, sizeof(device_id) - (size_t)(ptr - device_id), "%sPDF", prefix);
*ptr++ = ';';
*ptr = '\0';
}
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, device_id);
-
- /* printer-input-tray */
- if (ppm_color > 0)
- {
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", printer_input_tray_color[0], (int)strlen(printer_input_tray_color[0]));
- for (i = 1; i < (int)(sizeof(printer_input_tray_color) / sizeof(printer_input_tray_color[0])); i ++)
- ippSetOctetString(attrs, &attr, i, printer_input_tray_color[i], (int)strlen(printer_input_tray_color[i]));
- }
- else
- {
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", printer_input_tray[0], (int)strlen(printer_input_tray[0]));
- for (i = 1; i < (int)(sizeof(printer_input_tray) / sizeof(printer_input_tray[0])); i ++)
- ippSetOctetString(attrs, &attr, i, printer_input_tray[i], (int)strlen(printer_input_tray[i]));
- }
-
- /* printer-make-and-model */
- snprintf(make_model, sizeof(make_model), "%s %s", make, model);
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-make-and-model", NULL, make_model);
-
- /* printer-resolution-default */
- ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-default", IPP_RES_PER_INCH, 600, 600);
-
- /* printer-resolution-supported */
- ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-supported", IPP_RES_PER_INCH, 600, 600);
-
- /* printer-supply and printer-supply-description */
- if (ppm_color > 0)
- {
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-supply", printer_supply_color[0], (int)strlen(printer_supply_color[0]));
- for (i = 1; i < (int)(sizeof(printer_supply_color) / sizeof(printer_supply_color[0])); i ++)
- ippSetOctetString(attrs, &attr, i, printer_supply_color[i], (int)strlen(printer_supply_color[i]));
-
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_TEXT), "printer-supply-description", (int)(sizeof(printer_supply_description_color) / sizeof(printer_supply_description_color[0])), NULL, printer_supply_description_color);
- }
- else
- {
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-supply", printer_supply[0], (int)strlen(printer_supply[0]));
- for (i = 1; i < (int)(sizeof(printer_supply) / sizeof(printer_supply[0])); i ++)
- ippSetOctetString(attrs, &attr, i, printer_supply[i], (int)strlen(printer_supply[i]));
-
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_TEXT), "printer-supply-description", (int)(sizeof(printer_supply_description) / sizeof(printer_supply_description[0])), NULL, printer_supply_description);
- }
-
- /* pwg-raster-document-xxx-supported */
- if (cupsArrayFind(docformats, (void *)"image/pwg-raster"))
- {
- ippAddResolutions(attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", (int)(sizeof(pwg_raster_document_resolution_supported) / sizeof(pwg_raster_document_resolution_supported[0])), IPP_RES_PER_INCH, pwg_raster_document_resolution_supported, pwg_raster_document_resolution_supported);
-
- if (ppm_color > 0 && duplex)
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-sheet-back", NULL, "rotated");
- else if (duplex)
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-sheet-back", NULL, "normal");
-
- if (ppm_color > 0)
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-type-supported", (int)(sizeof(pwg_raster_document_type_supported_color) / sizeof(pwg_raster_document_type_supported_color[0])), NULL, pwg_raster_document_type_supported_color);
- else
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-type-supported", (int)(sizeof(pwg_raster_document_type_supported) / sizeof(pwg_raster_document_type_supported[0])), NULL, pwg_raster_document_type_supported);
- }
-
- /* sides-default */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-default", NULL, "one-sided");
-
- /* sides-supported */
- if (duplex)
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", (int)(sizeof(sides_supported) / sizeof(sides_supported[0])), NULL, sides_supported);
- else
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", NULL, "one-sided");
-
- /* urf-supported */
- if (cupsArrayFind(docformats, (void *)"image/urf"))
- {
- if (ppm_color > 0)
- {
- if (duplex)
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported_color_duplex) / sizeof(urf_supported_color_duplex[0])), NULL, urf_supported_color_duplex);
- else
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported_color) / sizeof(urf_supported_color[0])), NULL, urf_supported_color);
- }
- else if (duplex)
- {
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported_duplex) / sizeof(urf_supported_duplex[0])), NULL, urf_supported_duplex);
- }
- else
- {
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported) / sizeof(urf_supported[0])), NULL, urf_supported);
- }
- }
-
- return (attrs);
-}
-
-
-#if !CUPS_LITE
-/*
- * 'load_ppd_attributes()' - Load IPP attributes from a PPD file.
- */
-
-static ipp_t * /* O - IPP attributes or `NULL` on error */
-load_ppd_attributes(
- const char *ppdfile, /* I - PPD filename */
- cups_array_t *docformats) /* I - document-format-supported values */
-{
- int i, j; /* Looping vars */
- ipp_t *attrs; /* Attributes */
- ipp_attribute_t *attr; /* Current attribute */
- ipp_t *col; /* Current collection value */
- ppd_file_t *ppd; /* PPD data */
- ppd_attr_t *ppd_attr; /* PPD attribute */
- ppd_choice_t *ppd_choice; /* PPD choice */
- ppd_size_t *ppd_size; /* Default PPD size */
- pwg_size_t *pwg_size, /* Current PWG size */
- *default_size = NULL; /* Default PWG size */
- const char *default_source = NULL, /* Default media source */
- *default_type = NULL; /* Default media type */
- pwg_map_t *pwg_map; /* Mapping from PWG to PPD keywords */
- _ppd_cache_t *pc; /* PPD cache */
- _pwg_finishings_t *finishings; /* Current finishings value */
- const char *template; /* Current finishings-template value */
- int num_margins; /* Number of media-xxx-margin-supported values */
- int margins[10]; /* media-xxx-margin-supported values */
- int xres, /* Default horizontal resolution */
- yres; /* Default vertical resolution */
- int num_urf; /* Number of urf-supported values */
- const char *urf[10]; /* urf-supported values */
- char urf_rs[32]; /* RS value */
- static const int orientation_requested_supported[4] =
- { /* orientation-requested-supported values */
- IPP_ORIENT_PORTRAIT,
- IPP_ORIENT_LANDSCAPE,
- IPP_ORIENT_REVERSE_LANDSCAPE,
- IPP_ORIENT_REVERSE_PORTRAIT
- };
- static const char * const overrides_supported[] =
- { /* overrides-supported */
- "document-numbers",
- "media",
- "media-col",
- "orientation-requested",
- "pages"
- };
- static const char * const print_color_mode_supported[] =
- { /* print-color-mode-supported values */
- "monochrome"
- };
- static const char * const print_color_mode_supported_color[] =
- { /* print-color-mode-supported values */
- "auto",
- "color",
- "monochrome"
- };
- static const int print_quality_supported[] =
- { /* print-quality-supported values */
- IPP_QUALITY_DRAFT,
- IPP_QUALITY_NORMAL,
- IPP_QUALITY_HIGH
- };
- static const char * const printer_supply[] =
- { /* printer-supply values */
- "index=1;class=receptacleThatIsFilled;type=wasteToner;unit=percent;"
- "maxcapacity=100;level=25;colorantname=unknown;",
- "index=2;class=supplyThatIsConsumed;type=toner;unit=percent;"
- "maxcapacity=100;level=75;colorantname=black;"
- };
- static const char * const printer_supply_color[] =
- { /* printer-supply values */
- "index=1;class=receptacleThatIsFilled;type=wasteInk;unit=percent;"
- "maxcapacity=100;level=25;colorantname=unknown;",
- "index=2;class=supplyThatIsConsumed;type=ink;unit=percent;"
- "maxcapacity=100;level=75;colorantname=black;",
- "index=3;class=supplyThatIsConsumed;type=ink;unit=percent;"
- "maxcapacity=100;level=50;colorantname=cyan;",
- "index=4;class=supplyThatIsConsumed;type=ink;unit=percent;"
- "maxcapacity=100;level=33;colorantname=magenta;",
- "index=5;class=supplyThatIsConsumed;type=ink;unit=percent;"
- "maxcapacity=100;level=67;colorantname=yellow;"
- };
- static const char * const printer_supply_description[] =
- { /* printer-supply-description values */
- "Toner Waste Tank",
- "Black Toner"
- };
- static const char * const printer_supply_description_color[] =
- { /* printer-supply-description values */
- "Ink Waste Tank",
- "Black Ink",
- "Cyan Ink",
- "Magenta Ink",
- "Yellow Ink"
- };
- static const char * const pwg_raster_document_type_supported[] =
- {
- "black_1",
- "sgray_8"
- };
- static const char * const pwg_raster_document_type_supported_color[] =
- {
- "black_1",
- "sgray_8",
- "srgb_8",
- "srgb_16"
- };
- static const char * const sides_supported[] =
- { /* sides-supported values */
- "one-sided",
- "two-sided-long-edge",
- "two-sided-short-edge"
- };
-
-
- /*
- * Open the PPD file...
- */
-
- if ((ppd = ppdOpenFile(ppdfile)) == NULL)
- {
- ppd_status_t status; /* Load error */
-
- status = ppdLastError(&i);
- _cupsLangPrintf(stderr, _("ippeveprinter: Unable to open \"%s\": %s on line %d."), ppdfile, ppdErrorString(status), i);
- return (NULL);
- }
-
- ppdMarkDefaults(ppd);
-
- pc = _ppdCacheCreateWithPPD(ppd);
-
- if ((ppd_size = ppdPageSize(ppd, NULL)) != NULL)
- {
- /*
- * Look up default size...
- */
-
- for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
- {
- if (!strcmp(pwg_size->map.ppd, ppd_size->name))
- {
- default_size = pwg_size;
- break;
- }
- }
- }
-
- if (!default_size)
- {
- /*
- * Default to A4 or Letter...
- */
-
- for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
- {
- if (!strcmp(pwg_size->map.ppd, "Letter") || !strcmp(pwg_size->map.ppd, "A4"))
- {
- default_size = pwg_size;
- break;
- }
- }
-
- if (!default_size)
- default_size = pc->sizes; /* Last resort: first size */
- }
-
- if ((ppd_choice = ppdFindMarkedChoice(ppd, "InputSlot")) != NULL)
- default_source = _ppdCacheGetSource(pc, ppd_choice->choice);
-
- if ((ppd_choice = ppdFindMarkedChoice(ppd, "MediaType")) != NULL)
- default_source = _ppdCacheGetType(pc, ppd_choice->choice);
-
- if ((ppd_attr = ppdFindAttr(ppd, "DefaultResolution", NULL)) != NULL)
- {
- /*
- * Use the PPD-defined default resolution...
- */
-
- if ((i = sscanf(ppd_attr->value, "%dx%d", &xres, &yres)) == 1)
- yres = xres;
- else if (i < 0)
- xres = yres = 300;
- }
- else
- {
- /*
- * Use default of 300dpi...
- */
-
- xres = yres = 300;
- }
-
- snprintf(urf_rs, sizeof(urf_rs), "RS%d", yres < xres ? yres : xres);
-
- num_urf = 0;
- urf[num_urf ++] = "V1.4";
- urf[num_urf ++] = "CP1";
- urf[num_urf ++] = urf_rs;
- urf[num_urf ++] = "W8";
- if (pc->sides_2sided_long)
- urf[num_urf ++] = "DM1";
- if (ppd->color_device)
- urf[num_urf ++] = "SRGB24";
-
- /*
- * PostScript printers accept PDF via one of the CUPS PDF to PostScript
- * filters, along with PostScript (of course) and JPEG...
- */
-
- cupsArrayAdd(docformats, "application/pdf");
- cupsArrayAdd(docformats, "application/postscript");
- cupsArrayAdd(docformats, "image/jpeg");
-
- /*
- * Create the attributes...
- */
-
- attrs = ippNew();
-
- /* color-supported */
- ippAddBoolean(attrs, IPP_TAG_PRINTER, "color-supported", (char)ppd->color_device);
-
- /* copies-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "copies-default", 1);
-
- /* copies-supported */
- ippAddRange(attrs, IPP_TAG_PRINTER, "copies-supported", 1, 999);
-
- /* document-password-supported */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "document-password-supported", 127);
-
- /* finishing-template-supported */
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template-supported", cupsArrayCount(pc->templates) + 1, NULL, NULL);
- ippSetString(attrs, &attr, 0, "none");
- for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
- ippSetString(attrs, &attr, i, template);
-
- /* finishings-col-database */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-database", cupsArrayCount(pc->templates) + 1, NULL);
-
- col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
- ippSetCollection(attrs, &attr, 0, col);
- ippDelete(col);
-
- for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
- {
- col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
- ippSetCollection(attrs, &attr, i, col);
- ippDelete(col);
- }
-
- /* finishings-col-default */
- col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
- ippAddCollection(attrs, IPP_TAG_PRINTER, "finishings-col-default", col);
- ippDelete(col);
-
- /* finishings-col-ready */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "finishings-col-ready", cupsArrayCount(pc->templates) + 1, NULL);
-
- col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, "none");
- ippSetCollection(attrs, &attr, 0, col);
- ippDelete(col);
-
- for (i = 1, template = (const char *)cupsArrayFirst(pc->templates); template; i ++, template = (const char *)cupsArrayNext(pc->templates))
- {
- col = ippNew();
- ippAddString(col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "finishing-template", NULL, template);
- ippSetCollection(attrs, &attr, i, col);
- ippDelete(col);
- }
-
- /* finishings-col-supported */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "finishings-col-supported", NULL, "finishing-template");
-
- /* finishings-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-default", IPP_FINISHINGS_NONE);
-
- /* finishings-ready */
- attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-ready", cupsArrayCount(pc->finishings) + 1, NULL);
- ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE);
- for (i = 1, finishings = (_pwg_finishings_t *)cupsArrayFirst(pc->finishings); finishings; i ++, finishings = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
- ippSetInteger(attrs, &attr, i, (int)finishings->value);
-
- /* finishings-supported */
- attr = ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "finishings-supported", cupsArrayCount(pc->finishings) + 1, NULL);
- ippSetInteger(attrs, &attr, 0, IPP_FINISHINGS_NONE);
- for (i = 1, finishings = (_pwg_finishings_t *)cupsArrayFirst(pc->finishings); finishings; i ++, finishings = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
- ippSetInteger(attrs, &attr, i, (int)finishings->value);
-
- /* media-bottom-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
- {
- for (j = 0; j < num_margins; j ++)
- {
- if (margins[j] == pwg_size->bottom)
- break;
- }
-
- if (j >= num_margins)
- margins[num_margins ++] = pwg_size->bottom;
- }
-
- for (i = 0; i < (num_margins - 1); i ++)
- {
- for (j = i + 1; j < num_margins; j ++)
- {
- if (margins[i] > margins[j])
- {
- int mtemp = margins[i];
-
- margins[i] = margins[j];
- margins[j] = mtemp;
- }
- }
- }
-
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-bottom-margin-supported", num_margins, margins);
-
- /* media-col-database */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-col-database", pc->num_sizes, NULL);
- for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
- {
- col = create_media_col(pwg_size->map.pwg, NULL, NULL, pwg_size->width, pwg_size->length, pwg_size->bottom, pwg_size->left, pwg_size->right, pwg_size->top);
- ippSetCollection(attrs, &attr, i, col);
- ippDelete(col);
- }
-
- /* media-col-default */
- col = create_media_col(default_size->map.pwg, default_source, default_type, default_size->width, default_size->length, default_size->bottom, default_size->left, default_size->right, default_size->top);
- ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-default", col);
- ippDelete(col);
-
- /* media-col-ready */
- col = create_media_col(default_size->map.pwg, default_source, default_type, default_size->width, default_size->length, default_size->bottom, default_size->left, default_size->right, default_size->top);
- ippAddCollection(attrs, IPP_TAG_PRINTER, "media-col-ready", col);
- ippDelete(col);
-
- /* media-default */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-default", NULL, default_size->map.pwg);
-
- /* media-left-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
- {
- for (j = 0; j < num_margins; j ++)
- {
- if (margins[j] == pwg_size->left)
- break;
- }
-
- if (j >= num_margins)
- margins[num_margins ++] = pwg_size->left;
- }
-
- for (i = 0; i < (num_margins - 1); i ++)
- {
- for (j = i + 1; j < num_margins; j ++)
- {
- if (margins[i] > margins[j])
- {
- int mtemp = margins[i];
-
- margins[i] = margins[j];
- margins[j] = mtemp;
- }
- }
- }
-
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-left-margin-supported", num_margins, margins);
-
- /* media-ready */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-ready", NULL, default_size->map.pwg);
-
- /* media-right-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
- {
- for (j = 0; j < num_margins; j ++)
- {
- if (margins[j] == pwg_size->right)
- break;
- }
-
- if (j >= num_margins)
- margins[num_margins ++] = pwg_size->right;
- }
-
- for (i = 0; i < (num_margins - 1); i ++)
- {
- for (j = i + 1; j < num_margins; j ++)
- {
- if (margins[i] > margins[j])
- {
- int mtemp = margins[i];
-
- margins[i] = margins[j];
- margins[j] = mtemp;
- }
- }
- }
-
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-right-margin-supported", num_margins, margins);
-
- /* media-supported */
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-supported", pc->num_sizes, NULL, NULL);
- for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
- ippSetString(attrs, &attr, i, pwg_size->map.pwg);
-
- /* media-size-supported */
- attr = ippAddCollections(attrs, IPP_TAG_PRINTER, "media-size-supported", pc->num_sizes, NULL);
- for (i = 0, pwg_size = pc->sizes; i < pc->num_sizes; i ++, pwg_size ++)
- {
- col = create_media_size(pwg_size->width, pwg_size->length);
- ippSetCollection(attrs, &attr, i, col);
- ippDelete(col);
- }
-
- /* media-source-supported */
- if (pc->num_sources > 0)
- {
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-source-supported", pc->num_sources, NULL, NULL);
- for (i = 0, pwg_map = pc->sources; i < pc->num_sources; i ++, pwg_map ++)
- ippSetString(attrs, &attr, i, pwg_map->pwg);
- }
- else
- {
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-source-supported", NULL, "auto");
- }
-
- /* media-top-margin-supported */
- for (i = 0, num_margins = 0, pwg_size = pc->sizes; i < pc->num_sizes && num_margins < (int)(sizeof(margins) / sizeof(margins[0])); i ++, pwg_size ++)
- {
- for (j = 0; j < num_margins; j ++)
- {
- if (margins[j] == pwg_size->top)
- break;
- }
-
- if (j >= num_margins)
- margins[num_margins ++] = pwg_size->top;
- }
-
- for (i = 0; i < (num_margins - 1); i ++)
- {
- for (j = i + 1; j < num_margins; j ++)
- {
- if (margins[i] > margins[j])
- {
- int mtemp = margins[i];
-
- margins[i] = margins[j];
- margins[j] = mtemp;
- }
- }
- }
-
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "media-top-margin-supported", num_margins, margins);
-
- /* media-type-supported */
- if (pc->num_types > 0)
- {
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-type-supported", pc->num_types, NULL, NULL);
- for (i = 0, pwg_map = pc->types; i < pc->num_types; i ++, pwg_map ++)
- ippSetString(attrs, &attr, i, pwg_map->pwg);
- }
- else
- {
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "media-type-supported", NULL, "auto");
- }
-
- /* orientation-requested-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-default", IPP_ORIENT_PORTRAIT);
-
- /* orientation-requested-supported */
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "orientation-requested-supported", (int)(sizeof(orientation_requested_supported) / sizeof(orientation_requested_supported[0])), orientation_requested_supported);
-
- /* output-bin-default */
- if (pc->num_bins > 0)
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-default", NULL, pc->bins->pwg);
- else
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-default", NULL, "face-down");
-
- /* output-bin-supported */
- if (pc->num_bins > 0)
- {
- attr = ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "output-bin-supported", pc->num_bins, NULL, NULL);
- for (i = 0, pwg_map = pc->bins; i < pc->num_bins; i ++, pwg_map ++)
- ippSetString(attrs, &attr, i, pwg_map->pwg);
- }
- else
- {
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "output-bin-supported", NULL, "face-down");
- }
-
- /* overrides-supported */
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "overrides-supported", (int)(sizeof(overrides_supported) / sizeof(overrides_supported[0])), NULL, overrides_supported);
-
- /* page-ranges-supported */
- ippAddBoolean(attrs, IPP_TAG_PRINTER, "page-ranges-supported", 1);
-
- /* pages-per-minute */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute", ppd->throughput);
-
- /* pages-per-minute-color */
- if (ppd->color_device)
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "pages-per-minute-color", ppd->throughput);
-
- /* print-color-mode-default */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-default", NULL, ppd->color_device ? "auto" : "monochrome");
-
- /* print-color-mode-supported */
- if (ppd->color_device)
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-supported", (int)(sizeof(print_color_mode_supported_color) / sizeof(print_color_mode_supported_color[0])), NULL, print_color_mode_supported_color);
- else
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-color-mode-supported", (int)(sizeof(print_color_mode_supported) / sizeof(print_color_mode_supported[0])), NULL, print_color_mode_supported);
-
- /* print-content-optimize-default */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-content-optimize-default", NULL, "auto");
-
- /* print-content-optimize-supported */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-content-optimize-supported", NULL, "auto");
-
- /* print-quality-default */
- ippAddInteger(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-default", IPP_QUALITY_NORMAL);
-
- /* print-quality-supported */
- ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_ENUM, "print-quality-supported", (int)(sizeof(print_quality_supported) / sizeof(print_quality_supported[0])), print_quality_supported);
-
- /* print-rendering-intent-default */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-rendering-intent-default", NULL, "auto");
-
- /* print-rendering-intent-supported */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "print-rendering-intent-supported", NULL, "auto");
-
- /* printer-device-id */
- if ((ppd_attr = ppdFindAttr(ppd, "1284DeviceId", NULL)) != NULL)
- {
- /*
- * Use the device ID string from the PPD...
- */
-
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, ppd_attr->value);
- }
- else
- {
- /*
- * Synthesize a device ID string...
- */
-
- char device_id[1024]; /* Device ID string */
-
- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;CMD:PS;", ppd->manufacturer, ppd->modelname);
-
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, device_id);
- }
-
- /* printer-input-tray */
- if (pc->num_sources > 0)
- {
- for (i = 0, attr = NULL; i < pc->num_sources; i ++)
- {
- char input_tray[1024]; /* printer-input-tray value */
-
- if (!strcmp(pc->sources[i].pwg, "manual") || strstr(pc->sources[i].pwg, "-man") != NULL)
- snprintf(input_tray, sizeof(input_tray), "type=sheetFeedManual;mediafeed=0;mediaxfeed=0;maxcapacity=1;level=-2;status=0;name=%s", pc->sources[i].pwg);
- else
- snprintf(input_tray, sizeof(input_tray), "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=250;level=125;status=0;name=%s", pc->sources[i].pwg);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-device-id", NULL, device_id);
- if (attr)
- ippSetOctetString(attrs, &attr, i, input_tray, (int)strlen(input_tray));
- else
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", input_tray, (int)strlen(input_tray));
- }
+ // printer-input-tray
+ if (ppm_color > 0)
+ {
+ attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", printer_input_tray_color[0], strlen(printer_input_tray_color[0]));
+ for (i = 1; i < (int)(sizeof(printer_input_tray_color) / sizeof(printer_input_tray_color[0])); i ++)
+ ippSetOctetString(attrs, &attr, i, printer_input_tray_color[i], strlen(printer_input_tray_color[i]));
}
else
{
- static const char *printer_input_tray = "type=sheetFeedAutoRemovableTray;mediafeed=0;mediaxfeed=0;maxcapacity=-2;level=-2;status=0;name=auto";
-
- ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", printer_input_tray, (int)strlen(printer_input_tray));
+ attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-input-tray", printer_input_tray[0], strlen(printer_input_tray[0]));
+ for (i = 1; i < (int)(sizeof(printer_input_tray) / sizeof(printer_input_tray[0])); i ++)
+ ippSetOctetString(attrs, &attr, i, printer_input_tray[i], strlen(printer_input_tray[i]));
}
- /* printer-make-and-model */
- ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-make-and-model", NULL, ppd->nickname);
+ // printer-make-and-model
+ snprintf(make_model, sizeof(make_model), "%s %s", make, model);
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-make-and-model", NULL, make_model);
- /* printer-resolution-default */
- ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-default", IPP_RES_PER_INCH, xres, yres);
+ // printer-resolution-default
+ ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-default", IPP_RES_PER_INCH, 600, 600);
- /* printer-resolution-supported */
- ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-supported", IPP_RES_PER_INCH, xres, yres);
+ // printer-resolution-supported
+ ippAddResolution(attrs, IPP_TAG_PRINTER, "printer-resolution-supported", IPP_RES_PER_INCH, 600, 600);
- /* printer-supply and printer-supply-description */
- if (ppd->color_device)
+ // printer-supply and printer-supply-description
+ if (ppm_color > 0)
{
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-supply", printer_supply_color[0], (int)strlen(printer_supply_color[0]));
+ attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-supply", printer_supply_color[0], strlen(printer_supply_color[0]));
for (i = 1; i < (int)(sizeof(printer_supply_color) / sizeof(printer_supply_color[0])); i ++)
- ippSetOctetString(attrs, &attr, i, printer_supply_color[i], (int)strlen(printer_supply_color[i]));
+ ippSetOctetString(attrs, &attr, i, printer_supply_color[i], strlen(printer_supply_color[i]));
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_TEXT), "printer-supply-description", (int)(sizeof(printer_supply_description_color) / sizeof(printer_supply_description_color[0])), NULL, printer_supply_description_color);
}
else
{
- attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-supply", printer_supply[0], (int)strlen(printer_supply[0]));
+ attr = ippAddOctetString(attrs, IPP_TAG_PRINTER, "printer-supply", printer_supply[0], strlen(printer_supply[0]));
for (i = 1; i < (int)(sizeof(printer_supply) / sizeof(printer_supply[0])); i ++)
- ippSetOctetString(attrs, &attr, i, printer_supply[i], (int)strlen(printer_supply[i]));
+ ippSetOctetString(attrs, &attr, i, printer_supply[i], strlen(printer_supply[i]));
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_TEXT), "printer-supply-description", (int)(sizeof(printer_supply_description) / sizeof(printer_supply_description[0])), NULL, printer_supply_description);
}
- /* pwg-raster-document-xxx-supported */
+ // pwg-raster-document-xxx-supported
if (cupsArrayFind(docformats, (void *)"image/pwg-raster"))
{
- ippAddResolution(attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", IPP_RES_PER_INCH, xres, yres);
+ ippAddResolutions(attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", (int)(sizeof(pwg_raster_document_resolution_supported) / sizeof(pwg_raster_document_resolution_supported[0])), IPP_RES_PER_INCH, pwg_raster_document_resolution_supported, pwg_raster_document_resolution_supported);
- if (pc->sides_2sided_long)
+ if (ppm_color > 0 && duplex)
+ ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-sheet-back", NULL, "rotated");
+ else if (duplex)
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-sheet-back", NULL, "normal");
- if (ppd->color_device)
+ if (ppm_color > 0)
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-type-supported", (int)(sizeof(pwg_raster_document_type_supported_color) / sizeof(pwg_raster_document_type_supported_color[0])), NULL, pwg_raster_document_type_supported_color);
else
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "pwg-raster-document-type-supported", (int)(sizeof(pwg_raster_document_type_supported) / sizeof(pwg_raster_document_type_supported[0])), NULL, pwg_raster_document_type_supported);
}
- /* sides-default */
+ // sides-default
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-default", NULL, "one-sided");
- /* sides-supported */
- if (pc->sides_2sided_long)
+ // sides-supported
+ if (duplex)
ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", (int)(sizeof(sides_supported) / sizeof(sides_supported[0])), NULL, sides_supported);
else
ippAddString(attrs, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD), "sides-supported", NULL, "one-sided");
- /* urf-supported */
+ // urf-supported
if (cupsArrayFind(docformats, (void *)"image/urf"))
- ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", num_urf, NULL, urf);
-
- /*
- * Free the PPD file and return the attributes...
- */
-
- _ppdCacheDestroy(pc);
-
- ppdClose(ppd);
+ {
+ if (ppm_color > 0)
+ {
+ if (duplex)
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported_color_duplex) / sizeof(urf_supported_color_duplex[0])), NULL, urf_supported_color_duplex);
+ else
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported_color) / sizeof(urf_supported_color[0])), NULL, urf_supported_color);
+ }
+ else if (duplex)
+ {
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported_duplex) / sizeof(urf_supported_duplex[0])), NULL, urf_supported_duplex);
+ }
+ else
+ {
+ ippAddStrings(attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "urf-supported", (int)(sizeof(urf_supported) / sizeof(urf_supported[0])), NULL, urf_supported);
+ }
+ }
return (attrs);
}
-#endif /* !CUPS_LITE */
#if HAVE_LIBPAM
-/*
- * 'pam_func()' - PAM conversation function.
- */
+//
+// 'pam_func()' - PAM conversation function.
+//
-static int /* O - Success or failure */
+static int // O - Success or failure
pam_func(
- int num_msg, /* I - Number of messages */
- const struct pam_message **msg, /* I - Messages */
- struct pam_response **resp, /* O - Responses */
+ int num_msg, // I - Number of messages
+ const struct pam_message **msg, // I - Messages
+ struct pam_response **resp, // O - Responses
void *appdata_ptr)
- /* I - Pointer to connection */
+ // I - Pointer to connection
{
- int i; /* Looping var */
- struct pam_response *replies; /* Replies */
- ippeve_authdata_t *data; /* Pointer to auth data */
-
+ int i; // Looping var
+ struct pam_response *replies; // Replies
+ ippeve_authdata_t *data; // Pointer to auth data
- /*
- * Allocate memory for the responses...
- */
+ // Allocate memory for the responses...
if ((replies = malloc(sizeof(struct pam_response) * (size_t)num_msg)) == NULL)
return (PAM_CONV_ERR);
- /*
- * Answer all of the messages...
- */
-
+ // Answer all of the messages...
data = (ippeve_authdata_t *)appdata_ptr;
for (i = 0; i < num_msg; i ++)
}
}
- /*
- * Return the responses back to PAM...
- */
-
+ // Return the responses back to PAM...
*resp = replies;
return (PAM_SUCCESS);
}
-#endif /* HAVE_LIBPAM */
+#endif // HAVE_LIBPAM
-/*
- * 'parse_options()' - Parse URL options into CUPS options.
- *
- * The client->options string is destroyed by this function.
- */
+//
+// 'parse_options()' - Parse URL options into CUPS options.
+//
+// The client->options string is destroyed by this function.
+//
-static int /* O - Number of options */
-parse_options(ippeve_client_t *client, /* I - Client */
- cups_option_t **options)/* O - Options */
+static int // O - Number of options
+parse_options(ippeve_client_t *client, // I - Client
+ cups_option_t **options)// O - Options
{
- char *name, /* Name */
- *value, /* Value */
- *next; /* Next name=value pair */
- int num_options = 0; /* Number of options */
+ char *name, // Name
+ *value, // Value
+ *next; // Next name=value pair
+ int num_options = 0; // Number of options
*options = NULL;
}
-/*
- * 'process_attr_message()' - Process an ATTR: message from a command.
- */
+//
+// 'process_attr_message()' - Process an ATTR: message from a command.
+//
static void
process_attr_message(
- ippeve_job_t *job, /* I - Job */
- char *message) /* I - Message */
+ ippeve_job_t *job, // I - Job
+ char *message) // I - Message
{
- int i, /* Looping var */
- num_options = 0; /* Number of name=value pairs */
- cups_option_t *options = NULL, /* name=value pairs from message */
- *option; /* Current option */
- ipp_attribute_t *attr; /* Current attribute */
+ int i, // Looping var
+ num_options = 0; // Number of name=value pairs
+ cups_option_t *options = NULL, // name=value pairs from message
+ *option; // Current option
+ ipp_attribute_t *attr; // Current attribute
- /*
- * Grab attributes from the message line...
- */
-
+ // Grab attributes from the message line...
num_options = cupsParseOptions(message + 5, num_options, &options);
- /*
- * Loop through the options and record them in the printer or job objects...
- */
-
+ // Loop through the options and record them in the printer or job objects...
for (i = num_options, option = options; i > 0; i --, option ++)
{
if (!strcmp(option->name, "job-impressions"))
{
- /*
- * Update job-impressions attribute...
- */
-
+ // Update job-impressions attribute...
job->impressions = atoi(option->value);
}
else if (!strcmp(option->name, "job-impressions-completed"))
{
- /*
- * Update job-impressions-completed attribute...
- */
-
+ // Update job-impressions-completed attribute...
job->impcompleted = atoi(option->value);
}
else if (!strncmp(option->name, "marker-", 7) || !strcmp(option->name, "printer-alert") || !strcmp(option->name, "printer-alert-description") || !strcmp(option->name, "printer-supply") || !strcmp(option->name, "printer-supply-description"))
{
- /*
- * Update Printer Status attribute...
- */
-
+ // Update Printer Status attribute...
cupsRWLockWrite(&job->printer->rwlock);
if ((attr = ippFindAttribute(job->printer->attrs, option->name, IPP_TAG_ZERO)) != NULL)
}
else
{
- /*
- * Something else that isn't currently supported...
- */
-
+ // Something else that isn't currently supported...
fprintf(stderr, "[Job %d] Ignoring update of attribute \"%s\" with value \"%s\".\n", job->id, option->name, option->value);
}
}
}
-/*
- * 'process_client()' - Process client requests on a thread.
- */
+//
+// 'process_client()' - Process client requests on a thread.
+//
-static void * /* O - Exit status */
-process_client(ippeve_client_t *client) /* I - Client */
+static void * // O - Exit status
+process_client(ippeve_client_t *client) // I - Client
{
- /*
- * Loop until we are out of requests or timeout (30 seconds)...
- */
-
- int first_time = 1; /* First time request? */
-
+ // Loop until we are out of requests or timeout (30 seconds)...
+ bool first_time = true; // First time request?
while (httpWait(client->http, 30000))
{
if (first_time)
{
- /*
- * See if we need to negotiate a TLS connection...
- */
-
- char buf[1]; /* First byte from client */
+ // See if we need to negotiate a TLS connection...
+ char buf[1]; // First byte from client
if (recv(httpGetFd(client->http), buf, 1, MSG_PEEK) == 1 && (!buf[0] || !strchr("DGHOPT", buf[0])))
{
fprintf(stderr, "%s Starting HTTPS session.\n", client->hostname);
- if (httpEncryption(client->http, HTTP_ENCRYPTION_ALWAYS))
+ if (!httpSetEncryption(client->http, HTTP_ENCRYPTION_ALWAYS))
{
fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsGetErrorString());
break;
fprintf(stderr, "%s Connection now encrypted.\n", client->hostname);
}
- first_time = 0;
+ first_time = false;
}
if (!process_http(client))
break;
}
- /*
- * Close the connection to the client and return...
- */
-
+ // Close the conection to the client and return...
delete_client(client);
return (NULL);
}
-/*
- * 'process_http()' - Process a HTTP request.
- */
+//
+// 'process_http()' - Process a HTTP request.
+//
-int /* O - 1 on success, 0 on failure */
-process_http(ippeve_client_t *client) /* I - Client connection */
+int // O - 1 on success, 0 on failure
+process_http(ippeve_client_t *client) // I - Client connection
{
- char uri[1024]; /* URI */
- http_state_t http_state; /* HTTP state */
- http_status_t http_status; /* HTTP status */
- ipp_state_t ipp_state; /* State of IPP transfer */
- char scheme[32], /* Method/scheme */
- userpass[128], /* Username:password */
+ char uri[1024]; // URI
+ http_state_t http_state; // HTTP state
+ http_status_t http_status; // HTTP status
+ ipp_state_t ipp_state; // State of IPP transfer
+ char scheme[32], // Method/scheme
+ userpass[128], // Username:password
hostname[HTTP_MAX_HOST],
- /* Hostname */
- *ptr; /* Pointer into value */
- int port; /* Port number */
- static const char * const http_states[] =
- { /* Strings for logging HTTP method */
- "WAITING",
- "OPTIONS",
- "GET",
- "GET_SEND",
- "HEAD",
- "POST",
- "POST_RECV",
- "POST_SEND",
- "PUT",
- "PUT_RECV",
- "DELETE",
- "TRACE",
- "CONNECT",
- "STATUS",
- "UNKNOWN_METHOD",
- "UNKNOWN_VERSION"
- };
-
+ // Hostname
+ *ptr; // Pointer into value
+ int port; // Port number
- /*
- * Clear state variables...
- */
+ // Clear state variables...
client->username[0] = '\0';
ippDelete(client->request);
client->response = NULL;
client->operation = HTTP_STATE_WAITING;
- /*
- * Read a request from the connection...
- */
-
- while ((http_state = httpReadRequest(client->http, uri,
- sizeof(uri))) == HTTP_STATE_WAITING)
+ // Read a request from the connection...
+ while ((http_state = httpReadRequest(client->http, uri, sizeof(uri))) == HTTP_STATE_WAITING)
usleep(1);
- /*
- * Parse the request line...
- */
-
+ // Parse the request line...
if (http_state == HTTP_STATE_ERROR)
{
- if (httpError(client->http) == EPIPE)
+ if (httpGetError(client->http) == EPIPE)
fprintf(stderr, "%s Client closed connection.\n", client->hostname);
else
- fprintf(stderr, "%s Bad request line (%s).\n", client->hostname, strerror(httpError(client->http)));
+ fprintf(stderr, "%s Bad request line (%s).\n", client->hostname, strerror(httpGetError(client->http)));
return (0);
}
return (0);
}
- fprintf(stderr, "%s %s %s\n", client->hostname, http_states[http_state], uri);
+ fprintf(stderr, "%s %s %s\n", client->hostname, httpStateString(http_state), uri);
- /*
- * Separate the URI into its components...
- */
-
- if (httpSeparateURI(HTTP_URI_CODING_MOST, uri, scheme, sizeof(scheme),
- userpass, sizeof(userpass),
- hostname, sizeof(hostname), &port,
- client->uri, sizeof(client->uri)) < HTTP_URI_STATUS_OK &&
- (http_state != HTTP_STATE_OPTIONS || strcmp(uri, "*")))
+ // Separate the URI into its components...
+ if (httpSeparateURI(HTTP_URI_CODING_MOST, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, client->uri, sizeof(client->uri)) < HTTP_URI_STATUS_OK && (http_state != HTTP_STATE_OPTIONS || strcmp(uri, "*")))
{
fprintf(stderr, "%s Bad URI \"%s\".\n", client->hostname, uri);
respond_http(client, HTTP_STATUS_BAD_REQUEST, NULL, NULL, 0);
if ((client->options = strchr(client->uri, '?')) != NULL)
*(client->options)++ = '\0';
- /*
- * Process the request...
- */
-
+ // Process the request...
client->start = time(NULL);
client->operation = httpGetState(client->http);
- /*
- * Parse incoming parameters until the status changes...
- */
-
+ // Parse incoming parameters until the status changes...
while ((http_status = httpUpdate(client->http)) == HTTP_STATUS_CONTINUE);
if (http_status != HTTP_STATUS_OK)
return (0);
}
- /*
- * Validate the host header...
- */
-
- if (!httpGetField(client->http, HTTP_FIELD_HOST)[0] &&
- httpGetVersion(client->http) >= HTTP_VERSION_1_1)
+ // Validate the host header...
+ if (!httpGetField(client->http, HTTP_FIELD_HOST)[0] && httpGetVersion(client->http) >= HTTP_VERSION_1_1)
{
- /*
- * HTTP/1.1 and higher require the "Host:" field...
- */
-
+ // HTTP/1.1 and higher require the "Host:" field...
fprintf(stderr, "%s Missing Host: header.\n", client->hostname);
respond_http(client, HTTP_STATUS_BAD_REQUEST, NULL, NULL, 0);
return (0);
cupsCopyString(client->host_field, httpGetField(client->http, HTTP_FIELD_HOST), sizeof(client->host_field));
if ((ptr = strrchr(client->host_field, ':')) != NULL)
{
- /*
- * Grab port number from Host: header...
- */
-
+ // Grab port number from Host: header...
*ptr++ = '\0';
client->host_port = atoi(ptr);
}
else
{
- /*
- * Use the default port number...
- */
-
+ // Use the default port number...
client->host_port = client->printer->port;
}
return (0);
}
- /*
- * Handle HTTP Upgrade...
- */
-
+ // Handle HTTP Upgrade...
if (!strcasecmp(httpGetField(client->http, HTTP_FIELD_CONNECTION), "Upgrade"))
{
if (strstr(httpGetField(client->http, HTTP_FIELD_UPGRADE), "TLS/") != NULL && !httpIsEncrypted(client->http))
fprintf(stderr, "%s Upgrading to encrypted connection.\n", client->hostname);
- if (httpEncryption(client->http, HTTP_ENCRYPTION_REQUIRED))
+ if (!httpSetEncryption(client->http, HTTP_ENCRYPTION_REQUIRED))
{
fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsGetErrorString());
return (0);
return (0);
}
- /*
- * Handle new transfers...
- */
-
+ // Handle new transfers...
switch (client->operation)
{
case HTTP_STATE_OPTIONS :
- /*
- * Do OPTIONS command...
- */
-
+ // Do OPTIONS command...
return (respond_http(client, HTTP_STATUS_OK, NULL, NULL, 0));
case HTTP_STATE_HEAD :
case HTTP_STATE_GET :
if (!strcmp(client->uri, "/en.strings"))
{
- /*
- * Send strings file.
- */
-
+ // Send strings file.
if (client->printer->strings)
{
- int fd; /* Icon file */
- struct stat fileinfo; /* Icon file information */
- char buffer[4096]; /* Copy buffer */
- ssize_t bytes; /* Bytes */
+ int fd; // Icon file
+ struct stat fileinfo; // Icon file information
+ char buffer[4096]; // Copy buffer
+ ssize_t bytes; // Bytes
- if (!stat(client->printer->strings, &fileinfo) && (fd = open(client->printer->strings, O_RDONLY | O_BINARY)) >= 0)
+ if ((fd = open(client->printer->strings, O_RDONLY | O_BINARY)) >= 0)
{
- if (!respond_http(client, HTTP_STATUS_OK, NULL, "text/strings", (size_t)fileinfo.st_size))
+ if (fstat(fd, &fileinfo))
+ {
+ close(fd);
+ return (0);
+ }
+ else if (!respond_http(client, HTTP_STATUS_OK, NULL, "text/strings", (size_t)fileinfo.st_size))
{
close(fd);
return (0);
}
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
- httpWrite2(client->http, buffer, (size_t)bytes);
+ httpWrite(client->http, buffer, (size_t)bytes);
httpFlushWrite(client->http);
}
else if (!strcmp(client->uri, "/icon.png"))
{
- /*
- * Send medium PNG icon file.
- */
-
+ // Send medium PNG icon file.
if (client->printer->icons[1])
{
- int fd; /* Icon file */
- struct stat fileinfo; /* Icon file information */
- char buffer[4096]; /* Copy buffer */
- ssize_t bytes; /* Bytes */
+ int fd; // Icon file
+ struct stat fileinfo; // Icon file information
+ char buffer[4096]; // Copy buffer
+ ssize_t bytes; // Bytes
- if (!stat(client->printer->icons[1], &fileinfo) && (fd = open(client->printer->icons[1], O_RDONLY | O_BINARY)) >= 0)
+ if ((fd = open(client->printer->icons[1], O_RDONLY | O_BINARY)) >= 0)
{
- if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
+ if (fstat(fd, &fileinfo))
+ {
+ close(fd);
+ return (0);
+ }
+ else if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
{
close(fd);
return (0);
}
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
- httpWrite2(client->http, buffer, (size_t)bytes);
+ httpWrite(client->http, buffer, (size_t)bytes);
httpFlushWrite(client->http);
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", sizeof(printer_png)))
return (0);
- httpWrite2(client->http, (const char *)printer_png, sizeof(printer_png));
+ httpWrite(client->http, (const char *)printer_png, sizeof(printer_png));
httpFlushWrite(client->http);
}
}
else if (!strcmp(client->uri, "/icon-lg.png"))
{
- /*
- * Send large PNG icon file.
- */
-
+ // Send large PNG icon file.
if (client->printer->icons[2])
{
- int fd; /* Icon file */
- struct stat fileinfo; /* Icon file information */
- char buffer[4096]; /* Copy buffer */
- ssize_t bytes; /* Bytes */
+ int fd; // Icon file
+ struct stat fileinfo; // Icon file information
+ char buffer[4096]; // Copy buffer
+ ssize_t bytes; // Bytes
- if (!stat(client->printer->icons[2], &fileinfo) && (fd = open(client->printer->icons[2], O_RDONLY | O_BINARY)) >= 0)
+ if ((fd = open(client->printer->icons[2], O_RDONLY | O_BINARY)) >= 0)
{
- if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
+ if (fstat(fd, &fileinfo))
+ {
+ close(fd);
+ return (0);
+ }
+ else if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
{
close(fd);
return (0);
}
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
- httpWrite2(client->http, buffer, (size_t)bytes);
+ httpWrite(client->http, buffer, (size_t)bytes);
httpFlushWrite(client->http);
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", sizeof(printer_lg_png)))
return (0);
- httpWrite2(client->http, (const char *)printer_lg_png, sizeof(printer_lg_png));
+ httpWrite(client->http, (const char *)printer_lg_png, sizeof(printer_lg_png));
httpFlushWrite(client->http);
}
}
else if (!strcmp(client->uri, "/icon-sm.png"))
{
- /*
- * Send small PNG icon file.
- */
-
+ // Send small PNG icon file.
if (client->printer->icons[0])
{
- int fd; /* Icon file */
- struct stat fileinfo; /* Icon file information */
- char buffer[4096]; /* Copy buffer */
- ssize_t bytes; /* Bytes */
+ int fd; // Icon file
+ struct stat fileinfo; // Icon file information
+ char buffer[4096]; // Copy buffer
+ ssize_t bytes; // Bytes
- if (!stat(client->printer->icons[0], &fileinfo) && (fd = open(client->printer->icons[0], O_RDONLY | O_BINARY)) >= 0)
+ if ((fd = open(client->printer->icons[0], O_RDONLY | O_BINARY)) >= 0)
{
- if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
+ if (fstat(fd, &fileinfo))
+ {
+ close(fd);
+ return (0);
+ }
+ else if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", (size_t)fileinfo.st_size))
{
close(fd);
return (0);
}
while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
- httpWrite2(client->http, buffer, (size_t)bytes);
+ httpWrite(client->http, buffer, (size_t)bytes);
httpFlushWrite(client->http);
if (!respond_http(client, HTTP_STATUS_OK, NULL, "image/png", sizeof(printer_sm_png)))
return (0);
- httpWrite2(client->http, (const char *)printer_sm_png, sizeof(printer_sm_png));
+ httpWrite(client->http, (const char *)printer_sm_png, sizeof(printer_sm_png));
httpFlushWrite(client->http);
}
}
else
{
- /*
- * Authenticate if needed...
- */
-
+ // Authenticate if needed...
if ((http_status = authenticate_request(client)) != HTTP_STATUS_CONTINUE)
{
return (respond_http(client, http_status, NULL, NULL, 0));
if (!strcmp(client->uri, "/"))
{
- /*
- * Show web status page...
- */
-
+ // Show web status page...
return (show_status(client));
}
else if (!strcmp(client->uri, "/media"))
{
- /*
- * Show web media page...
- */
-
+ // Show web media page...
return (show_media(client));
}
else if (!strcmp(client->uri, "/supplies"))
{
- /*
- * Show web supplies page...
- */
-
+ // Show web supplies page...
return (show_supplies(client));
}
else
if (strcmp(httpGetField(client->http, HTTP_FIELD_CONTENT_TYPE),
"application/ipp"))
{
- /*
- * Not an IPP request...
- */
-
+ // Not an IPP request...
return (respond_http(client, HTTP_STATUS_BAD_REQUEST, NULL, NULL, 0));
}
- /*
- * Read the IPP request...
- */
-
+ // Read the IPP request...
client->request = ippNew();
- while ((ipp_state = ippRead(client->http,
- client->request)) != IPP_STATE_DATA)
+ while ((ipp_state = ippRead(client->http, client->request)) != IPP_STATE_DATA)
{
if (ipp_state == IPP_STATE_ERROR)
{
}
}
- /*
- * Now that we have the IPP request, process the request...
- */
-
+ // Now that we have the IPP request, process the request...
return (process_ipp(client));
default :
- break; /* Anti-compiler-warning-code */
+ break; // Anti-compiler-warning-code
}
return (1);
}
-/*
- * 'process_ipp()' - Process an IPP request.
- */
+//
+// 'process_ipp()' - Process an IPP request.
+//
-static int /* O - 1 on success, 0 on error */
-process_ipp(ippeve_client_t *client) /* I - Client */
+static int // O - 1 on success, 0 on error
+process_ipp(ippeve_client_t *client) // I - Client
{
- ipp_tag_t group; /* Current group tag */
- ipp_attribute_t *attr; /* Current attribute */
- ipp_attribute_t *charset; /* Character set attribute */
- ipp_attribute_t *language; /* Language attribute */
- ipp_attribute_t *uri; /* Printer URI attribute */
- int major, minor; /* Version number */
- const char *name; /* Name of attribute */
- http_status_t status; /* Authentication status */
+ ipp_tag_t group; // Current group tag
+ ipp_attribute_t *attr; // Current attribute
+ ipp_attribute_t *charset; // Character set attribute
+ ipp_attribute_t *language; // Language attribute
+ ipp_attribute_t *uri; // Printer URI attribute
+ int major, minor; // Version number
+ const char *name; // Name of attribute
+ http_status_t status; // Authentication status
debug_attributes("Request", client->request, 1);
- /*
- * First build an empty response message for this request...
- */
-
+ // First build an empty response message for this request...
client->operation_id = ippGetOperation(client->request);
client->response = ippNewResponse(client->request);
- /*
- * Then validate the request header and required attributes...
- */
-
+ // Then validate the request header and required attributes...
major = ippGetVersion(client->request, &minor);
if (major < 1 || major > 2)
{
- /*
- * Return an error, since we only support IPP 1.x and 2.x.
- */
-
+ // Return an error, since we only support IPP 1.x and 2.x.
respond_ipp(client, IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED, "Bad request version number %d.%d.", major, minor);
}
else if ((major * 10 + minor) > MaxVersion)
{
if (httpGetState(client->http) != HTTP_STATE_POST_SEND)
- httpFlush(client->http); /* Flush trailing (junk) data */
+ httpFlush(client->http); // Flush trailing (junk) data
respond_http(client, HTTP_STATUS_BAD_REQUEST, NULL, NULL, 0);
return (0);
{
respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "Bad request-id %d.", ippGetRequestId(client->request));
}
- else if (!ippFirstAttribute(client->request))
+ else if (!ippGetFirstAttribute(client->request))
{
respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "No attributes in request.");
}
else
{
- /*
- * Make sure that the attributes are provided in the correct order and
- * don't repeat groups...
- */
-
- for (attr = ippFirstAttribute(client->request),
- group = ippGetGroupTag(attr);
- attr;
- attr = ippNextAttribute(client->request))
+ // Make sure that the attributes are provided in the correct order and don't repeat groups...
+ for (attr = ippGetFirstAttribute(client->request), group = ippGetGroupTag(attr); attr; attr = ippGetNextAttribute(client->request))
{
if (ippGetGroupTag(attr) < group && ippGetGroupTag(attr) != IPP_TAG_ZERO)
{
- /*
- * Out of order; return an error...
- */
-
- respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST,
- "Attribute groups are out of order (%x < %x).",
- ippGetGroupTag(attr), group);
+ // Out of order; return an error...
+ respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "Attribute groups are out of order (%x < %x).", ippGetGroupTag(attr), group);
break;
}
else
+ {
group = ippGetGroupTag(attr);
+ }
}
if (!attr)
{
- /*
- * Then make sure that the first three attributes are:
- *
- * attributes-charset
- * attributes-natural-language
- * printer-uri/job-uri
- */
-
- attr = ippFirstAttribute(client->request);
+ // Then make sure that the first three attributes are:
+ //
+ // attributes-charset
+ // attributes-natural-language
+ // printer-uri/job-uri
+ attr = ippGetFirstAttribute(client->request);
name = ippGetName(attr);
- if (attr && name && !strcmp(name, "attributes-charset") &&
- ippGetValueTag(attr) == IPP_TAG_CHARSET)
+ if (attr && name && !strcmp(name, "attributes-charset") && ippGetValueTag(attr) == IPP_TAG_CHARSET)
charset = attr;
else
charset = NULL;
- attr = ippNextAttribute(client->request);
+ attr = ippGetNextAttribute(client->request);
name = ippGetName(attr);
- if (attr && name && !strcmp(name, "attributes-natural-language") &&
- ippGetValueTag(attr) == IPP_TAG_LANGUAGE)
+ if (attr && name && !strcmp(name, "attributes-natural-language") && ippGetValueTag(attr) == IPP_TAG_LANGUAGE)
language = attr;
else
language = NULL;
- if ((attr = ippFindAttribute(client->request, "printer-uri",
- IPP_TAG_URI)) != NULL)
+ if ((attr = ippFindAttribute(client->request, "printer-uri", IPP_TAG_URI)) != NULL)
uri = attr;
- else if ((attr = ippFindAttribute(client->request, "job-uri",
- IPP_TAG_URI)) != NULL)
+ else if ((attr = ippFindAttribute(client->request, "job-uri", IPP_TAG_URI)) != NULL)
uri = attr;
else
uri = NULL;
- if (charset &&
- strcasecmp(ippGetString(charset, 0, NULL), "us-ascii") &&
- strcasecmp(ippGetString(charset, 0, NULL), "utf-8"))
+ if (charset && strcasecmp(ippGetString(charset, 0, NULL), "us-ascii") && strcasecmp(ippGetString(charset, 0, NULL), "utf-8"))
{
- /*
- * Bad character set...
- */
-
- respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST,
- "Unsupported character set \"%s\".",
- ippGetString(charset, 0, NULL));
+ // Bad character set...
+ respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "Unsupported character set \"%s\".", ippGetString(charset, 0, NULL));
}
else if (!charset || !language || !uri)
{
- /*
- * Return an error, since attributes-charset,
- * attributes-natural-language, and printer-uri/job-uri are required
- * for all operations.
- */
-
- respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST,
- "Missing required attributes.");
+ // Return an error, since attributes-charset,
+ // attributes-natural-language, and printer-uri/job-uri are required
+ // for all operations.
+ respond_ipp(client, IPP_STATUS_ERROR_BAD_REQUEST, "Missing required attributes.");
}
else
{
- char scheme[32], /* URI scheme */
- userpass[32], /* Username/password in URI */
- host[256], /* Host name in URI */
- resource[256]; /* Resource path in URI */
- int port; /* Port number in URI */
+ char scheme[32], // URI scheme
+ userpass[32], // Username/password in URI
+ host[256], // Host name in URI
+ resource[256]; // Resource path in URI
+ int port; // Port number in URI
name = ippGetName(uri);
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ippGetString(uri, 0, NULL),
- scheme, sizeof(scheme),
- userpass, sizeof(userpass),
- host, sizeof(host), &port,
- resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
- respond_ipp(client, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES,
- "Bad %s value '%s'.", name, ippGetString(uri, 0, NULL));
- else if ((!strcmp(name, "job-uri") &&
- strncmp(resource, "/ipp/print/", 11)) ||
- (!strcmp(name, "printer-uri") &&
- strcmp(resource, "/ipp/print") &&
- (strcmp(resource, "/") || ippGetOperation(client->request) != IPP_OP_GET_PRINTER_ATTRIBUTES)))
- respond_ipp(client, IPP_STATUS_ERROR_NOT_FOUND, "%s %s not found.",
- name, ippGetString(uri, 0, NULL));
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ippGetString(uri, 0, NULL), scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ {
+ respond_ipp(client, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, "Bad %s value '%s'.", name, ippGetString(uri, 0, NULL));
+ }
+ else if ((!strcmp(name, "job-uri") && strncmp(resource, "/ipp/print/", 11)) || (!strcmp(name, "printer-uri") && strcmp(resource, "/ipp/print") && (strcmp(resource, "/") || ippGetOperation(client->request) != IPP_OP_GET_PRINTER_ATTRIBUTES)))
+ {
+ respond_ipp(client, IPP_STATUS_ERROR_NOT_FOUND, "%s %s not found.", name, ippGetString(uri, 0, NULL));
+ }
else if (client->operation_id != IPP_OP_GET_PRINTER_ATTRIBUTES && (status = authenticate_request(client)) != HTTP_STATUS_CONTINUE)
{
flush_document_data(client);
}
else
{
- /*
- * Handle HTTP Expect...
- */
-
+ // Handle HTTP Expect...
if (httpGetExpect(client->http))
{
if (httpGetExpect(client->http) == HTTP_STATUS_CONTINUE)
{
- /*
- * Send 100-continue header...
- */
-
+ // Send 100-continue header...
if (!respond_http(client, HTTP_STATUS_CONTINUE, NULL, NULL, 0))
return (0);
}
else
{
- /*
- * Send 417-expectation-failed header...
- */
-
+ // Send 417-expectation-failed header...
if (!respond_http(client, HTTP_STATUS_EXPECTATION_FAILED, NULL, NULL, 0))
return (0);
}
}
- /*
- * Try processing the operation...
- */
-
+ // Try processing the operation...
switch (client->operation_id)
{
case IPP_OP_PRINT_JOB :
break;
default :
- respond_ipp(client, IPP_STATUS_ERROR_OPERATION_NOT_SUPPORTED,
- "Operation not supported.");
+ respond_ipp(client, IPP_STATUS_ERROR_OPERATION_NOT_SUPPORTED, "Operation not supported.");
break;
}
}
}
}
- /*
- * Send the HTTP header and return...
- */
-
+ // Send the HTTP header and return...
if (httpGetState(client->http) != HTTP_STATE_POST_SEND)
- httpFlush(client->http); /* Flush trailing (junk) data */
+ httpFlush(client->http); // Flush trailing (junk) data
- return (respond_http(client, HTTP_STATUS_OK, NULL, "application/ipp",
- ippLength(client->response)));
+ return (respond_http(client, HTTP_STATUS_OK, NULL, "application/ipp", ippGetLength(client->response)));
}
-/*
- * 'process_job()' - Process a print job.
- */
+//
+// 'process_job()' - Process a print job.
+//
-static void * /* O - Thread exit status */
-process_job(ippeve_job_t *job) /* I - Job */
+static void * // O - Thread exit status
+process_job(ippeve_job_t *job) // I - Job
{
job->state = IPP_JSTATE_PROCESSING;
job->printer->state = IPP_PSTATE_PROCESSING;
if (job->printer->command)
{
- /*
- * Execute a command with the job spool file and wait for it to complete...
- */
-
- int pid, /* Process ID */
- status; /* Exit status */
- struct timeval start, /* Start time */
- end; /* End time */
- char *myargv[3], /* Command-line arguments */
- *myenvp[400]; /* Environment variables */
- int myenvc; /* Number of environment variables */
- ipp_attribute_t *attr; /* Job attribute */
- char val[1280], /* IPP_NAME=value */
- *valptr; /* Pointer into string */
+ // Execute a command with the job spool file and wait for it to complete...
+ int pid, // Process ID
+ status; // Exit status
+ struct timeval start, // Start time
+ end; // End time
+ char *myargv[3], // Command-line arguments
+ *myenvp[400]; // Environment variables
+ int myenvc; // Number of environment variables
+ ipp_attribute_t *attr; // Job attribute
+ char val[1280], // IPP_NAME=value
+ *valptr; // Pointer into string
#ifndef _WIN32
- int mystdout = -1; /* File for stdout */
- int mypipe[2]; /* Pipe for stderr */
- char line[2048], /* Line from stderr */
- *ptr, /* Pointer into line */
- *endptr; /* End of line */
- ssize_t bytes; /* Bytes read */
-#endif /* !_WIN32 */
+ int mystdout = -1; // File for stdout
+ int mypipe[2]; // Pipe for stderr
+ char line[2048], // Line from stderr
+ *ptr, // Pointer into line
+ *endptr; // End of line
+ ssize_t bytes; // Bytes read
+#endif // !_WIN32
fprintf(stderr, "[Job %d] Running command \"%s %s\".\n", job->id, job->printer->command, job->filename);
gettimeofday(&start, NULL);
- /*
- * Setup the command-line arguments...
- */
-
+ // Setup the command-line arguments...
myargv[0] = job->printer->command;
myargv[1] = job->filename;
myargv[2] = NULL;
- /*
- * Copy the current environment, then add environment variables for every
- * Job attribute and Printer -default attributes...
- */
-
+ // Copy the current environment, then add environment variables for every
+ // Job attribute and Printer -default attributes...
for (myenvc = 0; environ[myenvc] && myenvc < (int)(sizeof(myenvp) / sizeof(myenvp[0]) - 1); myenvc ++)
myenvp[myenvc] = strdup(environ[myenvc]);
myenvp[myenvc ++] = strdup(val);
}
-#if !CUPS_LITE
- if (job->printer->ppdfile)
- {
- snprintf(val, sizeof(val), "PPD=%s", job->printer->ppdfile);
- myenvp[myenvc++] = strdup(val);
- }
-#endif /* !CUPS_LITE */
-
- for (attr = ippFirstAttribute(job->printer->attrs); attr && myenvc < (int)(sizeof(myenvp) / sizeof(myenvp[0]) - 1); attr = ippNextAttribute(job->printer->attrs))
+ for (attr = ippGetFirstAttribute(job->printer->attrs); attr && myenvc < (int)(sizeof(myenvp) / sizeof(myenvp[0]) - 1); attr = ippGetNextAttribute(job->printer->attrs))
{
- /*
- * Convert "attribute-name-default" to "IPP_ATTRIBUTE_NAME_DEFAULT=" and
- * "pwg-xxx" to "IPP_PWG_XXX", then add the value(s) from the attribute.
- */
-
+ // Convert "attribute-name-default" to "IPP_ATTRIBUTE_NAME_DEFAULT=" and
+ // "pwg-xxx" to "IPP_PWG_XXX", then add the value(s) from the attribute.
const char *name = ippGetName(attr),
- /* Attribute name */
+ // Attribute name
*suffix = strstr(name, "-default");
- /* Suffix on attribute name */
+ // Suffix on attribute name
if (strncmp(name, "pwg-", 4) && (!suffix || suffix[8]))
continue;
myenvp[myenvc++] = strdup(val);
}
- for (attr = ippFirstAttribute(job->attrs); attr && myenvc < (int)(sizeof(myenvp) / sizeof(myenvp[0]) - 1); attr = ippNextAttribute(job->attrs))
+ for (attr = ippGetFirstAttribute(job->attrs); attr && myenvc < (int)(sizeof(myenvp) / sizeof(myenvp[0]) - 1); attr = ippGetNextAttribute(job->attrs))
{
- /*
- * Convert "attribute-name" to "IPP_ATTRIBUTE_NAME=" and then add the
- * value(s) from the attribute.
- */
-
+ // Convert "attribute-name" to "IPP_ATTRIBUTE_NAME=" and then add the
+ // value(s) from the attribute.
const char *name = ippGetName(attr);
- /* Attribute name */
+ // Attribute name
if (!name)
continue;
myenvp[myenvc] = NULL;
- /*
- * Now run the program...
- */
-
+ // Now run the program...
#ifdef _WIN32
status = _spawnvpe(_P_WAIT, job->printer->command, myargv, myenvp);
#else
if (job->printer->device_uri)
{
- char scheme[32], /* URI scheme */
- userpass[256], /* username:password (unused) */
- host[256], /* Hostname or IP address */
- resource[256]; /* Resource path */
- int port; /* Port number */
+ char scheme[32], // URI scheme
+ userpass[256], // username:password (unused)
+ host[256], // Hostname or IP address
+ resource[256]; // Resource path
+ int port; // Port number
if (httpSeparateURI(HTTP_URI_CODING_ALL, job->printer->device_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
}
else if (!strcmp(scheme, "file"))
{
- struct stat fileinfo; /* See if this is a file or directory... */
+ struct stat fileinfo; // See if this is a file or directory...
if (stat(resource, &fileinfo))
{
}
else if (!strcmp(scheme, "socket"))
{
- http_addrlist_t *addrlist; /* List of addresses */
- char service[32]; /* Service number */
+ http_addrlist_t *addrlist; // List of addresses
+ char service[32]; // Service number
snprintf(service, sizeof(service), "%d", port);
if ((pid = fork()) == 0)
{
- /*
- * Child comes here...
- */
-
+ // Child comes here...
if (mystdout >= 0)
{
- close(1);
+ close(1);
dup2(mystdout, 1);
close(mystdout);
}
if (mypipe[1] >= 0)
{
- close(2);
+ close(2);
dup2(mypipe[1], 2);
close(mypipe[0]);
close(mypipe[1]);
}
else if (pid < 0)
{
- /*
- * Unable to fork process...
- */
-
+ // Unable to fork process...
fprintf(stderr, "[Job %d] Unable to start job processing command: %s\n", job->id, strerror(errno));
status = -1;
- close(mystdout);
- close(mypipe[0]);
- close(mypipe[1]);
+ if (mystdout >= 0)
+ close(mystdout);
- /*
- * Free memory used for environment...
- */
+ if (mypipe[0] >= 0)
+ {
+ close(mypipe[0]);
+ close(mypipe[1]);
+ }
+ // Free memory used for environment...
while (myenvc > 0)
free(myenvp[-- myenvc]);
}
else
{
- /*
- * Free memory used for environment...
- */
-
+ // Free memory used for environment...
while (myenvc > 0)
free(myenvp[-- myenvc]);
- /*
- * Close the output file in the parent process...
- */
-
- close(mystdout);
-
- /*
- * If the pipe exists, read from it until EOF...
- */
+ // Close the output file in the parent process...
+ if (mystdout >= 0)
+ close(mystdout);
+ // If the pipe exists, read from it until EOF...
if (mypipe[0] >= 0)
{
close(mypipe[1]);
while ((ptr = strchr(line, '\n')) != NULL)
{
- int level = 3; /* Message log level */
+ int level = 3; // Message log level
*ptr++ = '\0';
if (!strncmp(line, "ATTR:", 5))
{
- /*
- * Process job/printer attribute updates.
- */
-
+ // Process job/printer attribute updates.
process_attr_message(job, line);
}
else if (!strncmp(line, "DEBUG:", 6))
{
- /*
- * Debug message...
- */
-
+ // Debug message...
level = 2;
}
else if (!strncmp(line, "ERROR:", 6))
{
- /*
- * Error message...
- */
-
+ // Error message...
level = 0;
job->message = strdup(line + 6);
job->msglevel = 0;
}
else if (!strncmp(line, "INFO:", 5))
{
- /*
- * Informational/progress message...
- */
-
+ // Informational/progress message...
level = 1;
if (job->msglevel)
{
}
else if (!strncmp(line, "STATE:", 6))
{
- /*
- * Process printer-state-reasons keywords.
- */
-
+ // Process printer-state-reasons keywords.
process_state_message(job, line);
}
close(mypipe[0]);
}
- /*
- * Wait for child to complete...
- */
-
+ // Wait for child to complete...
# ifdef HAVE_WAITPID
while (waitpid(pid, &status, 0) < 0);
# else
while (wait(&status) < 0);
-# endif /* HAVE_WAITPID */
+# endif // HAVE_WAITPID
}
-#endif /* _WIN32 */
+#endif // _WIN32
if (status)
{
#ifndef _WIN32
if (WIFEXITED(status))
-#endif /* !_WIN32 */
+#endif // !_WIN32
fprintf(stderr, "[Job %d] Command \"%s\" exited with status %d.\n", job->id, job->printer->command, WEXITSTATUS(status));
#ifndef _WIN32
else
fprintf(stderr, "[Job %d] Command \"%s\" terminated with signal %d.\n", job->id, job->printer->command, WTERMSIG(status));
-#endif /* !_WIN32 */
+#endif // !_WIN32
job->state = IPP_JSTATE_ABORTED;
}
else
+ {
fprintf(stderr, "[Job %d] Command \"%s\" completed successfully.\n", job->id, job->printer->command);
+ }
- /*
- * Report the total processing time...
- */
-
+ // Report the total processing time...
gettimeofday(&end, NULL);
fprintf(stderr, "[Job %d] Processing time was %.3f seconds.\n", job->id, end.tv_sec - start.tv_sec + 0.000001 * (end.tv_usec - start.tv_usec));
}
else
{
- /*
- * Sleep for a random amount of time to simulate job processing.
- */
-
- sleep((unsigned)(5 + (CUPS_RAND() % 11)));
+ // Sleep for a random amount of time to simulate job processing.
+ sleep((unsigned)(5 + (cupsGetRand() % 11)));
}
if (job->cancel)
}
-/*
- * 'process_state_message()' - Process a STATE: message from a command.
- */
+//
+// 'process_state_message()' - Process a STATE: message from a command.
+//
static void
process_state_message(
- ippeve_job_t *job, /* I - Job */
- char *message) /* I - Message */
+ ippeve_job_t *job, // I - Job
+ char *message) // I - Message
{
- int i; /* Looping var */
- ippeve_preason_t state_reasons, /* printer-state-reasons values */
- bit; /* Current reason bit */
- char *ptr, /* Pointer into message */
- *next; /* Next keyword in message */
- int remove; /* Non-zero if we are removing keywords */
+ int i; // Looping var
+ ippeve_preason_t state_reasons, // printer-state-reasons values
+ bit; // Current reason bit
+ char *ptr, // Pointer into message
+ *next; // Next keyword in message
+ int remove; // Non-zero if we are removing keywords
- /*
- * Skip leading "STATE:" and any whitespace...
- */
-
+ // Skip leading "STATE:" and any whitespace...
for (message += 6; *message; message ++)
+ {
if (*message != ' ' && *message != '\t')
break;
+ }
- /*
- * Support the following forms of message:
- *
- * "keyword[,keyword,...]" to set the printer-state-reasons value(s).
- *
- * "-keyword[,keyword,...]" to remove keywords.
- *
- * "+keyword[,keyword,...]" to add keywords.
- *
- * Keywords may or may not have a suffix (-report, -warning, -error) per
- * RFC 8011.
- */
-
+ // Support the following forms of message:
+ //
+ // "keyword[,keyword,...]" to set the printer-state-reasons value(s).
+ //
+ // "-keyword[,keyword,...]" to remove keywords.
+ //
+ // "+keyword[,keyword,...]" to add keywords.
+ //
+ // Keywords may or may not have a suffix (-report, -warning, -error) per
+ // RFC 8011.
if (*message == '-')
{
remove = 1;
}
-/*
- * 'register_printer()' - Register a printer object via DNS-SD.
- */
+//
+// 'register_printer()' - Register a printer object via DNS-SD.
+//
-static int /* O - 1 on success, 0 on error */
+static bool // O - `true` on success, `false` on error
register_printer(
- ippeve_printer_t *printer) /* I - Printer */
+ ippeve_printer_t *printer) // I - Printer
{
-#ifdef HAVE_DNSSD
- ippeve_txt_t ipp_txt; /* DNS-SD IPP TXT record */
- int i, /* Looping var */
- count; /* Number of values */
+ int num_txt; // Number of DNS-SD IPP TXT key/value pairs
+ cups_option_t *txt; // DNS-SD IPP TXT key/value pairs
+ uint32_t if_index; // Interface index
+ int i, // Looping var
+ count; // Number of values
ipp_attribute_t *color_supported,
*document_format_supported,
*printer_location,
*printer_make_and_model,
*printer_uuid,
*sides_supported,
- *urf_supported; /* Printer attributes */
- const char *value; /* Value string */
- char adminurl[247], /* adminurl value */
- formats[252], /* List of supported formats */
- urf[252], /* List of supported URF values */
- *ptr; /* Pointer into string */
+ *urf_supported; // Printer attributes
+ const char *value; // Value string
+ char regtype[256], // Registration types
+ adminurl[247], // adminurl value
+ formats[252], // List of supported formats
+ urf[252], // List of supported URF values
+ *ptr; // Pointer into string
if (printer->dnssd_subtypes && !strcmp(printer->dnssd_subtypes, "off"))
- return (1);
+ return (true);
color_supported = ippFindAttribute(printer->attrs, "color-supported", IPP_TAG_BOOLEAN);
document_format_supported = ippFindAttribute(printer->attrs, "document-format-supported", IPP_TAG_MIMETYPE);
break;
}
- /*
- * Rename the service as needed...
- */
-
+ // Rename the service as needed...
if (printer->dnssd_collision)
{
- char new_dnssd_name[256]; /* New DNS-SD name */
+ char new_dnssd_name[256]; // New DNS-SD name
const char *uuid = ippGetString(printer_uuid, 0, NULL);
- /* "printer-uuid" value */
+ // "printer-uuid" value
cupsRWLockWrite(&printer->rwlock);
printer->dnssd_collision = 0;
}
-#endif /* HAVE_DNSSD */
-
-#ifdef HAVE_MDNSRESPONDER
- DNSServiceErrorType error; /* Error from DNS-SD */
- char regtype[256]; /* DNS-SD service type */
- uint32_t ifindex; /* Interface index */
-
- /*
- * Build the TXT record for IPP...
- */
-
- TXTRecordCreate(&ipp_txt, 1024, NULL);
- TXTRecordSetValue(&ipp_txt, "rp", 9, "ipp/print");
+ // Build the TXT record for IPP...
+ num_txt = cupsAddOption("rp", "ipp/print", 0, &txt);
if ((value = ippGetString(printer_make_and_model, 0, NULL)) != NULL)
- TXTRecordSetValue(&ipp_txt, "ty", (uint8_t)strlen(value), value);
- TXTRecordSetValue(&ipp_txt, "adminurl", (uint8_t)strlen(adminurl), adminurl);
+ num_txt = cupsAddOption("ty", value, num_txt, &txt);
+ num_txt = cupsAddOption("adminurl", adminurl, num_txt, &txt);
if ((value = ippGetString(printer_location, 0, NULL)) != NULL)
- TXTRecordSetValue(&ipp_txt, "note", (uint8_t)strlen(value), value);
- TXTRecordSetValue(&ipp_txt, "pdl", (uint8_t)strlen(formats), formats);
- TXTRecordSetValue(&ipp_txt, "Color", 1, ippGetBoolean(color_supported, 0) ? "T" : "F");
- TXTRecordSetValue(&ipp_txt, "Duplex", 1, ippGetCount(sides_supported) > 1 ? "T" : "F");
+ num_txt = cupsAddOption("note", value, num_txt, &txt);
+ num_txt = cupsAddOption("pdl", formats, num_txt, &txt);
+ num_txt = cupsAddOption("Color", ippGetBoolean(color_supported, 0) ? "T" : "F", num_txt, &txt);
+ num_txt = cupsAddOption("Duplex", ippGetCount(sides_supported) > 1 ? "T" : "F", num_txt, &txt);
if ((value = ippGetString(printer_uuid, 0, NULL)) != NULL)
- TXTRecordSetValue(&ipp_txt, "UUID", (uint8_t)strlen(value) - 9, value + 9);
- TXTRecordSetValue(&ipp_txt, "TLS", 3, "1.3");
+ num_txt = cupsAddOption("UUID", value + 9, num_txt, &txt);
+ num_txt = cupsAddOption("TLS", "1.3", num_txt, &txt);
if (urf[0])
- TXTRecordSetValue(&ipp_txt, "URF", (uint8_t)strlen(urf), urf);
- TXTRecordSetValue(&ipp_txt, "txtvers", 1, "1");
- TXTRecordSetValue(&ipp_txt, "qtotal", 1, "1");
-
- /*
- * Register the _printer._tcp (LPD) service type with a port number of 0 to
- * defend our service name but not actually support LPD...
- */
-
- ifindex = !strcmp(printer->hostname, "localhost") ? kDNSServiceInterfaceIndexLocalOnly : kDNSServiceInterfaceIndexAny;
-
- if (printer->printer_ref)
- DNSServiceRefDeallocate(printer->printer_ref);
-
- printer->printer_ref = DNSSDMaster;
-
- if ((error = DNSServiceRegister(&(printer->printer_ref), kDNSServiceFlagsShareConnection | kDNSServiceFlagsNoAutoRename, ifindex, printer->dnssd_name, "_printer._tcp", NULL /* domain */, NULL /* host */, 0 /* port */, 0 /* txtLen */, NULL /* txtRecord */, (DNSServiceRegisterReply)dnssd_callback, printer)) != kDNSServiceErr_NoError)
- {
- _cupsLangPrintf(stderr, _("Unable to register \"%s.%s\": %d"), printer->dnssd_name, "_printer._tcp", error);
- return (0);
- }
+ num_txt = cupsAddOption("URF", urf, num_txt, &txt);
+ num_txt = cupsAddOption("txtvers", "1", num_txt, &txt);
+ num_txt = cupsAddOption("qtotal", "1", num_txt, &txt);
- /*
- * Then register the _ipp._tcp (IPP) service type with the real port number to
- * advertise our IPP printer...
- */
+ // Register the _printer._tcp (LPD) service type with a port number of 0 to
+ // defend our service name but not actually support LPD...
+ if_index = !strcmp(printer->hostname, "localhost") ? CUPS_DNSSD_IF_INDEX_LOCAL : CUPS_DNSSD_IF_INDEX_ANY;
- if (printer->ipp_ref)
- DNSServiceRefDeallocate(printer->ipp_ref);
+ cupsDNSSDServiceDelete(printer->services);
+ if ((printer->services = cupsDNSSDServiceNew(printer->dnssd, if_index, printer->dnssd_name, (cups_dnssd_service_cb_t)dnssd_callback, printer)) == NULL)
+ goto error;
- printer->ipp_ref = DNSSDMaster;
+ if (!cupsDNSSDServiceAdd(printer->services, "_printer._tcp", /*domain*/NULL, printer->hostname, /*port*/0, /*num_txt*/0, /*txt*/NULL))
+ goto error;
+ // Then register the _ipp._tcp (IPP) service type with the real port number to
+ // advertise our IPP printer...
if (printer->dnssd_subtypes && *(printer->dnssd_subtypes))
snprintf(regtype, sizeof(regtype), "_ipp._tcp,%s", printer->dnssd_subtypes);
else
cupsCopyString(regtype, "_ipp._tcp", sizeof(regtype));
- if ((error = DNSServiceRegister(&(printer->ipp_ref), kDNSServiceFlagsShareConnection | kDNSServiceFlagsNoAutoRename, ifindex, printer->dnssd_name, regtype, NULL /* domain */, NULL /* host */, htons(printer->port), TXTRecordGetLength(&ipp_txt), TXTRecordGetBytesPtr(&ipp_txt), (DNSServiceRegisterReply)dnssd_callback, printer)) != kDNSServiceErr_NoError)
- {
- _cupsLangPrintf(stderr, _("Unable to register \"%s.%s\": %d"), printer->dnssd_name, regtype, error);
- return (0);
- }
-
- /*
- * Then register the _ipps._tcp (IPP) service type with the real port number to
- * advertise our IPPS printer...
- */
-
- if (printer->ipps_ref)
- DNSServiceRefDeallocate(printer->ipps_ref);
-
- printer->ipps_ref = DNSSDMaster;
+ if (!cupsDNSSDServiceAdd(printer->services, regtype, /*domain*/NULL, printer->hostname, (uint16_t)printer->port, num_txt, txt))
+ goto error;
+ // Then register the _ipps._tcp (IPP) service type with the real port number
+ // to advertise our IPPS printer...
if (printer->dnssd_subtypes && *(printer->dnssd_subtypes))
snprintf(regtype, sizeof(regtype), "_ipps._tcp,%s", printer->dnssd_subtypes);
else
cupsCopyString(regtype, "_ipps._tcp", sizeof(regtype));
- if ((error = DNSServiceRegister(&(printer->ipps_ref), kDNSServiceFlagsShareConnection | kDNSServiceFlagsNoAutoRename, ifindex, printer->dnssd_name, regtype, NULL /* domain */, NULL /* host */, htons(printer->port), TXTRecordGetLength(&ipp_txt), TXTRecordGetBytesPtr(&ipp_txt), (DNSServiceRegisterReply)dnssd_callback, printer)) != kDNSServiceErr_NoError)
- {
- _cupsLangPrintf(stderr, _("Unable to register \"%s.%s\": %d"), printer->dnssd_name, regtype, error);
- return (0);
- }
-
- /*
- * Similarly, register the _http._tcp,_printer (HTTP) service type with the
- * real port number to advertise our IPP printer...
- */
-
- if (printer->http_ref)
- DNSServiceRefDeallocate(printer->http_ref);
-
- printer->http_ref = DNSSDMaster;
-
- if ((error = DNSServiceRegister(&(printer->http_ref), kDNSServiceFlagsShareConnection | kDNSServiceFlagsNoAutoRename, ifindex, printer->dnssd_name, "_http._tcp,_printer", NULL /* domain */, NULL /* host */, htons(printer->port), 0 /* txtLen */, NULL /* txtRecord */, (DNSServiceRegisterReply)dnssd_callback, printer)) != kDNSServiceErr_NoError)
- {
- _cupsLangPrintf(stderr, _("Unable to register \"%s.%s\": %d"), printer->dnssd_name, "_http._tcp,_printer", error);
- return (0);
- }
-
- TXTRecordDeallocate(&ipp_txt);
-
-#elif defined(HAVE_AVAHI)
- char temp[256]; /* Subtype service string */
-
- /*
- * Create the TXT record...
- */
-
- ipp_txt = NULL;
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "rp=ipp/print");
- if ((value = ippGetString(printer_make_and_model, 0, NULL)) != NULL)
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "ty=%s", value);
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "adminurl=%s", adminurl);
- if ((value = ippGetString(printer_location, 0, NULL)) != NULL)
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "note=%s", value);
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "pdl=%s", formats);
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "Color=%s", ippGetBoolean(color_supported, 0) ? "T" : "F");
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "Duplex=%s", ippGetCount(sides_supported) > 1 ? "T" : "F");
- if ((value = ippGetString(printer_uuid, 0, NULL)) != NULL)
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "UUID=%s", value + 9);
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "TLS=1.2");
- if (urf[0])
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "URF=%s", urf);
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "txtvers=1");
- ipp_txt = avahi_string_list_add_printf(ipp_txt, "qtotal=1");
-
- /*
- * Register _printer._tcp (LPD) with port 0 to reserve the service name...
- */
-
- avahi_threaded_poll_lock(DNSSDMaster);
-
- if (printer->dnssd_ref)
- avahi_entry_group_free(printer->dnssd_ref);
-
- printer->dnssd_ref = avahi_entry_group_new(DNSSDClient, dnssd_callback, printer);
-
- avahi_entry_group_add_service_strlst(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_printer._tcp", NULL, NULL, 0, NULL);
-
- /*
- * Then register the _ipp._tcp (IPP)...
- */
-
- avahi_entry_group_add_service_strlst(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_ipp._tcp", NULL, NULL, printer->port, ipp_txt);
- if (printer->dnssd_subtypes && *(printer->dnssd_subtypes))
- {
- char *temptypes = strdup(printer->dnssd_subtypes), *start, *end;
-
- for (start = temptypes; *start; start = end)
- {
- if ((end = strchr(start, ',')) != NULL)
- *end++ = '\0';
- else
- end = start + strlen(start);
-
- snprintf(temp, sizeof(temp), "%s._sub._ipp._tcp", start);
- avahi_entry_group_add_service_subtype(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_ipp._tcp", NULL, temp);
- }
-
- free(temptypes);
- }
-
- /*
- * _ipps._tcp (IPPS) for secure printing...
- */
-
- avahi_entry_group_add_service_strlst(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_ipps._tcp", NULL, NULL, printer->port, ipp_txt);
- if (printer->dnssd_subtypes && *(printer->dnssd_subtypes))
- {
- char *temptypes = strdup(printer->dnssd_subtypes), *start, *end;
-
- for (start = temptypes; *start; start = end)
- {
- if ((end = strchr(start, ',')) != NULL)
- *end++ = '\0';
- else
- end = start + strlen(start);
+ if (!cupsDNSSDServiceAdd(printer->services, regtype, /*domain*/NULL, printer->hostname, (uint16_t)printer->port, num_txt, txt))
+ goto error;
- snprintf(temp, sizeof(temp), "%s._sub._ipps._tcp", start);
- avahi_entry_group_add_service_subtype(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_ipps._tcp", NULL, temp);
- }
-
- free(temptypes);
- }
-
- /*
- * Finally _http.tcp (HTTP) for the web interface...
- */
+ // Similarly, register the _http._tcp,_printer (HTTP) service type with the
+ // real port number to advertise our IPP printer's web interface...
+ if (!cupsDNSSDServiceAdd(printer->services, "_http._tcp,_printer", /*domain*/NULL, printer->hostname, (uint16_t)printer->port, num_txt, txt))
+ goto error;
- avahi_entry_group_add_service_strlst(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_http._tcp", NULL, NULL, printer->port, NULL);
- avahi_entry_group_add_service_subtype(printer->dnssd_ref, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, printer->dnssd_name, "_http._tcp", NULL, "_printer._sub._http._tcp");
+ cupsFreeOptions(num_txt, txt);
- /*
- * Commit it...
- */
+ // Commit it...
+ return (cupsDNSSDServicePublish(printer->services));
- avahi_entry_group_commit(printer->dnssd_ref);
- avahi_threaded_poll_unlock(DNSSDMaster);
-
- avahi_string_list_free(ipp_txt);
-#endif /* HAVE_MDNSRESPONDER */
+ // If we get here there was a problem...
+ error:
- return (1);
+ cupsFreeOptions(num_txt, txt);
+ return (false);
}
-/*
- * 'respond_http()' - Send a HTTP response.
- */
+//
+// 'respond_http()' - Send a HTTP response.
+//
-int /* O - 1 on success, 0 on failure */
+bool // O - `true` on success, `false` on failure
respond_http(
- ippeve_client_t *client, /* I - Client */
- http_status_t code, /* I - HTTP status of response */
- const char *content_encoding, /* I - Content-Encoding of response */
- const char *type, /* I - MIME media type of response */
- size_t length) /* I - Length of response */
+ ippeve_client_t *client, // I - Client
+ http_status_t code, // I - HTTP status of response
+ const char *content_encoding, // I - Content-Encoding of response
+ const char *type, // I - MIME media type of response
+ size_t length) // I - Length of response
{
- char message[1024]; /* Text message */
+ char message[1024]; // Text message
- fprintf(stderr, "%s %s\n", client->hostname, httpStatus(code));
+ fprintf(stderr, "%s %s\n", client->hostname, httpStatusString(code));
if (code == HTTP_STATUS_CONTINUE)
{
- /*
- * 100-continue doesn't send any headers...
- */
-
- return (httpWriteResponse(client->http, HTTP_STATUS_CONTINUE) == 0);
+ // 100-continue doesn't send any headers...
+ return (httpWriteResponse(client->http, HTTP_STATUS_CONTINUE));
}
- /*
- * Format an error message...
- */
-
+ // Format an error message...
if (!type && !length && code != HTTP_STATUS_OK && code != HTTP_STATUS_SWITCHING_PROTOCOLS)
{
- snprintf(message, sizeof(message), "%d - %s\n", code, httpStatus(code));
+ snprintf(message, sizeof(message), "%d - %s\n", code, httpStatusString(code));
type = "text/plain";
length = strlen(message);
else
message[0] = '\0';
- /*
- * Send the HTTP response header...
- */
-
+ // Send the HTTP response header...
httpClearFields(client->http);
- if (code == HTTP_STATUS_METHOD_NOT_ALLOWED ||
- client->operation == HTTP_STATE_OPTIONS)
+ if (code == HTTP_STATUS_METHOD_NOT_ALLOWED || client->operation == HTTP_STATE_OPTIONS)
httpSetField(client->http, HTTP_FIELD_ALLOW, "GET, HEAD, OPTIONS, POST");
if (code == HTTP_STATUS_UNAUTHORIZED)
{
- char value[256]; /* WWW-Authenticate value */
+ char value[256]; // WWW-Authenticate value
snprintf(value, sizeof(value), "Basic realm=\"%s\"", PAMService);
httpSetField(client->http, HTTP_FIELD_WWW_AUTHENTICATE, value);
if (type)
{
if (!strcmp(type, "text/html"))
- httpSetField(client->http, HTTP_FIELD_CONTENT_TYPE,
- "text/html; charset=utf-8");
+ httpSetField(client->http, HTTP_FIELD_CONTENT_TYPE, "text/html; charset=utf-8");
else
httpSetField(client->http, HTTP_FIELD_CONTENT_TYPE, type);
httpSetLength(client->http, length);
- if (httpWriteResponse(client->http, code) < 0)
- return (0);
-
- /*
- * Send the response data...
- */
+ if (!httpWriteResponse(client->http, code))
+ return (false);
+ // Send the response data...
if (message[0])
{
- /*
- * Send a plain text message.
- */
-
+ // Send a plain text message.
if (httpPrintf(client->http, "%s", message) < 0)
- return (0);
+ return (false);
- if (httpWrite2(client->http, "", 0) < 0)
- return (0);
+ if (httpWrite(client->http, "", 0) < 0)
+ return (false);
}
else if (client->response)
{
- /*
- * Send an IPP response...
- */
-
+ // Send an IPP response...
debug_attributes("Response", client->response, 2);
ippSetState(client->response, IPP_STATE_IDLE);
if (ippWrite(client->http, client->response) != IPP_STATE_DATA)
- return (0);
+ return (false);
}
- return (1);
+ return (true);
}
-/*
- * 'respond_ignored()' - Respond with an ignored attribute.
- */
+//
+// 'respond_ignored()' - Respond with an ignored attribute.
+//
static void
respond_ignored(
- ippeve_client_t *client, /* I - Client */
- ipp_attribute_t *attr) /* I - Attribute */
+ ippeve_client_t *client, // I - Client
+ ipp_attribute_t *attr) // I - Attribute
{
- ipp_attribute_t *temp; /* Copy of attribute */
+ ipp_attribute_t *temp; // Copy of attribute
if (!ippGetStatusCode(client->response))
}
-/*
- * 'respond_ipp()' - Send an IPP response.
- */
+//
+// 'respond_ipp()' - Send an IPP response.
+//
static void
-respond_ipp(ippeve_client_t *client, /* I - Client */
- ipp_status_t status, /* I - status-code */
- const char *message, /* I - printf-style status-message */
- ...) /* I - Additional args as needed */
+respond_ipp(ippeve_client_t *client, // I - Client
+ ipp_status_t status, // I - status-code
+ const char *message, // I - printf-style status-message
+ ...) // I - Additional args as needed
{
- const char *formatted = NULL; /* Formatted message */
+ const char *formatted = NULL; // Formatted message
ippSetStatusCode(client->response, status);
if (message)
{
- va_list ap; /* Pointer to additional args */
- ipp_attribute_t *attr; /* New status-message attribute */
+ va_list ap; // Pointer to additional args
+ ipp_attribute_t *attr; // New status-message attribute
va_start(ap, message);
if ((attr = ippFindAttribute(client->response, "status-message", IPP_TAG_TEXT)) != NULL)
}
-/*
- * 'respond_unsupported()' - Respond with an unsupported attribute.
- */
+//
+// 'respond_unsupported()' - Respond with an unsupported attribute.
+//
static void
respond_unsupported(
- ippeve_client_t *client, /* I - Client */
- ipp_attribute_t *attr) /* I - Attribute */
+ ippeve_client_t *client, // I - Client
+ ipp_attribute_t *attr) // I - Atribute
{
- ipp_attribute_t *temp; /* Copy of attribute */
+ ipp_attribute_t *temp; // Copy of attribute
respond_ipp(client, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, "Unsupported %s %s%s value.", ippGetName(attr), ippGetCount(attr) > 1 ? "1setOf " : "", ippTagString(ippGetValueTag(attr)));
}
-/*
- * 'run_printer()' - Run the printer service.
- */
+//
+// 'run_printer()' - Run the printer service.
+//
static void
-run_printer(ippeve_printer_t *printer) /* I - Printer */
+run_printer(ippeve_printer_t *printer) // I - Printer
{
- int num_fds; /* Number of file descriptors */
- struct pollfd polldata[3]; /* poll() data */
- ippeve_client_t *client; /* New client */
+ int num_fds; // Number of file descriptors
+ struct pollfd polldata[3]; // poll() data
+ ippeve_client_t *client; // New client
#ifndef _WIN32
- /*
- * Set signal handlers for SIGINT and SIGTERM...
- */
-
+ // Set signal handlers for SIGINT and SIGTERM...
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
#endif // !_WIN32
- /*
- * Setup poll() data for the DNS-SD service socket and IPv4/6 listeners...
- */
-
+ // Setup poll() data for the DNS-SD service socket and IPv4/6 listeners...
polldata[0].fd = printer->ipv4;
polldata[0].events = POLLIN;
num_fds = 2;
-#ifdef HAVE_MDNSRESPONDER
- polldata[num_fds ].fd = DNSServiceRefSockFD(DNSSDMaster);
- polldata[num_fds ++].events = POLLIN;
-#endif /* HAVE_MDNSRESPONDER */
-
- /*
- * Loop until we are killed or have a hard error...
- */
-
+ // Loop until we are killed or have a hard error...
for (;;)
{
if (poll(polldata, (nfds_t)num_fds, 1000) < 0 && errno != EINTR)
}
}
- /*
- * Process DNS-SD messages...
- */
-
-#ifdef HAVE_MDNSRESPONDER
- if (polldata[2].revents & POLLIN)
- DNSServiceProcessResult(DNSSDMaster);
-#endif /* HAVE_MDNSRESPONDER */
-
-#ifdef HAVE_DNSSD
if (printer->dnssd_collision)
register_printer(printer);
-#endif /* HAVE_DNSSD */
-
- /*
- * Clean out old jobs...
- */
+ // Clean out old jobs...
clean_jobs(printer);
}
}
-/*
- * 'show_media()' - Show media load state.
- */
+//
+// 'show_media()' - Show media load state.
+//
-static int /* O - 1 on success, 0 on failure */
-show_media(ippeve_client_t *client) /* I - Client connection */
+static int // O - 1 on success, 0 on failure
+show_media(ippeve_client_t *client) // I - Client connection
{
ippeve_printer_t *printer = client->printer;
- /* Printer */
- int i, j, /* Looping vars */
- num_ready, /* Number of ready media */
- num_sizes, /* Number of media sizes */
- num_sources, /* Number of media sources */
- num_types; /* Number of media types */
- ipp_attribute_t *media_col_ready,/* media-col-ready attribute */
- *media_ready, /* media-ready attribute */
- *media_sizes, /* media-supported attribute */
- *media_sources, /* media-source-supported attribute */
- *media_types, /* media-type-supported attribute */
- *input_tray; /* printer-input-tray attribute */
- ipp_t *media_col; /* media-col value */
- const char *media_size, /* media value */
- *media_source, /* media-source value */
- *media_type, /* media-type value */
- *ready_size, /* media-col-ready media-size[-name] value */
- *ready_source, /* media-col-ready media-source value */
- *ready_tray, /* printer-input-tray value */
- *ready_type; /* media-col-ready media-type value */
- char tray_str[1024], /* printer-input-tray string value */
- *tray_ptr; /* Pointer into value */
- int tray_len; /* Length of printer-input-tray value */
- int ready_sheets; /* printer-input-tray sheets value */
- int num_options = 0;/* Number of form options */
- cups_option_t *options = NULL;/* Form options */
- static const int sheets[] = /* Number of sheets */
+ // Printer
+ int i, j, // Looping vars
+ num_ready, // Number of ready media
+ num_sizes, // Number of media sizes
+ num_sources, // Number of media sources
+ num_types; // Number of media types
+ ipp_attribute_t *media_col_ready,// media-col-ready attribute
+ *media_ready, // media-ready attribute
+ *media_sizes, // media-supported attribute
+ *media_sources, // media-source-supported attribute
+ *media_types, // media-type-supported attribute
+ *input_tray; // printer-input-tray attribute
+ ipp_t *media_col; // media-col value
+ const char *media_size, // media value
+ *media_source, // media-source value
+ *media_type, // media-type value
+ *ready_size, // media-col-ready media-size[-name] value
+ *ready_source, // media-col-ready media-source value
+ *ready_tray, // printer-input-tray value
+ *ready_type; // media-col-ready media-type value
+ char tray_str[1024], // printer-input-tray string value
+ *tray_ptr; // Pointer into value
+ int tray_len; // Length of printer-input-tray value
+ int ready_sheets; // printer-input-tray sheets value
+ int num_options = 0;// Number of form options
+ cups_option_t *options = NULL;// Form options
+ static const int sheets[] = // Number of sheets
{
250,
125,
return (1);
}
+ num_ready = ippGetCount(media_col_ready);
+ num_sizes = ippGetCount(media_sizes);
num_sources = ippGetCount(media_sources);
-
- /*
- * Make sure the number of trays is consistent.
- */
+ num_types = ippGetCount(media_types);
if (num_sources != ippGetCount(input_tray))
{
return (1);
}
- num_ready = ippGetCount(media_col_ready);
- num_sizes = ippGetCount(media_sizes);
- num_types = ippGetCount(media_types);
-
- /*
- * Process form data if present...
- */
-
+ // Process form data if present...
if (printer->web_forms)
num_options = parse_options(client, &options);
if (num_options > 0)
{
- /*
- * WARNING: A real printer/server implementation MUST NOT implement
- * media updates via a GET request - GET requests are supposed to be
- * idempotent (without side-effects) and we obviously are not
- * authenticating access here. This form is provided solely to
- * enable testing and development!
- */
-
- char name[255]; /* Form name */
- const char *val; /* Form value */
- pwg_media_t *media; /* Media info */
+ // WARNING: A real printer/server implementation MUST NOT implement
+ // media updates via a GET request - GET requests are supposed to be
+ // idempotent (without side-effects) and we obviously are not
+ // authenticating access here. This form is provided solely to
+ // enable testing and development!
+ char name[255]; // Form name
+ const char *val; // Form value
+ pwg_media_t *media; // Media info
cupsRWLockWrite(&printer->rwlock);
if (!strcmp(media_source, "auto") || !strcmp(media_source, "manual") || strstr(media_source, "-man") != NULL)
continue;
- snprintf(name, sizeof(name), "size%d", i);
+ snprintf(name, sizeof(name), "size%u", (unsigned)i);
if ((media_size = cupsGetOption(name, num_options, options)) != NULL && (media = pwgMediaForPWG(media_size)) != NULL)
{
- snprintf(name, sizeof(name), "type%d", i);
+ snprintf(name, sizeof(name), "type%u", (unsigned)i);
if ((media_type = cupsGetOption(name, num_options, options)) != NULL && !*media_type)
media_type = NULL;
else
media_ready = ippAddString(printer->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "media-ready", NULL, media_size);
- media_col = create_media_col(media_size, media_source, media_type, media->width, media->length, -1, -1, -1, -1);
+ media_col = create_media_col(media_size, media_source, media_type, create_media_size(media->width, media->length), -1, -1, -1, -1);
if (media_col_ready)
ippSetCollection(printer->attrs, &media_col_ready, ippGetCount(media_col_ready), media_col);
else
media = NULL;
- snprintf(name, sizeof(name), "level%d", i);
+ snprintf(name, sizeof(name), "level%u", (unsigned)i);
if ((val = cupsGetOption(name, num_options, options)) != NULL)
ready_sheets = atoi(val);
else
ready_sheets = 0;
- snprintf(tray_str, sizeof(tray_str), "type=sheetFeedAuto%sRemovableTray;mediafeed=%d;mediaxfeed=%d;maxcapacity=%d;level=%d;status=0;name=%s;", !strcmp(media_source, "by-pass-tray") ? "Non" : "", media ? media->length : 0, media ? media->width : 0, strcmp(media_source, "by-pass-tray") ? 250 : 25, ready_sheets, media_source);
+ if (!strcmp(media_source, "roll"))
+ snprintf(tray_str, sizeof(tray_str), "type=continuousRoll;mediafeed=%d;mediaxfeed=%d;maxcapacity=%d;level=%d;status=0;name=%s;", media ? media->length : 0, media ? media->width : 0, 100, ready_sheets, media_source);
+ else
+ snprintf(tray_str, sizeof(tray_str), "type=sheetFeedAuto%sRemovableTray;mediafeed=%d;mediaxfeed=%d;maxcapacity=%d;level=%d;status=0;name=%s;", !strcmp(media_source, "by-pass-tray") ? "Non" : "", media ? media->length : 0, media ? media->width : 0, strcmp(media_source, "by-pass-tray") ? 250 : 25, ready_sheets, media_source);
- ippSetOctetString(printer->attrs, &input_tray, i, tray_str, (int)strlen(tray_str));
+ ippSetOctetString(printer->attrs, &input_tray, i, tray_str, strlen(tray_str));
if (ready_sheets == 0)
{
ready_source = ippGetString(ippFindAttribute(media_col, "media-source", IPP_TAG_ZERO), 0, NULL);
ready_type = ippGetString(ippFindAttribute(media_col, "media-type", IPP_TAG_ZERO), 0, NULL);
+ if (!ready_size)
+ ready_size = ippGetString(media_ready, j, NULL);
+
if (ready_source && !strcmp(ready_source, media_source))
break;
- ready_source = NULL;
- ready_size = NULL;
- ready_type = NULL;
+ ready_size = NULL;
+ ready_type = NULL;
}
html_printf(client, "<tr><th>%s:</th>", media_source);
- /*
- * Media size...
- */
-
+ // Media size...
if (printer->web_forms)
{
- html_printf(client, "<td><select name=\"size%d\"><option value=\"\">None</option>", i);
+ html_printf(client, "<td><select name=\"size%u\"><option value=\"\">None</option>", (unsigned)i);
+ if (ready_size)
+ html_printf(client, "<option selected>%s</option>", ready_size);
for (j = 0; j < num_sizes; j ++)
{
media_size = ippGetString(media_sizes, j, NULL);
- html_printf(client, "<option%s>%s</option>", (ready_size && !strcmp(ready_size, media_size)) ? " selected" : "", media_size);
+ html_printf(client, "<option>%s</option>", media_size);
}
html_printf(client, "</select>");
}
else
html_printf(client, "<td>%s", ready_size);
- /*
- * Media type...
- */
-
+ // Media type...
if (printer->web_forms)
{
- html_printf(client, " <select name=\"type%d\"><option value=\"\">None</option>", i);
+ html_printf(client, " <select name=\"type%u\"><option value=\"\">None</option>", (unsigned)i);
+ if (ready_type)
+ html_printf(client, "<option selected>%s</option>", ready_type);
for (j = 0; j < num_types; j ++)
{
media_type = ippGetString(media_types, j, NULL);
else if (ready_type)
html_printf(client, ", %s", ready_type);
- /*
- * Level/sheets loaded...
- */
-
+ // Level/sheets loaded...
if ((ready_tray = ippGetOctetString(input_tray, i, &tray_len)) != NULL)
{
if (tray_len > (int)(sizeof(tray_str) - 1))
if (printer->web_forms)
{
- html_printf(client, " <select name=\"level%d\">", i);
+ html_printf(client, " <select name=\"level%u\">", (unsigned)i);
for (j = 0; j < (int)(sizeof(sheets) / sizeof(sheets[0])); j ++)
{
if (!strcmp(media_source, "by-pass-tray") && sheets[j] > 25)
}
-/*
- * 'show_status()' - Show printer/system state.
- */
+//
+// 'show_status()' - Show printer/system state.
+//
-static int /* O - 1 on success, 0 on failure */
-show_status(ippeve_client_t *client) /* I - Client connection */
+static int // O - 1 on success, 0 on failure
+show_status(ippeve_client_t *client) // I - Client connection
{
ippeve_printer_t *printer = client->printer;
- /* Printer */
- ippeve_job_t *job; /* Current job */
- int i; /* Looping var */
- ippeve_preason_t reason; /* Current reason */
- static const char * const reasons[] = /* Reason strings */
+ // Printer
+ ippeve_job_t *job; // Current job
+ size_t i; // Looping var
+ ippeve_preason_t reason; // Current reason
+ static const char * const reasons[] = // Reason strings
{
"Other",
"Cover Open",
"Toner Low"
};
static const char * const state_colors[] =
- { /* State colors */
- "#0C0", /* Idle */
- "#EE0", /* Processing */
- "#C00" /* Stopped */
+ { // State colors
+ "#0C0", // Idle
+ "#EE0", // Processing
+ "#C00" // Stopped
};
html_header(client, printer->name, printer->state == IPP_PSTATE_PROCESSING ? 5 : 15);
html_printf(client, "<h1><img style=\"background: %s; border-radius: 10px; float: left; margin-right: 10px; padding: 10px;\" src=\"/icon.png\" width=\"64\" height=\"64\">%s Jobs</h1>\n", state_colors[printer->state - IPP_PSTATE_IDLE], printer->name);
- html_printf(client, "<p>%s, %d job(s).", printer->state == IPP_PSTATE_IDLE ? "Idle" : printer->state == IPP_PSTATE_PROCESSING ? "Printing" : "Stopped", cupsArrayCount(printer->jobs));
- for (i = 0, reason = 1; i < (int)(sizeof(reasons) / sizeof(reasons[0])); i ++, reason <<= 1)
+ html_printf(client, "<p>%s, %u job(s).", printer->state == IPP_PSTATE_IDLE ? "Idle" : printer->state == IPP_PSTATE_PROCESSING ? "Printing" : "Stopped", (unsigned)cupsArrayGetCount(printer->jobs));
+ for (i = 0, reason = 1; i < (sizeof(reasons) / sizeof(reasons[0])); i ++, reason <<= 1)
if (printer->state_reasons & reason)
html_printf(client, "\n<br> %s", reasons[i]);
html_printf(client, "</p>\n");
- if (cupsArrayCount(printer->jobs) > 0)
+ if (cupsArrayGetCount(printer->jobs) > 0)
{
cupsRWLockRead(&(printer->rwlock));
html_printf(client, "<table class=\"striped\" summary=\"Jobs\"><thead><tr><th>Job #</th><th>Name</th><th>Owner</th><th>Status</th></tr></thead><tbody>\n");
- for (job = (ippeve_job_t *)cupsArrayFirst(printer->jobs); job; job = (ippeve_job_t *)cupsArrayNext(printer->jobs))
+ for (job = (ippeve_job_t *)cupsArrayGetFirst(printer->jobs); job; job = (ippeve_job_t *)cupsArrayGetNext(printer->jobs))
{
- char when[256], /* When job queued/started/finished */
- hhmmss[64]; /* Time HH:MM:SS */
+ char when[256], // When job queued/started/finished
+ hhmmss[64]; // Time HH:MM:SS
switch (job->state)
{
}
-/*
- * 'show_supplies()' - Show printer supplies.
- */
+//
+// 'show_supplies()' - Show printer supplies.
+//
-static int /* O - 1 on success, 0 on failure */
+static int // O - 1 on success, 0 on failure
show_supplies(
- ippeve_client_t *client) /* I - Client connection */
+ ippeve_client_t *client) // I - Client connection
{
ippeve_printer_t *printer = client->printer;
- /* Printer */
- int i, /* Looping var */
- num_supply; /* Number of supplies */
- ipp_attribute_t *supply, /* printer-supply attribute */
- *supply_desc; /* printer-supply-description attribute */
- int num_options = 0; /* Number of form options */
- cups_option_t *options = NULL; /* Form options */
- int supply_len, /* Length of supply value */
- level; /* Supply level */
- const char *supply_value; /* Supply value */
- char supply_text[1024], /* Supply string */
- *supply_ptr; /* Pointer into supply string */
+ // Printer
+ int i, // Looping var
+ num_supply; // Number of supplies
+ ipp_attribute_t *supply, // printer-supply attribute
+ *supply_desc; // printer-supply-description attribute
+ int num_options = 0; // Number of form options
+ cups_option_t *options = NULL; // Form options
+ int supply_len; // Length of supply value
+ int level; // Supply level
+ const char *supply_value; // Supply value
+ char supply_text[1024], // Supply string
+ *supply_ptr; // Pointer into supply string
static const char * const printer_supply[] =
- { /* printer-supply values */
+ { // printer-supply values
"index=1;class=receptacleThatIsFilled;type=wasteToner;unit=percent;"
"maxcapacity=100;level=%d;colorantname=unknown;",
"index=2;class=supplyThatIsConsumed;type=toner;unit=percent;"
"maxcapacity=100;level=%d;colorantname=yellow;"
};
static const char * const backgrounds[] =
- { /* Background colors for the supply-level bars */
+ { // Background colors for the supply-level bars
"#777 linear-gradient(#333,#777)",
"#000 linear-gradient(#666,#000)",
"#0FF linear-gradient(#6FF,#0FF)",
"#F0F linear-gradient(#F6F,#F0F)",
"#CC0 linear-gradient(#EE6,#EE0)"
};
- static const char * const colors[] = /* Text colors for the supply-level bars */
+ static const char * const colors[] = // Text colors for the supply-level bars
{
"#fff",
"#fff",
if (num_options > 0)
{
- /*
- * WARNING: A real printer/server implementation MUST NOT implement
- * supply updates via a GET request - GET requests are supposed to be
- * idempotent (without side-effects) and we obviously are not
- * authenticating access here. This form is provided solely to
- * enable testing and development!
- */
-
- char name[64]; /* Form field */
- const char *val; /* Form value */
+ // WARNING: A real printer/server implementation MUST NOT implement
+ // supply updates via a GET request - GET requests are supposed to be
+ // idempotent (without side-effects) and we obviously are not
+ // authenticating access here. This form is provided solely to
+ // enable testing and development!
+ char name[64]; // Form field
+ const char *val; // Form value
cupsRWLockWrite(&printer->rwlock);
for (i = 0; i < num_supply; i ++)
{
- snprintf(name, sizeof(name), "supply%d", i);
+ snprintf(name, sizeof(name), "supply%u", (unsigned)i);
if ((val = cupsGetOption(name, num_options, options)) != NULL)
{
- level = atoi(val); /* New level */
+ level = atoi(val); // New level
snprintf(supply_text, sizeof(supply_text), printer_supply[i], level);
if (supply)
- ippSetOctetString(printer->attrs, &supply, ippGetCount(supply), supply_text, (int)strlen(supply_text));
+ ippSetOctetString(printer->attrs, &supply, ippGetCount(supply), supply_text, strlen(supply_text));
else
- supply = ippAddOctetString(printer->attrs, IPP_TAG_PRINTER, "printer-supply", supply_text, (int)strlen(supply_text));
+ supply = ippAddOctetString(printer->attrs, IPP_TAG_PRINTER, "printer-supply", supply_text, strlen(supply_text));
if (i == 0)
{
level = 50;
if (printer->web_forms)
- html_printf(client, "<tr><th>%s:</th><td><input name=\"supply%d\" size=\"3\" value=\"%d\"></td>", ippGetString(supply_desc, i, NULL), i, level);
+ html_printf(client, "<tr><th>%s:</th><td><input name=\"supply%u\" size=\"3\" value=\"%d\"></td>", ippGetString(supply_desc, i, NULL), (unsigned)i, level);
else
html_printf(client, "<tr><th>%s:</th>", ippGetString(supply_desc, i, NULL));
#ifndef _WIN32
-/*
- * 'signal_handler()' - Handle termination signals.
- */
+//
+// 'signal_handler()' - Handle termination signals.
+//
static void
-signal_handler(int signum) /* I - Signal number (not used) */
+signal_handler(int signum) // I - Signal number (not used)
{
(void)signum;
#endif // !_WIN32
-/*
- * 'time_string()' - Return the local time in hours, minutes, and seconds.
- */
+//
+// 'time_string()' - Return the local time in hours, minutes, and seconds.
+//
static char *
-time_string(time_t tv, /* I - Time value */
- char *buffer, /* I - Buffer */
- size_t bufsize) /* I - Size of buffer */
+time_string(time_t tv, // I - Time value
+ char *buffer, // I - Buffer
+ size_t bufsize) // I - Size of buffer
{
- struct tm date; /* Local time and date */
+ struct tm date; // Local time and date
localtime_r(&tv, &date);
}
-/*
- * 'usage()' - Show program usage.
- */
+//
+// 'usage()' - Show program usage.
+//
static void
-usage(int status) /* O - Exit status */
+usage(int status) // O - Exit status
{
_cupsLangPuts(stdout, _("Usage: ippeveprinter [options] \"name\""));
_cupsLangPuts(stdout, _("Options:"));
_cupsLangPuts(stdout, _("-F output-type/subtype Set the output format for the printer"));
_cupsLangPuts(stdout, _("-K keypath Set location of server X.509 certificates and keys."));
_cupsLangPuts(stdout, _("-M manufacturer Set manufacturer name (default=Test)"));
-#if !CUPS_LITE
- _cupsLangPuts(stdout, _("-P filename.ppd Load printer attributes from PPD file"));
-#endif /* !CUPS_LITE */
_cupsLangPuts(stdout, _("-S filename.strings Set strings file"));
_cupsLangPuts(stdout, _("-V version Set default IPP version"));
_cupsLangPuts(stdout, _("-a filename.conf Load printer attributes from conf file"));
}
-/*
- * 'valid_doc_attributes()' - Determine whether the document attributes are
- * valid.
- *
- * When one or more document attributes are invalid, this function adds a
- * suitable response and attributes to the unsupported group.
- */
+//
+// 'valid_doc_attributes()' - Determine whether the document attributes are
+// valid.
+//
+// When one or more document attributes are invalid, this function adds a
+// suitable response and attributes to the unsupported group.
+//
-static int /* O - 1 if valid, 0 if not */
+static bool // O - `true` if valid, `false` if not
valid_doc_attributes(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- int valid = 1; /* Valid attributes? */
+ bool valid = true; // Valid attributes?
ipp_op_t op = ippGetOperation(client->request);
- /* IPP operation */
+ // IPP operation
const char *op_name = ippOpString(op);
- /* IPP operation name */
- ipp_attribute_t *attr, /* Current attribute */
- *supported; /* xxx-supported attribute */
+ // IPP operation name
+ ipp_attribute_t *attr, // Current attribute
+ *supported; // xxx-supported attribute
const char *compression = NULL,
- /* compression value */
- *format = NULL; /* document-format value */
-
+ // compression value
+ *format = NULL; // document-format value
- /*
- * Check operation attributes...
- */
+ // Check operation attributes...
if ((attr = ippFindAttribute(client->request, "compression", IPP_TAG_ZERO)) != NULL)
{
- /*
- * If compression is specified, only accept a supported value in a Print-Job
- * or Send-Document request...
- */
-
+ // If compression is specified, only accept a supported value in a Print-Job
+ // or Send-Document request...
compression = ippGetString(attr, 0, NULL);
supported = ippFindAttribute(client->printer->attrs,
"compression-supported", IPP_TAG_KEYWORD);
!ippContainsString(supported, compression))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
}
}
- /*
- * Is it a format we support?
- */
-
+ // Is it a format we support?
if ((attr = ippFindAttribute(client->request, "document-format", IPP_TAG_ZERO)) != NULL)
{
if (ippGetCount(attr) != 1 || ippGetValueTag(attr) != IPP_TAG_MIMETYPE ||
ippGetGroupTag(attr) != IPP_TAG_OPERATION)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
{
format = ippGetString(ippFindAttribute(client->printer->attrs, "document-format-default", IPP_TAG_MIMETYPE), 0, NULL);
if (!format)
- format = "application/octet-stream"; /* Should never happen */
+ format = "application/octet-stream"; // Should never happen
attr = ippAddString(client->request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, format);
}
if (format && !strcmp(format, "application/octet-stream") && (ippGetOperation(client->request) == IPP_OP_PRINT_JOB || ippGetOperation(client->request) == IPP_OP_SEND_DOCUMENT))
{
- /*
- * Auto-type the file using the first 8 bytes of the file...
- */
-
- unsigned char header[8]; /* First 8 bytes of file */
+ // Auto-type the file using the first 8 bytes of the file...
+ unsigned char header[8]; // First 8 bytes of file
memset(header, 0, sizeof(header));
httpPeek(client->http, (char *)header, sizeof(header));
if (op != IPP_OP_CREATE_JOB && (supported = ippFindAttribute(client->printer->attrs, "document-format-supported", IPP_TAG_MIMETYPE)) != NULL && !ippContainsString(supported, format))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
- /*
- * document-name
- */
-
+ // document-name
if ((attr = ippFindAttribute(client->request, "document-name", IPP_TAG_NAME)) != NULL)
ippAddString(client->request, IPP_TAG_JOB, IPP_TAG_NAME, "document-name-supplied", NULL, ippGetString(attr, 0, NULL));
}
-/*
- * 'valid_job_attributes()' - Determine whether the job attributes are valid.
- *
- * When one or more job attributes are invalid, this function adds a suitable
- * response and attributes to the unsupported group.
- */
+//
+// 'valid_job_attributes()' - Determine whether the job attributes are valid.
+//
+// When one or more job attributes are invalid, this function adds a suitable
+// response and attributes to the unsupported group.
+//
-static int /* O - 1 if valid, 0 if not */
+static bool // O - `true` if valid, `false` if not
valid_job_attributes(
- ippeve_client_t *client) /* I - Client */
+ ippeve_client_t *client) // I - Client
{
- int i, /* Looping var */
- count, /* Number of values */
- fidelity, /* "ipp-attribute-fidelity" value */
- valid = 1; /* Valid attributes? */
- ipp_attribute_t *attr, /* Current attribute */
- *supported; /* xxx-supported attribute */
+ int i, // Looping var
+ count; // Number of values
+ bool fidelity, // "ipp-attribute-fidelity" value
+ valid = true; // Valid attributes?
+ ipp_attribute_t *attr, // Current attribute
+ *supported; // xxx-supported attribute
- /*
- * Check operation attributes...
- */
-
+ // Check operation attributes...
valid = valid_doc_attributes(client);
- /*
- * Check the various job template attributes...
- */
-
+ // Check the various job template attributes...
if ((attr = ippFindAttribute(client->request, "ipp-attribute-fidelity", IPP_TAG_ZERO)) != NULL)
{
if (ippGetCount(attr) != 1 || ippGetValueTag(attr) != IPP_TAG_BOOLEAN)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
strcmp(ippGetString(attr, 0, NULL), "no-hold"))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
if (ippGetCount(attr) != 1 || ippGetValueTag(attr) != IPP_TAG_INTEGER || ippGetInteger(attr, 0) < 0)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
ippGetValueTag(attr) != IPP_TAG_NAMELANG))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
ippSetGroupTag(client->request, &attr, IPP_TAG_JOB);
ippGetInteger(attr, 0) < 1 || ippGetInteger(attr, 0) > 100)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
strcmp(ippGetString(attr, 0, NULL), "none"))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
ippGetValueTag(attr) != IPP_TAG_KEYWORD))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if ((attr = ippFindAttribute(client->request, "media-col", IPP_TAG_ZERO)) != NULL)
{
- ipp_t *col, /* media-col collection */
- *size; /* media-size collection */
- ipp_attribute_t *member, /* Member attribute */
- *x_dim, /* x-dimension */
- *y_dim; /* y-dimension */
- int x_value, /* y-dimension value */
- y_value; /* x-dimension value */
+ ipp_t *col, // media-col collection
+ *size; // media-size collection
+ ipp_attribute_t *member, // Member attribute
+ *x_dim, // x-dimension
+ *y_dim; // y-dimension
+ int x_value, // y-dimension value
+ y_value; // x-dimension value
if (ippGetCount(attr) != 1 ||
ippGetValueTag(attr) != IPP_TAG_BEGIN_COLLECTION)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
col = ippGetCollection(attr, 0);
ippGetValueTag(member) != IPP_TAG_KEYWORD))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if (ippGetCount(member) != 1)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
(y_dim = ippFindAttribute(size, "y-dimension", IPP_TAG_INTEGER)) == NULL || ippGetCount(y_dim) != 1)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
"separate-documents-collated-copies")))
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
ippGetInteger(attr, 0) > IPP_ORIENT_REVERSE_PORTRAIT)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
if (ippGetValueTag(attr) != IPP_TAG_RANGE)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
ippGetInteger(attr, 0) > IPP_QUALITY_HIGH)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
}
!supported)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
- int xdpi, /* Horizontal resolution for job template attribute */
- ydpi, /* Vertical resolution for job template attribute */
- sydpi; /* Vertical resolution for supported value */
- ipp_res_t units, /* Units for job template attribute */
- sunits; /* Units for supported value */
+ int xdpi, // Horizontal resolution for job template attribute
+ ydpi, // Vertical resolution for job template attribute
+ sydpi; // Vertical resolution for supported value
+ ipp_res_t units, // Units for job template attribute
+ sunits; // Units for supported value
xdpi = ippGetResolution(attr, 0, &ydpi, &units);
count = ippGetCount(supported);
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if ((attr = ippFindAttribute(client->request, "sides", IPP_TAG_ZERO)) != NULL)
{
const char *sides = ippGetString(attr, 0, NULL);
- /* "sides" value... */
+ // "sides" value...
if (ippGetCount(attr) != 1 || ippGetValueTag(attr) != IPP_TAG_KEYWORD)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else if ((supported = ippFindAttribute(client->printer->attrs, "sides-supported", IPP_TAG_KEYWORD)) != NULL)
{
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
if (fidelity)
{
respond_unsupported(client, attr);
- valid = 0;
+ valid = false;
}
else
{
*host, // Hostname
*resource, // Resource path
*uri; // URI
- size_t num_txt; // Number of TXT record keys
+ int num_txt; // Number of TXT record keys
cups_option_t *txt; // TXT record keys
int port; // Port number
bool is_local, // Is a local service?
static void browse_callback(cups_dnssd_browse_t *browse, void *context, cups_dnssd_flags_t flags, uint32_t if_index, const char *serviceName, const char *regtype, const char *replyDomain);
static int compare_services(ippfind_srv_t *a, ippfind_srv_t *b);
static int eval_expr(ippfind_srv_t *service, ippfind_expr_t *expressions);
-static int exec_program(ippfind_srv_t *service, size_t num_args, char **args);
+static int exec_program(ippfind_srv_t *service, int num_args, char **args);
static ippfind_srv_t *get_service(ippfind_srvs_t *services, const char *serviceName, const char *regtype, const char *replyDomain) _CUPS_NONNULL(1,2,3,4);
static double get_time(void);
static int list_service(ippfind_srv_t *service);
static ippfind_expr_t *new_expr(ippfind_op_t op, bool invert, const char *value, const char *regex, char **args);
-static void resolve_callback(cups_dnssd_resolve_t *resolve, void *context, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullName, const char *hostTarget, uint16_t port, size_t num_txt, cups_option_t *txt);
+static void resolve_callback(cups_dnssd_resolve_t *resolve, void *context, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullName, const char *hostTarget, uint16_t port, int num_txt, cups_option_t *txt);
static void set_service_uri(ippfind_srv_t *service);
static void show_usage(void) _CUPS_NORETURN;
static void show_version(void) _CUPS_NORETURN;
while (get_time() < endtime)
{
// Process any services that we have found...
- size_t j, // Looping var
+ int j, // Looping var
count, // Number of services
active = 0, // Number of active resolves
resolved = 0, // Number of resolved services
static int // O - 1 if program terminated successfully, 0 otherwise
exec_program(ippfind_srv_t *service, // I - Service
- size_t num_args, // I - Number of command-line args
+ int num_args, // I - Number of command-line args
char **args) // I - Command-line arguments
{
char **myargv, // Command-line arguments
scheme[128], // IPPFIND_SERVICE_SCHEME
uri[1024], // IPPFIND_SERVICE_URI
txt[100][256]; // IPPFIND_TXT_foo
- size_t i, // Looping var
+ int i, // Looping var
myenvc; // Number of environment variables
int status; // Exit status of program
#ifndef _WIN32
const char *regtype, // I - Type of service
const char *replyDomain)// I - Service domain
{
- size_t i, // Looping var
+ int i, // Looping var
count; // Number of services
ippfind_srv_t key, // Search key
*service; // Service
ipp_t *request, // IPP request
*response; // IPP response
ipp_attribute_t *attr; // IPP attribute
- size_t i, // Looping var
+ int i, // Looping var
count; // Number of values
int version; // IPP version
bool paccepting; // printer-is-accepting-jobs value
const char *fullName, // I - Full service name
const char *hostTarget, // I - Hostname
uint16_t port, // I - Port number
- size_t num_txt, // I - Number of TXT key/value pairs
+ int num_txt, // I - Number of TXT key/value pairs
cups_option_t *txt) // I - TXT key/value pairs
{
ippfind_srv_t *service = (ippfind_srv_t *)context;
// Service
- size_t i; // Looping var
+ int i; // Looping var
char *value; // Pointer into value
if (getenv("IPPFIND_DEBUG"))
- fprintf(stderr, "R flags=0x%04X, if_index=%u, fullName=\"%s\", hostTarget=\"%s\", port=%u, num_txt=%u, txt=%p\n", flags, if_index, fullName, hostTarget, port, (unsigned)num_txt, txt);
+ fprintf(stderr, "R flags=0x%04X, if_index=%u, fullName=\"%s\", hostTarget=\"%s\", port=%u, num_txt=%d, txt=%p\n", flags, if_index, fullName, hostTarget, port, num_txt, (void *)txt);
(void)resolve;
(void)if_index;
-/*
- * ipptool command for CUPS.
- *
- * Copyright © 2021-2023 by OpenPrinting.
- * Copyright © 2020 by The Printer Working Group.
- * Copyright © 2007-2021 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// ipptool command for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2020 by The Printer Working Group.
+// Copyright © 2007-2021 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
+
+//
+// Include necessary headers...
+//
#include <cups/cups-private.h>
+#include <cups/raster-testpage.h>
#include <regex.h>
#include <sys/stat.h>
#ifdef _WIN32
# include <windows.h>
# ifndef R_OK
# define R_OK 0
-# endif /* !R_OK */
+# endif // !R_OK
#else
# include <signal.h>
# include <termios.h>
-#endif /* _WIN32 */
+#endif // _WIN32
#ifndef O_BINARY
# define O_BINARY 0
-#endif /* !O_BINARY */
+#endif // !O_BINARY
-/*
- * Limits...
- */
+//
+// Limits...
+//
-#define MAX_EXPECT 200 // Maximum number of EXPECT directives
+#define MAX_EXPECT 1000 // Maximum number of EXPECT directives
#define MAX_DISPLAY 200 // Maximum number of DISPLAY directives
#define MAX_MONITOR 10 // Maximum number of MONITOR-PRINTER-STATE EXPECT directives
-/*
- * Types...
- */
+//
+// Types...
+//
-typedef enum ipptool_transfer_e /**** How to send request data ****/
+typedef enum ipptool_content_e // Content Validation
{
- IPPTOOL_TRANSFER_AUTO, /* Chunk for files, length for static */
- IPPTOOL_TRANSFER_CHUNKED, /* Chunk always */
- IPPTOOL_TRANSFER_LENGTH /* Length always */
-} ipptool_transfer_t;
+ IPPTOOL_CONTENT_NONE, // No content validation
+ IPPTOOL_CONTENT_AVAILABLE, // Accessible resource
+ IPPTOOL_CONTENT_VALID, // Valid resource
+ IPPTOOL_CONTENT_VALID_ICON // Valid icon resource
+} ipptool_content_t;
-typedef enum ipptool_output_e /**** Output mode ****/
+typedef enum ipptool_output_e // Output mode
{
- IPPTOOL_OUTPUT_QUIET, /* No output */
- IPPTOOL_OUTPUT_TEST, /* Traditional CUPS test output */
- IPPTOOL_OUTPUT_PLIST, /* XML plist test output */
- IPPTOOL_OUTPUT_IPPSERVER, /* ippserver attribute file output */
- IPPTOOL_OUTPUT_LIST, /* Tabular list output */
- IPPTOOL_OUTPUT_CSV, /* Comma-separated values output */
- IPPTOOL_OUTPUT_JSON /* JSON output */
+ IPPTOOL_OUTPUT_QUIET, // No output
+ IPPTOOL_OUTPUT_TEST, // Traditional CUPS test output
+ IPPTOOL_OUTPUT_PLIST, // XML plist test output
+ IPPTOOL_OUTPUT_IPPSERVER, // ippserver attribute file output
+ IPPTOOL_OUTPUT_LIST, // Tabular list output
+ IPPTOOL_OUTPUT_CSV, // Comma-separated values output
+ IPPTOOL_OUTPUT_JSON // JSON output
} ipptool_output_t;
-typedef enum ipptool_with_e /**** WITH flags ****/
+typedef enum ipptool_transfer_e // How to send request data
+{
+ IPPTOOL_TRANSFER_AUTO, // Chunk for files, length for static
+ IPPTOOL_TRANSFER_CHUNKED, // Chunk always
+ IPPTOOL_TRANSFER_LENGTH // Length always
+} ipptool_transfer_t;
+
+typedef enum ipptool_with_e // WITH flags
{
- IPPTOOL_WITH_LITERAL = 0, /* Match string is a literal value */
- IPPTOOL_WITH_ALL = 1, /* Must match all values */
- IPPTOOL_WITH_REGEX = 2, /* Match string is a regular expression */
- IPPTOOL_WITH_HOSTNAME = 4, /* Match string is a URI hostname */
- IPPTOOL_WITH_RESOURCE = 8, /* Match string is a URI resource */
- IPPTOOL_WITH_SCHEME = 16 /* Match string is a URI scheme */
+ IPPTOOL_WITH_LITERAL = 0, // Match string is a literal value
+ IPPTOOL_WITH_ALL = 1, // Must match all values
+ IPPTOOL_WITH_REGEX = 2, // Match string is a regular expression
+ IPPTOOL_WITH_HOSTNAME = 4, // Match string is a URI hostname
+ IPPTOOL_WITH_RESOURCE = 8, // Match string is a URI resource
+ IPPTOOL_WITH_SCHEME = 16 // Match string is a URI scheme
} ipptool_with_t;
-typedef struct ipptool_expect_s /**** Expected attribute info ****/
+typedef struct ipptool_expect_s // Expected attribute info
{
- int optional, /* Optional attribute? */
- not_expect, /* Don't expect attribute? */
- expect_all; /* Expect all attributes to match/not match */
- char *name, /* Attribute name */
- *of_type, /* Type name */
- *same_count_as, /* Parallel attribute name */
- *if_defined, /* Only required if variable defined */
- *if_not_defined, /* Only required if variable is not defined */
- *with_value, /* Attribute must include this value */
- *with_value_from, /* Attribute must have one of the values in this attribute */
- *define_match, /* Variable to define on match */
- *define_no_match, /* Variable to define on no-match */
- *define_value, /* Variable to define with value */
- *display_match; /* Message to display on a match */
- int repeat_limit, /* Maximum number of times to repeat */
- repeat_match, /* Repeat test on match */
- repeat_no_match, /* Repeat test on no match */
- with_distinct, /* WITH-DISTINCT-VALUES? */
- with_flags, /* WITH flags */
- count; /* Expected count if > 0 */
- ipp_tag_t in_group; /* IN-GROUP value */
+ bool optional, // Optional attribute?
+ not_expect, // Don't expect attribute?
+ expect_all; // Expect all attributes to match/not match
+ char *name, // Attribute name
+ *of_type, // Type name
+ *same_count_as, // Parallel attribute name
+ *if_defined, // Only required if variable defined
+ *if_not_defined, // Only required if variable is not defined
+ *with_value, // Attribute must include this value
+ *with_value_from, // Attribute must have one of the values in this attribute
+ *define_match, // Variable to define on match
+ *define_no_match, // Variable to define on no-match
+ *define_value, // Variable to define with value
+ *display_match; // Message to display on a match
+ ipptool_content_t with_content; // WITH-*-CONTENT value
+ cups_array_t *with_mime_types; // WITH-*-MIME-TYPES value(s)
+ char *save_filespec; // SAVE-*-CONTENT filespec
+ int repeat_limit; // Maximum number of times to repeat
+ bool repeat_match, // Repeat test on match
+ repeat_no_match, // Repeat test on no match
+ with_distinct; // WITH-DISTINCT-VALUES?
+ int with_flags; // WITH flags
+ int count; // Expected count if > 0
+ ipp_tag_t in_group; // IN-GROUP value
} ipptool_expect_t;
-typedef struct ipptool_status_s /**** Status info ****/
+typedef struct ipptool_generate_s //// GENERATE-FILE parameters
+{
+ char media[128], // Media size name
+ type[128]; // Raster type/color mode
+ int xdpi, // Horizontal resolution
+ ydpi; // Vertical resolution
+ ipp_orient_t orientation; // Orientation
+ char sides[128]; // Duplex mode
+ int num_copies, // Number of copies
+ num_pages; // Number of pages
+ char format[128]; // Document format
+ char sheet_back[128]; // "pwg-raster-document-sheet-back" value
+} ipptool_generate_t;
+
+typedef struct ipptool_status_s // Status info
{
- ipp_status_t status; /* Expected status code */
- char *if_defined, /* Only if variable is defined */
- *if_not_defined, /* Only if variable is not defined */
- *define_match, /* Variable to define on match */
- *define_no_match, /* Variable to define on no-match */
- *define_value; /* Variable to define with value */
- int repeat_limit, /* Maximum number of times to repeat */
- repeat_match, /* Repeat the test when it does not match */
- repeat_no_match; /* Repeat the test when it matches */
+ ipp_status_t status; // Expected status code
+ char *if_defined, // Only if variable is defined
+ *if_not_defined, // Only if variable is not defined
+ *define_match, // Variable to define on match
+ *define_no_match, // Variable to define on no-match
+ *define_value; // Variable to define with value
+ int repeat_limit; // Maximum number of times to repeat
+ bool repeat_match, // Repeat the test when it does not match
+ repeat_no_match; // Repeat the test when it matches
} ipptool_status_t;
-typedef struct ipptool_test_s /**** Test Data ****/
+typedef struct ipptool_test_s // Test Data
{
- /* Global Options */
- _ipp_vars_t *vars; /* Variables */
- http_encryption_t encryption; /* Encryption for connection */
- int family; /* Address family */
- ipptool_output_t output; /* Output mode */
- int repeat_on_busy; /* Repeat tests on server-error-busy */
- int stop_after_include_error;
- /* Stop after include errors? */
- double timeout; /* Timeout for connection */
- int validate_headers, /* Validate HTTP headers in response? */
- verbosity; /* Show all attributes? */
-
- /* Test Defaults */
- int def_ignore_errors; /* Default IGNORE-ERRORS value */
- ipptool_transfer_t def_transfer; /* Default TRANSFER value */
- int def_version; /* Default IPP version */
-
- /* Global State */
- http_t *http; /* HTTP connection to printer/server */
- cups_file_t *outfile; /* Output file */
- int show_header, /* Show the test header? */
- xml_header; /* 1 if XML plist header was written */
- int pass, /* Have we passed all tests? */
- test_count, /* Number of tests (total) */
- pass_count, /* Number of tests that passed */
- fail_count, /* Number of tests that failed */
- skip_count; /* Number of tests that were skipped */
-
- /* Per-Test State */
- cups_array_t *errors; /* Errors array */
- int prev_pass, /* Result of previous test */
- skip_previous; /* Skip on previous test failure? */
- char compression[16]; /* COMPRESSION value */
- useconds_t delay; /* Initial delay */
- int num_displayed; /* Number of displayed attributes */
- char *displayed[MAX_DISPLAY];/* Displayed attributes */
- int num_expects; /* Number of expected attributes */
- ipptool_expect_t expects[MAX_EXPECT], /* Expected attributes */
- *expect, /* Current expected attribute */
- *last_expect; /* Last EXPECT (for predicates) */
- char file[1024], /* Data filename */
- file_id[1024]; /* File identifier */
- int ignore_errors; /* Ignore test failures? */
- char name[1024]; /* Test name */
- char pause[1024]; /* PAUSE value */
- useconds_t repeat_interval; /* Repeat interval (delay) */
- int request_id; /* Current request ID */
- char resource[512]; /* Resource for request */
- int pass_test, /* Pass this test? */
- skip_test, /* Skip this test? */
- num_statuses; /* Number of valid status codes */
- ipptool_status_t statuses[100], /* Valid status codes */
- *last_status; /* Last STATUS (for predicates) */
- char test_id[1024]; /* Test identifier */
- ipptool_transfer_t transfer; /* To chunk or not to chunk */
- int version; /* IPP version number to use */
- cups_thread_t monitor_thread; /* Monitoring thread ID */
- int monitor_done; /* Set to 1 to stop monitor thread */
- char *monitor_uri; /* MONITOR-PRINTER-STATE URI */
- useconds_t monitor_delay, /* MONITOR-PRINTER-STATE DELAY value, if any */
- monitor_interval; /* MONITOR-PRINTER-STATE DELAY interval */
- int num_monitor_expects; /* Number MONITOR-PRINTER-STATE EXPECTs */
+ // Global Options
+ ipp_file_t *parent; // Parent IPP data file values
+ int password_tries; // Number of password attempts
+ http_encryption_t encryption; // Encryption for connection
+ int family; // Address family
+ ipptool_output_t output; // Output mode
+ bool repeat_on_busy; // Repeat tests on server-error-busy
+ bool stop_after_include_error;
+ // Stop after include errors?
+ double timeout; // Timeout for connection
+ bool validate_headers; // Validate HTTP headers in response?
+ int verbosity; // Show all attributes?
+
+ // Test Defaults
+ bool def_ignore_errors; // Default IGNORE-ERRORS value
+ ipptool_transfer_t def_transfer; // Default TRANSFER value
+ int def_version; // Default IPP version
+
+ // Global State
+ http_t *http; // HTTP connection to printer/server
+ cups_file_t *outfile; // Output file
+ bool show_header, // Show the test header?
+ xml_header, // `true` if XML plist header was written
+ pass; // Have we passed all tests?
+ int test_count, // Number of tests (total)
+ pass_count, // Number of tests that passed
+ fail_count, // Number of tests that failed
+ skip_count; // Number of tests that were skipped
+
+ // Per-Test State
+ ipp_op_t op; // Operation code
+ cups_array_t *errors; // Errors array
+ bool prev_pass, // Result of previous test
+ skip_previous; // Skip on previous test failure?
+ char compression[16]; // COMPRESSION value
+ useconds_t delay; // Initial delay
+ int num_displayed; // Number of displayed attributes
+ char *displayed[MAX_DISPLAY];// Displayed attributes
+ int num_expects; // Number of expected attributes
+ ipptool_expect_t expects[MAX_EXPECT], // Expected attributes
+ *expect, // Current expected attribute
+ *last_expect; // Last EXPECT (for predicates)
+ char file[1024], // Data filename
+ file_id[1024]; // File identifier
+ bool ignore_errors; // Ignore test failures?
+ char name[1024]; // Test name
+ char pause[1024]; // PAUSE value
+ useconds_t repeat_interval; // Repeat interval (delay)
+ int request_id; // Current request ID
+ char resource[512]; // Resource for request
+ bool pass_test, // Pass this test?
+ skip_test; // Skip this test?
+ int num_statuses; // Number of valid status codes
+ ipptool_status_t statuses[100], // Valid status codes
+ *last_status; // Last STATUS (for predicates)
+ char test_id[1024]; // Test identifier
+ ipptool_transfer_t transfer; // To chunk or not to chunk
+ int version; // IPP version number to use
+ cups_thread_t monitor_thread; // Monitoring thread ID
+ bool monitor_done; // Set to `true` to stop monitor thread
+ char *monitor_uri; // MONITOR-PRINTER-STATE URI
+ useconds_t monitor_delay, // MONITOR-PRINTER-STATE DELAY value, if any
+ monitor_interval; // MONITOR-PRINTER-STATE DELAY interval
+ int num_monitor_expects; // Number MONITOR-PRINTER-STATE EXPECTs
ipptool_expect_t monitor_expects[MAX_MONITOR];
- /* MONITOR-PRINTER-STATE EXPECTs */
+ // MONITOR-PRINTER-STATE EXPECTs
+ ipptool_generate_t *generate_params; // GENERATE-FILE parameters
+ char buffer[1024*1024]; // Output buffer
} ipptool_test_t;
-/*
- * Globals...
- */
+//
+// Globals...
+//
-static int Cancel = 0; /* Cancel test? */
+static bool Cancel = false; // Cancel test?
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
static void add_stringf(cups_array_t *a, const char *s, ...) _CUPS_FORMAT(2, 3);
-static int compare_uris(const char *a, const char *b);
+static ipptool_test_t *alloc_data(void);
+static void clear_data(ipptool_test_t *data);
+static int compare_uris(const char *a, const char *b);
+static http_t *connect_printer(ipptool_test_t *data);
static void copy_hex_string(char *buffer, unsigned char *data, int datalen, size_t bufsize);
+static int create_file(const char *filespec, const char *resource, int idx, char *filename, size_t filenamesize);
static void *do_monitor_printer_state(ipptool_test_t *data);
-static int do_test(_ipp_file_t *f, ipptool_test_t *data);
-static int do_tests(const char *testfile, ipptool_test_t *data);
-static int error_cb(_ipp_file_t *f, ipptool_test_t *data, const char *error);
-static int expect_matches(ipptool_expect_t *expect, ipp_attribute_t *attr);
+static bool do_test(ipp_file_t *file, ipptool_test_t *data);
+static bool do_tests(const char *testfile, ipptool_test_t *data);
+static bool error_cb(ipp_file_t *f, ipptool_test_t *data, const char *error);
+static bool expect_matches(ipptool_expect_t *expect, ipp_attribute_t *attr);
+static void free_data(ipptool_test_t *data);
+static http_status_t generate_file(http_t *http, ipptool_generate_t *params);
static char *get_filename(const char *testfile, char *dst, const char *src, size_t dstsize);
static const char *get_string(ipp_attribute_t *attr, int element, int flags, char *buffer, size_t bufsize);
-static void init_data(ipptool_test_t *data);
static char *iso_date(const ipp_uchar_t *date);
-static int parse_monitor_printer_state(_ipp_file_t *f, ipptool_test_t *data);
+static bool parse_generate_file(ipp_file_t *f, ipptool_test_t *data);
+static bool parse_monitor_printer_state(ipp_file_t *f, ipptool_test_t *data);
+static const char *password_cb(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data);
static void pause_message(const char *message);
static void print_attr(cups_file_t *outfile, ipptool_output_t output, ipp_attribute_t *attr, ipp_tag_t *group);
-static ipp_attribute_t *print_csv(ipptool_test_t *data, ipp_t *ipp, ipp_attribute_t *attr, int num_displayed, char **displayed, size_t *widths);
+static ipp_attribute_t *print_csv(ipptool_test_t *data, ipp_t *ipp, ipp_attribute_t *attr, int num_displayed, char **displayed, int *widths);
static void print_fatal_error(ipptool_test_t *data, const char *s, ...) _CUPS_FORMAT(2, 3);
static void print_ippserver_attr(ipptool_test_t *data, ipp_attribute_t *attr, int indent);
static void print_ippserver_string(ipptool_test_t *data, const char *s, size_t len);
static void print_json_attr(ipptool_test_t *data, ipp_attribute_t *attr, int indent);
static void print_json_string(ipptool_test_t *data, const char *s, size_t len);
-static ipp_attribute_t *print_line(ipptool_test_t *data, ipp_t *ipp, ipp_attribute_t *attr, int num_displayed, char **displayed, size_t *widths);
+static ipp_attribute_t *print_line(ipptool_test_t *data, ipp_t *ipp, ipp_attribute_t *attr, int num_displayed, char **displayed, int *widths);
static void print_xml_header(ipptool_test_t *data);
static void print_xml_string(cups_file_t *outfile, const char *element, const char *s);
static void print_xml_trailer(ipptool_test_t *data, int success, const char *message);
#ifndef _WIN32
static void sigterm_handler(int sig);
-#endif /* _WIN32 */
+#endif // _WIN32
static int timeout_cb(http_t *http, void *user_data);
-static int token_cb(_ipp_file_t *f, _ipp_vars_t *vars, ipptool_test_t *data, const char *token);
+static bool token_cb(ipp_file_t *f, ipptool_test_t *data, const char *token);
static void usage(void) _CUPS_NORETURN;
-static int with_distinct_values(cups_array_t *errors, ipp_attribute_t *attr);
+static bool valid_image(const char *filename, int *width, int *height, int *depth);
+static bool with_content(cups_array_t *errors, ipp_attribute_t *attr, ipptool_content_t content, cups_array_t *mime_types, const char *filespec);
+static bool with_distinct_values(cups_array_t *errors, ipp_attribute_t *attr);
static const char *with_flags_string(int flags);
-static int with_value(ipptool_test_t *data, cups_array_t *errors, char *value, int flags, ipp_attribute_t *attr, char *matchbuf, size_t matchlen);
-static int with_value_from(cups_array_t *errors, ipp_attribute_t *fromattr, ipp_attribute_t *attr, char *matchbuf, size_t matchlen);
+static bool with_value(ipptool_test_t *data, cups_array_t *errors, char *value, int flags, ipp_attribute_t *attr, char *matchbuf, size_t matchlen);
+static bool with_value_from(cups_array_t *errors, ipp_attribute_t *fromattr, ipp_attribute_t *attr, char *matchbuf, size_t matchlen);
-/*
- * 'main()' - Parse options and do tests.
- */
+//
+// 'main()' - Parse options and do tests.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line args */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line args
+ char *argv[]) // I - Command-line arguments
{
- int i; /* Looping var */
- int status; /* Status of tests... */
- char *opt, /* Current option */
- name[1024], /* Name/value buffer */
- *value, /* Pointer to value */
- filename[1024], /* Real filename */
- testname[1024]; /* Real test filename */
- const char *ext, /* Extension on filename */
- *testfile; /* Test file to use */
- int interval, /* Test interval in microseconds */
- repeat; /* Repeat count */
- _ipp_vars_t vars; /* Variables */
- ipptool_test_t data; /* Test data */
+ int i; // Looping var
+ int status; // Status of tests...
+ char *opt, // Current option
+ name[1024], // Name/value buffer
+ *value, // Pointer to value
+ filename[1024], // Real filename
+ testname[1024]; // Real test filename
+ const char *base, // Base filename
+ *ext, // Extension on filename
+ *testfile; // Test file to use
+ int interval, // Test interval in microseconds
+ repeat; // Repeat count
+ ipptool_test_t *data; // Test data
_cups_globals_t *cg = _cupsGlobals();
- /* Global data */
+ // Global data
#ifndef _WIN32
- /*
- * Catch SIGINT and SIGTERM...
- */
-
+ // Catch SIGINT and SIGTERM...
signal(SIGINT, sigterm_handler);
signal(SIGTERM, sigterm_handler);
-#endif /* !_WIN32 */
-
- /*
- * Initialize the locale and variables...
- */
+#endif // !_WIN32
+ // Initialize the locale and variables...
_cupsSetLocale(argv);
- init_data(&data);
-
- _ippVarsInit(&vars, NULL, (_ipp_ferror_cb_t)error_cb, (_ipp_ftoken_cb_t)token_cb);
- data.vars = &vars;
-
- _ippVarsSet(data.vars, "date-start", iso_date(ippTimeToDate(time(NULL))));
-
- /*
- * We need at least:
- *
- * ipptool URI testfile
- */
+ data = alloc_data();
+ // We need at least:
+ //
+ // ipptool URI testfile
interval = 0;
repeat = 0;
status = 0;
{
if (!strcmp(argv[i], "--help"))
{
+ free_data(data);
usage();
}
else if (!strcmp(argv[i], "--ippserver"))
if (i >= argc)
{
_cupsLangPuts(stderr, _("ipptool: Missing filename for \"--ippserver\"."));
+ free_data(data);
usage();
}
- if (data.outfile != cupsFileStdout())
+ if (data->outfile != cupsFileStdout())
usage();
- if ((data.outfile = cupsFileOpen(argv[i], "w")) == NULL)
+ if ((data->outfile = cupsFileOpen(argv[i], "w")) == NULL)
{
_cupsLangPrintf(stderr, _("%s: Unable to open \"%s\": %s"), "ipptool", argv[i], strerror(errno));
- exit(1);
+ free_data(data);
+ return (1);
}
- data.output = IPPTOOL_OUTPUT_IPPSERVER;
+ data->output = IPPTOOL_OUTPUT_IPPSERVER;
}
else if (!strcmp(argv[i], "--stop-after-include-error"))
{
- data.stop_after_include_error = 1;
+ data->stop_after_include_error = 1;
}
else if (!strcmp(argv[i], "--version"))
{
puts(CUPS_SVERSION);
+
+ free_data(data);
return (0);
}
else if (argv[i][0] == '-')
{
switch (*opt)
{
- case '4' : /* Connect using IPv4 only */
- data.family = AF_INET;
+ case '4' : // Connect using IPv4 only
+ data->family = AF_INET;
break;
#ifdef AF_INET6
- case '6' : /* Connect using IPv6 only */
- data.family = AF_INET6;
+ case '6' : // Connect using IPv6 only
+ data->family = AF_INET6;
break;
-#endif /* AF_INET6 */
+#endif // AF_INET6
- case 'C' : /* Enable HTTP chunking */
- data.def_transfer = IPPTOOL_TRANSFER_CHUNKED;
+ case 'C' : // Enable HTTP chunking
+ data->def_transfer = IPPTOOL_TRANSFER_CHUNKED;
break;
- case 'E' : /* Encrypt with TLS */
- data.encryption = HTTP_ENCRYPTION_REQUIRED;
+ case 'E' : // Encrypt with TLS
+ data->encryption = HTTP_ENCRYPTION_REQUIRED;
break;
- case 'I' : /* Ignore errors */
- data.def_ignore_errors = 1;
+ case 'I' : // Ignore errors
+ data->def_ignore_errors = 1;
break;
- case 'L' : /* Disable HTTP chunking */
- data.def_transfer = IPPTOOL_TRANSFER_LENGTH;
+ case 'L' : // Disable HTTP chunking
+ data->def_transfer = IPPTOOL_TRANSFER_LENGTH;
break;
- case 'P' : /* Output to plist file */
+ case 'P' : // Output to plist file
i ++;
if (i >= argc)
usage();
}
- if (data.outfile != cupsFileStdout())
+ if (data->outfile != cupsFileStdout())
usage();
- if ((data.outfile = cupsFileOpen(argv[i], "w")) == NULL)
+ if ((data->outfile = cupsFileOpen(argv[i], "w")) == NULL)
{
_cupsLangPrintf(stderr, _("%s: Unable to open \"%s\": %s"), "ipptool", argv[i], strerror(errno));
exit(1);
}
- data.output = IPPTOOL_OUTPUT_PLIST;
+ data->output = IPPTOOL_OUTPUT_PLIST;
if (interval || repeat)
{
}
break;
- case 'R' : /* Repeat on server-error-busy */
- data.repeat_on_busy = 1;
+ case 'R' : // Repeat on server-error-busy
+ data->repeat_on_busy = 1;
break;
- case 'S' : /* Encrypt with SSL */
- data.encryption = HTTP_ENCRYPTION_ALWAYS;
+ case 'S' : // Encrypt with SSL
+ data->encryption = HTTP_ENCRYPTION_ALWAYS;
break;
- case 'T' : /* Set timeout */
+ case 'T' : // Set timeout
i ++;
if (i >= argc)
usage();
}
- data.timeout = _cupsStrScand(argv[i], NULL, localeconv());
+ data->timeout = _cupsStrScand(argv[i], NULL, localeconv());
break;
- case 'V' : /* Set IPP version */
+ case 'V' : // Set IPP version
i ++;
if (i >= argc)
if (!strcmp(argv[i], "1.0"))
{
- data.def_version = 10;
+ data->def_version = 10;
}
else if (!strcmp(argv[i], "1.1"))
{
- data.def_version = 11;
+ data->def_version = 11;
}
else if (!strcmp(argv[i], "2.0"))
{
- data.def_version = 20;
+ data->def_version = 20;
}
else if (!strcmp(argv[i], "2.1"))
{
- data.def_version = 21;
+ data->def_version = 21;
}
else if (!strcmp(argv[i], "2.2"))
{
- data.def_version = 22;
+ data->def_version = 22;
}
else
{
}
break;
- case 'X' : /* Produce XML output */
- data.output = IPPTOOL_OUTPUT_PLIST;
+ case 'X' : // Produce XML output
+ data->output = IPPTOOL_OUTPUT_PLIST;
if (interval || repeat)
{
}
break;
- case 'c' : /* CSV output */
- data.output = IPPTOOL_OUTPUT_CSV;
+ case 'c' : // CSV output
+ data->output = IPPTOOL_OUTPUT_CSV;
break;
- case 'd' : /* Define a variable */
+ case 'd' : // Define a variable
i ++;
if (i >= argc)
else
value = name + strlen(name);
- _ippVarsSet(data.vars, name, value);
+ ippFileSetVar(data->parent, name, value);
break;
- case 'f' : /* Set the default test filename */
+ case 'f' : // Set the default test filename
i ++;
if (i >= argc)
if (access(argv[i], 0))
{
- /*
- * Try filename.gz...
- */
-
+ // Try filename.gz...
snprintf(filename, sizeof(filename), "%s.gz", argv[i]);
if (access(filename, 0) && filename[0] != '/'
#ifdef _WIN32
&& (!isalpha(filename[0] & 255) || filename[1] != ':')
-#endif /* _WIN32 */
+#endif // _WIN32
)
{
snprintf(filename, sizeof(filename), "%s/ipptool/%s", cg->cups_datadir, argv[i]);
else
cupsCopyString(filename, argv[i], sizeof(filename));
- _ippVarsSet(data.vars, "filename", filename);
+ ippFileSetVar(data->parent, "filename", filename);
+
+ if ((base = strrchr(filename, '/')) != NULL)
+ ippFileSetVar(data->parent, "basename", base + 1);
+ else
+ ippFileSetVar(data->parent, "basename", filename);
if ((ext = strrchr(filename, '.')) != NULL)
{
- /*
- * Guess the MIME media type based on the extension...
- */
-
+ // Guess the MIME media type based on the extension...
if (!_cups_strcasecmp(ext, ".gif"))
- _ippVarsSet(data.vars, "filetype", "image/gif");
- else if (!_cups_strcasecmp(ext, ".htm") ||
- !_cups_strcasecmp(ext, ".htm.gz") ||
- !_cups_strcasecmp(ext, ".html") ||
- !_cups_strcasecmp(ext, ".html.gz"))
- _ippVarsSet(data.vars, "filetype", "text/html");
- else if (!_cups_strcasecmp(ext, ".jpg") ||
- !_cups_strcasecmp(ext, ".jpeg"))
- _ippVarsSet(data.vars, "filetype", "image/jpeg");
- else if (!_cups_strcasecmp(ext, ".pcl") ||
- !_cups_strcasecmp(ext, ".pcl.gz"))
- _ippVarsSet(data.vars, "filetype", "application/vnd.hp-PCL");
+ ippFileSetVar(data->parent, "filetype", "image/gif");
+ else if (!_cups_strcasecmp(ext, ".htm") || !_cups_strcasecmp(ext, ".htm.gz") || !_cups_strcasecmp(ext, ".html") || !_cups_strcasecmp(ext, ".html.gz"))
+ ippFileSetVar(data->parent, "filetype", "text/html");
+ else if (!_cups_strcasecmp(ext, ".jpg") || !_cups_strcasecmp(ext, ".jpeg"))
+ ippFileSetVar(data->parent, "filetype", "image/jpeg");
+ else if (!_cups_strcasecmp(ext, ".pcl") || !_cups_strcasecmp(ext, ".pcl.gz"))
+ ippFileSetVar(data->parent, "filetype", "application/vnd.hp-PCL");
else if (!_cups_strcasecmp(ext, ".pdf"))
- _ippVarsSet(data.vars, "filetype", "application/pdf");
+ ippFileSetVar(data->parent, "filetype", "application/pdf");
else if (!_cups_strcasecmp(ext, ".png"))
- _ippVarsSet(data.vars, "filetype", "image/png");
- else if (!_cups_strcasecmp(ext, ".ps") ||
- !_cups_strcasecmp(ext, ".ps.gz"))
- _ippVarsSet(data.vars, "filetype", "application/postscript");
- else if (!_cups_strcasecmp(ext, ".pwg") ||
- !_cups_strcasecmp(ext, ".pwg.gz") ||
- !_cups_strcasecmp(ext, ".ras") ||
- !_cups_strcasecmp(ext, ".ras.gz"))
- _ippVarsSet(data.vars, "filetype", "image/pwg-raster");
- else if (!_cups_strcasecmp(ext, ".tif") ||
- !_cups_strcasecmp(ext, ".tiff"))
- _ippVarsSet(data.vars, "filetype", "image/tiff");
- else if (!_cups_strcasecmp(ext, ".txt") ||
- !_cups_strcasecmp(ext, ".txt.gz"))
- _ippVarsSet(data.vars, "filetype", "text/plain");
- else if (!_cups_strcasecmp(ext, ".urf") ||
- !_cups_strcasecmp(ext, ".urf.gz"))
- _ippVarsSet(data.vars, "filetype", "image/urf");
+ ippFileSetVar(data->parent, "filetype", "image/png");
+ else if (!_cups_strcasecmp(ext, ".ps") || !_cups_strcasecmp(ext, ".ps.gz"))
+ ippFileSetVar(data->parent, "filetype", "application/postscript");
+ else if (!_cups_strcasecmp(ext, ".pwg") || !_cups_strcasecmp(ext, ".pwg.gz") || !_cups_strcasecmp(ext, ".ras") || !_cups_strcasecmp(ext, ".ras.gz"))
+ ippFileSetVar(data->parent, "filetype", "image/pwg-raster");
+ else if (!_cups_strcasecmp(ext, ".pxl") || !_cups_strcasecmp(ext, ".pxl.gz"))
+ ippFileSetVar(data->parent, "filetype", "application/vnd.hp-PCLXL");
+ else if (!_cups_strcasecmp(ext, ".tif") || !_cups_strcasecmp(ext, ".tiff"))
+ ippFileSetVar(data->parent, "filetype", "image/tiff");
+ else if (!_cups_strcasecmp(ext, ".txt") || !_cups_strcasecmp(ext, ".txt.gz"))
+ ippFileSetVar(data->parent, "filetype", "text/plain");
+ else if (!_cups_strcasecmp(ext, ".urf") || !_cups_strcasecmp(ext, ".urf.gz"))
+ ippFileSetVar(data->parent, "filetype", "image/urf");
else if (!_cups_strcasecmp(ext, ".xps"))
- _ippVarsSet(data.vars, "filetype", "application/openxps");
+ ippFileSetVar(data->parent, "filetype", "application/openxps");
else
- _ippVarsSet(data.vars, "filetype", "application/octet-stream");
+ ippFileSetVar(data->parent, "filetype", "application/octet-stream");
}
else
{
- /*
- * Use the "auto-type" MIME media type...
- */
-
- _ippVarsSet(data.vars, "filetype", "application/octet-stream");
+ // Use the "auto-type" MIME media type...
+ ippFileSetVar(data->parent, "filetype", "application/octet-stream");
}
break;
- case 'h' : /* Validate response headers */
- data.validate_headers = 1;
+ case 'h' : // Validate response headers
+ data->validate_headers = 1;
break;
- case 'i' : /* Test every N seconds */
+ case 'i' : // Test every N seconds
i ++;
if (i >= argc)
}
}
- if ((data.output == IPPTOOL_OUTPUT_PLIST || data.output == IPPTOOL_OUTPUT_IPPSERVER) && interval)
+ if ((data->output == IPPTOOL_OUTPUT_PLIST || data->output == IPPTOOL_OUTPUT_IPPSERVER) && interval)
{
_cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\", and \"-X\"."));
usage();
}
break;
- case 'j' : /* JSON output */
- data.output = IPPTOOL_OUTPUT_JSON;
+ case 'j' : // JSON output
+ data->output = IPPTOOL_OUTPUT_JSON;
break;
- case 'l' : /* List as a table */
- data.output = IPPTOOL_OUTPUT_LIST;
+ case 'l' : // List as a table
+ data->output = IPPTOOL_OUTPUT_LIST;
break;
- case 'n' : /* Repeat count */
+ case 'n' : // Repeat count
i ++;
if (i >= argc)
else
repeat = atoi(argv[i]);
- if ((data.output == IPPTOOL_OUTPUT_PLIST || data.output == IPPTOOL_OUTPUT_IPPSERVER) && repeat)
+ if ((data->output == IPPTOOL_OUTPUT_PLIST || data->output == IPPTOOL_OUTPUT_IPPSERVER) && repeat)
{
_cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\", and \"-X\"."));
usage();
}
break;
- case 'q' : /* Be quiet */
- data.output = IPPTOOL_OUTPUT_QUIET;
+ case 'q' : // Be quiet
+ data->output = IPPTOOL_OUTPUT_QUIET;
break;
- case 't' : /* CUPS test output */
- data.output = IPPTOOL_OUTPUT_TEST;
+ case 't' : // CUPS test output
+ data->output = IPPTOOL_OUTPUT_TEST;
break;
- case 'v' : /* Be verbose */
- data.verbosity ++;
+ case 'v' : // Be verbose
+ data->verbosity ++;
break;
default :
_cupsLangPrintf(stderr, _("%s: Unknown option \"-%c\"."), "ipptool", *opt);
+ free_data(data);
usage();
}
}
}
else if (!strncmp(argv[i], "ipp://", 6) || !strncmp(argv[i], "http://", 7) || !strncmp(argv[i], "ipps://", 7) || !strncmp(argv[i], "https://", 8))
{
- /*
- * Set URI...
- */
-
- if (data.vars->uri)
+ // Set URI...
+ if (ippFileGetVar(data->parent, "uri"))
{
_cupsLangPuts(stderr, _("ipptool: May only specify a single URI."));
+ free_data(data);
usage();
}
if (!strncmp(argv[i], "ipps://", 7) || !strncmp(argv[i], "https://", 8))
- data.encryption = HTTP_ENCRYPTION_ALWAYS;
+ data->encryption = HTTP_ENCRYPTION_ALWAYS;
- if (!_ippVarsSet(data.vars, "uri", argv[i]))
+ if (!ippFileSetVar(data->parent, "uri", argv[i]))
{
_cupsLangPrintf(stderr, _("ipptool: Bad URI \"%s\"."), argv[i]);
+ free_data(data);
return (1);
}
- if (data.vars->username[0] && data.vars->password)
- cupsSetPasswordCB2(_ippVarsPasswordCB, data.vars);
+ if (ippFileGetVar(data->parent, "uriuser") && ippFileGetVar(data->parent, "uripassword"))
+ cupsSetPasswordCB2(password_cb, data->parent);
}
else
{
- /*
- * Run test...
- */
-
- if (!data.vars->uri)
+ // Run test...
+ if (!ippFileGetVar(data->parent, "uri"))
{
_cupsLangPuts(stderr, _("ipptool: URI required before test file."));
_cupsLangPuts(stderr, argv[i]);
+ free_data(data);
usage();
}
if (access(argv[i], 0) && argv[i][0] != '/'
#ifdef _WIN32
&& (!isalpha(argv[i][0] & 255) || argv[i][1] != ':')
-#endif /* _WIN32 */
+#endif // _WIN32
)
{
snprintf(testname, sizeof(testname), "%s/ipptool/%s", cg->cups_datadir, argv[i]);
_cupsLangPrintf(stderr, _("%s: Unable to open \"%s\": %s"), "ipptool", testfile, strerror(errno));
status = 1;
}
- else if (!do_tests(testfile, &data))
+ else if (!do_tests(testfile, data))
status = 1;
}
}
- if (!data.vars->uri || !testfile)
+ if (!ippFileGetVar(data->parent, "uri") || !testfile)
+ {
+ free_data(data);
usage();
+ }
- /*
- * Loop if the interval is set...
- */
-
- if (data.output == IPPTOOL_OUTPUT_PLIST)
- print_xml_trailer(&data, !status, NULL);
+ // Loop if the interval is set...
+ if (data->output == IPPTOOL_OUTPUT_PLIST)
+ {
+ print_xml_trailer(data, !status, NULL);
+ }
else if (interval > 0 && repeat > 0)
{
while (repeat > 1)
{
usleep((useconds_t)interval);
- do_tests(testfile, &data);
+ do_tests(testfile, data);
repeat --;
}
}
for (;;)
{
usleep((useconds_t)interval);
- do_tests(testfile, &data);
+ do_tests(testfile, data);
}
}
- if ((data.output == IPPTOOL_OUTPUT_TEST || (data.output == IPPTOOL_OUTPUT_PLIST && data.outfile)) && data.test_count > 1)
+ if ((data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile)) && data->test_count > 1)
{
- /*
- * Show a summary report if there were multiple tests...
- */
-
- cupsFilePrintf(cupsFileStdout(), "\nSummary: %d tests, %d passed, %d failed, %d skipped\nScore: %d%%\n", data.test_count, data.pass_count, data.fail_count, data.skip_count, 100 * (data.pass_count + data.skip_count) / data.test_count);
+ // Show a summary report if there were multiple tests...
+ cupsFilePrintf(cupsFileStdout(), "\nSummary: %d tests, %d passed, %d failed, %d skipped\nScore: %d%%\n", data->test_count, data->pass_count, data->fail_count, data->skip_count, 100 * (data->pass_count + data->skip_count) / data->test_count);
}
- cupsFileClose(data.outfile);
-
- /*
- * Exit...
- */
+ cupsFileClose(data->outfile);
+ free_data(data);
+ // Exit...
return (status);
}
-/*
- * 'add_stringf()' - Add a formatted string to an array.
- */
+//
+// 'add_stringf()' - Add a formatted string to an array.
+//
static void
-add_stringf(cups_array_t *a, /* I - Array */
- const char *s, /* I - Printf-style format string */
- ...) /* I - Additional args as needed */
+add_stringf(cups_array_t *a, // I - Array
+ const char *s, // I - Printf-style format string
+ ...) // I - Additional args as needed
{
- char buffer[10240]; /* Format buffer */
- va_list ap; /* Argument pointer */
-
+ char buffer[10240]; // Format buffer
+ va_list ap; // Argument pointer
- /*
- * Don't bother is the array is NULL...
- */
+ // Don't bother is the array is NULL...
if (!a)
return;
- /*
- * Format the message...
- */
-
+ // Format the message...
va_start(ap, s);
vsnprintf(buffer, sizeof(buffer), s, ap);
va_end(ap);
- /*
- * Add it to the array...
- */
-
+ // Add it to the array...
cupsArrayAdd(a, buffer);
}
-/*
- * 'compare_uris()' - Compare two URIs...
- */
+//
+// 'alloc_data()' - Initialize and allocate test data.
+//
+
+static ipptool_test_t * // O - Test data
+alloc_data(void)
+{
+ ipptool_test_t *data; // Test data
+
+
+ if ((data = calloc(1, sizeof(ipptool_test_t))) == NULL)
+ {
+ _cupsLangPrintf(stderr, _("ipptool: Unable to allocate memory: %s"), strerror(errno));
+ exit(1);
+ }
+
+ data->parent = ippFileNew(/*parent*/NULL, /*attr_cb*/NULL, (ipp_ferror_cb_t)error_cb, data);
+ data->output = IPPTOOL_OUTPUT_LIST;
+ data->outfile = cupsFileStdout();
+ data->family = AF_UNSPEC;
+ data->def_transfer = IPPTOOL_TRANSFER_AUTO;
+ data->def_version = 20;
+ data->errors = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);
+ data->pass = true;
+ data->prev_pass = true;
+ data->request_id = (cupsGetRand() % 1000) * 137;
+ data->show_header = true;
+
+ ippFileSetVar(data->parent, "date-start", iso_date(ippTimeToDate(time(NULL))));
+
+ return (data);
+}
+
+
+//
+// 'clear_data()' - Clear per-test data...
+//
+
+static void
+clear_data(ipptool_test_t *data) // I - Test data
+{
+ int i; // Looping var
+ ipptool_expect_t *expect; // Current EXPECT
+
+
+ cupsArrayClear(data->errors);
+
+ for (i = 0; i < data->num_displayed; i ++)
+ free(data->displayed[i]);
+ data->num_displayed = 0;
+
+ for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++)
+ {
+ free(expect->name);
+ free(expect->of_type);
+ free(expect->same_count_as);
+ free(expect->if_defined);
+ free(expect->if_not_defined);
+ free(expect->with_value);
+ free(expect->define_match);
+ free(expect->define_no_match);
+ free(expect->define_value);
+ free(expect->display_match);
+ cupsArrayDelete(expect->with_mime_types);
+ free(expect->save_filespec);
+ }
+ data->num_expects = 0;
+
+ for (i = 0; i < data->num_statuses; i ++)
+ {
+ free(data->statuses[i].if_defined);
+ free(data->statuses[i].if_not_defined);
+ free(data->statuses[i].define_match);
+ free(data->statuses[i].define_no_match);
+ free(data->statuses[i].define_value);
+ }
+ data->num_statuses = 0;
+
+ free(data->monitor_uri);
+ data->monitor_uri = NULL;
+
+ for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++)
+ {
+ free(expect->name);
+ free(expect->of_type);
+ free(expect->same_count_as);
+ free(expect->if_defined);
+ free(expect->if_not_defined);
+ free(expect->with_value);
+ free(expect->define_match);
+ free(expect->define_no_match);
+ free(expect->define_value);
+ free(expect->display_match);
+ }
+ data->num_monitor_expects = 0;
+
+ free(data->generate_params);
+ data->generate_params = NULL;
+}
+
+
+//
+// 'compare_uris()' - Compare two URIs...
+//
-static int /* O - Result of comparison */
-compare_uris(const char *a, /* I - First URI */
- const char *b) /* I - Second URI */
+static int // O - Result of comparison
+compare_uris(const char *a, // I - First URI
+ const char *b) // I - Second URI
{
- char ascheme[32], /* Components of first URI */
+ char ascheme[32], // Components of first URI
auserpass[256],
ahost[256],
aresource[256];
int aport;
- char bscheme[32], /* Components of second URI */
+ char bscheme[32], // Components of second URI
buserpass[256],
bhost[256],
bresource[256];
int bport;
- char *ptr; /* Pointer into string */
- int result; /* Result of comparison */
-
+ char *ptr; // Pointer into string
+ int result; // Result of comparison
- /*
- * Separate the URIs into their components...
- */
+ // Separate the URIs into their components...
if (httpSeparateURI(HTTP_URI_CODING_ALL, a, ascheme, sizeof(ascheme), auserpass, sizeof(auserpass), ahost, sizeof(ahost), &aport, aresource, sizeof(aresource)) < HTTP_URI_STATUS_OK)
return (-1);
if (httpSeparateURI(HTTP_URI_CODING_ALL, b, bscheme, sizeof(bscheme), buserpass, sizeof(buserpass), bhost, sizeof(bhost), &bport, bresource, sizeof(bresource)) < HTTP_URI_STATUS_OK)
return (-1);
- /*
- * Strip trailing dots from the host components, if present...
- */
-
+ // Strip trailing dots from the host components, if present...
if ((ptr = ahost + strlen(ahost) - 1) > ahost && *ptr == '.')
*ptr = '\0';
if ((ptr = bhost + strlen(bhost) - 1) > bhost && *ptr == '.')
*ptr = '\0';
- /*
- * Compare each component...
- */
-
+ // Compare each component...
if ((result = _cups_strcasecmp(ascheme, bscheme)) != 0)
return (result);
}
-/*
- * 'copy_hex_string()' - Copy an octetString to a C string and encode as hex if
- * needed.
- */
+//
+// 'connect_printer()' - Connect to the printer.
+//
+
+static http_t * // O - HTTP connection or `NULL` on error
+connect_printer(ipptool_test_t *data) // I - Test data
+{
+ const char *scheme = ippFileGetVar(data->parent, "scheme"),
+ *hostname = ippFileGetVar(data->parent, "hostname"),
+ *port = ippFileGetVar(data->parent, "port");
+ // URI fields
+ http_encryption_t encryption; // Encryption mode
+ http_t *http; // HTTP connection
+
+
+ if (!scheme || !hostname || !port)
+ {
+ // This should never happen, but just in case...
+ print_fatal_error(data, "Missing printer/system URI.");
+ return (NULL);
+ }
+
+ if (!_cups_strcasecmp(scheme, "https") || !_cups_strcasecmp(scheme, "ipps") || atoi(port) == 443)
+ encryption = HTTP_ENCRYPTION_ALWAYS;
+ else
+ encryption = data->encryption;
+
+ if ((http = httpConnect2(hostname, atoi(port), NULL, data->family, encryption, 1, 30000, NULL)) == NULL)
+ {
+ print_fatal_error(data, "Unable to connect to '%s' on port %s: %s", hostname, port, cupsGetErrorString());
+ return (NULL);
+ }
+
+ httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
+
+ if (data->timeout > 0.0)
+ httpSetTimeout(http, data->timeout, timeout_cb, NULL);
+
+ return (http);
+}
+
+
+//
+// 'copy_hex_string()' - Copy an octetString to a C string and encode as hex if
+// needed.
+//
static void
-copy_hex_string(char *buffer, /* I - String buffer */
- unsigned char *data, /* I - octetString data */
- int datalen, /* I - octetString length */
- size_t bufsize) /* I - Size of string buffer */
+copy_hex_string(char *buffer, // I - String buffer
+ unsigned char *data, // I - octetString data
+ int datalen, // I - octetString length
+ size_t bufsize) // I - Size of string buffer
{
- char *bufptr, /* Pointer into string buffer */
+ char *bufptr, // Pointer into string buffer
*bufend = buffer + bufsize - 2;
- /* End of string buffer */
- unsigned char *dataptr, /* Pointer into octetString data */
+ // End of string buffer
+ unsigned char *dataptr, // Pointer into octetString data
*dataend = data + datalen;
- /* End of octetString data */
+ // End of octetString data
static const char *hexdigits = "0123456789ABCDEF";
- /* Hex digits */
+ // Hex digits
- /*
- * First see if there are any non-ASCII bytes in the octetString...
- */
-
+ // First see if there are any non-ASCII bytes in the octetString...
for (dataptr = data; dataptr < dataend; dataptr ++)
+ {
if (*dataptr < 0x20 || *dataptr >= 0x7f)
break;
+ }
if (dataptr < dataend)
{
- /*
- * Yes, encode as hex...
- */
-
+ // Yes, encode as hex...
*buffer = '<';
for (bufptr = buffer + 1, dataptr = data; bufptr < bufend && dataptr < dataend; dataptr ++)
}
else
{
- /*
- * No, copy as a string...
- */
-
+ // No, copy as a string...
if ((size_t)datalen > bufsize)
datalen = (int)bufsize - 1;
}
-/*
- * 'do_monitor_printer_state()' - Do the MONITOR-PRINTER-STATE tests in the background.
- */
+//
+// 'create_file()' - Create a file for content checks.
+//
+
+static int // O - File descriptor or -1 on error
+create_file(const char *filespec, // I - Filespec string or NULL
+ const char *resource, // I - Resource name
+ int idx, // I - Value index
+ char *filename, // I - Filename buffer
+ size_t filenamesize) // I - Filename buffer size
+{
+ char *ptr, // Pointer into filename
+ *end, // End of filename buffer
+ base_resource[256], // Base name for resource
+ *base_ext; // Extension for resource
+
+
+ // If there is no filespec, just create a temporary file...
+ if (!filespec)
+ return (cupsCreateTempFd(NULL, NULL, filename, filenamesize));
+
+ // Convert resource path to base name...
+ if ((ptr = strrchr(resource, '/')) != NULL)
+ cupsCopyString(base_resource, ptr + 1, sizeof(base_resource));
+ else
+ cupsCopyString(base_resource, resource, sizeof(base_resource));
+
+ if ((base_ext = strrchr(base_resource, '.')) != NULL)
+ *base_ext++ = '\0';
+ else
+ base_ext = base_resource + strlen(base_resource);
+
+ // Format the filename...
+ for (ptr = filename, end = filename + filenamesize - 1; *filespec && ptr < end;)
+ {
+ if (!strncmp(filespec, "%basename%", 10))
+ {
+ cupsCopyString(ptr, base_resource, (size_t)(end - ptr + 1));
+ ptr += strlen(ptr);
+ filespec += 10;
+ }
+ else if (!strncmp(filespec, "%ext%", 5))
+ {
+ cupsCopyString(ptr, base_ext, (size_t)(end - ptr + 1));
+ ptr += strlen(ptr);
+ filespec += 5;
+ }
+ else if (!strncmp(filespec, "%index%", 7))
+ {
+ snprintf(ptr, (size_t)(end - ptr + 1), "%u", (unsigned)idx);
+ ptr += strlen(ptr);
+ filespec += 7;
+ }
+ else if (*filespec == '%')
+ {
+ filespec ++;
+
+ if (*filespec == '%')
+ *ptr++ = '%';
+
+ while (*filespec != '%')
+ filespec ++;
+
+ if (*filespec)
+ filespec ++;
+ }
+ else
+ {
+ // Copy literal character...
+ *ptr++ = *filespec++;
+ }
+ }
+
+ *ptr = '\0';
+
+ // Try creating the file...
+ return (open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666));
+}
+
+
+//
+// 'do_monitor_printer_state()' - Do the MONITOR-PRINTER-STATE tests in the background.
+//
static void * // O - Thread exit status
do_monitor_printer_state(
const char *pattrs[100]; // Printer attributes we care about
+ if (getenv("IPPTOOL_DEBUG"))
+ fprintf(stderr, "ipptool: Monitoring printer '%s' in the background.\n", data->monitor_uri);
+
// Connect to the printer...
if (httpSeparateURI(HTTP_URI_CODING_ALL, data->monitor_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
{
return (0);
}
-#ifdef HAVE_LIBZ
httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
-#else
- httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "identity");
-#endif /* HAVE_LIBZ */
if (data->timeout > 0.0)
httpSetTimeout(http, data->timeout, timeout_cb, NULL);
// Poll the printer state...
ippSetRequestId(request, ippGetRequestId(request) + 1);
- if ((status = cupsSendRequest(http, request, resource, ippLength(request))) != HTTP_STATUS_ERROR)
+ if ((status = cupsSendRequest(http, request, resource, ippGetLength(request))) != HTTP_STATUS_ERROR)
{
response = cupsGetResponse(http, resource);
status = httpGetStatus(http);
}
- if (!data->monitor_done && !Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL &&
+ if (!data->monitor_done && !Cancel && status == HTTP_STATUS_ERROR && httpGetError(data->http) != EINVAL &&
#ifdef _WIN32
- httpError(data->http) != WSAETIMEDOUT)
+ httpGetError(data->http) != WSAETIMEDOUT)
#else
- httpError(data->http) != ETIMEDOUT)
+ httpGetError(data->http) != ETIMEDOUT)
#endif // _WIN32
{
- if (httpReconnect2(http, 30000, NULL))
+ if (!httpReconnect2(http, 30000, NULL))
break;
}
else if (status == HTTP_STATUS_ERROR || status == HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED)
for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++)
{
- if (expect->if_defined && !_ippVarsGet(data->vars, expect->if_defined))
+ if (expect->if_defined && !ippFileGetVar(data->parent, expect->if_defined))
continue;
- if (expect->if_not_defined && _ippVarsGet(data->vars, expect->if_not_defined))
+ if (expect->if_not_defined && ippFileGetVar(data->parent, expect->if_not_defined))
continue;
found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO);
{
if (expect->define_no_match)
{
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
data->monitor_done = 1;
}
break;
{
if (expect->define_no_match)
{
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
data->monitor_done = 1;
}
break;
{
if (expect->define_no_match)
{
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
data->monitor_done = 1;
}
break;
if (found && expect->define_match)
{
- _ippVarsSet(data->vars, expect->define_match, "1");
+ ippFileSetVar(data->parent, expect->define_match, "1");
data->monitor_done = 1;
}
}
}
- _ippVarsSet(data->vars, expect->define_value, buffer);
+ ippFileSetVar(data->parent, expect->define_value, buffer);
data->monitor_done = 1;
}
}
}
-/*
- * 'do_test()' - Do a single test from the test file.
- */
+//
+// 'do_test()' - Do a single test from the test file.
+//
-static int /* O - 1 on success, 0 on failure */
-do_test(_ipp_file_t *f, /* I - IPP data file */
- ipptool_test_t *data) /* I - Test data */
+static bool // O - `true` on success, `false` on failure
+do_test(ipp_file_t *f, // I - IPP data file
+ ipptool_test_t *data) // I - Test data
{
- int i, /* Looping var */
- status_ok, /* Did we get a matching status? */
- repeat_count = 0, /* Repeat count */
- repeat_test; /* Repeat the test? */
- ipptool_expect_t *expect; /* Current expected attribute */
- ipp_t *request, /* IPP request */
- *response; /* IPP response */
- size_t length; /* Length of IPP request */
- http_status_t status; /* HTTP status */
- cups_array_t *a; /* Duplicate attribute array */
- ipp_tag_t group; /* Current group */
- ipp_attribute_t *attrptr, /* Attribute pointer */
- *found; /* Found attribute */
- char temp[1024]; /* Temporary string */
- cups_file_t *reqfile; /* File to send */
- ssize_t bytes; /* Bytes read/written */
- char buffer[1024 * 1024]; /* Copy buffer */
- size_t widths[200]; /* Width of columns */
- const char *error; /* Current error */
+ int i; // Looping var
+ bool status_ok; // Did we get a matching status?
+ int repeat_count = 0; // Repeat count
+ bool repeat_test; // Repeat the test?
+ ipptool_expect_t *expect; // Current expected attribute
+ ipp_t *request, // IPP request
+ *response; // IPP response
+ size_t length; // Length of IPP request
+ http_status_t status; // HTTP status
+ cups_array_t *a; // Duplicate attribute array
+ ipp_tag_t group; // Current group
+ ipp_attribute_t *attrptr, // Attribute pointer
+ *found; // Found attribute
+ char temp[1024]; // Temporary string
+ cups_file_t *reqfile; // File to send
+ ssize_t bytes; // Bytes read/written
+ int widths[200]; // Width of columns
+ const char *error; // Current error
if (Cancel)
- return (0);
+ return (false);
- /*
- * Show any PAUSE message, as needed...
- */
+ if (getenv("IPPTOOL_DEBUG"))
+ fprintf(stderr, "ipptool: Doing test '%s', num_expects=%u, num_statuses=%u.\n", data->name, (unsigned)data->num_expects, (unsigned)data->num_statuses);
+ // Show any PAUSE message, as needed...
if (data->pause[0])
{
if (!data->skip_test && !data->pass_test)
data->pause[0] = '\0';
}
- /*
- * Start the background thread as needed...
- */
-
+ // Start the background thread as needed...
if (data->monitor_uri)
{
- data->monitor_done = 0;
+ data->monitor_done = false;
data->monitor_thread = cupsThreadCreate((cups_thread_func_t)do_monitor_printer_state, data);
}
- /*
- * Take over control of the attributes in the request...
- */
-
- request = f->attrs;
- f->attrs = NULL;
-
- /*
- * Submit the IPP request...
- */
+ // Take over control of the attributes in the request...
+ request = ippFileGetAttributes(f);
+ ippFileSetAttributes(f, NULL);
+ // Submit the IPP request...
data->test_count ++;
+ ippSetOperation(request, data->op);
ippSetVersion(request, data->version / 10, data->version % 10);
ippSetRequestId(request, data->request_id);
cupsFilePrintf(data->outfile, "<integer>%d</integer>\n", data->request_id);
cupsFilePuts(data->outfile, "<key>RequestAttributes</key>\n");
cupsFilePuts(data->outfile, "<array>\n");
- if (ippFirstAttribute(request))
+ if (ippGetFirstAttribute(request))
{
cupsFilePuts(data->outfile, "<dict>\n");
- for (attrptr = ippFirstAttribute(request), group = ippGetGroupTag(attrptr); attrptr; attrptr = ippNextAttribute(request))
+ for (attrptr = ippGetFirstAttribute(request), group = ippGetGroupTag(attrptr); attrptr; attrptr = ippGetNextAttribute(request))
print_attr(data->outfile, data->output, attrptr, &group);
cupsFilePuts(data->outfile, "</dict>\n");
}
{
cupsFilePrintf(cupsFileStdout(), " %s:\n", ippOpString(ippGetOperation(request)));
- for (attrptr = ippFirstAttribute(request); attrptr; attrptr = ippNextAttribute(request))
+ for (attrptr = ippGetFirstAttribute(request); attrptr; attrptr = ippGetNextAttribute(request))
print_attr(cupsFileStdout(), IPPTOOL_OUTPUT_TEST, attrptr, NULL);
}
goto skip_error;
}
- data->vars->password_tries = 0;
+ data->password_tries = 0;
do
{
if (data->delay > 0)
usleep(data->delay);
+ if (getenv("IPPTOOL_DEBUG"))
+ fprintf(stderr, "ipptool: Sending %s request to '%s'.\n", ippOpString(ippGetOperation(request)), data->resource);
+
data->delay = data->repeat_interval;
repeat_count ++;
status = HTTP_STATUS_OK;
- if (data->transfer == IPPTOOL_TRANSFER_CHUNKED || (data->transfer == IPPTOOL_TRANSFER_AUTO && data->file[0]))
+ if (data->transfer == IPPTOOL_TRANSFER_CHUNKED || (data->transfer == IPPTOOL_TRANSFER_AUTO && (data->file[0] || data->generate_params)))
{
- /*
- * Send request using chunking - a 0 length means "chunk".
- */
-
+ // Send request using chunking - a 0 length means "chunk".
length = 0;
}
else
{
- /*
- * Send request using content length...
- */
-
- length = ippLength(request);
+ // Send request using content length...
+ length = ippGetLength(request);
if (data->file[0] && (reqfile = cupsFileOpen(data->file, "r")) != NULL)
{
- /*
- * Read the file to get the uncompressed file size...
- */
-
- while ((bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
+ // Read the file to get the uncompressed file size...
+ while ((bytes = cupsFileRead(reqfile, data->buffer, sizeof(data->buffer))) > 0)
length += (size_t)bytes;
cupsFileClose(reqfile);
}
}
- /*
- * Send the request...
- */
-
- data->prev_pass = 1;
- repeat_test = 0;
+ // Send the request...
+ data->prev_pass = true;
+ repeat_test = false;
response = NULL;
if (status != HTTP_STATUS_ERROR)
status = cupsSendRequest(data->http, request, data->resource, length);
-#ifdef HAVE_LIBZ
if (data->compression[0])
httpSetField(data->http, HTTP_FIELD_CONTENT_ENCODING, data->compression);
-#endif /* HAVE_LIBZ */
- if (!Cancel && status == HTTP_STATUS_CONTINUE && ippGetState(request) == IPP_DATA && data->file[0])
+ if (!Cancel && status == HTTP_STATUS_CONTINUE && ippGetState(request) == IPP_STATE_DATA && data->file[0])
{
+ // Send attached file...
if ((reqfile = cupsFileOpen(data->file, "r")) != NULL)
{
- while (!Cancel && (bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
+ while (!Cancel && (bytes = cupsFileRead(reqfile, data->buffer, sizeof(data->buffer))) > 0)
{
- if ((status = cupsWriteRequestData(data->http, buffer, (size_t)bytes)) != HTTP_STATUS_CONTINUE)
+ if ((status = cupsWriteRequestData(data->http, data->buffer, (size_t)bytes)) != HTTP_STATUS_CONTINUE)
break;
}
}
else
{
- snprintf(buffer, sizeof(buffer), "%s: %s", data->file, strerror(errno));
- _cupsSetError(IPP_INTERNAL_ERROR, buffer, 0);
+ snprintf(data->buffer, sizeof(data->buffer), "%s: %s", data->file, strerror(errno));
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, data->buffer, 0);
status = HTTP_STATUS_ERROR;
}
}
+ else if (!Cancel && status == HTTP_STATUS_CONTINUE && ippGetState(request) == IPP_STATE_DATA && data->generate_params)
+ {
+ // Generate attached file...
+ status = generate_file(data->http, data->generate_params);
+ }
- /*
- * Get the server's response...
- */
-
+ // Get the server's response...
if (!Cancel && status != HTTP_STATUS_ERROR)
{
response = cupsGetResponse(data->http, data->resource);
status = httpGetStatus(data->http);
}
- if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL &&
+ if (!Cancel && status == HTTP_STATUS_ERROR && httpGetError(data->http) != EINVAL &&
#ifdef _WIN32
- httpError(data->http) != WSAETIMEDOUT)
+ httpGetError(data->http) != WSAETIMEDOUT)
#else
- httpError(data->http) != ETIMEDOUT)
-#endif /* _WIN32 */
+ httpGetError(data->http) != ETIMEDOUT)
+#endif // _WIN32
{
- if (httpReconnect2(data->http, 30000, NULL))
- data->prev_pass = 0;
+ if (!httpReconnect2(data->http, 30000, NULL))
+ data->prev_pass = false;
}
else if (status == HTTP_STATUS_ERROR || status == HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED)
{
- data->prev_pass = 0;
+ data->prev_pass = false;
break;
}
else if (status != HTTP_STATUS_OK)
}
}
- if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL &&
+ if (!Cancel && status == HTTP_STATUS_ERROR && httpGetError(data->http) != EINVAL &&
#ifdef _WIN32
- httpError(data->http) != WSAETIMEDOUT)
+ httpGetError(data->http) != WSAETIMEDOUT)
#else
- httpError(data->http) != ETIMEDOUT)
-#endif /* _WIN32 */
+ httpGetError(data->http) != ETIMEDOUT)
+#endif // _WIN32
{
- if (httpReconnect2(data->http, 30000, NULL))
- data->prev_pass = 0;
+ if (!httpReconnect2(data->http, 30000, NULL))
+ data->prev_pass = false;
}
else if (status == HTTP_STATUS_ERROR)
{
if (!Cancel)
httpReconnect2(data->http, 30000, NULL);
- data->prev_pass = 0;
+ data->prev_pass = false;
}
else if (status != HTTP_STATUS_OK)
{
httpFlush(data->http);
- data->prev_pass = 0;
+ data->prev_pass = false;
}
- /*
- * Check results of request...
- */
-
+ // Check results of request...
cupsArrayClear(data->errors);
if (httpGetVersion(data->http) != HTTP_VERSION_1_1)
if (data->validate_headers)
{
- const char *header; /* HTTP header value */
+ const char *header; // HTTP header value
if ((header = httpGetField(data->http, HTTP_FIELD_CONTENT_TYPE)) == NULL || _cups_strcasecmp(header, "application/ipp"))
add_stringf(data->errors, "Bad HTTP Content-Type in response (%s)", header && *header ? header : "<missing>");
if (!response)
{
- /*
- * No response, log error...
- */
-
+ // No response, log error...
add_stringf(data->errors, "IPP request failed with status %s (%s)", ippErrorString(cupsGetError()), cupsGetErrorString());
}
else
{
- /*
- * Collect common attribute values...
- */
-
+ // Collect common attribute values...
if ((attrptr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL)
{
snprintf(temp, sizeof(temp), "%d", ippGetInteger(attrptr, 0));
- _ippVarsSet(data->vars, "job-id", temp);
+ ippFileSetVar(data->parent, "job-id", temp);
}
if ((attrptr = ippFindAttribute(response, "job-uri", IPP_TAG_URI)) != NULL)
- _ippVarsSet(data->vars, "job-uri", ippGetString(attrptr, 0, NULL));
+ ippFileSetVar(data->parent, "job-uri", ippGetString(attrptr, 0, NULL));
if ((attrptr = ippFindAttribute(response, "notify-subscription-id", IPP_TAG_INTEGER)) != NULL)
{
snprintf(temp, sizeof(temp), "%d", ippGetInteger(attrptr, 0));
- _ippVarsSet(data->vars, "notify-subscription-id", temp);
+ ippFileSetVar(data->parent, "notify-subscription-id", temp);
}
- /*
- * Check response, validating groups and attributes and logging errors
- * as needed...
- */
-
- if (ippGetState(response) != IPP_DATA)
+ // Check response, validating groups and attributes and logging errors as needed...
+ if (ippGetState(response) != IPP_STATE_DATA)
add_stringf(data->errors, "Missing end-of-attributes-tag in response (RFC 2910 section 3.5.1)");
if (data->version)
{
- int major, minor; /* IPP version */
+ int major, minor; // IPP version
major = ippGetVersion(response, &minor);
if (ippGetRequestId(response) != data->request_id)
add_stringf(data->errors, "Bad request ID %d in response - expected %d (RFC 8011 section 4.1.1)", ippGetRequestId(response), data->request_id);
- attrptr = ippFirstAttribute(response);
+ attrptr = ippGetFirstAttribute(response);
if (!attrptr)
{
add_stringf(data->errors, "Missing first attribute \"attributes-charset (charset)\" in group operation-attributes-tag (RFC 8011 section 4.1.4).");
if (!ippGetName(attrptr) || ippGetValueTag(attrptr) != IPP_TAG_CHARSET || ippGetGroupTag(attrptr) != IPP_TAG_OPERATION || ippGetCount(attrptr) != 1 ||strcmp(ippGetName(attrptr), "attributes-charset"))
add_stringf(data->errors, "Bad first attribute \"%s (%s%s)\" in group %s, expected \"attributes-charset (charset)\" in group operation-attributes-tag (RFC 8011 section 4.1.4).", ippGetName(attrptr) ? ippGetName(attrptr) : "(null)", ippGetCount(attrptr) > 1 ? "1setOf " : "", ippTagString(ippGetValueTag(attrptr)), ippTagString(ippGetGroupTag(attrptr)));
- attrptr = ippNextAttribute(response);
+ attrptr = ippGetNextAttribute(response);
if (!attrptr)
add_stringf(data->errors, "Missing second attribute \"attributes-natural-language (naturalLanguage)\" in group operation-attributes-tag (RFC 8011 section 4.1.4).");
else if (!ippGetName(attrptr) || ippGetValueTag(attrptr) != IPP_TAG_LANGUAGE || ippGetGroupTag(attrptr) != IPP_TAG_OPERATION || ippGetCount(attrptr) != 1 || strcmp(ippGetName(attrptr), "attributes-natural-language"))
if ((attrptr = ippFindAttribute(response, "status-message", IPP_TAG_ZERO)) != NULL)
{
const char *status_message = ippGetString(attrptr, 0, NULL);
- /* String value */
+ // String value
if (ippGetValueTag(attrptr) != IPP_TAG_TEXT)
add_stringf(data->errors, "status-message (text(255)) has wrong value tag %s (RFC 8011 section 4.1.6.2).", ippTagString(ippGetValueTag(attrptr)));
if (ippGetGroupTag(attrptr) != IPP_TAG_OPERATION)
add_stringf(data->errors, "status-message (text(255)) has wrong group tag %s (RFC 8011 section 4.1.6.2).", ippTagString(ippGetGroupTag(attrptr)));
if (ippGetCount(attrptr) != 1)
- add_stringf(data->errors, "status-message (text(255)) has %d values (RFC 8011 section 4.1.6.2).", ippGetCount(attrptr));
+ add_stringf(data->errors, "status-message (text(255)) has %u values (RFC 8011 section 4.1.6.2).", (unsigned)ippGetCount(attrptr));
if (status_message && strlen(status_message) > 255)
- add_stringf(data->errors, "status-message (text(255)) has bad length %d (RFC 8011 section 4.1.6.2).", (int)strlen(status_message));
+ add_stringf(data->errors, "status-message (text(255)) has bad length %u (RFC 8011 section 4.1.6.2).", (unsigned)strlen(status_message));
}
if ((attrptr = ippFindAttribute(response, "detailed-status-message",
IPP_TAG_ZERO)) != NULL)
{
const char *detailed_status_message = ippGetString(attrptr, 0, NULL);
- /* String value */
+ // String value
if (ippGetValueTag(attrptr) != IPP_TAG_TEXT)
add_stringf(data->errors, "detailed-status-message (text(MAX)) has wrong value tag %s (RFC 8011 section 4.1.6.3).", ippTagString(ippGetValueTag(attrptr)));
if (ippGetGroupTag(attrptr) != IPP_TAG_OPERATION)
add_stringf(data->errors, "detailed-status-message (text(MAX)) has wrong group tag %s (RFC 8011 section 4.1.6.3).", ippTagString(ippGetGroupTag(attrptr)));
if (ippGetCount(attrptr) != 1)
- add_stringf(data->errors, "detailed-status-message (text(MAX)) has %d values (RFC 8011 section 4.1.6.3).", ippGetCount(attrptr));
+ add_stringf(data->errors, "detailed-status-message (text(MAX)) has %u values (RFC 8011 section 4.1.6.3).", (unsigned)ippGetCount(attrptr));
if (detailed_status_message && strlen(detailed_status_message) > 1023)
- add_stringf(data->errors, "detailed-status-message (text(MAX)) has bad length %d (RFC 8011 section 4.1.6.3).", (int)strlen(detailed_status_message));
+ add_stringf(data->errors, "detailed-status-message (text(MAX)) has bad length %u (RFC 8011 section 4.1.6.3).", (unsigned)strlen(detailed_status_message));
}
- a = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+ a = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
- for (attrptr = ippFirstAttribute(response), group = ippGetGroupTag(attrptr);
+ for (attrptr = ippGetFirstAttribute(response), group = ippGetGroupTag(attrptr);
attrptr;
- attrptr = ippNextAttribute(response))
+ attrptr = ippGetNextAttribute(response))
{
if (ippGetGroupTag(attrptr) != group)
{
- int out_of_order = 0; /* Are attribute groups out-of-order? */
+ bool out_of_order = false; // Are attribute groups out-of-order?
cupsArrayClear(a);
switch (ippGetGroupTag(attrptr))
break;
case IPP_TAG_OPERATION :
- out_of_order = 1;
+ out_of_order = true;
break;
case IPP_TAG_UNSUPPORTED_GROUP :
if (group != IPP_TAG_OPERATION)
- out_of_order = 1;
+ out_of_order = true;
break;
case IPP_TAG_JOB :
case IPP_TAG_PRINTER :
if (group != IPP_TAG_OPERATION && group != IPP_TAG_UNSUPPORTED_GROUP)
- out_of_order = 1;
+ out_of_order = true;
break;
case IPP_TAG_SUBSCRIPTION :
if (group > ippGetGroupTag(attrptr) && group != IPP_TAG_DOCUMENT)
- out_of_order = 1;
+ out_of_order = true;
break;
default :
if (group > ippGetGroupTag(attrptr))
- out_of_order = 1;
+ out_of_order = true;
break;
}
cupsArrayDelete(a);
- /*
- * Now check the test-defined expected status-code and attribute
- * values...
- */
-
+ // Now check the test-defined expected status-code and attribute values...
if (ippGetStatusCode(response) == IPP_STATUS_ERROR_BUSY && data->repeat_on_busy)
{
// Repeat on a server-error-busy status code...
- status_ok = 1;
- repeat_test = 1;
+ status_ok = true;
+ repeat_test = true;
}
else
{
- for (i = 0, status_ok = 0; i < data->num_statuses; i ++)
+ for (i = 0, status_ok = false; i < data->num_statuses; i ++)
{
- if (data->statuses[i].if_defined &&
- !_ippVarsGet(data->vars, data->statuses[i].if_defined))
+ if (data->statuses[i].if_defined && !ippFileGetVar(f, data->statuses[i].if_defined))
continue;
- if (data->statuses[i].if_not_defined &&
- _ippVarsGet(data->vars, data->statuses[i].if_not_defined))
+ if (data->statuses[i].if_not_defined && ippFileGetVar(f, data->statuses[i].if_not_defined))
continue;
if (ippGetStatusCode(response) == data->statuses[i].status)
{
- status_ok = 1;
+ status_ok = true;
if (data->statuses[i].repeat_match && repeat_count < data->statuses[i].repeat_limit)
- repeat_test = 1;
+ repeat_test = true;
if (data->statuses[i].define_match)
- _ippVarsSet(data->vars, data->statuses[i].define_match, "1");
+ ippFileSetVar(data->parent, data->statuses[i].define_match, "1");
}
else
{
if (data->statuses[i].repeat_no_match && repeat_count < data->statuses[i].repeat_limit)
- repeat_test = 1;
+ repeat_test = true;
if (data->statuses[i].define_no_match)
{
- _ippVarsSet(data->vars, data->statuses[i].define_no_match, "1");
- status_ok = 1;
+ ippFileSetVar(data->parent, data->statuses[i].define_no_match, "1");
+ status_ok = true;
}
}
}
{
for (i = 0; i < data->num_statuses; i ++)
{
- if (data->statuses[i].if_defined &&
- !_ippVarsGet(data->vars, data->statuses[i].if_defined))
+ if (data->statuses[i].if_defined && !ippFileGetVar(f, data->statuses[i].if_defined))
continue;
- if (data->statuses[i].if_not_defined &&
- _ippVarsGet(data->vars, data->statuses[i].if_not_defined))
+ if (data->statuses[i].if_not_defined && ippFileGetVar(f, data->statuses[i].if_not_defined))
continue;
if (!data->statuses[i].repeat_match || repeat_count >= data->statuses[i].repeat_limit)
for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++)
{
- ipp_attribute_t *group_found; /* Found parent attribute for group tests */
+ cups_array_t *exp_errors; // Temporary list of errors
+ bool exp_member, // Expect for member attribute?
+ exp_pass; // Did this expect pass?
+ ipp_attribute_t *group_found; // Found parent attribute for group tests
- if (expect->if_defined && !_ippVarsGet(data->vars, expect->if_defined))
+ if (expect->if_defined && !ippFileGetVar(f, expect->if_defined))
continue;
- if (expect->if_not_defined &&
- _ippVarsGet(data->vars, expect->if_not_defined))
+ if (expect->if_not_defined && ippFileGetVar(f, expect->if_not_defined))
continue;
if ((found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL && expect->in_group && expect->in_group != ippGetGroupTag(found))
break;
}
+ exp_errors = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);
+ exp_member = strchr(expect->name, '/') != NULL;
+ exp_pass = false;
+
do
{
group_found = found;
+ ippSave(response);
+
if (expect->in_group && strchr(expect->name, '/'))
{
- char group_name[256],/* Parent attribute name */
- *group_ptr; /* Pointer into parent attribute name */
+ char group_name[256],// Parent attribute name
+ *group_ptr; // Pointer into parent attribute name
cupsCopyString(group_name, expect->name, sizeof(group_name));
if ((group_ptr = strchr(group_name, '/')) != NULL)
(expect->with_distinct && !with_distinct_values(NULL, found)))
{
if (expect->define_no_match)
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ {
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
+ exp_pass = true;
+ }
else if (!expect->define_match && !expect->define_value)
{
if (found && expect->not_expect && !expect->with_value && !expect->with_value_from)
- add_stringf(data->errors, "NOT EXPECTED: %s", expect->name);
+ {
+ add_stringf(exp_errors, "NOT EXPECTED: %s", expect->name);
+ }
else if (!found && !(expect->not_expect || expect->optional))
- add_stringf(data->errors, "EXPECTED: %s", expect->name);
+ {
+ add_stringf(exp_errors, "EXPECTED: %s", expect->name);
+ }
else if (found)
{
if (!expect_matches(expect, found))
- add_stringf(data->errors, "EXPECTED: %s OF-TYPE %s (got %s)",
+ add_stringf(exp_errors, "EXPECTED: %s OF-TYPE %s (got %s)",
expect->name, expect->of_type,
ippTagString(ippGetValueTag(found)));
if (expect->in_group && ippGetGroupTag(group_found) != expect->in_group)
- add_stringf(data->errors, "EXPECTED: %s IN-GROUP %s (got %s).",
+ add_stringf(exp_errors, "EXPECTED: %s IN-GROUP %s (got %s).",
expect->name, ippTagString(expect->in_group),
ippTagString(ippGetGroupTag(group_found)));
if (expect->with_distinct)
- with_distinct_values(data->errors, found);
+ with_distinct_values(exp_errors, found);
}
}
if (expect->repeat_no_match && repeat_count < expect->repeat_limit)
- repeat_test = 1;
+ repeat_test = true;
+
+ ippRestore(response);
break;
}
if (found)
- ippAttributeString(found, buffer, sizeof(buffer));
+ ippAttributeString(found, data->buffer, sizeof(data->buffer));
+
+ if (found && (expect->with_content || expect->with_mime_types || expect->save_filespec) && !with_content(exp_errors, found, expect->with_content, expect->with_mime_types, expect->save_filespec))
+ {
+ if (expect->define_no_match)
+ {
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
+ exp_pass = true;
+ }
+ }
- if (found && expect->with_value_from && !with_value_from(NULL, ippFindAttribute(response, expect->with_value_from, IPP_TAG_ZERO), found, buffer, sizeof(buffer)))
+ if (found && expect->with_value_from && !with_value_from(NULL, ippFindAttribute(response, expect->with_value_from, IPP_TAG_ZERO), found, data->buffer, sizeof(data->buffer)))
{
if (expect->define_no_match)
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ {
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
+ exp_pass = true;
+ }
else if (!expect->define_match && !expect->define_value && ((!expect->repeat_match && !expect->repeat_no_match) || repeat_count >= expect->repeat_limit))
{
- add_stringf(data->errors, "EXPECTED: %s WITH-VALUES-FROM %s", expect->name, expect->with_value_from);
+ add_stringf(exp_errors, "EXPECTED: %s WITH-VALUES-FROM %s", expect->name, expect->with_value_from);
- with_value_from(data->errors, ippFindAttribute(response, expect->with_value_from, IPP_TAG_ZERO), found, buffer, sizeof(buffer));
+ with_value_from(exp_errors, ippFindAttribute(response, expect->with_value_from, IPP_TAG_ZERO), found, data->buffer, sizeof(data->buffer));
}
if (expect->repeat_no_match && repeat_count < expect->repeat_limit)
- repeat_test = 1;
+ repeat_test = true;
+ ippRestore(response);
break;
}
- else if (found && !with_value(data, NULL, expect->with_value, expect->with_flags, found, buffer, sizeof(buffer)))
+ else if (found && !with_value(data, NULL, expect->with_value, expect->with_flags, found, data->buffer, sizeof(data->buffer)))
{
if (expect->define_no_match)
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ {
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
+ exp_pass = true;
+ }
else if (!expect->define_match && !expect->define_value &&
!expect->repeat_match && (!expect->repeat_no_match || repeat_count >= expect->repeat_limit))
{
if (expect->with_flags & IPPTOOL_WITH_REGEX)
- add_stringf(data->errors, "EXPECTED: %s %s /%s/", expect->name, with_flags_string(expect->with_flags), expect->with_value);
+ add_stringf(exp_errors, "EXPECTED: %s %s /%s/", expect->name, with_flags_string(expect->with_flags), expect->with_value);
else
- add_stringf(data->errors, "EXPECTED: %s %s \"%s\"", expect->name, with_flags_string(expect->with_flags), expect->with_value);
+ add_stringf(exp_errors, "EXPECTED: %s %s \"%s\"", expect->name, with_flags_string(expect->with_flags), expect->with_value);
- with_value(data, data->errors, expect->with_value, expect->with_flags, found, buffer, sizeof(buffer));
+ with_value(data, exp_errors, expect->with_value, expect->with_flags, found, data->buffer, sizeof(data->buffer));
}
- if (expect->repeat_no_match &&
- repeat_count < expect->repeat_limit)
- repeat_test = 1;
+ if (expect->repeat_no_match && repeat_count < expect->repeat_limit)
+ repeat_test = true;
+ ippRestore(response);
break;
}
+ else if (expect->with_value)
+ {
+ exp_pass = true;
+ }
if (found && expect->count > 0 && ippGetCount(found) != expect->count)
{
if (expect->define_no_match)
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ {
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
+ exp_pass = true;
+ }
else if (!expect->define_match && !expect->define_value)
{
- add_stringf(data->errors, "EXPECTED: %s COUNT %d (got %d)", expect->name, expect->count, ippGetCount(found));
+ add_stringf(exp_errors, "EXPECTED: %s COUNT %u (got %u)", expect->name, (unsigned)expect->count, (unsigned)ippGetCount(found));
}
- if (expect->repeat_no_match &&
- repeat_count < expect->repeat_limit)
- repeat_test = 1;
+ if (expect->repeat_no_match && repeat_count < expect->repeat_limit)
+ repeat_test = true;
+ ippRestore(response);
break;
}
if (!attrptr || ippGetCount(attrptr) != ippGetCount(found))
{
if (expect->define_no_match)
- _ippVarsSet(data->vars, expect->define_no_match, "1");
+ {
+ ippFileSetVar(data->parent, expect->define_no_match, "1");
+ exp_pass = true;
+ }
else if (!expect->define_match && !expect->define_value)
{
if (!attrptr)
- add_stringf(data->errors, "EXPECTED: %s (%d values) SAME-COUNT-AS %s (not returned)", expect->name, ippGetCount(found), expect->same_count_as);
+ add_stringf(exp_errors, "EXPECTED: %s (%u values) SAME-COUNT-AS %s (not returned)", expect->name, (unsigned)ippGetCount(found), expect->same_count_as);
else if (ippGetCount(attrptr) != ippGetCount(found))
- add_stringf(data->errors, "EXPECTED: %s (%d values) SAME-COUNT-AS %s (%d values)", expect->name, ippGetCount(found), expect->same_count_as, ippGetCount(attrptr));
+ add_stringf(exp_errors, "EXPECTED: %s (%u values) SAME-COUNT-AS %s (%u values)", expect->name, (unsigned)ippGetCount(found), expect->same_count_as, (unsigned)ippGetCount(attrptr));
}
- if (expect->repeat_no_match &&
- repeat_count < expect->repeat_limit)
- repeat_test = 1;
+ if (expect->repeat_no_match && repeat_count < expect->repeat_limit)
+ repeat_test = true;
+ ippRestore(response);
break;
}
}
cupsFilePrintf(cupsFileStdout(), "\n%s\n\n", expect->display_match);
if (found && expect->define_match)
- _ippVarsSet(data->vars, expect->define_match, "1");
+ {
+ ippFileSetVar(data->parent, expect->define_match, "1");
+ exp_pass = true;
+ }
if (found && expect->define_value)
{
+ exp_pass = true;
if (!expect->with_value)
{
int last = ippGetCount(found) - 1;
- /* Last element in attribute */
+ // Last element in attribute
switch (ippGetValueTag(found))
{
case IPP_TAG_ENUM :
case IPP_TAG_INTEGER :
- snprintf(buffer, sizeof(buffer), "%d", ippGetInteger(found, last));
+ snprintf(data->buffer, sizeof(data->buffer), "%d", ippGetInteger(found, last));
break;
case IPP_TAG_BOOLEAN :
if (ippGetBoolean(found, last))
- cupsCopyString(buffer, "true", sizeof(buffer));
+ cupsCopyString(data->buffer, "true", sizeof(data->buffer));
else
- cupsCopyString(buffer, "false", sizeof(buffer));
+ cupsCopyString(data->buffer, "false", sizeof(data->buffer));
break;
case IPP_TAG_RESOLUTION :
{
- int xres, /* Horizontal resolution */
- yres; /* Vertical resolution */
- ipp_res_t units; /* Resolution units */
+ int xres, // Horizontal resolution
+ yres; // Vertical resolution
+ ipp_res_t units; // Resolution units
xres = ippGetResolution(found, last, &yres, &units);
if (xres == yres)
- snprintf(buffer, sizeof(buffer), "%d%s", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
+ snprintf(data->buffer, sizeof(data->buffer), "%d%s", xres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
else
- snprintf(buffer, sizeof(buffer), "%dx%d%s", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
+ snprintf(data->buffer, sizeof(data->buffer), "%dx%d%s", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
}
break;
case IPP_TAG_TEXTLANG :
case IPP_TAG_URI :
case IPP_TAG_URISCHEME :
- cupsCopyString(buffer, ippGetString(found, last, NULL), sizeof(buffer));
+ cupsCopyString(data->buffer, ippGetString(found, last, NULL), sizeof(data->buffer));
break;
default :
- ippAttributeString(found, buffer, sizeof(buffer));
+ ippAttributeString(found, data->buffer, sizeof(data->buffer));
break;
}
}
- _ippVarsSet(data->vars, expect->define_value, buffer);
+ ippFileSetVar(data->parent, expect->define_value, data->buffer);
}
- if (found && expect->repeat_match &&
- repeat_count < expect->repeat_limit)
+ if (found && expect->repeat_match && repeat_count < expect->repeat_limit)
repeat_test = 1;
+
+ ippRestore(response);
+ }
+ while ((expect->expect_all || !exp_member) && (found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL);
+
+ // Handle results of the EXPECT checks...
+ if (!exp_pass)
+ {
+ // Copy errors...
+ char *e; // Current error
+
+ for (e = (char *)cupsArrayGetFirst(exp_errors); e; e = (char *)cupsArrayGetNext(exp_errors))
+ cupsArrayAdd(data->errors, e);
}
- while (expect->expect_all && (found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL);
+
+ cupsArrayDelete(exp_errors);
}
}
- /*
- * If we are going to repeat this test, display intermediate results...
- */
-
+ // If we are going to repeat this test, display intermediate results...
if (repeat_test)
{
if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile != cupsFileStdout()))
\
if (data->num_displayed > 0)
{
- for (attrptr = ippFirstAttribute(response); attrptr; attrptr = ippNextAttribute(response))
+ for (attrptr = ippGetFirstAttribute(response); attrptr; attrptr = ippGetNextAttribute(response))
{
const char *attrname = ippGetName(attrptr);
if (attrname)
request = NULL;
- if (cupsArrayCount(data->errors) > 0)
- data->prev_pass = data->pass = 0;
+ if (cupsArrayGetCount(data->errors) > 0)
+ data->prev_pass = data->pass = false;
if (data->prev_pass)
data->pass_count ++;
cupsFilePuts(data->outfile, "<key>ResponseAttributes</key>\n");
cupsFilePuts(data->outfile, "<array>\n");
cupsFilePuts(data->outfile, "<dict>\n");
- for (attrptr = ippFirstAttribute(response), group = ippGetGroupTag(attrptr);
+ for (attrptr = ippGetFirstAttribute(response), group = ippGetGroupTag(attrptr);
attrptr;
- attrptr = ippNextAttribute(response))
+ attrptr = ippGetNextAttribute(response))
print_attr(data->outfile, data->output, attrptr, &group);
cupsFilePuts(data->outfile, "</dict>\n");
cupsFilePuts(data->outfile, "</array>\n");
}
else if (data->output == IPPTOOL_OUTPUT_IPPSERVER && response)
{
- for (attrptr = ippFirstAttribute(response); attrptr; attrptr = ippNextAttribute(response))
+ for (attrptr = ippGetFirstAttribute(response); attrptr; attrptr = ippGetNextAttribute(response))
{
if (!ippGetName(attrptr) || ippGetGroupTag(attrptr) != IPP_TAG_PRINTER)
continue;
}
else if (data->output == IPPTOOL_OUTPUT_JSON && response)
{
- ipp_tag_t cur_tag = IPP_TAG_ZERO, /* Current group tag */
- group_tag; /* Attribute's group tag */
+ ipp_tag_t cur_tag = IPP_TAG_ZERO, // Current group tag
+ group_tag; // Attribute's group tag
cupsFilePuts(data->outfile, "[\n");
- attrptr = ippFirstAttribute(response);
+ attrptr = ippGetFirstAttribute(response);
while (attrptr)
{
group_tag = ippGetGroupTag(attrptr);
}
print_json_attr(data, attrptr, 8);
- attrptr = ippNextAttribute(response);
+ attrptr = ippGetNextAttribute(response);
cupsFilePuts(data->outfile, ippGetName(attrptr) && ippGetGroupTag(attrptr) == cur_tag ? ",\n" : "\n");
}
else
{
- attrptr = ippNextAttribute(response);
+ attrptr = ippGetNextAttribute(response);
}
}
if (!data->prev_pass || (data->verbosity && response))
{
- cupsFilePrintf(cupsFileStdout(), " RECEIVED: %lu bytes in response\n", (unsigned long)ippLength(response));
+ cupsFilePrintf(cupsFileStdout(), " RECEIVED: %lu bytes in response\n", (unsigned long)ippGetLength(response));
cupsFilePrintf(cupsFileStdout(), " status-code = %s (%s)\n", ippErrorString(cupsGetError()), cupsGetErrorString());
if (data->verbosity && response)
{
- for (attrptr = ippFirstAttribute(response); attrptr; attrptr = ippNextAttribute(response))
+ for (attrptr = ippGetFirstAttribute(response); attrptr; attrptr = ippGetNextAttribute(response))
print_attr(cupsFileStdout(), IPPTOOL_OUTPUT_TEST, attrptr, NULL);
}
}
if (data->prev_pass && data->output >= IPPTOOL_OUTPUT_LIST && !data->verbosity && data->num_displayed > 0)
{
- size_t width; /* Length of value */
+ int width; // Length of value
for (i = 0; i < data->num_displayed; i ++)
{
- widths[i] = strlen(data->displayed[i]);
+ widths[i] = (int)strlen(data->displayed[i]);
for (attrptr = ippFindAttribute(response, data->displayed[i], IPP_TAG_ZERO);
attrptr;
attrptr = ippFindNextAttribute(response, data->displayed[i], IPP_TAG_ZERO))
{
- width = ippAttributeString(attrptr, NULL, 0);
+ width = (int)ippAttributeString(attrptr, NULL, 0);
if (width > widths[i])
widths[i] = width;
}
else
print_line(data, NULL, NULL, data->num_displayed, data->displayed, widths);
- attrptr = ippFirstAttribute(response);
+ attrptr = ippGetFirstAttribute(response);
while (attrptr)
{
while (attrptr && ippGetGroupTag(attrptr) <= IPP_TAG_OPERATION)
- attrptr = ippNextAttribute(response);
+ attrptr = ippGetNextAttribute(response);
if (attrptr)
{
attrptr = print_line(data, response, attrptr, data->num_displayed, data->displayed, widths);
while (attrptr && ippGetGroupTag(attrptr) > IPP_TAG_OPERATION)
- attrptr = ippNextAttribute(response);
+ attrptr = ippGetNextAttribute(response);
}
}
}
cupsFilePuts(data->outfile, "<key>Errors</key>\n");
cupsFilePuts(data->outfile, "<array>\n");
- for (error = (char *)cupsArrayFirst(data->errors);
+ for (error = (char *)cupsArrayGetFirst(data->errors);
error;
- error = (char *)cupsArrayNext(data->errors))
+ error = (char *)cupsArrayGetNext(data->errors))
print_xml_string(data->outfile, "string", error);
cupsFilePuts(data->outfile, "</array>\n");
if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile != cupsFileStdout()))
{
- for (error = (char *)cupsArrayFirst(data->errors);
+ for (error = (char *)cupsArrayGetFirst(data->errors);
error;
- error = (char *)cupsArrayNext(data->errors))
+ error = (char *)cupsArrayGetNext(data->errors))
cupsFilePrintf(cupsFileStdout(), " %s\n", error);
}
}
if (data->num_displayed > 0 && !data->verbosity && response && (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile != cupsFileStdout())))
{
- for (attrptr = ippFirstAttribute(response); attrptr; attrptr = ippNextAttribute(response))
+ for (attrptr = ippGetFirstAttribute(response); attrptr; attrptr = ippGetNextAttribute(response))
{
if (ippGetName(attrptr))
{
ippDelete(response);
response = NULL;
- for (i = 0; i < data->num_statuses; i ++)
+ clear_data(data);
+
+ return (data->ignore_errors || data->prev_pass);
+}
+
+
+//
+// 'do_tests()' - Do tests as specified in the test file.
+//
+
+static bool // O - `true` on success, `false` on failure
+do_tests(const char *testfile, // I - Test file to use
+ ipptool_test_t *data) // I - Test data
+{
+ ipp_file_t *file; // IPP data file
+
+
+ // Connect to the printer/server...
+ data->http = connect_printer(data);
+
+ // Run tests...
+ if ((file = ippFileNew(data->parent, NULL, (ipp_ferror_cb_t)error_cb, data)) == NULL)
{
- free(data->statuses[i].if_defined);
- free(data->statuses[i].if_not_defined);
- free(data->statuses[i].define_match);
- free(data->statuses[i].define_no_match);
+ print_fatal_error(data, "Unable to create test file parser: %s", cupsGetErrorString());
+ return (false);
}
- data->num_statuses = 0;
- for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++)
+ if (!ippFileOpen(file, testfile, "r"))
{
- free(expect->name);
- free(expect->of_type);
- free(expect->same_count_as);
- free(expect->if_defined);
- free(expect->if_not_defined);
- free(expect->with_value);
- free(expect->define_match);
- free(expect->define_no_match);
- free(expect->define_value);
- free(expect->display_match);
+ print_fatal_error(data, "Unable to open '%s': %s", testfile, cupsGetErrorString());
+ return (false);
}
- data->num_expects = 0;
- for (i = 0; i < data->num_displayed; i ++)
- free(data->displayed[i]);
- data->num_displayed = 0;
-
- free(data->monitor_uri);
- data->monitor_uri = NULL;
-
- for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++)
- {
- free(expect->name);
- free(expect->of_type);
- free(expect->same_count_as);
- free(expect->if_defined);
- free(expect->if_not_defined);
- free(expect->with_value);
- free(expect->define_match);
- free(expect->define_no_match);
- free(expect->define_value);
- free(expect->display_match);
- }
- data->num_monitor_expects = 0;
-
- return (data->ignore_errors || data->prev_pass);
-}
-
-
-/*
- * 'do_tests()' - Do tests as specified in the test file.
- */
-
-static int /* O - 1 on success, 0 on failure */
-do_tests(const char *testfile, /* I - Test file to use */
- ipptool_test_t *data) /* I - Test data */
-{
- http_encryption_t encryption; /* Encryption mode */
-
-
- /*
- * Connect to the printer/server...
- */
-
- if (!_cups_strcasecmp(data->vars->scheme, "https") || !_cups_strcasecmp(data->vars->scheme, "ipps") || data->vars->port == 443)
- encryption = HTTP_ENCRYPTION_ALWAYS;
- else
- encryption = data->encryption;
+ ippFileRead(file, (ipp_ftoken_cb_t)token_cb, true);
- if ((data->http = httpConnect2(data->vars->host, data->vars->port, NULL, data->family, encryption, 1, 30000, NULL)) == NULL)
- {
- print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", data->vars->host, data->vars->port, cupsGetErrorString());
- return (0);
- }
-
-#ifdef HAVE_LIBZ
- httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
-#else
- httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "identity");
-#endif /* HAVE_LIBZ */
-
- if (data->timeout > 0.0)
- httpSetTimeout(data->http, data->timeout, timeout_cb, NULL);
-
- /*
- * Run tests...
- */
-
- _ippFileParse(data->vars, testfile, (void *)data);
-
- /*
- * Close connection and return...
- */
+ ippFileDelete(file);
+ // Close connection and return...
httpClose(data->http);
data->http = NULL;
}
-/*
- * 'error_cb()' - Print/add an error message.
- */
+//
+// 'error_cb()' - Print/add an error message.
+//
-static int /* O - 1 to continue, 0 to stop */
-error_cb(_ipp_file_t *f, /* I - IPP file data */
- ipptool_test_t *data, /* I - Test data */
- const char *error) /* I - Error message */
+static bool // O - `true` to continue, `false` to stop
+error_cb(ipp_file_t *f, // I - IPP file data (not used)
+ ipptool_test_t *data, // I - Test data
+ const char *error) // I - Error message
{
(void)f;
print_fatal_error(data, "%s", error);
- return (1);
+ return (true);
}
-/*
- * 'expect_matches()' - Return true if the tag matches the specification.
- */
+//
+// 'expect_matches()' - Return true if the tag matches the specification.
+//
-static int /* O - 1 if matches, 0 otherwise */
+static bool // O - `true` on match, `false` on non-match
expect_matches(
- ipptool_expect_t *expect, /* I - Expected attribute */
- ipp_attribute_t *attr) /* I - Attribute */
+ ipptool_expect_t *expect, // I - Expected attribute
+ ipp_attribute_t *attr) // I - Attribute
{
- int i, /* Looping var */
- count, /* Number of values */
- match; /* Match? */
- char *of_type, /* Type name to match */
- *paren, /* Pointer to opening parenthesis */
- *next, /* Next name to match */
- sep; /* Separator character */
- ipp_tag_t value_tag; /* Syntax/value tag */
- int lower, upper; /* Lower and upper bounds for syntax */
-
+ int i, // Looping var
+ count; // Number of values
+ bool match; // Match?
+ char *of_type, // Type name to match
+ *paren, // Pointer to opening parenthesis
+ *next, // Next name to match
+ sep; // Separator character
+ ipp_tag_t value_tag; // Syntax/value tag
+ int lower, upper; // Lower and upper bounds for syntax
- /*
- * If we don't expect a particular type, return immediately...
- */
+ // If we don't expect a particular type, return immediately...
if (!expect->of_type)
- return (1);
-
- /*
- * Parse the "of_type" value since the string can contain multiple attribute
- * types separated by "," or "|"...
- */
+ return (true);
+ // Parse the "of_type" value since the string can contain multiple attribute
+ // types separated by "," or "|"...
value_tag = ippGetValueTag(attr);
count = ippGetCount(attr);
- for (of_type = expect->of_type, match = 0; !match && *of_type; of_type = next)
+ for (of_type = expect->of_type, match = false; !match && *of_type; of_type = next)
{
- /*
- * Find the next separator, and set it (temporarily) to nul if present.
- */
-
+ // Find the next separator, and set it (temporarily) to nul if present.
for (next = of_type; *next && *next != '|' && *next != ','; next ++);
if ((sep = *next) != '\0')
*next = '\0';
- /*
- * Support some meta-types to make it easier to write the test file.
- */
-
+ // Support some meta-types to make it easier to write the test file.
if ((paren = strchr(of_type, '(')) != NULL)
{
char *ptr; // Pointer into syntax string
else if ((ptr = strchr(paren + 1, ':')) != NULL)
{
lower = atoi(paren + 1);
+ ptr ++;
}
else
{
default :
// No other constraints, so this is a match
- match = 1;
+ match = true;
break;
}
}
- /*
- * Restore the separators if we have them...
- */
-
+ // Restore the separators if we have them...
if (paren)
*paren = '(';
}
-/*
- * 'get_filename()' - Get a filename based on the current test file.
- */
+//
+// 'free_data()' - Free test data.
+//
-static char * /* O - Filename */
-get_filename(const char *testfile, /* I - Current test file */
- char *dst, /* I - Destination filename */
- const char *src, /* I - Source filename */
- size_t dstsize) /* I - Size of destination buffer */
+static void
+free_data(ipptool_test_t *data) // I - Test data
{
- char *dstptr; /* Pointer into destination */
+ clear_data(data);
+
+ ippFileDelete(data->parent);
+ cupsArrayDelete(data->errors);
+
+ free(data);
+}
+
+
+//
+// 'generate_file()' - Generate a print file.
+//
+
+static http_status_t // O - HTTP status
+generate_file(
+ http_t *http, // I - HTTP connection
+ ipptool_generate_t *params) // I - GENERATE-FILE parameters
+{
+ cups_raster_mode_t mode; // Raster output mode
+ cups_raster_t *ras; // Raster stream
+ cups_page_header2_t header; // Raster page header (front side)
+ cups_page_header2_t back_header; // Raster page header (back side)
+ pwg_media_t *pwg; // PWG media information
+ cups_media_t media; // CUPS media information
+
+
+ // Set the output mode...
+ if (!strcmp(params->format, "image/pwg-raster"))
+ mode = CUPS_RASTER_WRITE_PWG;
+ else if (!strcmp(params->format, "image/urf"))
+ mode = CUPS_RASTER_WRITE_APPLE;
+ else
+ mode = CUPS_RASTER_WRITE_COMPRESSED;
+
+ // Create the raster header...
+ if ((pwg = pwgMediaForPWG(params->media)) == NULL)
+ {
+ fprintf(stderr, "ipptool: Unable to parse media size '%s'.\n", params->media);
+ return (HTTP_STATUS_SERVER_ERROR);
+ }
+
+ memset(&media, 0, sizeof(media));
+ cupsCopyString(media.media, pwg->pwg, sizeof(media.media));
+ media.width = pwg->width;
+ media.length = pwg->length;
+
+ cupsRasterInitHeader(&header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, params->orientation, params->sides, params->type, params->xdpi, params->ydpi, /*sheet_back*/NULL);
+ cupsRasterInitHeader(&back_header, &media, /*optimize*/NULL, IPP_QUALITY_NORMAL, /*intent*/NULL, params->orientation, params->sides, params->type, params->xdpi, params->ydpi, params->sheet_back);
+
+#if 0
+ fprintf(stderr, "ipptool: media='%s'\n", params->media);
+ fprintf(stderr, "ipptool: type='%s'\n", params->type);
+ fprintf(stderr, "ipptool: resolution=%dx%d\n", params->xdpi, params->ydpi);
+ fprintf(stderr, "ipptool: orientation=%d\n", params->orientation);
+ fprintf(stderr, "ipptool: sides='%s'\n", params->sides);
+ fprintf(stderr, "ipptool: num_copies=%d\n", params->num_copies);
+ fprintf(stderr, "ipptool: num_pages=%d\n", params->num_pages);
+ fprintf(stderr, "ipptool: format='%s'\n", params->format);
+ fprintf(stderr, "ipptool: sheet_back='%s'\n", params->sheet_back);
+#endif // 0
+
+ // Create the raster stream...
+ if ((ras = cupsRasterOpenIO((cups_raster_cb_t)httpWrite, http, mode)) == NULL)
+ return (HTTP_STATUS_SERVER_ERROR);
+
+ // Write it...
+ if (!cupsRasterWriteTest(ras, &header, &back_header, params->sheet_back, params->orientation, params->num_copies, params->num_pages))
+ return (HTTP_STATUS_SERVER_ERROR);
+
+ cupsRasterClose(ras);
+
+ return (HTTP_STATUS_CONTINUE);
+}
+
+
+//
+// 'get_filename()' - Get a filename based on the current test file.
+//
+
+static char * // O - Filename
+get_filename(const char *testfile, // I - Current test file
+ char *dst, // I - Destination filename
+ const char *src, // I - Source filename
+ size_t dstsize) // I - Size of destination buffer
+{
+ char *dstptr; // Pointer into destination
_cups_globals_t *cg = _cupsGlobals();
- /* Global data */
+ // Global data
if (*src == '<' && src[strlen(src) - 1] == '>')
{
- /*
- * Map <filename> to CUPS_DATADIR/ipptool/filename...
- */
-
+ // Map <filename> to CUPS_DATADIR/ipptool/filename...
snprintf(dst, dstsize, "%s/ipptool/%s", cg->cups_datadir, src + 1);
dstptr = dst + strlen(dst) - 1;
if (*dstptr == '>')
else if (!access(src, R_OK) || *src == '/'
#ifdef _WIN32
|| (isalpha(*src & 255) && src[1] == ':')
-#endif /* _WIN32 */
+#endif // _WIN32
)
{
- /*
- * Use the path as-is...
- */
-
+ // Use the path as-is...
cupsCopyString(dst, src, dstsize);
}
else
{
- /*
- * Make path relative to testfile...
- */
-
+ // Make path relative to testfile...
cupsCopyString(dst, testfile, dstsize);
if ((dstptr = strrchr(dst, '/')) != NULL)
dstptr ++;
else
- dstptr = dst; /* Should never happen */
+ dstptr = dst; // Should never happen
cupsCopyString(dstptr, src, dstsize - (size_t)(dstptr - dst));
#if _WIN32
if (_access(dst, 0))
{
- /*
- * Not available relative to the testfile, see if it can be found on the
- * desktop...
- */
+ // Not available relative to the testfile, see if it can be found on the desktop...
const char *userprofile = getenv("USERPROFILE");
- /* User home directory */
+ // User home directory
if (userprofile)
snprintf(dst, dstsize, "%s/Desktop/%s", userprofile, src);
}
-#endif /* _WIN32 */
+#endif // _WIN32
}
return (dst);
}
-/*
- * 'get_string()' - Get a pointer to a string value or the portion of interest.
- */
+//
+// 'get_string()' - Get a pointer to a string value or the portion of interest.
+//
-static const char * /* O - Pointer to string */
-get_string(ipp_attribute_t *attr, /* I - IPP attribute */
- int element, /* I - Element to fetch */
- int flags, /* I - Value ("with") flags */
- char *buffer, /* I - Temporary buffer */
- size_t bufsize) /* I - Size of temporary buffer */
+static const char * // O - Pointer to string
+get_string(ipp_attribute_t *attr, // I - IPP attribute
+ int element, // I - Element to fetch
+ int flags, // I - Value ("with") flags
+ char *buffer, // I - Temporary buffer
+ size_t bufsize) // I - Size of temporary buffer
{
- const char *value; /* Value */
- char *ptr, /* Pointer into value */
- scheme[256], /* URI scheme */
- userpass[256], /* Username/password */
- hostname[256], /* Hostname */
- resource[1024]; /* Resource */
- int port; /* Port number */
+ const char *value; // Value
+ char *ptr, // Pointer into value
+ scheme[256], // URI scheme
+ userpass[256], // Username/password
+ hostname[256], // Hostname
+ resource[1024]; // Resource
+ int port; // Port number
value = ippGetString(attr, element, NULL);
if (flags & IPPTOOL_WITH_HOSTNAME)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), buffer, (int)bufsize, &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), buffer, bufsize, &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
buffer[0] = '\0';
ptr = buffer + strlen(buffer) - 1;
if (ptr >= buffer && *ptr == '.')
- *ptr = '\0'; /* Drop trailing "." */
+ *ptr = '\0'; // Drop trailing "."
return (buffer);
}
else if (flags & IPPTOOL_WITH_RESOURCE)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, buffer, (int)bufsize) < HTTP_URI_STATUS_OK)
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, buffer, bufsize) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
+ }
+ else if (flags & IPPTOOL_WITH_SCHEME)
+ {
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, value, buffer, bufsize, userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
buffer[0] = '\0';
- return (buffer);
- }
- else if (flags & IPPTOOL_WITH_SCHEME)
- {
- if (httpSeparateURI(HTTP_URI_CODING_ALL, value, buffer, (int)bufsize, userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
- buffer[0] = '\0';
+ return (buffer);
+ }
+ else if (ippGetValueTag(attr) == IPP_TAG_URI && (!strncmp(value, "ipp://", 6) || !strncmp(value, "http://", 7) || !strncmp(value, "ipps://", 7) || !strncmp(value, "https://", 8)))
+ {
+ http_uri_status_t status = httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource));
+
+ if (status < HTTP_URI_STATUS_OK)
+ {
+ // Bad URI...
+ buffer[0] = '\0';
+ }
+ else
+ {
+ // Normalize URI with no trailing dot...
+ if ((ptr = hostname + strlen(hostname) - 1) >= hostname && *ptr == '.')
+ *ptr = '\0';
+
+ httpAssembleURI(HTTP_URI_CODING_ALL, buffer, bufsize, scheme, userpass, hostname, port, resource);
+ }
+
+ return (buffer);
+ }
+ else
+ {
+ return (value);
+ }
+}
+
+
+//
+// 'iso_date()' - Return an ISO 8601 date/time string for the given IPP dateTime
+// value.
+//
+
+static char * // O - ISO 8601 date/time string
+iso_date(const ipp_uchar_t *date) // I - IPP (RFC 1903) date/time value
+{
+ time_t utctime; // UTC time since 1970
+ struct tm utcdate; // UTC date/time
+ static char buffer[255]; // String buffer
+
+
+ utctime = ippDateToTime(date);
+ gmtime_r(&utctime, &utcdate);
+
+ snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ",
+ utcdate.tm_year + 1900, utcdate.tm_mon + 1, utcdate.tm_mday,
+ utcdate.tm_hour, utcdate.tm_min, utcdate.tm_sec);
+
+ return (buffer);
+}
+
+
+//
+// 'parse_generate_file()' - Parse the GENERATE-FILE directive.
+//
+// GENERATE-FILE {
+// MEDIA "media size name, default, ready"
+// COLORSPACE "colorspace_bits, auto, color, monochrome, bi-level"
+// RESOLUTION "resolution, min, max, default"
+// ORIENTATION "portrait, landscape, reverse-landscape, reverse-portrait"
+// SIDES "one-sided, two-sided-long-edge, two-sided-short-edge"
+// NUM-COPIES "copies"
+// NUM-PAGES "pages, min"
+// FORMAT "image/pwg-raster, image/urf"
+// }
+//
+
+static bool // O - `true` to continue, `false` to stop
+parse_generate_file(
+ ipp_file_t *f, // I - IPP file data
+ ipptool_test_t *data) // I - Test data
+{
+ int i; // Looping var
+ ipptool_generate_t *params = NULL; // Generation parameters
+ http_t *http; // Connection to printer
+ ipp_t *request, // Get-Printer-Attributes request
+ *response = NULL;// Get-Printer-Attributes response
+ ipp_attribute_t *attr; // Current attribute
+ const char *keyword; // Keyword value
+ char token[256], // Token string
+ temp[1024], // Temporary string
+ value[1024], // Value string
+ *ptr; // Pointer into value
+ static const char *autos[][2] = // Automatic color/monochrome keywords
+ {
+ { "SRGB24", "srgb_8" },
+ { "ADOBERGB24", "adobe-rgb_8" },
+ { "DEVRGB24", "rgb_8" },
+ { "DEVCMYK32", "cmyk_8" },
+ { "ADOBERGB48", "adobe-rgb_16" },
+ { "DEVRGB48", "rgb_16" },
+ { "DEVCMYK64", "cmyk_16" },
+ { "W8", "sgray_8" },
+ { NULL, "black_8" },
+ { "W16", "sgray_16" },
+ { NULL, "black_16" },
+ { NULL, "sgray_1" },
+ { NULL, "black_1" }
+ };
+ static const char *bi_levels[][2] = // Bi-level keywords
+ {
+ { NULL, "sgray_1" },
+ { NULL, "black_1" }
+ };
+ static const char *colors[][2] = // Color keywords
+ {
+ { "SRGB24", "srgb_8" },
+ { "ADOBERGB24", "adobe-rgb_8" },
+ { "DEVRGB24", "rgb_8" },
+ { "DEVCMYK32", "cmyk_8" },
+ { "ADOBERGB48", "adobe-rgb_16" },
+ { "DEVRGB48", "rgb_16" },
+ { "DEVCMYK64", "cmyk_16" }
+ };
+ static const char *monochromes[][2] = // Monochrome keywords
+ {
+ { "W8", "sgray_8" },
+ { NULL, "black_8" },
+ { "W16", "sgray_16" },
+ { NULL, "black_16" },
+ { NULL, "sgray_1" },
+ { NULL, "black_1" }
+ };
+
+
+ // Make sure we have an open brace after the GENERATE-FILE...
+ if (!ippFileReadToken(f, token, sizeof(token)) || strcmp(token, "{"))
+ {
+ print_fatal_error(data, "Missing open brace on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (0);
+ }
+
+ // Get printer attributes...
+ if ((http = connect_printer(data)) == NULL)
+ {
+ print_fatal_error(data, "GENERATE-FILE connection failure on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+
+ request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, ippFileGetVar(data->parent, "uri"));
+
+ response = cupsDoRequest(http, request, ippFileGetVar(data->parent, "resource"));
+
+ httpClose(http);
+
+ if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
+ {
+ print_fatal_error(data, "GENERATE-FILE query failure on line %d of '%s': %s", ippFileGetLineNumber(f), ippFileGetFilename(f), cupsGetErrorString());
+ ippDelete(response);
+ return (false);
+ }
+
+ // Allocate parameters...
+ if ((params = calloc(1, sizeof(ipptool_generate_t))) == NULL)
+ {
+ print_fatal_error(data, "GENERATE-FILE memory allocation failure on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+
+ // Loop until we get a closing brace...
+ while (ippFileReadToken(f, token, sizeof(token)))
+ {
+ if (!strcmp(token, "}"))
+ {
+ // Update the raster type as needed...
+ if (!params->type[0])
+ {
+ // Get request/printer default value for print-color-mode, default to "auto"...
+ if ((attr = ippFileGetAttribute(f, "print-color-mode", IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(response, "print-color-mode-default", IPP_TAG_KEYWORD);
+
+ if (attr)
+ cupsCopyString(params->type, ippGetString(attr, 0, NULL), sizeof(params->type));
+ else
+ cupsCopyString(params->type, "auto", sizeof(params->type));
+ }
+
+ if (!strcmp(params->type, "auto"))
+ {
+ // Find auto keyword...
+ params->type[0] = '\0';
+
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD);
+
+ for (i = 0; i < (int)(sizeof(autos) / sizeof(autos[0])); i ++)
+ {
+ if (ippContainsString(attr, autos[i][0]) || ippContainsString(attr, autos[i][1]))
+ {
+ cupsCopyString(params->type, autos[i][1], sizeof(params->type));
+ break;
+ }
+ }
+
+ if (!params->type[0])
+ {
+ print_fatal_error(data, "Printer does not support COLORSPACE \"auto\" on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!strcmp(params->type, "bi-level"))
+ {
+ // Find bi-level keyword...
+ params->type[0] = '\0';
+
+ attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD);
+
+ for (i = 0; i < (int)(sizeof(bi_levels) / sizeof(bi_levels[0])); i ++)
+ {
+ if (ippContainsString(attr, bi_levels[i][1]))
+ {
+ cupsCopyString(params->type, bi_levels[i][1], sizeof(params->type));
+ break;
+ }
+ }
+
+ if (!params->type[0])
+ {
+ print_fatal_error(data, "Printer does not support COLORSPACE \"bi-level\" on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!strcmp(params->type, "color"))
+ {
+ // Find color keyword...
+ params->type[0] = '\0';
+
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) != NULL)
+ attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD);
+
+ for (i = 0; i < (int)(sizeof(colors) / sizeof(colors[0])); i ++)
+ {
+ if (ippContainsString(attr, colors[i][0]) || ippContainsString(attr, colors[i][1]))
+ {
+ cupsCopyString(params->type, colors[i][1], sizeof(params->type));
+ break;
+ }
+ }
+
+ if (!params->type[0])
+ {
+ print_fatal_error(data, "Printer does not support COLORSPACE \"color\" on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!strcmp(params->type, "monochrome"))
+ {
+ // Find grayscale keyword...
+ params->type[0] = '\0';
+
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD);
+
+ for (i = 0; i < (int)(sizeof(monochromes) / sizeof(monochromes[0])); i ++)
+ {
+ if (ippContainsString(attr, monochromes[i][0]) || ippContainsString(attr, monochromes[i][1]))
+ {
+ cupsCopyString(params->type, monochromes[i][1], sizeof(params->type));
+ break;
+ }
+ }
+
+ if (!params->type[0])
+ {
+ print_fatal_error(data, "Printer does not support COLORSPACE \"monochrome\" on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+
+ // Make sure we have an output format...
+ if (!params->format[0])
+ {
+ // Check the supported formats and choose a suitable one...
+ if ((keyword = ippGetString(ippFileGetAttribute(f, "document-format", IPP_TAG_MIMETYPE), 0, NULL)) != NULL)
+ {
+ if (strcmp(keyword, "image/pwg-raster") && strcmp(keyword, "image/urf"))
+ {
+ print_fatal_error(data, "Unsupported \"document-format\" value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ cupsCopyString(params->format, keyword, sizeof(params->format));
+ }
+ else if ((attr = ippFindAttribute(response, "document-format-supported", IPP_TAG_MIMETYPE)) != NULL)
+ {
+ // Default to Apple Raster unless sending bitmaps, which are only
+ // supported by PWG Raster...
+ if (ippContainsString(attr, "image/urf") && strncmp(params->type, "black_", 6) && strcmp(params->type, "srgb_1"))
+ cupsCopyString(params->format, "image/urf", sizeof(params->format));
+ else if (ippContainsString(attr, "image/pwg-raster"))
+ cupsCopyString(params->format, "image/pwg-raster", sizeof(params->format));
+ }
+
+ if (!params->format[0])
+ {
+ print_fatal_error(data, "Printer does not support a compatible FORMAT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+
+ // Get default/ready media...
+ if (!params->media[0] || !strcmp(params->media, "default"))
+ {
+ // Use job ticket or default media...
+ if (!params->media[0] && (keyword = ippGetString(ippFileGetAttribute(f, "media", IPP_TAG_ZERO), 0, NULL)) != NULL)
+ {
+ cupsCopyString(params->media, keyword, sizeof(params->media));
+ }
+ else if ((keyword = ippGetString(ippFindAttribute(response, "media-default", IPP_TAG_ZERO), 0, NULL)) != NULL)
+ {
+ cupsCopyString(params->media, keyword, sizeof(params->media));
+ }
+ else
+ {
+ print_fatal_error(data, "Printer does not report a default MEDIA size name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!strcmp(params->media, "ready"))
+ {
+ // Use ready media
+ if ((keyword = ippGetString(ippFindAttribute(response, "media-ready", IPP_TAG_ZERO), 0, NULL)) != NULL)
+ {
+ cupsCopyString(params->media, keyword, sizeof(params->media));
+ }
+ else
+ {
+ print_fatal_error(data, "Printer does not report a ready MEDIA size name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+
+ // Default resolution
+ if (!params->xdpi || !params->ydpi)
+ {
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-resolution-supported", IPP_TAG_RESOLUTION)) != NULL)
+ {
+ ipp_res_t units; // Resolution units
+
+ // Use the middle resolution in the list...
+ params->xdpi = ippGetResolution(attr, ippGetCount(attr) / 2, ¶ms->ydpi, &units);
+
+ if (units == IPP_RES_PER_CM)
+ {
+ params->xdpi = (int)(params->xdpi * 2.54);
+ params->ydpi = (int)(params->ydpi * 2.54);
+ }
+ }
+ else if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) != NULL)
+ {
+ int count = ippGetCount(attr); // Number of values
+
+ for (i = 0; i < count; i ++)
+ {
+ keyword = ippGetString(attr, i, NULL);
+ if (!strncmp(keyword, "RS", 2))
+ {
+ // Use the first resolution in the list...
+ params->xdpi = params->ydpi = atoi(keyword + 2);
+ break;
+ }
+ }
+ }
+
+ if (!params->xdpi || !params->ydpi)
+ {
+ print_fatal_error(data, "Printer does not report a supported RESOLUTION on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+
+ // Default duplex/sides
+ if (!params->sides[0])
+ {
+ if ((keyword = ippGetString(ippFileGetAttribute(f, "sides", IPP_TAG_ZERO), 0, NULL)) != NULL)
+ {
+ // Use the setting from the job ticket...
+ cupsCopyString(params->sides, keyword, sizeof(params->sides));
+ }
+ else if (params->num_pages != 1 && (attr = ippFindAttribute(response, "sides-supported", IPP_TAG_KEYWORD)) != NULL && ippGetCount(attr) > 1)
+ {
+ // Default to two-sided for capable printers...
+ if (params->orientation == IPP_ORIENT_LANDSCAPE || params->orientation == IPP_ORIENT_REVERSE_LANDSCAPE)
+ cupsCopyString(params->sides, "two-sided-short-edge", sizeof(params->sides));
+ else
+ cupsCopyString(params->sides, "two-sided-long-edge", sizeof(params->sides));
+ }
+ else
+ {
+ // Fall back to 1-sided output...
+ cupsCopyString(params->sides, "one-sided", sizeof(params->sides));
+ }
+ }
+
+ // Default orientation
+ if (!params->orientation)
+ {
+ // Use the job ticket value, otherwise use landscape for short-edge duplex
+ if ((attr = ippFileGetAttribute(f, "orientation-requested", IPP_TAG_ENUM)) != NULL)
+ params->orientation = (ipp_orient_t)ippGetInteger(attr, 0);
+ else
+ params->orientation = !strcmp(params->sides, "two-sided-short-edge") ? IPP_ORIENT_LANDSCAPE : IPP_ORIENT_PORTRAIT;
+ }
+
+ // Default number of copies and pages...
+ if (!params->num_copies)
+ params->num_copies = 1;
+
+ if (!params->num_pages)
+ params->num_pages = !strncmp(params->sides, "two-sided-", 10) ? 2 : 1;
+
+ // Back side transform, if any
+ if (!params->sheet_back[0])
+ {
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-sheet-back", IPP_TAG_KEYWORD)) != NULL)
+ {
+ cupsCopyString(params->sheet_back, ippGetString(attr, 0, NULL), sizeof(params->sheet_back));
+ }
+ else if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) != NULL)
+ {
+ if (ippContainsString(attr, "DM1"))
+ cupsCopyString(params->sheet_back, "flip", sizeof(params->sheet_back));
+ else if (ippContainsString(attr, "DM2"))
+ cupsCopyString(params->sheet_back, "manual-tumble", sizeof(params->sheet_back));
+ else if (ippContainsString(attr, "DM3"))
+ cupsCopyString(params->sheet_back, "rotated", sizeof(params->sheet_back));
+ else
+ cupsCopyString(params->sheet_back, "normal", sizeof(params->sheet_back));
+ }
+ else
+ {
+ cupsCopyString(params->sheet_back, "normal", sizeof(params->sheet_back));
+ }
+ }
+
+ // Everything is good, save the parameters and return...
+ data->generate_params = params;
+ ippDelete(response);
+
+ return (1);
+ }
+ else if (!_cups_strcasecmp(token, "COLORSPACE"))
+ {
+ if (params->type[0])
+ {
+ print_fatal_error(data, "Unexpected extra COLORSPACE on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing COLORSPACE value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if (!strcmp(value, "auto") || !strcmp(value, "bi-level") || !strcmp(value, "color") || !strcmp(value, "monochrome") || !strcmp(value, "adobe-rgb_8") || !strcmp(value, "adobe-rgb_16") || !strcmp(value, "black_1") || !strcmp(value, "black_8") || !strcmp(value, "black_16") || !strcmp(value, "cmyk_8") || !strcmp(value, "cmyk_16") || !strcmp(value, "rgb_8") || !strcmp(value, "rgb_16") || !strcmp(value, "sgray_1") || !strcmp(value, "sgray_8") || !strcmp(value, "sgray_16") || !strcmp(value, "srgb_8") || !strcmp(value, "srgb_16"))
+ {
+ // Use "print-color-mode" or "pwg-raster-document-type-supported" keyword...
+ cupsCopyString(params->type, value, sizeof(params->type));
+ }
+ else
+ {
+ print_fatal_error(data, "Bad COLORSPACE \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!_cups_strcasecmp(token, "FORMAT"))
+ {
+ if (params->format[0])
+ {
+ print_fatal_error(data, "Unexpected extra FORMAT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing FORMAT MIME media type on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if (!strcmp(value, "image/pwg-raster") || !strcmp(value, "image/urf"))
+ {
+ cupsCopyString(params->format, value, sizeof(params->format));
+ }
+ else
+ {
+ print_fatal_error(data, "Bad FORMAT \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!_cups_strcasecmp(token, "MEDIA"))
+ {
+ if (params->media[0])
+ {
+ print_fatal_error(data, "Unexpected extra MEDIA on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing MEDIA size name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if (!strcmp(value, "default") || !strcmp(value, "ready") || pwgMediaForPWG(value) != NULL)
+ {
+ cupsCopyString(params->media, value, sizeof(params->media));
+ }
+ else
+ {
+ print_fatal_error(data, "Bad MEDIA \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!_cups_strcasecmp(token, "NUM-COPIES"))
+ {
+ int intvalue; // Number of copies value
+
+ if (params->num_copies)
+ {
+ print_fatal_error(data, "Unexpected extra NUM-COPIES on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing NUM-COPIES number on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if ((intvalue = strtol(value, NULL, 10)) > INT_MAX || intvalue < 1)
+ {
+ print_fatal_error(data, "Bad NUM-COPIES \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ params->num_copies = intvalue;
+ }
+ else if (!_cups_strcasecmp(token, "NUM-PAGES"))
+ {
+ int intvalue; // Number of pages value
+
+ if (params->num_pages)
+ {
+ print_fatal_error(data, "Unexpected extra NUM-PAGES on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing NUM-PAGES number on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if ((intvalue = strtol(value, NULL, 10)) > INT_MAX || intvalue < 1)
+ {
+ print_fatal_error(data, "Bad NUM-PAGES \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ params->num_pages = (int)intvalue;
+ }
+ else if (!_cups_strcasecmp(token, "ORIENTATION"))
+ {
+ if (params->orientation)
+ {
+ print_fatal_error(data, "Unexpected extra ORIENTATION on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing ORIENTATION on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if (!strcmp(value, "portrait"))
+ params->orientation = IPP_ORIENT_PORTRAIT;
+ else if (!strcmp(value, "landscape"))
+ params->orientation = IPP_ORIENT_LANDSCAPE;
+ else if (!strcmp(value, "reverse-landscape"))
+ params->orientation = IPP_ORIENT_REVERSE_LANDSCAPE;
+ else if (!strcmp(value, "reverse-portrait"))
+ params->orientation = IPP_ORIENT_REVERSE_PORTRAIT;
+ else
+ {
+ print_fatal_error(data, "Bad ORIENTATION \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!_cups_strcasecmp(token, "RESOLUTION"))
+ {
+ if (params->xdpi || params->ydpi)
+ {
+ print_fatal_error(data, "Unexpected extra RESOLUTION on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing RESOLUTION on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if (!strcmp(value, "min") || !strcmp(value, "max"))
+ {
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-resolution-supported", IPP_TAG_RESOLUTION)) != NULL)
+ {
+ ipp_res_t units; // Resolution units
+
+ // Use the first or last resolution in the list...
+ params->xdpi = ippGetResolution(attr, !strcmp(value, "min") ? 0 : ippGetCount(attr) - 1, ¶ms->ydpi, &units);
+
+ if (units == IPP_RES_PER_CM)
+ {
+ params->xdpi = (int)(params->xdpi * 2.54);
+ params->ydpi = (int)(params->ydpi * 2.54);
+ }
+ }
+ else if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) != NULL)
+ {
+ int count = ippGetCount(attr); // Number of values
+
+ for (i = 0; i < count; i ++)
+ {
+ keyword = ippGetString(attr, i, NULL);
+ if (!strncmp(keyword, "RS", 2))
+ {
+ if (!strcmp(value, "min"))
+ {
+ // Use the first resolution in the list...
+ params->xdpi = params->ydpi = atoi(keyword + 2);
+ }
+ else
+ {
+ // Use the last resolution in the list...
+ params->xdpi = params->ydpi = (int)strtol(keyword + 2, &ptr, 10);
+ while (ptr && *ptr && *ptr == '-')
+ params->xdpi = params->ydpi = (int)strtol(ptr + 1, &ptr, 10);
+ }
+ break;
+ }
+ }
+ }
+ }
+ else if (strcmp(value, "default"))
+ {
+ char units[8] = ""; // Resolution units (dpi or dpcm)
+
+ if (sscanf(value, "%dx%d%7s", ¶ms->xdpi, ¶ms->ydpi, units) == 1)
+ {
+ sscanf(value, "%d%7s", ¶ms->xdpi, units);
+ params->ydpi = params->xdpi;
+ }
- return (buffer);
- }
- else if (ippGetValueTag(attr) == IPP_TAG_URI && (!strncmp(value, "ipp://", 6) || !strncmp(value, "http://", 7) || !strncmp(value, "ipps://", 7) || !strncmp(value, "https://", 8)))
- {
- http_uri_status_t status = httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource));
+ if (!strcmp(units, "dpcm"))
+ {
+ params->xdpi = (int)(params->xdpi * 2.54);
+ params->ydpi = (int)(params->ydpi * 2.54);
+ }
+ else if (strcmp(units, "dpi"))
+ params->xdpi = params->ydpi = 0;
+ }
- if (status < HTTP_URI_STATUS_OK)
+ if (strcmp(value, "default") && (params->xdpi <= 0 || params->ydpi <= 0))
+ {
+ print_fatal_error(data, "Bad RESOLUTION \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
+ }
+ else if (!_cups_strcasecmp(token, "SIDES"))
{
- /*
- * Bad URI...
- */
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing SIDES on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
- buffer[0] = '\0';
+ ippFileExpandVars(f, value, temp, sizeof(value));
+
+ if (!strcmp(value, "one-sided") || !strcmp(value, "two-sided-long-edge") || !strcmp(value, "two-sided-short-edge"))
+ {
+ cupsCopyString(params->sides, value, sizeof(params->sides));
+ }
+ else
+ {
+ print_fatal_error(data, "Bad SIDES \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
+ }
}
else
{
- /*
- * Normalize URI with no trailing dot...
- */
-
- if ((ptr = hostname + strlen(hostname) - 1) >= hostname && *ptr == '.')
- *ptr = '\0';
-
- httpAssembleURI(HTTP_URI_CODING_ALL, buffer, (int)bufsize, scheme, userpass, hostname, port, resource);
+ print_fatal_error(data, "Unknown %s on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ goto fail;
}
-
- return (buffer);
}
- else
- return (value);
-}
-
-
-/*
- * 'init_data()' - Initialize test data.
- */
-
-static void
-init_data(ipptool_test_t *data) /* I - Data */
-{
- memset(data, 0, sizeof(ipptool_test_t));
-
- data->output = IPPTOOL_OUTPUT_LIST;
- data->outfile = cupsFileStdout();
- data->family = AF_UNSPEC;
- data->def_transfer = IPPTOOL_TRANSFER_AUTO;
- data->def_version = 11;
- data->errors = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
- data->pass = 1;
- data->prev_pass = 1;
- data->request_id = (CUPS_RAND() % 1000) * 137;
- data->show_header = 1;
-}
-
-
-/*
- * 'iso_date()' - Return an ISO 8601 date/time string for the given IPP dateTime
- * value.
- */
-
-static char * /* O - ISO 8601 date/time string */
-iso_date(const ipp_uchar_t *date) /* I - IPP (RFC 1903) date/time value */
-{
- time_t utctime; /* UTC time since 1970 */
- struct tm utcdate; /* UTC date/time */
- static char buffer[255]; /* String buffer */
-
- utctime = ippDateToTime(date);
- gmtime_r(&utctime, &utcdate);
+ print_fatal_error(data, "Missing closing brace on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
- snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ",
- utcdate.tm_year + 1900, utcdate.tm_mon + 1, utcdate.tm_mday,
- utcdate.tm_hour, utcdate.tm_min, utcdate.tm_sec);
+ fail:
- return (buffer);
+ free(params);
+ ippDelete(response);
+ return (0);
}
-/*
- * 'parse_monitor_printer_state()' - Parse the MONITOR-PRINTER-STATE directive.
- *
- * MONITOR-PRINTER-STATE [printer-uri] {
- * DELAY nnn
- * EXPECT attribute-name ...
- * }
- */
+//
+// 'parse_monitor_printer_state()' - Parse the MONITOR-PRINTER-STATE directive.
+//
+// MONITOR-PRINTER-STATE [printer-uri] {
+// DELAY nnn
+// EXPECT attribute-name ...
+// }
+//
-static int /* O - 1 to continue, 0 to stop */
+static bool // O - `true` to continue, `false` to stop
parse_monitor_printer_state(
- _ipp_file_t *f, /* I - IPP file data */
- ipptool_test_t *data) /* I - Test data */
+ ipp_file_t *f, // I - IPP file data
+ ipptool_test_t *data) // I - Test data
{
- char token[256], /* Token string */
- name[1024], /* Name string */
- temp[1024], /* Temporary string */
- value[1024], /* Value string */
- *ptr; /* Pointer into value */
+ char token[256], // Token string
+ name[1024], // Name string
+ temp[1024], // Temporary string
+ value[1024], // Value string
+ *ptr; // Pointer into value
+ const char *uri; // Printer URI
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing printer URI on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing printer URI on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
if (strcmp(temp, "{"))
{
// Got a printer URI so copy it...
- _ippVarsExpand(data->vars, value, temp, sizeof(value));
+ ippFileExpandVars(f, value, temp, sizeof(value));
data->monitor_uri = strdup(value);
// Then see if we have an opening brace...
- if (!_ippFileReadToken(f, temp, sizeof(temp)) || strcmp(temp, "{"))
+ if (!ippFileReadToken(f, temp, sizeof(temp)) || strcmp(temp, "{"))
{
- print_fatal_error(data, "Missing opening brace on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing opening brace on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
- else
+ else if ((uri = ippFileGetVar(data->parent, "uri")) != NULL)
{
// Use the default printer URI...
- data->monitor_uri = strdup(data->vars->uri);
+ data->monitor_uri = strdup(uri);
}
// Loop until we get a closing brace...
- while (_ippFileReadToken(f, token, sizeof(token)))
+ while (ippFileReadToken(f, token, sizeof(token)))
{
if (_cups_strcasecmp(token, "COUNT") &&
_cups_strcasecmp(token, "DEFINE-MATCH") &&
return (1);
else if (!_cups_strcasecmp(token, "EXPECT"))
{
- /*
- * Expected attributes...
- */
-
+ // Expected attributes...
if (data->num_monitor_expects >= (int)(sizeof(data->monitor_expects) / sizeof(data->monitor_expects[0])))
{
- print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Too many EXPECT's on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
- if (!_ippFileReadToken(f, name, sizeof(name)))
+ if (!ippFileReadToken(f, name, sizeof(name)))
{
- print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing EXPECT name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "COUNT"))
{
- int count; /* Count value */
+ int count; // Count value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing COUNT number on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
- if ((count = atoi(temp)) <= 0)
+ if ((count = strtol(temp, NULL, 10)) > INT_MAX)
{
- print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
+ print_fatal_error(data, "Bad COUNT \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "DEFINE-MATCH"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "DEFINE-VALUE"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "DISPLAY-MATCH"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DISPLAY-MATCH message on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing DISPLAY-MATCH message on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "DELAY"))
{
- /*
- * Delay before operation...
- */
-
- double dval; /* Delay value */
+ // Delay before operation...
+ double dval; // Delay value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing DELAY value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
- _ippVarsExpand(data->vars, value, temp, sizeof(value));
+ ippFileExpandVars(f, value, temp, sizeof(value));
if ((dval = _cupsStrScand(value, &ptr, localeconv())) < 0.0 || (*ptr && *ptr != ','))
{
- print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
+ print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
{
if ((dval = _cupsStrScand(ptr + 1, &ptr, localeconv())) <= 0.0 || *ptr)
{
- print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
+ print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "OF-TYPE"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "IN-GROUP"))
{
- ipp_tag_t in_group; /* IN-GROUP value */
+ ipp_tag_t in_group; // IN-GROUP value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing IN-GROUP group tag on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
if ((in_group = ippTagValue(temp)) == IPP_TAG_ZERO || in_group >= IPP_TAG_UNSUPPORTED_VALUE)
{
- print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
+ print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
else if (data->last_expect)
}
else
{
- print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "IF-DEFINED"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing IF-DEFINED name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "IF-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "IF-DEFINED without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else
{
- print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
}
else
{
- print_fatal_error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename);
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
else if (!_cups_strcasecmp(token, "WITH-VALUE"))
{
- off_t lastpos; /* Last file position */
- int lastline; /* Last line number */
-
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename);
+ print_fatal_error(data, "Missing %s value on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
- /*
- * Read additional comma-delimited values - needed since legacy test files
- * will have unquoted WITH-VALUE values with commas...
- */
-
+ // Read additional comma-delimited values - needed since legacy test files
+ // will have unquoted WITH-VALUE values with commas...
ptr = temp + strlen(temp);
for (;;)
{
- lastpos = cupsFileTell(f->fp);
- lastline = f->linenum;
- ptr += strlen(ptr);
+ ippFileSavePosition(f);
- if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
+ ptr += strlen(ptr);
+
+ if (!ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
break;
if (!strcmp(ptr, ","))
{
- /*
- * Append a value...
- */
-
+ // Append a value...
ptr += strlen(ptr);
- if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
+ if (!ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
break;
}
else
{
- /*
- * Not another value, stop here...
- */
-
- cupsFileSeek(f->fp, lastpos);
- f->linenum = lastline;
+ // Not another value, stop here...
+ ippFileRestorePosition(f);
*ptr = '\0';
break;
}
if (data->last_expect)
{
- /*
- * Expand any variables in the value and then save it.
- */
-
- _ippVarsExpand(data->vars, value, temp, sizeof(value));
+ // Expand any variables in the value and then save it.
+ ippFileExpandVars(f, value, temp, sizeof(value));
ptr = value + strlen(value) - 1;
if (value[0] == '/' && ptr > value && *ptr == '/')
{
- /*
- * WITH-VALUE is a POSIX extended regular expression.
- */
-
+ // WITH-VALUE is a POSIX extended regular expression.
data->last_expect->with_value = calloc(1, (size_t)(ptr - value));
data->last_expect->with_flags |= IPPTOOL_WITH_REGEX;
}
else
{
- /*
- * WITH-VALUE is a literal value...
- */
-
+ // WITH-VALUE is a literal value...
for (ptr = value; *ptr; ptr ++)
{
if (*ptr == '\\' && ptr[1])
{
- /*
- * Remove \ from \foo...
- */
-
+ // Remove \ from \foo...
_cups_strcpy(ptr, ptr + 1);
}
}
}
else
{
- print_fatal_error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename);
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
}
}
- print_fatal_error(data, "Missing closing brace on line %d of \"%s\".", f->linenum, f->filename);
+ print_fatal_error(data, "Missing closing brace on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
return (0);
}
-/*
- * 'pause_message()' - Display the message and pause until the user presses a key.
- */
+//
+// 'password_cb()' - Password callback using the IPP variables.
+//
+
+const char * // O - Password string or @code NULL@
+password_cb(
+ const char *prompt, // I - Prompt string (not used)
+ http_t *http, // I - HTTP connection (not used)
+ const char *method, // I - HTTP method (not used)
+ const char *resource, // I - Resource path (not used)
+ void *user_data) // I - IPP test data
+{
+ ipptool_test_t *test = (ipptool_test_t *)user_data;
+ // IPP test data
+ const char *uriuser = ippFileGetVar(test->parent, "uriuser"),
+ // Username
+ *uripassword = ippFileGetVar(test->parent, "uripassword");
+ // Password
+
+
+ (void)prompt;
+ (void)http;
+ (void)method;
+ (void)resource;
+
+ if (uriuser && uripassword && test->password_tries < 3)
+ {
+ test->password_tries ++;
+
+ cupsSetUser(uriuser);
+
+ return (uripassword);
+ }
+ else
+ {
+ return (NULL);
+ }
+}
+
+
+//
+// 'pause_message()' - Display the message and pause until the user presses a key.
+//
static void
-pause_message(const char *message) /* I - Message */
+pause_message(const char *message) // I - Message
{
#ifdef _WIN32
- HANDLE tty; /* Console handle */
- DWORD mode; /* Console mode */
- char key; /* Key press */
- DWORD bytes; /* Bytes read for key press */
+ HANDLE tty; // Console handle
+ DWORD mode; // Console mode
+ char key; // Key press
+ DWORD bytes; // Bytes read for key press
- /*
- * Disable input echo and set raw input...
- */
-
+ // Disable input echo and set raw input...
if ((tty = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE)
return;
return;
#else
- int tty; /* /dev/tty - never read from stdin */
- struct termios original, /* Original input mode */
- noecho; /* No echo input mode */
- char key; /* Current key press */
-
+ int tty; // /dev/tty - never read from stdin
+ struct termios original, // Original input mode
+ noecho; // No echo input mode
+ char key; // Current key press
- /*
- * Disable input echo and set raw input...
- */
+ // Disable input echo and set raw input...
if ((tty = open("/dev/tty", O_RDONLY)) < 0)
return;
close(tty);
return;
}
-#endif /* _WIN32 */
-
- /*
- * Display the prompt...
- */
+#endif // _WIN32
+ // Display the prompt...
cupsFilePrintf(cupsFileStdout(), "\n%s\n\n---- PRESS ANY KEY ----", message);
#ifdef _WIN32
- /*
- * Read a key...
- */
-
+ // Read a key...
ReadFile(tty, &key, 1, &bytes, NULL);
- /*
- * Cleanup...
- */
-
+ // Cleanup...
SetConsoleMode(tty, mode);
#else
- /*
- * Read a key...
- */
-
+ // Read a key...
read(tty, &key, 1);
- /*
- * Cleanup...
- */
-
+ // Cleanup...
tcsetattr(tty, TCSAFLUSH, &original);
close(tty);
-#endif /* _WIN32 */
-
- /*
- * Erase the "press any key" prompt...
- */
+#endif // _WIN32
+ // Erase the "press any key" prompt...
cupsFilePuts(cupsFileStdout(), "\r \r");
}
-/*
- * 'print_attr()' - Print an attribute on the screen.
- */
+//
+// 'print_attr()' - Print an attribute on the screen.
+//
static void
-print_attr(cups_file_t *outfile, /* I - Output file */
- ipptool_output_t output, /* I - Output format */
- ipp_attribute_t *attr, /* I - Attribute to print */
- ipp_tag_t *group) /* IO - Current group */
+print_attr(cups_file_t *outfile, // I - Output file
+ ipptool_output_t output, // I - Output format
+ ipp_attribute_t *attr, // I - Attribute to print
+ ipp_tag_t *group) // IO - Current group
{
- int i, /* Looping var */
- count; /* Number of values */
- ipp_attribute_t *colattr; /* Collection attribute */
+ int i, // Looping var
+ count; // Number of values
+ ipp_attribute_t *colattr; // Collection attribute
if (output == IPPTOOL_OUTPUT_PLIST)
case IPP_TAG_RANGE :
for (i = 0; i < count; i ++)
{
- int lower, upper; /* Lower and upper ranges */
+ int lower, upper; // Lower and upper ranges
lower = ippGetRange(attr, i, &upper);
cupsFilePrintf(outfile, "<dict><key>lower</key><integer>%d</integer><key>upper</key><integer>%d</integer></dict>\n", lower, upper);
case IPP_TAG_RESOLUTION :
for (i = 0; i < count; i ++)
{
- int xres, yres; /* Resolution values */
- ipp_res_t units; /* Resolution units */
+ int xres, yres; // Resolution values
+ ipp_res_t units; // Resolution units
xres = ippGetResolution(attr, i, &yres, &units);
cupsFilePrintf(outfile, "<dict><key>xres</key><integer>%d</integer><key>yres</key><integer>%d</integer><key>units</key><string>%s</string></dict>\n", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
case IPP_TAG_STRING :
for (i = 0; i < count; i ++)
{
- int datalen; /* Length of data */
+ int datalen; // Length of data
void *data = ippGetOctetString(attr, i, &datalen);
- /* Data */
+ // Data
char buffer[IPP_MAX_LENGTH * 5 / 4 + 1];
- /* Base64 output buffer */
+ // Base64 output buffer
- cupsFilePrintf(outfile, "<data>%s</data>\n", httpEncode64_2(buffer, sizeof(buffer), data, datalen));
+ cupsFilePrintf(outfile, "<data>%s</data>\n", httpEncode64_3(buffer, sizeof(buffer), data, (size_t)datalen, false));
}
break;
case IPP_TAG_NAMELANG :
for (i = 0; i < count; i ++)
{
- const char *s, /* String */
- *lang; /* Language */
+ const char *s, // String
+ *lang; // Language
s = ippGetString(attr, i, &lang);
cupsFilePuts(outfile, "<dict><key>language</key><string>");
for (i = 0; i < count; i ++)
{
ipp_t *col = ippGetCollection(attr, i);
- /* Collection value */
+ // Collection value
cupsFilePuts(outfile, "<dict>\n");
- for (colattr = ippFirstAttribute(col); colattr; colattr = ippNextAttribute(col))
+ for (colattr = ippGetFirstAttribute(col); colattr; colattr = ippGetNextAttribute(col))
print_attr(outfile, output, colattr, NULL);
cupsFilePuts(outfile, "</dict>\n");
}
}
else
{
- char buffer[131072]; /* Value buffer */
+ size_t attrsize; // Size of current attribute
+ static char *buffer = NULL; // Value buffer
+ static size_t bufsize = 0; // Current size of value buffer
+
+ if (!buffer)
+ {
+ bufsize = 65536;
+ buffer = malloc(bufsize);
+ }
if (output == IPPTOOL_OUTPUT_TEST)
{
cupsFilePrintf(outfile, " %s (%s%s) = ", ippGetName(attr), ippGetCount(attr) > 1 ? "1setOf " : "", ippTagString(ippGetValueTag(attr)));
}
- ippAttributeString(attr, buffer, sizeof(buffer));
+ if ((attrsize = ippAttributeString(attr, buffer, bufsize)) >= bufsize)
+ {
+ // Expand attribute value buffer...
+ char *temp = realloc(buffer, attrsize + 1);
+ // New buffer pointer
+
+ if (temp)
+ {
+ buffer = temp;
+ bufsize = attrsize + 1;
+
+ ippAttributeString(attr, buffer, bufsize);
+ }
+
+ }
cupsFilePrintf(outfile, "%s\n", buffer);
}
}
-/*
- * 'print_csv()' - Print a line of CSV text.
- */
+//
+// 'print_csv()' - Print a line of CSV text.
+//
-static ipp_attribute_t * /* O - Next attribute */
+static ipp_attribute_t * // O - Next attribute
print_csv(
- ipptool_test_t *data, /* I - Test data */
- ipp_t *ipp, /* I - Response message */
- ipp_attribute_t *attr, /* I - First attribute for line */
- int num_displayed, /* I - Number of attributes to display */
- char **displayed, /* I - Attributes to display */
- size_t *widths) /* I - Column widths */
+ ipptool_test_t *data, // I - Test data
+ ipp_t *ipp, // I - Response message
+ ipp_attribute_t *attr, // I - First attribute for line
+ int num_displayed, // I - Number of attributes to display
+ char **displayed, // I - Attributes to display
+ int *widths) // I - Column widths
{
- int i; /* Looping var */
- size_t maxlength; /* Max length of all columns */
- ipp_attribute_t *current = attr; /* Current attribute */
- char *values[MAX_DISPLAY], /* Strings to display */
- *valptr; /* Pointer into value */
-
- /*
- * Get the maximum string length we have to show and allocate...
- */
+ int i; // Looping var
+ int maxlength; // Max length of all columns
+ ipp_attribute_t *current = attr; // Current attribute
+ char *values[MAX_DISPLAY], // Strings to display
+ *valptr; // Pointer into value
+ // Get the maximum string length we have to show and allocate...
for (i = 1, maxlength = widths[0]; i < num_displayed; i ++)
+ {
if (widths[i] > maxlength)
maxlength = widths[i];
+ }
maxlength += 2;
- /*
- * Loop through the attributes to display...
- */
-
+ // Loop through the attributes to display...
if (attr)
{
// Collect the values...
memset(values, 0, sizeof(values));
- for (; current; current = ippNextAttribute(ipp))
+ for (; current; current = ippGetNextAttribute(ipp))
{
if (!ippGetName(current))
break;
{
if (!strcmp(ippGetName(current), displayed[i]))
{
- if ((values[i] = (char *)calloc(1, maxlength)) != NULL)
- ippAttributeString(current, values[i], maxlength);
+ if ((values[i] = (char *)calloc(1, (size_t)maxlength)) != NULL)
+ ippAttributeString(current, values[i], (size_t)maxlength);
break;
}
}
}
-/*
- * 'print_fatal_error()' - Print a fatal error message.
- */
+//
+// 'print_fatal_error()' - Print a fatal error message.
+//
static void
print_fatal_error(
- ipptool_test_t *data, /* I - Test data */
- const char *s, /* I - Printf-style format string */
- ...) /* I - Additional arguments as needed */
+ ipptool_test_t *data, // I - Test data
+ const char *s, // I - Printf-style format string
+ ...) // I - Additional arguments as needed
{
- char buffer[10240]; /* Format buffer */
- va_list ap; /* Pointer to arguments */
+ char buffer[10240]; // Format buffer
+ va_list ap; // Pointer to arguments
- /*
- * Format the error message...
- */
-
+ // Format the error message...
va_start(ap, s);
vsnprintf(buffer, sizeof(buffer), s, ap);
va_end(ap);
- /*
- * Then output it...
- */
-
+ // Then output it...
if (data->output == IPPTOOL_OUTPUT_PLIST)
{
print_xml_header(data);
}
-/*
- * 'print_ippserver_attr()' - Print an attribute suitable for use by ippserver.
- */
+//
+// 'print_ippserver_attr()' - Print a attribute suitable for use by ippserver.
+//
static void
print_ippserver_attr(
- ipptool_test_t *data, /* I - Test data */
- ipp_attribute_t *attr, /* I - Attribute to print */
- int indent) /* I - Indentation level */
+ ipptool_test_t *data, // I - Test data
+ ipp_attribute_t *attr, // I - Attribute to print
+ int indent) // I - Indentation level
{
- int i, /* Looping var */
+ int i, // Looping var
count = ippGetCount(attr);
- /* Number of values */
- ipp_attribute_t *colattr; /* Collection attribute */
+ // Number of values
+ ipp_attribute_t *colattr; // Collection attribute
if (indent == 0)
ipp_t *col = ippGetCollection(attr, i);
cupsFilePuts(data->outfile, i ? ",{\n" : " {\n");
- for (colattr = ippFirstAttribute(col); colattr; colattr = ippNextAttribute(col))
+ for (colattr = ippGetFirstAttribute(col); colattr; colattr = ippGetNextAttribute(col))
print_ippserver_attr(data, colattr, indent + 4);
cupsFilePrintf(data->outfile, "%*s}", indent, "");
}
break;
default :
- /* Out-of-band value */
+ // Out-of-band value
break;
}
}
-/*
- * 'print_ippserver_string()' - Print a string suitable for use by ippserver.
- */
+//
+// 'print_ippserver_string()' - Print a string suitable for use by ippserver.
+//
static void
print_ippserver_string(
- ipptool_test_t *data, /* I - Test data */
- const char *s, /* I - String to print */
- size_t len) /* I - Length of string */
+ ipptool_test_t *data, // I - Test data
+ const char *s, // I - String to print
+ size_t len) // I - Length of string
{
cupsFilePutChar(data->outfile, '\"');
while (len > 0)
}
-/*
- * 'print_json_attr()' - Print an attribute in JSON format.
- */
+//
+// 'print_json_attr()' - Print an attribute in JSON format.
+//
static void
print_json_attr(
- ipptool_test_t *data, /* I - Test data */
- ipp_attribute_t *attr, /* I - IPP attribute */
- int indent) /* I - Indentation */
+ ipptool_test_t *data, // I - Test data
+ ipp_attribute_t *attr, // I - IPP attribute
+ int indent) // I - Indentation
{
const char *name = ippGetName(attr);
- /* Name of attribute */
- int i, /* Looping var */
+ // Name of attribute
+ int i, // Looping var
count = ippGetCount(attr);
- /* Number of values */
- ipp_attribute_t *colattr; /* Collection attribute */
+ // Number of values
+ ipp_attribute_t *colattr; // Collection attribute
cupsFilePrintf(data->outfile, "%*s", indent, "");
ipp_t *col = ippGetCollection(attr, 0);
cupsFilePuts(data->outfile, ": {\n");
- colattr = ippFirstAttribute(col);
+ colattr = ippGetFirstAttribute(col);
while (colattr)
{
print_json_attr(data, colattr, indent + 4);
- colattr = ippNextAttribute(col);
+ colattr = ippGetNextAttribute(col);
cupsFilePuts(data->outfile, colattr ? ",\n" : "\n");
}
cupsFilePrintf(data->outfile, "%*s}", indent, "");
ipp_t *col = ippGetCollection(attr, i);
cupsFilePrintf(data->outfile, "%*s{\n", indent + 4, "");
- colattr = ippFirstAttribute(col);
+ colattr = ippGetFirstAttribute(col);
while (colattr)
{
print_json_attr(data, colattr, indent + 8);
- colattr = ippNextAttribute(col);
+ colattr = ippGetNextAttribute(col);
cupsFilePuts(data->outfile, colattr ? ",\n" : "\n");
}
cupsFilePrintf(data->outfile, "%*s}%s", indent + 4, "", (i + 1) < count ? ",\n" : "\n");
break;
default :
- /* Out-of-band value */
- cupsFilePrintf(data->outfile, ": null");
+ // Out-of-band value
+ cupsFilePrintf(data->outfile, ": null");
break;
}
}
-/*
- * 'print_json_string()' - Print a string in JSON format.
- */
+//
+// 'print_json_string()' - Print a string in JSON format.
+//
static void
print_json_string(
- ipptool_test_t *data, /* I - Test data */
- const char *s, /* I - String to print */
- size_t len) /* I - Length of string */
+ ipptool_test_t *data, // I - Test data
+ const char *s, // I - String to print
+ size_t len) // I - Length of string
{
cupsFilePutChar(data->outfile, '\"');
while (len > 0)
}
-/*
- * 'print_line()' - Print a line of formatted or CSV text.
- */
+//
+// 'print_line()' - Print a line of formatted or CSV text.
+//
-static ipp_attribute_t * /* O - Next attribute */
+static ipp_attribute_t * // O - Next attribute
print_line(
- ipptool_test_t *data, /* I - Test data */
- ipp_t *ipp, /* I - Response message */
- ipp_attribute_t *attr, /* I - First attribute for line */
- int num_displayed, /* I - Number of attributes to display */
- char **displayed, /* I - Attributes to display */
- size_t *widths) /* I - Column widths */
+ ipptool_test_t *data, // I - Test data
+ ipp_t *ipp, // I - Response message
+ ipp_attribute_t *attr, // I - First attribute for line
+ int num_displayed, // I - Number of attributes to display
+ char **displayed, // I - Attributes to display
+ int *widths) // I - Column widths
{
- int i; /* Looping var */
- size_t maxlength; /* Max length of all columns */
- ipp_attribute_t *current = attr; /* Current attribute */
- char *values[MAX_DISPLAY]; /* Strings to display */
-
+ int i; // Looping var
+ int maxlength; // Max length of all columns
+ ipp_attribute_t *current = attr; // Current attribute
+ char *values[MAX_DISPLAY]; // Strings to display
- /*
- * Get the maximum string length we have to show and allocate...
- */
+ // Get the maximum string length we have to show and allocate...
for (i = 1, maxlength = widths[0]; i < num_displayed; i ++)
+ {
if (widths[i] > maxlength)
maxlength = widths[i];
+ }
maxlength += 2;
- /*
- * Loop through the attributes to display...
- */
-
+ // Loop through the attributes to display...
if (attr)
{
// Collect the values...
memset(values, 0, sizeof(values));
- for (; current; current = ippNextAttribute(ipp))
+ for (; current; current = ippGetNextAttribute(ipp))
{
if (!ippGetName(current))
break;
{
if (!strcmp(ippGetName(current), displayed[i]))
{
- if ((values[i] = (char *)calloc(1, maxlength)) != NULL)
- ippAttributeString(current, values[i], maxlength);
+ if ((values[i] = (char *)calloc(1, (size_t)maxlength)) != NULL)
+ ippAttributeString(current, values[i], (size_t)maxlength);
break;
}
}
else
{
// Show column headings...
- char *buffer = (char *)malloc(maxlength);
+ char *buffer = (char *)malloc((size_t)maxlength);
// Buffer for separator lines
if (!buffer)
}
-/*
- * 'print_xml_header()' - Print a standard XML plist header.
- */
+//
+// 'print_xml_header()' - Print a standard XML plist header.
+//
static void
-print_xml_header(ipptool_test_t *data)/* I - Test data */
+print_xml_header(ipptool_test_t *data)// I - Test data
{
if (!data->xml_header)
{
}
-/*
- * 'print_xml_string()' - Print an XML string with escaping.
- */
+//
+// 'print_xml_string()' - Print an XML string with escaping.
+//
static void
-print_xml_string(cups_file_t *outfile, /* I - Test data */
- const char *element, /* I - Element name or NULL */
- const char *s) /* I - String to print */
+print_xml_string(cups_file_t *outfile, // I - Test data
+ const char *element, // I - Element name or NULL
+ const char *s) // I - String to print
{
if (element)
cupsFilePrintf(outfile, "<%s>", element);
while (*s)
{
if (*s == '&')
+ {
cupsFilePuts(outfile, "&");
+ }
else if (*s == '<')
+ {
cupsFilePuts(outfile, "<");
+ }
else if (*s == '>')
+ {
cupsFilePuts(outfile, ">");
+ }
else if ((*s & 0xe0) == 0xc0)
{
- /*
- * Validate UTF-8 two-byte sequence...
- */
-
+ // Validate UTF-8 two-byte sequence...
if ((s[1] & 0xc0) != 0x80)
{
cupsFilePutChar(outfile, '?');
}
else if ((*s & 0xf0) == 0xe0)
{
- /*
- * Validate UTF-8 three-byte sequence...
- */
-
+ // Validate UTF-8 three-byte sequence...
if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80)
{
cupsFilePutChar(outfile, '?');
}
else if ((*s & 0xf8) == 0xf0)
{
- /*
- * Validate UTF-8 four-byte sequence...
- */
-
- if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 ||
- (s[3] & 0xc0) != 0x80)
+ // Validate UTF-8 four-byte sequence...
+ if ((s[1] & 0xc0) != 0x80 || (s[2] & 0xc0) != 0x80 || (s[3] & 0xc0) != 0x80)
{
cupsFilePutChar(outfile, '?');
s += 3;
}
else if ((*s & 0x80) || (*s < ' ' && !isspace(*s & 255)))
{
- /*
- * Invalid control character...
- */
-
+ // Invalid control character...
cupsFilePutChar(outfile, '?');
}
else
+ {
cupsFilePutChar(outfile, *s);
+ }
s ++;
}
}
-/*
- * 'print_xml_trailer()' - Print the XML trailer with success/fail value.
- */
+//
+// 'print_xml_trailer()' - Print the XML trailer with success/fail value.
+//
static void
print_xml_trailer(
- ipptool_test_t *data, /* I - Test data */
- int success, /* I - 1 on success, 0 on failure */
- const char *message) /* I - Error message or NULL */
+ ipptool_test_t *data, // I - Test data
+ int success, // I - 1 on success, 0 on failure
+ const char *message) // I - Error message or NULL
{
if (data->xml_header)
{
#ifndef _WIN32
-/*
- * 'sigterm_handler()' - Handle SIGINT and SIGTERM.
- */
+//
+// 'sigterm_handler()' - Handle SIGINT and SIGTERM.
+//
static void
-sigterm_handler(int sig) /* I - Signal number (unused) */
+sigterm_handler(int sig) // I - Signal number (unused)
{
(void)sig;
- Cancel = 1;
+ Cancel = true;
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
}
-#endif /* !_WIN32 */
+#endif // !_WIN32
-/*
- * 'timeout_cb()' - Handle HTTP timeouts.
- */
+//
+// 'timeout_cb()' - Handle HTTP timeouts.
+//
-static int /* O - 1 to continue, 0 to cancel */
-timeout_cb(http_t *http, /* I - Connection to server */
- void *user_data) /* I - User data (unused) */
+static int // O - 1 to continue, 0 to cancel
+timeout_cb(http_t *http, // I - Connection to server
+ void *user_data) // I - User data (unused)
{
- int buffered = 0; /* Bytes buffered but not yet sent */
+ int buffered = 0; // Bytes buffered but not yet sent
(void)user_data;
- /*
- * If the socket still have data waiting to be sent to the printer (as can
- * happen if the printer runs out of paper), continue to wait until the output
- * buffer is empty...
- */
-
-#ifdef SO_NWRITE /* macOS and some versions of Linux */
- socklen_t len = sizeof(buffered); /* Size of return value */
+ // If the socket still have data waiting to be sent to the printer (as can
+ // happen if the printer runs out of paper), continue to wait until the output
+ // buffer is empty...
+#ifdef SO_NWRITE // macOS and some versions of Linux
+ socklen_t len = sizeof(buffered); // Size of return value
if (getsockopt(httpGetFd(http), SOL_SOCKET, SO_NWRITE, &buffered, &len))
buffered = 0;
-#elif defined(SIOCOUTQ) /* Others except Windows */
+#elif defined(SIOCOUTQ) // Others except Windows
if (ioctl(httpGetFd(http), SIOCOUTQ, &buffered))
buffered = 0;
-#else /* Windows (not possible) */
+#else // Windows (not possible)
(void)http;
-#endif /* SO_NWRITE */
+#endif // SO_NWRITE
return (buffered > 0);
}
-/*
- * 'token_cb()' - Parse test file-specific tokens and run tests.
- */
+//
+// 'token_cb()' - Parse test file-specific tokens and run tests.
+//
-static int /* O - 1 to continue, 0 to stop */
-token_cb(_ipp_file_t *f, /* I - IPP file data */
- _ipp_vars_t *vars, /* I - IPP variables */
- ipptool_test_t *data, /* I - Test data */
- const char *token) /* I - Current token */
+static bool // O - `true` to continue, `false` to stop
+token_cb(ipp_file_t *f, // I - IPP file data
+ ipptool_test_t *data, // I - Test data
+ const char *token) // I - Current token
{
- char name[1024], /* Name string */
- temp[1024], /* Temporary string */
- value[1024], /* Value string */
- *ptr; /* Pointer into value */
+ char name[1024], // Name string
+ temp[1024], // Temporary string
+ value[1024], // Value string
+ *ptr; // Pointer into value
- if (!token)
- {
- /*
- * Initialize state as needed (nothing for now...)
- */
+ if (getenv("IPPTOOL_DEBUG"))
+ fprintf(stderr, "ipptool: token='%s'\n", token);
- return (1);
- }
- else if (f->attrs)
+ if (ippFileGetAttributes(f))
{
- /*
- * Parse until we see a close brace...
- */
-
+ // Parse until we see a close brace...
if (_cups_strcasecmp(token, "COUNT") &&
_cups_strcasecmp(token, "DEFINE-MATCH") &&
_cups_strcasecmp(token, "DEFINE-NO-MATCH") &&
_cups_strcasecmp(token, "REPEAT-MATCH") &&
_cups_strcasecmp(token, "REPEAT-NO-MATCH") &&
_cups_strcasecmp(token, "SAME-COUNT-AS") &&
+ _cups_strcasecmp(token, "SAVE-ALL-CONTENT") &&
+ _cups_strcasecmp(token, "SAVE-CONTENT") &&
+ _cups_strcasecmp(token, "WITH-ALL-CONTENT") &&
+ _cups_strcasecmp(token, "WITH-ALL-MIME-TYPES") &&
_cups_strcasecmp(token, "WITH-ALL-VALUES") &&
+ _cups_strcasecmp(token, "WITH-ALL-VALUES-FROM") &&
_cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") &&
_cups_strcasecmp(token, "WITH-ALL-RESOURCES") &&
_cups_strcasecmp(token, "WITH-ALL-SCHEMES") &&
+ _cups_strcasecmp(token, "WITH-CONTENT") &&
_cups_strcasecmp(token, "WITH-DISTINCT-VALUES") &&
_cups_strcasecmp(token, "WITH-HOSTNAME") &&
+ _cups_strcasecmp(token, "WITH-MIME-TYPES") &&
_cups_strcasecmp(token, "WITH-RESOURCE") &&
_cups_strcasecmp(token, "WITH-SCHEME") &&
_cups_strcasecmp(token, "WITH-VALUE") &&
{
return (do_test(f, data));
}
+ else if (!strcmp(token, "GENERATE-FILE"))
+ {
+ if (data->generate_params)
+ {
+ print_fatal_error(data, "Extra GENERATE-FILE seen on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+ else if (data->file[0])
+ {
+ print_fatal_error(data, "Cannot use GENERATE-FILE on line %d of '%s' with FILE.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+
+ return (parse_generate_file(f, data));
+ }
else if (!strcmp(token, "MONITOR-PRINTER-STATE"))
{
if (data->monitor_uri)
{
- print_fatal_error(data, "Extra MONITOR-PRINTER-STATE seen on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Extra MONITOR-PRINTER-STATE seen on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
return (parse_monitor_printer_state(f, data));
}
else if (!strcmp(token, "COMPRESSION"))
{
- /*
- * COMPRESSION none
- * COMPRESSION deflate
- * COMPRESSION gzip
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // COMPRESSION none
+ // COMPRESSION deflate
+ // COMPRESSION gzip
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
- _ippVarsExpand(vars, data->compression, temp, sizeof(data->compression));
-#ifdef HAVE_LIBZ
- if (strcmp(data->compression, "none") && strcmp(data->compression, "deflate") &&
- strcmp(data->compression, "gzip"))
-#else
- if (strcmp(data->compression, "none"))
-#endif /* HAVE_LIBZ */
+ ippFileExpandVars(f, data->compression, temp, sizeof(data->compression));
+ if (strcmp(data->compression, "none") && strcmp(data->compression, "deflate") && strcmp(data->compression, "gzip"))
{
- print_fatal_error(data, "Unsupported COMPRESSION value \"%s\" on line %d of \"%s\".", data->compression, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Unsupported COMPRESSION value \"%s\" on line %d of '%s'.", data->compression, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (!strcmp(data->compression, "none"))
}
else
{
- print_fatal_error(data, "Missing COMPRESSION value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing COMPRESSION value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "DEFINE"))
{
- /*
- * DEFINE name value
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)) && _ippFileReadToken(f, temp, sizeof(temp)))
+ // DEFINE name value
+ if (ippFileReadToken(f, name, sizeof(name)) && ippFileReadToken(f, temp, sizeof(temp)))
{
- _ippVarsExpand(vars, value, temp, sizeof(value));
- _ippVarsSet(vars, name, value);
+ ippFileExpandVars(f, value, temp, sizeof(value));
+ ippFileSetVar(f, name, value);
}
else
{
- print_fatal_error(data, "Missing DEFINE name and/or value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DEFINE name and/or value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "IGNORE-ERRORS"))
{
- /*
- * IGNORE-ERRORS yes
- * IGNORE-ERRORS no
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
+ // IGNORE-ERRORS yes
+ // IGNORE-ERRORS no
+ if (ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
{
data->ignore_errors = !_cups_strcasecmp(temp, "yes");
}
else
{
- print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "NAME"))
{
- /*
- * Name of test...
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // Name of test...
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
- _ippVarsExpand(vars, data->name, temp, sizeof(data->name));
+ ippFileExpandVars(f, data->name, temp, sizeof(data->name));
}
else
{
- print_fatal_error(data, "Missing NAME string on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing NAME string on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "PAUSE"))
{
- /*
- * Pause with a message...
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // Pause with a message...
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
cupsCopyString(data->pause, temp, sizeof(data->pause));
}
else
{
- print_fatal_error(data, "Missing PAUSE message on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing PAUSE message on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "REQUEST-ID"))
{
- /*
- * REQUEST-ID #
- * REQUEST-ID random
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // REQUEST-ID #
+ // REQUEST-ID random
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
if (isdigit(temp[0] & 255))
{
}
else if (!_cups_strcasecmp(temp, "random"))
{
- data->request_id = (CUPS_RAND() % 1000) * 137;
+ data->request_id = (cupsGetRand() % 1000) * 137;
}
else
{
- print_fatal_error(data, "Bad REQUEST-ID value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad REQUEST-ID value \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing REQUEST-ID value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing REQUEST-ID value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "PASS-IF-DEFINED"))
{
- /*
- * PASS-IF-DEFINED variable
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)))
+ // PASS-IF-DEFINED variable
+ if (ippFileReadToken(f, name, sizeof(name)))
{
- if (_ippVarsGet(vars, name))
+ if (ippFileGetVar(f, name))
data->pass_test = 1;
}
else
{
- print_fatal_error(data, "Missing PASS-IF-DEFINED value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing PASS-IF-DEFINED value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "PASS-IF-NOT-DEFINED"))
{
- /*
- * PASS-IF-NOT-DEFINED variable
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)))
+ // PASS-IF-NOT-DEFINED variable
+ if (ippFileReadToken(f, name, sizeof(name)))
{
- if (!_ippVarsGet(vars, name))
+ if (!ippFileGetVar(f, name))
data->pass_test = 1;
}
else
{
- print_fatal_error(data, "Missing PASS-IF-NOT-DEFINED value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing PASS-IF-NOT-DEFINED value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "SKIP-IF-DEFINED"))
{
- /*
- * SKIP-IF-DEFINED variable
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)))
+ // SKIP-IF-DEFINED variable
+ if (ippFileReadToken(f, name, sizeof(name)))
{
- if (_ippVarsGet(vars, name))
- data->skip_test = 1;
+ if (ippFileGetVar(f, name) || getenv(name))
+ data->skip_test = true;
}
else
{
- print_fatal_error(data, "Missing SKIP-IF-DEFINED value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing SKIP-IF-DEFINED value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "SKIP-IF-MISSING"))
{
- /*
- * SKIP-IF-MISSING filename
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // SKIP-IF-MISSING filename
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
- char filename[1024]; /* Filename */
+ char filename[1024]; // Filename
- _ippVarsExpand(vars, value, temp, sizeof(value));
- get_filename(f->filename, filename, temp, sizeof(filename));
+ ippFileExpandVars(f, value, temp, sizeof(value));
+ get_filename(ippFileGetFilename(f), filename, temp, sizeof(filename));
if (access(filename, R_OK))
- data->skip_test = 1;
+ data->skip_test = true;
}
else
{
- print_fatal_error(data, "Missing SKIP-IF-MISSING filename on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing SKIP-IF-MISSING filename on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "SKIP-IF-NOT-DEFINED"))
{
- /*
- * SKIP-IF-NOT-DEFINED variable
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)))
+ // SKIP-IF-NOT-DEFINED variable
+ if (ippFileReadToken(f, name, sizeof(name)))
{
- if (!_ippVarsGet(vars, name))
- data->skip_test = 1;
+ if (!ippFileGetVar(f, name) && !getenv(name))
+ data->skip_test = true;
}
else
{
- print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "SKIP-PREVIOUS-ERROR"))
{
- /*
- * SKIP-PREVIOUS-ERROR yes
- * SKIP-PREVIOUS-ERROR no
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
+ // SKIP-PREVIOUS-ERROR yes
+ // SKIP-PREVIOUS-ERROR no
+ if (ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
{
data->skip_previous = !_cups_strcasecmp(temp, "yes");
}
else
{
- print_fatal_error(data, "Missing SKIP-PREVIOUS-ERROR value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing SKIP-PREVIOUS-ERROR value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "TEST-ID"))
{
- /*
- * TEST-ID "string"
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // TEST-ID "string"
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
- _ippVarsExpand(vars, data->test_id, temp, sizeof(data->test_id));
+ ippFileExpandVars(f, data->test_id, temp, sizeof(data->test_id));
}
else
{
- print_fatal_error(data, "Missing TEST-ID value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing TEST-ID value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "TRANSFER"))
{
- /*
- * TRANSFER auto
- * TRANSFER chunked
- * TRANSFER length
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // TRANSFER auto
+ // TRANSFER chunked
+ // TRANSFER length
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
if (!strcmp(temp, "auto"))
{
}
else
{
- print_fatal_error(data, "Bad TRANSFER value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad TRANSFER value \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing TRANSFER value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing TRANSFER value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "VERSION"))
{
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
if (!strcmp(temp, "0.0"))
{
}
else
{
- print_fatal_error(data, "Bad VERSION \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad VERSION \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing VERSION number on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing VERSION number on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "RESOURCE"))
{
- /*
- * Resource name...
- */
-
- if (!_ippFileReadToken(f, data->resource, sizeof(data->resource)))
+ // Resource name...
+ if (!ippFileReadToken(f, data->resource, sizeof(data->resource)))
{
- print_fatal_error(data, "Missing RESOURCE path on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing RESOURCE path on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "OPERATION"))
{
- /*
- * Operation...
- */
-
- ipp_op_t op; /* Operation code */
+ // Operation...
+ ipp_op_t op; // Operation code
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing OPERATION code on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing OPERATION code on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- _ippVarsExpand(vars, value, temp, sizeof(value));
+ ippFileExpandVars(f, value, temp, sizeof(value));
if ((op = ippOpValue(value)) == (ipp_op_t)-1 && (op = (ipp_op_t)strtol(value, NULL, 0)) == 0)
{
- print_fatal_error(data, "Bad OPERATION code \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
- }
-
- ippSetOperation(f->attrs, op);
- }
- else if (!_cups_strcasecmp(token, "GROUP"))
- {
- /*
- * Attribute group...
- */
-
- ipp_tag_t group_tag; /* Group tag */
-
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
- {
- print_fatal_error(data, "Missing GROUP tag on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
- }
-
- if ((group_tag = ippTagValue(temp)) == IPP_TAG_ZERO || group_tag >= IPP_TAG_UNSUPPORTED_VALUE)
- {
- print_fatal_error(data, "Bad GROUP tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad OPERATION code \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- if (group_tag == f->group_tag)
- ippAddSeparator(f->attrs);
-
- f->group_tag = group_tag;
+ data->op = op;
}
else if (!_cups_strcasecmp(token, "DELAY"))
{
- /*
- * Delay before operation...
- */
-
- double dval; /* Delay value */
+ // Delay before operation...
+ double dval; // Delay value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DELAY value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- _ippVarsExpand(vars, value, temp, sizeof(value));
+ ippFileExpandVars(f, value, temp, sizeof(value));
if ((dval = _cupsStrScand(value, &ptr, localeconv())) < 0.0 || (*ptr && *ptr != ','))
{
- print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
data->delay = (useconds_t)(1000000.0 * dval);
{
if ((dval = _cupsStrScand(ptr + 1, &ptr, localeconv())) <= 0.0 || *ptr)
{
- print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of '%s'.", value, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
data->repeat_interval = (useconds_t)(1000000.0 * dval);
}
else
+ {
data->repeat_interval = data->delay;
+ }
}
else if (!_cups_strcasecmp(token, "FILE"))
{
- /*
- * File...
- */
+ // File...
+ if (data->file[0])
+ {
+ print_fatal_error(data, "Extra FILE seen on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+ else if (data->generate_params)
+ {
+ print_fatal_error(data, "Cannot use FILE on line %d of '%s' with GENERATE-FILE.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing FILE filename on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing FILE filename on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- _ippVarsExpand(vars, value, temp, sizeof(value));
- get_filename(f->filename, data->file, value, sizeof(data->file));
+ ippFileExpandVars(f, value, temp, sizeof(value));
+ get_filename(ippFileGetFilename(f), data->file, value, sizeof(data->file));
if (access(data->file, R_OK))
{
- print_fatal_error(data, "Filename \"%s\" (mapped to \"%s\") on line %d of \"%s\" cannot be read.", value, data->file, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Filename \"%s\" (mapped to \"%s\") on line %d of '%s' cannot be read.", value, data->file, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "STATUS"))
{
- /*
- * Status...
- */
-
+ // Status...
if (data->num_statuses >= (int)(sizeof(data->statuses) / sizeof(data->statuses[0])))
{
- print_fatal_error(data, "Too many STATUS's on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Too many STATUS's on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing STATUS code on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing STATUS code on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if ((data->statuses[data->num_statuses].status = ippErrorValue(temp)) == (ipp_status_t)-1 && (data->statuses[data->num_statuses].status = (ipp_status_t)strtol(temp, NULL, 0)) == 0)
{
- print_fatal_error(data, "Bad STATUS code \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad STATUS code \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
data->last_status = data->statuses + data->num_statuses;
}
else if (!_cups_strcasecmp(token, "EXPECT") || !_cups_strcasecmp(token, "EXPECT-ALL"))
{
- /*
- * Expected attributes...
- */
-
+ // Expected attributes...
int expect_all = !_cups_strcasecmp(token, "EXPECT-ALL");
if (data->num_expects >= (int)(sizeof(data->expects) / sizeof(data->expects[0])))
{
- print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Too many EXPECT's on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- if (!_ippFileReadToken(f, name, sizeof(name)))
+ if (!ippFileReadToken(f, name, sizeof(name)))
{
- print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing EXPECT name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
data->last_expect = data->expects + data->num_expects;
}
else if (!_cups_strcasecmp(token, "COUNT"))
{
- int count; /* Count value */
+ int count; // Count value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing COUNT number on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- if ((count = atoi(temp)) <= 0)
+ if ((count = strtol(temp, NULL, 10)) > INT_MAX)
{
- print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad COUNT \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "DEFINE-MATCH"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "DEFINE-VALUE"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "DISPLAY-MATCH"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DISPLAY-MATCH mesaage on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DISPLAY-MATCH mesaage on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "OF-TYPE"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "IN-GROUP"))
{
- ipp_tag_t in_group; /* IN-GROUP value */
+ ipp_tag_t in_group; // IN-GROUP value
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing IN-GROUP group tag on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if ((in_group = ippTagValue(temp)) == IPP_TAG_ZERO || in_group >= IPP_TAG_UNSUPPORTED_VALUE)
{
- print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
else if (data->last_expect)
{
}
else
{
- print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "REPEAT-LIMIT"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing REPEAT-LIMIT value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing REPEAT-LIMIT value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
else if (atoi(temp) <= 0)
{
- print_fatal_error(data, "Bad REPEAT-LIMIT value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad REPEAT-LIMIT value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_status)
}
else
{
- print_fatal_error(data, "REPEAT-LIMIT without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "REPEAT-LIMIT without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "REPEAT-MATCH"))
}
else
{
- print_fatal_error(data, "REPEAT-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "REPEAT-MATCH without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "REPEAT-NO-MATCH"))
}
else
{
- print_fatal_error(data, "REPEAT-NO-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "REPEAT-NO-MATCH without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+ }
+ else if (!_cups_strcasecmp(token, "SAME-COUNT-AS"))
+ {
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing SAME-COUNT-AS name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+
+ if (data->last_expect)
+ {
+ data->last_expect->same_count_as = strdup(temp);
+ }
+ else
+ {
+ print_fatal_error(data, "SAME-COUNT-AS without a preceding EXPECT on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
- else if (!_cups_strcasecmp(token, "SAME-COUNT-AS"))
+ else if (!_cups_strcasecmp(token, "SAVE-ALL-CONTENT") || !_cups_strcasecmp(token, "SAVE-CONTENT"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing SAME-COUNT-AS name on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing %s filespec on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
{
- data->last_expect->same_count_as = strdup(temp);
+ data->last_expect->save_filespec = strdup(temp);
}
else
{
- print_fatal_error(data, "SAME-COUNT-AS without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "IF-DEFINED"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing IF-DEFINED name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "IF-DEFINED without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "IF-DEFINED without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
}
else
{
- print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT or STATUS on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT or STATUS on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+ }
+ else if (!_cups_strcasecmp(token, "WITH-ALL-CONTENT") || !_cups_strcasecmp(token, "WITH-CONTENT"))
+ {
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing %s condition on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+
+ if (data->last_expect)
+ {
+ if (!_cups_strcasecmp(temp, "available"))
+ {
+ data->last_expect->with_content = IPPTOOL_CONTENT_AVAILABLE;
+ }
+ else if (!_cups_strcasecmp(temp, "valid"))
+ {
+ data->last_expect->with_content = IPPTOOL_CONTENT_VALID;
+ }
+ else if (!_cups_strcasecmp(temp, "valid-icon"))
+ {
+ data->last_expect->with_content = IPPTOOL_CONTENT_VALID_ICON;
+ }
+ else
+ {
+ print_fatal_error(data, "Unsupported %s %s on line %d of '%s'.", token, temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+ }
+ else
+ {
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+ }
+ else if (!_cups_strcasecmp(token, "WITH-ALL-MIME-TYPES") || !_cups_strcasecmp(token, "WITH-MIME-TYPES"))
+ {
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
+ {
+ print_fatal_error(data, "Missing %s MIME media type(s) on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
+ }
+
+ if (data->last_expect)
+ {
+ data->last_expect->with_mime_types = cupsArrayNewStrings(temp, ',');
+ }
+ else
+ {
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "WITH-DISTINCT-VALUES"))
}
else
{
- print_fatal_error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "WITH-ALL-VALUES") ||
!_cups_strcasecmp(token, "WITH-SCHEME") ||
!_cups_strcasecmp(token, "WITH-VALUE"))
{
- off_t lastpos; /* Last file position */
- int lastline; /* Last line number */
-
if (data->last_expect)
{
if (!_cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") || !_cups_strcasecmp(token, "WITH-HOSTNAME"))
data->last_expect->with_flags |= IPPTOOL_WITH_ALL;
}
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing %s value on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- /*
- * Read additional comma-delimited values - needed since legacy test files
- * will have unquoted WITH-VALUE values with commas...
- */
-
+ // Read additional comma-delimited values - needed since legacy test files
+ // will have unquoted WITH-VALUE values with commas...
ptr = temp + strlen(temp);
for (;;)
{
- lastpos = cupsFileTell(f->fp);
- lastline = f->linenum;
- ptr += strlen(ptr);
+ ippFileSavePosition(f);
+
+ ptr += strlen(ptr);
- if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
+ if (!ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
break;
if (!strcmp(ptr, ","))
{
- /*
- * Append a value...
- */
-
+ // Append a value...
ptr += strlen(ptr);
- if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
+ if (!ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
break;
}
else
{
- /*
- * Not another value, stop here...
- */
+ // Not another value, stop here...
+ ippFileRestorePosition(f);
- cupsFileSeek(f->fp, lastpos);
- f->linenum = lastline;
*ptr = '\0';
break;
}
if (data->last_expect)
{
- /*
- * Expand any variables in the value and then save it.
- */
-
- _ippVarsExpand(vars, value, temp, sizeof(value));
+ // Expand any variables in the value and then save it.
+ ippFileExpandVars(f, value, temp, sizeof(value));
ptr = value + strlen(value) - 1;
if (value[0] == '/' && ptr > value && *ptr == '/')
{
- /*
- * WITH-VALUE is a POSIX extended regular expression.
- */
-
+ // WITH-VALUE is a POSIX extended regular expression.
data->last_expect->with_value = calloc(1, (size_t)(ptr - value));
data->last_expect->with_flags |= IPPTOOL_WITH_REGEX;
}
else
{
- /*
- * WITH-VALUE is a literal value...
- */
-
+ // WITH-VALUE is a literal value...
for (ptr = value; *ptr; ptr ++)
{
if (*ptr == '\\' && ptr[1])
{
- /*
- * Remove \ from \foo...
- */
-
+ // Remove \ from \foo...
_cups_strcpy(ptr, ptr + 1);
}
}
}
else
{
- print_fatal_error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
- else if (!_cups_strcasecmp(token, "WITH-VALUE-FROM"))
+ else if (!_cups_strcasecmp(token, "WITH-ALL-VALUES-FROM") ||
+ !_cups_strcasecmp(token, "WITH-VALUE-FROM"))
{
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing %s value on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
if (data->last_expect)
{
- /*
- * Expand any variables in the value and then save it.
- */
-
- _ippVarsExpand(vars, value, temp, sizeof(value));
+ // Expand any variables in the value and then save it.
+ ippFileExpandVars(f, value, temp, sizeof(value));
data->last_expect->with_value_from = strdup(value);
data->last_expect->with_flags = IPPTOOL_WITH_LITERAL;
+
+ if (!_cups_strncasecmp(token, "WITH-ALL-", 9))
+ data->last_expect->with_flags |= IPPTOOL_WITH_ALL;
}
else
{
- print_fatal_error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "%s without a preceding EXPECT on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!_cups_strcasecmp(token, "DISPLAY"))
{
- /*
- * Display attributes...
- */
-
+ // Display attributes...
if (data->num_displayed >= (int)(sizeof(data->displayed) / sizeof(data->displayed[0])))
{
- print_fatal_error(data, "Too many DISPLAY's on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Too many DISPLAY's on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- if (!_ippFileReadToken(f, temp, sizeof(temp)))
+ if (!ippFileReadToken(f, temp, sizeof(temp)))
{
- print_fatal_error(data, "Missing DISPLAY name on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DISPLAY name on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
data->displayed[data->num_displayed] = strdup(temp);
}
else
{
- print_fatal_error(data, "Unexpected token %s seen on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Unexpected token %s seen on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- /*
- * Scan for the start of a test (open brace)...
- */
-
+ // Scan for the start of a test (open brace)...
if (!strcmp(token, "{"))
{
- /*
- * Start new test...
- */
+ // Start new test...
+ const char *resource; // Resource path
if (data->show_header)
{
print_xml_header(data);
if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile != cupsFileStdout()))
- cupsFilePrintf(cupsFileStdout(), "\"%s\":\n", f->filename);
+ cupsFilePrintf(cupsFileStdout(), "\"%s\":\n", ippFileGetFilename(f));
- data->show_header = 0;
+ data->show_header = false;
}
+ if ((resource = ippFileGetVar(data->parent, "resource")) == NULL)
+ resource = "/ipp/print";
+
data->compression[0] = '\0';
data->delay = 0;
data->num_expects = 0;
data->last_expect = NULL;
data->file[0] = '\0';
data->ignore_errors = data->def_ignore_errors;
- cupsCopyString(data->name, f->filename, sizeof(data->name));
+ cupsCopyString(data->name, ippFileGetFilename(f), sizeof(data->name));
if ((ptr = strrchr(data->name, '.')) != NULL)
*ptr = '\0';
data->repeat_interval = 5000000;
- cupsCopyString(data->resource, data->vars->resource, sizeof(data->resource));
- data->skip_previous = 0;
- data->pass_test = 0;
- data->skip_test = 0;
+ cupsCopyString(data->resource, resource, sizeof(data->resource));
+ data->skip_previous = false;
+ data->pass_test = false;
+ data->skip_test = false;
data->num_statuses = 0;
data->last_status = NULL;
data->test_id[0] = '\0';
data->monitor_interval = 5000000;
data->num_monitor_expects = 0;
- _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
-
- f->attrs = ippNew();
- f->group_tag = IPP_TAG_ZERO;
+ ippFileSetAttributes(f, ippNew());
+ ippFileSetVar(f, "date-current", iso_date(ippTimeToDate(time(NULL))));
}
else if (!strcmp(token, "DEFINE"))
{
- /*
- * DEFINE name value
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)) && _ippFileReadToken(f, temp, sizeof(temp)))
+ // DEFINE name value
+ if (ippFileReadToken(f, name, sizeof(name)) && ippFileReadToken(f, temp, sizeof(temp)))
{
- _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
- _ippVarsExpand(vars, value, temp, sizeof(value));
- _ippVarsSet(vars, name, value);
+ ippFileSetVar(f, "date-current", iso_date(ippTimeToDate(time(NULL))));
+ ippFileExpandVars(f, value, temp, sizeof(value));
+ ippFileSetVar(f, name, value);
}
else
{
- print_fatal_error(data, "Missing DEFINE name and/or value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DEFINE name and/or value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "DEFINE-DEFAULT"))
{
- /*
- * DEFINE-DEFAULT name value
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)) && _ippFileReadToken(f, temp, sizeof(temp)))
+ // DEFINE-DEFAULT name value
+ if (ippFileReadToken(f, name, sizeof(name)) && ippFileReadToken(f, temp, sizeof(temp)))
{
- if (!_ippVarsGet(vars, name))
+ if (!ippFileGetVar(f, name))
{
- _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
- _ippVarsExpand(vars, value, temp, sizeof(value));
- _ippVarsSet(vars, name, value);
+ ippFileSetVar(f, "date-current", iso_date(ippTimeToDate(time(NULL))));
+ ippFileExpandVars(f, value, temp, sizeof(value));
+ ippFileSetVar(f, name, value);
}
}
else
{
- print_fatal_error(data, "Missing DEFINE-DEFAULT name and/or value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing DEFINE-DEFAULT name and/or value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "FILE-ID"))
{
- /*
- * FILE-ID "string"
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // FILE-ID "string"
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
- _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
- _ippVarsExpand(vars, data->file_id, temp, sizeof(data->file_id));
+ ippFileSetVar(f, "date-current", iso_date(ippTimeToDate(time(NULL))));
+ ippFileExpandVars(f, data->file_id, temp, sizeof(data->file_id));
}
else
{
- print_fatal_error(data, "Missing FILE-ID value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing FILE-ID value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "IGNORE-ERRORS"))
{
- /*
- * IGNORE-ERRORS yes
- * IGNORE-ERRORS no
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
+ // IGNORE-ERRORS yes
+ // IGNORE-ERRORS no
+ if (ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
{
data->def_ignore_errors = !_cups_strcasecmp(temp, "yes");
}
else
{
- print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "INCLUDE"))
{
- /*
- * INCLUDE "filename"
- * INCLUDE <filename>
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // INCLUDE "filename"
+ // INCLUDE <filename>
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
- /*
- * Map the filename to and then run the tests...
- */
-
- ipptool_test_t inc_data; /* Data for included file */
- char filename[1024]; /* Mapped filename */
+ // Map the filename to and then run the tests...
+ ipptool_test_t inc_data; // Data for included file
+ bool inc_pass; // Include file passed?
+ char filename[1024]; // Mapped filename
memcpy(&inc_data, data, sizeof(inc_data));
+ inc_data.test_count = 0;
+ inc_data.pass_count = 0;
+ inc_data.fail_count = 0;
+ inc_data.skip_count = 0;
inc_data.http = NULL;
- inc_data.pass = 1;
- inc_data.prev_pass = 1;
- inc_data.show_header = 1;
+ inc_data.pass = true;
+ inc_data.prev_pass = true;
+ inc_data.show_header = true;
+
+ inc_pass = do_tests(get_filename(ippFileGetFilename(f), filename, temp, sizeof(filename)), &inc_data);
- if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->stop_after_include_error)
+ data->test_count += inc_data.test_count;
+ data->pass_count += inc_data.pass_count;
+ data->fail_count += inc_data.fail_count;
+ data->skip_count += inc_data.skip_count;
+
+ if (!inc_pass && data->stop_after_include_error)
{
- data->pass = data->prev_pass = 0;
- return (0);
+ data->pass = data->prev_pass = false;
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing INCLUDE filename on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing INCLUDE filename on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- data->show_header = 1;
+ data->show_header = true;
}
else if (!strcmp(token, "INCLUDE-IF-DEFINED"))
{
- /*
- * INCLUDE-IF-DEFINED name "filename"
- * INCLUDE-IF-DEFINED name <filename>
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)) && _ippFileReadToken(f, temp, sizeof(temp)))
+ // INCLUDE-IF-DEFINED name "filename"
+ // INCLUDE-IF-DEFINED name <filename>
+ if (ippFileReadToken(f, name, sizeof(name)) && ippFileReadToken(f, temp, sizeof(temp)))
{
- /*
- * Map the filename to and then run the tests...
- */
-
- ipptool_test_t inc_data; /* Data for included file */
- char filename[1024]; /* Mapped filename */
+ // Map the filename to and then run the tests...
+ ipptool_test_t inc_data; // Data for included file
+ bool inc_pass; // Include file passed?
+ char filename[1024]; // Mapped filename
memcpy(&inc_data, data, sizeof(inc_data));
+ inc_data.test_count = 0;
+ inc_data.pass_count = 0;
+ inc_data.fail_count = 0;
+ inc_data.skip_count = 0;
inc_data.http = NULL;
- inc_data.pass = 1;
- inc_data.prev_pass = 1;
- inc_data.show_header = 1;
+ inc_data.pass = true;
+ inc_data.prev_pass = true;
+ inc_data.show_header = true;
+
+ inc_pass = do_tests(get_filename(ippFileGetFilename(f), filename, temp, sizeof(filename)), &inc_data);
- if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->stop_after_include_error)
+ data->test_count += inc_data.test_count;
+ data->pass_count += inc_data.pass_count;
+ data->fail_count += inc_data.fail_count;
+ data->skip_count += inc_data.skip_count;
+
+ if (!inc_pass && data->stop_after_include_error)
{
- data->pass = data->prev_pass = 0;
- return (0);
+ data->pass = data->prev_pass = false;
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing INCLUDE-IF-DEFINED name or filename on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing INCLUDE-IF-DEFINED name or filename on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- data->show_header = 1;
+ data->show_header = true;
}
else if (!strcmp(token, "INCLUDE-IF-NOT-DEFINED"))
{
- /*
- * INCLUDE-IF-NOT-DEFINED name "filename"
- * INCLUDE-IF-NOT-DEFINED name <filename>
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)) && _ippFileReadToken(f, temp, sizeof(temp)))
+ // INCLUDE-IF-NOT-DEFINED name "filename"
+ // INCLUDE-IF-NOT-DEFINED name <filename>
+ if (ippFileReadToken(f, name, sizeof(name)) && ippFileReadToken(f, temp, sizeof(temp)))
{
- /*
- * Map the filename to and then run the tests...
- */
-
- ipptool_test_t inc_data; /* Data for included file */
- char filename[1024]; /* Mapped filename */
+ // Map the filename to and then run the tests...
+ ipptool_test_t inc_data; // Data for included file
+ bool inc_pass; // Include file passed?
+ char filename[1024]; // Mapped filename
memcpy(&inc_data, data, sizeof(inc_data));
+ inc_data.test_count = 0;
+ inc_data.pass_count = 0;
+ inc_data.fail_count = 0;
+ inc_data.skip_count = 0;
inc_data.http = NULL;
- inc_data.pass = 1;
- inc_data.prev_pass = 1;
- inc_data.show_header = 1;
+ inc_data.pass = true;
+ inc_data.prev_pass = true;
+ inc_data.show_header = true;
+
+ inc_pass = do_tests(get_filename(ippFileGetFilename(f), filename, temp, sizeof(filename)), &inc_data);
- if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->stop_after_include_error)
+ data->test_count += inc_data.test_count;
+ data->pass_count += inc_data.pass_count;
+ data->fail_count += inc_data.fail_count;
+ data->skip_count += inc_data.skip_count;
+
+ if (!inc_pass && data->stop_after_include_error)
{
- data->pass = data->prev_pass = 0;
- return (0);
+ data->pass = data->prev_pass = false;
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing INCLUDE-IF-NOT-DEFINED name or filename on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing INCLUDE-IF-NOT-DEFINED name or filename on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
- data->show_header = 1;
+ data->show_header = true;
}
else if (!strcmp(token, "SKIP-IF-DEFINED"))
{
- /*
- * SKIP-IF-DEFINED variable
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)))
+ // SKIP-IF-DEFINED variable
+ if (ippFileReadToken(f, name, sizeof(name)))
{
- if (_ippVarsGet(vars, name))
- data->skip_test = 1;
+ if (ippFileGetVar(f, name) || getenv(name))
+ data->skip_test = true;
}
else
{
- print_fatal_error(data, "Missing SKIP-IF-DEFINED variable on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing SKIP-IF-DEFINED variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "SKIP-IF-NOT-DEFINED"))
{
- /*
- * SKIP-IF-NOT-DEFINED variable
- */
-
- if (_ippFileReadToken(f, name, sizeof(name)))
+ // SKIP-IF-NOT-DEFINED variable
+ if (ippFileReadToken(f, name, sizeof(name)))
{
- if (!_ippVarsGet(vars, name))
- data->skip_test = 1;
+ if (!ippFileGetVar(f, name) && !getenv(name))
+ data->skip_test = true;
}
else
{
- print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED variable on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED variable on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "STOP-AFTER-INCLUDE-ERROR"))
{
- /*
- * STOP-AFTER-INCLUDE-ERROR yes
- * STOP-AFTER-INCLUDE-ERROR no
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
+ // STOP-AFTER-INCLUDE-ERROR yes
+ // STOP-AFTER-INCLUDE-ERROR no
+ if (ippFileReadToken(f, temp, sizeof(temp)) && (!_cups_strcasecmp(temp, "yes") || !_cups_strcasecmp(temp, "no")))
{
data->stop_after_include_error = !_cups_strcasecmp(temp, "yes");
}
else
{
- print_fatal_error(data, "Missing STOP-AFTER-INCLUDE-ERROR value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing STOP-AFTER-INCLUDE-ERROR value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "TRANSFER"))
{
- /*
- * TRANSFER auto
- * TRANSFER chunked
- * TRANSFER length
- */
-
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ // TRANSFER auto
+ // TRANSFER chunked
+ // TRANSFER length
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
if (!strcmp(temp, "auto"))
data->def_transfer = IPPTOOL_TRANSFER_AUTO;
data->def_transfer = IPPTOOL_TRANSFER_LENGTH;
else
{
- print_fatal_error(data, "Bad TRANSFER value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad TRANSFER value \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing TRANSFER value on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing TRANSFER value on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else if (!strcmp(token, "VERSION"))
{
- if (_ippFileReadToken(f, temp, sizeof(temp)))
+ if (ippFileReadToken(f, temp, sizeof(temp)))
{
if (!strcmp(temp, "1.0"))
data->def_version = 10;
data->def_version = 22;
else
{
- print_fatal_error(data, "Bad VERSION \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Bad VERSION \"%s\" on line %d of '%s'.", temp, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- print_fatal_error(data, "Missing VERSION number on line %d of \"%s\".", f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Missing VERSION number on line %d of '%s'.", ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
else
{
- print_fatal_error(data, "Unexpected token %s seen on line %d of \"%s\".", token, f->linenum, f->filename);
- return (0);
+ print_fatal_error(data, "Unexpected token %s seen on line %d of '%s'.", token, ippFileGetLineNumber(f), ippFileGetFilename(f));
+ return (false);
}
}
- return (1);
+ return (true);
}
-/*
- * 'usage()' - Show program usage.
- */
+//
+// 'usage()' - Show program usage.
+//
static void
usage(void)
}
-/*
- * 'with_distinct_values()' - Verify that an attribute contains unique values.
- */
+//
+// 'valid_image()' - Validate an image.
+//
+// Supports JPEG and PNG images.
+//
+
+static bool // O - `true` if valid, `false` if not
+valid_image(const char *filename, // I - Image filename
+ int *width, // O - Width in columns
+ int *height, // O - Height in lines
+ int *depth) // O - Number of color planes
+{
+ bool ret = true; // Return value
+ int fd; // File descriptor
+ unsigned char buffer[16384], // Read buffer
+ *bufptr, // Pointer into buffer
+ *bufend; // End of buffer
+ ssize_t bytes; // Number of bytes read
+
+
+ // Initialize things...
+ *width = *height = *depth = 0;
+
+ // Try opening the file and reading from it...
+ if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
+ {
+ // Unable to open...
+ ret = false;
+ }
+ else if ((bytes = read(fd, buffer, sizeof(buffer))) < 16)
+ {
+ // Unable to read...
+ ret = false;
+ }
+ else if (!memcmp(buffer, "\211PNG\015\012\032\012\000\000\000\015IHDR", 16) && bytes > 25)
+ {
+ // PNG image...
+ *width = (int)((buffer[16] << 24) | (buffer[17] << 16) | (buffer[18] << 8) | buffer[19]);
+ *height = (int)((buffer[20] << 24) | (buffer[21] << 16) | (buffer[22] << 8) | buffer[23]);
+ *depth = ((buffer[25] & 3) == 0 ? 1 : 3) + ((buffer[25] & 4) ? 1 : 0);
+ }
+ else if (!memcmp(buffer, "\377\330\377", 3))
+ {
+ // JPEG image...
+ size_t length; // Length of chunk
+
+ for (bufptr = buffer + 2, bufend = buffer + bytes; bufptr < bufend;)
+ {
+ if (*bufptr == 0xff)
+ {
+ bufptr ++;
+
+ if (bufptr >= bufend)
+ {
+ // If we are at the end of the current buffer, re-fill and continue...
+ if ((bytes = read(fd, buffer, sizeof(buffer))) <= 0)
+ break;
+
+ bufptr = buffer;
+ bufend = buffer + bytes;
+ }
+
+ if (*bufptr == 0xff)
+ continue;
+
+ if ((bufptr + 16) >= bufend)
+ {
+ // Read more of the marker...
+ bytes = bufend - bufptr;
+
+ memmove(buffer, bufptr, (size_t)bytes);
+ bufptr = buffer;
+ bufend = buffer + bytes;
+
+ if ((bytes = read(fd, bufend, sizeof(buffer) - (size_t)bytes)) <= 0)
+ break;
+
+ bufend += bytes;
+ }
+
+ length = (size_t)((bufptr[1] << 8) | bufptr[2]);
+
+ if ((*bufptr >= 0xc0 && *bufptr <= 0xc3) || (*bufptr >= 0xc5 && *bufptr <= 0xc7) || (*bufptr >= 0xc9 && *bufptr <= 0xcb) || (*bufptr >= 0xcd && *bufptr <= 0xcf))
+ {
+ // SOFn marker, look for dimensions...
+ if (bufptr[3] != 8)
+ {
+ ret = false;
+ break;
+ }
+
+ *width = (int)((bufptr[6] << 8) | bufptr[7]);
+ *height = (int)((bufptr[4] << 8) | bufptr[5]);
+ *depth = (int)bufptr[8];
+ break;
+ }
+
+ // Skip past this marker...
+ bufptr ++;
+ bytes = bufend - bufptr;
+
+ while (length >= (size_t)bytes)
+ {
+ length -= (size_t)bytes;
+
+ if ((bytes = read(fd, buffer, sizeof(buffer))) <= 0)
+ break;
+
+ bufptr = buffer;
+ bufend = buffer + bytes;
+ }
+
+ if (length > (size_t)bytes)
+ break;
+
+ bufptr += length;
+ }
+ }
+
+ if (*width == 0 || *height == 0 || (*depth != 1 && *depth != 3))
+ ret = false;
+ }
+ else
+ {
+ // Something we don't recognize...
+ ret = false;
+ }
+
+ if (fd >= 0)
+ close(fd);
+
+ return (ret);
+}
+
+
+//
+// 'with_content()' - Verify that URIs meet content/MIME media type requirements
+// and save as needed.
+//
+
+static bool // O - `true` if valid, `false` otherwise
+with_content(
+ cups_array_t *errors, // I - Array of errors
+ ipp_attribute_t *attr, // I - Attribute
+ ipptool_content_t content, // I - Content validation rule
+ cups_array_t *mime_types, // I - Comma-delimited list of MIME media types
+ const char *filespec) // I - Output filename specification
+{
+ bool ret = true; // Return value
+ int i, // Looping var
+ count; // Number of values
+ const char *uri; // URI value
+ char scheme[256], // Scheme
+ userpass[256], // Username:password (not used)
+ host[256], // Hostname
+ resource[256]; // Resource path
+ int port; // Port number
+ http_encryption_t encryption; // Encryption mode
+ http_uri_status_t uri_status; // URI decoding status
+ http_t *http; // Connection to server
+ http_status_t status; // Request status
+ const char *content_type; // Content-Type header
+
+
+ for (i = 0, count = ippGetCount(attr); i < count; i ++)
+ {
+ uri = ippGetString(attr, i, NULL);
+
+ if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource))) < HTTP_URI_STATUS_OK)
+ {
+ add_stringf(errors, "Bad URI value '%s': %s", uri, httpURIStatusString(uri_status));
+ ret = false;
+ continue;
+ }
+
+ if (strcmp(scheme, "http") && strcmp(scheme, "https") && strcmp(scheme, "ipp") && strcmp(scheme, "ipps"))
+ {
+ add_stringf(errors, "Unsupported URI scheme for '%s'.", uri);
+ ret = false;
+ continue;
+ }
+
+ encryption = (!strcmp(scheme, "https") || !strcmp(scheme, "ipps") || port == 443) ? HTTP_ENCRYPTION_ALWAYS : HTTP_ENCRYPTION_IF_REQUESTED;
+
+ if ((http = httpConnect2(host, port, NULL, AF_UNSPEC, encryption, 1, 30000, NULL)) == NULL)
+ {
+ add_stringf(errors, "Unable to connect to '%s' on port %d: %s", host, port, cupsGetErrorString());
+ ret = false;
+ continue;
+ }
+
+ if (content == IPPTOOL_CONTENT_AVAILABLE)
+ {
+ if (!httpWriteRequest(http, "HEAD", resource))
+ {
+ add_stringf(errors, "Unable to send HEAD request to '%s': %s", uri, cupsGetErrorString());
+ ret = false;
+ goto http_done;
+ }
+
+ while ((status = httpUpdate(http)) == HTTP_STATUS_CONTINUE)
+ {
+ // Do nothing
+ }
+
+ if (status != HTTP_STATUS_OK)
+ {
+ add_stringf(errors, "Got unexpected status %d for HEAD request to '%s'.", (int)status, uri);
+ ret = false;
+ goto http_done;
+ }
+
+ content_type = httpGetField(http, HTTP_FIELD_CONTENT_TYPE);
+ if ((!strcmp(scheme, "ipp") || !strcmp(scheme, "ipps")) != !_cups_strcasecmp(content_type, "application/ipp") || (mime_types && !cupsArrayFind(mime_types, (void *)content_type)))
+ {
+ add_stringf(errors, "Got unexpected Content-Type '%s' for HEAD request to '%s'.", content_type, uri);
+ ret = false;
+ goto http_done;
+ }
+ }
+ else if (!strcmp(scheme, "http") || !strcmp(scheme, "https"))
+ {
+ // Check HTTP resource with a GET...
+ char filename[1024]; // Temporary filename
+ int fd; // Temporary file
+ struct stat fileinfo; // Temporary file information
+ int width, // Image width
+ height, // Image height
+ depth; // Image color depth
+
+ if ((fd = create_file(filespec, resource, i + 1, filename, sizeof(filename))) < 0)
+ {
+ add_stringf(errors, "Unable to create temporary file for WITH-CONTENT: %s", strerror(errno));
+ ret = false;
+ goto http_done;
+ }
+
+ status = cupsGetFd(http, resource, fd);
+ if (fstat(fd, &fileinfo))
+ memset(&fileinfo, 0, sizeof(fileinfo));
+ close(fd);
+
+ if (status != HTTP_STATUS_OK)
+ {
+ add_stringf(errors, "Got unexpected status %d for HEAD request to '%s'.", (int)status, uri);
+ ret = false;
+ goto get_done;
+ }
+
+ content_type = httpGetField(http, HTTP_FIELD_CONTENT_TYPE);
+
+ if (mime_types && !cupsArrayFind(mime_types, (void *)content_type))
+ {
+ add_stringf(errors, "Got unexpected Content-Type '%s' for GET request to '%s'.", content_type, uri);
+ ret = false;
+ goto get_done;
+ }
+
+ if (content == IPPTOOL_CONTENT_VALID_ICON)
+ {
+ if (_cups_strcasecmp(content_type, "image/png"))
+ {
+ add_stringf(errors, "Got unexpected Content-Type '%s' for GET request to '%s'.", content_type, uri);
+ ret = false;
+ goto get_done;
+ }
+
+ if (!valid_image(filename, &width, &height, &depth))
+ {
+ add_stringf(errors, "Unable to load image '%s'.", uri);
+ ret = false;
+ goto get_done;
+ }
+ else if (width != height || (width != 48 && width != 128 && width != 512))
+ {
+ add_stringf(errors, "Image '%s' has bad dimensions %dx%d.", uri, width, height);
+ ret = false;
+ goto get_done;
+ }
+ else if (depth & 1)
+ {
+ add_stringf(errors, "Image '%s' doesn't have transparency information.", uri);
+ ret = false;
+ goto get_done;
+ }
+ }
+ else if (!_cups_strcasecmp(content_type, "image/jpeg") || !_cups_strcasecmp(content_type, "image/png"))
+ {
+ if (!valid_image(filename, &width, &height, &depth))
+ {
+ add_stringf(errors, "Unable to load image '%s'.", uri);
+ ret = false;
+ goto get_done;
+ }
+ }
+ else if (!_cups_strcasecmp(content_type, "application/pdf") || !_cups_strcasecmp(content_type, "application/ipp") || !_cups_strcasecmp(content_type, "application/vnd.iccprofile") || !_cups_strcasecmp(content_type, "text/css") || !_cups_strcasecmp(content_type, "text/html") || !_cups_strcasecmp(content_type, "text/strings"))
+ {
+ // Just require these files to be non-empty for now, might add more checks in the future...
+ if (fileinfo.st_size == 0)
+ {
+ add_stringf(errors, "Empty resource '%s'.", uri);
+ ret = false;
+ goto get_done;
+ }
+ }
+ else
+ {
+ add_stringf(errors, "Got unexpected Content-Type '%s' for HEAD request to '%s'.", content_type, uri);
+ ret = false;
+ goto get_done;
+ }
+
+ get_done:
+
+ if (!filespec)
+ unlink(filename);
+ }
+ else
+ {
+ // Check IPP resource...
+ ipp_t *request; // IPP Get-Printer-Attributes request
+
+ request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
+
+ ippDelete(cupsDoRequest(http, request, resource));
+
+ if (cupsGetError() > IPP_STATUS_OK_EVENTS_COMPLETE)
+ {
+ add_stringf(errors, "Got unexpected status-code '%s' (%s) for Get-Printer-Attributes request to '%s'.", ippErrorString(cupsGetError()), cupsGetErrorString(), uri);
+ ret = false;
+ }
+ }
+
+ http_done:
+
+ httpClose(http);
+ }
+
+ return (ret);
+}
+
+
+//
+// 'with_distinct_values()' - Verify that an attribute contains unique values.
+//
-static int // O - 1 if distinct, 0 if duplicate
+static bool // O - `true` if distinct, `false` if duplicate
with_distinct_values(
cups_array_t *errors, // I - Array of errors
ipp_attribute_t *attr) // I - Attribute to test
{
+ bool ret; // Return value
int i, // Looping var
count; // Number of values
ipp_tag_t value_tag; // Value syntax
const char *value; // Current value
- char buffer[8192]; // Temporary buffer
+ char buffer[131072]; // Temporary buffer
cups_array_t *values; // Array of values as strings
// If there is only 1 value, it must be distinct
if ((count = ippGetCount(attr)) == 1)
- return (1);
+ return (true);
// Only check integers, enums, rangeOfInteger, resolution, and nul-terminated
// strings...
default :
add_stringf(errors, "WITH-DISTINCT-VALUES %s not supported for 1setOf %s", ippGetName(attr), ippTagString(value_tag));
- return (0);
+ return (false);
}
// Collect values and determine they are all unique...
- values = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ values = cupsArrayNew3((cups_array_cb_t)strcmp, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);
for (i = 0; i < count; i ++)
{
*bufend, // End of buffer
prefix; // Prefix character
- for (prefix = '{', bufptr = buffer, bufend = buffer + sizeof(buffer) - 2, member = ippFirstAttribute(col); member && bufptr < bufend; member = ippNextAttribute(col))
+ for (prefix = '{', bufptr = buffer, bufend = buffer + sizeof(buffer) - 2, member = ippGetFirstAttribute(col); member && bufptr < bufend; member = ippGetNextAttribute(col))
{
*bufptr++ = prefix;
prefix = ' ';
}
// Cleanup...
- i = cupsArrayCount(values) == count;
+ ret = cupsArrayGetCount(values) == count;
cupsArrayDelete(values);
- return (i);
+ return (ret);
}
-/*
- * 'with_flags_string()' - Return the "WITH-xxx" predicate that corresponds to
- * the flags.
- */
+//
+// 'with_flags_string()' - Return the "WITH-xxx" predicate that corresponds to
+// the flags.
+//
-static const char * /* O - WITH-xxx string */
-with_flags_string(int flags) /* I - WITH flags */
+static const char * // O - WITH-xxx string
+with_flags_string(int flags) // I - WITH flags
{
if (flags & IPPTOOL_WITH_ALL)
{
}
-/*
- * 'with_value()' - Test a WITH-VALUE predicate.
- */
+//
+// 'with_value()' - Test a WITH-VALUE predicate.
+//
-static int /* O - 1 on match, 0 on non-match */
-with_value(ipptool_test_t *data, /* I - Test data */
- cups_array_t *errors, /* I - Errors array */
- char *value, /* I - Value string */
- int flags, /* I - Flags for match */
- ipp_attribute_t *attr, /* I - Attribute to compare */
- char *matchbuf, /* I - Buffer to hold matching value */
- size_t matchlen) /* I - Length of match buffer */
+static bool // O - `true` on match, `false` on non-match
+with_value(ipptool_test_t *data, // I - Test data
+ cups_array_t *errors, // I - Errors array
+ char *value, // I - Value string
+ int flags, // I - Flags for match
+ ipp_attribute_t *attr, // I - Attribute to compare
+ char *matchbuf, // I - Buffer to hold matching value
+ size_t matchlen) // I - Length of match buffer
{
- int i, /* Looping var */
- count, /* Number of values */
- match; /* Match? */
- char temp[1024], /* Temporary value string */
- *valptr; /* Pointer into value */
- const char *name; /* Attribute name */
+ int i, // Looping var
+ count; // Number of values
+ bool match; // Match?
+ char temp[1024], // Temporary value string
+ *valptr; // Pointer into value
+ const char *name; // Attribute name
*matchbuf = '\0';
- match = (flags & IPPTOOL_WITH_ALL) ? 1 : 0;
-
- /*
- * NULL matches everything.
- */
+ match = (flags & IPPTOOL_WITH_ALL) ? true : false;
+ // NULL matches everything.
if (!value || !*value)
- return (1);
-
- /*
- * Compare the value string to the attribute value.
- */
+ return (true);
+ // Compare the value string to the attribute value.
name = ippGetName(attr);
count = ippGetCount(attr);
case IPP_TAG_ENUM :
for (i = 0; i < count; i ++)
{
- char op, /* Comparison operator */
- *nextptr; /* Next pointer */
- int intvalue, /* Integer value */
- attrvalue = ippGetInteger(attr, i),
- /* Attribute value */
- valmatch = 0; /* Does the current value match? */
+ char op, // Comparison operator
+ *nextptr; // Next pointer
+ int intvalue, // Integer value
+ attrvalue = ippGetInteger(attr, i);
+ // Attribute value
+ bool valmatch = false; // Does the current value match?
valptr = value;
if (!matchbuf[0])
snprintf(matchbuf, matchlen, "%d", attrvalue);
- valmatch = 1;
+ valmatch = true;
break;
}
}
{
if (!valmatch)
{
- match = 0;
+ match = false;
break;
}
}
else if (valmatch)
{
- match = 1;
+ match = true;
break;
}
}
case IPP_TAG_RANGE :
for (i = 0; i < count; i ++)
{
- char op, /* Comparison operator */
- *nextptr; /* Next pointer */
- int intvalue, /* Integer value */
- lower, /* Lower range */
- upper, /* Upper range */
- valmatch = 0; /* Does the current value match? */
+ char op, // Comparison operator
+ *nextptr; // Next pointer
+ int intvalue, // Integer value
+ lower, // Lower range
+ upper; // Upper range
+ bool valmatch = false; // Does the current value match?
lower = ippGetRange(attr, i, &upper);
valptr = value;
if (!matchbuf[0])
snprintf(matchbuf, matchlen, "%d-%d", lower, upper);
- valmatch = 1;
+ valmatch = true;
break;
}
}
{
if (!valmatch)
{
- match = 0;
+ match = false;
break;
}
}
else if (valmatch)
{
- match = 1;
+ match = true;
break;
}
}
{
for (i = 0; i < count; i ++)
{
- int lower, upper; /* Range values */
+ int lower, upper; // Range values
lower = ippGetRange(attr, i, &upper);
add_stringf(data->errors, "GOT: %s=%d-%d", name, lower, upper);
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
case IPP_TAG_RESOLUTION :
for (i = 0; i < count; i ++)
{
- int xres, yres; /* Resolution values */
- ipp_res_t units; /* Resolution units */
+ int xres, yres; // Resolution values
+ ipp_res_t units; // Resolution units
xres = ippGetResolution(attr, i, &yres, &units);
if (xres == yres)
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
{
for (i = 0; i < count; i ++)
{
- int xres, yres; /* Resolution values */
- ipp_res_t units; /* Resolution units */
+ int xres, yres; // Resolution values
+ ipp_res_t units; // Resolution units
xres = ippGetResolution(attr, i, &yres, &units);
if (xres == yres)
case IPP_TAG_NOVALUE :
case IPP_TAG_UNKNOWN :
- return (1);
+ return (true);
case IPP_TAG_CHARSET :
case IPP_TAG_KEYWORD :
case IPP_TAG_URISCHEME :
if (flags & IPPTOOL_WITH_REGEX)
{
- /*
- * Value is an extended, case-sensitive POSIX regular expression...
- */
+ // Value is an extended, case-sensitive POSIX regular expression...
+ int r; // Error, if any
+ regex_t re; // Regular expression
- regex_t re; /* Regular expression */
-
- if ((i = regcomp(&re, value, REG_EXTENDED | REG_NOSUB)) != 0)
+ if ((r = regcomp(&re, value, REG_EXTENDED | REG_NOSUB)) != 0)
{
- regerror(i, &re, temp, sizeof(temp));
+ regerror(r, &re, temp, sizeof(temp));
print_fatal_error(data, "Unable to compile WITH-VALUE regular expression \"%s\" - %s", value, temp);
- return (0);
+ return (false);
}
- /*
- * See if ALL of the values match the given regular expression.
- */
-
+ // See if ALL of the values match the given regular expression.
for (i = 0; i < count; i ++)
{
if (!regexec(&re, get_string(attr, i, flags, temp, sizeof(temp)),
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
}
else if (ippGetValueTag(attr) == IPP_TAG_URI && !(flags & (IPPTOOL_WITH_SCHEME | IPPTOOL_WITH_HOSTNAME | IPPTOOL_WITH_RESOURCE)))
{
- /*
- * Value is a literal URI string, see if the value(s) match...
- */
-
+ // Value is a literal URI string, see if the value(s) match...
for (i = 0; i < count; i ++)
{
if (!compare_uris(value, get_string(attr, i, flags, temp, sizeof(temp))))
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
}
else
{
- /*
- * Value is a literal string, see if the value(s) match...
- */
-
+ // Value is a literal string, see if the value(s) match...
for (i = 0; i < count; i ++)
{
int result;
switch (ippGetValueTag(attr))
{
case IPP_TAG_URI :
- /*
- * Some URI components are case-sensitive, some not...
- */
-
+ // Some URI components are case-sensitive, some not...
if (flags & (IPPTOOL_WITH_SCHEME | IPPTOOL_WITH_HOSTNAME))
result = _cups_strcasecmp(value, get_string(attr, i, flags, temp, sizeof(temp)));
else
case IPP_TAG_NAMELANG :
case IPP_TAG_TEXT :
case IPP_TAG_TEXTLANG :
- /*
- * mimeMediaType, nameWithoutLanguage, nameWithLanguage,
- * textWithoutLanguage, and textWithLanguage are defined to
- * be case-insensitive strings...
- */
-
+ // mimeMediaType, nameWithoutLanguage, nameWithLanguage,
+ // textWithoutLanguage, and textWithLanguage are defined to
+ // be case-insensitive strings...
result = _cups_strcasecmp(value, get_string(attr, i, flags, temp, sizeof(temp)));
break;
default :
- /*
- * Other string syntaxes are defined as lowercased so we use
- * case-sensitive comparisons to catch problems...
- */
-
+ // Other string syntaxes are defined as lowercased so we use
+ // case-sensitive comparisons to catch problems...
result = strcmp(value, get_string(attr, i, flags, temp, sizeof(temp)));
break;
}
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
case IPP_TAG_STRING :
if (flags & IPPTOOL_WITH_REGEX)
{
- /*
- * Value is an extended, case-sensitive POSIX regular expression...
- */
-
- void *adata; /* Pointer to octetString data */
- int adatalen; /* Length of octetString */
- regex_t re; /* Regular expression */
+ // Value is an extended, case-sensitive POSIX regular expression...
+ void *adata; // Pointer to octetString data
+ int adatalen; // Length of octetString
+ int r; // Error, if any
+ regex_t re; // Regular expression
- if ((i = regcomp(&re, value, REG_EXTENDED | REG_NOSUB)) != 0)
+ if ((r = regcomp(&re, value, REG_EXTENDED | REG_NOSUB)) != 0)
{
- regerror(i, &re, temp, sizeof(temp));
+ regerror(r, &re, temp, sizeof(temp));
print_fatal_error(data, "Unable to compile WITH-VALUE regular expression \"%s\" - %s", value, temp);
- return (0);
+ return (false);
}
- /*
- * See if ALL of the values match the given regular expression.
- */
-
+ // See if ALL of the values match the given regular expression.
for (i = 0; i < count; i ++)
{
if ((adata = ippGetOctetString(attr, i, &adatalen)) == NULL || adatalen >= (int)sizeof(temp))
{
- match = 0;
+ match = false;
break;
}
memcpy(temp, adata, (size_t)adatalen);
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
}
else
{
- /*
- * Value is a literal or hex-encoded string...
- */
-
- unsigned char withdata[1023], /* WITH-VALUE data */
- *adata; /* Pointer to octetString data */
- int withlen, /* Length of WITH-VALUE data */
- adatalen; /* Length of octetString */
+ // Value is a literal or hex-encoded string...
+ unsigned char withdata[1023], // WITH-VALUE data
+ *adata; // Pointer to octetString data
+ int withlen, // Length of WITH-VALUE data
+ adatalen; // Length of octetString
if (*value == '<')
{
- /*
- * Grab hex-encoded value...
- */
-
+ // Grab hex-encoded value...
if ((withlen = (int)strlen(value)) & 1 || withlen > (int)(2 * (sizeof(withdata) + 1)))
{
print_fatal_error(data, "Bad WITH-VALUE hex value.");
- return (0);
+ return (false);
}
withlen = withlen / 2 - 1;
for (valptr = value + 1, adata = withdata; *valptr; valptr += 2)
{
- int ch; /* Current character/byte */
+ int ch; // Current character/byte
if (isdigit(valptr[0]))
ch = (valptr[0] - '0') << 4;
if (*valptr)
{
print_fatal_error(data, "Bad WITH-VALUE hex value.");
- return (0);
+ return (false);
}
}
else
{
- /*
- * Copy literal string value...
- */
-
- withlen = (int)strlen(value);
+ // Copy literal string value...
+ withlen = strlen(value);
memcpy(withdata, value, (size_t)withlen);
}
if (!(flags & IPPTOOL_WITH_ALL))
{
- match = 1;
+ match = true;
break;
}
}
else if (flags & IPPTOOL_WITH_ALL)
{
- match = 0;
+ match = false;
break;
}
}
}
-/*
- * 'with_value_from()' - Test a WITH-VALUE-FROM predicate.
- */
+//
+// 'with_value_from()' - Test a WITH-VALUE-FROM predicate.
+//
-static int /* O - 1 on match, 0 on non-match */
+static bool // O - `true` on match, `false` on non-match
with_value_from(
- cups_array_t *errors, /* I - Errors array */
- ipp_attribute_t *fromattr, /* I - "From" attribute */
- ipp_attribute_t *attr, /* I - Attribute to compare */
- char *matchbuf, /* I - Buffer to hold matching value */
- size_t matchlen) /* I - Length of match buffer */
+ cups_array_t *errors, // I - Errors array
+ ipp_attribute_t *fromattr, // I - "From" attribute
+ ipp_attribute_t *attr, // I - Attribute to compare
+ char *matchbuf, // I - Buffer to hold matching value
+ size_t matchlen) // I - Length of match buffer
{
- int i, j, /* Looping vars */
- count = ippGetCount(attr), /* Number of attribute values */
- match = 1; /* Match? */
+ int i, j, // Looping vars
+ count = ippGetCount(attr);
+ // Number of attribute values
+ bool match = true; // Match?
*matchbuf = '\0';
- /*
- * Compare the from value(s) to the attribute value(s)...
- */
-
+ // Compare the from value(s) to the attribute value(s)...
switch (ippGetValueTag(attr))
{
case IPP_TAG_INTEGER :
for (i = 0; i < count; i ++)
{
int value = ippGetInteger(attr, i);
- /* Current integer value */
+ // Current integer value
if (ippContainsInteger(fromattr, value))
{
else
{
add_stringf(errors, "GOT: %s=%d", ippGetName(attr), value);
- match = 0;
+ match = false;
}
}
break;
for (i = 0; i < count; i ++)
{
int value = ippGetInteger(attr, i);
- /* Current integer value */
+ // Current integer value
if (ippContainsInteger(fromattr, value))
{
else
{
add_stringf(errors, "GOT: %s=%d", ippGetName(attr), value);
- match = 0;
+ match = false;
}
}
break;
for (i = 0; i < count; i ++)
{
- int xres, yres;
- ipp_res_t units;
- int fromcount = ippGetCount(fromattr);
- int fromxres, fromyres;
- ipp_res_t fromunits;
+ int xres, yres; // Current X,Y resolution
+ ipp_res_t units; // Current units
+ int fromcount = ippGetCount(fromattr);
+ // From count
+ int fromxres, fromyres;
+ // From X,Y resolution
+ ipp_res_t fromunits; // From units
xres = ippGetResolution(attr, i, &yres, &units);
else
add_stringf(errors, "GOT: %s=%dx%d%s", ippGetName(attr), xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
- match = 0;
+ match = false;
}
}
break;
case IPP_TAG_NOVALUE :
case IPP_TAG_UNKNOWN :
- return (1);
+ return (true);
case IPP_TAG_CHARSET :
case IPP_TAG_KEYWORD :
for (i = 0; i < count; i ++)
{
const char *value = ippGetString(attr, i, NULL);
- /* Current string value */
+ // Current string value
if (ippContainsString(fromattr, value))
{
else
{
add_stringf(errors, "GOT: %s='%s'", ippGetName(attr), value);
- match = 0;
+ match = false;
}
}
break;
case IPP_TAG_URI :
for (i = 0; i < count; i ++)
{
- const char *value = ippGetString(attr, i, NULL);
- /* Current string value */
- int fromcount = ippGetCount(fromattr);
+ const char *value = ippGetString(attr, i, NULL);
+ // Current string value
+ int fromcount = ippGetCount(fromattr);
+ // From count
for (j = 0; j < fromcount; j ++)
{
if (j >= fromcount)
{
add_stringf(errors, "GOT: %s='%s'", ippGetName(attr), value);
- match = 0;
+ match = false;
}
}
break;
default :
- match = 0;
+ match = false;
break;
}
return (match);
- /* value tag mismatch between fromattr and attr */
+ // value tag mismatch between fromattr and attr...
wrong_value_tag :
add_stringf(errors, "GOT: %s OF-TYPE %s", ippGetName(attr), ippTagString(ippGetValueTag(attr)));
- return (0);
+ return (false);
}
270696461CADF3E200FFE5FB /* md5-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220EEE133305BB00FCA411 /* md5-internal.h */; settings = {ATTRIBUTES = (Private, ); }; };
270696481CADF3E200FFE5FB /* pwg-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220EF9133305BB00FCA411 /* pwg-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
2706964A1CADF3E200FFE5FB /* string-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220F01133305BB00FCA411 /* string-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 2706964B1CADF3E200FFE5FB /* thread-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220F04133305BB00FCA411 /* thread-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
2706964C1CADF3E200FFE5FB /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220F471333063D00FCA411 /* config.h */; settings = {ATTRIBUTES = (Private, ); }; };
2706964D1CADF3E200FFE5FB /* cups.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220EC11333056300FCA411 /* cups.h */; settings = {ATTRIBUTES = (Public, ); }; };
2706964E1CADF3E200FFE5FB /* dir.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220ED4133305BB00FCA411 /* dir.h */; settings = {ATTRIBUTES = (); }; };
279AE6F52395B80F004DD600 /* libpam.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 279AE6F42395B80F004DD600 /* libpam.tbd */; };
27A034821A8BDC3A00650675 /* lpadmin.c in Sources */ = {isa = PBXBuildFile; fileRef = 2732E08D137A3F5200FAFEF6 /* lpadmin.c */; };
27A034851A8BDC5C00650675 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
+ 27F515462AAFBECF0045EE21 /* raster-testpage.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F515432AAFBECF0045EE21 /* raster-testpage.h */; };
+ 27F515472AAFBECF0045EE21 /* raster-testpage.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F515432AAFBECF0045EE21 /* raster-testpage.h */; };
+ 27F515482AAFBECF0045EE21 /* raster-testpage.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F515432AAFBECF0045EE21 /* raster-testpage.h */; };
+ 27F515492AAFBECF0045EE21 /* rand.c in Sources */ = {isa = PBXBuildFile; fileRef = 27F515442AAFBECF0045EE21 /* rand.c */; };
+ 27F5154A2AAFBECF0045EE21 /* rand.c in Sources */ = {isa = PBXBuildFile; fileRef = 27F515442AAFBECF0045EE21 /* rand.c */; };
+ 27F5154B2AAFBECF0045EE21 /* rand.c in Sources */ = {isa = PBXBuildFile; fileRef = 27F515442AAFBECF0045EE21 /* rand.c */; };
+ 27F5154C2AAFBECF0045EE21 /* test-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F515452AAFBECF0045EE21 /* test-internal.h */; };
+ 27F5154D2AAFBECF0045EE21 /* test-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F515452AAFBECF0045EE21 /* test-internal.h */; };
+ 27F5154E2AAFBECF0045EE21 /* test-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F515452AAFBECF0045EE21 /* test-internal.h */; };
+ 27F515502AAFCCDA0045EE21 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F5154F2AAFCCDA0045EE21 /* thread.h */; };
+ 27F515512AAFCCDA0045EE21 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F5154F2AAFCCDA0045EE21 /* thread.h */; };
+ 27F515522AAFCCDA0045EE21 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = 27F5154F2AAFCCDA0045EE21 /* thread.h */; };
7200511218F492F200E7B81B /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278C58E5136B64AF00836530 /* CoreFoundation.framework */; };
720DD6CD1358FD720064AA82 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
720DD6D31358FDDE0064AA82 /* snmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 720DD6D21358FDDE0064AA82 /* snmp.c */; };
720DD6D413590AB90064AA82 /* ieee1284.c in Sources */ = {isa = PBXBuildFile; fileRef = 724379CA1334000E009631B9 /* ieee1284.c */; };
720E854320164E7B00C6C411 /* ipp-file.c in Sources */ = {isa = PBXBuildFile; fileRef = 720E854120164E7A00C6C411 /* ipp-file.c */; };
720E854420164E7B00C6C411 /* ipp-file.c in Sources */ = {isa = PBXBuildFile; fileRef = 720E854120164E7A00C6C411 /* ipp-file.c */; };
- 720E854520164E7B00C6C411 /* ipp-vars.c in Sources */ = {isa = PBXBuildFile; fileRef = 720E854220164E7A00C6C411 /* ipp-vars.c */; };
- 720E854620164E7B00C6C411 /* ipp-vars.c in Sources */ = {isa = PBXBuildFile; fileRef = 720E854220164E7A00C6C411 /* ipp-vars.c */; };
72220EB61333052D00FCA411 /* adminutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220EB51333052D00FCA411 /* adminutil.c */; };
72220EC41333056300FCA411 /* adminutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220EB71333056300FCA411 /* adminutil.h */; settings = {ATTRIBUTES = (Public, ); }; };
72220EC51333056300FCA411 /* array.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220EB81333056300FCA411 /* array.c */; };
72220F3B133305BB00FCA411 /* string-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220F01133305BB00FCA411 /* string-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
72220F3C133305BB00FCA411 /* string.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220F02133305BB00FCA411 /* string.c */; };
72220F3D133305BB00FCA411 /* tempfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220F03133305BB00FCA411 /* tempfile.c */; };
- 72220F3E133305BB00FCA411 /* thread-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220F04133305BB00FCA411 /* thread-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
72220F3F133305BB00FCA411 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220F05133305BB00FCA411 /* thread.c */; };
72220F40133305BB00FCA411 /* transcode.c in Sources */ = {isa = PBXBuildFile; fileRef = 72220F06133305BB00FCA411 /* transcode.c */; };
72220F41133305BB00FCA411 /* transcode.h in Headers */ = {isa = PBXBuildFile; fileRef = 72220F07133305BB00FCA411 /* transcode.h */; settings = {ATTRIBUTES = (Public, ); }; };
722A24F32178D091000CAB20 /* debug-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 722A24F22178D090000CAB20 /* debug-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
722A24F42178D091000CAB20 /* debug-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 722A24F22178D090000CAB20 /* debug-private.h */; };
722A24F52178D091000CAB20 /* debug-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 722A24F22178D090000CAB20 /* debug-private.h */; };
- 7234F4201378A16F00D3E9C9 /* array-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7234F41F1378A16F00D3E9C9 /* array-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
724379081333E4A5009631B9 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
7243790D1333E4E3009631B9 /* ipp.c in Sources */ = {isa = PBXBuildFile; fileRef = 7243790A1333E4E3009631B9 /* ipp.c */; };
7243790E1333E4E3009631B9 /* network.c in Sources */ = {isa = PBXBuildFile; fileRef = 7243790B1333E4E3009631B9 /* network.c */; };
7253C46C216ED5E500494ADD /* raster-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 2767FC76192696A0000F61D3 /* raster-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
7253C46F216ED69200494ADD /* pwg.h in Headers */ = {isa = PBXBuildFile; fileRef = 2767FC7519269687000F61D3 /* pwg.h */; settings = {ATTRIBUTES = (Public, ); }; };
7253C470216ED69400494ADD /* pwg.h in Headers */ = {isa = PBXBuildFile; fileRef = 2767FC7519269687000F61D3 /* pwg.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 7253C471216ED6C400494ADD /* array-private.h in Headers */ = {isa = PBXBuildFile; fileRef = 7234F41F1378A16F00D3E9C9 /* array-private.h */; settings = {ATTRIBUTES = (Private, ); }; };
7258EAED134594EB009286F1 /* rastertopwg.c in Sources */ = {isa = PBXBuildFile; fileRef = 7258EAEC134594EB009286F1 /* rastertopwg.c */; };
7258EAF413459B6D009286F1 /* libcups.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /* libcups.dylib */; };
7258EAF513459B6D009286F1 /* libcupsimage.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 72F75A611336F9A3004BB496 /* libcupsimage.dylib */; };
/* Begin PBXFileReference section */
2706965A1CADF3E200FFE5FB /* libcups_ios.a */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups_ios.a; sourceTree = BUILT_PRODUCTS_DIR; };
270B267E17F5C06700C8A3A9 /* tls-gnutls.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-gnutls.c"; path = "../cups/tls-gnutls.c"; sourceTree = "<group>"; };
- 270B268117F5C5D600C8A3A9 /* tls-sspi.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-sspi.c"; path = "../cups/tls-sspi.c"; sourceTree = "<group>"; };
270CCDA7135E3C9E00007BE2 /* testmime */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testmime; sourceTree = BUILT_PRODUCTS_DIR; };
270CCDBB135E3D3E00007BE2 /* testmime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testmime.c; path = ../scheduler/testmime.c; sourceTree = "<group>"; };
270D02241D707E0200EA9403 /* testcreds */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testcreds; sourceTree = BUILT_PRODUCTS_DIR; };
27A0347B1A8BDB1300650675 /* lpadmin */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lpadmin; sourceTree = BUILT_PRODUCTS_DIR; };
27C89C902613E7C300A58F43 /* cups-tls.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-tls.m4"; path = "../config-scripts/cups-tls.m4"; sourceTree = "<group>"; };
27D3037D134148CB00F022B1 /* libcups2.def */ = {isa = PBXFileReference; lastKnownFileType = text; name = libcups2.def; path = ../cups/libcups2.def; sourceTree = "<group>"; };
+ 27F515432AAFBECF0045EE21 /* raster-testpage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "raster-testpage.h"; path = "../cups/raster-testpage.h"; sourceTree = "<group>"; };
+ 27F515442AAFBECF0045EE21 /* rand.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rand.c; path = ../cups/rand.c; sourceTree = "<group>"; };
+ 27F515452AAFBECF0045EE21 /* test-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "test-internal.h"; path = "../cups/test-internal.h"; sourceTree = "<group>"; };
+ 27F5154F2AAFCCDA0045EE21 /* thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = thread.h; path = ../cups/thread.h; sourceTree = "<group>"; };
27F89DA21B3AC43B00E5A4B7 /* testraster.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testraster.c; path = ../cups/testraster.c; sourceTree = "<group>"; };
27F9A76D28CBFC03002CCEE0 /* tls-openssl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "tls-openssl.c"; path = "../cups/tls-openssl.c"; sourceTree = "<group>"; };
720DD6C21358FD5F0064AA82 /* snmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = snmp; sourceTree = BUILT_PRODUCTS_DIR; };
720DD6D21358FDDE0064AA82 /* snmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = snmp.c; path = ../backend/snmp.c; sourceTree = "<group>"; };
720E854120164E7A00C6C411 /* ipp-file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "ipp-file.c"; path = "../cups/ipp-file.c"; sourceTree = "<group>"; };
- 720E854220164E7A00C6C411 /* ipp-vars.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "ipp-vars.c"; path = "../cups/ipp-vars.c"; sourceTree = "<group>"; };
72220EAE1333047D00FCA411 /* libcups.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
72220EB51333052D00FCA411 /* adminutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = adminutil.c; path = ../cups/adminutil.c; sourceTree = "<group>"; };
72220EB71333056300FCA411 /* adminutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = adminutil.h; path = ../cups/adminutil.h; sourceTree = "<group>"; };
72220F01133305BB00FCA411 /* string-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "string-private.h"; path = "../cups/string-private.h"; sourceTree = "<group>"; };
72220F02133305BB00FCA411 /* string.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = string.c; path = ../cups/string.c; sourceTree = "<group>"; };
72220F03133305BB00FCA411 /* tempfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tempfile.c; path = ../cups/tempfile.c; sourceTree = "<group>"; };
- 72220F04133305BB00FCA411 /* thread-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "thread-private.h"; path = "../cups/thread-private.h"; sourceTree = "<group>"; };
72220F05133305BB00FCA411 /* thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = thread.c; path = ../cups/thread.c; sourceTree = "<group>"; };
72220F06133305BB00FCA411 /* transcode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = transcode.c; path = ../cups/transcode.c; sourceTree = "<group>"; };
72220F07133305BB00FCA411 /* transcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = transcode.h; path = ../cups/transcode.h; sourceTree = "<group>"; };
7226369D18AE73BB004ED309 /* config.h.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = config.h.in; path = ../config.h.in; sourceTree = "<group>"; };
722A24EE2178D00C000CAB20 /* debug-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "debug-internal.h"; path = "../cups/debug-internal.h"; sourceTree = "<group>"; };
722A24F22178D090000CAB20 /* debug-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "debug-private.h"; path = "../cups/debug-private.h"; sourceTree = "<group>"; };
- 7234F41F1378A16F00D3E9C9 /* array-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "array-private.h"; path = "../cups/array-private.h"; sourceTree = "<group>"; };
724378FD1333E43E009631B9 /* ipp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ipp; sourceTree = BUILT_PRODUCTS_DIR; };
724379091333E4E3009631B9 /* backend-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "backend-private.h"; path = "../backend/backend-private.h"; sourceTree = "<group>"; };
7243790A1333E4E3009631B9 /* ipp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ipp.c; path = ../backend/ipp.c; sourceTree = "<group>"; };
72220EB41333050100FCA411 /* libcups */ = {
isa = PBXGroup;
children = (
- 272A5C0D2AA41D6B00027F9B /* dnssd.c */,
72220EB51333052D00FCA411 /* adminutil.c */,
72220EB81333056300FCA411 /* array.c */,
72220EBB1333056300FCA411 /* auth.c */,
276683561337A8C5000D33D0 /* cups.strings */,
722A24EE2178D00C000CAB20 /* debug-internal.h */,
72220ED1133305BB00FCA411 /* debug.c */,
+ 72220ED2133305BB00FCA411 /* dest.c */,
72CF95E018A13543000FCAE4 /* dest-job.c */,
72CF95E118A13543000FCAE4 /* dest-localization.c */,
72CF95E218A13543000FCAE4 /* dest-options.c */,
- 72220ED2133305BB00FCA411 /* dest.c */,
72220ED3133305BB00FCA411 /* dir.c */,
- 72220ED4133305BB00FCA411 /* dir.h */,
+ 272A5C0D2AA41D6B00027F9B /* dnssd.c */,
72220ED6133305BB00FCA411 /* encode.c */,
72220ED8133305BB00FCA411 /* file.c */,
72220EDA133305BB00FCA411 /* getdevices.c */,
72220EDC133305BB00FCA411 /* getputfile.c */,
72220EDD133305BB00FCA411 /* globals.c */,
7284F9EF1BFCCD940026F886 /* hash.c */,
+ 72220EE2133305BB00FCA411 /* http.c */,
72220EDE133305BB00FCA411 /* http-addr.c */,
72220EDF133305BB00FCA411 /* http-addrlist.c */,
72220EE1133305BB00FCA411 /* http-support.c */,
- 72220EE2133305BB00FCA411 /* http.c */,
720E854120164E7A00C6C411 /* ipp-file.c */,
72220EE5133305BB00FCA411 /* ipp-support.c */,
- 720E854220164E7A00C6C411 /* ipp-vars.c */,
72220EE6133305BB00FCA411 /* ipp.c */,
72220EE8133305BB00FCA411 /* langprintf.c */,
72220EEA133305BB00FCA411 /* language.c */,
72220EF0133305BB00FCA411 /* md5passwd.c */,
72220EF1133305BB00FCA411 /* notify.c */,
72220EF2133305BB00FCA411 /* options.c */,
+ 72220EF6133305BB00FCA411 /* ppd.c */,
72220EBA1333056300FCA411 /* ppd-attr.c */,
72220EF4133305BB00FCA411 /* ppd-cache.c */,
72220EBF1333056300FCA411 /* ppd-conflicts.c */,
72220EED133305BB00FCA411 /* ppd-mark.c */,
72220EF3133305BB00FCA411 /* ppd-page.c */,
72A8B3D61C188BDE00A1A547 /* ppd-util.c */,
- 72220EF6133305BB00FCA411 /* ppd.c */,
72220EF8133305BB00FCA411 /* pwg-media.c */,
+ 27F515442AAFBECF0045EE21 /* rand.c */,
72F75A691336FA8A004BB496 /* raster-error.c */,
72F75A6A1336FA8A004BB496 /* raster-interpret.c */,
72F75A6B1336FA8A004BB496 /* raster-stream.c */,
+ 27F515432AAFBECF0045EE21 /* raster-testpage.h */,
72220EFB133305BB00FCA411 /* request.c */,
72220EFC133305BB00FCA411 /* sidechannel.c */,
72220EFF133305BB00FCA411 /* snmp.c */,
72220F00133305BB00FCA411 /* snprintf.c */,
72220F02133305BB00FCA411 /* string.c */,
72220F03133305BB00FCA411 /* tempfile.c */,
+ 27F515452AAFBECF0045EE21 /* test-internal.h */,
72220F05133305BB00FCA411 /* thread.c */,
+ 727AD5B619100A58009F6862 /* tls.c */,
270B267E17F5C06700C8A3A9 /* tls-gnutls.c */,
27F9A76D28CBFC03002CCEE0 /* tls-openssl.c */,
- 270B268117F5C5D600C8A3A9 /* tls-sspi.c */,
- 727AD5B619100A58009F6862 /* tls.c */,
72220F06133305BB00FCA411 /* transcode.c */,
72220F08133305BB00FCA411 /* usersys.c */,
72220F09133305BB00FCA411 /* util.c */,
72220EB91333056300FCA411 /* array.h */,
72220EBE1333056300FCA411 /* backend.h */,
72220EC11333056300FCA411 /* cups.h */,
+ 72220ED4133305BB00FCA411 /* dir.h */,
272A5C0A2AA41D5A00027F9B /* dnssd.h */,
72220ED9133305BB00FCA411 /* file.h */,
72220EE3133305BB00FCA411 /* http.h */,
2767FC7519269687000F61D3 /* pwg.h */,
72220EFA133305BB00FCA411 /* raster.h */,
72220EFD133305BB00FCA411 /* sidechannel.h */,
+ 27F5154F2AAFCCDA0045EE21 /* thread.h */,
72220F07133305BB00FCA411 /* transcode.h */,
72220F0A133305BB00FCA411 /* versioning.h */,
);
72220F461333060C00FCA411 /* Private Headers */ = {
isa = PBXGroup;
children = (
- 7234F41F1378A16F00D3E9C9 /* array-private.h */,
72220F471333063D00FCA411 /* config.h */,
72220EC01333056300FCA411 /* cups-private.h */,
722A24F22178D090000CAB20 /* debug-private.h */,
2767FC76192696A0000F61D3 /* raster-private.h */,
72220EFE133305BB00FCA411 /* snmp-private.h */,
72220F01133305BB00FCA411 /* string-private.h */,
- 72220F04133305BB00FCA411 /* thread-private.h */,
);
name = "Private Headers";
sourceTree = "<group>";
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 27F515512AAFCCDA0045EE21 /* thread.h in Headers */,
2706963E1CADF3E200FFE5FB /* array.h in Headers */,
7253C469216ED5D400494ADD /* raster.h in Headers */,
722A24F42178D091000CAB20 /* debug-private.h in Headers */,
+ 27F5154D2AAFBECF0045EE21 /* test-internal.h in Headers */,
270696401CADF3E200FFE5FB /* cups-private.h in Headers */,
- 7253C471216ED6C400494ADD /* array-private.h in Headers */,
270696421CADF3E200FFE5FB /* file-private.h in Headers */,
270696431CADF3E200FFE5FB /* http-private.h in Headers */,
270696441CADF3E200FFE5FB /* ipp-private.h in Headers */,
270696481CADF3E200FFE5FB /* pwg-private.h in Headers */,
2706964A1CADF3E200FFE5FB /* string-private.h in Headers */,
7253C46C216ED5E500494ADD /* raster-private.h in Headers */,
- 2706964B1CADF3E200FFE5FB /* thread-private.h in Headers */,
2706964C1CADF3E200FFE5FB /* config.h in Headers */,
2706964D1CADF3E200FFE5FB /* cups.h in Headers */,
+ 27F515472AAFBECF0045EE21 /* raster-testpage.h in Headers */,
722A24F02178D00D000CAB20 /* debug-internal.h in Headers */,
2706964E1CADF3E200FFE5FB /* dir.h in Headers */,
2706964F1CADF3E200FFE5FB /* file.h in Headers */,
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 27F515522AAFCCDA0045EE21 /* thread.h in Headers */,
+ 27F5154E2AAFBECF0045EE21 /* test-internal.h in Headers */,
722A24F52178D091000CAB20 /* debug-private.h in Headers */,
274FF6C61333B1C400317ECB /* dir.h in Headers */,
+ 27F515482AAFBECF0045EE21 /* raster-testpage.h in Headers */,
722A24F12178D00D000CAB20 /* debug-internal.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
72220F13133305BB00FCA411 /* file.h in Headers */,
72220F1D133305BB00FCA411 /* http.h in Headers */,
72220F21133305BB00FCA411 /* ipp.h in Headers */,
+ 27F5154C2AAFBECF0045EE21 /* test-internal.h in Headers */,
72220F25133305BB00FCA411 /* language.h in Headers */,
72220F31133305BB00FCA411 /* ppd.h in Headers */,
722A24F32178D091000CAB20 /* debug-private.h in Headers */,
72220F37133305BB00FCA411 /* sidechannel.h in Headers */,
72220F41133305BB00FCA411 /* transcode.h in Headers */,
72220F44133305BB00FCA411 /* versioning.h in Headers */,
- 7234F4201378A16F00D3E9C9 /* array-private.h in Headers */,
72220ECD1333056300FCA411 /* cups-private.h in Headers */,
72220F11133305BB00FCA411 /* file-private.h in Headers */,
72220F1A133305BB00FCA411 /* http-private.h in Headers */,
272A5C0B2AA41D5A00027F9B /* dnssd.h in Headers */,
72220F38133305BB00FCA411 /* snmp-private.h in Headers */,
72220F3B133305BB00FCA411 /* string-private.h in Headers */,
- 72220F3E133305BB00FCA411 /* thread-private.h in Headers */,
722A24EF2178D00D000CAB20 /* debug-internal.h in Headers */,
72220F481333063D00FCA411 /* config.h in Headers */,
+ 27F515502AAFCCDA0045EE21 /* thread.h in Headers */,
+ 27F515462AAFBECF0045EE21 /* raster-testpage.h in Headers */,
7253C468216ED5D300494ADD /* raster.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
270696181CADF3E200FFE5FB /* ipp.c in Sources */,
270696191CADF3E200FFE5FB /* langprintf.c in Sources */,
2706961A1CADF3E200FFE5FB /* language.c in Sources */,
+ 27F5154A2AAFBECF0045EE21 /* rand.c in Sources */,
2706961D1CADF3E200FFE5FB /* md5.c in Sources */,
2706961E1CADF3E200FFE5FB /* md5passwd.c in Sources */,
2706961F1CADF3E200FFE5FB /* hash.c in Sources */,
274FF68D1333B1C400317ECB /* ppd-attr.c in Sources */,
274FF68E1333B1C400317ECB /* auth.c in Sources */,
274FF68F1333B1C400317ECB /* backchannel.c in Sources */,
- 720E854620164E7B00C6C411 /* ipp-vars.c in Sources */,
274FF6901333B1C400317ECB /* backend.c in Sources */,
274FF6911333B1C400317ECB /* ppd-conflicts.c in Sources */,
274FF6921333B1C400317ECB /* ppd-custom.c in Sources */,
274FF6A91333B1C400317ECB /* notify.c in Sources */,
274FF6AA1333B1C400317ECB /* options.c in Sources */,
727AD5B819100A58009F6862 /* tls.c in Sources */,
+ 27F5154B2AAFBECF0045EE21 /* rand.c in Sources */,
7253C465216ED51500494ADD /* raster-stubs.c in Sources */,
274FF6AB1333B1C400317ECB /* ppd-page.c in Sources */,
7253C456216E980200494ADD /* raster-error.c in Sources */,
72220EC71333056300FCA411 /* ppd-attr.c in Sources */,
727AD5B719100A58009F6862 /* tls.c in Sources */,
72220EC81333056300FCA411 /* auth.c in Sources */,
- 720E854520164E7B00C6C411 /* ipp-vars.c in Sources */,
72220EC91333056300FCA411 /* backchannel.c in Sources */,
72220ECA1333056300FCA411 /* backend.c in Sources */,
72220ECC1333056300FCA411 /* ppd-conflicts.c in Sources */,
72220F1C133305BB00FCA411 /* http.c in Sources */,
72CF95E518A13543000FCAE4 /* dest-options.c in Sources */,
72220F1F133305BB00FCA411 /* ipp-support.c in Sources */,
+ 27F515492AAFBECF0045EE21 /* rand.c in Sources */,
72220F20133305BB00FCA411 /* ipp.c in Sources */,
72220F22133305BB00FCA411 /* langprintf.c in Sources */,
72220F24133305BB00FCA411 /* language.c in Sources */,