transition.
trust = httpCredentialsGetTrust(creds, hostname);
httpCredentialsString(creds, credinfo, sizeof(credinfo));
- fprintf(stderr, "DEBUG: %s (%s)\n", trust_msgs[trust], cupsLastErrorString());
+ fprintf(stderr, "DEBUG: %s (%s)\n", trust_msgs[trust], cupsGetErrorString());
fprintf(stderr, "DEBUG: Printer credentials: %s\n", credinfo);
if (!httpLoadCredentials(NULL, &lcreds, hostname))
}
supported = cupsDoRequest(http, request, resource);
- ipp_status = cupsLastError();
+ ipp_status = cupsGetError();
fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
- ippErrorString(ipp_status), cupsLastErrorString());
+ ippErrorString(ipp_status), cupsGetErrorString());
if (ipp_status <= IPP_STATUS_OK_CONFLICTING)
password_tries = 0;
response = cupsDoRequest(http, request, resource);
- ipp_status = cupsLastError();
+ ipp_status = cupsGetError();
fprintf(stderr, "DEBUG: Validate-Job: %s (%s)\n",
- ippErrorString(ipp_status), cupsLastErrorString());
+ ippErrorString(ipp_status), cupsGetErrorString());
debug_attributes(response);
if ((job_auth = ippFindAttribute(response, "job-authorization-uri",
ippDelete(request);
}
- ipp_status = cupsLastError();
+ ipp_status = cupsGetError();
fprintf(stderr, "DEBUG: %s: %s (%s)\n",
(num_files > 1 || create_job) ? "Create-Job" : "Print-Job",
- ippErrorString(ipp_status), cupsLastErrorString());
+ ippErrorString(ipp_status), cupsGetErrorString());
debug_attributes(response);
if (ipp_status > IPP_STATUS_OK_CONFLICTING)
response = cupsGetResponse(http, resource);
ippDelete(request);
- fprintf(stderr, "DEBUG: Send-Document: %s (%s)\n", ippErrorString(cupsLastError()), cupsLastErrorString());
+ fprintf(stderr, "DEBUG: Send-Document: %s (%s)\n", ippErrorString(cupsGetError()), cupsGetErrorString());
debug_attributes(response);
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING && !job_canceled)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING && !job_canceled)
{
ipp_attribute_t *reasons = ippFindAttribute(response, "job-state-reasons", IPP_TAG_KEYWORD);
/* job-state-reasons values */
- ipp_status = cupsLastError();
+ ipp_status = cupsGetError();
if (ippContainsString(reasons, "document-format-error"))
ipp_status = IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR;
check_printer_state(http, uri, resource, argv[2], version);
- if (cupsLastError() <= IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
password_tries = 0;
/*
httpReconnect2(http, 30000, NULL);
response = cupsDoRequest(http, request, resource);
- ipp_status = cupsLastError();
+ ipp_status = cupsGetError();
if (ipp_status == IPP_STATUS_ERROR_NOT_FOUND || ipp_status == IPP_STATUS_ERROR_NOT_POSSIBLE)
{
}
fprintf(stderr, "DEBUG: Get-Job-Attributes: %s (%s)\n",
- ippErrorString(ipp_status), cupsLastErrorString());
+ ippErrorString(ipp_status), cupsGetErrorString());
debug_attributes(response);
if (ipp_status <= IPP_STATUS_OK_CONFLICTING)
{
cancel_job(http, uri, job_id, resource, argv[2], version);
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
_cupsLangPrintFilter(stderr, "ERROR", _("Unable to cancel print job."));
}
check_printer_state(http, uri, resource, argv[2], version);
- if (cupsLastError() <= IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
password_tries = 0;
/*
}
fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
- ippErrorString(cupsLastError()), cupsLastErrorString());
+ ippErrorString(cupsGetError()), cupsGetErrorString());
debug_attributes(response);
ippDelete(response);
monitor->resource,
monitor->user,
monitor->version);
- if (cupsLastError() <= IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
password_tries = 0;
if (monitor->job_id == 0 && monitor->create_job)
response = cupsDoRequest(http, request, monitor->resource);
fprintf(stderr, "DEBUG: (monitor) %s: %s (%s)\n", ippOpString(job_op),
- ippErrorString(cupsLastError()), cupsLastErrorString());
+ ippErrorString(cupsGetError()), cupsGetErrorString());
- if (cupsLastError() <= IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() <= IPP_STATUS_OK_CONFLICTING)
password_tries = 0;
if (job_op == IPP_OP_GET_JOB_ATTRIBUTES)
cancel_job(http, monitor->uri, monitor->job_id, monitor->resource,
monitor->user, monitor->version);
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- fprintf(stderr, "DEBUG: (monitor) cancel_job() = %s\n", cupsLastErrorString());
+ fprintf(stderr, "DEBUG: (monitor) cancel_job() = %s\n", cupsGetErrorString());
_cupsLangPrintFilter(stderr, "ERROR", _("Unable to cancel print job."));
}
}
if ((named_dest = cupsGetNamedDest(http, dest, instance)) == NULL)
{
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
else if (instance)
_cupsLangPrintf(stderr, _("%s: Error - unknown destination \"%s/%s\"."), argv[0], dest, instance);
{
if ((named_dest = cupsGetNamedDest(http, NULL, NULL)) == NULL)
{
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
}
else
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
ippDelete(response);
return (0);
}
}
else
{
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (0);
}
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
ippDelete(response);
return;
}
ippDelete(response);
}
else
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
}
{
char email[1024]; /* EMail address */
- snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(), httpGetHostname(NULL, buffer, sizeof(buffer)));
+ snprintf(email, sizeof(email), "mailto:%s@%s", cupsGetUser(), httpGetHostname(NULL, buffer, sizeof(buffer)));
num_options = cupsAddOption("notify-recipient-uri", email, num_options, &options);
}
break;
dest->options[j].value,
num_options, &options);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND)
+ else if (cupsGetError() == IPP_STATUS_ERROR_NOT_FOUND)
{
_cupsLangPrintf(stderr,
_("%s: Error - The printer or class does not exist."), argv[0]);
dest->options[j].value,
num_options, &options);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server "
if (printer == NULL)
{
- if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND)
- _cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsLastErrorString());
+ if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsGetError() == IPP_STATUS_ERROR_NOT_FOUND)
+ _cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsGetErrorString());
else
_cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."), argv[0]);
if (cupsFinishDocument(CUPS_HTTP_DEFAULT, printer) != IPP_OK)
{
- _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
return (1);
}
if (job_id < 1)
{
- _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
return (1);
}
if (cupsCancelJob2(CUPS_HTTP_DEFAULT, name, job_id, 0) != IPP_OK)
{
- _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
goto error;
}
if (!did_cancel && cupsCancelJob2(CUPS_HTTP_DEFAULT, name, 0, 0) != IPP_OK)
{
- _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
goto error;
}
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(modify ? _("Unable to modify class") :
{
fprintf(stderr,
"ERROR: CUPS-Get-Devices request failed with status %x: %s\n",
- cupsLastError(), cupsLastErrorString());
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ cupsGetError(), cupsGetErrorString());
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
else
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(modify ? _("Unable to modify printer") :
cgiStartHTML(cgiText(_("Change Settings")));
cgiSetVariable("MESSAGE",
cgiText(_("Unable to change server settings")));
- cgiSetVariable("ERROR", cupsLastErrorString());
+ cgiSetVariable("ERROR", cupsGetErrorString());
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
return;
if (!cupsAdminSetServerSettings(http, num_newsettings, newsettings))
{
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
cgiStartHTML(cgiText(_("Change Settings")));
cgiSetVariable("MESSAGE",
cgiText(_("Unable to change server settings")));
- cgiSetVariable("ERROR", cupsLastErrorString());
+ cgiSetVariable("ERROR", cupsGetErrorString());
cgiCopyTemplateLang("error.tmpl");
}
else
* Show the results...
*/
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() <= IPP_OK_CONFLICT)
+ else if (cupsGetError() <= IPP_OK_CONFLICT)
{
/*
* Redirect successful updates back to the classes page...
cgiStartHTML(cgiText(_("Delete Class")));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Unable to delete class"));
else
cgiCopyTemplateLang("class-deleted.tmpl");
* Show the results...
*/
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() <= IPP_OK_CONFLICT)
+ else if (cupsGetError() <= IPP_OK_CONFLICT)
{
/*
* Redirect successful updates back to the printers page...
cgiStartHTML(cgiText(_("Delete Printer")));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Unable to delete printer"));
else
cgiCopyTemplateLang("printer-deleted.tmpl");
{
cgiSetVariable("SETTINGS_MESSAGE",
cgiText(_("Unable to open cupsd.conf file:")));
- cgiSetVariable("SETTINGS_ERROR", cupsLastErrorString());
+ cgiSetVariable("SETTINGS_ERROR", cupsGetErrorString());
}
if ((val = cupsGetOption(CUPS_SERVER_DEBUG_LOGGING, num_settings,
cgiStartHTML(cgiText(_("Set Allowed Users")));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Unable to get printer attributes"));
else
cgiCopyTemplateLang("users.tmpl");
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(cgiText(_("Set Allowed Users")));
cgiShowIPPError(_("Unable to change printer"));
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to set server default"));
else
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to set options"));
ippDelete(response);
}
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(cgiText(_("Set Publishing")));
cgiShowIPPError(_("Unable to change printer-is-shared attribute"));
snprintf(resource, sizeof(resource), "/classes/%s", printer);
ippDelete(cupsDoRequest(http, request, resource));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to do maintenance command"));
job_printer_name = strrchr(job_printer_uri, '/') + 1;
- if (cupsLastError() <= IPP_OK_CONFLICT)
+ if (cupsGetError() <= IPP_OK_CONFLICT)
{
const char *path = strstr(job_printer_uri, "/printers/");
if (!path)
else
cgiStartHTML(cgiText(_("Move All Jobs")));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
{
if (job_id)
cgiShowIPPError(_("Unable to move job"));
1, &hold_option)) < 1)
{
cgiSetVariable("MESSAGE", cgiText(_("Unable to send command to printer driver")));
- cgiSetVariable("ERROR", cupsLastErrorString());
+ cgiSetVariable("ERROR", cupsGetErrorString());
cgiStartHTML(title);
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
if (status == HTTP_CONTINUE)
cupsFinishDocument(http, dest);
- if (cupsLastError() >= IPP_REDIRECTION_OTHER_SITE)
+ if (cupsGetError() >= IPP_REDIRECTION_OTHER_SITE)
{
cgiSetVariable("MESSAGE", cgiText(_("Unable to send command to printer driver")));
- cgiSetVariable("ERROR", cupsLastErrorString());
+ cgiSetVariable("ERROR", cupsGetErrorString());
cgiStartHTML(title);
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
ippDelete(response);
}
- if (cupsLastError() <= IPP_OK_CONFLICT)
+ if (cupsGetError() <= IPP_OK_CONFLICT)
{
/*
* Automatically reload the printer status page...
snprintf(refresh, sizeof(refresh), "2;URL=%s", uri);
cgiSetVariable("refresh_page", refresh);
}
- else if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ else if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
cgiStartHTML(cgiText(_("Print Test Page")));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Unable to print test page"));
else
{
cgiShowIPPError(const char *message) /* I - Contextual message */
{
cgiSetVariable("MESSAGE", cgiText(message));
- cgiSetVariable("ERROR", cupsLastErrorString());
+ cgiSetVariable("ERROR", cupsGetErrorString());
cgiCopyTemplateLang("error.tmpl");
}
ippDelete(cupsDoRequest(http, request, "/jobs"));
- if (cupsLastError() <= IPP_OK_CONFLICT && getenv("HTTP_REFERER"))
+ if (cupsGetError() <= IPP_OK_CONFLICT && 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 (cupsLastError() == IPP_NOT_AUTHORIZED)
+ else if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
cgiStartHTML(cgiText(_("Jobs")));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
cgiShowIPPError(_("Job operation failed"));
else if (op == IPP_CANCEL_JOB)
cgiCopyTemplateLang("job-cancel.tmpl");
snprintf(resource, sizeof(resource), "/printers/%s", printer);
ippDelete(cupsDoRequest(http, request, resource));
- if (cupsLastError() == IPP_NOT_AUTHORIZED)
+ if (cupsGetError() == IPP_NOT_AUTHORIZED)
{
puts("Status: 401\n");
exit(0);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
cgiStartHTML(title);
cgiShowIPPError(_("Unable to do maintenance command"));
if (!<a href="#cupsAdminGetServerSettings">cupsAdminGetServerSettings</a>(CUPS_HTTP_DEFAULT, &num_settings, &settings))
{
- fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsLastErrorString());
+ fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsGetErrorString());
return;
}
if (!<a href="#cupsAdminSetServerSettings">cupsAdminSetServerSettings</a>(CUPS_HTTP_DEFAULT, num_settings, settings))
{
- fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsLastErrorString());
+ fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsGetErrorString());
}
<a href="api-cups.html#cupsFreeOptions">cupsFreeOptions</a>(num_settings, settings);
if (cups_auth_param(schemedata, "username", default_username, sizeof(default_username)))
cupsSetUser(default_username);
- snprintf(prompt, sizeof(prompt), _cupsLangString(cg->lang_default, _("Password for %s on %s? ")), cupsUser(), http->hostname[0] == '/' ? "localhost" : http->hostname);
+ snprintf(prompt, sizeof(prompt), _cupsLangString(cg->lang_default, _("Password for %s on %s? ")), cupsGetUser(), http->hostname[0] == '/' ? "localhost" : http->hostname);
http->digest_tries = _cups_strncasecmp(scheme, "Digest", 6) != 0;
http->userpass[0] = '\0';
return (-1);
}
- snprintf(http->userpass, sizeof(http->userpass), "%s:%s", cupsUser(), password);
+ snprintf(http->userpass, sizeof(http->userpass), "%s:%s", cupsGetUser(), password);
}
else if (http->status == HTTP_STATUS_UNAUTHORIZED)
http->digest_tries ++;
snprintf(prompt, sizeof(prompt),
_cupsLangString(cg->lang_default, _("Password for %s on %s? ")),
- cupsUser(), http->gsshost);
+ cupsGetUser(), http->gsshost);
if ((password = cupsGetPassword2(prompt, http, method, resource)) == NULL)
return (CUPS_GSS_FAIL);
* Try to acquire credentials...
*/
- username = cupsUser();
+ username = cupsGetUser();
if (!strchr(username, '@'))
{
snprintf(userbuf, sizeof(userbuf), "%s@%s", username, http->gsshost);
cups_auth_find(www_auth, "PeerCred"))
{
/*
- * Verify that the current cupsUser() matches the current UID...
+ * Verify that the current cupsGetUser() matches the current UID...
*/
struct passwd pwd; /* Password information */
struct passwd *result; /* Auxiliary pointer */
const char *username; /* Current username */
- username = cupsUser();
+ username = cupsGetUser();
getpwnam_r(username, &pwd, cg->pw_buf, PW_BUF_SIZE, &result);
if (result && pwd.pw_uid == getuid())
# ifdef HAVE_GSSAPI
extern int _cupsSetNegotiateAuthString(http_t *http, const char *method, const char *resource) _CUPS_PRIVATE;
# endif /* HAVE_GSSAPI */
-extern char *_cupsUserDefault(char *name, size_t namesize) _CUPS_INTERNAL;
+extern char *_cupsGetUserDefault(char *name, size_t namesize) _CUPS_INTERNAL;
/*
-/*
- * API definitions for CUPS.
- *
- * Copyright © 2021-2023 by OpenPrinting.
- * Copyright © 2007-2020 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
- */
+//
+// API definitions for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2020 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0. See the file "LICENSE" for more
+// information.
+//
#ifndef _CUPS_CUPS_H_
# define _CUPS_CUPS_H_
-
-/*
- * Include necessary headers...
- */
-
+# include <stdbool.h>
# include <sys/types.h>
# if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
# define __CUPS_SSIZE_T_DEFINED
# include <stddef.h>
-/* Windows does not support the ssize_t type, so map it to __int64... */
-typedef __int64 ssize_t; /* @private@ */
-# endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
-
+// Windows does not support the ssize_t type, so map it to __int64...
+typedef __int64 ssize_t; // @private@
+# endif // _WIN32 && !__CUPS_SSIZE_T_DEFINED
# include "file.h"
# include "ipp.h"
# include "language.h"
# include "pwg.h"
-
-
-/*
- * C++ magic...
- */
-
# ifdef __cplusplus
extern "C" {
-# endif /* __cplusplus */
+# endif // __cplusplus
-/*
- * Constants...
- */
+//
+// Constants...
+//
# define CUPS_VERSION 2.0500
# define CUPS_VERSION_MAJOR 2
# define CUPS_VERSION_PATCH 0
# define CUPS_BC_FD 3
- /* Back-channel file descriptor for
- * select/poll */
+ // Back-channel file descriptor for select/poll
# define CUPS_DATE_ANY (time_t)-1
# define CUPS_EXCLUDE_NONE (const char *)0
# define CUPS_FORMAT_AUTO "application/octet-stream"
# define CUPS_JOBID_CURRENT 0
# define CUPS_LENGTH_VARIABLE (ssize_t)0
# define CUPS_TIMEOUT_DEFAULT 0
-# define CUPS_WHICHJOBS_ALL -1
-# define CUPS_WHICHJOBS_ACTIVE 0
-# define CUPS_WHICHJOBS_COMPLETED 1
-
-/* Flags for cupsConnectDest and cupsEnumDests */
-# define CUPS_DEST_FLAGS_NONE 0x00
- /* No flags are set */
-# define CUPS_DEST_FLAGS_UNCONNECTED 0x01
- /* There is no connection */
-# define CUPS_DEST_FLAGS_MORE 0x02
- /* There are more destinations */
-# define CUPS_DEST_FLAGS_REMOVED 0x04
- /* The destination has gone away */
-# define CUPS_DEST_FLAGS_ERROR 0x08
- /* An error occurred */
-# define CUPS_DEST_FLAGS_RESOLVING 0x10
- /* The destination address is being
- * resolved */
-# define CUPS_DEST_FLAGS_CONNECTING 0x20
- /* A connection is being established */
-# define CUPS_DEST_FLAGS_CANCELED 0x40
- /* Operation was canceled */
-# define CUPS_DEST_FLAGS_DEVICE 0x80
- /* For @link cupsConnectDest@: Connect to device */
-
-/* Flags for cupsGetDestMediaByName/Size */
-# define CUPS_MEDIA_FLAGS_DEFAULT 0x00
- /* Find the closest size supported by
- * the printer */
-# define CUPS_MEDIA_FLAGS_BORDERLESS 0x01
- /* Find a borderless size */
-# define CUPS_MEDIA_FLAGS_DUPLEX 0x02
- /* Find a size compatible with 2-sided
- * printing */
-# define CUPS_MEDIA_FLAGS_EXACT 0x04
- /* Find an exact match for the size */
-# define CUPS_MEDIA_FLAGS_READY 0x08
- /* If the printer supports media
- * sensing, find the size amongst the
- * "ready" media. */
-
-/* Options and values */
+
+// Options and values
# define CUPS_COPIES "copies"
# define CUPS_COPIES_SUPPORTED "copies-supported"
# define CUPS_PRINT_COLOR_MODE_SUPPORTED "print-color-mode-supported"
# define CUPS_PRINT_COLOR_MODE_AUTO "auto"
-# define CUPS_PRINT_COLOR_MODE_MONOCHROME "monochrome"
+# define CUPS_PRINT_COLOR_MODE_BI_LEVEL "bi-level"
# define CUPS_PRINT_COLOR_MODE_COLOR "color"
+# define CUPS_PRINT_COLOR_MODE_MONOCHROME "monochrome"
# define CUPS_PRINT_QUALITY "print-quality"
# define CUPS_PRINT_QUALITY_SUPPORTED "print-quality-supported"
# define CUPS_SIDES_TWO_SIDED_LANDSCAPE "two-sided-short-edge"
-/*
- * Types and structures...
- */
-
-typedef unsigned cups_ptype_t; /* Printer type/capability bits */
-enum cups_ptype_e /* Printer type/capability bit
- * constants */
-{ /* Not a typedef'd enum so we can OR */
- CUPS_PRINTER_LOCAL = 0x0000, /* Local printer or class */
- CUPS_PRINTER_CLASS = 0x0001, /* Printer class */
- CUPS_PRINTER_REMOTE = 0x0002, /* Remote printer or class */
- CUPS_PRINTER_BW = 0x0004, /* Can do B&W printing */
- CUPS_PRINTER_COLOR = 0x0008, /* Can do color printing */
- CUPS_PRINTER_DUPLEX = 0x0010, /* Can do two-sided printing */
- CUPS_PRINTER_STAPLE = 0x0020, /* Can staple output */
- CUPS_PRINTER_COPIES = 0x0040, /* Can do copies in hardware */
- CUPS_PRINTER_COLLATE = 0x0080, /* Can quickly collate copies */
- CUPS_PRINTER_PUNCH = 0x0100, /* Can punch output */
- CUPS_PRINTER_COVER = 0x0200, /* Can cover output */
- CUPS_PRINTER_BIND = 0x0400, /* Can bind output */
- CUPS_PRINTER_SORT = 0x0800, /* Can sort output */
- CUPS_PRINTER_SMALL = 0x1000, /* Can print on Letter/Legal/A4-size media */
- CUPS_PRINTER_MEDIUM = 0x2000, /* Can print on Tabloid/B/C/A3/A2-size media */
- CUPS_PRINTER_LARGE = 0x4000, /* Can print on D/E/A1/A0-size media */
- CUPS_PRINTER_VARIABLE = 0x8000, /* Can print on rolls and custom-size media */
- CUPS_PRINTER_IMPLICIT = 0x10000, /* Implicit class @private@
- * @since Deprecated@ */
- CUPS_PRINTER_DEFAULT = 0x20000, /* Default printer on network */
- CUPS_PRINTER_FAX = 0x40000, /* Fax queue */
- CUPS_PRINTER_REJECTING = 0x80000, /* Printer is rejecting jobs */
- CUPS_PRINTER_DELETE = 0x100000, /* Delete printer
- * @deprecated@ @exclude all@ */
- CUPS_PRINTER_NOT_SHARED = 0x200000, /* Printer is not shared
- * @since CUPS 1.2/macOS 10.5@ */
- CUPS_PRINTER_AUTHENTICATED = 0x400000,/* Printer requires authentication
- * @since CUPS 1.2/macOS 10.5@ */
- CUPS_PRINTER_COMMANDS = 0x800000, /* Printer supports maintenance commands
- * @since CUPS 1.2/macOS 10.5@ */
- CUPS_PRINTER_DISCOVERED = 0x1000000, /* Printer was discovered @since CUPS 1.2/macOS 10.5@ */
- CUPS_PRINTER_SCANNER = 0x2000000, /* Scanner-only device
- * @since CUPS 1.4/macOS 10.6@ @private@ */
- CUPS_PRINTER_MFP = 0x4000000, /* Printer with scanning capabilities
- * @since CUPS 1.4/macOS 10.6@ @private@ */
- CUPS_PRINTER_3D = 0x8000000, /* Printer with 3D capabilities @exclude all@ @private@ */
- CUPS_PRINTER_OPTIONS = 0x6fffc /* ~(CLASS | REMOTE | IMPLICIT |
- * DEFAULT | FAX | REJECTING | DELETE |
- * NOT_SHARED | AUTHENTICATED |
- * COMMANDS | DISCOVERED) @private@ */
+//
+// Types and structures...
+//
+
+enum cups_credpurpose_e // X.509 credential purposes
+{
+ CUPS_CREDPURPOSE_SERVER_AUTH = 0x01, // serverAuth
+ CUPS_CREDPURPOSE_CLIENT_AUTH = 0x02, // clientAuth
+ CUPS_CREDPURPOSE_CODE_SIGNING = 0x04, // codeSigning
+ CUPS_CREDPURPOSE_EMAIL_PROTECTION = 0x08, // emailProtection
+ CUPS_CREDPURPOSE_TIME_STAMPING = 0x10, // timeStamping
+ CUPS_CREDPURPOSE_OCSP_SIGNING = 0x20, // OCSPSigning
+ CUPS_CREDPURPOSE_ALL = 0x3f // All purposes
};
+typedef unsigned cups_credpurpose_t; // Combined X.509 credential purposes for @link cupsCreateCredentials@ and @link cupsCreateCredentialsRequest@
-typedef struct cups_option_s /**** Printer Options ****/
+typedef enum cups_credtype_e // X.509 credential types for @link cupsCreateCredentials@ and @link cupsCreateCredentialsRequest@
+{
+ CUPS_CREDTYPE_DEFAULT, // Default type
+ CUPS_CREDTYPE_RSA_2048_SHA256, // RSA with 2048-bit keys and SHA-256 hash
+ CUPS_CREDTYPE_RSA_3072_SHA256, // RSA with 3072-bit keys and SHA-256 hash
+ CUPS_CREDTYPE_RSA_4096_SHA256, // RSA with 4096-bit keys and SHA-256 hash
+ CUPS_CREDTYPE_ECDSA_P256_SHA256, // ECDSA using the P-256 curve with SHA-256 hash
+ CUPS_CREDTYPE_ECDSA_P384_SHA256, // ECDSA using the P-384 curve with SHA-256 hash
+ CUPS_CREDTYPE_ECDSA_P521_SHA256 // ECDSA using the P-521 curve with SHA-256 hash
+} cups_credtype_t;
+
+enum cups_credusage_e // X.509 keyUsage flags
{
- char *name; /* Name of option */
- char *value; /* Value of option */
+ CUPS_CREDUSAGE_DIGITAL_SIGNATURE = 0x001, // digitalSignature
+ CUPS_CREDUSAGE_NON_REPUDIATION = 0x002, // nonRepudiation/contentCommitment
+ CUPS_CREDUSAGE_KEY_ENCIPHERMENT = 0x004, // keyEncipherment
+ CUPS_CREDUSAGE_DATA_ENCIPHERMENT = 0x008, // dataEncipherment
+ CUPS_CREDUSAGE_KEY_AGREEMENT = 0x010, // keyAgreement
+ CUPS_CREDUSAGE_KEY_CERT_SIGN = 0x020, // keyCertSign
+ CUPS_CREDUSAGE_CRL_SIGN = 0x040, // cRLSign
+ CUPS_CREDUSAGE_ENCIPHER_ONLY = 0x080, // encipherOnly
+ CUPS_CREDUSAGE_DECIPHER_ONLY = 0x100, // decipherOnly
+ CUPS_CREDUSAGE_DEFAULT_CA = 0x061, // Defaults for CA certs
+ CUPS_CREDUSAGE_DEFAULT_TLS = 0x005, // Defaults for TLS certs
+ CUPS_CREDUSAGE_ALL = 0x1ff // All keyUsage flags
+};
+typedef unsigned cups_credusage_t; // Combined X.509 keyUsage flags for @link cupsCreateCredentials@ and @link cupsCreateCredentialsRequest@
+
+enum cups_dest_flags_e // Flags for @link cupsConnectDest@ and @link cupsEnumDests@
+{
+ CUPS_DEST_FLAGS_NONE = 0x00, // No flags are set
+ CUPS_DEST_FLAGS_UNCONNECTED = 0x01, // There is no connection
+ CUPS_DEST_FLAGS_MORE = 0x02, // There are more destinations
+ CUPS_DEST_FLAGS_REMOVED = 0x04, // The destination has gone away
+ CUPS_DEST_FLAGS_ERROR = 0x08, // An error occurred
+ CUPS_DEST_FLAGS_RESOLVING = 0x10, // The destination address is being resolved
+ CUPS_DEST_FLAGS_CONNECTING = 0x20, // A connection is being established
+ CUPS_DEST_FLAGS_CANCELED = 0x40, // Operation was canceled
+ CUPS_DEST_FLAGS_DEVICE = 0x80 // For @link cupsConnectDest@: Connect to device
+};
+typedef unsigned cups_dest_flags_t; // Combined flags for @link cupsConnectDest@ and @link cupsEnumDests@
+
+enum cups_media_flags_e // Flags for @link cupsGetDestMediaByName@ and @link cupsGetDestMediaBySize@
+{
+ CUPS_MEDIA_FLAGS_DEFAULT = 0x00, // Find the closest size supported by the printer
+ CUPS_MEDIA_FLAGS_BORDERLESS = 0x01, // Find a borderless size
+ CUPS_MEDIA_FLAGS_DUPLEX = 0x02, // Find a size compatible with 2-sided printing
+ CUPS_MEDIA_FLAGS_EXACT = 0x04, // Find an exact match for the size
+ CUPS_MEDIA_FLAGS_READY = 0x08 // If the printer supports media sensing, find the size amongst the "ready" media.
+};
+typedef unsigned cups_media_flags_t; // Combined flags for @link cupsGetDestMediaByName@ and @link cupsGetDestMediaBySize@
+
+enum cups_ptype_e // Printer type/capability flags
+{
+ CUPS_PRINTER_LOCAL = 0x0000, // Local printer or class
+ CUPS_PRINTER_CLASS = 0x0001, // Printer class
+ CUPS_PRINTER_REMOTE = 0x0002, // Remote printer or class
+ CUPS_PRINTER_BW = 0x0004, // Can do B&W printing
+ CUPS_PRINTER_COLOR = 0x0008, // Can do color printing
+ CUPS_PRINTER_DUPLEX = 0x0010, // Can do two-sided printing
+ CUPS_PRINTER_STAPLE = 0x0020, // Can staple output
+ CUPS_PRINTER_COPIES = 0x0040, // Can do copies in hardware
+ CUPS_PRINTER_COLLATE = 0x0080, // Can quickly collate copies
+ CUPS_PRINTER_PUNCH = 0x0100, // Can punch output
+ CUPS_PRINTER_COVER = 0x0200, // Can cover output
+ CUPS_PRINTER_BIND = 0x0400, // Can bind output
+ CUPS_PRINTER_SORT = 0x0800, // Can sort output
+ CUPS_PRINTER_SMALL = 0x1000, // Can print on Letter/Legal/A4-size media
+ CUPS_PRINTER_MEDIUM = 0x2000, // Can print on Tabloid/B/C/A3/A2-size media
+ CUPS_PRINTER_LARGE = 0x4000, // Can print on D/E/A1/A0-size media
+ CUPS_PRINTER_VARIABLE = 0x8000, // Can print on rolls and custom-size media
+ CUPS_PRINTER_DEFAULT = 0x20000, // Default printer on network
+ CUPS_PRINTER_FAX = 0x40000, // Fax queue
+ CUPS_PRINTER_REJECTING = 0x80000, // Printer is rejecting jobs
+ CUPS_PRINTER_NOT_SHARED = 0x200000, // Printer is not shared
+ CUPS_PRINTER_AUTHENTICATED = 0x400000, // Printer requires authentication
+ CUPS_PRINTER_COMMANDS = 0x800000, // Printer supports maintenance commands
+ CUPS_PRINTER_DISCOVERED = 0x1000000, // Printer was discovered
+ CUPS_PRINTER_SCANNER = 0x2000000, // Scanner-only device
+ CUPS_PRINTER_MFP = 0x4000000, // Printer with scanning capabilities
+ CUPS_PRINTER_3D = 0x8000000, // Printer with 3D capabilities @exclude all@ @private@ @deprecated@
+ CUPS_PRINTER_OPTIONS = 0x6fffc // ~(CLASS | REMOTE | IMPLICIT | DEFAULT | FAX | REJECTING | DELETE | NOT_SHARED | AUTHENTICATED | COMMANDS | DISCOVERED) @private@
+};
+typedef unsigned cups_ptype_t; // Combined printer type/capability flags
+
+typedef enum cups_whichjobs_e // Which jobs for @link cupsGetJobs@
+{
+ CUPS_WHICHJOBS_ALL = -1, // All jobs
+ CUPS_WHICHJOBS_ACTIVE, // Pending/held/processing jobs
+ CUPS_WHICHJOBS_COMPLETED // Completed/canceled/aborted jobs
+} cups_whichjobs_t;
+
+typedef struct cups_option_s // Printer Options
+{
+ char *name; // Name of option
+ char *value; // Value of option
} cups_option_t;
-typedef struct cups_dest_s /**** Destination ****/
+typedef struct cups_dest_s // Destination
{
- char *name, /* Printer or class name */
- *instance; /* Local instance name or NULL */
- int is_default; /* Is this printer the default? */
- int num_options; /* Number of options */
- cups_option_t *options; /* Options */
+ char *name, // Printer or class name
+ *instance; // Local instance name or `NULL`
+ int is_default; // Is this printer the default?
+ int num_options; // Number of options
+ cups_option_t *options; // Options
} cups_dest_t;
typedef struct _cups_dinfo_s cups_dinfo_t;
- /* Destination capability and status
- * information @since CUPS 1.6/macOS 10.8@ */
+ // Destination capability and status information @since CUPS 1.6/macOS 10.8@
-typedef struct cups_job_s /**** Job ****/
+typedef struct cups_job_s // Job information
{
- int id; /* The job ID */
- char *dest; /* Printer or class name */
- char *title; /* Title/job name */
- char *user; /* User that submitted the job */
- char *format; /* Document format */
- ipp_jstate_t state; /* Job state */
- int size; /* Size in kilobytes */
- int priority; /* Priority (1-100) */
- time_t completed_time; /* Time the job was completed */
- time_t creation_time; /* Time the job was created */
- time_t processing_time; /* Time the job was processed */
+ int id; // The job ID
+ char *dest; // Printer or class name
+ char *title; // Title/job name
+ char *user; // User that submitted the job
+ char *format; // Document format
+ ipp_jstate_t state; // Job state
+ int size; // Size in kilobytes
+ int priority; // Priority (1-100)
+ time_t completed_time; // Time the job was completed
+ time_t creation_time; // Time the job was created
+ time_t processing_time; // Time the job was processed
} cups_job_t;
-typedef struct cups_size_s /**** Media Size @since CUPS 1.6/macOS 10.8@ ****/
+typedef struct cups_media_s // Media information @since CUPS 2.5@
+{
+ char media[128], // Media name to use
+ color[128], // Media color (blank for any/auto)
+ source[128], // Media source (blank for any/auto)
+ type[128]; // Media type (blank for any/auto)
+ int width, // Width in hundredths of millimeters
+ length, // Length in hundredths of millimeters
+ bottom, // Bottom margin in hundredths of millimeters
+ left, // Left margin in hundredths of millimeters
+ right, // Right margin in hundredths of millimeters
+ top; // Top margin in hundredths of millimeters
+} cups_media_t;
+
+typedef struct cups_size_s // Media Size @deprecated@
{
- char media[128]; /* Media name to use */
- int width, /* Width in hundredths of millimeters */
- length, /* Length in hundredths of
- * millimeters */
- bottom, /* Bottom margin in hundredths of
- * millimeters */
- left, /* Left margin in hundredths of
- * millimeters */
- right, /* Right margin in hundredths of
- * millimeters */
- top; /* Top margin in hundredths of
- * millimeters */
+ char media[128]; // Media name to use
+ int width, // Width in hundredths of millimeters
+ length, // Length in hundredths of millimeters
+ bottom, // Bottom margin in hundredths of millimeters
+ left, // Left margin in hundredths of millimeters
+ right, // Right margin in hundredths of millimeters
+ top; // Top margin in hundredths of millimeters
} cups_size_t;
-typedef int (*cups_client_cert_cb_t)(http_t *http, void *tls,
- cups_array_t *distinguished_names,
- void *user_data);
- /* Client credentials callback
- * @since CUPS 1.5/macOS 10.7@ */
+typedef int (*cups_client_cert_cb_t)(http_t *http, void *tls, cups_array_t *distinguished_names, void *user_data);
+ // Client credentials callback @deprecated@
+
+typedef bool (*cups_cert_san_cb_t)(const char *common_name, const char *subject_alt_name, void *user_data);
+ // Certificate signing subjectAltName callback
-typedef int (*cups_dest_cb_t)(void *user_data, unsigned flags,
- cups_dest_t *dest);
- /* Destination enumeration callback
- * @since CUPS 1.6/macOS 10.8@ */
+typedef int (*cups_dest_cb_t)(void *user_data, unsigned flags, cups_dest_t *dest);
+ // Destination enumeration callback @since CUPS 1.6/macOS 10.8@
# ifdef __BLOCKS__
typedef int (^cups_dest_block_t)(unsigned flags, cups_dest_t *dest);
- /* Destination enumeration block
- * @since CUPS 1.6/macOS 10.8@
- * @exclude all@ */
+ // Destination enumeration block @deprecated@ @exclude all@
# endif /* __BLOCKS__ */
typedef const char *(*cups_oauth_cb_t)(http_t *http, const char *realm, const char *scope, const char *resource, void *user_data);
- /* OAuth callback @since CUPS 2.4@ */
+ // OAuth callback @since CUPS 2.4@
typedef const char *(*cups_password_cb_t)(const char *prompt);
- /* Password callback @exclude all@ */
+ // Password callback @deprecated@ @exclude all@
-typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http,
- const char *method,
- const char *resource,
- void *user_data);
- /* New password callback
- * @since CUPS 1.4/macOS 10.6@ */
+typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data);
+ // New password callback @since CUPS 1.4/macOS 10.6@
-typedef int (*cups_server_cert_cb_t)(http_t *http, void *tls,
- cups_array_t *certs, void *user_data);
- /* Server credentials callback
- * @since CUPS 1.5/macOS 10.7@ */
+typedef int (*cups_server_cert_cb_t)(http_t *http, void *tls, cups_array_t *certs, void *user_data);
+ // Server credentials callback @deprecated@
-/*
- * Functions...
- */
+//
+// Functions...
+//
+extern int cupsAddDest(const char *name, const char *instance, int num_dests, cups_dest_t **dests) _CUPS_PUBLIC;
+extern int cupsAddDestMediaOptions(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size, int num_options, cups_option_t **options) _CUPS_DEPRECATED_MSG("Use cupsAddDestMediaOptions2 instead.");
+extern int cupsAddDestMediaOptions2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_media_t *media, int num_options, cups_option_t **options) _CUPS_PUBLIC;
+extern int cupsAddIntegerOption(const char *name, int value, int num_options, cups_option_t **options) _CUPS_PUBLIC;
+extern int cupsAddOption(const char *name, const char *value, int num_options, cups_option_t **options) _CUPS_PUBLIC;
+extern bool cupsAreCredentialsValidForName(const char *common_name, const char *credentials);
+
+extern ipp_status_t cupsCancelDestJob(http_t *http, cups_dest_t *dest, int job_id) _CUPS_PUBLIC;
extern int cupsCancelJob(const char *name, int job_id) _CUPS_PUBLIC;
-extern ipp_t *cupsDoFileRequest(http_t *http, ipp_t *request,
- const char *resource,
- const char *filename) _CUPS_PUBLIC;
-extern ipp_t *cupsDoRequest(http_t *http, ipp_t *request,
- const char *resource) _CUPS_PUBLIC;
-extern http_encryption_t cupsEncryption(void);
+extern ipp_status_t cupsCancelJob2(http_t *http, const char *name, int job_id, int purge) _CUPS_PUBLIC;
+extern int cupsCheckDestSupported(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, const char *option, const char *value) _CUPS_PUBLIC;
+extern ipp_status_t cupsCloseDestJob(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int job_id) _CUPS_PUBLIC;
+extern size_t cupsConcatString(char *dst, const char *src, size_t dstsize) _CUPS_PUBLIC;
+extern http_t *cupsConnectDest(cups_dest_t *dest, unsigned flags, int msec, int *cancel, char *resource, size_t resourcesize, cups_dest_cb_t cb, void *user_data) _CUPS_PUBLIC;
+# ifdef __BLOCKS__
+extern http_t *cupsConnectDestBlock(cups_dest_t *dest, unsigned flags, int msec, int *cancel, char *resource, size_t resourcesize, cups_dest_block_t block) _CUPS_DEPRECATED;
+# endif // __BLOCKS__
+extern char *cupsCopyCredentials(const char *path, const char *common_name) _CUPS_PUBLIC;
+extern char *cupsCopyCredentialsKey(const char *path, const char *common_name) _CUPS_PUBLIC;
+extern char *cupsCopyCredentialsRequest(const char *path, const char *common_name) _CUPS_PUBLIC;
+extern int cupsCopyDest(cups_dest_t *dest, int num_dests, cups_dest_t **dests) _CUPS_PUBLIC;
+extern int cupsCopyDestConflicts(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int num_options, cups_option_t *options, const char *new_option, const char *new_value, int *num_conflicts, cups_option_t **conflicts, int *num_resolved, cups_option_t **resolved) _CUPS_PUBLIC;
+extern cups_dinfo_t *cupsCopyDestInfo(http_t *http, cups_dest_t *dest) _CUPS_PUBLIC;
+extern size_t cupsCopyString(char *dst, const char *src, size_t dstsize) _CUPS_PUBLIC;
+extern bool cupsCreateCredentials(const char *path, bool ca_cert, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t usage, const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, size_t num_alt_names, const char * const *alt_names, const char *root_name, time_t expiration_date) _CUPS_PUBLIC;
+extern bool cupsCreateCredentialsRequest(const char *path, cups_credpurpose_t purpose, cups_credtype_t type, cups_credusage_t usage, const char *organization, const char *org_unit, const char *locality, const char *state_province, const char *country, const char *common_name, size_t num_alt_names, const char * const *alt_names) _CUPS_PUBLIC;
+extern ipp_status_t cupsCreateDestJob(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int *job_id, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern int cupsCreateJob(http_t *http, const char *name, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern int cupsCreateTempFd(const char *prefix, const char *suffix, char *filename, size_t len) _CUPS_PUBLIC;
+extern cups_file_t *cupsCreateTempFile(const char *prefix, const char *suffix, char *filename, size_t len) _CUPS_PUBLIC;
+
+extern int cupsDoAuthentication(http_t *http, const char *method, const char *resource) _CUPS_PUBLIC;
+extern ipp_t *cupsDoFileRequest(http_t *http, ipp_t *request, const char *resource, const char *filename) _CUPS_PUBLIC;
+extern ipp_t *cupsDoIORequest(http_t *http, ipp_t *request, const char *resource, int infile, int outfile) _CUPS_PUBLIC;
+extern ipp_t *cupsDoRequest(http_t *http, ipp_t *request, const char *resource) _CUPS_PUBLIC;
+
+extern ipp_attribute_t *cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, const char *name, const char *value) _CUPS_PUBLIC;
+extern void cupsEncodeOptions(ipp_t *ipp, int num_options, cups_option_t *options) _CUPS_DEPRECATED_MSG("Use cupsEncodeOptions2 instead.");
+extern void cupsEncodeOptions2(ipp_t *ipp, int num_options, cups_option_t *options, ipp_tag_t group_tag) _CUPS_PUBLIC;
+extern http_encryption_t cupsEncryption(void) _CUPS_DEPRECATED_MSG("Use cupsGetEncryption instead.");
+extern int cupsEnumDests(cups_dest_flags_t flags, int msec, int *cancel, cups_ptype_t type, cups_ptype_t mask, cups_dest_cb_t cb, void *user_data) _CUPS_PUBLIC;
+# ifdef __BLOCKS__
+extern int cupsEnumDestsBlock(unsigned flags, int msec, int *cancel, cups_ptype_t type, cups_ptype_t mask, cups_dest_block_t block) _CUPS_DEPRECATED;
+# endif // __BLOCKS__
+
+extern ipp_attribute_t *cupsFindDestDefault(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option) _CUPS_PUBLIC;
+extern ipp_attribute_t *cupsFindDestReady(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option) _CUPS_PUBLIC;
+extern ipp_attribute_t *cupsFindDestSupported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option) _CUPS_PUBLIC;
+extern ipp_status_t cupsFinishDestDocument(http_t *http, cups_dest_t *dest, cups_dinfo_t *info) _CUPS_PUBLIC;
+extern ipp_status_t cupsFinishDocument(http_t *http, const char *name) _CUPS_PUBLIC;
+extern void cupsFreeDestInfo(cups_dinfo_t *dinfo) _CUPS_PUBLIC;
+extern void cupsFreeDests(int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
extern void cupsFreeJobs(int num_jobs, cups_job_t *jobs) _CUPS_PUBLIC;
+extern void cupsFreeOptions(int num_options, cups_option_t *options) _CUPS_PUBLIC;
+
extern int cupsGetClasses(char ***classes) _CUPS_DEPRECATED_MSG("Use cupsEnumDests instead.");
+extern time_t cupsGetCredentialsExpiration(const char *credentials) _CUPS_PUBLIC;
+extern char *cupsGetCredentialsInfo(const char *credentials, char *buffer, size_t bufsize) _CUPS_PUBLIC;
+extern http_trust_t cupsGetCredentialsTrust(const char *path, const char *common_name, const char *credentials) _CUPS_PUBLIC;
extern const char *cupsGetDefault(void) _CUPS_PUBLIC;
-extern int cupsGetJobs(cups_job_t **jobs, const char *name,
- int myjobs, int whichjobs) _CUPS_PUBLIC;
-extern int cupsGetPrinters(char ***printers) _CUPS_DEPRECATED_MSG("Use cupsEnumDests instead.");
-extern ipp_status_t cupsLastError(void) _CUPS_PUBLIC;
-extern int cupsPrintFile(const char *name, const char *filename,
- const char *title, int num_options,
- cups_option_t *options) _CUPS_PUBLIC;
-extern int cupsPrintFiles(const char *name, int num_files,
- const char **files, const char *title,
- int num_options, cups_option_t *options) _CUPS_PUBLIC;
-extern char *cupsTempFile(char *filename, int len) _CUPS_DEPRECATED_MSG("Use cupsTempFd or cupsTempFile2 instead.");
-extern int cupsTempFd(char *filename, int len) _CUPS_PUBLIC;
-
-extern int cupsAddDest(const char *name, const char *instance,
- int num_dests, cups_dest_t **dests) _CUPS_PUBLIC;
-extern void cupsFreeDests(int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
-extern cups_dest_t *cupsGetDest(const char *name, const char *instance,
- int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
+extern const char *cupsGetDefault2(http_t *http) _CUPS_PUBLIC;
+extern cups_dest_t *cupsGetDest(const char *name, const char *instance, int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
+extern int cupsGetDestMediaByIndex(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, int n, unsigned flags, cups_size_t *size) _CUPS_DEPRECATED_MSG("Use cupsGetDestMediaByIndex2 instead.");
+extern bool cupsGetDestMediaByIndex2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, size_t n, unsigned flags, cups_media_t *media) _CUPS_PUBLIC;
+extern int cupsGetDestMediaByName(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *name, unsigned flags, cups_size_t *size) _CUPS_DEPRECATED_MSG("Use cupsGetDestMediaByName2 instead.");
+extern bool cupsGetDestMediaByName2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *name, unsigned flags, cups_media_t *media) _CUPS_PUBLIC;
+extern int cupsGetDestMediaBySize(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, int width, int length, unsigned flags, cups_size_t *size) _CUPS_DEPRECATED_MSG("Use cupsGetDestMediaBySize2 instead.");
+extern bool cupsGetDestMediaBySize2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, int width, int length, unsigned flags, cups_media_t *media) _CUPS_PUBLIC;
+extern int cupsGetDestMediaCount(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags) _CUPS_PUBLIC;
+extern int cupsGetDestMediaDefault(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size) _CUPS_DEPRECATED_MSG("Use cupsGetDestMediaDefault2 instead.");
+extern bool cupsGetDestMediaDefault2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_media_t *media) _CUPS_PUBLIC;
+extern cups_dest_t *cupsGetDestWithURI(const char *name, const char *uri) _CUPS_PUBLIC;
extern int cupsGetDests(cups_dest_t **dests) _CUPS_PUBLIC;
+extern int cupsGetDests2(http_t *http, cups_dest_t **dests) _CUPS_PUBLIC;
+extern http_encryption_t cupsGetEncryption(void) _CUPS_PUBLIC;
+extern ipp_status_t cupsGetError(void) _CUPS_PUBLIC;
+extern const char *cupsGetErrorString(void) _CUPS_PUBLIC;
+extern http_status_t cupsGetFile(http_t *http, const char *resource, const char *filename) _CUPS_PUBLIC;
+extern http_status_t cupsGetFd(http_t *http, const char *resource, int fd) _CUPS_PUBLIC;
+extern int cupsGetIntegerOption(const char *name, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern int cupsGetJobs(cups_job_t **jobs, const char *name, int myjobs, int whichjobs) _CUPS_PUBLIC;
+extern int cupsGetJobs2(http_t *http, cups_job_t **jobs, const char *name, int myjobs, int whichjobs) _CUPS_PUBLIC;
+extern cups_dest_t *cupsGetNamedDest(http_t *http, const char *name, const char *instance) _CUPS_PUBLIC;
+extern const char *cupsGetOption(const char *name, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern const char *cupsGetPassword(const char *prompt) _CUPS_DEPRECATED_MSG("Use cupsGetPassword instead.");
+extern const char *cupsGetPassword2(const char *prompt, http_t *http, const char *method, const char *resource) _CUPS_PUBLIC;
+extern int cupsGetPrinters(char ***printers) _CUPS_DEPRECATED_MSG("Use cupsEnumDests instead.");
+extern unsigned cupsGetRand(void) _CUPS_PUBLIC;
+extern ipp_t *cupsGetResponse(http_t *http, const char *resource) _CUPS_PUBLIC;
+extern const char *cupsGetServer(void) _CUPS_PUBLIC;
+extern const char *cupsGetUser(void) _CUPS_PUBLIC;
+extern const char *cupsGetUserAgent(void) _CUPS_PUBLIC;
+
+extern ssize_t cupsHashData(const char *algorithm, const void *data, size_t datalen, unsigned char *hash, size_t hashsize) _CUPS_PUBLIC;
+extern const char *cupsHashString(const unsigned char *hash, size_t hashsize, char *buffer, size_t bufsize) _CUPS_PUBLIC;
+extern ssize_t cupsHMACData(const char *algorithm, const unsigned char *key, size_t keylen, const void *data, size_t datalen, unsigned char *hash, size_t hashsize) _CUPS_PUBLIC;
+
+extern ipp_status_t cupsLastError(void) _CUPS_DEPRECATED_MSG("Use cupsGetError instead.");
+extern const char *cupsLastErrorString(void) _CUPS_DEPRECATED_MSG("Use cupsGetErrorString instead.");
+
+extern const char *cupsLocalizeDestMedia(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, unsigned flags, cups_size_t *size) _CUPS_DEPRECATED_MSG("Use cupsLocalizeDestMedia2 instead.");
+extern const char *cupsLocalizeDestMedia2(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, unsigned flags, cups_media_t *media) _CUPS_PUBLIC;
+extern const char *cupsLocalizeDestOption(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, const char *option) _CUPS_PUBLIC;
+extern const char *cupsLocalizeDestValue(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, const char *option, const char *value) _CUPS_PUBLIC;
+extern char *cupsLocalizeNotifySubject(cups_lang_t *lang, ipp_t *event) _CUPS_PUBLIC;
+extern char *cupsLocalizeNotifyText(cups_lang_t *lang, ipp_t *event) _CUPS_PUBLIC;
+
+extern int cupsMakeServerCredentials(const char *path, const char *common_name, int num_alt_names, const char **alt_names, time_t expiration_date) _CUPS_DEPRECATED_MSG("Use cupsCreateCredentials instead.");
+
+extern char *cupsNotifySubject(cups_lang_t *lang, ipp_t *event) _CUPS_DEPRECATED_MSG("Use cupsLocalizeNotifySubject instead.");
+extern char *cupsNotifyText(cups_lang_t *lang, ipp_t *event) _CUPS_DEPRECATED_MSG("Use cupsLocalizeNotifyText instead.");
+
+extern int cupsParseOptions(const char *arg, int num_options, cups_option_t **options) _CUPS_PUBLIC;
+extern int cupsPrintFile(const char *name, const char *filename, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern int cupsPrintFile2(http_t *http, const char *name, const char *filename, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern int cupsPrintFiles(const char *name, int num_files, const char **files, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern int cupsPrintFiles2(http_t *http, const char *name, int num_files, const char **files, const char *title, int num_options, cups_option_t *options) _CUPS_PUBLIC;
+extern http_status_t cupsPutFd(http_t *http, const char *resource, int fd) _CUPS_PUBLIC;
+extern http_status_t cupsPutFile(http_t *http, const char *resource, const char *filename) _CUPS_PUBLIC;
+
+extern ssize_t cupsReadResponseData(http_t *http, char *buffer, size_t length) _CUPS_PUBLIC;
+extern int cupsRemoveDest(const char *name, const char *instance, int num_dests, cups_dest_t **dests) _CUPS_PUBLIC;
+extern int cupsRemoveOption(const char *name, int num_options, cups_option_t **options) _CUPS_PUBLIC;
+
+extern bool cupsSaveCredentials(const char *path, const char *common_name, const char *credentials, const char *key) _CUPS_PUBLIC;
+extern http_status_t cupsSendRequest(http_t *http, ipp_t *request, const char *resource, size_t length) _CUPS_PUBLIC;
+extern const char *cupsServer(void) _CUPS_DEPRECATED_MSG("Use cupsGetServer instead.");
+extern void cupsSetClientCertCB(cups_client_cert_cb_t cb, void *user_data) _CUPS_DEPRECATED;
+extern bool cupsSetClientCredentials(const char *credentials, const char *key) _CUPS_PUBLIC;
+extern int cupsSetCredentials(cups_array_t *certs) _CUPS_DEPRECATED;
+extern void cupsSetDefaultDest(const char *name, const char *instance, int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
extern void cupsSetDests(int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
-
-extern int cupsAddOption(const char *name, const char *value,
- int num_options, cups_option_t **options) _CUPS_PUBLIC;
-extern void cupsEncodeOptions(ipp_t *ipp, int num_options,
- cups_option_t *options) _CUPS_PUBLIC;
-extern void cupsFreeOptions(int num_options,
- cups_option_t *options) _CUPS_PUBLIC;
-extern const char *cupsGetOption(const char *name, int num_options,
- cups_option_t *options) _CUPS_PUBLIC;
-extern int cupsParseOptions(const char *arg, int num_options,
- cups_option_t **options) _CUPS_PUBLIC;
-
-extern const char *cupsGetPassword(const char *prompt) _CUPS_PUBLIC;
-extern const char *cupsServer(void) _CUPS_PUBLIC;
+extern int cupsSetDests2(http_t *http, int num_dests, cups_dest_t *dests) _CUPS_PUBLIC;
extern void cupsSetEncryption(http_encryption_t e) _CUPS_PUBLIC;
-extern void cupsSetPasswordCB(cups_password_cb_t cb) _CUPS_PUBLIC;
+extern void cupsSetOAuthCB(cups_oauth_cb_t cb, void *data) _CUPS_PUBLIC;
+extern void cupsSetPasswordCB(cups_password_cb_t cb) _CUPS_DEPRECATED_MSG("Use cupsSetPasswordCB2 instead.");
+extern void cupsSetPasswordCB2(cups_password_cb2_t cb, void *user_data) _CUPS_PUBLIC;
extern void cupsSetServer(const char *server) _CUPS_PUBLIC;
+extern void cupsSetServerCertCB(cups_server_cert_cb_t cb, void *user_data) _CUPS_DEPRECATED;
+extern int cupsSetServerCredentials(const char *path, const char *common_name, int auto_create) _CUPS_PUBLIC;
extern void cupsSetUser(const char *user) _CUPS_PUBLIC;
-extern const char *cupsUser(void) _CUPS_PUBLIC;
-
-/**** New in CUPS 1.1.20 ****/
-extern int cupsDoAuthentication(http_t *http, const char *method,
- const char *resource)
- _CUPS_API_1_1_20;
-extern http_status_t cupsGetFile(http_t *http, const char *resource,
- const char *filename) _CUPS_API_1_1_20;
-extern http_status_t cupsGetFd(http_t *http, const char *resource, int fd) _CUPS_API_1_1_20;
-extern http_status_t cupsPutFile(http_t *http, const char *resource,
- const char *filename) _CUPS_API_1_1_20;
-extern http_status_t cupsPutFd(http_t *http, const char *resource, int fd)
- _CUPS_API_1_1_20;
-
-/**** New in CUPS 1.1.21 ****/
-extern const char *cupsGetDefault2(http_t *http) _CUPS_API_1_1_21;
-extern int cupsGetDests2(http_t *http, cups_dest_t **dests)
- _CUPS_API_1_1_21;
-extern int cupsGetJobs2(http_t *http, cups_job_t **jobs,
- const char *name, int myjobs,
- int whichjobs) _CUPS_API_1_1_21;
-extern int cupsPrintFile2(http_t *http, const char *name,
- const char *filename,
- const char *title, int num_options,
- cups_option_t *options) _CUPS_API_1_1_21;
-extern int cupsPrintFiles2(http_t *http, const char *name,
- int num_files, const char **files,
- const char *title, int num_options,
- cups_option_t *options)
- _CUPS_API_1_1_21;
-extern int cupsSetDests2(http_t *http, int num_dests,
- cups_dest_t *dests) _CUPS_API_1_1_21;
-
-/**** New in CUPS 1.2/macOS 10.5 ****/
-extern void cupsEncodeOptions2(ipp_t *ipp, int num_options,
- cups_option_t *options,
- ipp_tag_t group_tag) _CUPS_API_1_2;
-extern const char *cupsLastErrorString(void) _CUPS_API_1_2;
-extern char *cupsNotifySubject(cups_lang_t *lang, ipp_t *event)
- _CUPS_API_1_2;
-extern char *cupsNotifyText(cups_lang_t *lang, ipp_t *event)
- _CUPS_API_1_2;
-extern int cupsRemoveOption(const char *name, int num_options,
- cups_option_t **options) _CUPS_API_1_2;
-extern cups_file_t *cupsTempFile2(char *filename, int len) _CUPS_API_1_2;
-
-/**** New in CUPS 1.3/macOS 10.5 ****/
-extern ipp_t *cupsDoIORequest(http_t *http, ipp_t *request,
- const char *resource, int infile,
- int outfile) _CUPS_API_1_3;
-extern int cupsRemoveDest(const char *name,
- const char *instance,
- int num_dests, cups_dest_t **dests)
- _CUPS_API_1_3;
-extern void cupsSetDefaultDest(const char *name,
- const char *instance,
- int num_dests,
- cups_dest_t *dests) _CUPS_API_1_3;
-
-/**** New in CUPS 1.4/macOS 10.6 ****/
-extern ipp_status_t cupsCancelJob2(http_t *http, const char *name,
- int job_id, int purge) _CUPS_API_1_4;
-extern int cupsCreateJob(http_t *http, const char *name,
- const char *title, int num_options,
- cups_option_t *options) _CUPS_API_1_4;
-extern ipp_status_t cupsFinishDocument(http_t *http,
- const char *name) _CUPS_API_1_4;
-extern cups_dest_t *cupsGetNamedDest(http_t *http, const char *name,
- const char *instance) _CUPS_API_1_4;
-extern const char *cupsGetPassword2(const char *prompt, http_t *http,
- const char *method,
- const char *resource) _CUPS_API_1_4;
-extern ipp_t *cupsGetResponse(http_t *http,
- const char *resource) _CUPS_API_1_4;
-extern ssize_t cupsReadResponseData(http_t *http, char *buffer,
- size_t length) _CUPS_API_1_4;
-extern http_status_t cupsSendRequest(http_t *http, ipp_t *request,
- const char *resource,
- size_t length) _CUPS_API_1_4;
-extern void cupsSetPasswordCB2(cups_password_cb2_t cb,
- void *user_data) _CUPS_API_1_4;
-extern http_status_t cupsStartDocument(http_t *http, const char *name,
- int job_id, const char *docname,
- const char *format,
- int last_document) _CUPS_API_1_4;
-extern http_status_t cupsWriteRequestData(http_t *http, const char *buffer,
- size_t length) _CUPS_API_1_4;
-
-/**** New in CUPS 1.5/macOS 10.7 ****/
-extern void cupsSetClientCertCB(cups_client_cert_cb_t cb,
- void *user_data) _CUPS_API_1_5;
-extern int cupsSetCredentials(cups_array_t *certs) _CUPS_API_1_5;
-extern void cupsSetServerCertCB(cups_server_cert_cb_t cb,
- void *user_data) _CUPS_API_1_5;
-
-/**** New in CUPS 1.6/macOS 10.8 ****/
-extern ipp_status_t cupsCancelDestJob(http_t *http, cups_dest_t *dest,
- int job_id) _CUPS_API_1_6;
-extern int cupsCheckDestSupported(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info,
- const char *option,
- const char *value) _CUPS_API_1_6;
-extern ipp_status_t cupsCloseDestJob(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info, int job_id)
- _CUPS_API_1_6;
-extern http_t *cupsConnectDest(cups_dest_t *dest, unsigned flags,
- int msec, int *cancel,
- char *resource, size_t resourcesize,
- cups_dest_cb_t cb, void *user_data)
- _CUPS_API_1_6;
-# ifdef __BLOCKS__
-extern http_t *cupsConnectDestBlock(cups_dest_t *dest,
- unsigned flags, int msec,
- int *cancel, char *resource,
- size_t resourcesize,
- cups_dest_block_t block)
- _CUPS_API_1_6;
-# endif /* __BLOCKS__ */
-extern int cupsCopyDest(cups_dest_t *dest, int num_dests,
- cups_dest_t **dests) _CUPS_API_1_6;
-extern cups_dinfo_t *cupsCopyDestInfo(http_t *http, cups_dest_t *dest)
- _CUPS_API_1_6;
-extern int cupsCopyDestConflicts(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info,
- int num_options,
- cups_option_t *options,
- const char *new_option,
- const char *new_value,
- int *num_conflicts,
- cups_option_t **conflicts,
- int *num_resolved,
- cups_option_t **resolved)
- _CUPS_API_1_6;
-extern ipp_status_t cupsCreateDestJob(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info, int *job_id,
- const char *title, int num_options,
- cups_option_t *options) _CUPS_API_1_6;
-extern int cupsEnumDests(unsigned flags, int msec, int *cancel,
- cups_ptype_t type, cups_ptype_t mask,
- cups_dest_cb_t cb, void *user_data)
- _CUPS_API_1_6;
-# ifdef __BLOCKS__
-extern int cupsEnumDestsBlock(unsigned flags, int msec,
- int *cancel, cups_ptype_t type,
- cups_ptype_t mask,
- cups_dest_block_t block)
- _CUPS_API_1_6;
-# endif /* __BLOCKS__ */
-extern ipp_status_t cupsFinishDestDocument(http_t *http,
- cups_dest_t *dest,
- cups_dinfo_t *info)
- _CUPS_API_1_6;
-extern void cupsFreeDestInfo(cups_dinfo_t *dinfo) _CUPS_API_1_6;
-extern int cupsGetDestMediaByName(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- const char *media,
- unsigned flags,
- cups_size_t *size) _CUPS_API_1_6;
-extern int cupsGetDestMediaBySize(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- int width, int length,
- unsigned flags,
- cups_size_t *size) _CUPS_API_1_6;
-extern const char *cupsLocalizeDestOption(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info,
- const char *option)
- _CUPS_API_1_6;
-extern const char *cupsLocalizeDestValue(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info,
- const char *option,
- const char *value)
- _CUPS_API_1_6;
-extern http_status_t cupsStartDestDocument(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *info, int job_id,
- const char *docname,
- const char *format,
- int num_options,
- cups_option_t *options,
- int last_document) _CUPS_API_1_6;
-
-/* New in CUPS 1.7 */
-extern ipp_attribute_t *cupsFindDestDefault(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- const char *option) _CUPS_API_1_7;
-extern ipp_attribute_t *cupsFindDestReady(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- const char *option) _CUPS_API_1_7;
-extern ipp_attribute_t *cupsFindDestSupported(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- const char *option)
- _CUPS_API_1_7;
-extern int cupsGetDestMediaByIndex(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo, int n,
- unsigned flags,
- cups_size_t *size)
- _CUPS_API_1_7;
-extern int cupsGetDestMediaCount(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- unsigned flags) _CUPS_API_1_7;
-extern int cupsGetDestMediaDefault(http_t *http, cups_dest_t *dest,
- cups_dinfo_t *dinfo,
- unsigned flags,
- cups_size_t *size)
- _CUPS_API_1_7;
-extern void cupsSetUserAgent(const char *user_agent) _CUPS_API_1_7;
-extern const char *cupsUserAgent(void) _CUPS_API_1_7;
-
-/* New in CUPS 2.0/macOS 10.10 */
-extern cups_dest_t *cupsGetDestWithURI(const char *name, const char *uri) _CUPS_API_2_0;
-extern const char *cupsLocalizeDestMedia(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, unsigned flags, cups_size_t *size) _CUPS_API_2_0;
-extern int cupsMakeServerCredentials(const char *path, const char *common_name, int num_alt_names, const char **alt_names, time_t expiration_date) _CUPS_API_2_0;
-extern int cupsSetServerCredentials(const char *path, const char *common_name, int auto_create) _CUPS_API_2_0;
-
-/* New in CUPS 2.2/macOS 10.12 */
-extern ssize_t cupsHashData(const char *algorithm, const void *data, size_t datalen, unsigned char *hash, size_t hashsize) _CUPS_API_2_2;
-
-/* New in CUPS 2.2.4 */
-extern int cupsAddIntegerOption(const char *name, int value, int num_options, cups_option_t **options) _CUPS_API_2_2_4;
-extern int cupsGetIntegerOption(const char *name, int num_options, cups_option_t *options) _CUPS_API_2_2_4;
-
-/* New in CUPS 2.2.7 */
-extern const char *cupsHashString(const unsigned char *hash, size_t hashsize, char *buffer, size_t bufsize) _CUPS_API_2_2_7;
-
-/* New in CUPS 2.3 */
-extern int cupsAddDestMediaOptions(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size, int num_options, cups_option_t **options) _CUPS_API_2_3;
-extern ipp_attribute_t *cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, const char *name, const char *value) _CUPS_API_2_3;
-
-/* New in CUPS 2.4 */
-extern void cupsSetOAuthCB(cups_oauth_cb_t cb, void *data) _CUPS_API_2_4;
-
-/* New in CUPS 2.5 */
-extern size_t cupsConcatString(char *dst, const char *src, size_t dstsize) _CUPS_PUBLIC;
-extern size_t cupsCopyString(char *dst, const char *src, size_t dstsize) _CUPS_PUBLIC;
+extern void cupsSetUserAgent(const char *user_agent) _CUPS_PUBLIC;
+extern bool cupsSignCredentialsRequest(const char *path, const char *common_name, const char *request, const char *root_name, cups_credpurpose_t allowed_purpose, cups_credusage_t allowed_usage, cups_cert_san_cb_t cb, void *cb_data, time_t expiration_date) _CUPS_PUBLIC;
+extern http_status_t cupsStartDestDocument(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int job_id, const char *docname, const char *format, int num_options, cups_option_t *options, int last_document) _CUPS_PUBLIC;
+extern http_status_t cupsStartDocument(http_t *http, const char *name, int job_id, const char *docname, const char *format, int last_document) _CUPS_PUBLIC;
+
+extern int cupsTempFd(char *filename, int len) _CUPS_DEPRECATED_MSG("Use cupsCreateTempFd instead.");
+extern char *cupsTempFile(char *filename, int len) _CUPS_DEPRECATED_MSG("Use cupsCreateTempFd or cupsCreateTempFile instead.");
+extern cups_file_t *cupsTempFile2(char *filename, int len) _CUPS_DEPRECATED_MSG("Use cupsCreateTempFile instead.");
+
+extern const char *cupsUser(void) _CUPS_DEPRECATED_MSG("Use cupsGetUser instead.");
+extern const char *cupsUserAgent(void) _CUPS_DEPRECATED_MSG("Use cupsGetUserAgent instead.");
+
+extern http_status_t cupsWriteRequestData(http_t *http, const char *buffer, size_t length) _CUPS_PUBLIC;
# ifdef __cplusplus
}
-# endif /* __cplusplus */
-
-#endif /* !_CUPS_CUPS_H_ */
+# endif // __cplusplus
+#endif // !_CUPS_CUPS_H_
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, info->uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippDelete(cupsDoRequest(http, request, info->resource));
cupsFreeDestInfo(info);
}
- return (cupsLastError());
+ return (cupsGetError());
}
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
job_id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
if (ippGetOperation(request) == IPP_OP_SEND_DOCUMENT)
ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", 1);
ippDelete(cupsDoRequest(http, request, info->resource));
- DEBUG_printf(("1cupsCloseDestJob: %s (%s)", ippErrorString(cupsLastError()),
- cupsLastErrorString()));
+ DEBUG_printf(("1cupsCloseDestJob: %s (%s)", ippErrorString(cupsGetError()),
+ cupsGetErrorString()));
- return (cupsLastError());
+ return (cupsGetError());
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, info->uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
if (title)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
title);
* Return the status code from the Create-Job request...
*/
- DEBUG_printf(("1cupsCreateDestJob: %s (%s)", ippErrorString(cupsLastError()),
- cupsLastErrorString()));
+ DEBUG_printf(("1cupsCreateDestJob: %s (%s)", ippErrorString(cupsGetError()),
+ cupsGetErrorString()));
- return (cupsLastError());
+ return (cupsGetError());
}
ippDelete(cupsGetResponse(http, info->resource));
DEBUG_printf(("1cupsFinishDestDocument: %s (%s)",
- ippErrorString(cupsLastError()), cupsLastErrorString()));
+ ippErrorString(cupsGetError()), cupsGetErrorString()));
- return (cupsLastError());
+ return (cupsGetError());
}
NULL, info->uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
if (docname)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name",
NULL, docname);
30000, NULL)) == NULL)
{
DEBUG_printf(("4cups_create_localizations: Unable to connect to "
- "%s:%d: %s", hostname, port, cupsLastErrorString()));
+ "%s:%d: %s", hostname, port, cupsGetErrorString()));
return;
}
}
if ((temp = cupsTempFile2(tempfile, sizeof(tempfile))) == NULL)
{
DEBUG_printf(("4cups_create_localizations: Unable to create temporary "
- "file: %s", cupsLastErrorString()));
+ "file: %s", cupsGetErrorString()));
if (http2 != http)
httpClose(http2);
return;
unsigned flags);
static void cups_create_constraints(cups_dinfo_t *dinfo);
static void cups_create_defaults(cups_dinfo_t *dinfo);
-static void cups_create_media_db(cups_dinfo_t *dinfo,
- unsigned flags);
+static void cups_create_media_db(cups_dinfo_t *dinfo, unsigned flags);
static void cups_free_media_db(_cups_media_db_t *mdb);
-static int cups_get_media_db(http_t *http, cups_dinfo_t *dinfo,
- pwg_media_t *pwg, unsigned flags,
- cups_size_t *size);
+static int cups_get_media_db(http_t *http, cups_dinfo_t *dinfo, pwg_media_t *pwg, unsigned flags, cups_size_t *size, cups_media_t *media);
static int cups_is_close_media_db(_cups_media_db_t *a,
_cups_media_db_t *b);
-static cups_array_t *cups_test_constraints(cups_dinfo_t *dinfo,
- const char *new_option,
- const char *new_value,
- int num_options,
- cups_option_t *options,
- int *num_conflicts,
- cups_option_t **conflicts);
+static cups_array_t *cups_test_constraints(cups_dinfo_t *dinfo, const char *new_option, const char *new_value, int num_options, cups_option_t *options, int *num_conflicts, cups_option_t **conflicts);
static void cups_update_ready(http_t *http, cups_dinfo_t *dinfo);
}
+/*
+ * 'cupsAddDestMediaOptions2()' - Add the options corresponding to the specified media information.
+ *
+ * @since CUPS 2.5@
+ */
+
+int /* O - New number of options */
+cupsAddDestMediaOptions2(
+ http_t *http, /* I - Connection to destination */
+ cups_dest_t *dest, /* I - Destination */
+ cups_dinfo_t *dinfo, /* I - Destination information */
+ unsigned flags, /* I - Media matching flags */
+ cups_media_t *media, /* I - Media information */
+ int num_options, /* I - Current number of options */
+ cups_option_t **options) /* IO - Options */
+{
+ cups_array_t *db; /* Media database */
+ _cups_media_db_t *mdb; /* Media database entry */
+ char value[2048]; /* Option value */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!http || !dest || !dinfo || !media || !options)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (num_options);
+ }
+
+ /*
+ * Find the matching media size...
+ */
+
+ if (flags & CUPS_MEDIA_FLAGS_READY)
+ db = dinfo->ready_db;
+ else
+ db = dinfo->media_db;
+
+ DEBUG_printf(("1cupsAddDestMediaOptions2: media->media=\"%s\"", media->media));
+
+ for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
+ {
+ if (mdb->key && !strcmp(mdb->key, media->media))
+ break;
+ else if (mdb->size_name && !strcmp(mdb->size_name, media->media))
+ break;
+ }
+
+ if (!mdb)
+ {
+ for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
+ {
+ if (mdb->width == media->width && mdb->length == media->length && mdb->bottom == media->bottom && mdb->left == media->left && mdb->right == media->right && mdb->top == media->top)
+ break;
+ }
+ }
+
+ if (!mdb)
+ {
+ for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
+ {
+ if (mdb->width == media->width && mdb->length == media->length)
+ break;
+ }
+ }
+
+ if (!mdb)
+ {
+ DEBUG_puts("1cupsAddDestMediaOptions2: Unable to find matching size.");
+ return (num_options);
+ }
+
+ DEBUG_printf(("1cupsAddDestMediaOptions2: MATCH mdb%p [key=\"%s\" size_name=\"%s\" source=\"%s\" type=\"%s\" width=%d length=%d B%d L%d R%d T%d]", (void *)mdb, mdb->key, mdb->size_name, mdb->source, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top));
+
+ if (mdb->source)
+ {
+ if (mdb->type)
+ snprintf(value, sizeof(value), "{media-size={x-dimension=%d y-dimension=%d} media-bottom-margin=%d media-left-margin=%d media-right-margin=%d media-top-margin=%d media-source=\"%s\" media-type=\"%s\"}", mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top, mdb->source, mdb->type);
+ else
+ snprintf(value, sizeof(value), "{media-size={x-dimension=%d y-dimension=%d} media-bottom-margin=%d media-left-margin=%d media-right-margin=%d media-top-margin=%d media-source=\"%s\"}", mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top, mdb->source);
+ }
+ else if (mdb->type)
+ {
+ snprintf(value, sizeof(value), "{media-size={x-dimension=%d y-dimension=%d} media-bottom-margin=%d media-left-margin=%d media-right-margin=%d media-top-margin=%d media-type=\"%s\"}", mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top, mdb->type);
+ }
+ else
+ {
+ snprintf(value, sizeof(value), "{media-size={x-dimension=%d y-dimension=%d} media-bottom-margin=%d media-left-margin=%d media-right-margin=%d media-top-margin=%d}", mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top);
+ }
+
+ num_options = cupsAddOption("media-col", value, num_options, options);
+
+ return (num_options);
+}
+
+
/*
* 'cupsCheckDestSupported()' - Check that the option and value are supported
* by the destination.
ippSetVersion(request, version / 10, version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested_attrs) / sizeof(requested_attrs[0])), NULL, requested_attrs);
response = cupsDoRequest(http, request, resource);
- status = cupsLastError();
+ status = cupsGetError();
if (status > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
{
- DEBUG_printf(("1cupsCopyDestInfo: Get-Printer-Attributes for '%s' returned %s (%s)", dest->name, ippErrorString(status), cupsLastErrorString()));
+ DEBUG_printf(("1cupsCopyDestInfo: Get-Printer-Attributes for '%s' returned %s (%s)", dest->name, ippErrorString(status), cupsGetErrorString()));
ippDelete(response);
response = NULL;
}
+/*
+ * 'cupsGetDestMediaByIndex2()' - Get specific media information.
+ *
+ * The @code flags@ parameter determines which set of media are indexed. For
+ * example, passing @code CUPS_MEDIA_FLAGS_BORDERLESS@ will get the Nth
+ * borderless size supported by the printer.
+ *
+ * @since CUPS 2.5@
+ */
+
+bool /* O - `true` on success, `false` on failure */
+cupsGetDestMediaByIndex2(
+ http_t *http, /* I - Connection to destination */
+ cups_dest_t *dest, /* I - Destination */
+ cups_dinfo_t *dinfo, /* I - Destination information */
+ size_t n, /* I - Media number (0-based) */
+ unsigned flags, /* I - Media flags */
+ cups_media_t *media) /* O - Media information */
+{
+ _cups_media_db_t *nsize; /* Size for N */
+ pwg_media_t *pwg; /* PWG media name for size */
+
+
+ /*
+ * Get the default connection as needed...
+ */
+
+ if (!http)
+ http = _cupsConnect();
+
+ /*
+ * Range check input...
+ */
+
+ if (media)
+ memset(media, 0, sizeof(cups_media_t));
+
+ if (!http || !dest || !dinfo || !media)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ /*
+ * Load media list as needed...
+ */
+
+ if (flags & CUPS_MEDIA_FLAGS_READY)
+ cups_update_ready(http, dinfo);
+
+ if (!dinfo->cached_db || dinfo->cached_flags != flags)
+ cups_create_cached(http, dinfo, flags);
+
+ /*
+ * Copy the size over and return...
+ */
+
+ if ((nsize = (_cups_media_db_t *)cupsArrayIndex(dinfo->cached_db, n)) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ if (nsize->size_name)
+ {
+ cupsCopyString(media->media, nsize->size_name, sizeof(media->media));
+ }
+ else if ((pwg = pwgMediaForSize(nsize->width, nsize->length)) != NULL)
+ {
+ cupsCopyString(media->media, pwg->pwg, sizeof(media->media));
+ }
+ else
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ if (nsize->color)
+ cupsCopyString(media->color, nsize->color, sizeof(media->color));
+
+ if (nsize->source)
+ cupsCopyString(media->source, nsize->source, sizeof(media->source));
+
+ if (nsize->type)
+ cupsCopyString(media->type, nsize->type, sizeof(media->type));
+
+ media->width = nsize->width;
+ media->length = nsize->length;
+ media->bottom = nsize->bottom;
+ media->left = nsize->left;
+ media->right = nsize->right;
+ media->top = nsize->top;
+
+ return (true);
+}
+
+
/*
* 'cupsGetDestMediaByName()' - Get media names, dimensions, and margins.
*
http_t *http, /* I - Connection to destination */
cups_dest_t *dest, /* I - Destination */
cups_dinfo_t *dinfo, /* I - Destination information */
- const char *media, /* I - Media name */
+ const char *name, /* I - Media name */
unsigned flags, /* I - Media matching flags */
cups_size_t *size) /* O - Media size information */
{
if (size)
memset(size, 0, sizeof(cups_size_t));
- if (!http || !dest || !dinfo || !media || !size)
+ if (!http || !dest || !dinfo || !name || !size)
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
return (0);
* Lookup the media size name...
*/
- if ((pwg = pwgMediaForPWG(media)) == NULL)
- if ((pwg = pwgMediaForLegacy(media)) == NULL)
+ if ((pwg = pwgMediaForPWG(name)) == NULL)
+ {
+ if ((pwg = pwgMediaForLegacy(name)) == NULL)
{
- DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", media));
+ DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", name));
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown media size name."), 1);
return (0);
}
+ }
+
+ /*
+ * Lookup the size...
+ */
+
+ return (cups_get_media_db(http, dinfo, pwg, flags, size, NULL));
+}
+
+
+/*
+ * 'cupsGetDestMediaByName2()' - Get media names, dimensions, and margins.
+ *
+ * The "media" string is a PWG media name. "Flags" provides some matching
+ * guidance (multiple flags can be combined):
+ *
+ * CUPS_MEDIA_FLAGS_DEFAULT = find the closest size supported by the printer,
+ * CUPS_MEDIA_FLAGS_BORDERLESS = find a borderless size,
+ * CUPS_MEDIA_FLAGS_DUPLEX = find a size compatible with 2-sided printing,
+ * CUPS_MEDIA_FLAGS_EXACT = find an exact match for the size, and
+ * CUPS_MEDIA_FLAGS_READY = if the printer supports media sensing, find the
+ * size amongst the "ready" media.
+ *
+ * The matching result (if any) is returned in the "cups_size_t" structure.
+ *
+ * Returns `true` when there is a match and `false` if there is not a match.
+ *
+ * @since CUPS 1.6/macOS 10.8@
+ */
+
+bool /* O - `true` on match, `false` on failure */
+cupsGetDestMediaByName2(
+ http_t *http, /* I - Connection to destination */
+ cups_dest_t *dest, /* I - Destination */
+ cups_dinfo_t *dinfo, /* I - Destination information */
+ const char *name, /* I - Media name */
+ unsigned flags, /* I - Media matching flags */
+ cups_media_t *media) /* O - Media information */
+{
+ pwg_media_t *pwg; /* PWG media info */
+
+
+ /*
+ * Get the default connection as needed...
+ */
+
+ if (!http)
+ http = _cupsConnect();
+
+ /*
+ * Range check input...
+ */
+
+ if (media)
+ memset(media, 0, sizeof(cups_media_t));
+
+ if (!http || !dest || !dinfo || !name || !media)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ /*
+ * Lookup the media size name...
+ */
+
+ if ((pwg = pwgMediaForPWG(name)) == NULL)
+ {
+ if ((pwg = pwgMediaForLegacy(name)) == NULL)
+ {
+ DEBUG_printf(("1cupsGetDestMediaByName: Unknown size '%s'.", name));
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unknown media size name."), 1);
+ return (false);
+ }
+ }
/*
* Lookup the size...
*/
- return (cups_get_media_db(http, dinfo, pwg, flags, size));
+ return (cups_get_media_db(http, dinfo, pwg, flags, NULL, media) != 0);
}
* Lookup the size...
*/
- return (cups_get_media_db(http, dinfo, pwg, flags, size));
+ return (cups_get_media_db(http, dinfo, pwg, flags, size, NULL));
+}
+
+
+/*
+ * 'cupsGetDestMediaBySize2()' - Get media names, dimensions, and margins.
+ *
+ * "Width" and "length" are the dimensions in hundredths of millimeters.
+ * "Flags" provides some matching guidance (multiple flags can be combined):
+ *
+ * CUPS_MEDIA_FLAGS_DEFAULT = find the closest size supported by the printer,
+ * CUPS_MEDIA_FLAGS_BORDERLESS = find a borderless size,
+ * CUPS_MEDIA_FLAGS_DUPLEX = find a size compatible with 2-sided printing,
+ * CUPS_MEDIA_FLAGS_EXACT = find an exact match for the size, and
+ * CUPS_MEDIA_FLAGS_READY = if the printer supports media sensing, find the
+ * size amongst the "ready" media.
+ *
+ * The matching result (if any) is returned in the "cups_size_t" structure.
+ *
+ * Returns `true` when there is a match and `false` if there is not a match.
+ *
+ * @since CUPS 2.5@
+ */
+
+bool /* O - `true` on match, `false` on failure */
+cupsGetDestMediaBySize2(
+ http_t *http, /* I - Connection to destination */
+ cups_dest_t *dest, /* I - Destination */
+ cups_dinfo_t *dinfo, /* I - Destination information */
+ int width, /* I - Media width in hundredths of millimeters */
+ int length, /* I - Media length in hundredths of millimeters */
+ unsigned flags, /* I - Media matching flags */
+ cups_media_t *media) /* O - Media information */
+{
+ pwg_media_t *pwg; /* PWG media info */
+
+
+ /*
+ * Get the default connection as needed...
+ */
+
+ if (!http)
+ http = _cupsConnect();
+
+ /*
+ * Range check input...
+ */
+
+ if (media)
+ memset(media, 0, sizeof(cups_media_t));
+
+ if (!http || !dest || !dinfo || width <= 0 || length <= 0 || !media)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (false);
+ }
+
+ /*
+ * Lookup the media size name...
+ */
+
+ if ((pwg = pwgMediaForSize(width, length)) == NULL)
+ {
+ DEBUG_printf(("1cupsGetDestMediaBySize2: Invalid size %dx%d.", width,
+ length));
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Invalid media size."), 1);
+ return (0);
+ }
+
+ /*
+ * Lookup the size...
+ */
+
+ return (cups_get_media_db(http, dinfo, pwg, flags, NULL, media) != 0);
}
}
+/*
+ * 'cupsGetDestMediaDefault2()' - Get the default size for a destination.
+ *
+ * The @code flags@ parameter determines which default size is returned. For
+ * example, passing @code CUPS_MEDIA_FLAGS_BORDERLESS@ will return the default
+ * borderless size, typically US Letter or A4, but sometimes 4x6 photo media.
+ *
+ * @since CUPS 2.5@
+ */
+
+bool /* O - `true` on match, `false` on failure */
+cupsGetDestMediaDefault2(
+ http_t *http, /* I - Connection to destination */
+ cups_dest_t *dest, /* I - Destination */
+ cups_dinfo_t *dinfo, /* I - Destination information */
+ unsigned flags, /* I - Media flags */
+ cups_media_t *media) /* O - Media information */
+{
+ const char *name; /* Default media size */
+
+
+ /*
+ * Get the default connection as needed...
+ */
+
+ if (!http)
+ http = _cupsConnect();
+
+ /*
+ * Range check input...
+ */
+
+ if (media)
+ memset(media, 0, sizeof(cups_media_t));
+
+ if (!http || !dest || !dinfo || !media)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (0);
+ }
+
+ /*
+ * Get the default media size, if any...
+ */
+
+ if ((name = cupsGetOption("media", dest->num_options, dest->options)) == NULL)
+ name = "na_letter_8.5x11in";
+
+ if (cupsGetDestMediaByName2(http, dest, dinfo, name, flags, media))
+ return (true);
+
+ if (strcmp(name, "na_letter_8.5x11in") && cupsGetDestMediaByName2(http, dest, dinfo, "iso_a4_210x297mm", flags, media))
+ return (true);
+
+ if (strcmp(name, "iso_a4_210x297mm") && cupsGetDestMediaByName2(http, dest, dinfo, "na_letter_8.5x11in", flags, media))
+ return (true);
+
+ if ((flags & CUPS_MEDIA_FLAGS_BORDERLESS) && cupsGetDestMediaByName2(http, dest, dinfo, "na_index_4x6in", flags, media))
+ return (true);
+
+ /*
+ * Fall back to the first matching media size...
+ */
+
+ return (cupsGetDestMediaByIndex2(http, dest, dinfo, 0, flags, media));
+}
+
+
/*
* 'cups_add_dconstres()' - Add a constraint or resolver to an array.
*/
const ipp_uchar_t *date = ippGetDate(member, j);
/* Date value */
- year = (date[0] << 8) | date[1];
+ year = (unsigned)(date[0] << 8) | date[1];
if (date[9] == 0 && date[10] == 0)
snprintf(temp, sizeof(temp), "%04u-%02u-%02uT%02u:%02u:%02uZ", year, date[2], date[3], date[4], date[5], date[6]);
cups_dinfo_t *dinfo, /* I - Destination information */
pwg_media_t *pwg, /* I - PWG media info */
unsigned flags, /* I - Media matching flags */
- cups_size_t *size) /* O - Media size/margin/name info */
+ cups_size_t *size, /* O - Media size/margin/name info */
+ cups_media_t *media) /* O - Media information */
{
cups_array_t *db; /* Which media database to query */
_cups_media_db_t *mdb, /* Current media database entry */
* Return the matching size...
*/
- if (best->key)
- strlcpy(size->media, best->key, sizeof(size->media));
- else if (best->size_name)
- strlcpy(size->media, best->size_name, sizeof(size->media));
- else if (pwg->pwg)
- strlcpy(size->media, pwg->pwg, sizeof(size->media));
- else
- strlcpy(size->media, "unknown", sizeof(size->media));
+ if (size)
+ {
+ if (best->key)
+ cupsCopyString(size->media, best->key, sizeof(size->media));
+ else if (best->size_name)
+ cupsCopyString(size->media, best->size_name, sizeof(size->media));
+ else if (pwg->pwg)
+ cupsCopyString(size->media, pwg->pwg, sizeof(size->media));
+ else
+ cupsCopyString(size->media, "unknown", sizeof(size->media));
+
+ size->width = best->width;
+ size->length = best->length;
+ size->bottom = best->bottom;
+ size->left = best->left;
+ size->right = best->right;
+ size->top = best->top;
+ }
+
+ if (media)
+ {
+ if (best->size_name)
+ cupsCopyString(media->media, best->size_name, sizeof(media->media));
+ else if (pwg->pwg)
+ cupsCopyString(media->media, pwg->pwg, sizeof(media->media));
+ else
+ cupsCopyString(media->media, "unknown", sizeof(media->media));
+
+ if (best->color)
+ cupsCopyString(media->color, best->color, sizeof(media->color));
+
+ if (best->source)
+ cupsCopyString(media->source, best->source, sizeof(media->source));
- size->width = best->width;
- size->length = best->length;
- size->bottom = best->bottom;
- size->left = best->left;
- size->right = best->right;
- size->top = best->top;
+ if (best->type)
+ cupsCopyString(media->type, best->type, sizeof(media->type));
+
+ media->width = best->width;
+ media->length = best->length;
+ media->bottom = best->bottom;
+ media->left = best->left;
+ media->right = best->right;
+ media->top = best->top;
+ }
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
dinfo->uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
dinfo->ready_attrs = cupsDoRequest(http, request, dinfo->resource);
request = ippNewRequest(IPP_OP_CUPS_CREATE_LOCAL_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, "ipp://localhost/");
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, device_uri);
ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL, name);
if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL)
state = (ipp_pstate_t)ippGetInteger(attr, 0);
- while (state == IPP_PSTATE_STOPPED && cupsLastError() == IPP_STATUS_OK)
+ while (state == IPP_PSTATE_STOPPED && cupsGetError() == IPP_STATUS_OK)
{
sleep(1);
ippDelete(response);
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "printer-state");
response = cupsDoRequest(http, request, "/");
NULL, pattrs);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
if (name && op != IPP_OP_CUPS_GET_DEFAULT)
{
if (!dest_name)
{
set_as_default = 1;
- dest_name = _cupsUserDefault(defname, sizeof(defname));
+ dest_name = _cupsGetUserDefault(defname, sizeof(defname));
if (dest_name)
{
num_temps = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &temps, 0, 0);
- if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
+ if (cupsGetError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
{
cupsFreeDests(num_temps, temps);
return (-1);
/*
- * '_cupsUserDefault()' - Get the user default printer from environment
+ * '_cupsGetUserDefault()' - Get the user default printer from environment
* variables and location information.
*/
char * /* O - Default printer or NULL */
-_cupsUserDefault(char *name, /* I - Name buffer */
+_cupsGetUserDefault(char *name, /* I - Name buffer */
size_t namesize) /* I - Size of name buffer */
{
const char *env; /* LPDEST or PRINTER env variable */
else
name[0] = '\0';
- DEBUG_printf(("1_cupsUserDefault: Returning \"%s\".", name));
+ DEBUG_printf(("1_cupsGetUserDefault: Returning \"%s\".", name));
return (*name ? name : NULL);
memset(&data, 0, sizeof(data));
- user_default = _cupsUserDefault(data.def_name, sizeof(data.def_name));
+ user_default = _cupsGetUserDefault(data.def_name, sizeof(data.def_name));
snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot);
data.num_dests = cups_get_dests(filename, NULL, NULL, 1, user_default != NULL, data.num_dests, &data.dests);
if (status != HTTP_STATUS_OK)
{
_cupsSetHTTPError(status);
- return (cupsLastError());
+ return (cupsGetError());
}
/*
ippDelete(response);
- return (cupsLastError());
+ return (cupsGetError());
}
*/
if (http->opaque[0])
- snprintf(digest, sizeof(digest), "username=\"%s\", realm=\"%s\", nonce=\"%s\", algorithm=%s, qop=auth, opaque=\"%s\", cnonce=\"%s\", nc=%08x, uri=\"%s\", response=\"%s\"", cupsUser(), http->realm, http->nonce, http->algorithm, http->opaque, cnonce, http->nonce_count, resource, kd);
+ snprintf(digest, sizeof(digest), "username=\"%s\", realm=\"%s\", nonce=\"%s\", algorithm=%s, qop=auth, opaque=\"%s\", cnonce=\"%s\", nc=%08x, uri=\"%s\", response=\"%s\"", cupsGetUser(), http->realm, http->nonce, http->algorithm, http->opaque, cnonce, http->nonce_count, resource, kd);
else
snprintf(digest, sizeof(digest), "username=\"%s\", realm=\"%s\", nonce=\"%s\", algorithm=%s, qop=auth, cnonce=\"%s\", nc=%08x, uri=\"%s\", response=\"%s\"", username, http->realm, http->nonce, http->algorithm, cnonce, http->nonce_count, resource, kd);
}
if (http->default_fields[HTTP_FIELD_USER_AGENT])
httpSetField(http, HTTP_FIELD_USER_AGENT, http->default_fields[HTTP_FIELD_USER_AGENT]);
else
- httpSetField(http, HTTP_FIELD_USER_AGENT, cupsUserAgent());
+ httpSetField(http, HTTP_FIELD_USER_AGENT, cupsGetUserAgent());
}
/*
else if (!strcmp(name, "resource"))
return (v->resource);
else if (!strcmp(name, "user"))
- return (cupsUser());
+ return (cupsGetUser());
else
return (cupsGetOption(name, v->num_vars, v->vars));
}
*
* 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 cupsLastErrorString@ is set to a human-readable message.
+ * failure, @link cupsGetErrorString@ is set to a human-readable message.
*
* @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 cupsLastErrorString@ is
+ * attribute. Like @link ippValidateAttribute@, @link cupsGetErrorString@ is
* set to a human-readable message on failure.
*
* @since CUPS 1.7/macOS 10.9@
close(fd);
- if (cupsLastError() != IPP_STATUS_OK)
+ if (cupsGetError() != IPP_STATUS_OK)
{
unlink(pg->ppd_filename);
return (NULL);
ippDelete(response);
}
- if (cupsLastError() != IPP_STATUS_ERROR_NOT_FOUND)
+ if (cupsGetError() != IPP_STATUS_ERROR_NOT_FOUND)
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No printer-uri found"), 1);
*host = '\0';
}
+/*
+ * 'cupsGetError()' - Return the last IPP status code received on the current thread.
+ *
+ * @since CUPS 2.5@
+ */
+
+ipp_status_t /* O - IPP status code from last request */
+cupsGetError(void)
+{
+ return (_cupsGlobals()->last_error);
+}
+
+
+/*
+ * 'cupsGetErrorString()' - Return the last IPP status-message received on the current thread.
+ *
+ * @since CUPS 2.5@
+ */
+
+const char * /* O - status-message text from last request */
+cupsGetErrorString(void)
+{
+ return (_cupsGlobals()->last_status_message);
+}
+
+
/*
* 'cupsGetResponse()' - Get a response to an IPP request.
*
/*
- * 'cupsLastError()' - Return the last IPP status code received on the current
- * thread.
+ * 'cupsLastError()' - Return the last IPP status code received on the current thread.
+ *
+ * @deprecated@
*/
ipp_status_t /* O - IPP status code from last request */
cupsLastError(void)
{
- return (_cupsGlobals()->last_error);
+ return (cupsGetError());
}
/*
- * 'cupsLastErrorString()' - Return the last IPP status-message received on the
- * current thread.
+ * 'cupsLastErrorString()' - Return the last IPP status-message received on the current thread.
*
- * @since CUPS 1.2/macOS 10.5@
+ * @deprecated@
*/
const char * /* O - status-message text from last request */
cupsLastErrorString(void)
{
- return (_cupsGlobals()->last_status_message);
+ return (cupsGetErrorString());
}
-/*
- * Temp file utilities 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.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Temp file utilities 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.
+//
#include "cups-private.h"
-#include "debug-internal.h"
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>
# include <io.h>
#else
# include <unistd.h>
-#endif /* _WIN32 || __EMX__ */
-
-
-/*
- * 'cupsTempFd()' - Creates a temporary file.
- *
- * The temporary filename is returned in the filename buffer.
- * The temporary file is opened for reading and writing.
- */
-
-int /* O - New file descriptor or -1 on error */
-cupsTempFd(char *filename, /* I - Pointer to buffer */
- int len) /* I - Size of buffer */
+#endif // _WIN32 || __EMX__
+
+
+//
+// 'cupsCreateTempFd()' - Creates a temporary file descriptor.
+//
+// This function creates a temporary file and associated descriptor. The unique
+// temporary filename uses the "prefix" and "suffix" arguments and is returned
+// in the "filename" buffer. The temporary file is opened for reading and
+// writing.
+//
+// @since CUPS 2.5@
+//
+
+int // O - New file descriptor or `-1` on error
+cupsCreateTempFd(const char *prefix, // I - Filename prefix or `NULL` for none
+ const char *suffix, // I - Filename suffix or `NULL` for none
+ char *filename, // I - Pointer to buffer
+ size_t len) // I - Size of buffer
{
- int fd; /* File descriptor for temp file */
- int tries; /* Number of tries */
- const char *tmpdir; /* TMPDIR environment var */
+ int fd; // File descriptor for temp file
+ int tries; // Number of tries
+ const char *tmpdir; // TMPDIR environment var
#if (defined(__APPLE__) && defined(_CS_DARWIN_USER_TEMP_DIR)) || defined(_WIN32)
- char tmppath[1024]; /* Temporary directory */
-#endif /* (__APPLE__ && _CS_DARWIN_USER_TEMP_DIR) || _WIN32 */
+ char tmppath[1024]; // Temporary directory
+#endif // (__APPLE__ && _CS_DARWIN_USER_TEMP_DIR) || _WIN32
#ifdef _WIN32
- DWORD curtime; /* Current time */
+ DWORD curtime; // Current time
#else
- struct timeval curtime; /* Current time */
-#endif /* _WIN32 */
-
+ struct timeval curtime; // Current time
+#endif // _WIN32
- /*
- * See if TMPDIR is defined...
- */
+ // Get the current temporary directory...
#ifdef _WIN32
if ((tmpdir = getenv("TEMP")) == NULL)
{
+ // Use the Windows API to get the system temporary directory...
GetTempPathA(sizeof(tmppath), tmppath);
tmpdir = tmppath;
}
#elif defined(__APPLE__)
- /*
- * On macOS and iOS, the TMPDIR environment variable is not always the best
- * location to place temporary files due to sandboxing. Instead, the confstr
- * function should be called to get the proper per-user, per-process TMPDIR
- * value.
- */
-
+ // On macOS and iOS, the TMPDIR environment variable is not always the best
+ // location to place temporary files due to sandboxing. Instead, the confstr
+ // function should be called to get the proper per-user, per-process TMPDIR
+ // value.
if ((tmpdir = getenv("TMPDIR")) != NULL && access(tmpdir, W_OK))
tmpdir = NULL;
if (confstr(_CS_DARWIN_USER_TEMP_DIR, tmppath, sizeof(tmppath)))
tmpdir = tmppath;
else
-#endif /* _CS_DARWIN_USER_TEMP_DIR */
- tmpdir = "/private/tmp"; /* OS X 10.4 and earlier */
+#endif // _CS_DARWIN_USER_TEMP_DIR
+ tmpdir = "/private/tmp"; // macOS 10.4 and earlier
}
#else
- /*
- * Previously we put root temporary files in the default CUPS temporary
- * directory under /var/spool/cups. However, since the scheduler cleans
- * out temporary files there and runs independently of the user apps, we
- * don't want to use it unless specifically told to by cupsd.
- */
-
+ // Previously we put root temporary files in the default CUPS temporary
+ // directory under /var/spool/cups. However, since the scheduler cleans
+ // out temporary files there and runs independently of the user apps, we
+ // don't want to use it unless specifically told to by cupsd.
if ((tmpdir = getenv("TMPDIR")) == NULL)
tmpdir = "/tmp";
-#endif /* _WIN32 */
-
- /*
- * Make the temporary name using the specified directory...
- */
+#endif // _WIN32
+ // Make the temporary name using the specified directory...
tries = 0;
do
{
#ifdef _WIN32
- /*
- * Get the current time of day...
- */
-
+ // Get the current time of day...
curtime = GetTickCount() + tries;
- /*
- * Format a string using the hex time values...
- */
+ // Format a string using the hex time values...
+ snprintf(filename, (size_t)len - 1, "%s/%s%05lx%08lx%s", tmpdir, prefix ? prefix : "", GetCurrentProcessId(), curtime, suffix ? suffix : "");
- snprintf(filename, (size_t)len - 1, "%s/%05lx%08lx", tmpdir, GetCurrentProcessId(), curtime);
#else
- /*
- * Get the current time of day...
- */
-
+ // Get the current time of day...
gettimeofday(&curtime, NULL);
- /*
- * Format a string using the hex time values...
- */
-
- snprintf(filename, (size_t)len - 1, "%s/%05x%08x", tmpdir, (unsigned)getpid(), (unsigned)(curtime.tv_sec + curtime.tv_usec + tries));
-#endif /* _WIN32 */
-
- /*
- * Open the file in "exclusive" mode, making sure that we don't
- * stomp on an existing file or someone's symlink crack...
- */
+ // Format a string using the hex time values...
+ snprintf(filename, (size_t)len - 1, "%s/%s%05x%08x%s", tmpdir, prefix ? prefix : "", (unsigned)getpid(), (unsigned)(curtime.tv_sec + curtime.tv_usec + tries), suffix ? suffix : "");
+#endif // _WIN32
+ // Open the file in "exclusive" mode, making sure that we don't
+ // stomp on an existing file or someone's symlink crack...
#ifdef _WIN32
- fd = open(filename, _O_CREAT | _O_RDWR | _O_TRUNC | _O_BINARY,
- _S_IREAD | _S_IWRITE);
+ fd = open(filename, _O_CREAT | _O_RDWR | _O_TRUNC | _O_BINARY, _S_IREAD | _S_IWRITE);
#elif defined(O_NOFOLLOW)
fd = open(filename, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600);
#else
fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
-#endif /* _WIN32 */
+#endif // _WIN32
if (fd < 0 && errno != EEXIST)
break;
}
while (fd < 0 && tries < 1000);
- /*
- * Return the file descriptor...
- */
+ // Clear the filename if we didn't create a file...
+ if (fd < 0)
+ *filename = '\0';
+ // Return the file descriptor...
return (fd);
}
-/*
- * 'cupsTempFile()' - Generates a temporary filename.
- *
- * The temporary filename is returned in the filename buffer.
- * This function is deprecated and will no longer generate a temporary
- * filename - use @link cupsTempFd@ or @link cupsTempFile2@ instead.
- *
- * @deprecated@
- */
+//
+// 'cupsCreateTempFile()' - Creates a temporary CUPS file.
+//
+// This function creates a temporary file and returns a CUPS file for it. The
+// unique temporary filename uses the "prefix" and "suffix" arguments and is
+// returned in the "filename" buffer. The temporary file is opened for writing.
+//
+// @since CUPS 2.5@
+//
+
+cups_file_t * // O - CUPS file or `NULL` on error
+cupsCreateTempFile(const char *prefix, // I - Filename prefix or `NULL` for none
+ const char *suffix, // I - Filename suffix or `NULL` for none
+ char *filename,// I - Pointer to buffer
+ size_t len) // I - Size of buffer
+{
+ cups_file_t *file; // CUPS file
+ int fd; // File descriptor
+
-char * /* O - Filename or @code NULL@ on error */
-cupsTempFile(char *filename, /* I - Pointer to buffer */
- int len) /* I - Size of buffer */
+ if ((fd = cupsCreateTempFd(prefix, suffix, filename, len)) < 0)
+ {
+ return (NULL);
+ }
+ else if ((file = cupsFileOpenFd(fd, "w")) == NULL)
+ {
+ close(fd);
+ unlink(filename);
+ return (NULL);
+ }
+ else
+ {
+ return (file);
+ }
+}
+
+
+//
+// 'cupsTempFd()' - Create a temporary file descriptor.
+//
+// This function creates a temporary file descriptor and places the filename in
+// the "filename" buffer. The temporary file descriptor is opened for reading
+// and writing.
+//
+// > Note: This function is deprecated. Use the @link cupsCreateTempFd@
+// > function instead.
+//
+// @deprecated@
+//
+
+int /* O - New file descriptor or -1 on error */
+cupsTempFd(char *filename, /* I - Pointer to buffer */
+ int len) /* I - Size of buffer */
+{
+ return (cupsCreateTempFd(NULL, NULL, filename, (size_t)len));
+}
+
+
+//
+// 'cupsTempFile()' - Generate a temporary filename (deprecated).
+//
+// This function is deprecated and no longer generates a temporary filename.
+// Use @link cupsCreateTempFd@ or @link cupsCreateTempFile2@ instead.
+//
+// @deprecated@
+//
+
+char * // O - `NULL` (error)
+cupsTempFile(char *filename, // I - Pointer to buffer */
+ int len) // I - Size of buffer
{
(void)len;
}
-/*
- * 'cupsTempFile2()' - Creates a temporary CUPS file.
- *
- * The temporary filename is returned in the filename buffer.
- * The temporary file is opened for writing.
- *
- * @since CUPS 1.2/macOS 10.5@
- */
+//
+// 'cupsTempFile2()' - Creates a temporary CUPS file.
+//
+// This function creates a temporary CUPS file and places the filename in the
+// "filename" buffer. The temporary file is opened for writing.
+//
+// > Note: This function is deprecated. Use the @link cupsCreateTempFile@
+// > function instead.
+//
+// @deprecated@
+//
cups_file_t * /* O - CUPS file or @code NULL@ on error */
cupsTempFile2(char *filename, /* I - Pointer to buffer */
int len) /* I - Size of buffer */
{
- cups_file_t *file; /* CUPS file */
- int fd; /* File descriptor */
-
-
- if ((fd = cupsTempFd(filename, len)) < 0)
- return (NULL);
- else if ((file = cupsFileOpenFd(fd, "w")) == NULL)
- {
- close(fd);
- unlink(filename);
- return (NULL);
- }
- else
- return (file);
+ return (cupsCreateTempFile(NULL, NULL, filename, (size_t)len));
}
}
else
{
- printf("Server settings not changed: %s\n", cupsLastErrorString());
+ printf("Server settings not changed: %s\n", cupsGetErrorString());
return (1);
}
}
}
else
{
- printf(" %s\n", cupsLastErrorString());
+ printf(" %s\n", cupsGetErrorString());
return (1);
}
}
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
response = cupsDoRequest(http, request, data->resource);
request = ippNewRequest(IPP_OP_GET_JOB_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", data->job_id);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(jattrs) / sizeof(jattrs[0])), NULL, jattrs);
response = cupsDoRequest(http, request, data->resource);
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, ldata.uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
response = cupsDoRequest(http, request, ldata.resource);
{
request = ippNewRequest(IPP_OP_CREATE_JOB);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, ldata.uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
if ((name = strrchr(ldata.docfile, '/')) != NULL)
name ++;
if (verbosity)
show_attributes("Create-Job response", 0, response);
- if (cupsLastError() == IPP_STATUS_ERROR_BUSY)
+ if (cupsGetError() == IPP_STATUS_ERROR_BUSY)
{
puts("Printer is busy - retrying in 5 seconds...");
sleep(5);
ippDelete(response);
response = NULL;
}
- else if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
+ else if (cupsGetError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
{
- printf("Unable to create print job: %s\n", cupsLastErrorString());
+ printf("Unable to create print job: %s\n", cupsGetErrorString());
ldata.job_state = IPP_JSTATE_ABORTED;
ippDelete(response);
response = NULL;
}
}
- while (cupsLastError() == IPP_STATUS_ERROR_BUSY);
+ while (cupsGetError() == IPP_STATUS_ERROR_BUSY);
- if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
+ if (cupsGetError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
goto cleanup;
if ((attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) == NULL)
request = ippNewRequest(IPP_OP_SEND_DOCUMENT);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, ldata.uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", ldata.job_id);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, ldata.docformat);
ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", 1);
if (verbosity)
show_attributes("Send-Document response", 0, response);
- if (cupsLastError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
+ if (cupsGetError() >= IPP_STATUS_REDIRECTION_OTHER_SITE)
{
- printf("Unable to print file: %s\n", cupsLastErrorString());
+ printf("Unable to print file: %s\n", cupsGetErrorString());
ldata.job_state = IPP_JSTATE_ABORTED;
if ((http = httpConnect2(hostname, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_ALWAYS, 1, 30000, NULL)) == NULL)
{
- printf("ERROR: Unable to connect to \"%s\" on port %d: %s\n", hostname, port, cupsLastErrorString());
+ printf("ERROR: Unable to connect to \"%s\" on port %d: %s\n", hostname, port, cupsGetErrorString());
return (1);
}
if (trust == HTTP_TRUST_OK)
puts(" Trust: OK");
else
- printf(" Trust: %s (%s)\n", trusts[trust], cupsLastErrorString());
+ printf(" Trust: %s (%s)\n", trusts[trust], cupsGetErrorString());
printf(" Expiration: %s\n", httpGetDateString(httpCredentialsGetExpiration(hcreds)));
printf(" IsValidName: %d\n", httpCredentialsAreValidForName(hcreds, hostname));
printf(" String: \"%s\"\n", hinfo);
if ((http_status = cupsGetPPD3(CUPS_HTTP_DEFAULT, argv[2], &modtime,
buffer, sizeof(buffer))) != HTTP_STATUS_OK)
printf("Unable to get PPD: %d (%s)\n", (int)http_status,
- cupsLastErrorString());
+ cupsGetErrorString());
else
puts(buffer);
}
NULL)) <= 0)
{
printf("Unable to create print job on %s: %s\n", argv[1],
- cupsLastErrorString());
+ cupsGetErrorString());
return (1);
}
if (cupsPrintFile(dest->name, "../test/testfile.pdf", "Test Page",
dest->num_options, dest->options) <= 0)
{
- printf("FAIL (%s)\n", cupsLastErrorString());
+ printf("FAIL (%s)\n", cupsGetErrorString());
return (1);
}
else
if (!dest)
{
- printf("testdest: Unable to get destination \"%s\": %s\n", argv[i], cupsLastErrorString());
+ printf("testdest: Unable to get destination \"%s\": %s\n", argv[i], cupsGetErrorString());
return (1);
}
if ((http = cupsConnectDest(dest, dflags, 30000, NULL, NULL, 0, NULL, NULL)) == NULL)
{
- printf("testdest: Unable to connect to destination \"%s\": %s\n", dest->name, cupsLastErrorString());
+ printf("testdest: Unable to connect to destination \"%s\": %s\n", dest->name, cupsGetErrorString());
return (1);
}
if ((dinfo = cupsCopyDestInfo(http, dest)) == NULL)
{
- printf("testdest: Unable to get information for destination \"%s\": %s\n", dest->name, cupsLastErrorString());
+ printf("testdest: Unable to get information for destination \"%s\": %s\n", dest->name, cupsGetErrorString());
return (1);
}
if (cupsCreateDestJob(http, dest, dinfo, &job_id, title, num_options, options) > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
{
- printf("Unable to create job: %s\n", cupsLastErrorString());
+ printf("Unable to create job: %s\n", cupsGetErrorString());
cupsFileClose(fp);
return;
}
if (cupsStartDestDocument(http, dest, dinfo, job_id, title, CUPS_FORMAT_AUTO, 0, NULL, 1) != HTTP_STATUS_CONTINUE)
{
- printf("Unable to send document: %s\n", cupsLastErrorString());
+ printf("Unable to send document: %s\n", cupsGetErrorString());
cupsFileClose(fp);
return;
}
{
if (cupsWriteRequestData(http, buffer, (size_t)bytes) != HTTP_STATUS_CONTINUE)
{
- printf("Unable to write document data: %s\n", cupsLastErrorString());
+ printf("Unable to write document data: %s\n", cupsGetErrorString());
break;
}
}
if (cupsFinishDestDocument(http, dest, dinfo) > IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED)
{
- printf("Unable to send document: %s\n", cupsLastErrorString());
+ printf("Unable to send document: %s\n", cupsGetErrorString());
return;
}
if (state != IPP_STATE_DATA)
{
- printf("Error reading IPP message from \"%s\": %s\n", argv[i], cupsLastErrorString());
+ printf("Error reading IPP message from \"%s\": %s\n", argv[i], cupsGetErrorString());
status = 1;
ippDelete(request);
if (state != IPP_STATE_DATA)
{
- printf("Error reading IPP message from \"%s\": %s\n", argv[i], cupsLastErrorString());
+ printf("Error reading IPP message from \"%s\": %s\n", argv[i], cupsGetErrorString());
status = 1;
ippDelete(request);
http = httpConnect2(host, port, NULL, AF_UNSPEC, !strcmp(scheme, "ipps") ? HTTP_ENCRYPTION_ALWAYS : HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL);
if (!http)
{
- printf("Unable to connect to \"%s:%d\": %s\n", host, port, cupsLastErrorString());
+ printf("Unable to connect to \"%s:%d\": %s\n", host, port, cupsGetErrorString());
return (1);
}
if ((filename = cupsGetServerPPD(CUPS_HTTP_DEFAULT, argv[1])) == NULL)
{
- printf("%s: %s\n", argv[1], cupsLastErrorString());
+ printf("%s: %s\n", argv[1], cupsGetErrorString());
return (1);
}
}
if (!filename)
{
- printf("%s: %s\n", printer, cupsLastErrorString());
+ printf("%s: %s\n", printer, cupsGetErrorString());
return (1);
}
}
puts("\nPPD Cache:");
if ((pc = _ppdCacheCreateWithPPD(ppd)) == NULL)
- printf(" Unable to create: %s\n", cupsLastErrorString());
+ printf(" Unable to create: %s\n", cupsGetErrorString());
else
{
_ppdCacheWriteFile(pc, "t.cache", NULL);
// Local functions...
//
-static bool enum_dests_cb(void *_name, unsigned flags, cups_dest_t *dest);
+static int enum_dests_cb(void *_name, unsigned flags, cups_dest_t *dest);
static void *run_query(cups_dest_t *dest);
static void show_supported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option, const char *value);
// 'enum_dests_cb()' - Destination enumeration function...
//
-static bool // O - `true` to continue, `false` to stop
+static int // O - 1 to continue, 0 to stop
enum_dests_cb(void *_name, // I - Printer name, if any
unsigned flags, // I - Enumeration flags
cups_dest_t *dest) // I - Found destination
// If a name was specified, compare it...
if (name && strcasecmp(name, dest->name))
- return (true); // Continue
+ return (1); // Continue
// Copy the destination and run the query on a separate thread...
cupsCopyDest(dest, 0, &cdest);
for (i = 0; i < count; i ++)
{
size_t j; // Looping var
- size_t len; // Length of value
+ int len; // Length of value
unsigned char *data = ippGetOctetString(attr, i, &len);
// Pointer to octet string
if (!http)
{
- printf("%s: ERROR (%s)\n", server, cupsLastErrorString());
+ printf("%s: ERROR (%s)\n", server, cupsGetErrorString());
return (1);
}
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipps", NULL, server, port, resource);
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
response = cupsDoRequest(http, request, resource);
/*
* 'cupsEncryption()' - Get the current encryption settings.
*
+ * @deprecated@
+ */
+
+http_encryption_t /* O - Encryption settings */
+cupsEncryption(void)
+{
+ return (cupsGetEncryption());
+}
+
+
+/*
+ * 'cupsGetEncryption()' - Get the current encryption settings.
+ *
* The default encryption setting comes from the CUPS_ENCRYPTION
* environment variable, then the ~/.cups/client.conf file, and finally the
* /etc/cups/client.conf file. If not set, the default is
* in a program. Multi-threaded programs that override the setting via the
* @link cupsSetEncryption@ function need to do so in each thread for the same
* setting to be used.
+ *
+ * @since CUPS 2.5@
*/
http_encryption_t /* O - Encryption settings */
-cupsEncryption(void)
+cupsGetEncryption(void)
{
_cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
/*
- * 'cupsServer()' - Return the hostname/address of the current server.
+ * 'cupsGetServer()' - Return the hostname/address of the current server.
*
* The default server comes from the CUPS_SERVER environment variable, then the
* ~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not
* Multi-threaded programs that override the server via the
* @link cupsSetServer@ function need to do so in each thread for the same
* server to be used.
+ *
+ * @since CUPS 2.5@
*/
const char * /* O - Server name */
-cupsServer(void)
+cupsGetServer(void)
{
_cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
}
+/*
+ * 'cupsGetUser()' - Return the current user's name.
+ *
+ * Note: The current user name is tracked separately for each thread in a
+ * program. Multi-threaded programs that override the user name with the
+ * @link cupsSetUser@ function need to do so in each thread for the same user
+ * name to be used.
+ *
+ * @since CUPS 2.5@
+ */
+
+const char * /* O - User name */
+cupsGetUser(void)
+{
+ _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
+
+
+ if (!cg->user[0])
+ _cupsSetDefaults();
+
+ return (cg->user);
+}
+
+
+/*
+ * 'cupsGetUserAgent()' - Return the default HTTP User-Agent string.
+ *
+ * @since CUPS 2.5@
+ */
+
+const char * /* O - User-Agent string */
+cupsGetUserAgent(void)
+{
+ _cups_globals_t *cg = _cupsGlobals(); /* Thread globals */
+
+
+ if (!cg->user_agent[0])
+ cupsSetUserAgent(NULL);
+
+ return (cg->user_agent);
+}
+
+
+/*
+ * 'cupsServer()' - Return the hostname/address of the current server.
+ *
+ * The default server comes from the CUPS_SERVER environment variable, then the
+ * ~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not
+ * set, the default is the local system - either "localhost" or a domain socket
+ * path.
+ *
+ * The returned value can be a fully-qualified hostname, a numeric IPv4 or IPv6
+ * address, or a domain socket pathname.
+ *
+ * Note: The current server is tracked separately for each thread in a program.
+ * Multi-threaded programs that override the server via the
+ * @link cupsSetServer@ function need to do so in each thread for the same
+ * server to be used.
+ *
+ * @deprecated@
+ */
+
+const char * /* O - Server name */
+cupsServer(void)
+{
+ return (cupsGetServer());
+}
+
+
/*
* 'cupsSetClientCertCB()' - Set the client certificate callback.
*
* in a program. Multi-threaded programs that override the callback need to do
* so in each thread for the same callback to be used.
*
- * @since CUPS 1.5/macOS 10.7@
+ * @deprecated@
*/
void
cups_client_cert_cb_t cb, /* I - Callback function */
void *user_data) /* I - User data pointer */
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
-
-
- cg->client_cert_cb = cb;
- cg->client_cert_data = user_data;
+ (void)cb;
+ (void)user_data;
}
* 'cupsSetCredentials()' - Set the default credentials to be used for SSL/TLS
* connections.
*
- * Note: The default credentials are tracked separately for each thread in a
- * program. Multi-threaded programs that override the setting need to do so in
- * each thread for the same setting to be used.
- *
- * @since CUPS 1.5/macOS 10.7@
+ * @deprecated@
*/
int /* O - Status of call (0 = success) */
cupsSetCredentials(
cups_array_t *credentials) /* I - Array of credentials */
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
-
+ (void)credentials;
- if (cupsArrayCount(credentials) < 1)
- return (-1);
-
- _httpFreeCredentials(cg->tls_credentials);
- cg->tls_credentials = _httpCreateCredentials(credentials);
-
- return (cg->tls_credentials ? 0 : -1);
+ return (-1);
}
* in a program. Multi-threaded programs that override the callback need to do
* so in each thread for the same callback to be used.
*
- * @since CUPS 1.5/macOS 10.7@
+ * @deprecated@
*/
void
cups_server_cert_cb_t cb, /* I - Callback function */
void *user_data) /* I - User data pointer */
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
-
-
- cg->server_cert_cb = cb;
- cg->server_cert_data = user_data;
+ (void)cb;
+ (void)user_data;
}
* program. Multi-threaded programs that override the user name with the
* @link cupsSetUser@ function need to do so in each thread for the same user
* name to be used.
+ *
+ * @deprecated@
*/
const char * /* O - User name */
cupsUser(void)
{
- _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */
-
-
- if (!cg->user[0])
- _cupsSetDefaults();
-
- return (cg->user);
+ return (cupsGetUser());
}
/*
* 'cupsUserAgent()' - Return the default HTTP User-Agent string.
*
- * @since CUPS 1.7/macOS 10.9@
+ * @deprecated@
*/
const char * /* O - User-Agent string */
cupsUserAgent(void)
{
- _cups_globals_t *cg = _cupsGlobals(); /* Thread globals */
-
-
- if (!cg->user_agent[0])
- cupsSetUserAgent(NULL);
-
- return (cg->user_agent);
+ return (cupsGetUserAgent());
}
* Pass @code CUPS_JOBID_ALL@ to cancel all jobs or @code CUPS_JOBID_CURRENT@
* to cancel the current job on the named destination.
*
- * Use the @link cupsLastError@ and @link cupsLastErrorString@ functions to get
+ * Use the @link cupsGetError@ and @link cupsGetErrorString@ functions to get
* the cause of any failure.
*
* @exclude all@
* Pass @code CUPS_JOBID_ALL@ to cancel all jobs or @code CUPS_JOBID_CURRENT@
* to cancel the current job on the named destination.
*
- * Use the @link cupsLastError@ and @link cupsLastErrorString@ functions to get
+ * Use the @link cupsGetError@ and @link cupsGetErrorString@ functions to get
* the cause of any failure.
*
* @since CUPS 1.4/macOS 10.6@ @exclude all@
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
if (purge && job_id >= 0)
ippAddBoolean(request, IPP_TAG_OPERATION, "purge-job", 1);
ippDelete(cupsDoRequest(http, request, "/jobs/"));
- return (cupsLastError());
+ return (cupsGetError());
}
ippDelete(cupsGetResponse(http, resource));
- return (cupsLastError());
+ return (cupsGetError());
}
* See if we have a user default printer set...
*/
- if (_cupsUserDefault(cg->def_printer, sizeof(cg->def_printer)))
+ if (_cupsGetUserDefault(cg->def_printer, sizeof(cg->def_printer)))
return (cg->def_printer);
/*
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
if (myjobs)
ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1);
NULL, printer_uri);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", job_id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
if (docname)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name",
NULL, docname);
if (!<a href="#cupsAdminGetServerSettings">cupsAdminGetServerSettings</a>(CUPS_HTTP_DEFAULT, &num_settings, &settings))
{
- fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsLastErrorString());
+ fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsGetErrorString());
return;
}
if (!<a href="#cupsAdminSetServerSettings">cupsAdminSetServerSettings</a>(CUPS_HTTP_DEFAULT, num_settings, settings))
{
- fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsLastErrorString());
+ fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsGetErrorString());
}
<a href="api-cups.html#cupsFreeOptions">cupsFreeOptions</a>(num_settings, settings);
<li><a href="#cupsSetUser">cupsSetUser</a></li>
<li><a href="#cupsSetUserAgent">cupsSetUserAgent</a></li>
<li><a href="#cupsStartDestDocument">cupsStartDestDocument</a></li>
-<li><a href="#cupsUser">cupsUser</a></li>
-<li><a href="#cupsUserAgent">cupsUserAgent</a></li>
+<li><a href="#cupsGetUser">cupsGetUser</a></li>
+<li><a href="#cupsGetUserAgent">cupsGetUserAgent</a></li>
<li><a href="#httpAcceptConnection">httpAcceptConnection</a></li>
<li><a href="#httpAddCredential">httpAddCredential</a></li>
<li><a href="#httpAddrAny">httpAddrAny</a></li>
</li>
<li><p><code>CUPS_DEST_FLAGS_REMOVED</code>: The destination has gone away and should be removed from the list of destinations a user can select.</p>
</li>
-<li><p><code>CUPS_DEST_FLAGS_ERROR</code>: An error occurred. The reason for the error can be found by calling the <code>cupsLastError</code> and/or <code>cupsLastErrorString</code> functions.</p>
+<li><p><code>CUPS_DEST_FLAGS_ERROR</code>: An error occurred. The reason for the error can be found by calling the <code>cupsGetError</code> and/or <code>cupsGetErrorString</code> functions.</p>
</li>
</ul>
<p>The callback function returns 0 to stop enumeration or 1 to continue.</p>
printf("Created job: %d\n", job_id);
else
printf("Unable to create job: %s\n",
- cupsLastErrorString());
+ cupsGetErrorString());
</code></pre>
<p>Once the job is created, you submit documents for the job using the <code>cupsStartDestDocument</code>, <code>cupsWriteRequestData</code>, and <code>cupsFinishDestDocument</code> functions:</p>
<pre><code>http_status_t
puts("Document send succeeded.");
else
printf("Document send failed: %s\n",
- cupsLastErrorString());
+ cupsGetErrorString());
}
fclose(fp);
filename);
</code></pre>
<p>Both <code>cupsDoRequest</code> and <code>cupsDoFileRequest</code> free the IPP request. If a valid IPP response is received, it is stored in a new IPP message (<code>ipp_t</code>) and returned to the caller. Otherwise <code>NULL</code> is returned.</p>
-<p>The status from the most recent request can be queried using the <code>cupsLastError</code> function, for example:</p>
-<pre><code>if (cupsLastError() >= IPP_STATUS_ERROR_BAD_REQUEST)
+<p>The status from the most recent request can be queried using the <code>cupsGetError</code> function, for example:</p>
+<pre><code>if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
{
/* request failed */
}
</code></pre>
-<p>A human-readable error message is also available using the <code>cupsLastErrorString</code> function:</p>
-<pre><code>if (cupsLastError() >= IPP_STATUS_ERROR_BAD_REQUEST)
+<p>A human-readable error message is also available using the <code>cupsGetErrorString</code> function:</p>
+<pre><code>if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
{
/* request failed */
- printf("Request failed: %s\n", cupsLastErrorString());
+ printf("Request failed: %s\n", cupsGetErrorString());
}
</code></pre>
<h3 class="title" id="processing-the-ipp-response">Processing the IPP Response</h3>
<code>HTTP_CONTINUE</code> on success.
</p>
-<h3 class="function"><a id="cupsUser">cupsUser</a></h3>
+<h3 class="function"><a id="cupsGetUser">cupsGetUser</a></h3>
<p class="description">Return the current user's name.</p>
<p class="code">
-const char *cupsUser(void);</p>
+const char *cupsGetUser(void);</p>
<h4 class="returnvalue">Return Value</h4>
<p class="description">User name</p>
<h4 class="discussion">Discussion</h4>
program. Multi-threaded programs that override the user name with the
<a href="#cupsSetUser"><code>cupsSetUser</code></a> function need to do so in each thread for the same user
name to be used.</p>
-<h3 class="function"><span class="info"> CUPS 1.7/macOS 10.9 </span><a id="cupsUserAgent">cupsUserAgent</a></h3>
+<h3 class="function"><span class="info"> CUPS 1.7/macOS 10.9 </span><a id="cupsGetUserAgent">cupsGetUserAgent</a></h3>
<p class="description">Return the default HTTP User-Agent string.</p>
<p class="code">
-const char *cupsUserAgent(void);</p>
+const char *cupsGetUserAgent(void);</p>
<h4 class="returnvalue">Return Value</h4>
<p class="description">User-Agent string</p>
<h3 class="function"><span class="info"> CUPS 1.7/macOS 10.9 </span><a id="httpAcceptConnection">httpAcceptConnection</a></h3>
<h4 class="discussion">Discussion</h4>
<p class="discussion">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, <a href="#cupsLastErrorString"><code>cupsLastErrorString</code></a> is set to a human-readable message.
+failure, <a href="#cupsGetErrorString"><code>cupsGetErrorString</code></a> is set to a human-readable message.
</p>
<h3 class="function"><span class="info"> CUPS 1.7/macOS 10.9 </span><a id="ippValidateAttributes">ippValidateAttributes</a></h3>
<p class="description">1 if valid, 0 otherwise</p>
<h4 class="discussion">Discussion</h4>
<p class="discussion">This function validates the contents of the IPP message, including each
-attribute. Like <a href="#ippValidateAttribute"><code>ippValidateAttribute</code></a>, <a href="#cupsLastErrorString"><code>cupsLastErrorString</code></a> is
+attribute. Like <a href="#ippValidateAttribute"><code>ippValidateAttribute</code></a>, <a href="#cupsGetErrorString"><code>cupsGetErrorString</code></a> is
set to a human-readable message on failure.
</p>
else
cupsdLogClient(con, CUPSD_LOG_DEBUG,
"HTTP_STATE_WAITING Closing on error: %s",
- cupsLastErrorString());
+ cupsGetErrorString());
cupsdCloseClient(con);
return;
if ((ipp_state = ippRead(con->http, con->request)) == IPP_STATE_ERROR)
{
cupsdLogClient(con, CUPSD_LOG_ERROR, "IPP read error: %s",
- cupsLastErrorString());
+ cupsGetErrorString());
cupsdSendError(con, HTTP_STATUS_BAD_REQUEST, CUPSD_AUTH_NONE);
cupsdCloseClient(con);
if (httpEncryption(con->http, e))
{
cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to encrypt connection: %s",
- cupsLastErrorString());
+ cupsGetErrorString());
return (-1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name",
NULL, title);
- cupsEncodeOptions(request, num_options, options);
+ cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
+ cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);
+ cupsEncodeOptions2(request, num_options, options, IPP_TAG_SUBSCRIPTION);
/*
* Do the request...
response = cupsDoRequest(http, request, uri);
- if (!response || cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (!response || cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- syslog(LOG_ERR, "Unable to create job - %s", cupsLastErrorString());
+ syslog(LOG_ERR, "Unable to create job - %s", cupsGetErrorString());
ippDelete(response);
response = cupsDoRequest(http, request, "/");
- if (!response || cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (!response || cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
/*
* If we can't find the printer by name, look up the printer-name
response = cupsDoRequest(http, request, "/");
- if (!response || cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (!response || cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
syslog(LOG_ERR, "Unable to get list of printers - %s",
- cupsLastErrorString());
+ cupsGetErrorString());
ippDelete(response);
ippDelete(cupsDoFileRequest(http, request, uri, filename));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- syslog(LOG_ERR, "Unable to send document - %s", cupsLastErrorString());
+ syslog(LOG_ERR, "Unable to send document - %s", cupsGetErrorString());
return (-1);
}
* Connect to the server...
*/
- http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL);
+ http = httpConnect2(cupsGetServer(), ippPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL);
if (!http)
{
syslog(LOG_ERR, "Unable to connect to server: %s", strerror(errno));
}
else
{
- if ((fd = cupsTempFd(control, sizeof(control))) < 0)
+ if ((fd = cupsCreateTempFd(NULL, NULL, control, sizeof(control))) < 0)
{
syslog(LOG_ERR, "Unable to open temporary control file \"%s\" - %s",
control, strerror(errno));
strlcpy(data[num_data], name, sizeof(data[0]));
- if ((fd = cupsTempFd(temp[num_data], sizeof(temp[0]))) < 0)
+ if ((fd = cupsCreateTempFd(NULL, NULL, temp[num_data], sizeof(temp[0]))) < 0)
{
syslog(LOG_ERR, "Unable to open temporary data file \"%s\" - %s",
temp[num_data], strerror(errno));
* Try connecting to the local server...
*/
- if ((http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL)) == NULL)
+ if ((http = httpConnect2(cupsGetServer(), ippPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
{
- syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsServer(),
+ syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsGetServer(),
strerror(errno));
return (1);
}
ippDelete(cupsDoRequest(http, request, "/jobs"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
syslog(LOG_WARNING, "Cancel of job ID %d failed: %s\n", id,
- cupsLastErrorString());
+ cupsGetErrorString());
httpClose(http);
return (1);
}
* Try connecting to the local server...
*/
- if ((http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 1, 30000, NULL)) == NULL)
+ if ((http = httpConnect2(cupsGetServer(), ippPort(), NULL, AF_UNSPEC, cupsGetEncryption(), 1, 30000, NULL)) == NULL)
{
- syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsServer(),
+ syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsGetServer(),
strerror(errno));
- printf("Unable to connect to server %s: %s", cupsServer(), strerror(errno));
+ printf("Unable to connect to server %s: %s", cupsGetServer(), strerror(errno));
return (1);
}
if (get_printer(http, queue, dest, sizeof(dest), NULL, NULL, NULL, &state))
{
syslog(LOG_ERR, "Unable to get printer %s: %s", queue,
- cupsLastErrorString());
- printf("Unable to get printer %s: %s", queue, cupsLastErrorString());
+ cupsGetErrorString());
+ printf("Unable to get printer %s: %s", queue, cupsGetErrorString());
return (1);
}
jobcount = 0;
response = cupsDoRequest(http, request, "/");
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- printf("get-jobs failed: %s\n", cupsLastErrorString());
+ printf("get-jobs failed: %s\n", cupsGetErrorString());
ippDelete(response);
return (1);
}
options = NULL;
ppdfile = NULL;
title = NULL;
- user = cupsUser();
+ user = cupsGetUser();
all_filters = 0;
removeppd = 0;
removeinfile = 0;
httpClose(http);
- if (cupsLastError() != IPP_OK)
+ if (cupsGetError() != IPP_OK)
{
_cupsLangPrintf(stderr, _("cupsfilter: Unable to get job file - %s"),
- cupsLastErrorString());
+ cupsGetErrorString());
unlink(TempFile);
exit(1);
}
else if (!ippValidateAttribute(attr))
{
send_ipp_status(con, IPP_ATTRIBUTES, _("Bad job-name value: %s"),
- cupsLastErrorString());
+ cupsGetErrorString());
if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
if ((http = httpConnect2(host, port, NULL, AF_UNSPEC, encryption, 1, 30000, NULL)) == NULL)
{
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Unable to connect to %s:%d: %s", printer->name, host, port, cupsLastErrorString());
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Unable to connect to %s:%d: %s", printer->name, host, port, cupsGetErrorString());
return (NULL);
}
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
response = cupsDoRequest(http, request, resource);
- status = cupsLastError();
+ status = cupsGetError();
- cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsLastError()), cupsLastErrorString());
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsGetError()), cupsGetErrorString());
if (status == IPP_STATUS_ERROR_BAD_REQUEST || status == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
response = cupsDoRequest(http, request, resource);
- cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: IPP/1.1 Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsLastError()), cupsLastErrorString());
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "%s: IPP/1.1 Get-Printer-Attributes returned %s (%s)", printer->name, ippErrorString(cupsGetError()), cupsGetErrorString());
}
/*
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", NULL, "media-col-database");
response2 = cupsDoRequest(http, request, resource);
- //ipp_status = cupsLastError();
+ //ipp_status = cupsGetError();
if (response2)
{
if ((attr = ippFindAttribute(response2, "media-col-database",
}
}
else
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed: %s", printer->name, cupsLastErrorString());
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed: %s", printer->name, cupsGetErrorString());
ippDelete(response);
p->pc = _ppdCacheCreateWithPPD(ppd);
if (!p->pc)
- cupsdLogMessage(CUPSD_LOG_WARN, "Unable to create cache of \"%s\": %s", ppd_name, cupsLastErrorString());
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unable to create cache of \"%s\": %s", ppd_name, cupsGetErrorString());
ppdMarkDefaults(ppd);
"ldfA%03dlocalhost\n"
"UdfA%03dlocalhost\n"
"N%s\n",
- cupsUser(), jobname, sequence, sequence, jobname);
+ cupsGetUser(), jobname, sequence, sequence, jobname);
/*
* Send the control file...
0.000001 * (end.tv_usec - start.tv_usec);
elapsed += reqtime;
- switch (cupsLastError())
+ switch (cupsGetError())
{
case IPP_OK :
case IPP_NOT_FOUND :
if (verbose)
{
- printf("succeeded: %s (%.6f)\n", cupsLastErrorString(), reqtime);
+ printf("succeeded: %s (%.6f)\n", cupsGetErrorString(), reqtime);
fflush(stdout);
}
break;
printf("testspeed(%d): %s ", (int)getpid(),
ippOpString(ops[i & 3]));
- printf("failed: %s\n", cupsLastErrorString());
+ printf("failed: %s\n", cupsGetErrorString());
httpClose(http);
return (1);
}
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD, "notify-events",
num_events, NULL, events);
"notify-pull-method", NULL, "ippget");
response = cupsDoRequest(http, request, uri);
- if (cupsLastError() >= IPP_BAD_REQUEST)
+ if (cupsGetError() >= IPP_BAD_REQUEST)
{
fprintf(stderr, "Create-%s-Subscription: %s\n",
- strstr(uri, "/jobs") ? "Job" : "Printer", cupsLastErrorString());
+ strstr(uri, "/jobs") ? "Job" : "Printer", cupsGetErrorString());
ippDelete(response);
httpClose(http);
return (1);
uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
"notify-subscription-ids", subscription_id);
response = cupsDoRequest(http, request, uri);
- printf(" %s\n", ippErrorString(cupsLastError()));
+ printf(" %s\n", ippErrorString(cupsGetError()));
- if (cupsLastError() >= IPP_BAD_REQUEST)
- fprintf(stderr, "Get-Notifications: %s\n", cupsLastErrorString());
+ if (cupsGetError() >= IPP_BAD_REQUEST)
+ fprintf(stderr, "Get-Notifications: %s\n", cupsGetErrorString());
else if (response)
{
print_attributes(response, 0);
uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
"notify-subscription-id", subscription_id);
ippDelete(cupsDoRequest(http, request, uri));
- printf(" %s\n", ippErrorString(cupsLastError()));
+ printf(" %s\n", ippErrorString(cupsGetError()));
- if (cupsLastError() >= IPP_BAD_REQUEST)
- fprintf(stderr, "Cancel-Subscription: %s\n", cupsLastErrorString());
+ if (cupsGetError() >= IPP_BAD_REQUEST)
+ fprintf(stderr, "Cancel-Subscription: %s\n", cupsGetErrorString());
/*
* Close the connection and return...
}
else
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
if (purge)
{
* Do the request and get back a response...
*/
- if (op == IPP_CANCEL_JOBS && (!user || _cups_strcasecmp(user, cupsUser())))
+ if (op == IPP_CANCEL_JOBS && (!user || _cups_strcasecmp(user, cupsGetUser())))
response = cupsDoRequest(http, request, "/admin/");
else
response = cupsDoRequest(http, request, "/jobs/");
{
_cupsLangPrintf(stderr, _("%s: %s failed: %s"), argv[0],
op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
- cupsLastErrorString());
+ cupsGetErrorString());
ippDelete(response);
}
else
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
ippAddBoolean(request, IPP_TAG_OPERATION, "purge-jobs", (char)purge);
{
_cupsLangPrintf(stderr, _("%s: %s failed: %s"), argv[0],
op == IPP_PURGE_JOBS ? "purge-jobs" : "cancel-job",
- cupsLastErrorString());
+ cupsGetErrorString());
ippDelete(response);
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
if (reason != NULL)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_TEXT,
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/admin/"));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr,
_("%s: Operation failed: %s"),
- command, ippErrorString(cupsLastError()));
+ command, ippErrorString(cupsGetError()));
return (1);
}
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/admin/"));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (1);
}
}
{
if (!cupsAdminSetServerSettings(http, num_settings, settings))
{
- _cupsLangPrintf(stderr, "cupsctl: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "cupsctl: %s", cupsGetErrorString());
return (1);
}
}
else if (!cupsAdminGetServerSettings(http, &num_settings, &settings))
{
- _cupsLangPrintf(stderr, "cupsctl: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "cupsctl: %s", cupsGetErrorString());
return (1);
}
else
dest->options[j].value,
num_options, &options);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server "
"name."), argv[0]);
return (1);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND)
+ else if (cupsGetError() == IPP_STATUS_ERROR_NOT_FOUND)
{
_cupsLangPrintf(stderr,
_("%s: Error - The printer or class does not exist."), argv[0]);
char email[1024]; /* EMail address */
- snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(), httpGetHostname(NULL, buffer, sizeof(buffer)));
+ snprintf(email, sizeof(email), "mailto:%s@%s", cupsGetUser(), httpGetHostname(NULL, buffer, sizeof(buffer)));
num_options = cupsAddOption("notify-recipient-uri", email, num_options, &options);
}
dest->options[j].value,
num_options, &options);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server "
if (printer == NULL)
{
- if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND)
- _cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsLastErrorString());
+ if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsGetError() == IPP_STATUS_ERROR_NOT_FOUND)
+ _cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsGetErrorString());
else
_cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."), argv[0]);
if (cupsFinishDocument(CUPS_HTTP_DEFAULT, printer) != IPP_OK)
{
- _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
return (1);
}
if (job_id < 1)
{
- _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsGetErrorString());
return (1);
}
else if (!silent)
"job-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
if (job_hold_until)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "job-hold-until", NULL, job_hold_until);
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/jobs"));
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server "
"name."), command);
return (1);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (1);
}
"job-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
cupsEncodeOptions(request, num_options, options);
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/jobs"));
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server "
"name."), command);
return (1);
}
- else if (cupsLastError() > IPP_OK_CONFLICT)
+ else if (cupsGetError() > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
+ _cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* See if the printer is already in the class...
ippDelete(response);
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
if ((response = cupsDoRequest(http, request, "/classes/")) == NULL ||
response->request.status.status_code == IPP_STATUS_ERROR_NOT_FOUND)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
ippDelete(response);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
}
else
{
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
/*
* Delete the printer from the class...
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_DELETEATTR, option, 0);
/*
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, "localhost", ippPort(), "/printers/%s", printer);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
request = ippNewRequest(IPP_OP_RESUME_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
ippDelete(cupsDoRequest(http, request, "/admin/"));
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", NULL, "printer-type");
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
/*
* Do the request...
request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
/*
* Add the options...
* Check the response...
*/
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsLastErrorString());
+ _cupsLangPrintf(stderr, _("%s: %s"), "lpadmin", cupsGetErrorString());
return (1);
}
if (cupsGetDevices(CUPS_HTTP_DEFAULT, timeout, include_schemes,
exclude_schemes, device_cb, &long_status) != IPP_OK)
{
- _cupsLangPrintf(stderr, "lpinfo: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpinfo: %s", cupsGetErrorString());
return (1);
}
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "lpinfo: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpinfo: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
}
else
{
- _cupsLangPrintf(stderr, "lpinfo: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpinfo: %s", cupsGetErrorString());
return (1);
}
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
"ipp", NULL, "localhost", 0, "/printers/%s", dest);
ippDelete(cupsDoRequest(http, request, "/jobs"));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ if (cupsGetError() > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "lpmove: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpmove: %s", cupsGetErrorString());
return (1);
}
else
if ((http = cupsConnectDest(dest, CUPS_DEST_FLAGS_NONE, 30000, NULL, resource, sizeof(resource), NULL, NULL)) == NULL)
{
_cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"),
- dest->name, cupsLastErrorString());
+ dest->name, cupsGetErrorString());
return;
}
httpClose(http);
_cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"),
- dest->name, cupsLastErrorString());
+ dest->name, cupsGetErrorString());
return;
}
cupsFreeDests(num_dests, dests);
num_dests = cupsGetDests(&dests);
- if (num_dests == 0 && (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
+ if (num_dests == 0 && (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
num_dests = dests ? 1 : 0;
if (num_dests == 0 &&
- (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
+ (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
num_dests = cupsGetDests(&dests);
if (num_dests == 0 &&
- (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
+ (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
num_dests = cupsGetDests(&dests);
if (num_dests == 0 &&
- (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
+ (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
num_dests = cupsGetDests(&dests);
if (num_dests == 0 &&
- (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
+ (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
num_dests = cupsGetDests(&dests);
if (num_dests == 0 &&
- (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
+ (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED))
{
_cupsLangPrintf(stderr, _("%s: Error - add '/version=1.1' to server name."), argv[0]);
return (1);
}
if (!op)
- status |= show_jobs(NULL, cupsUser(), long_status, ranking, which);
+ status |= show_jobs(NULL, cupsGetUser(), long_status, ranking, which);
return (status);
}
if ((*dests = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer, pptr)) == NULL)
{
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
command);
if (!cupsGetDest(printer, NULL, *num_dests, *dests))
{
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
command);
NULL, pattrs);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
- if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
+ if (cupsGetError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
{
_cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat");
ippDelete(response);
return (1);
}
- else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ else if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST || cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
ippDelete(response);
return (1);
}
- else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
NULL, cattrs);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
- if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
+ if (cupsGetError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
{
_cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat");
ippDelete(response);
return (1);
}
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
ippDelete(response);
return (1);
}
- else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
{
if (response->request.status.status_code > IPP_OK_CONFLICT)
{
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
NULL, pattrs);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
- if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
+ if (cupsGetError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
{
_cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat");
ippDelete(response);
return (1);
}
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
ippDelete(response);
return (1);
}
- else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
NULL, jattrs);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
NULL, which);
response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
- if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
+ if (cupsGetError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
{
_cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat");
ippDelete(response);
return (1);
}
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
ippDelete(response);
return (1);
}
- else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
NULL, pattrs);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
+ NULL, cupsGetUser());
/*
* Do the request and get back a response...
response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
- if (cupsLastError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
+ if (cupsGetError() == IPP_STATUS_ERROR_SERVICE_UNAVAILABLE)
{
_cupsLangPrintf(stderr, _("%s: Scheduler is not running."), "lpstat");
ippDelete(response);
return (1);
}
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
- cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsGetError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
_cupsLangPrintf(stderr,
_("%s: Error - add '/version=1.1' to server name."),
ippDelete(response);
return (1);
}
- else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ else if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
{
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsGetErrorString());
ippDelete(response);
return (1);
}
if ((http = httpConnect2(hostname, port, NULL, AF_UNSPEC, encryption, 1, 30000, NULL)) == NULL)
{
- respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to connect to %s: %s", hostname, cupsLastErrorString());
+ respond_ipp(client, IPP_STATUS_ERROR_DOCUMENT_ACCESS, "Unable to connect to %s: %s", hostname, cupsGetErrorString());
close(job->fd);
job->fd = -1;
if (httpEncryption(client->http, HTTP_ENCRYPTION_ALWAYS))
{
- fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsLastErrorString());
+ fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsGetErrorString());
break;
}
if (httpEncryption(client->http, HTTP_ENCRYPTION_REQUIRED))
{
- fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsLastErrorString());
+ fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsGetErrorString());
return (0);
}
{
if (ipp_state == IPP_STATE_ERROR)
{
- fprintf(stderr, "%s IPP read error (%s).\n", client->hostname, cupsLastErrorString());
+ fprintf(stderr, "%s IPP read error (%s).\n", client->hostname, cupsGetErrorString());
respond_http(client, HTTP_STATUS_BAD_REQUEST, NULL, NULL, 0);
return (0);
}
snprintf(service, sizeof(service), "%d", port);
if ((addrlist = httpAddrGetList(host, AF_UNSPEC, service)) == NULL)
- fprintf(stderr, "[Job %d] Unable to find \"%s\": %s\n", job->id, host, cupsLastErrorString());
+ fprintf(stderr, "[Job %d] Unable to find \"%s\": %s\n", job->id, host, cupsGetErrorString());
else if (!httpAddrConnect2(addrlist, &mystdout, 30000, &(job->cancel)))
- fprintf(stderr, "[Job %d] Unable to connect to \"%s\": %s\n", job->id, host, cupsLastErrorString());
+ fprintf(stderr, "[Job %d] Unable to connect to \"%s\": %s\n", job->id, host, cupsGetErrorString());
httpAddrFreeList(addrlist);
}
const char *job_id = getenv("IPP_JOB_ID");
/* job-id value */
- ppdEmitJCL(ppd, stdout, job_id ? atoi(job_id) : 0, cupsUser(), job_name ? job_name : "Unknown");
+ ppdEmitJCL(ppd, stdout, job_id ? atoi(job_id) : 0, cupsGetUser(), job_name ? job_name : "Unknown");
#endif /* !CUPS_LITE */
puts("%!PS-Adobe-3.0");
pdf_argv[0] = "printer";
pdf_argv[1] = job_id;
- pdf_argv[2] = cupsUser();
+ pdf_argv[2] = cupsGetUser();
pdf_argv[3] = job_name;
pdf_argv[4] = "1";
pdf_argv[5] = pdf_options;
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
service->uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsGetUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
(int)(sizeof(rattrs) / sizeof(rattrs[0])), NULL, rattrs);
response = cupsDoRequest(http, request, service->resource);
- if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST && version > 11)
+ if (cupsGetError() == IPP_STATUS_ERROR_BAD_REQUEST && version > 11)
version = 11;
}
- while (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE && version > 11);
+ while (cupsGetError() > IPP_STATUS_OK_EVENTS_COMPLETE && version > 11);
/*
* Show results...
*/
- if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE)
+ if (cupsGetError() > IPP_STATUS_OK_EVENTS_COMPLETE)
{
_cupsLangPrintf(stdout, "%s: unavailable", service->uri);
return (0);
if ((http = httpConnect2(host, port, NULL, data->family, encryption, 1, 30000, NULL)) == NULL)
{
- print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", host, port, cupsLastErrorString());
+ print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", host, port, cupsGetErrorString());
return (0);
}
ippSetRequestId(request, data->request_id * 100 - 1);
ippSetVersion(request, data->version / 10, data->version % 10);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->monitor_uri);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsGetUser());
for (i = data->num_monitor_expects, expect = data->monitor_expects, num_pattrs = 0; i > 0; i --, expect ++)
{
* No response, log error...
*/
- add_stringf(data->errors, "IPP request failed with status %s (%s)", ippErrorString(cupsLastError()), cupsLastErrorString());
+ add_stringf(data->errors, "IPP request failed with status %s (%s)", ippErrorString(cupsGetError()), cupsGetErrorString());
}
else
{
}
if (!ippValidateAttribute(attrptr))
- cupsArrayAdd(data->errors, (void *)cupsLastErrorString());
+ cupsArrayAdd(data->errors, (void *)cupsGetErrorString());
if (ippGetName(attrptr))
{
continue;
if (!data->statuses[i].repeat_match || repeat_count >= data->statuses[i].repeat_limit)
- add_stringf(data->errors, "EXPECTED: STATUS %s (got %s)", ippErrorString(data->statuses[i].status), ippErrorString(cupsLastError()));
+ add_stringf(data->errors, "EXPECTED: STATUS %s (got %s)", ippErrorString(data->statuses[i].status), ippErrorString(cupsGetError()));
}
if ((attrptr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT)) != NULL)
cupsFilePuts(data->outfile, "<key>Successful</key>\n");
cupsFilePuts(data->outfile, data->prev_pass ? "<true />\n" : "<false />\n");
cupsFilePuts(data->outfile, "<key>StatusCode</key>\n");
- print_xml_string(data->outfile, "string", ippErrorString(cupsLastError()));
+ print_xml_string(data->outfile, "string", ippErrorString(cupsGetError()));
cupsFilePuts(data->outfile, "<key>ResponseAttributes</key>\n");
cupsFilePuts(data->outfile, "<array>\n");
cupsFilePuts(data->outfile, "<dict>\n");
if (!data->prev_pass || (data->verbosity && response))
{
cupsFilePrintf(cupsFileStdout(), " RECEIVED: %lu bytes in response\n", (unsigned long)ippLength(response));
- cupsFilePrintf(cupsFileStdout(), " status-code = %s (%s)\n", ippErrorString(cupsLastError()), cupsLastErrorString());
+ cupsFilePrintf(cupsFileStdout(), " status-code = %s (%s)\n", ippErrorString(cupsGetError()), cupsGetErrorString());
if (data->verbosity && response)
{
}
}
else if (!data->prev_pass && data->output != IPPTOOL_OUTPUT_QUIET)
- fprintf(stderr, "%s\n", cupsLastErrorString());
+ fprintf(stderr, "%s\n", cupsGetErrorString());
if (data->prev_pass && data->output >= IPPTOOL_OUTPUT_LIST && !data->verbosity && data->num_displayed > 0)
{
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, cupsLastErrorString());
+ print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", data->vars->host, data->vars->port, cupsGetErrorString());
return (0);
}