Michael R Sweet
Copyright © 2020-2025 by OpenPrinting. All Rights Reserved.
Please file issues on GitHub to provide feedback on this document.
CUPS provides the "cups" library to talk to the different parts of CUPS and with Internet Printing Protocol (IPP) printers. The "cups" library functions are accessed by including the <cups/cups.h>
header.
CUPS is based on the Internet Printing Protocol ("IPP"), which allows clients (applications) to communicate with a server (the scheduler, printers, etc.) to get a list of destinations, send print jobs, and so forth. You identify which server you want to communicate with using a pointer to the opaque structure http_t
. The CUPS_HTTP_DEFAULT
constant can be used when you want to talk to the CUPS scheduler.
When writing software (other than printer drivers) that uses the "cups" library:
Do not use undocumented or deprecated APIs,
Do not rely on pre-configured printers,
Do not assume that printers support specific features or formats, and
Do not rely on implementation details (PPDs, etc.)
CUPS is designed to insulate users and developers from the implementation details of printers and file formats. The goal is to allow an application to supply a print file in a standard format with the user intent ("print four copies, two-sided on A4 media, and staple each copy") and have the printing system manage the printer communication and format conversion needed.
Similarly, printer and job management applications can use standard query operations to obtain the status information in a common, generic form and use standard management operations to control the state of those printers and jobs.
Note:
CUPS printer drivers necessarily depend on specific file formats and certain implementation details of the CUPS software. Please consult the Postscript and raster printer driver developer documentation on the OpenPrinting CUPS website for more information.
A Destination is a printer or print queue that accepts print jobs. A Print Job is a collection of one or more documents that are processed by a destination using options supplied when creating the job. A Document is a file (JPEG image, PDF file, etc.) suitable for printing. An Option controls some aspect of printing, such as the media used. Media is the sheets or roll that is printed on. An Attribute is an option encoded for an Internet Printing Protocol (IPP) request.
The CUPS libraries can be used from any C, C++, or Objective-C program. The method of compiling against the libraries varies depending on the operating system and installation of CUPS. The following sections show how to compile a simple program (shown below) in two common environments.
The following simple program lists the available destinations:
#include <stdio.h>
#include <cups/cups.h>
int print_dest(void *user_data, unsigned flags, cups_dest_t *dest)
{
if (dest->instance)
printf("%s/%s\n", dest->name, dest->instance);
else
puts(dest->name);
return (1);
}
int main(void)
{
cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, 0, 0, print_dest, NULL);
return (0);
}
In Xcode, choose New Project... from the File menu (or press SHIFT+CMD+N), then select the Command Line Tool under the macOS Application project type. Click Next and enter a name for the project, for example "firstcups". Click Next and choose a project directory. The click Next to create the project.
In the project window, click on the Build Phases group and expand the Link Binary with Libraries section. Click +, type "libcups" to show the library, and then double-click on libcups.tbd
.
Finally, click on the main.c
file in the sidebar and copy the example program to the file. Build and run (CMD+R) to see the list of destinations.
From the command-line, create a file called simple.c
using your favorite editor, copy the example to this file, and save. Then run the following command to compile it with GCC and run it:
gcc -o simple `pkg-config --cflags cups` simple.c `pkg-config --libs cups`
./simple
The pkg-config
command provides the compiler flags (pkg-config --cflags cups
) and libraries (pkg-config --libs cups
) needed for the local system.
Destinations, which in CUPS represent individual printers or classes (collections or pools) of printers, are represented by the cups_dest_t
structure which includes the name (name
), instance (instance
, saved options/settings), whether the destination is the default for the user (is_default
), and the options and basic information associated with that destination (num_options
and options
).
Historically destinations have been manually maintained by the administrator of a system or network, but CUPS also supports dynamic discovery of destinations on the current network.
The cupsEnumDests
function finds all of the available destinations:
int
cupsEnumDests(unsigned flags, int msec, int *cancel,
cups_ptype_t type, cups_ptype_t mask,
cups_dest_cb_t cb, void *user_data)
The flags
argument specifies enumeration options, which at present must be CUPS_DEST_FLAGS_NONE
.
The msec
argument specifies the maximum amount of time that should be used for enumeration in milliseconds - interactive applications should keep this value to 5000 or less when run on the main thread.
The cancel
argument points to an integer variable that, when set to a non-zero value, will cause enumeration to stop as soon as possible. It can be NULL
if not needed.
The type
and mask
arguments are bitfields that allow the caller to filter the destinations based on categories and/or capabilities. The destination's "printer-type" value is masked by the mask
value and compared to the type
value when filtering. For example, to only enumerate destinations that are hosted on the local system, pass CUPS_PTYPE_LOCAL
for the type
argument and CUPS_PTYPE_DISCOVERED
for the mask
argument. The following constants can be used for filtering:
CUPS_PTYPE_CLASS
: A collection of destinations.
CUPS_PTYPE_FAX
: A facsimile device.
CUPS_PTYPE_LOCAL
: A local printer or class. This constant has the value 0 (no bits set) and is only used for the type
argument and is paired with the CUPS_PTYPE_REMOTE
or CUPS_PTYPE_DISCOVERED
constant passed in the mask
argument.
CUPS_PTYPE_REMOTE
: A remote (shared) printer or class.
CUPS_PTYPE_DISCOVERED
: An available network printer or class.
CUPS_PTYPE_BW
: Can do B&W printing.
CUPS_PTYPE_COLOR
: Can do color printing.
CUPS_PTYPE_DUPLEX
: Can do two-sided printing.
CUPS_PTYPE_STAPLE
: Can staple output.
CUPS_PTYPE_COLLATE
: Can quickly collate copies.
CUPS_PTYPE_PUNCH
: Can punch output.
CUPS_PTYPE_COVER
: Can cover output.
CUPS_PTYPE_BIND
: Can bind output.
CUPS_PTYPE_SORT
: Can sort output (mailboxes, etc.)
CUPS_PTYPE_SMALL
: Can print on Letter/Legal/A4-size media.
CUPS_PTYPE_MEDIUM
: Can print on Tabloid/B/C/A3/A2-size media.
CUPS_PTYPE_LARGE
: Can print on D/E/A1/A0-size media.
CUPS_PTYPE_VARIABLE
: Can print on rolls and custom-size media.
The cb
argument specifies a function to call for every destination that is found:
typedef int (*cups_dest_cb_t)(void *user_data,
unsigned flags,
cups_dest_t *dest);
The callback function receives a copy of the user_data
argument along with a bitfield (flags
) and the destination that was found. The flags
argument can have any of the following constant (bit) values set:
CUPS_DEST_FLAGS_MORE
: There are more destinations coming.
CUPS_DEST_FLAGS_REMOVED
: The destination has gone away and should be removed from the list of destinations a user can select.
CUPS_DEST_FLAGS_ERROR
: An error occurred. The reason for the error can be found by calling the cupsGetError
and/or cupsGetErrorString
functions.
The callback function returns 0
to stop enumeration or 1
to continue.
Note:
The callback function will likely be called multiple times for the same destination, so it is up to the caller to suppress any duplicate destinations.
The following example shows how to use cupsEnumDests
to get a filtered array of destinations:
typedef struct
{
int num_dests;
cups_dest_t *dests;
} my_user_data_t;
int
my_dest_cb(my_user_data_t *user_data, unsigned flags,
cups_dest_t *dest)
{
if (flags & CUPS_DEST_FLAGS_REMOVED)
{
/*
* Remove destination from array...
*/
user_data->num_dests =
cupsRemoveDest(dest->name, dest->instance,
user_data->num_dests,
&(user_data->dests));
}
else
{
/*
* Add destination to array...
*/
user_data->num_dests =
cupsCopyDest(dest, user_data->num_dests,
&(user_data->dests));
}
return (1);
}
int
my_get_dests(cups_ptype_t type, cups_ptype_t mask,
cups_dest_t **dests)
{
my_user_data_t user_data = { 0, NULL };
if (!cupsEnumDests(CUPS_DEST_FLAGS_NONE, 1000, NULL, type,
mask, (cups_dest_cb_t)my_dest_cb,
&user_data))
{
/*
* An error occurred, free all of the destinations and
* return...
*/
cupsFreeDests(user_data.num_dests, user_data.dests);
*dests = NULL;
return (0);
}
/*
* Return the destination array...
*/
*dests = user_data.dests;
return (user_data.num_dests);
}
The num_options
and options
members of the cups_dest_t
structure provide basic attributes about the destination in addition to the user default options and values for that destination. The following names are predefined for various destination attributes:
"auth-info-required": The type of authentication required for printing to this destination: "none", "username,password", "domain,username,password", or "negotiate" (Kerberos).
"printer-info": The human-readable description of the destination such as "My Laser Printer".
"printer-is-accepting-jobs": "true" if the destination is accepting new jobs, "false" otherwise.
"printer-is-shared": "true" if the destination is being shared with other computers, "false" otherwise.
"printer-location": The human-readable location of the destination such as "Lab 4".
"printer-make-and-model": The human-readable make and model of the destination such as "ExampleCorp LaserPrinter 4000 Series".
"printer-state": "3" if the destination is idle, "4" if the destination is printing a job, and "5" if the destination is stopped.
"printer-state-change-time": The UNIX time when the destination entered the current state.
"printer-state-reasons": Additional comma-delimited state keywords for the destination such as "media-tray-empty-error" and "toner-low-warning".
"printer-type": The cups_ptype_t
value associated with the destination.
"printer-uri-supported": The URI associated with the destination; if not set, this destination was discovered but is not yet setup as a local printer.
Use the cupsGetOption
function to retrieve the value. For example, the following code gets the make and model of a destination:
const char *model = cupsGetOption("printer-make-and-model",
dest->num_options,
dest->options);
Once a destination has been chosen, the cupsCopyDestInfo
function can be used to gather detailed information about the destination:
cups_dinfo_t *
cupsCopyDestInfo(http_t *http, cups_dest_t *dest);
The http
argument specifies a connection to the CUPS scheduler and is typically the constant CUPS_HTTP_DEFAULT
. The dest
argument specifies the destination to query.
The cups_dinfo_t
structure that is returned contains a snapshot of the supported options and their supported, ready, and default values. It also can report constraints between different options and values, and recommend changes to resolve those constraints.
The cupsCheckDestSupported
function can be used to test whether a particular option or option and value is supported:
int
cupsCheckDestSupported(http_t *http, cups_dest_t *dest,
cups_dinfo_t *info,
const char *option,
const char *value);
The option
argument specifies the name of the option to check. The following constants can be used to check the various standard options:
CUPS_COPIES
: Controls the number of copies that are produced.
CUPS_FINISHINGS
: A comma-delimited list of integer constants that control the finishing processes that are applied to the job, including stapling, punching, and folding.
CUPS_MEDIA
: Controls the media size that is used, typically one of the following: CUPS_MEDIA_3X5
, CUPS_MEDIA_4X6
, CUPS_MEDIA_5X7
, CUPS_MEDIA_8X10
, CUPS_MEDIA_A3
, CUPS_MEDIA_A4
, CUPS_MEDIA_A5
, CUPS_MEDIA_A6
, CUPS_MEDIA_ENV10
, CUPS_MEDIA_ENVDL
, CUPS_MEDIA_LEGAL
, CUPS_MEDIA_LETTER
, CUPS_MEDIA_PHOTO_L
, CUPS_MEDIA_SUPERBA3
, or CUPS_MEDIA_TABLOID
.
CUPS_MEDIA_SOURCE
: Controls where the media is pulled from, typically either CUPS_MEDIA_SOURCE_AUTO
or CUPS_MEDIA_SOURCE_MANUAL
.
CUPS_MEDIA_TYPE
: Controls the type of media that is used, typically one of the following: CUPS_MEDIA_TYPE_AUTO
, CUPS_MEDIA_TYPE_ENVELOPE
, CUPS_MEDIA_TYPE_LABELS
, CUPS_MEDIA_TYPE_LETTERHEAD
, CUPS_MEDIA_TYPE_PHOTO
, CUPS_MEDIA_TYPE_PHOTO_GLOSSY
, CUPS_MEDIA_TYPE_PHOTO_MATTE
, CUPS_MEDIA_TYPE_PLAIN
, or CUPS_MEDIA_TYPE_TRANSPARENCY
.
CUPS_NUMBER_UP
: Controls the number of document pages that are placed on each media side.
CUPS_ORIENTATION
: Controls the orientation of document pages placed on the media: CUPS_ORIENTATION_PORTRAIT
or CUPS_ORIENTATION_LANDSCAPE
.
CUPS_PRINT_COLOR_MODE
: Controls whether the output is in color (CUPS_PRINT_COLOR_MODE_COLOR
), grayscale (CUPS_PRINT_COLOR_MODE_MONOCHROME
), or either (CUPS_PRINT_COLOR_MODE_AUTO
).
CUPS_PRINT_QUALITY
: Controls the generate quality of the output: CUPS_PRINT_QUALITY_DRAFT
, CUPS_PRINT_QUALITY_NORMAL
, or CUPS_PRINT_QUALITY_HIGH
.
CUPS_SIDES
: Controls whether prints are placed on one or both sides of the media: CUPS_SIDES_ONE_SIDED
, CUPS_SIDES_TWO_SIDED_PORTRAIT
, or CUPS_SIDES_TWO_SIDED_LANDSCAPE
.
If the value
argument is NULL
, the cupsCheckDestSupported
function returns whether the option is supported by the destination. Otherwise, the function returns whether the specified value of the option is supported.
The cupsFindDestSupported
function returns the IPP attribute containing the supported values for a given option:
ipp_attribute_t *
cupsFindDestSupported(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo,
const char *option);
For example, the following code prints the supported finishing processes for a destination, if any, to the standard output:
cups_dinfo_t *info = cupsCopyDestInfo(CUPS_HTTP_DEFAULT,
dest);
if (cupsCheckDestSupported(CUPS_HTTP_DEFAULT, dest, info,
CUPS_FINISHINGS, NULL))
{
ipp_attribute_t *finishings =
cupsFindDestSupported(CUPS_HTTP_DEFAULT, dest, info,
CUPS_FINISHINGS);
int i, count = ippGetCount(finishings);
puts("finishings supported:");
for (i = 0; i < count; i ++)
{
int val = ippGetInteger(finishings, i);
printf(" %d (%s)\n", val,
ippEnumString("finishings", val));
}
else
{
puts("finishings not supported.");
}
The "job-creation-attributes" option can be queried to get a list of supported options. For example, the following code prints the list of supported options to the standard output:
ipp_attribute_t *attrs =
cupsFindDestSupported(CUPS_HTTP_DEFAULT, dest, info,
"job-creation-attributes");
int i, count = ippGetCount(attrs);
for (i = 0; i < count; i ++)
puts(ippGetString(attrs, i, NULL));
There are two sets of default values - user defaults that are available via the num_options
and options
members of the cups_dest_t
structure, and destination defaults that available via the cups_dinfo_t
structure and the cupsFindDestDefault
function which returns the IPP attribute containing the default value(s) for a given option:
ipp_attribute_t *
cupsFindDestDefault(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo,
const char *option);
The user defaults from cupsGetOption
should always take preference over the destination defaults. For example, the following code prints the default finishings value(s) to the standard output:
const char *def_value =
cupsGetOption(CUPS_FINISHINGS, dest->num_options,
dest->options);
ipp_attribute_t *def_attr =
cupsFindDestDefault(CUPS_HTTP_DEFAULT, dest, info,
CUPS_FINISHINGS);
if (def_value != NULL)
{
printf("Default finishings: %s\n", def_value);
}
else
{
int i, count = ippGetCount(def_attr);
printf("Default finishings: %d",
ippGetInteger(def_attr, 0));
for (i = 1; i < count; i ++)
printf(",%d", ippGetInteger(def_attr, i));
putchar('\n');
}
The finishings and media options also support queries for the ready, or loaded, values. For example, a printer may have punch and staple finishers installed but be out of staples - the supported values will list both punch and staple finishing processes but the ready values will only list the punch processes. Similarly, a printer may support hundreds of different sizes of media but only have a single size loaded at any given time - the ready values are limited to the media that is actually in the printer.
The cupsFindDestReady
function finds the IPP attribute containing the ready values for a given option:
ipp_attribute_t *
cupsFindDestReady(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo, const char *option);
For example, the following code lists the ready finishing processes:
ipp_attribute_t *ready_finishings =
cupsFindDestReady(CUPS_HTTP_DEFAULT, dest, info,
CUPS_FINISHINGS);
if (ready_finishings != NULL)
{
int i, count = ippGetCount(ready_finishings);
puts("finishings ready:");
for (i = 0; i < count; i ++)
{
int val = ippGetInteger(ready_finishings, i);
printf(" %d (%s)\n", val,
ippEnumString("finishings", val));
}
else
{
puts("no finishings are ready.");
}
CUPS provides functions for querying the dimensions, margins, color, source (tray/roll), and type for each of the supported media size options. The cups_media_t
structure is used to describe media:
typedef struct cups_media_s
{
char media[128];
char color[128];
char source[128];
char type[128];
int width, length;
int bottom, left, right, top;
} cups_media_t;
The "media" member specifies a PWG self-describing media size name such as "na_letter_8.5x11in", "iso_a4_210x297mm", etc. The "color" member specifies a PWG media color name such as "white", "blue", etc. The "source" member specifies a standard keyword for the paper tray or roll such as "tray-1", "manual", "by-pass-tray" (multi-purpose tray), etc. The "type" member specifies a PWG media type name such as "stationery" (plain paper), "photographic", "envelope", "transparency", etc.
The width
and length
members specify the dimensions of the media in hundredths of millimeters (1/2540th of an inch). The bottom
, left
, right
, and top
members specify the margins of the printable area, also in hundredths of millimeters.
The cupsGetDestMediaByName2
and cupsGetDestMediaBySize2
functions lookup the media information using a standard media size name or dimensions in hundredths of millimeters:
bool
cupsGetDestMediaByName2(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo,
const char *name,
unsigned flags, cups_media_t *media);
bool
cupsGetDestMediaBySize2(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo,
int width, int length,
unsigned flags, cups_media_t *media);
The name
, width
, and length
arguments specify the size to lookup. The flags
argument specifies a bitfield controlling various lookup options:
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 two-sided printing.
CUPS_MEDIA_FLAGS_EXACT
: Find an exact match for the size.
CUPS_MEDIA_FLAGS_READY
: If the printer supports media sensing or configuration of the media in each tray/source, find the size amongst the "ready" media.
If a matching size is found for the destination, the size information is stored in the structure pointed to by the media
argument and true
is returned. Otherwise false
is returned.
For example, the following code prints the margins for two-sided printing on US Letter media:
cups_media_t media:
if (cupsGetDestMediaByName2(CUPS_HTTP_DEFAULT, dest, info,
CUPS_MEDIA_LETTER,
CUPS_MEDIA_FLAGS_DUPLEX, &size))
{
puts("Margins for duplex US Letter:");
printf(" Bottom: %.2fin\n", media.bottom / 2540.0);
printf(" Left: %.2fin\n", media.left / 2540.0);
printf(" Right: %.2fin\n", media.right / 2540.0);
printf(" Top: %.2fin\n", media.top / 2540.0);
}
else
{
puts("Margins for duplex US Letter are not available.");
}
You can also enumerate all of the sizes that match a given flags
value using the cupsGetDestMediaByIndex2
and cupsGetDestMediaCount
functions:
bool
cupsGetDestMediaByIndex2(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo, size_t n,
unsigned flags, cups_media_t *media);
int
cupsGetDestMediaCount(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo, unsigned flags);
For example, the following code prints the list of ready media and corresponding margins:
cups_media_t media;
size_t i;
size_t count = (size_t)cupsGetDestMediaCount(CUPS_HTTP_DEFAULT,
dest, info,
CUPS_MEDIA_FLAGS_READY);
for (i = 0; i < count; i ++)
{
if (cupsGetDestMediaByIndex2(CUPS_HTTP_DEFAULT, dest, info,
i, CUPS_MEDIA_FLAGS_READY,
&media))
{
printf("%s:\n", media.name);
printf(" Width: %.2fin\n", media.width / 2540.0);
printf(" Length: %.2fin\n", media.length / 2540.0);
printf(" Bottom: %.2fin\n", media.bottom / 2540.0);
printf(" Left: %.2fin\n", media.left / 2540.0);
printf(" Right: %.2fin\n", media.right / 2540.0);
printf(" Top: %.2fin\n", media.top / 2540.0);
}
}
Finally, the cupsGetDestMediaDefault2
function returns the default media:
int
cupsGetDestMediaDefault2(http_t *http, cups_dest_t *dest,
cups_dinfo_t *dinfo, unsigned flags,
cups_media_t *media);
CUPS provides three functions to get localized, human-readable strings in the user's current locale for options and values: cupsLocalizeDestMedia2
, cupsLocalizeDestOption
, and cupsLocalizeDestValue
:
const char *
cupsLocalizeDestMedia2(http_t *http, cups_dest_t *dest,
cups_dinfo_t *info, unsigned flags,
cups_media_t *media);
const char *
cupsLocalizeDestOption(http_t *http, cups_dest_t *dest,
cups_dinfo_t *info,
const char *option);
const char *
cupsLocalizeDestValue(http_t *http, cups_dest_t *dest,
cups_dinfo_t *info,
const char *option, const char *value);
Note:
These functions require a valid
http_t
connection to work. Use thecupsConnectDest
function to connect to the destination for its localization information.
For example, the following code will list the localized media names for a destination:
char resource[256];
http_t *http = cupsConnectDest(dest, CUPS_DEST_FLAGS_NONE,
/*msec*/30000, /*cancel*/NULL,
resource, sizeof(resource),
/*dest_cb*/NULL, /*user_data*/NULL);
size_t i;
size_t count = (size_t)cupsGetDestMediaCount(http, dest, info,
CUPS_MEDIA_FLAGS_DEFAULT);
cups_media_t media;
for (i = 0; i < count; i ++)
{
if (cupsGetDestMediaByIndex2(http, dest, info, i,
CUPS_MEDIA_FLAGS_DEFAULT, &media))
printf("%s: %s\n", media.name,
cupsLocalizeDestMedia2(http, dest, info,
CUPS_MEDIA_FLAGS_DEFAULT, &media));
}
Once you are ready to submit a print job, you create a job using the cupsCreateDestJob
function:
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);
The title
argument specifies a name for the print job such as "My Document". The num_options
and options
arguments specify the options for the print job which are allocated using the cupsAddOption
function.
When successful, the job's numeric identifier is stored in the integer pointed to by the job_id
argument and IPP_STATUS_OK
is returned. Otherwise, an IPP error status is returned.
For example, the following code creates a new job that will print 42 copies of a two-sided US Letter document:
int job_id = 0;
int num_options = 0;
cups_option_t *options = NULL;
num_options = cupsAddOption(CUPS_COPIES, "42",
num_options, &options);
num_options = cupsAddOption(CUPS_MEDIA, CUPS_MEDIA_LETTER,
num_options, &options);
num_options = cupsAddOption(CUPS_SIDES,
CUPS_SIDES_TWO_SIDED_PORTRAIT,
num_options, &options);
if (cupsCreateDestJob(CUPS_HTTP_DEFAULT, dest, info,
&job_id, "My Document", num_options,
options) == IPP_STATUS_OK)
printf("Created job: %d\n", job_id);
else
printf("Unable to create job: %s\n",
cupsGetErrorString());
Once the job is created, you submit documents for the job using the cupsStartDestDocument
, cupsWriteRequestData
, and cupsFinishDestDocument
functions:
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);
http_status_t
cupsWriteRequestData(http_t *http, const char *buffer,
size_t length);
ipp_status_t
cupsFinishDestDocument(http_t *http, cups_dest_t *dest,
cups_dinfo_t *info);
The docname
argument specifies the name of the document, typically the original filename. The format
argument specifies the MIME media type of the document, including the following constants:
CUPS_FORMAT_AUTO
: "application/octet-stream"
CUPS_FORMAT_JPEG
: "image/jpeg"
CUPS_FORMAT_PDF
: "application/pdf"
CUPS_FORMAT_TEXT
: "text/plain"
The num_options
and options
arguments specify per-document print options, which at present must be 0 and NULL
. The last_document
argument specifies whether this is the last document in the job.
For example, the following code submits a PDF file to the job that was just created:
FILE *fp = fopen("filename.pdf", "rb");
size_t bytes;
char buffer[65536];
if (cupsStartDestDocument(CUPS_HTTP_DEFAULT, dest, info,
job_id, "filename.pdf", 0, NULL,
1) == HTTP_STATUS_CONTINUE)
{
while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0)
{
if (cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer,
bytes) != HTTP_STATUS_CONTINUE)
break;
}
if (cupsFinishDestDocument(CUPS_HTTP_DEFAULT, dest,
info) == IPP_STATUS_OK)
puts("Document send succeeded.");
else
printf("Document send failed: %s\n",
cupsGetErrorString());
}
fclose(fp);
CUPS provides a rich API for sending IPP requests to the scheduler or printers, typically from management or utility applications whose primary purpose is not to send print jobs.
The connection to the scheduler or printer is represented by the HTTP connection type http_t
. The cupsConnectDest
function connects to the scheduler or printer associated with the destination:
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);
The dest
argument specifies the destination to connect to.
The flags
argument specifies whether you want to connect to the scheduler (CUPS_DEST_FLAGS_NONE
) or device/printer (CUPS_DEST_FLAGS_DEVICE
) associated with the destination.
The msec
argument specifies how long you are willing to wait for the connection to be established in milliseconds. Specify a value of -1
to wait indefinitely.
The cancel
argument specifies the address of an integer variable that can be set to a non-zero value to cancel the connection. Specify a value of NULL
to not provide a cancel variable.
The resource
and resourcesize
arguments specify the address and size of a character string array to hold the path to use when sending an IPP request.
The cb
and user_data
arguments specify a destination callback function that returns 1 to continue connecting or 0 to stop. The destination callback works the same way as the one used for the cupsEnumDests
function.
On success, a HTTP connection is returned that can be used to send IPP requests and get IPP responses.
For example, the following code connects to the printer associated with a destination with a 30 second timeout:
char resource[256];
http_t *http = cupsConnectDest(dest, CUPS_DEST_FLAGS_DEVICE,
30000, /*cancel*/NULL, resource,
sizeof(resource),
/*cb*/NULL, /*user_data*/NULL);
IPP requests are represented by the IPP message type ipp_t
and each IPP attribute in the request is representing using the type ipp_attribute_t
. Each IPP request includes an operation code (IPP_OP_CREATE_JOB
, IPP_OP_GET_PRINTER_ATTRIBUTES
, etc.) and a 32-bit integer identifier.
The ippNewRequest
function creates a new IPP request:
ipp_t *
ippNewRequest(ipp_op_t op);
The op
argument specifies the IPP operation code for the request. For example, the following code creates an IPP Get-Printer-Attributes request:
ipp_t *request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
The request identifier is automatically set to a unique value for the current process.
Each IPP request starts with two IPP attributes, "attributes-charset" and "attributes-natural-language", followed by IPP attribute(s) that specify the target of the operation. The ippNewRequest
automatically adds the correct "attributes-charset" and "attributes-natural-language" attributes, but you must add the target attribute(s). For example, the following code adds the "printer-uri" attribute to the IPP Get-Printer-Attributes request to specify which printer is being queried:
const char *printer_uri = cupsGetOption("device-uri",
dest->num_options,
dest->options);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", /*language*/NULL, printer_uri);
```c
> **Note:**
>
> If we wanted to query the scheduler instead of the device, we would look
> up the "printer-uri-supported" option instead of the "device-uri" value.
The [`ippAddString`](@@) function adds the "printer-uri" attribute to the IPP
request. The `IPP_TAG_OPERATION` argument specifies that the attribute is part
of the operation. The `IPP_TAG_URI` argument specifies that the value is a
Universal Resource Identifier (URI) string. The `NULL` argument specifies there
is no language (English, French, Japanese, etc.) associated with the string, and
the `printer_uri` argument specifies the string value.
The IPP Get-Printer-Attributes request also supports an IPP attribute called
"requested-attributes" that lists the attributes and values you are interested
in. For example, the following code requests the printer state attributes:
```c
static const char * const requested_attributes[] =
{
"printer-state",
"printer-state-message",
"printer-state-reasons"
};
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", 3, /*language*/NULL,
requested_attributes);
The ippAddStrings
function adds an attribute with one or more strings, in this case three. The IPP_TAG_KEYWORD
argument specifies that the strings are keyword values, which are used for attribute names. All strings use the same language (NULL
for none), and the attribute will contain the three strings in the array requested_attributes
.
CUPS provides many functions to adding attributes of different types:
ippAddBoolean
adds a boolean (IPP_TAG_BOOLEAN
) attribute with one value.
ippAddInteger
adds an enum (IPP_TAG_ENUM
) or integer (IPP_TAG_INTEGER
) attribute with one value.
ippAddIntegers
adds an enum or integer attribute with one or more values.
ippAddOctetString
adds an octetString attribute with one value.
ippAddOutOfBand
adds a admin-defined (IPP_TAG_ADMINDEFINE
), default (IPP_TAG_DEFAULT
), delete-attribute (IPP_TAG_DELETEATTR
), no-value (IPP_TAG_NOVALUE
), not-settable (IPP_TAG_NOTSETTABLE
), unknown (IPP_TAG_UNKNOWN
), or unsupported (IPP_TAG_UNSUPPORTED_VALUE
) out-of-band attribute.
ippAddRange
adds a rangeOfInteger attribute with one range.
ippAddRanges
adds a rangeOfInteger attribute with one or more ranges.
ippAddResolution
adds a resolution attribute with one resolution.
ippAddResolutions
adds a resolution attribute with one or more resolutions.
ippAddString
adds a charset (IPP_TAG_CHARSET
), keyword (IPP_TAG_KEYWORD
), mimeMediaType (IPP_TAG_MIMETYPE
), name (IPP_TAG_NAME
and IPP_TAG_NAMELANG
), naturalLanguage (IPP_TAG_NATURAL_LANGUAGE
), text (IPP_TAG_TEXT
and IPP_TAG_TEXTLANG
), uri (IPP_TAG_URI
), or uriScheme (IPP_TAG_URISCHEME
) attribute with one value.
ippAddStrings
adds a charset, keyword, mimeMediaType, name, naturalLanguage, text, uri, or uriScheme attribute with one or more values.
Once you have created the IPP request, you can send it using the cupsDoRequest
function. For example, the following code sends the IPP Get-Printer-Attributes request to the destination and saves the response:
ipp_t *response = cupsDoRequest(http, request, resource);
For requests like Send-Document that include a file, the cupsDoFileRequest
function should be used:
ipp_t *response = cupsDoFileRequest(http, request, resource,
filename);
Both cupsDoRequest
and cupsDoFileRequest
free the IPP request. If a valid IPP response is received, it is stored in a new IPP message (ipp_t
) and returned to the caller. Otherwise NULL
is returned.
The status from the most recent request can be queried using the cupsGetError
function, for example:
if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
{
/* request failed */
}
A human-readable error message is also available using the cupsGetErrorString
function:
if (cupsGetError() >= IPP_STATUS_ERROR_BAD_REQUEST)
{
/* request failed */
printf("Request failed: %s\n", cupsGetErrorString());
}
Each response to an IPP request is also an IPP message (ipp_t
) with its own IPP attributes (ipp_attribute_t
) that includes a status code (IPP_STATUS_OK
, IPP_STATUS_ERROR_BAD_REQUEST
, etc.) and the corresponding 32-bit integer identifier from the request.
For example, the following code finds the printer state attributes and prints their values:
ipp_attribute_t *attr;
if ((attr = ippFindAttribute(response, "printer-state",
IPP_TAG_ENUM)) != NULL)
{
printf("printer-state=%s\n",
ippEnumString("printer-state", ippGetInteger(attr, 0)));
}
else
puts("printer-state=unknown");
if ((attr = ippFindAttribute(response, "printer-state-message",
IPP_TAG_TEXT)) != NULL)
{
printf("printer-state-message=\"%s\"\n",
ippGetString(attr, 0, NULL)));
}
if ((attr = ippFindAttribute(response, "printer-state-reasons",
IPP_TAG_KEYWORD)) != NULL)
{
int i, count = ippGetCount(attr);
puts("printer-state-reasons=");
for (i = 0; i < count; i ++)
printf(" %s\n", ippGetString(attr, i, NULL)));
}
The ippGetCount
function returns the number of values in an attribute.
The ippGetInteger
and ippGetString
functions return a single integer or string value from an attribute.
The ippEnumString
function converts a enum value to its keyword (string) equivalent.
Once you are done using the IPP response message, free it using the ippDelete
function:
ippDelete(response);
CUPS normally handles authentication through the console. GUI applications should set a password callback using the cupsSetPasswordCB2
function:
void
cupsSetPasswordCB2(cups_password_cb2_t cb, void *user_data);
The password callback will be called when needed and is responsible for setting the current user name using cupsSetUser
and returning a string:
const char *
cups_password_cb2(const char *prompt, http_t *http,
const char *method, const char *resource,
void *user_data);
The prompt
argument is a string from CUPS that should be displayed to the user.
The http
argument is the connection hosting the request that is being authenticated. The password callback can call the httpGetField
and httpGetSubField
functions to look for additional details concerning the authentication challenge.
The method
argument specifies the HTTP method used for the request and is typically "POST".
The resource
argument specifies the path used for the request.
The user_data
argument provides the user data pointer from the cupsSetPasswordCB2
call.
The IPP data file API provides functions to read and write IPP attributes and other commands or data using a common base format that supports tools such as ipptool
and ippeveprinter
.
The ippFileNew
function creates a new IPP data file (ipp_file_t
) object:
ipp_file_t *parent = NULL;
void *data;
ipp_file_t *file = ippFileNew(parent, attr_cb, error_cb, data);
The "parent" IPP data file pointer is typically used to support nested files and is normally NULL
for a new file. The "data" argument supplies your application data to the callbacks. The "attr_cb" callback function is used to filter IPP attributes; return true
to include the attribute and false
to ignore it:
bool
attr_cb(ipp_file_t *file, void *cb_data, const char *name)
{
... determine whether to use an attribute named "name" ...
}
The "error_cb" callback function is used to record/report errors when reading the file:
bool
error_cb(ipp_file_t *file, void *cb_data, const char *error)
{
... display/record error and return `true` to continue or `false` to stop ...
}
The ippFileOpen
function opens the specified data file and ippFileRead
reads from it:
if (ippFileOpen(file, "somefile", "r"))
{
// Opened successfully, now read it...
ippFileRead(file, token_cb, /*with_groups*/false);
ippFileClose(file);
}
The token callback function passed to ippFileRead
handles custom directives in your data file:
bool
token_cb(ipp_file_t *file, void *cb_data, const char *token)
{
... handle token, return `true` to continue or `false` to stop ...
}
The "token" parameter contains the token to be processed. The callback can use the ippFileReadToken
function to read additional tokens from the file and the ippFileExpandToken
function to expand any variables in the token string. Return false
to stop reading the file and true
to continue. The default NULL
callback reports an unknown token error through the error callback end returns false
.
Once read, you call the ippFileGetAttributes
function to get the IPP attributes from the file.
Each IPP data file object has associated variables that can be used when reading the file. The default set of variables is:
"date-current": Current date in ISO-8601 format
"date-start": Start date (when file opened) in ISO-8601 format
"filename": Associated data/document filename, if any
"filetype": MIME media type of associated data/document filename, if any
"hostname": Hostname or IP address from the "uri" value, if any
"port": Port number from the "uri" value, if any
"resource": Resource path from the "uri" value, if any
"scheme": URI scheme from the "uri" value, if any
"uri": URI, if any
"uriuser": Username from the "uri" value, if any
"uripassword": Password from the "uri" value, if any
"user": Current login user
The ippFileGetVar
, ippFileSetVar
, and ippFileSetVarf
functions get and set file variables, respectively.
As when reading an IPP data file, the ippFileNew
function creates a new file object, ippFileOpen
opens the file, and ippFileClose
closes the file. However, you call ippFileWriteAttributes
to write the attributes in an IPP message (ipp_t
), ippFileWriteComment
to write a comment in the file, and ippWriteToken
or ippWriteTokenf
to write a token or value to the file.
Add a destination to the list of destinations.
int cupsAddDest(const char *name, const char *instance, int num_dests, cups_dest_t **dests);
name | Destination name |
---|---|
instance | Instance name or NULL for none/primary |
num_dests | Number of destinations |
dests | Destinations |
New number of destinations
This function cannot be used to add a new class or printer queue,
it only adds a new container of saved options for the named
destination or instance.
If the named destination already exists, the destination list is
returned unchanged. Adding a new instance of a destination creates
a copy of that destination's options.
Use the cupsSetDests
function to save the updated list of
destinations to the user's lpoptions file.
Add the option corresponding to the specified media size.
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);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media matching flags |
size | Media size |
num_options | Current number of options |
options | Options |
New number of options
Add the options corresponding to the specified media information.
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);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media matching flags |
media | Media information |
num_options | Current number of options |
options | Options |
New number of options
Add an integer option to an option array.
int cupsAddIntegerOption(const char *name, int value, int num_options, cups_option_t **options);
name | Name of option |
---|---|
value | Value of option |
num_options | Number of options |
options | Pointer to options |
Number of options
New option arrays can be initialized simply by passing 0 for the "num_options" parameter.
Add an option to an option array.
int cupsAddOption(const char *name, const char *value, int num_options, cups_option_t **options);
name | Name of option |
---|---|
value | Value of option |
num_options | Number of options |
options | Pointer to options |
Number of options
New option arrays can be initialized simply by passing 0 for the "num_options" parameter.
Return whether the credentials are valid for the given name.
bool cupsAreCredentialsValidForName(const char *common_name, const char *credentials);
common_name | Name to check |
---|---|
credentials | Credentials |
true
if valid, false
otherwise
Add an element to the array.
int cupsArrayAdd(cups_array_t *a, void *e);
a | Array |
---|---|
e | Element |
1 on success, 0 on failure
When adding an element to a sorted array, non-unique elements are appended at the end of the run of identical elements. For unsorted arrays, the element is appended to the end of the array.
Add zero or more delimited strings to an array.
bool cupsArrayAddStrings(cups_array_t *a, const char *s, char delim);
a | Array |
---|---|
s | Delimited strings or NULL |
delim | Delimiter character |
true
on success, false
on failure
Note: The array MUST be created using the _cupsArrayNewStrings
function. Duplicate strings are NOT added. If the string pointer "s" is NULL
or the empty string, no strings are added to the array.
Clear the array.
void cupsArrayClear(cups_array_t *a);
a | Array |
---|
This function is equivalent to removing all elements in the array. The caller is responsible for freeing the memory used by the elements themselves.
Free all memory used by the array.
void cupsArrayDelete(cups_array_t *a);
a | Array |
---|
The caller is responsible for freeing the memory used by the elements themselves.
Duplicate the array.
cups_array_t *cupsArrayDup(cups_array_t *a);
a | Array |
---|
Duplicate array
Find an element in the array.
void *cupsArrayFind(cups_array_t *a, void *e);
a | Array |
---|---|
e | Element |
Element found or NULL
Get the number of elements in the array.
int cupsArrayGetCount(cups_array_t *a);
a | Array |
---|
Number of elements
Return the current element in the array.
void *cupsArrayGetCurrent(cups_array_t *a);
a | Array |
---|
Element
The current element is undefined until you call cupsArrayFind
,
cupsArrayFirst
, or cupsArrayIndex
, or cupsArrayLast
.
Get the N-th element in the array.
void *cupsArrayGetElement(cups_array_t *a, int n);
a | Array |
---|---|
n | Index into array, starting at 0 |
N-th element or NULL
Get the first element in the array.
void *cupsArrayGetFirst(cups_array_t *a);
a | Array |
---|
First element or NULL
if the array is empty
Get the index of the current element.
int cupsArrayGetIndex(cups_array_t *a);
a | Array |
---|
Index of the current element, starting at 0
The current element is undefined until you call cupsArrayFind
,
cupsArrayFirst
, or cupsArrayIndex
, or cupsArrayLast
.
Get the index of the last inserted element.
int cupsArrayGetInsert(cups_array_t *a);
a | Array |
---|
Index of the last inserted element, starting at 0
Get the last element in the array.
void *cupsArrayGetLast(cups_array_t *a);
a | Array |
---|
Last element or NULL
if the array is empty
Get the next element in the array.
void *cupsArrayGetNext(cups_array_t *a);
a | Array |
---|
Next element or NULL
This function is equivalent to "cupsArrayIndex(a, cupsArrayGetIndex(a) + 1)".
The next element is undefined until you call cupsArrayFind
,
cupsArrayFirst
, or cupsArrayIndex
, or cupsArrayLast
to set the current element.
Get the previous element in the array.
void *cupsArrayGetPrev(cups_array_t *a);
a | Array |
---|
Previous element or NULL
This function is equivalent to "cupsArrayIndex(a, cupsArrayGetIndex(a) - 1)".
The previous element is undefined until you call cupsArrayFind
,
cupsArrayFirst
, or cupsArrayIndex
, or cupsArrayLast
to set the current element.
Return the user data for an array.
void *cupsArrayGetUserData(cups_array_t *a);
a | Array |
---|
User data
Insert an element in the array.
int cupsArrayInsert(cups_array_t *a, void *e);
a | Array |
---|---|
e | Element |
0 on failure, 1 on success
When inserting an element in a sorted array, non-unique elements are inserted at the beginning of the run of identical elements. For unsorted arrays, the element is inserted at the beginning of the array.
Create a new array with optional compare, hash, copy, and/or free callbacks.
cups_array_t *cupsArrayNew3(cups_array_cb_t f, void *d, cups_ahash_cb_t h, int hsize, cups_acopy_cb_t cf, cups_afree_cb_t ff);
f | Comparison callback or NULL for an unsorted array |
---|---|
d | User data or NULL |
h | Hash callback or NULL for unhashed lookups |
hsize | Hash size (>= 0) |
cf | Copy callback |
ff | Free callback |
Array
This function creates a new array with optional compare, hash, copy, and free
callbacks. The comparison callback ("f") is used to create a sorted array.
The callback receives pointers to two elements and the user data pointer
("d").
The hash callback ("h") is used to implement cached lookups with the
specified hash size ("hsize").
The copy callback ("cf") is used to automatically copy/retain elements when
added or the array is duplicated with cupsArrayDup
.
The free callback ("cf") is used to automatically free/release elements when
removed with cupsArrayRemove
or the array is deleted with
cupsArrayDelete
.
Create a new array of delimited strings.
cups_array_t *cupsArrayNewStrings(const char *s, char delim);
s | Delimited strings or NULL |
---|---|
delim | Delimiter character |
Array
This function creates a new array of strings that are delimited by the
specified character. The array automatically manages copies of the strings
passed. If the string pointer "s" is NULL
or the empty string, no strings
are added to the newly created array.
Remove an element from the array.
int cupsArrayRemove(cups_array_t *a, void *e);
a | Array |
---|---|
e | Element |
1 on success, 0 on failure
If more than one element matches "e", only the first matching element is
removed.
The caller is responsible for freeing the memory used by the
removed element.
Reset the current element to the last cupsArraySave
.
void *cupsArrayRestore(cups_array_t *a);
a | Array |
---|
New current element
Mark the current element for a later cupsArrayRestore
.
int cupsArraySave(cups_array_t *a);
a | Array |
---|
1 on success, 0 on failure
The current element is undefined until you call cupsArrayFind
,
cupsArrayFirst
, or cupsArrayIndex
, or cupsArrayLast
to set the current element.
The save/restore stack is guaranteed to be at least 32 elements deep.
Cancel a job on a destination.
ipp_status_t cupsCancelDestJob(http_t *http, cups_dest_t *dest, int job_id);
http | Connection to destination |
---|---|
dest | Destination |
job_id | Job ID |
Status of cancel operation
The "job_id" is the number returned by cupsCreateDestJob.
Returns IPP_STATUS_OK
on success and
IPP_STATUS_ERROR_NOT_AUTHORIZED
or
IPP_STATUS_ERROR_FORBIDDEN
on failure.
Convert legacy character set to UTF-8.
int cupsCharsetToUTF8(cups_utf8_t *dest, const char *src, const int maxout, const cups_encoding_t encoding);
dest | Target string |
---|---|
src | Source string |
maxout | Max output |
encoding | Encoding |
Count or -1 on error
Check that the option and value are supported by the destination.
int cupsCheckDestSupported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option, const char *value);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
option | Option |
value | Value or NULL |
1 if supported, 0 otherwise
Returns 1 if supported, 0 otherwise.
Close a job and start printing.
ipp_status_t cupsCloseDestJob(http_t *http, cups_dest_t *dest, cups_dinfo_t *info, int job_id);
http | Connection to destination |
---|---|
dest | Destination |
info | Destination information |
job_id | Job ID |
IPP status code
Use when the last call to cupsStartDocument passed 0 for "last_document".
"job_id" is the job ID returned by cupsCreateDestJob. Returns IPP_STATUS_OK
on success.
Safely concatenate two UTF-8 strings.
size_t cupsConcatString(char *dst, const char *src, size_t dstsize);
dst | Destination string |
---|---|
src | Source string |
dstsize | Size of destination string buffer |
Length of string
Wake up waiting threads.
void cupsCondBroadcast(cups_cond_t *cond);
cond | Condition |
---|
Destroy a condition variable.
void cupsCondDestroy(cups_cond_t *cond);
cond | Condition |
---|
Initialize a condition variable.
void cupsCondInit(cups_cond_t *cond);
cond | Condition |
---|
Wait for a condition with optional timeout.
void cupsCondWait(cups_cond_t *cond, cups_mutex_t *mutex, double timeout);
cond | Condition |
---|---|
mutex | Mutex |
timeout | Timeout in seconds (0 or negative for none) |
Open a connection to the destination.
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);
dest | Destination |
---|---|
flags | Connection flags |
msec | Timeout in milliseconds |
cancel | Pointer to "cancel" variable |
resource | Resource buffer |
resourcesize | Size of resource buffer |
cb | Callback function |
user_data | User data pointer |
Connection to destination or NULL
Connect to the destination, returning a new http_t
connection object
and optionally the resource path to use for the destination. These calls
will block until a connection is made, the timeout expires, the integer
pointed to by "cancel" is non-zero, or the callback function (or block)
returns 0. The caller is responsible for calling httpClose
on the
returned connection.
Starting with CUPS 2.2.4, the caller can pass CUPS_DEST_FLAGS_DEVICE
for the "flags" argument to connect directly to the device associated with
the destination. Otherwise, the connection is made to the CUPS scheduler
associated with the destination.
char *cupsCopyCredentials(const char *path, const char *common_name);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name |
Copy the X.509 certificate chain to a string.
char *cupsCopyCredentialsKey(const char *path, const char *common_name);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name |
Copy the private key to a string.
Copy the public key for a X.509 certificate request.
char *cupsCopyCredentialsPublicKey(const char *path, const char *common_name);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name |
PEM-encoded public key
Copy the X.509 certificate signing request to a string.
char *cupsCopyCredentialsRequest(const char *path, const char *common_name);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name |
PEM-encoded X.509 certificate signing request
Copy a destination.
int cupsCopyDest(cups_dest_t *dest, int num_dests, cups_dest_t **dests);
dest | Destination to copy |
---|---|
num_dests | Number of destinations |
dests | Destination array |
New number of destinations
Make a copy of the destination to an array of destinations (or just a single copy) - for use with the cupsEnumDests* functions. The caller is responsible for calling cupsFreeDests() on the returned object(s).
Get conflicts and resolutions for a new option/value pair.
int cupsCopyDestConflicts(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, 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);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
num_options | Number of current options |
options | Current options |
new_option | New option |
new_value | New value |
num_conflicts | Number of conflicting options |
conflicts | Conflicting options |
num_resolved | Number of options to resolve |
resolved | Resolved options |
1 if there is a conflict, 0 if none, -1 on error
"num_options" and "options" represent the currently selected options by the
user. "new_option" and "new_value" are the setting the user has just
changed.
Returns 1 if there is a conflict, 0 if there are no conflicts, and -1 if
there was an unrecoverable error such as a resolver loop.
If "num_conflicts" and "conflicts" are not NULL
, they are set to
contain the list of conflicting option/value pairs. Similarly, if
"num_resolved" and "resolved" are not NULL
they will be set to the
list of changes needed to resolve the conflict.
If cupsCopyDestConflicts returns 1 but "num_resolved" and "resolved" are set
to 0 and NULL
, respectively, then the conflict cannot be resolved.
Get the supported values/capabilities for the destination.
cups_dinfo_t *cupsCopyDestInfo(http_t *http, cups_dest_t *dest);
http | Connection to destination |
---|---|
dest | Destination |
Destination information
The caller is responsible for calling cupsFreeDestInfo
on the return
value. NULL
is returned on error.
Get the supported values/capabilities for the destination.
cups_dinfo_t *cupsCopyDestInfo2(http_t *http, cups_dest_t *dest, cups_dest_flags_t dflags);
http | Connection to destination |
---|---|
dest | Destination |
dflags | Destination flags |
Destination information
The caller is responsible for calling cupsFreeDestInfo
on the return
value. NULL
is returned on error.
Safely copy a UTF-8 string.
size_t cupsCopyString(char *dst, const char *src, size_t dstsize);
dst | Destination string |
---|---|
src | Source string |
dstsize | Size of destination string buffer |
Length of string
Make an X.509 certificate and private key pair.
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, const char *email, size_t num_alt_names, const char *const *alt_names, const char *root_name, time_t expiration_date);
path | Directory path for certificate/key store or NULL for default |
---|---|
ca_cert | true to create a CA certificate, false for a client/server certificate |
purpose | Credential purposes |
type | Credential type |
usage | Credential usages |
organization | Organization or NULL to use common name |
org_unit | Organizational unit or NULL for none |
locality | City/town or NULL for "Unknown" |
state_province | State/province or NULL for "Unknown" |
country | Country or NULL for locale-based default |
common_name | Common name |
Email address or NULL for none | |
num_alt_names | Number of subject alternate names |
alt_names | Subject Alternate Names |
root_name | Root certificate/domain name or NULL for site/self-signed |
expiration_date | Expiration date |
true
on success, false
on failure
This function creates an X.509 certificate and private key pair. The
certificate and key are stored in the directory "path" or, if "path" is
NULL
, in a per-user or system-wide (when running as root) certificate/key
store. The generated certificate is signed by the named root certificate or,
if "root_name" is NULL
, a site-wide default root certificate. When
"root_name" is NULL
and there is no site-wide default root certificate, a
self-signed certificate is generated instead.
The "ca_cert" argument specifies whether a CA certificate should be created.
The "purpose" argument specifies the purpose(s) used for the credentials as a
bitwise OR of the following constants:
CUPS_CREDPURPOSE_SERVER_AUTH
for validating TLS servers,
CUPS_CREDPURPOSE_CLIENT_AUTH
for validating TLS clients,
CUPS_CREDPURPOSE_CODE_SIGNING
for validating compiled code,
CUPS_CREDPURPOSE_EMAIL_PROTECTION
for validating email messages,
CUPS_CREDPURPOSE_TIME_STAMPING
for signing timestamps to objects, and/or
CUPS_CREDPURPOSE_OCSP_SIGNING
for Online Certificate Status Protocol
message signing.The "type" argument specifies the type of credentials using one of the following constants:
CUPS_CREDTYPE_DEFAULT
: default type (RSA-3072 or P-384),
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, or
CUPS_CREDTYPE_ECDSA_P521_SHA256
: ECDSA using the P-521 curve with SHA-256 hash.The "usage" argument specifies the usage(s) for the credentials as a bitwise OR of the following constants:
CUPS_CREDUSAGE_DIGITAL_SIGNATURE
: digital signatures,
CUPS_CREDUSAGE_NON_REPUDIATION
: non-repudiation/content commitment,
CUPS_CREDUSAGE_KEY_ENCIPHERMENT
: key encipherment,
CUPS_CREDUSAGE_DATA_ENCIPHERMENT
: data encipherment,
CUPS_CREDUSAGE_KEY_AGREEMENT
: key agreement,
CUPS_CREDUSAGE_KEY_CERT_SIGN
: key certicate signing,
CUPS_CREDUSAGE_CRL_SIGN
: certificate revocation list signing,
CUPS_CREDUSAGE_ENCIPHER_ONLY
: encipherment only,
CUPS_CREDUSAGE_DECIPHER_ONLY
: decipherment only,
CUPS_CREDUSAGE_DEFAULT_CA
: defaults for CA certificates,
CUPS_CREDUSAGE_DEFAULT_TLS
: defaults for TLS certificates, and/or
CUPS_CREDUSAGE_ALL
: all usages.The "organization", "org_unit", "locality", "state_province", and "country"
arguments specify information about the identity and geolocation of the
issuer.
The "common_name" argument specifies the common name and the "num_alt_names"
and "alt_names" arguments specify a list of DNS hostnames for the
certificate.
The "expiration_date" argument specifies the expiration date and time as a
Unix time_t
value in seconds.
Make an X.509 Certificate Signing Request.
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, const char *email, size_t num_alt_names, const char *const *alt_names);
path | Directory path for certificate/key store or NULL for default |
---|---|
purpose | Credential purposes |
type | Credential type |
usage | Credential usages |
organization | Organization or NULL to use common name |
org_unit | Organizational unit or NULL for none |
locality | City/town or NULL for "Unknown" |
state_province | State/province or NULL for "Unknown" |
country | Country or NULL for locale-based default |
common_name | Common name |
Email address or NULL for none | |
num_alt_names | Number of subject alternate names |
alt_names | Subject Alternate Names |
true
on success, false
on error
This function creates an X.509 certificate signing request (CSR) and
associated private key. The CSR and key are stored in the directory "path"
or, if "path" is NULL
, in a per-user or system-wide (when running as root)
certificate/key store.
The "purpose" argument specifies the purpose(s) used for the credentials as a
bitwise OR of the following constants:
CUPS_CREDPURPOSE_SERVER_AUTH
for validating TLS servers,
CUPS_CREDPURPOSE_CLIENT_AUTH
for validating TLS clients,
CUPS_CREDPURPOSE_CODE_SIGNING
for validating compiled code,
CUPS_CREDPURPOSE_EMAIL_PROTECTION
for validating email messages,
CUPS_CREDPURPOSE_TIME_STAMPING
for signing timestamps to objects, and/or
CUPS_CREDPURPOSE_OCSP_SIGNING
for Online Certificate Status Protocol
message signing.The "type" argument specifies the type of credentials using one of the following constants:
CUPS_CREDTYPE_DEFAULT
: default type (RSA-3072 or P-384),
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, or
CUPS_CREDTYPE_ECDSA_P521_SHA256
: ECDSA using the P-521 curve with SHA-256 hash.The "usage" argument specifies the usage(s) for the credentials as a bitwise OR of the following constants:
CUPS_CREDUSAGE_DIGITAL_SIGNATURE
: digital signatures,
CUPS_CREDUSAGE_NON_REPUDIATION
: non-repudiation/content commitment,
CUPS_CREDUSAGE_KEY_ENCIPHERMENT
: key encipherment,
CUPS_CREDUSAGE_DATA_ENCIPHERMENT
: data encipherment,
CUPS_CREDUSAGE_KEY_AGREEMENT
: key agreement,
CUPS_CREDUSAGE_KEY_CERT_SIGN
: key certicate signing,
CUPS_CREDUSAGE_CRL_SIGN
: certificate revocation list signing,
CUPS_CREDUSAGE_ENCIPHER_ONLY
: encipherment only,
CUPS_CREDUSAGE_DECIPHER_ONLY
: decipherment only,
CUPS_CREDUSAGE_DEFAULT_CA
: defaults for CA certificates,
CUPS_CREDUSAGE_DEFAULT_TLS
: defaults for TLS certificates, and/or
CUPS_CREDUSAGE_ALL
: all usages.The "organization", "org_unit", "locality", "state_province", and "country"
arguments specify information about the identity and geolocation of the
issuer.
The "common_name" argument specifies the common name and the "num_alt_names"
and "alt_names" arguments specify a list of DNS hostnames for the
certificate.
Create a job on a destination.
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);
http | Connection to destination |
---|---|
dest | Destination |
info | Destination information |
job_id | Job ID or 0 on error |
title | Job name |
num_options | Number of job options |
options | Job options |
IPP status code
Returns IPP_STATUS_OK
or IPP_STATUS_OK_SUBST
on success, saving the job ID
in the variable pointed to by "job_id".
Creates a temporary file descriptor.
int cupsCreateTempFd(const char *prefix, const char *suffix, char *filename, size_t len);
prefix | Filename prefix or NULL for none |
---|---|
suffix | Filename suffix or NULL for none |
filename | Pointer to buffer |
len | Size of buffer |
New file descriptor or -1
on error
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.
Creates a temporary CUPS file.
cups_file_t *cupsCreateTempFile(const char *prefix, const char *suffix, char *filename, size_t len);
prefix | Filename prefix or NULL for none |
---|---|
suffix | Filename suffix or NULL for none |
filename | Pointer to buffer |
len | Size of buffer |
CUPS file or NULL
on error
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.
Create a full service name from the instance name, registration type, and domain.
bool cupsDNSSDAssembleFullName(char *fullname, size_t fullsize, const char *name, const char *type, const char *domain);
fullname | Buffer for full name |
---|---|
fullsize | Size of buffer |
name | Service instance name |
type | Registration type |
domain | Domain |
true
on success, false
on failure
This function combines an instance name ("Example Name"), registration type ("_ipp._tcp"), and domain ("local.") to create a properly escaped full service name ("Example032Name._ipp._tcp.local.").
Cancel and delete a browse request.
void cupsDNSSDBrowseDelete(cups_dnssd_browse_t *browse);
browse | Browse request |
---|
Get the DNS-SD context for the browse request.
cups_dnssd_t *cupsDNSSDBrowseGetContext(cups_dnssd_browse_t *browse);
browse | Browse request |
---|
Context or NULL
Create a new DNS-SD browse request.
cups_dnssd_browse_t *cupsDNSSDBrowseNew(cups_dnssd_t *dnssd, uint32_t if_index, const char *types, const char *domain, cups_dnssd_browse_cb_t browse_cb, void *cb_data);
dnssd | DNS-SD context |
---|---|
if_index | Interface index, CUPS_DNSSD_IF_INDEX_ANY , or CUPS_DNSSD_IF_INDEX_LOCAL |
types | Service types |
domain | Domain name or NULL for default |
browse_cb | Browse callback function |
cb_data | Browse callback data |
Browse request or NULL
on error
This function creates a new DNS-SD browse request for the specified service
types and optional domain and interface index. The "types" argument can be a
single service type ("_ipp._tcp") or a service type and comma-delimited list
of sub-types ("_ipp._tcp,_print,_universal").
Newly discovered services are reported using the required browse callback
function, with the "flags" argument set to CUPS_DNSSD_FLAGS_ADD
for newly
discovered services, CUPS_DNSSD_FLAGS_NONE
for removed services, or
CUPS_DNSSD_FLAGS_ERROR
on an error:
void browse_cb( cups_dnssd_browse_t *browse, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *name, const char *regtype, const char *domain) { // Process added/removed service }
Copy the current human-readable name for the system.
char *cupsDNSSDCopyComputerName(cups_dnssd_t *dnssd, char *buffer, size_t bufsize);
dnssd | DNS-SD context |
---|---|
buffer | Computer name buffer |
bufsize | Size of computer name buffer (at least 128 bytes) |
Computer name or NULL
on error
This function copies the current human-readable name ("My Computer") to the
provided buffer. The "dnssd" parameter is a DNS-SD context created with
cupsDNSSDNew
. The "buffer" parameter points to a character array of
at least 128 bytes and the "bufsize" parameter specifies the actual size of
the array.
Copy the current mDNS hostname for the system.
char *cupsDNSSDCopyHostName(cups_dnssd_t *dnssd, char *buffer, size_t bufsize);
dnssd | DNS-SD context |
---|---|
buffer | Hostname buffer |
bufsize | Size of hostname buffer (at least 70 bytes) |
mDNS hostname or NULL
on error
This function copies the current mDNS hostname ("hostname.local") to the
provided buffer. The "dnssd" parameter is a DNS-SD context created with
cupsDNSSDNew
. The "buffer" parameter points to a character array of
at least 70 bytes and the "bufsize" parameter specifies the actual size of
the array.
Decode a TXT record into key/value pairs.
int cupsDNSSDDecodeTXT(const unsigned char *txtrec, uint16_t txtlen, cups_option_t **txt);
txtrec | TXT record data |
---|---|
txtlen | TXT record length |
txt | Key/value pairs |
Number of key/value pairs
This function converts the DNS TXT record encoding of key/value pairs into
cups_option_t
elements that can be accessed using the cupsGetOption
function and freed using the cupsFreeOptions
function.
Delete a DNS-SD context and all its requests.
void cupsDNSSDDelete(cups_dnssd_t *dnssd);
dnssd | DNS-SD context |
---|
Get the number of host name/network configuration changes seen.
size_t cupsDNSSDGetConfigChanges(cups_dnssd_t *dnssd);
dnssd | DNS-SD context |
---|
Number of host name changes
This function returns the number of host name or network configuration
changes that have been seen since the context was created. The value can be
used to track when local services need to be updated. Registered services
will also get a callback with the CUPS_DNSSD_FLAGS_HOST_CHANGE
bit set in
the "flags" argument for host name changes and/or
CUPS_DNSSD_FLAGS_NETWORK_CHANGE
for network changes.
Create a new DNS-SD context.
cups_dnssd_t *cupsDNSSDNew(cups_dnssd_error_cb_t error_cb, void *cb_data);
error_cb | Error callback function |
---|---|
cb_data | Error callback data |
DNS-SD context
This function creates a new DNS-SD context for browsing, querying, resolving,
and/or registering services. Call cupsDNSSDDelete
to stop any pending
browses, queries, or resolves, unregister any services, and free the DNS-SD
context.
Cancel and delete a query request.
void cupsDNSSDQueryDelete(cups_dnssd_query_t *query);
query | Query request |
---|
Get the DNS-SD context for the query request.
cups_dnssd_t *cupsDNSSDQueryGetContext(cups_dnssd_query_t *query);
query | Query request |
---|
DNS-SD context or NULL
Create a new query request.
cups_dnssd_query_t *cupsDNSSDQueryNew(cups_dnssd_t *dnssd, uint32_t if_index, const char *fullname, uint16_t rrtype, cups_dnssd_query_cb_t query_cb, void *cb_data);
dnssd | DNS-SD context |
---|---|
if_index | Interface index or CUPS_DNSSD_IF_INDEX_ANY or CUPS_DNSSD_IF_INDEX_LOCAL |
fullname | Full DNS name including types and domain |
rrtype | Record type to query (CUPS_DNSSD_RRTYPE_TXT , etc.) |
query_cb | Query callback function |
cb_data | Query callback data |
Query request or NULL
on error
This function creates a new DNS-SD query request for the specified full
service name and DNS record type. The "fullname" parameter specifies the
full DNS name of the service (instance name, type, and domain) being queried.
Responses to the query are reported using the required query callback
function with the "flags" argument set to CUPS_DNSSD_FLAGS_NONE
on success
or CUPS_DNSSD_FLAGS_ERROR
on error:
void query_cb( cups_dnssd_query_t *query, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, uint16_t rrtype, const void *qdata, uint16_t qlen) { // Process query record }
Cancel and free a resolve request.
void cupsDNSSDResolveDelete(cups_dnssd_resolve_t *res);
res | Resolve request |
---|
Get the DNS-SD context for the resolve request.
cups_dnssd_t *cupsDNSSDResolveGetContext(cups_dnssd_resolve_t *resolve);
resolve | Resolve request |
---|
DNS-SD context or NULL
Create a new DNS-SD resolve request.
cups_dnssd_resolve_t *cupsDNSSDResolveNew(cups_dnssd_t *dnssd, uint32_t if_index, const char *name, const char *type, const char *domain, cups_dnssd_resolve_cb_t resolve_cb, void *cb_data);
dnssd | DNS-SD context |
---|---|
if_index | Interface index or CUPS_DNSSD_IF_INDEX_ANY or CUPS_DNSSD_IF_INDEX_LOCAL |
name | Service name |
type | Service type |
domain | Domain name or NULL for default |
resolve_cb | Resolve callback function |
cb_data | Resolve callback data |
Resolve request or NULL
on error
This function creates a new DNS-SD resolver for the specified instance name,
service type, and optional domain and interface index. Resikved services
are reported using the required resolve callback function, with the "flags"
argument set to CUPS_DNSSD_FLAGS_NONE
on success or
CUPS_DNSSD_FLAGS_ERROR
on error:
void resolve_cb( cups_dnssd_resolve_t *resolve, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, int num_txt, cups_option_t *txt) { // Process resolved service }
Separate a full service name into an instance name, registration type, and domain.
bool cupsDNSSDSeparateFullName(const char *fullname, char *name, size_t namesize, char *type, size_t typesize, char *domain, size_t domainsize);
fullname | Full service name |
---|---|
name | Instance name buffer |
namesize | Size of instance name buffer |
type | Registration type buffer |
typesize | Size of registration type buffer |
domain | Domain name buffer |
domainsize | Size of domain name buffer |
true
on success, false
on error
This function separates a full service name such as "Example032Name._ipp._tcp.local.") into its instance name ("Example Name"), registration type ("_ipp._tcp"), and domain ("local.").
Add a service instance.
bool cupsDNSSDServiceAdd(cups_dnssd_service_t *service, const char *types, const char *domain, const char *host, uint16_t port, int num_txt, cups_option_t *txt);
service | Service |
---|---|
types | Service types |
domain | Domain name or NULL for default |
host | Host name or NULL for default |
port | Port number or 0 for none |
num_txt | Number of TXT record values |
txt | TXT record values |
true
on success, false
on failure
This function adds a service instance for the specified service types,
domain, host, and port. The "types" argument can be a single service type
("_ipp._tcp") or a service type and comma-delimited list of sub-types
("_ipp._tcp,_print,_universal").
Call the cupsDNSSDServicePublish
function after all service instances
have been added.
Cancel and free a service registration.
void cupsDNSSDServiceDelete(cups_dnssd_service_t *service);
service | Service |
---|
Get the DNS-SD context for the service registration.
cups_dnssd_t *cupsDNSSDServiceGetContext(cups_dnssd_service_t *service);
service | Service registration |
---|
DNS-SD context or NULL
Get the service instance name for the service registration.
const char *cupsDNSSDServiceGetName(cups_dnssd_service_t *service);
service | Service registration |
---|
Service instance name
Create a new named service.
cups_dnssd_service_t *cupsDNSSDServiceNew(cups_dnssd_t *dnssd, uint32_t if_index, const char *name, cups_dnssd_service_cb_t cb, void *cb_data);
dnssd | DNS-SD context |
---|---|
if_index | Interface index, CUPS_DNSSD_IF_INDEX_ANY , or CUPS_DNSSD_IF_INDEX_LOCAL |
name | Name of service |
cb | Service registration callback function |
cb_data | Service registration callback data |
Service or NULL
on error
This function creates a new DNS-SD service registration for the given service
instance name and interface. Specific services using the name are added
using the cupsDNSSDServiceAdd
function.
The required service callback is called for select events, with the "flags"
argument set to CUPS_DNSSD_FLAGS_NONE
for a successful registration,
CUPS_DNSSD_FLAGS_COLLISION
when there is a name collision, or
CUPS_DNSSD_FLAGS_ERROR
when there is a problem completing the service
registration.
Publish a service.
bool cupsDNSSDServicePublish(cups_dnssd_service_t *service);
service | Service |
---|
true
on success, false
on failure
This function publishes the DNS-SD services added using the
cupsDNSSDServiceAdd
function.
Set the geolocation (LOC record) of a service.
bool cupsDNSSDServiceSetLocation(cups_dnssd_service_t *service, const char *geo_uri);
service | Service |
---|---|
geo_uri | Geolocation as a 'geo:' URI |
true
on success, false
on failure
This function sets the geolocation of a service using a 'geo:' URI (RFC 5870)
of the form
'geo:LATITUDE,LONGITUDE[,ALTITUDE][;crs=CRSLABEL][;u=UNCERTAINTY]'. The
specified coordinates and uncertainty are converted into a DNS LOC record
for the service name label. Only the "wgs84" CRSLABEL string is supported.
You must call this function prior to cupsDNSSDServiceAdd
.
Close a directory.
void cupsDirClose(cups_dir_t *dp);
dp | Directory pointer |
---|
Open a directory.
cups_dir_t *cupsDirOpen(const char *directory);
directory | Directory name |
---|
Directory pointer or NULL
if the directory could not be opened.
Read the next directory entry.
cups_dentry_t *cupsDirRead(cups_dir_t *dp);
dp | Directory pointer |
---|
Directory entry or NULL
when there are no more
Rewind to the start of the directory.
void cupsDirRewind(cups_dir_t *dp);
dp | Directory pointer |
---|
Authenticate a request.
int cupsDoAuthentication(http_t *http, const char *method, const char *resource);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
method | Request method ("GET", "POST", "PUT") |
resource | Resource path |
0 on success, -1 on error
This function should be called in response to a HTTP_STATUS_UNAUTHORIZED
status, prior to resubmitting your request.
Do an IPP request with a file.
ipp_t *cupsDoFileRequest(http_t *http, ipp_t *request, const char *resource, const char *filename);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
request | IPP request |
resource | HTTP resource for POST |
filename | File to send or NULL for none |
Response data
This function sends the IPP request and attached file to the specified
server, retrying and authenticating as necessary. The request is freed with
ippDelete
.
Do an IPP request with file descriptors.
ipp_t *cupsDoIORequest(http_t *http, ipp_t *request, const char *resource, int infile, int outfile);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
request | IPP request |
resource | HTTP resource for POST |
infile | File to read from or -1 for none |
outfile | File to write to or -1 for none |
Response data
This function sends the IPP request with the optional input file "infile" to
the specified server, retrying and authenticating as necessary. The request
is freed with ippDelete
.
If "infile" is a valid file descriptor, cupsDoIORequest
copies
all of the data from the file after the IPP request message.
If "outfile" is a valid file descriptor, cupsDoIORequest
copies
all of the data after the IPP response message to the file.
Do an IPP request.
ipp_t *cupsDoRequest(http_t *http, ipp_t *request, const char *resource);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
request | IPP request |
resource | HTTP resource for POST |
Response data
This function sends the IPP request to the specified server, retrying
and authenticating as necessary. The request is freed with ippDelete
.
Encode a single option into an IPP attribute.
ipp_attribute_t *cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, const char *name, const char *value);
ipp | IPP request/response |
---|---|
group_tag | Attribute group |
name | Option name |
value | Option string value |
New attribute or NULL
on error
Encode printer options into IPP attributes.
void cupsEncodeOptions(ipp_t *ipp, int num_options, cups_option_t *options);
ipp | IPP request/response |
---|---|
num_options | Number of options |
options | Options |
This function adds operation, job, and then subscription attributes,
in that order. Use the cupsEncodeOptions2
function to add attributes
for a single group.
Encode printer options into IPP attributes for a group.
void cupsEncodeOptions2(ipp_t *ipp, int num_options, cups_option_t *options, ipp_tag_t group_tag);
ipp | IPP request/response |
---|---|
num_options | Number of options |
options | Options |
group_tag | Group to encode |
This function only adds attributes for a single group. Call this
function multiple times for each group, or use cupsEncodeOptions
to add the standard groups.
Get the current encryption settings.
http_encryption_t cupsEncryption(void);
Encryption settings
Enumerate available destinations with a callback function.
int cupsEnumDests(unsigned flags, int msec, int *cancel, cups_ptype_t type, cups_ptype_t mask, cups_dest_cb_t cb, void *user_data);
flags | Enumeration flags |
---|---|
msec | Timeout in milliseconds, -1 for indefinite |
cancel | Pointer to "cancel" variable |
type | Printer type bits |
mask | Mask for printer type bits |
cb | Callback function |
user_data | User data |
1 on success, 0 on failure
Destinations are enumerated from one or more sources. The callback function
receives the user_data
pointer and the destination pointer which can
be used as input to the cupsCopyDest
function. The function must
return 1 to continue enumeration or 0 to stop.
The type
and mask
arguments allow the caller to filter the
destinations that are enumerated. Passing 0 for both will enumerate all
printers. The constant CUPS_PTYPE_DISCOVERED
is used to filter on
destinations that are available but have not yet been added locally.
Enumeration happens on the current thread and does not return until all
destinations have been enumerated or the callback function returns 0.
Note: The callback function will likely receive multiple updates for the same
destinations - it is up to the caller to suppress any duplicate destinations.
Close a CUPS file.
int cupsFileClose(cups_file_t *fp);
fp | CUPS file |
---|
0 on success, -1 on error
Return the end-of-file status.
int cupsFileEOF(cups_file_t *fp);
fp | CUPS file |
---|
1 on end of file, 0 otherwise
Find a file using the specified path.
const char *cupsFileFind(const char *filename, const char *path, int executable, char *buffer, int bufsize);
filename | File to find |
---|---|
path | Colon/semicolon-separated path |
executable | 1 = executable files, 0 = any file/dir |
buffer | Filename buffer |
bufsize | Size of filename buffer |
Full path to file or NULL
if not found
This function allows the paths in the path string to be separated by
colons (UNIX standard) or semicolons (Windows standard) and stores the
result in the buffer supplied. If the file cannot be found in any of
the supplied paths, NULL
is returned. A NULL
path only
matches the current directory.
Flush pending output.
int cupsFileFlush(cups_file_t *fp);
fp | CUPS file |
---|
0 on success, -1 on error
Get a single character from a file.
int cupsFileGetChar(cups_file_t *fp);
fp | CUPS file |
---|
Character or -1 on end of file
Get a line from a configuration file.
char *cupsFileGetConf(cups_file_t *fp, char *buf, size_t buflen, char **value, int *linenum);
fp | CUPS file |
---|---|
buf | String buffer |
buflen | Size of string buffer |
value | Pointer to value |
linenum | Current line number |
Line read or NULL
on end of file or error
Get a CR and/or LF-terminated line that may contain binary data.
size_t cupsFileGetLine(cups_file_t *fp, char *buf, size_t buflen);
fp | File to read from |
---|---|
buf | Buffer |
buflen | Size of buffer |
Number of bytes on line or 0 on end of file
This function differs from cupsFileGets
in that the trailing CR
and LF are preserved, as is any binary data on the line. The buffer is
nul-terminated, however you should use the returned length to determine
the number of bytes on the line.
Get a CR and/or LF-terminated line.
char *cupsFileGets(cups_file_t *fp, char *buf, size_t buflen);
fp | CUPS file |
---|---|
buf | String buffer |
buflen | Size of string buffer |
Line read or NULL
on end of file or error
Return whether a file is compressed.
bool cupsFileIsCompressed(cups_file_t *fp);
fp | CUPS file |
---|
true
if file is compressed, false
otherwise
Temporarily lock access to a file.
int cupsFileLock(cups_file_t *fp, int block);
fp | CUPS file |
---|---|
block | 1 to wait for the lock, 0 to fail right away |
0 on success, -1 on error
Return the file descriptor associated with a CUPS file.
int cupsFileNumber(cups_file_t *fp);
fp | CUPS file |
---|
File descriptor
Open a CUPS file.
cups_file_t *cupsFileOpen(const char *filename, const char *mode);
filename | Name of file |
---|---|
mode | Open mode |
CUPS file or NULL
if the file or socket cannot be opened
The "mode" parameter can be "r" to read, "w" to write, overwriting any
existing file, "a" to append to an existing file or create a new file,
or "s" to open a socket connection.
When opening for writing ("w"), an optional number from 1 to 9 can be
supplied which enables Flate compression of the file. Compression is
not supported for the "a" (append) mode.
When opening for writing ("w") or append ("a"), an optional 'm###' suffix
can be used to set the permissions of the opened file.
When opening a socket connection, the filename is a string of the form
"address:port" or "hostname:port". The socket will make an IPv4 or IPv6
connection as needed, generally preferring IPv6 connections when there is
a choice.
Open a CUPS file using a file descriptor.
cups_file_t *cupsFileOpenFd(int fd, const char *mode);
fd | File descriptor |
---|---|
mode | Open mode |
CUPS file or NULL
if the file could not be opened
The "mode" parameter can be "r" to read, "w" to write, "a" to append,
or "s" to treat the file descriptor as a bidirectional socket connection.
When opening for writing ("w"), an optional number from 1 to 9 can be
supplied which enables Flate compression of the file. Compression is
not supported for the "a" (append) mode.
Peek at the next character from a file.
int cupsFilePeekChar(cups_file_t *fp);
fp | CUPS file |
---|
Character or -1 on end of file
Write a formatted string.
int cupsFilePrintf(cups_file_t *fp, const char *format, ...);
fp | CUPS file |
---|---|
format | Printf-style format string |
... | Additional args as necessary |
Number of bytes written or -1 on error
Write a character.
int cupsFilePutChar(cups_file_t *fp, int c);
fp | CUPS file |
---|---|
c | Character to write |
0 on success, -1 on error
Write a configuration line.
ssize_t cupsFilePutConf(cups_file_t *fp, const char *directive, const char *value);
fp | CUPS file |
---|---|
directive | Directive |
value | Value |
Number of bytes written or -1 on error
This function handles any comment escaping of the value.
Write a string.
int cupsFilePuts(cups_file_t *fp, const char *s);
fp | CUPS file |
---|---|
s | String to write |
Number of bytes written or -1 on error
Like the fputs
function, no newline is appended to the string.
Read from a file.
ssize_t cupsFileRead(cups_file_t *fp, char *buf, size_t bytes);
fp | CUPS file |
---|---|
buf | Buffer |
bytes | Number of bytes to read |
Number of bytes read or -1 on error
Set the current file position to the beginning of the file.
off_t cupsFileRewind(cups_file_t *fp);
fp | CUPS file |
---|
New file position or -1 on error
Seek in a file.
off_t cupsFileSeek(cups_file_t *fp, off_t pos);
fp | CUPS file |
---|---|
pos | Position in file |
New file position or -1 on error
Return a CUPS file associated with stderr.
cups_file_t *cupsFileStderr(void);
CUPS file
Return a CUPS file associated with stdin.
cups_file_t *cupsFileStdin(void);
CUPS file
Return a CUPS file associated with stdout.
cups_file_t *cupsFileStdout(void);
CUPS file
Return the current file position.
off_t cupsFileTell(cups_file_t *fp);
fp | CUPS file |
---|
File position
Unlock access to a file.
int cupsFileUnlock(cups_file_t *fp);
fp | CUPS file |
---|
0 on success, -1 on error
Write to a file.
ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, size_t bytes);
fp | CUPS file |
---|---|
buf | Buffer |
bytes | Number of bytes to write |
Number of bytes written or -1 on error
Find the default value(s) for the given option.
ipp_attribute_t *cupsFindDestDefault(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
option | Option/attribute name |
Default attribute or NULL
for none
The returned value is an IPP attribute. Use the ippGetBoolean
,
ippGetCollection
, ippGetCount
, ippGetDate
,
ippGetInteger
, ippGetOctetString
, ippGetRange
,
ippGetResolution
, ippGetString
, and ippGetValueTag
functions to inspect the default value(s) as needed.
Find the default value(s) for the given option.
ipp_attribute_t *cupsFindDestReady(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
option | Option/attribute name |
Default attribute or NULL
for none
The returned value is an IPP attribute. Use the ippGetBoolean
,
ippGetCollection
, ippGetCount
, ippGetDate
,
ippGetInteger
, ippGetOctetString
, ippGetRange
,
ippGetResolution
, ippGetString
, and ippGetValueTag
functions to inspect the default value(s) as needed.
Find the default value(s) for the given option.
ipp_attribute_t *cupsFindDestSupported(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
option | Option/attribute name |
Default attribute or NULL
for none
The returned value is an IPP attribute. Use the ippGetBoolean
,
ippGetCollection
, ippGetCount
, ippGetDate
,
ippGetInteger
, ippGetOctetString
, ippGetRange
,
ippGetResolution
, ippGetString
, and ippGetValueTag
functions to inspect the default value(s) as needed.
Finish the current document.
ipp_status_t cupsFinishDestDocument(http_t *http, cups_dest_t *dest, cups_dinfo_t *info);
http | Connection to destination |
---|---|
dest | Destination |
info | Destination information |
Status of document submission
Returns IPP_STATUS_OK
or IPP_STATUS_OK_SUBST
on success.
Decode URL-encoded form data.
int cupsFormDecode(const char *data, cups_option_t **vars);
data | URL-encoded form data |
---|---|
vars | Array of variables |
Number of variables
This function decodes URL-encoded form data, returning the number of
variables and a pointer to a cups_option_t
array of the variables.
Use the cupsFreeOptions
function to return the memory used when you
are done with the form variables.
Encode options as URL-encoded form data.
char *cupsFormEncode(const char *url, int num_vars, cups_option_t *vars);
url | URL or NULL for none |
---|---|
num_vars | Number of variables |
vars | Variables |
URL-encoded form data
This function encodes a CUPS options array as URL-encoded form data with an
optional URL prefix, returning an allocated string.
Use free
to return the memory used for the string.
Format a UTF-8 string into a fixed size buffer.
ssize_t cupsFormatString(char *buffer, size_t bufsize, const char *format, ...);
buffer | Output buffer |
---|---|
bufsize | Size of output buffer |
format | printf -style format string |
... | Additional arguments |
Number of bytes formatted
This function formats a UTF-8 string into a fixed size buffer, escaping special/control characters as needed so they can be safely displayed or logged.
Format a UTF-8 string into a fixed size buffer (va_list
version).
ssize_t cupsFormatStringv(char *buffer, size_t bufsize, const char *format, va_list ap);
buffer | Output buffer |
---|---|
bufsize | Size of output buffer |
format | printf-style format string |
ap | Pointer to additional arguments |
Number of bytes formatted
This function formats a UTF-8 string into a fixed size buffer using a variable argument pointer, escaping special/control characters as needed so they can be safely displayed or logged.
Free destination information obtained using
cupsCopyDestInfo
.
void cupsFreeDestInfo(cups_dinfo_t *dinfo);
dinfo | Destination information |
---|
Free the memory used by the list of destinations.
void cupsFreeDests(int num_dests, cups_dest_t *dests);
num_dests | Number of destinations |
---|---|
dests | Destinations |
Free memory used by job data.
void cupsFreeJobs(int num_jobs, cups_job_t *jobs);
num_jobs | Number of jobs |
---|---|
jobs | Jobs |
Free all memory used by options.
void cupsFreeOptions(int num_options, cups_option_t *options);
num_options | Number of options |
---|---|
options | Pointer to options |
Get a monotonic clock value in seconds.
double cupsGetClock(void);
Elapsed seconds
This function returns a monotonically increasing clock value in seconds. The first call will always return 0.0. Subsequent calls will return the number of seconds that have elapsed since the first call, regardless of system time changes, sleep, etc. The sub-second accuracy varies based on the operating system and hardware but is typically 10ms or better.
Return the expiration date of the credentials.
time_t cupsGetCredentialsExpiration(const char *credentials);
credentials | Credentials |
---|
Expiration date of credentials
Return a string describing the credentials.
char *cupsGetCredentialsInfo(const char *credentials, char *buffer, size_t bufsize);
credentials | Credentials |
---|---|
buffer | Buffer |
bufsize | Size of buffer |
Credentials description or NULL
on error
Return the trust of credentials.
http_trust_t cupsGetCredentialsTrust(const char *path, const char *common_name, const char *credentials, bool require_ca);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name for trust lookup |
credentials | Credentials |
require_ca | Require a CA-signed certificate? |
Level of trust
This function determines the level of trust for the supplied credentials.
The "path" parameter specifies the certificate/key store for known
credentials and certificate authorities. The "common_name" parameter
specifies the FQDN of the service being accessed such as
"printer.example.com". The "credentials" parameter provides the credentials
being evaluated, which are usually obtained with the
httpCopyPeerCredentials
function. The "require_ca" parameter
specifies whether a CA-signed certificate is required for trust.
The AllowAnyRoot
, AllowExpiredCerts
, TrustOnFirstUse
, and
ValidateCerts
options in the "client.conf" file (or corresponding
preferences file on macOS) control the trust policy, which defaults to
AllowAnyRoot=Yes, AllowExpiredCerts=No, TrustOnFirstUse=Yes, and
ValidateCerts=No. When the "require_ca" parameter is true
the AllowAnyRoot
and TrustOnFirstUse policies are turned off ("No").
The returned trust value can be one of the following:
HTTP_TRUST_OK
: Credentials are OK/trusted
HTTP_TRUST_INVALID
: Credentials are invalid
HTTP_TRUST_EXPIRED
: Credentials are expired
HTTP_TRUST_RENEWED
: Credentials have been renewed
HTTP_TRUST_UNKNOWN
: Credentials are unknown/newGet the named destination from the list.
cups_dest_t *cupsGetDest(const char *name, const char *instance, int num_dests, cups_dest_t *dests);
name | Destination name or NULL for the default destination |
---|---|
instance | Instance name or NULL |
num_dests | Number of destinations |
dests | Destinations |
Destination pointer or NULL
Use the cupsEnumDests
or cupsGetDests2
functions to get a
list of supported destinations for the current user.
Get a media name, dimension, and margins for a specific size.
int cupsGetDestMediaByIndex(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, int n, unsigned flags, cups_size_t *size);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
n | Media size number (0-based) |
flags | Media flags |
size | Media size information |
1 on success, 0 on failure
The flags
parameter determines which set of media are indexed. For
example, passing CUPS_MEDIA_FLAGS_BORDERLESS
will get the Nth
borderless size supported by the printer.
Get specific media information.
bool cupsGetDestMediaByIndex2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, size_t n, unsigned flags, cups_media_t *media);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
n | Media number (0-based) |
flags | Media flags |
media | Media information |
true
on success, false
on failure
The flags
parameter determines which set of media are indexed. For
example, passing CUPS_MEDIA_FLAGS_BORDERLESS
will get the Nth
borderless size supported by the printer.
Get media names, dimensions, and margins.
int cupsGetDestMediaByName(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *name, unsigned flags, cups_size_t *size);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
name | Media name |
flags | Media matching flags |
size | Media size information |
1 on match, 0 on failure
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 1 when there is a match and 0 if there is not a match.
Get media names, dimensions, and margins.
bool cupsGetDestMediaByName2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *name, unsigned flags, cups_media_t *media);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
name | Media name |
flags | Media matching flags |
media | Media information |
true
on match, false
on failure
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.
Get media names, dimensions, and margins.
int cupsGetDestMediaBySize(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, int width, int length, unsigned flags, cups_size_t *size);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
width | Media width in hundredths of of millimeters |
length | Media length in hundredths of of millimeters |
flags | Media matching flags |
size | Media size information |
1 on match, 0 on failure
"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 1 when there is a match and 0 if there is not a match.
Get media names, dimensions, and margins.
bool cupsGetDestMediaBySize2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, int width, int length, unsigned flags, cups_media_t *media);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
width | Media width in hundredths of millimeters |
length | Media length in hundredths of millimeters |
flags | Media matching flags |
media | Media information |
true
on match, false
on failure
"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.
Get the number of sizes supported by a destination.
int cupsGetDestMediaCount(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media flags |
Number of sizes
The flags
parameter determines the set of media sizes that are
counted. For example, passing CUPS_MEDIA_FLAGS_BORDERLESS
will return
the number of borderless sizes.
Get the default size for a destination.
int cupsGetDestMediaDefault(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media flags |
size | Media size information |
1 on success, 0 on failure
The flags
parameter determines which default size is returned. For
example, passing CUPS_MEDIA_FLAGS_BORDERLESS
will return the default
borderless size, typically US Letter or A4, but sometimes 4x6 photo media.
Get the default size for a destination.
bool cupsGetDestMediaDefault2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_media_t *media);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media flags |
media | Media information |
true
on match, false
on failure
The flags
parameter determines which default size is returned. For
example, passing CUPS_MEDIA_FLAGS_BORDERLESS
will return the default
borderless size, typically US Letter or A4, but sometimes 4x6 photo media.
Get a destination associated with a URI.
cups_dest_t *cupsGetDestWithURI(const char *name, const char *uri);
name | Desired printer name or NULL |
---|---|
uri | URI for the printer |
Destination or NULL
"name" is the desired name for the printer. If NULL
, a name will be
created using the URI.
"uri" is the "ipp" or "ipps" URI for the printer.
Get the list of destinations from the specified server.
int cupsGetDests2(http_t *http, cups_dest_t **dests);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
dests | Destinations |
Number of destinations
Starting with CUPS 1.2, the returned list of destinations include the
"printer-info", "printer-is-accepting-jobs", "printer-is-shared",
"printer-make-and-model", "printer-state", "printer-state-change-time",
"printer-state-reasons", "printer-type", and "printer-uri-supported"
attributes as options.
CUPS 1.4 adds the "marker-change-time", "marker-colors",
"marker-high-levels", "marker-levels", "marker-low-levels", "marker-message",
"marker-names", "marker-types", and "printer-commands" attributes as options.
CUPS 2.2 adds accessible IPP printers to the list of destinations that can
be used. The "printer-uri-supported" option will be present for those IPP
printers that have been recently used.
Use the cupsFreeDests
function to free the destination list and
the cupsGetDest
function to find a particular destination.
Get the current encryption settings.
http_encryption_t cupsGetEncryption(void);
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
HTTP_ENCRYPTION_IF_REQUESTED
.
Note: The current encryption setting is tracked separately for each thread
in a program. Multi-threaded programs that override the setting via the
cupsSetEncryption
function need to do so in each thread for the same
setting to be used.
Return the last IPP status code received on the current thread.
ipp_status_t cupsGetError(void);
IPP status code from last request
Return the last IPP status-message received on the current thread.
const char *cupsGetErrorString(void);
status-message text from last request
Get a file from the server.
http_status_t cupsGetFd(http_t *http, const char *resource, int fd);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
resource | Resource name |
fd | File descriptor |
HTTP status
This function returns HTTP_STATUS_OK
when the file is successfully retrieved.
Get a file from the server.
http_status_t cupsGetFile(http_t *http, const char *resource, const char *filename);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
resource | Resource name |
filename | Filename |
HTTP status
This function returns HTTP_STATUS_OK
when the file is successfully retrieved.
Get an integer option value.
int cupsGetIntegerOption(const char *name, int num_options, cups_option_t *options);
name | Name of option |
---|---|
num_options | Number of options |
options | Options |
Option value or INT_MIN
INT_MIN is returned when the option does not exist, is not an integer, or exceeds the range of values for the "int" type.
Get the jobs from the specified server.
int cupsGetJobs2(http_t *http, cups_job_t **jobs, const char *name, int myjobs, int whichjobs);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
jobs | Job data |
name | NULL = all destinations, otherwise show jobs for named destination |
myjobs | 0 = all users, 1 = mine |
whichjobs | CUPS_WHICHJOBS_ALL , CUPS_WHICHJOBS_ACTIVE , or CUPS_WHICHJOBS_COMPLETED |
Number of jobs
A "whichjobs" value of CUPS_WHICHJOBS_ALL
returns all jobs regardless
of state, while CUPS_WHICHJOBS_ACTIVE
returns jobs that are
pending, processing, or held and CUPS_WHICHJOBS_COMPLETED
returns
jobs that are stopped, canceled, aborted, or completed.
Get options for the named destination.
cups_dest_t *cupsGetNamedDest(http_t *http, const char *name, const char *instance);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
name | Destination name or NULL for the default destination |
instance | Instance name or NULL |
Destination or NULL
This function is optimized for retrieving a single destination and should
be used instead of cupsGetDests2
and cupsGetDest
when you
either know the name of the destination or want to print to the default
destination. If NULL
is returned, the destination does not exist or
there is no default destination.
If "http" is CUPS_HTTP_DEFAULT
, the connection to the default print
server will be used.
If "name" is NULL
, the default printer for the current user will be
returned.
The returned destination must be freed using cupsFreeDests
with a
"num_dests" value of 1.
Get an option value.
const char *cupsGetOption(const char *name, int num_options, cups_option_t *options);
name | Name of option |
---|---|
num_options | Number of options |
options | Options |
Option value or NULL
Get a password from the user using the current password callback.
const char *cupsGetPassword2(const char *prompt, http_t *http, const char *method, const char *resource);
prompt | Prompt string |
---|---|
http | Connection to server or CUPS_HTTP_DEFAULT |
method | Request method ("GET", "POST", "PUT") |
resource | Resource path |
Password
Uses the current password callback function. Returns NULL
if the
user does not provide a password.
Note: The current password callback function is tracked separately for each
thread in a program. Multi-threaded programs that override the setting via
the cupsSetPasswordCB2
function need to do so in each thread for the
same function to be used.
Return a 32-bit pseudo-random number.
unsigned cupsGetRand(void);
Random number
This function returns a 32-bit pseudo-random number suitable for use as one-time identifiers or nonces. The random numbers are generated/seeded using system entropy.
Get a response to an IPP request.
ipp_t *cupsGetResponse(http_t *http, const char *resource);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
resource | HTTP resource for POST |
Response or NULL
on HTTP error
Use this function to get the response for an IPP request sent using
cupsSendRequest
. For requests that return additional data, use
cupsReadResponseData
after getting a successful response,
otherwise call httpFlush
to complete the response processing.
Return the hostname/address of the current server.
const char *cupsGetServer(void);
Server name
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
cupsSetServer
function need to do so in each thread for the same
server to be used.
Return the current user's name.
const char *cupsGetUser(void);
User 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
cupsSetUser
function need to do so in each thread for the same user
name to be used.
Return the default HTTP User-Agent string.
const char *cupsGetUserAgent(void);
User-Agent string
Perform a HMAC function on the given data.
ssize_t cupsHMACData(const char *algorithm, const unsigned char *key, size_t keylen, const void *data, size_t datalen, unsigned char *hmac, size_t hmacsize);
algorithm | Hash algorithm |
---|---|
key | Key |
keylen | Length of key |
data | Data to hash |
datalen | Length of data to hash |
hmac | HMAC buffer |
hmacsize | Size of HMAC buffer |
The length of the HMAC or -1
on error
This function performs a HMAC function on the given data with the given key.
The "algorithm" argument can be any of the registered, non-deprecated IPP
hash algorithms for the "job-password-encryption" attribute, including
"sha" for SHA-1, "sha2-256" for SHA2-256, etc.
The "hmac" argument points to a buffer of "hmacsize" bytes and should be at
least 64 bytes in length for all of the supported algorithms.
The returned HMAC is binary data.
Perform a hash function on the given data.
ssize_t cupsHashData(const char *algorithm, const void *data, size_t datalen, unsigned char *hash, size_t hashsize);
algorithm | Algorithm name |
---|---|
data | Data to hash |
datalen | Length of data to hash |
hash | Hash buffer |
hashsize | Size of hash buffer |
Size of hash or -1 on error
This function performs a hash function on the given data. The "algorithm"
argument can be any of the registered, non-deprecated IPP hash algorithms for
the "job-password-encryption" attribute, including "sha" for SHA-1,
"sha2-256" for SHA2-256, etc.
The "hash" argument points to a buffer of "hashsize" bytes and should be at
least 64 bytes in length for all of the supported algorithms.
The returned hash is binary data.
Format a hash value as a hexadecimal string.
const char *cupsHashString(const unsigned char *hash, size_t hashsize, char *buffer, size_t bufsize);
hash | Hash |
---|---|
hashsize | Size of hash |
buffer | String buffer |
bufsize | Size of string buffer |
Formatted string
The passed buffer must be at least 2 * hashsize + 1 characters in length.
Add a node to a JSON node.
void cupsJSONAdd(cups_json_t *parent, cups_json_t *after, cups_json_t *node);
parent | Parent JSON node |
---|---|
after | Previous sibling node or NULL to append to the end |
node | JSON node to add |
This function adds an existing JSON node as a child of other JSON node.
The "parent" argument specifies the node to add to. The "after" argument
specifies a child of the parent node or NULL
to append to the end of the
children.
Note: The node being added must not already be the child of another parent.
Delete a JSON node and all of its children.
void cupsJSONDelete(cups_json_t *json);
json | JSON node |
---|
Save a JSON node tree to a file.
bool cupsJSONExportFile(cups_json_t *json, const char *filename);
json | JSON root node |
---|---|
filename | JSON filename |
true
on success, false
on failure
Save a JSON node tree to a string.
char *cupsJSONExportString(cups_json_t *json);
json | JSON root node |
---|
JSON string or NULL
on error
This function saves a JSON node tree to an allocated string. The resulting
string must be freed using the free
function.
Find the value(s) associated with a given key.
cups_json_t *cupsJSONFind(cups_json_t *json, const char *key);
json | JSON object node |
---|---|
key | Object key |
JSON value or NULL
Get the first child node of an array or object node.
cups_json_t *cupsJSONGetChild(cups_json_t *json, size_t n);
json | JSON array or object node |
---|---|
n | Child node number (starting at 0 ) |
First child node or NULL
Get the number of child nodes.
size_t cupsJSONGetCount(cups_json_t *json);
json | JSON array or object node |
---|
Number of child nodes
Get the key string, if any.
const char *cupsJSONGetKey(cups_json_t *json);
json | JSON string node |
---|
String value
This function returns the key string for a JSON key node or NULL
if
the node is not a key.
Get the number value, if any.
double cupsJSONGetNumber(cups_json_t *json);
json | JSON number node |
---|
Number value
This function returns the number value for a JSON number node or 0.0
if
the node is not a number.
Get the parent node, if any.
cups_json_t *cupsJSONGetParent(cups_json_t *json);
json | JSON node |
---|
Parent node or NULL
if none
Get the next sibling node, if any.
cups_json_t *cupsJSONGetSibling(cups_json_t *json);
json | JSON node |
---|
Sibling node or NULL
if none
Get the string value, if any.
const char *cupsJSONGetString(cups_json_t *json);
json | JSON string node |
---|
String value
This function returns the string value for a JSON string node or NULL
if
the node is not a string.
Get the type of a JSON node.
cups_jtype_t cupsJSONGetType(cups_json_t *json);
json | JSON node |
---|
JSON node type
Load a JSON object file.
cups_json_t *cupsJSONImportFile(const char *filename);
filename | JSON filename |
---|
Root JSON object node
Load a JSON object from a string.
cups_json_t *cupsJSONImportString(const char *s);
s | JSON string |
---|
Root JSON object node
Load a JSON object from a URL.
cups_json_t *cupsJSONImportURL(const char *url, time_t *last_modified);
url | URL |
---|---|
last_modified | Last modified date/time or NULL |
Root JSON object node
This function loads a JSON object from a URL. The "url" can be a "http:" or
"https:" URL. The "last_modified" argument provides a pointer to a time_t
variable with the last modified date and time from a previous load. If
NULL
or the variable has a value of 0, the JSON is loaded unconditionally
from the URL.
On success, a pointer to the root JSON object node is returned and the
"last_modified" variable, if not NULL
, is updated to the Last-Modified
date and time returned by the server. Otherwise, NULL
is returned with
the cupsGetError
value set to IPP_STATUS_OK_EVENTS_COMPLETE
if
the JSON data has not been updated since the "last_modified" date and time
or a suitable IPP_STATUS_ERROR_
value if an error occurred.
Create a new JSON node.
cups_json_t *cupsJSONNew(cups_json_t *parent, cups_json_t *after, cups_jtype_t type);
parent | Parent JSON node or NULL for a root node |
---|---|
after | Previous sibling node or NULL to append to the end |
type | JSON node type |
JSON node
Create a new JSON key node.
cups_json_t *cupsJSONNewKey(cups_json_t *parent, cups_json_t *after, const char *value);
parent | Parent JSON node or NULL for a root node |
---|---|
after | Previous sibling node or NULL to append to the end |
value | Key string |
JSON node
Create a new JSON number node.
cups_json_t *cupsJSONNewNumber(cups_json_t *parent, cups_json_t *after, double value);
parent | Parent JSON node or NULL for a root node |
---|---|
after | Previous sibling node or NULL to append to the end |
value | Number value |
JSON node
Create a new JSON string node.
cups_json_t *cupsJSONNewString(cups_json_t *parent, cups_json_t *after, const char *value);
parent | Parent JSON node or NULL for a root node |
---|---|
after | Previous sibling node or NULL to append to the end |
value | String value |
JSON node
Free the memory used for a JSON Web Token.
void cupsJWTDelete(cups_jwt_t *jwt);
jwt | JWT object |
---|
Export a JWT with the JWS Compact or JWS JSON (Flattened) Serialization format.
char *cupsJWTExportString(cups_jwt_t *jwt, cups_jws_format_t format);
jwt | JWT object |
---|---|
format | JWS serialization format |
JWT/JWS Serialization string
This function exports a JWT to a JWS Compact or JWS JSON Serialization
string. The JSON output is always the "flattened" format since the JWT
only contains a single signature.
The return value must be freed using the free
function.
Get the signature algorithm used by a JSON Web Token.
cups_jwa_t cupsJWTGetAlgorithm(cups_jwt_t *jwt);
jwt | JWT object |
---|
Signature algorithm
Get the number value of a claim.
double cupsJWTGetClaimNumber(cups_jwt_t *jwt, const char *claim);
jwt | JWT object |
---|---|
claim | Claim name |
Number value
Get the string value of a claim.
const char *cupsJWTGetClaimString(cups_jwt_t *jwt, const char *claim);
jwt | JWT object |
---|---|
claim | Claim name |
String value
Get the value type of a claim.
cups_jtype_t cupsJWTGetClaimType(cups_jwt_t *jwt, const char *claim);
jwt | JWT object |
---|---|
claim | Claim name |
JSON value type
Get the value node of a claim.
cups_json_t *cupsJWTGetClaimValue(cups_jwt_t *jwt, const char *claim);
jwt | JWT object |
---|---|
claim | Claim name |
JSON value node
Get the JWT claims as a JSON object.
cups_json_t *cupsJWTGetClaims(cups_jwt_t *jwt);
jwt | JWT object |
---|
JSON object
Get the number value of a protected header.
double cupsJWTGetHeaderNumber(cups_jwt_t *jwt, const char *header);
jwt | JWT object |
---|---|
header | Header name |
Number value
Get the string value of a protected header.
const char *cupsJWTGetHeaderString(cups_jwt_t *jwt, const char *header);
jwt | JWT object |
---|---|
header | Header name |
String value
Get the value type of a protected header.
cups_jtype_t cupsJWTGetHeaderType(cups_jwt_t *jwt, const char *header);
jwt | JWT object |
---|---|
header | Header name |
JSON value type
Get the value node of a protected header.
cups_json_t *cupsJWTGetHeaderValue(cups_jwt_t *jwt, const char *header);
jwt | JWT object |
---|---|
header | Header name |
JSON value node
Get the JWT protected headers as a JSON object.
cups_json_t *cupsJWTGetHeaders(cups_jwt_t *jwt);
jwt | JWT object |
---|
JSON object
Determine whether the JWT has a valid signature.
bool cupsJWTHasValidSignature(cups_jwt_t *jwt, cups_json_t *jwk);
jwt | JWT object |
---|---|
jwk | JWK key set |
true
if value, false
otherwise
Import a JSON Web Token or JSON Web Signature.
cups_jwt_t *cupsJWTImportString(const char *s, cups_jws_format_t format);
s | JWS string |
---|---|
format | JWS serialization format |
JWT object
Load X.509 credentials and private key into a JSON Web Key for signing.
cups_json_t *cupsJWTLoadCredentials(const char *path, const char *common_name);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name |
JSON Web Key of NULL
on error
Make a JSON Web Key for encryption and signing.
cups_json_t *cupsJWTMakePrivateKey(cups_jwa_t alg);
alg | Signing/encryption algorithm |
---|
Private JSON Web Key or NULL
on error
This function makes a JSON Web Key (JWK) for the specified JWS/JWE algorithm
for use when signing or encrypting JSON Web Tokens. The resulting JWK
must not be provided to clients - instead, call cupsJWTMakePublicKey
to produce a public key subset suitable for verification and decryption.
Make a JSON Web Key for decryption and verification.
cups_json_t *cupsJWTMakePublicKey(cups_json_t *jwk);
jwk | Private JSON Web Key |
---|
Public JSON Web Key or NULL
on error
This function makes a public JSON Web Key (JWK) from the specified private JWK suitable for use when decrypting or verifying a JWE/JWS message.
Create a new, empty JSON Web Token.
cups_jwt_t *cupsJWTNew(const char *type, cups_json_t *claims);
type | JWT type or NULL for default ("JWT") |
---|---|
claims | JSON claims or NULL for empty |
JWT object
Set a claim number.
void cupsJWTSetClaimNumber(cups_jwt_t *jwt, const char *claim, double value);
jwt | JWT object |
---|---|
claim | Claim name |
value | Number value |
Set a claim string.
void cupsJWTSetClaimString(cups_jwt_t *jwt, const char *claim, const char *value);
jwt | JWT object |
---|---|
claim | Claim name |
value | String value |
Set a claim value.
void cupsJWTSetClaimValue(cups_jwt_t *jwt, const char *claim, cups_json_t *value);
jwt | JWT object |
---|---|
claim | Claim name |
value | JSON value node |
Set a protected header number.
void cupsJWTSetHeaderNumber(cups_jwt_t *jwt, const char *header, double value);
jwt | JWT object |
---|---|
header | Header name |
value | Number value |
Set a protected header string.
void cupsJWTSetHeaderString(cups_jwt_t *jwt, const char *header, const char *value);
jwt | JWT object |
---|---|
header | Header name |
value | String value |
Set a protected header value.
void cupsJWTSetHeaderValue(cups_jwt_t *jwt, const char *header, cups_json_t *value);
jwt | JWT object |
---|---|
header | Header name |
value | JSON value node |
Sign a JSON Web Token, creating a JSON Web Signature.
bool cupsJWTSign(cups_jwt_t *jwt, cups_jwa_t alg, cups_json_t *jwk);
jwt | JWT object |
---|---|
alg | Signing algorithm |
jwk | JWK key set |
true
on success, false
on error
Return the default language.
cups_lang_t *cupsLangDefault(void);
Language data
Return the character encoding (us-ascii, etc.) for the given language.
const char *cupsLangEncoding(cups_lang_t *lang);
lang | Language data |
---|
Character encoding
Flush all language data out of the cache.
void cupsLangFlush(void);
Free language data.
void cupsLangFree(cups_lang_t *lang);
lang | Language to free |
---|
This does not actually free anything; use cupsLangFlush
for that.
Get a language.
cups_lang_t *cupsLangGet(const char *language);
language | Language or locale |
---|
Language data
Return the last IPP status code received on the current thread.
ipp_status_t cupsLastError(void);
IPP status code from last request
Return the last IPP status-message received on the current thread.
const char *cupsLastErrorString(void);
status-message text from last request
Get the localized string for a destination media size.
const char *cupsLocalizeDestMedia(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_size_t *size);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media flags |
size | Media size |
Localized string
This function returns the localized string for the specified media size
information.
The returned string is stored in the destination information and will become
invalid if the destination information is deleted.
Get the localized string for a destination media.
const char *cupsLocalizeDestMedia2(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, unsigned flags, cups_media_t *media);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
flags | Media flags |
media | Media |
Localized string
This function returns the localized string for the specified media
information.
The returned string is stored in the destination information and will become
invalid if the destination information is deleted.
Get the localized string for a destination option.
const char *cupsLocalizeDestOption(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
option | Option to localize |
Localized string
The returned string is stored in the destination information and will become invalid if the destination information is deleted.
Get the localized string for a destination option+value pair.
const char *cupsLocalizeDestValue(http_t *http, cups_dest_t *dest, cups_dinfo_t *dinfo, const char *option, const char *value);
http | Connection to destination |
---|---|
dest | Destination |
dinfo | Destination information |
option | Option to localize |
value | Value to localize |
Localized string
The returned string is stored in the destination information and will become invalid if the destination information is deleted.
Destroy a mutex.
void cupsMutexDestroy(cups_mutex_t *mutex);
mutex | Mutex |
---|
Initialize a mutex.
void cupsMutexInit(cups_mutex_t *mutex);
mutex | Mutex |
---|
Lock a mutex.
void cupsMutexLock(cups_mutex_t *mutex);
mutex | Mutex |
---|
Unlock a mutex.
void cupsMutexUnlock(cups_mutex_t *mutex);
mutex | Mutex |
---|
Return the subject for the given notification message.
char *cupsNotifySubject(cups_lang_t *lang, ipp_t *event);
lang | Language data |
---|---|
event | Event data |
Subject string or NULL
The returned string must be freed by the caller using free
.
Return the text for the given notification message.
char *cupsNotifyText(cups_lang_t *lang, ipp_t *event);
lang | Language data |
---|---|
event | Event data |
Message text or NULL
The returned string must be freed by the caller using free
.
Clear any cached authorization information.
void cupsOAuthClearTokens(const char *auth_uri, const char *resource_uri);
auth_uri | Authorization server URI |
---|---|
resource_uri | Resource server URI |
This function clears cached authorization information for the given Authorization Server "auth_uri" and Resource "resource_uri" combination.
Get a cached access token.
char *cupsOAuthCopyAccessToken(const char *auth_uri, const char *resource_uri, time_t *access_expires);
auth_uri | Authorization Server URI |
---|---|
resource_uri | Resource URI |
access_expires | Access expiration time or NULL for don't care |
Access token
This function makes a copy of a cached access token and any
associated expiration time for the given Authorization Server "auth_uri" and
Resource "resource_uri" combination. The returned access token must be freed
using the free
function.
NULL
is returned if no token is cached.
Get the cached client_id
value.
char *cupsOAuthCopyClientId(const char *auth_uri, const char *redirect_uri);
auth_uri | Authorization Server URI |
---|---|
redirect_uri | Redirection URI |
client_id
value
This function makes a copy of the cached client_id
value for a given
Authorization Server "auth_uri" and Redirection URI "resource_uri". The
returned value must be freed using the free
function.
NULL
is returned if no client_id
is cached.
Get a cached refresh token.
char *cupsOAuthCopyRefreshToken(const char *auth_uri, const char *resource_uri);
auth_uri | Authorization Server URI |
---|---|
resource_uri | Resource URI |
Refresh token
This function makes a copy of a cached refresh token for the given
given Authorization Server "auth_uri" and Resource "resource_uri"
combination. The returned refresh token must be freed using the free
function.
NULL
is returned if no refresh token is cached.
Get cached user identification information.
cups_jwt_t *cupsOAuthCopyUserId(const char *auth_uri, const char *resource_uri);
auth_uri | Authorization Server URI |
---|---|
resource_uri | Resource URI |
Identification information
This function makes a copy of cached user identification information for the
given Authorization Server "auth_uri" and Resource "resource_uri"
combination. The returned user information must be freed using the
cupsJWTDelete
function.
NULL
is returned if no identification information is cached.
Authorize access using a web browser.
char *cupsOAuthGetAuthorizationCode(const char *auth_uri, cups_json_t *metadata, const char *resource_uri, const char *scopes, const char *redirect_uri);
auth_uri | Authorization Server URI |
---|---|
metadata | Authorization Server metadata |
resource_uri | Resource URI |
scopes | Space-delimited scopes |
redirect_uri | Redirect URI or NULL for default |
Authorization code or NULL
on error
This function performs a local/"native" OAuth authorization flow to obtain an
authorization code for use with the cupsOAuthGetTokens
function.
The "auth_uri" parameter specifies the URI for the OAuth Authorization
Server. The "metadata" parameter specifies the Authorization Server metadata
as obtained using cupsOAuthCopyMetadata
and/or
cupsOAuthGetMetadata
.
The "resource_uri" parameter specifies the URI for a resource (printer, web
file, etc.) that you which to access.
The "scopes" parameter specifies zero or more whitespace-delimited scope
names to request during authorization. The list of supported scope names are
available from the Authorization Server metadata, for example:
cups_json_t *metadata = cupsOAuthGetMetadata(auth_uri); cups_json_t *scopes_supported = cupsJSONFind(metadata, "scopes_supported");The "redirect_uri" parameter specifies a 'http:' URL with a listen address, port, and path to use. If
NULL
, 127.0.0.1 on a random port is used with a
path of "/".free
function.
Register a client application and get its ID.
char *cupsOAuthGetClientId(const char *auth_uri, cups_json_t *metadata, const char *redirect_uri, const char *logo_uri, const char *tos_uri);
auth_uri | Authorization Server URI |
---|---|
metadata | Authorization Server metadata |
redirect_uri | Redirection URL |
logo_uri | Logo URL or NULL for none |
tos_uri | Terms-of-service URL or NULL for none |
client_id
string or NULL
on error
This function registers a client application with the specified OAuth
Authorization Server.
The "auth_uri" parameter specifies the URI for the OAuth Authorization
Server. The "metadata" parameter specifies the Authorization Server metadata
as obtained using cupsOAuthCopyMetadata
and/or
cupsOAuthGetMetadata
.
The "redirect_uri" argument specifies the URL to use for providing
authorization results to a WWW application.
The "logo_uri" argument specifies a public URL for the logo of your
application, while the "tos_uri" specifies a public URL for the terms of
service for your application.
The returned "client_id" string must be freed using the free
function.
Note: This function should only be used to register WWW applications. The
cupsOAuthGetAuthorizationCode
function handles registration of
local/"native" applications for you.
Get the JWT key set for an Authorization Server.
cups_json_t *cupsOAuthGetJWKS(const char *auth_uri, cups_json_t *metadata);
auth_uri | Authorization server URI |
---|---|
metadata | Server metadata |
JWKS or NULL
on error
This function gets the JWT key set for the specified Authorization Server
"auth_uri". The "metadata" value is obtained using the
cupsOAuthGetMetadata
function. The returned key set is cached
per-user for better performance and must be freed using the
cupsJSONDelete
function.
The key set is typically used to validate JWT bearer tokens using the
cupsJWTHasValidSignature
function.
Get the metadata for an Authorization Server.
cups_json_t *cupsOAuthGetMetadata(const char *auth_uri);
auth_uri | Authorization Server URI |
---|
JSON metadata or NULL
on error
This function gets the RFC 8414 or Open ID Connect metadata for the specified
OAuth Authorization Server URI "auth_uri".
The returned metadata is cached per-user for better performance and must be
freed using the cupsJSONDelete
function.
Obtain access and refresh tokens.
char *cupsOAuthGetTokens(const char *auth_uri, cups_json_t *metadata, const char *resource_uri, const char *grant_code, cups_ogrant_t grant_type, const char *redirect_uri, time_t *access_expires);
auth_uri | Authorization Server URI |
---|---|
metadata | Authorization Server metadata |
resource_uri | Resource URI |
grant_code | Authorization code or refresh token |
grant_type | Grant code type |
redirect_uri | Redirect URI |
access_expires | Expiration time for access token |
Access token or NULL
on error
This function obtains a access and refresh tokens from an OAuth Authorization
Server. OpenID Authorization Servers also provide user identification
information.
The "auth_uri" parameter specifies the URI for the OAuth Authorization
Server. The "metadata" parameter specifies the Authorization Server metadata
as obtained using cupsOAuthCopyMetadata
and/or
cupsOAuthGetMetadata
.
The "resource_uri" parameter specifies the URI for a resource (printer, web
file, etc.) that you which to access.
The "grant_code" parameter specifies the code or token to use while the
"grant_type" parameter specifies the type of code:
CUPS_OGRANT_AUTHORIZATION_CODE
: A user authorization grant code.
CUPS_OGRANT_DEVICE_CODE
: A device authorization grant code.
CUPS_OGRANT_REFRESH_TOKEN
: A refresh token.The "redirect_uri" specifies the redirection URI used to obtain the code. The
constant CUPS_OAUTH_REDIRECT_URI
should be used for codes obtained using
the cupsOAuthGetAuthorizationCode
function.
When successful, the access token and expiration time are returned. The
access token must be freed using the free
function. The new refresh token
and any user ID information can be obtained using the
cupsOAuthCopyRefreshToken
and cupsOAuthCopyUserId
functions
respectively.
Get the user ID token associated with the given access token.
cups_jwt_t *cupsOAuthGetUserId(const char *auth_uri, cups_json_t *metadata, const char *access_token);
auth_uri | Authorization Server URL |
---|---|
metadata | Authorization Server metadata |
access_token | Access (Bearer) token |
Identification information or NULL
if none
This function retrieves the user ID token associated with a given access token. The user ID information is cached until the token expires to minimize the overhead of communicating with the Authorization Server.
Make an authorization URL.
char *cupsOAuthMakeAuthorizationURL(const char *auth_uri, cups_json_t *metadata, const char *resource_uri, const char *scopes, const char *client_id, const char *code_verifier, const char *nonce, const char *redirect_uri, const char *state);
auth_uri | Authorization Server URI |
---|---|
metadata | Authorization Server metadata |
resource_uri | Resource URI |
scopes | Space-delimited scope(s) |
client_id | Client ID |
code_verifier | Code verifier string |
nonce | Nonce |
redirect_uri | Redirection URI |
state | State |
Authorization URL
This function makes an authorization URL for the specified authorization
server and resource.
The "auth_uri" parameter specifies the URI for the OAuth Authorization
Server. The "metadata" parameter specifies the Authorization Server metadata
as obtained using cupsOAuthCopyMetadata
and/or
cupsOAuthGetMetadata
.
The "resource_uri" parameter specifies the URI for a resource (printer, web
file, etc.) that you which to access.
The "scopes" parameter specifies zero or more whitespace-delimited scope
names to request during authorization. The list of supported scope names are
available from the Authorization Server metadata, for example:
cups_json_t *metadata = cupsOAuthGetMetadata(auth_uri); cups_json_t *scopes_supported = cupsJSONFind(metadata, "scopes_supported");The "client_id" parameter specifies the client identifier obtained using
cupsOAuthCopyClientId
and/or cupsOAuthGetClientId
.cupsOAuthCopyClientId
or cupsOAuthGetClientId
.cupsOAuthMakeBase64Random
function
can be used to generate this string.cupsOAuthMakeBase64Random
function can be used to generate this string.Make a random data string.
char *cupsOAuthMakeBase64Random(size_t len);
len | Number of bytes |
---|
Random string
This function creates a string containing random data that has been Base64URL
encoded. "len" specifies the number of random bytes to include in the string.
The returned string must be freed using the free
function.
Save client_id and client_secret values.
void cupsOAuthSaveClientData(const char *auth_uri, const char *redirect_uri, const char *client_id, const char *client_secret);
auth_uri | Authorization Server URI |
---|---|
redirect_uri | Redirection URI |
client_id | client_id or NULL to delete |
client_secret | client_secret value or NULL for none |
This function saves the "client_id" and "client_secret" values for the given
Authorization Server "auth_uri" and redirection URI "redirect_uri". If the
"client_id" is NULL
then any saved values are deleted from the per-user
store.
Save authorization and refresh tokens.
void cupsOAuthSaveTokens(const char *auth_uri, const char *resource_uri, const char *access_token, time_t access_expires, const char *user_id, const char *refresh_token);
auth_uri | Authorization Server URI |
---|---|
resource_uri | Resource URI |
access_token | Access token or NULL to delete |
access_expires | Access expiration time |
user_id | User ID or NULL to delete |
refresh_token | Refresh token or NULL to delete |
This function saves the access token "access_token", user ID "user_id", and
refresh token "refresh_token" values for the given Authorization Server
"auth_uri" and resource "resource_uri". Specifying NULL
for any of the
values will delete the corresponding saved values from the per-user store.
Parse options from a command-line argument.
int cupsParseOptions(const char *arg, int num_options, cups_option_t **options);
arg | Argument to parse |
---|---|
num_options | Number of options |
options | Options found |
Number of options found
This function converts space-delimited name/value pairs according
to the PAPI text option ABNF specification. Collection values
("name={a=... b=... c=...}") are stored with the curley brackets
intact - use cupsParseOptions
on the value to extract the
collection attributes.
Parse options from a command-line argument.
int cupsParseOptions2(const char *arg, const char **end, int num_options, cups_option_t **options);
arg | Argument to parse |
---|---|
end | Pointer to end of options or NULL for "don't care" |
num_options | Number of options |
options | Options found |
Number of options found
This function converts space-delimited name/value pairs according
to the PAPI text option ABNF specification. Collection values
("name={a=... b=... c=...}") are stored with the curley brackets
intact - use cupsParseOptions
on the value to extract the
collection attributes.
The "end" argument, if not NULL
, receives a pointer to the end of the
options.
Put a file on the server.
http_status_t cupsPutFd(http_t *http, const char *resource, int fd);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
resource | Resource name |
fd | File descriptor |
HTTP status
This function returns HTTP_STATUS_CREATED
when the file is stored
successfully.
Put a file on the server.
http_status_t cupsPutFile(http_t *http, const char *resource, const char *filename);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
resource | Resource name |
filename | Filename |
HTTP status
This function returns HTTP_CREATED
when the file is stored
successfully.
Destroy a reader/writer lock.
void cupsRWDestroy(cups_rwlock_t *rwlock);
rwlock | Reader/writer lock |
---|
Initialize a reader/writer lock.
void cupsRWInit(cups_rwlock_t *rwlock);
rwlock | Reader/writer lock |
---|
Acquire a reader/writer lock for reading.
void cupsRWLockRead(cups_rwlock_t *rwlock);
rwlock | Reader/writer lock |
---|
Acquire a reader/writer lock for writing.
void cupsRWLockWrite(cups_rwlock_t *rwlock);
rwlock | Reader/writer lock |
---|
Release a reader/writer lock.
void cupsRWUnlock(cups_rwlock_t *rwlock);
rwlock | Reader/writer lock |
---|
Close a raster stream.
void cupsRasterClose(cups_raster_t *r);
r | Stream to close |
---|
The file descriptor associated with the raster stream must be closed separately as needed.
Return the last error from a raster function.
const char *cupsRasterGetErrorString(void);
Last error
If there are no recent errors, NULL is returned.
Initialize a page header for PWG Raster output.
bool cupsRasterInitHeader(cups_page_header2_t *h, cups_media_t *media, const char *optimize, ipp_quality_t quality, const char *intent, ipp_orient_t orientation, const char *sides, const char *type, int xdpi, int ydpi, const char *sheet_back);
h | Page header |
---|---|
media | Media information |
optimize | IPP "print-content-optimize" value |
quality | IPP "print-quality" value |
intent | IPP "print-rendering-intent" value |
orientation | IPP "orientation-requested" value |
sides | IPP "sides" value |
type | PWG raster type string |
xdpi | Cross-feed direction (horizontal) resolution |
ydpi | Feed direction (vertical) resolution |
sheet_back | Transform for back side or NULL for none |
true
on success, false
on failure
The "media" argument specifies the media to use. The "optimize", "quality",
"intent", "orientation", and "sides" arguments specify additional IPP Job
Template attribute values that are reflected in the raster header.
The "type" argument specifies a "pwg-raster-document-type-supported" value
that controls the color space and bit depth of the raster data. Supported
values include:
The "xres" and "yres" arguments specify the raster resolution in dots per
inch.
The "sheet_back" argument specifies a "pwg-raster-document-sheet-back" value
to apply for the back side of a page. Pass NULL
for the front side.
Open a raster stream using a file descriptor.
cups_raster_t *cupsRasterOpen(int fd, cups_mode_t mode);
fd | File descriptor |
---|---|
mode | Mode - CUPS_RASTER_READ ,
CUPS_RASTER_WRITE ,
CUPS_RASTER_WRITE_COMPRESSED ,
or CUPS_RASTER_WRITE_PWG |
New stream
This function associates a raster stream with the given file descriptor.
For most printer driver filters, "fd" will be 0 (stdin). For most raster
image processor (RIP) filters that generate raster data, "fd" will be 1
(stdout).
When writing raster data, the CUPS_RASTER_WRITE
,
CUPS_RASTER_WRITE_COMPRESS
, or CUPS_RASTER_WRITE_PWG
mode can
be used - compressed and PWG output is generally 25-50% smaller but adds a
100-300% execution time overhead.
Open a raster stream using a callback function.
cups_raster_t *cupsRasterOpenIO(cups_raster_cb_t iocb, void *ctx, cups_raster_mode_t mode);
iocb | Read/write callback |
---|---|
ctx | Context pointer for callback |
mode | Mode - CUPS_RASTER_READ ,
CUPS_RASTER_WRITE ,
CUPS_RASTER_WRITE_COMPRESSED ,
or CUPS_RASTER_WRITE_PWG |
New stream
This function associates a raster stream with the given callback function and
context pointer.
When writing raster data, the CUPS_RASTER_WRITE
,
CUPS_RASTER_WRITE_COMPRESS
, or CUPS_RASTER_WRITE_PWG
mode can
be used - compressed and PWG output is generally 25-50% smaller but adds a
100-300% execution time overhead.
Read a raster page header and store it in a version 1 page header structure.
unsigned cupsRasterReadHeader(cups_raster_t *r, cups_page_header_t *h);
r | Raster stream |
---|---|
h | Pointer to header data |
1 on success, 0 on failure/end-of-file
This function is deprecated. Use cupsRasterReadHeader2
instead.
Version 1 page headers were used in CUPS 1.0 and 1.1 and contain a subset
of the version 2 page header data. This function handles reading version 2
page headers and copying only the version 1 data into the provided buffer.
Read a raster page header and store it in a version 2 page header structure.
unsigned cupsRasterReadHeader2(cups_raster_t *r, cups_page_header2_t *h);
r | Raster stream |
---|---|
h | Pointer to header data |
1 on success, 0 on failure/end-of-file
Read raster pixels.
unsigned cupsRasterReadPixels(cups_raster_t *r, unsigned char *p, unsigned len);
r | Raster stream |
---|---|
p | Pointer to pixel buffer |
len | Number of bytes to read |
Number of bytes read
For best performance, filters should read one or more whole lines. The "cupsBytesPerLine" value from the page header can be used to allocate the line buffer and as the number of bytes to read.
Write a raster page header from a version 1 page header structure.
unsigned cupsRasterWriteHeader(cups_raster_t *r, cups_page_header_t *h);
r | Raster stream |
---|---|
h | Raster page header |
1 on success, 0 on failure
This function is deprecated. Use cupsRasterWriteHeader2
instead.
Write a raster page header from a version 2 page header structure.
unsigned cupsRasterWriteHeader2(cups_raster_t *r, cups_page_header2_t *h);
r | Raster stream |
---|---|
h | Raster page header |
1 on success, 0 on failure
The page header can be initialized using cupsRasterInitPWGHeader
.
Write raster pixels.
unsigned cupsRasterWritePixels(cups_raster_t *r, unsigned char *p, unsigned len);
r | Raster stream |
---|---|
p | Bytes to write |
len | Number of bytes to write |
Number of bytes written
For best performance, filters should write one or more whole lines. The "cupsBytesPerLine" value from the page header can be used to allocate the line buffer and as the number of bytes to write.
Read additional data after the IPP response.
ssize_t cupsReadResponseData(http_t *http, char *buffer, size_t length);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
buffer | Buffer to use |
length | Number of bytes to read |
Bytes read, 0 on EOF, -1 on error
This function is used after cupsGetResponse
to read the PPD or document
files from CUPS_GET_PPD
and CUPS_GET_DOCUMENT
requests,
respectively.
Remove a destination from the destination list.
int cupsRemoveDest(const char *name, const char *instance, int num_dests, cups_dest_t **dests);
name | Destination name |
---|---|
instance | Instance name or NULL |
num_dests | Number of destinations |
dests | Destinations |
New number of destinations
Removing a destination/instance does not delete the class or printer
queue, merely the lpoptions for that destination/instance. Use the
cupsSetDests
or cupsSetDests2
functions to save the new
options for the user.
Remove an option from an option array.
int cupsRemoveOption(const char *name, int num_options, cups_option_t **options);
name | Option name |
---|---|
num_options | Current number of options |
options | Options |
New number of options
Save the credentials associated with a printer/server.
bool cupsSaveCredentials(const char *path, const char *common_name, const char *credentials, const char *key);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name for certificate |
credentials | PEM-encoded certificate chain or NULL to remove |
key | PEM-encoded private key or NULL for none |
true
on success, false
on failure
This function saves the the PEM-encoded X.509 certificate chain string and
private key (if not NULL
) to the directory "path" or, if "path" is NULL
,
in a per-user or system-wide (when running as root) certificate/key store.
Send an IPP request.
http_status_t cupsSendRequest(http_t *http, ipp_t *request, const char *resource, size_t length);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
request | IPP request |
resource | Resource path |
length | Length of data to follow or CUPS_LENGTH_VARIABLE |
Initial HTTP status
Use cupsWriteRequestData
to write any additional data (document, PPD
file, etc.) for the request, cupsGetResponse
to get the IPP response,
and cupsReadResponseData
to read any additional data following the
response. Only one request can be sent/queued at a time per http_t
connection.
Returns the initial HTTP status code, which will be HTTP_STATUS_CONTINUE
on a successful send of the request.
Note: Unlike cupsDoFileRequest
, cupsDoIORequest
, and
cupsDoRequest
, the request is NOT freed with ippDelete
.
Return the hostname/address of the current server.
const char *cupsServer(void);
Server name
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
cupsSetServer
function need to do so in each thread for the same
server to be used.
Set the client certificate callback.
void cupsSetClientCertCB(cups_client_cert_cb_t cb, void *user_data);
cb | Callback function |
---|---|
user_data | User data pointer |
Pass NULL
to restore the default callback.
Note: The current certificate callback is tracked separately for each thread
in a program. Multi-threaded programs that override the callback need to do
so in each thread for the same callback to be used.
Set the default credentials to be used for TLS connections.
bool cupsSetClientCredentials(const char *credentials, const char *key);
credentials | PEM-encoded X.509 credentials string |
---|---|
key | PEM-encoded private key |
true
on success, false
on failure
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.
Set the default credentials to be used for SSL/TLS connections.
int cupsSetCredentials(cups_array_t *credentials);
credentials | Array of credentials |
---|
Status of call (0 = success)
Set the default destination.
void cupsSetDefaultDest(const char *name, const char *instance, int num_dests, cups_dest_t *dests);
name | Destination name |
---|---|
instance | Instance name or NULL |
num_dests | Number of destinations |
dests | Destinations |
Save the list of destinations for the specified server.
int cupsSetDests2(http_t *http, int num_dests, cups_dest_t *dests);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
num_dests | Number of destinations |
dests | Destinations |
0 on success, -1 on error
This function saves the destinations to /etc/cups/lpoptions when run as root and ~/.cups/lpoptions when run as a normal user.
Set the encryption preference.
void cupsSetEncryption(http_encryption_t e);
e | New encryption preference |
---|
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
HTTP_ENCRYPTION_IF_REQUESTED
.
Note: The current encryption setting is 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.
Set the OAuth 2.0 callback for CUPS.
void cupsSetOAuthCB(cups_oauth_cb_t cb, void *user_data);
cb | Callback function |
---|---|
user_data | User data pointer |
This function sets the OAuth 2.0 callback for the various CUPS APIs that
send HTTP requests. Pass NULL
to restore the default (console-based)
callback.
The OAuth callback receives the HTTP connection, realm name, scope name (if
any), resource path, and the "user_data" pointer for each request that
requires an OAuth access token. The function then returns either the Bearer
token string or NULL
if no authorization could be obtained.
Beyond reusing the Bearer token for subsequent requests on the same HTTP
connection, no caching of the token is done by the CUPS library. The
callback can determine whether to refresh a cached token by examining any
existing token returned by the httpGetAuthString
function.
Note: The current OAuth callback is tracked separately for each thread in a
program. Multi-threaded programs that override the callback need to do so in
each thread for the same callback to be used.
Set the advanced password callback for CUPS.
void cupsSetPasswordCB2(cups_password_cb2_t cb, void *user_data);
cb | Callback function |
---|---|
user_data | User data pointer |
Pass NULL
to restore the default (console) password callback, which
reads the password from the console. Programs should call either this
function or cupsSetPasswordCB2
, as only one callback can be registered
by a program per thread.
Note: The current password callback is tracked separately for each thread
in a program. Multi-threaded programs that override the callback need to do
so in each thread for the same callback to be used.
Set the default server name and port.
void cupsSetServer(const char *server);
server | Server name |
---|
The "server" string can be a fully-qualified hostname, a numeric
IPv4 or IPv6 address, or a domain socket pathname. Hostnames and numeric IP
addresses can be optionally followed by a colon and port number to override
the default port 631, e.g. "hostname:8631". Pass NULL
to restore the
default server name and port.
Note: The current server is tracked separately for each thread in a program.
Multi-threaded programs that override the server need to do so in each
thread for the same server to be used.
Set the server certificate callback.
void cupsSetServerCertCB(cups_server_cert_cb_t cb, void *user_data);
cb | Callback function |
---|---|
user_data | User data pointer |
Pass NULL
to restore the default callback.
Note: The current credentials callback is tracked separately for each thread
in a program. Multi-threaded programs that override the callback need to do
so in each thread for the same callback to be used.
Set the default server credentials.
int cupsSetServerCredentials(const char *path, const char *common_name, int auto_create);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Default common name for server |
auto_create | true = automatically create self-signed certificates |
1
on success, 0
on failure
Note: The server credentials are used by all threads in the running process. This function is threadsafe.
Set the default user name.
void cupsSetUser(const char *user);
user | User name |
---|
Pass NULL
to restore the default user name.
Note: The current user name is tracked separately for each thread in a
program. Multi-threaded programs that override the user name need to do so
in each thread for the same user name to be used.
Set the default HTTP User-Agent string.
void cupsSetUserAgent(const char *user_agent);
user_agent | User-Agent string or NULL |
---|
Setting the string to NULL forces the default value containing the CUPS version, IPP version, and operating system version and architecture.
Sign an X.509 certificate signing request to produce an X.509 certificate chain.
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);
path | Directory path for certificate/key store or NULL for default |
---|---|
common_name | Common name to use |
request | PEM-encoded CSR |
root_name | Root certificate |
allowed_purpose | Allowed credential purpose(s) |
allowed_usage | Allowed credential usage(s) |
cb | subjectAltName callback or NULL to allow just .local |
cb_data | Callback data |
expiration_date | Certificate expiration date |
true
on success, false
on failure
This function creates an X.509 certificate from a signing request. The
certificate is stored in the directory "path" or, if "path" is NULL
, in a
per-user or system-wide (when running as root) certificate/key store. The
generated certificate is signed by the named root certificate or, if
"root_name" is NULL
, a site-wide default root certificate. When
"root_name" is NULL
and there is no site-wide default root certificate, a
self-signed certificate is generated instead.
The "allowed_purpose" argument specifies the allowed purpose(s) used for the
credentials as a bitwise OR of the following constants:
CUPS_CREDPURPOSE_SERVER_AUTH
for validating TLS servers,
CUPS_CREDPURPOSE_CLIENT_AUTH
for validating TLS clients,
CUPS_CREDPURPOSE_CODE_SIGNING
for validating compiled code,
CUPS_CREDPURPOSE_EMAIL_PROTECTION
for validating email messages,
CUPS_CREDPURPOSE_TIME_STAMPING
for signing timestamps to objects, and/or
CUPS_CREDPURPOSE_OCSP_SIGNING
for Online Certificate Status Protocol
message signing.The "allowed_usage" argument specifies the allowed usage(s) for the credentials as a bitwise OR of the following constants:
CUPS_CREDUSAGE_DIGITAL_SIGNATURE
: digital signatures,
CUPS_CREDUSAGE_NON_REPUDIATION
: non-repudiation/content commitment,
CUPS_CREDUSAGE_KEY_ENCIPHERMENT
: key encipherment,
CUPS_CREDUSAGE_DATA_ENCIPHERMENT
: data encipherment,
CUPS_CREDUSAGE_KEY_AGREEMENT
: key agreement,
CUPS_CREDUSAGE_KEY_CERT_SIGN
: key certicate signing,
CUPS_CREDUSAGE_CRL_SIGN
: certificate revocation list signing,
CUPS_CREDUSAGE_ENCIPHER_ONLY
: encipherment only,
CUPS_CREDUSAGE_DECIPHER_ONLY
: decipherment only,
CUPS_CREDUSAGE_DEFAULT_CA
: defaults for CA certificates,
CUPS_CREDUSAGE_DEFAULT_TLS
: defaults for TLS certificates, and/or
CUPS_CREDUSAGE_ALL
: all usages.The "cb" and "cb_data" arguments specify a function and its data that are used to validate any subjectAltName values in the signing request:
bool san_cb(const char *common_name, const char *alt_name, void *cb_data) { ... return true if OK and false if not ... }If
NULL
, a default validation function is used that allows "localhost" and
variations of the common name.time_t
value in seconds.
Start a new document.
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);
http | Connection to destination |
---|---|
dest | Destination |
info | Destination information |
job_id | Job ID |
docname | Document name |
format | Document format |
num_options | Number of document options |
options | Document options |
last_document | 1 if this is the last document |
Status of document creation
"job_id" is the job ID returned by cupsCreateDestJob. "docname" is the name
of the document/file being printed, "format" is the MIME media type for the
document (see CUPS_FORMAT_xxx constants), and "num_options" and "options"
are the options do be applied to the document. "last_document" should be 1
if this is the last document to be submitted in the job. Returns
HTTP_CONTINUE
on success.
Create a temporary file descriptor.
int cupsTempFd(char *filename, int len);
filename | Pointer to buffer |
---|---|
len | Size of buffer |
New file descriptor or -1 on error
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 cupsCreateTempFd
function instead.
Generate a temporary filename (deprecated).
char *cupsTempFile(char *filename, int len);
filename | Pointer to buffer */ |
---|---|
len | Size of buffer |
NULL
(error)
This function is deprecated and no longer generates a temporary filename.
Use cupsCreateTempFd
or cupsCreateTempFile2
instead.
Creates a temporary CUPS file.
cups_file_t *cupsTempFile2(char *filename, int len);
filename | Pointer to buffer |
---|---|
len | Size of buffer |
CUPS file or NULL
on error
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 cupsCreateTempFile
function instead.
Cancel (kill) a thread.
void cupsThreadCancel(cups_thread_t thread);
thread | Thread ID |
---|
Create a thread.
cups_thread_t cupsThreadCreate(cups_thread_func_t func, void *arg);
func | Entry point |
---|---|
arg | Entry point context |
Thread ID or CUPS_THREAD_INVALID
on failure
Tell the OS that the thread is running independently.
void cupsThreadDetach(cups_thread_t thread);
thread | Thread ID |
---|
Wait for a thread to exit.
void *cupsThreadWait(cups_thread_t thread);
thread | Thread ID |
---|
Return value
Convert UTF-32 to UTF-8.
int cupsUTF32ToUTF8(cups_utf8_t *dest, const cups_utf32_t *src, const int maxout);
dest | Target string |
---|---|
src | Source string |
maxout | Max output |
Count or -1 on error
32-bit UTF-32 (actually 21-bit) maps to UTF-8 as follows...
UTF-32 char UTF-8 char(s)
--------------------------------------------------
0 to 127 = 0xxxxxxx (US-ASCII)
128 to 2047 = 110xxxxx 10yyyyyy
2048 to 65535 = 1110xxxx 10yyyyyy 10zzzzzz
> 65535 = 11110xxx 10yyyyyy 10zzzzzz 10xxxxxx
UTF-32 prohibits chars beyond Plane 16 (> 0x10ffff) in UCS-4,
which would convert to five- or six-octet UTF-8 sequences...
Convert UTF-8 to legacy character set.
int cupsUTF8ToCharset(char *dest, const cups_utf8_t *src, const int maxout, const cups_encoding_t encoding);
dest | Target string |
---|---|
src | Source string |
maxout | Max output |
encoding | Encoding |
Count or -1 on error
Convert UTF-8 to UTF-32.
int cupsUTF8ToUTF32(cups_utf32_t *dest, const cups_utf8_t *src, const int maxout);
dest | Target string |
---|---|
src | Source string |
maxout | Max output |
Count or -1 on error
32-bit UTF-32 (actually 21-bit) maps to UTF-8 as follows...
UTF-32 char UTF-8 char(s)
--------------------------------------------------
0 to 127 = 0xxxxxxx (US-ASCII)
128 to 2047 = 110xxxxx 10yyyyyy
2048 to 65535 = 1110xxxx 10yyyyyy 10zzzzzz
> 65535 = 11110xxx 10yyyyyy 10zzzzzz 10xxxxxx
UTF-32 prohibits chars beyond Plane 16 (> 0x10ffff) in UCS-4,
which would convert to five- or six-octet UTF-8 sequences...
Return the current user's name.
const char *cupsUser(void);
User 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
cupsSetUser
function need to do so in each thread for the same user
name to be used.
Return the default HTTP User-Agent string.
const char *cupsUserAgent(void);
User-Agent string
Write additional data after an IPP request.
http_status_t cupsWriteRequestData(http_t *http, const char *buffer, size_t length);
http | Connection to server or CUPS_HTTP_DEFAULT |
---|---|
buffer | Bytes to write |
length | Number of bytes to write |
HTTP_STATUS_CONTINUE
if OK or HTTP status on error
This function is used after cupsSendRequest
to provide a PPD and
after cupsStartDocument
to provide a document file.
Accept a new HTTP client connection.
http_t *httpAcceptConnection(int fd, int blocking);
fd | Listen socket file descriptor |
---|---|
blocking | 1 if the connection should be blocking, 0 otherwise |
HTTP connection or NULL
This function accepts a new HTTP client connection from the specified listening socket "fd". The "blocking" argument specifies whether the new HTTP connection is blocking.
Close a socket created by httpAddrConnect
or
httpAddrListen
.
int httpAddrClose(http_addr_t *addr, int fd);
addr | Listen address or NULL |
---|---|
fd | Socket file descriptor |
0 on success, -1 on failure
Pass NULL
for sockets created with httpAddrConnect2
and the
listen address for sockets created with httpAddrListen
. This function
ensures that domain sockets are removed when closed.
Connect to any of the addresses in the list with a timeout and optional cancel.
http_addrlist_t *httpAddrConnect2(http_addrlist_t *addrlist, int *sock, int msec, int *cancel);
addrlist | List of potential addresses |
---|---|
sock | Socket |
msec | Timeout in milliseconds |
cancel | Pointer to "cancel" variable |
Connected address or NULL on failure
Copy an address list.
http_addrlist_t *httpAddrCopyList(http_addrlist_t *src);
src | Source address list |
---|
New address list or NULL
on error
Free an address list.
void httpAddrFreeList(http_addrlist_t *addrlist);
addrlist | Address list to free |
---|
Get the address family of an address.
int httpAddrGetFamily(http_addr_t *addr);
addr | Address |
---|
Address family
Return the length of the address in bytes.
size_t httpAddrGetLength(const http_addr_t *addr);
addr | Address |
---|
Length in bytes
Get a list of addresses for a hostname.
http_addrlist_t *httpAddrGetList(const char *hostname, int family, const char *service);
hostname | Hostname, IP address, or NULL for passive listen address |
---|---|
family | Address family or AF_UNSPEC |
service | Service name or port number |
List of addresses or NULL
Get the port number associated with an address.
int httpAddrGetPort(http_addr_t *addr);
addr | Address |
---|
Port number
Convert an address to a numeric string.
char *httpAddrGetString(const http_addr_t *addr, char *s, size_t slen);
addr | Address to convert |
---|---|
s | String buffer |
slen | Length of string |
Numeric address string
Check for the "any" address.
bool httpAddrIsAny(const http_addr_t *addr);
addr | Address to check |
---|
true
if "any" address, false
otherwise
Compare two addresses.
bool httpAddrIsEqual(const http_addr_t *addr1, const http_addr_t *addr2);
addr1 | First address |
---|---|
addr2 | Second address |
true
if equal, false
if not
Check for the local loopback address.
bool httpAddrIsLocalhost(const http_addr_t *addr);
addr | Address to check |
---|
true
if local host, false
otherwise
Create a listening socket bound to the specified address and port.
int httpAddrListen(http_addr_t *addr, int port);
addr | Address to bind to |
---|---|
port | Port number to bind to |
Socket or -1 on error
Lookup the hostname associated with the address.
char *httpAddrLookup(const http_addr_t *addr, char *name, int namelen);
addr | Address to lookup |
---|---|
name | Host name buffer |
namelen | Size of name buffer |
Host name
Set the port number associated with an address.
void httpAddrSetPort(http_addr_t *addr, int port);
addr | Address |
---|---|
port | Port |
Assemble a uniform resource identifier from its components.
http_uri_status_t httpAssembleURI(http_uri_coding_t encoding, char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resource);
encoding | Encoding flags |
---|---|
uri | URI buffer |
urilen | Size of URI buffer |
scheme | Scheme name |
username | Username |
host | Hostname or address |
port | Port number |
resource | Resource |
URI status
This function escapes reserved characters in the URI depending on the value of the "encoding" argument. You should use this function in place of traditional string functions whenever you need to create a URI string.
Assemble a uniform resource identifier from its components with a formatted resource.
http_uri_status_t httpAssembleURIf(http_uri_coding_t encoding, char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resourcef, ...);
encoding | Encoding flags |
---|---|
uri | URI buffer |
urilen | Size of URI buffer |
scheme | Scheme name |
username | Username |
host | Hostname or address |
port | Port number |
resourcef | Printf-style resource |
... | Additional arguments as needed |
URI status
This function creates a formatted version of the resource string argument "resourcef" and escapes reserved characters in the URI depending on the value of the "encoding" argument. You should use this function in place of traditional string functions whenever you need to create a URI string.
Assemble a name-based UUID URN conforming to RFC 4122.
char *httpAssembleUUID(const char *server, int port, const char *name, int number, char *buffer, size_t bufsize);
server | Server name |
---|---|
port | Port number |
name | Object name or NULL |
number | Object number or 0 |
buffer | String buffer |
bufsize | Size of buffer |
UUID string
This function creates a unique 128-bit identifying number using the server
name, port number, random data, and optionally an object name and/or object
number. The result is formatted as a UUID URN as defined in RFC 4122.
The buffer needs to be at least 46 bytes in size.
Set blocking/non-blocking behavior on a connection.
void httpBlocking(http_t *http, int b);
http | HTTP connection |
---|---|
b | 1 = blocking, 0 = non-blocking |
Check to see if there is a pending response from the server.
int httpCheck(http_t *http);
http | HTTP connection |
---|
0 = no data, 1 = data available
Clear the cookie value(s).
void httpClearCookie(http_t *http);
http | HTTP connection |
---|
Clear HTTP request/response fields.
void httpClearFields(http_t *http);
http | HTTP connection |
---|
Close a HTTP connection.
void httpClose(http_t *http);
http | HTTP connection |
---|
Connect to a HTTP server.
http_t *httpConnect2(const char *host, int port, http_addrlist_t *addrlist, int family, http_encryption_t encryption, int blocking, int msec, int *cancel);
host | Host to connect to |
---|---|
port | Port number |
addrlist | List of addresses or NULL to lookup |
family | Address family to use or AF_UNSPEC for any |
encryption | Type of encryption to use |
blocking | 1 for blocking connection, 0 for non-blocking |
msec | Connection timeout in milliseconds, 0 means don't connect |
cancel | Pointer to "cancel" variable |
New HTTP connection
This function creates a connection to a HTTP server. The "host" and "port"
arguments specify a hostname or IP address and port number to use while the
"addrlist" argument specifies a list of addresses to use or NULL
to do a
fresh lookup. The "family" argument specifies the address family to use -
AF_UNSPEC
to try both IPv4 and IPv6, AF_INET
for IPv4, or AF_INET6
for
IPv6.
The "encryption" argument specifies whether to encrypt the connection and the
"blocking" argument specifies whether to use blocking behavior when reading
or writing data.
The "msec" argument specifies how long to try to connect to the server or 0
to just create an unconnected http_t
object. The "cancel" argument
specifies an integer variable that can be set to a non-zero value to cancel
the connection process.
Reconnect to a HTTP server with timeout and optional cancel variable.
bool httpConnectAgain(http_t *http, int msec, int *cancel);
http | HTTP connection |
---|---|
msec | Timeout in milliseconds |
cancel | Pointer to "cancel" variable |
true
on success, false
on failure
Connect to a HTTP service using a URI.
http_t *httpConnectURI(const char *uri, char *host, size_t hsize, int *port, char *resource, size_t rsize, bool blocking, int msec, int *cancel, bool require_ca);
uri | Service to connect to |
---|---|
host | Host name buffer (NULL for don't care) |
hsize | Size of host name buffer |
port | Port number (NULL for don't care) |
resource | Resource path buffer (NULL for don't care) |
rsize | Size of resource path buffer |
blocking | true for blocking connection, false for non-blocking |
msec | Connection timeout in milliseconds, 0 means don't connect |
cancel | Pointer to "cancel" variable or NULL for none |
require_ca | true to require a CA-signed X.509 certificate |
New HTTP connection
This function creates a connection to a HTTP server. The "uri" argument
specifies a "http", "https", "ipp", or "ipps" URI for the service.
The resource path for the service is returned in the buffer pointed to by
the "resource" argument of size "rsize".
The "msec" argument specifies how long to try to connect to the server or 0
to just create an unconnected http_t
object. The "cancel" argument
specifies an integer variable that can be set to a non-zero value to cancel
the connection process.
The "require_ca" argument specifies whether to verify that the service
connection is using a CA-signed X.509 certificate.
Copy the credentials associated with the peer in an encrypted connection.
char *httpCopyPeerCredentials(http_t *http);
http | Connection to server |
---|
PEM-encoded X.509 certificate chain or NULL
Base64-decode a string.
char *httpDecode64_3(char *out, size_t *outlen, const char *in, const char **end);
out | String to write to |
---|---|
outlen | Size of output string |
in | String to read from |
end | Pointer to end of Base64 data (NULL if don't care) |
Decoded string or NULL
on error
This function decodes a Base64 string as defined by RFC 4648. The caller
must initialize "outlen" to the maximum size of the decoded string. On
return "outlen" contains the decoded length of the string and "end" (if not
NULL
) points to the end of the Base64 data that has been decoded.
This function always reserves one byte in the output buffer for a nul
terminating character, even if the result is not a regular string. Callers
should ensure that the output buffer is at least one byte larger than the
expected size, for example 33 bytes for a SHA-256 hash which is 32 bytes in
length.
This function supports both Base64 and Base64url strings.
Base64-encode a string.
char *httpEncode64_3(char *out, size_t outlen, const char *in, size_t inlen, bool url);
out | String to write to |
---|---|
outlen | Maximum size of output string |
in | String to read from |
inlen | Size of input string |
url | true for Base64url, false for Base64 |
Encoded string
This function encodes a Base64 string as defined by RFC 4648. The "url"
parameter controls whether the original Base64 ("url" = false
) or the
Base64url ("url" = true
) alphabet is used.
Return the HTTP field enumeration value for a field name.
http_field_t httpFieldValue(const char *name);
name | String name |
---|
Field index
Flush data read from a HTTP connection.
void httpFlush(http_t *http);
http | HTTP connection |
---|
Flush data written to a HTTP connection.
int httpFlushWrite(http_t *http);
http | HTTP connection |
---|
Bytes written or -1 on error
Get the most recent activity for a connection.
time_t httpGetActivity(http_t *http);
http | HTTP connection |
---|
Time of last read or write
The return value is the time in seconds of the last read or write.
Get the address of the connected peer of a connection.
http_addr_t *httpGetAddress(http_t *http);
http | HTTP connection |
---|
Connected address or NULL
For connections created with httpConnect2
, the address is for the
server. For connections created with httpAccept
, the address is for
the client.
Returns NULL
if the socket is currently unconnected.
Get the current authorization string.
char *httpGetAuthString(http_t *http);
http | HTTP connection |
---|
Authorization string
The authorization string is set by cupsDoAuthentication
and
httpSetAuthString
. Use httpGetAuthString
to retrieve the
string to use with httpSetField
for the
HTTP_FIELD_AUTHORIZATION
value.
Get the blocking/non-blocking state of a connection.
int httpGetBlocking(http_t *http);
http | HTTP connection |
---|
1 if blocking, 0 if non-blocking
Get a common content encoding, if any, between the client and server.
const char *httpGetContentEncoding(http_t *http);
http | HTTP connection |
---|
Content-Coding value or NULL
for the identity coding.
This function uses the value of the Accepts-Encoding HTTP header and must be called after receiving a response from the server or a request from the client. The value returned can be use in subsequent requests (for clients) or in the response (for servers) in order to compress the content stream.
Get cookie data from the HTTP connection.
const char *httpGetCookie(http_t *http);
http | HTTP connection |
---|
Cookie data or NULL
This function returns any HTTP "Set-Cookie:" or "Cookie:" header data for the
given HTTP connection as described in RFC 6265. Use the
httpGetCookieValue
to get the value of a named "Cookie:" value.
Get the value of a named cookie from the HTTP connection.
char *httpGetCookieValue(http_t *http, const char *name, char *buffer, size_t bufsize);
http | HTTP connection |
---|---|
name | Cookie name |
buffer | Value buffer |
bufsize | Size of value buffer |
Cookie value or NULL
if not present
This function copies the value of a named cookie in the HTTP "Cookie:" header
for the given HTTP connection as described in RFC 6265. Use the
httpGetCookie
function to get the original "Cookie:" string.
Get a formatted date/time string from a time value.
const char *httpGetDateString2(time_t t, char *s, int slen);
t | Time in seconds |
---|---|
s | String buffer |
slen | Size of string buffer |
Date/time string
Get a time value from a formatted date/time string.
time_t httpGetDateTime(const char *s);
s | Date/time string |
---|
Time in seconds
Get the current encryption mode of a connection.
http_encryption_t httpGetEncryption(http_t *http);
http | HTTP connection |
---|
Current encryption mode
This function returns the encryption mode for the connection. Use the
httpIsEncrypted
function to determine whether a TLS session has
been established.
Get the last error on a connection.
int httpGetError(http_t *http);
http | HTTP connection |
---|
Error code (errno) value
Get the value of the Expect header, if any.
http_status_t httpGetExpect(http_t *http);
http | HTTP connection |
---|
Expect: status, if any
Returns HTTP_STATUS_NONE
if there is no Expect header, otherwise
returns the expected HTTP status code, typically HTTP_STATUS_CONTINUE
.
Get the file descriptor associated with a connection.
int httpGetFd(http_t *http);
http | HTTP connection |
---|
File descriptor or -1 if none
Get a field value from a request/response.
const char *httpGetField(http_t *http, http_field_t field);
http | HTTP connection |
---|---|
field | Field to get |
Field value
Get the FQDN for the connection or local system.
const char *httpGetHostname(http_t *http, char *s, int slen);
http | HTTP connection or NULL |
---|---|
s | String buffer for name |
slen | Size of buffer |
FQDN for connection or system
When "http" points to a connected socket, return the hostname or address that was used in the call to httpConnect() or httpConnectEncrypt(), or the address of the client for the connection from httpAcceptConnection(). Otherwise, return the FQDN for the local system using both gethostname() and gethostbyname() to get the local hostname with domain.
Get the current Keep-Alive state of the connection.
http_keepalive_t httpGetKeepAlive(http_t *http);
http | HTTP connection |
---|
Keep-Alive state
Get the amount of data remaining from the Content-Length or Transfer-Encoding fields.
off_t httpGetLength2(http_t *http);
http | HTTP connection |
---|
Content length
This function returns the complete content length, even for content larger than 2^31 - 1.
Get the number of bytes that are buffered for writing.
size_t httpGetPending(http_t *http);
http | HTTP connection |
---|
Number of bytes buffered
Get the number of bytes that can be read without blocking.
size_t httpGetReady(http_t *http);
http | HTTP connection |
---|
Number of bytes available
Get the number of remaining bytes in the message body or current chunk.
size_t httpGetRemaining(http_t *http);
http | HTTP connection |
---|
Remaining bytes
The httpIsChunked
function can be used to determine whether the
message body is chunked or fixed-length.
Get the TLS version and cipher suite used by a connection.
const char *httpGetSecurity(http_t *http, char *buffer, size_t bufsize);
http | HTTP connection |
---|---|
buffer | String buffer |
bufsize | Size of buffer |
Security information or NULL
if not encrypted
This function gets the TLS version and cipher suite being used by a connection, if any. The string is copied to "buffer" and is of the form "TLS/major.minor CipherSuite". If not encrypted, the buffer is cleared to the empty string.
Get the current state of the HTTP request.
http_state_t httpGetState(http_t *http);
http | HTTP connection |
---|
HTTP state
Get the status of the last HTTP request.
http_status_t httpGetStatus(http_t *http);
http | HTTP connection |
---|
HTTP status
Get a sub-field value.
char *httpGetSubField2(http_t *http, http_field_t field, const char *name, char *value, int valuelen);
http | HTTP connection |
---|---|
field | Field index |
name | Name of sub-field |
value | Value string |
valuelen | Size of value buffer |
Value or NULL
Get the HTTP version at the other end.
http_version_t httpGetVersion(http_t *http);
http | HTTP connection |
---|
Version number
Get a line of text from a HTTP connection.
char *httpGets2(http_t *http, char *line, size_t length);
http | HTTP connection |
---|---|
line | Line to read into |
length | Max length of buffer |
Line or NULL
Initialize the HTTP interface library and set the default HTTP proxy (if any).
void httpInitialize(void);
Report whether a message body is chunked.
int httpIsChunked(http_t *http);
http | HTTP connection |
---|
1 if chunked, 0 if not
This function returns non-zero if the message body is composed of variable-length chunks.
Report whether a connection is encrypted.
int httpIsEncrypted(http_t *http);
http | HTTP connection |
---|
1 if encrypted, 0 if not
This function returns non-zero if the connection is currently encrypted.
Compute the MD5 sum of the username:group:password.
char *httpMD5(const char *username, const char *realm, const char *passwd, char md5[33]);
username | User name |
---|---|
realm | Realm name |
passwd | Password string |
md5[33] | MD5 string |
MD5 sum
The function was used for HTTP Digest authentication. Since CUPS 2.4.0
it produces an empty string. Please use cupsDoAuthentication
instead.
Combine the MD5 sum of the username, group, and password with the server-supplied nonce value, method, and request-uri.
char *httpMD5Final(const char *nonce, const char *method, const char *resource, char md5[33]);
nonce | Server nonce value |
---|---|
method | METHOD (GET, POST, etc.) |
resource | Resource path |
md5[33] | MD5 sum |
New sum
The function was used for HTTP Digest authentication. Since CUPS 2.4.0
it produces an empty string. Please use cupsDoAuthentication
instead.
Convert an MD5 sum to a character string.
char *httpMD5String(const unsigned char *sum, char md5[33]);
sum | MD5 sum data |
---|---|
md5[33] | MD5 sum in hex |
MD5 sum in hex
The function was used for HTTP Digest authentication. Since CUPS 2.4.0
it produces an empty string. Please use cupsDoAuthentication
instead.
Peek at data from a HTTP connection.
ssize_t httpPeek(http_t *http, char *buffer, size_t length);
http | HTTP connection |
---|---|
buffer | Buffer for data |
length | Maximum number of bytes |
Number of bytes copied
This function copies available data from the given HTTP connection, reading
a buffer as needed. The data is still available for reading using
httpRead2
.
For non-blocking connections the usual timeouts apply.
Read data from a HTTP connection.
ssize_t httpRead2(http_t *http, char *buffer, size_t length);
http | HTTP connection |
---|---|
buffer | Buffer for data |
length | Maximum number of bytes |
Number of bytes read
Read a HTTP request from a connection.
http_state_t httpReadRequest(http_t *http, char *uri, size_t urilen);
http | HTTP connection |
---|---|
uri | URI buffer |
urilen | Size of URI buffer |
New state of connection
Resolve the hostname of the HTTP connection address.
const char *httpResolveHostname(http_t *http, char *buffer, size_t bufsize);
http | HTTP connection |
---|---|
buffer | Hostname buffer |
bufsize | Size of buffer |
Resolved hostname or NULL
Resolve a DNS-SD URI.
const char *httpResolveURI(const char *uri, char *resolved_uri, size_t resolved_size, http_resolve_t options, http_resolve_cb_t cb, void *cb_data);
uri | DNS-SD URI |
---|---|
resolved_uri | Buffer for resolved URI |
resolved_size | Size of URI buffer |
options | Resolve options |
cb | Continue callback function |
cb_data | Context pointer for callback |
Resolved URI
This function resolves a DNS-SD URI of the form "scheme://service-instance-name._protocol._tcp.domain/...". The "options" parameter specifies a bitfield of resolution options including:
HTTP_RESOLVE_DEFAULT
: Use default options
HTTP_RESOLVE_FQDN
: Resolve the fully-qualified domain name instead of an IP address
HTTP_RESOLVE_FAXOUT
: Resolve the FaxOut service instead of Print (IPP/IPPS)The "cb" parameter specifies a callback that allows resolution to be
terminated. The callback is provided the "cb_data" value and returns a
bool
value that is true
to continue and false
to stop. If no callback
is specified ("cb" is NULL
), then this function will block up to 90 seconds
to resolve the specified URI.
Separate a Universal Resource Identifier into its components.
http_uri_status_t httpSeparateURI(http_uri_coding_t decoding, const char *uri, char *scheme, int schemelen, char *username, int usernamelen, char *host, int hostlen, int *port, char *resource, int resourcelen);
decoding | Decoding flags |
---|---|
uri | Universal Resource Identifier |
scheme | Scheme (http, https, etc.) |
schemelen | Size of scheme buffer |
username | Username |
usernamelen | Size of username buffer |
host | Hostname |
hostlen | Size of hostname buffer |
port | Port number to use |
resource | Resource/filename |
resourcelen | Size of resource buffer |
Result of separation
Set the current authorization string.
void httpSetAuthString(http_t *http, const char *scheme, const char *data);
http | HTTP connection |
---|---|
scheme | Auth scheme (NULL to clear it) |
data | Auth data (NULL for none) |
This function just stores a copy of the current authorization string in
the HTTP connection object. You must still call httpSetField
to set
HTTP_FIELD_AUTHORIZATION
prior to issuing a HTTP request using
httpWriteRequest
.
Set blocking/non-blocking behavior on a connection.
void httpSetBlocking(http_t *http, bool b);
http | HTTP connection |
---|---|
b | true for blocking, false for non-blocking |
Add Set-Cookie value(s).
void httpSetCookie(http_t *http, const char *cookie);
http | HTTP cnnection |
---|---|
cookie | Cookie string |
This function adds one or more Set-Cookie header values that will be sent to
the client with the httpWriteResponse
function. Each value conforms
to the format defined in RFC 6265. Multiple values can be passed in the
"cookie" string separated by a newline character.
Call the httpClearCookies
function to clear all Set-Cookie values.
Set the default value of an HTTP header.
void httpSetDefaultField(http_t *http, http_field_t field, const char *value);
http | HTTP connection |
---|---|
field | Field index |
value | Value |
Currently only HTTP_FIELD_ACCEPT_ENCODING
, HTTP_FIELD_SERVER
,
and HTTP_FIELD_USER_AGENT
can be set.
Set the required encryption on the link.
bool httpSetEncryption(http_t *http, http_encryption_t e);
http | HTTP connection |
---|---|
e | New encryption preference |
true
on success, false
on error
Set the Expect: header in a request.
void httpSetExpect(http_t *http, http_status_t expect);
http | HTTP connection |
---|---|
expect | HTTP status to expect (HTTP_STATUS_CONTINUE ) |
Currently only HTTP_STATUS_CONTINUE
is supported for the "expect"
argument.
Set the value of an HTTP header.
void httpSetField(http_t *http, http_field_t field, const char *value);
http | HTTP connection |
---|---|
field | Field index |
value | Value |
Set the current Keep-Alive state of a connection.
void httpSetKeepAlive(http_t *http, http_keepalive_t keep_alive);
http | HTTP connection |
---|---|
keep_alive | New Keep-Alive value |
Set the content-length and content-encoding.
void httpSetLength(http_t *http, size_t length);
http | HTTP connection |
---|---|
length | Length (0 for chunked) |
Set read/write timeouts and an optional callback.
void httpSetTimeout(http_t *http, double timeout, http_timeout_cb_t cb, void *user_data);
http | HTTP connection |
---|---|
timeout | Number of seconds for timeout, must be greater than 0.0 |
cb | Callback function or NULL |
user_data | User data pointer |
The optional timeout callback receives both the HTTP connection and a user data pointer and must return 1 to continue or 0 to error (time) out.
Shutdown one side of an HTTP connection.
void httpShutdown(http_t *http);
http | HTTP connection |
---|
Return the string describing a HTTP state value.
const char *httpStateString(http_state_t state);
state | HTTP state value |
---|
State string
Return a short string describing a HTTP status code.
const char *httpStatusString(http_status_t status);
status | HTTP status code |
---|
Localized status string
The returned string is localized to the current POSIX locale and is based on the status strings defined in RFC 7231.
Return a string describing a URI status code.
const char *httpURIStatusString(http_uri_status_t status);
status | URI status code |
---|
Localized status string
Update the current HTTP state for incoming data.
http_status_t httpUpdate(http_t *http);
http | HTTP connection |
---|
HTTP status
Wait for data available on a connection.
int httpWait(http_t *http, int msec);
http | HTTP connection |
---|---|
msec | Milliseconds to wait |
1 if data is available, 0 otherwise
Write data to a HTTP connection.
ssize_t httpWrite2(http_t *http, const char *buffer, size_t length);
http | HTTP connection |
---|---|
buffer | Buffer for data |
length | Number of bytes to write |
Number of bytes written
Send a HTTP request.
bool httpWriteRequest(http_t *http, const char *method, const char *uri);
http | HTTP connection |
---|---|
method | Method string ("GET", "POST", etc.) |
uri | URI |
true
on success, false
on error
Write a HTTP response to a client connection.
int httpWriteResponse(http_t *http, http_status_t status);
http | HTTP connection |
---|---|
status | Status code |
0 on success, -1 on error
Add a boolean attribute to an IPP message.
ipp_attribute_t *ippAddBoolean(ipp_t *ipp, ipp_tag_t group, const char *name, char value);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
value | Value of attribute |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add an array of boolean values.
ipp_attribute_t *ippAddBooleans(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const char *values);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
num_values | Number of values |
values | Values |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add a collection value.
ipp_attribute_t *ippAddCollection(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_t *value);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
value | Value |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add an array of collection values.
ipp_attribute_t *ippAddCollections(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const ipp_t **values);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
num_values | Number of values |
values | Values |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add a credentials string attribute to an IPP message.
ipp_attribute_t *ippAddCredentialsString(ipp_t *ipp, ipp_tag_t group, const char *name, const char *credentials);
ipp | IPP message |
---|---|
group | IPP group |
name | Attribute name |
credentials | Credentials string |
New attribute
This function adds a 1setOf text attribute to an IPP message corresponding to
the specified credentials string.
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add a dateTime attribute to an IPP message.
ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group, const char *name, const ipp_uchar_t *value);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
value | Value |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add a integer attribute to an IPP message.
ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, int value);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
value | Value of attribute |
New attribute
This function adds an integer or enum attribute to an IPP message.
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported values include enum (IPP_TAG_ENUM
) and integer
(IPP_TAG_INTEGER
).
Add an array of integer values.
ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, int num_values, const int *values);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
num_values | Number of values |
values | Values |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported values include enum (IPP_TAG_ENUM
) and integer
(IPP_TAG_INTEGER
).
Add an octetString value to an IPP message.
ipp_attribute_t *ippAddOctetString(ipp_t *ipp, ipp_tag_t group, const char *name, const void *data, int datalen);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
data | octetString data |
datalen | Length of data in bytes |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add an out-of-band value to an IPP message.
ipp_attribute_t *ippAddOutOfBand(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported out-of-band values include unsupported-value
(IPP_TAG_UNSUPPORTED_VALUE
), default (IPP_TAG_DEFAULT
), unknown
(IPP_TAG_UNKNOWN
), no-value (IPP_TAG_NOVALUE
), not-settable
(IPP_TAG_NOTSETTABLE
), delete-attribute (IPP_TAG_DELETEATTR
), and
admin-define (IPP_TAG_ADMINDEFINE
).
Add a range of values to an IPP message.
ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group, const char *name, int lower, int upper);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
lower | Lower value |
upper | Upper value |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
The "lower" parameter must be less than or equal to the "upper" parameter.
Add ranges of values to an IPP message.
ipp_attribute_t *ippAddRanges(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const int *lower, const int *upper);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
num_values | Number of values |
lower | Lower values |
upper | Upper values |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add a resolution value to an IPP message.
ipp_attribute_t *ippAddResolution(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_res_t units, int xres, int yres);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
units | Units for resolution |
xres | X resolution |
yres | Y resolution |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add resolution values to an IPP message.
ipp_attribute_t *ippAddResolutions(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, ipp_res_t units, const int *xres, const int *yres);
ipp | IPP message |
---|---|
group | IPP group |
name | Name of attribute |
num_values | Number of values |
units | Units for resolution |
xres | X resolutions |
yres | Y resolutions |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Add a group separator to an IPP message.
ipp_attribute_t *ippAddSeparator(ipp_t *ipp);
ipp | IPP message |
---|
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
Add a language-encoded string to an IPP message.
ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, const char *language, const char *value);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
language | Language code |
value | Value |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported string values include charset (IPP_TAG_CHARSET
), keyword
(IPP_TAG_KEYWORD
), language (IPP_TAG_LANGUAGE
), mimeMediaType
(IPP_TAG_MIMETYPE
), name (IPP_TAG_NAME
), nameWithLanguage
(IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
(`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
(`IPP_TAG_URISCHEME`).
The "language" parameter must be non-`NULL` for nameWithLanguage and
textWithLanguage string values and must be `NULL` for all other string values.
Add a formatted string to an IPP message.
ipp_attribute_t *ippAddStringf(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, const char *language, const char *format, ...);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
language | Language code (NULL for default) |
format | Printf-style format string |
... | Additional arguments as needed |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document
(IPP_TAG_DOCUMENT
), event notification
(IPP_TAG_EVENT_NOTIFICATION
), operation (IPP_TAG_OPERATION
),
printer (IPP_TAG_PRINTER
), subscription (IPP_TAG_SUBSCRIPTION
),
or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported string values include charset (IPP_TAG_CHARSET
), keyword
(IPP_TAG_KEYWORD
), language (IPP_TAG_LANGUAGE
), mimeMediaType
(IPP_TAG_MIMETYPE
), name (IPP_TAG_NAME
), nameWithLanguage
(IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
(`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
(`IPP_TAG_URISCHEME`).
The "language" parameter must be non-`NULL` for nameWithLanguage
and textWithLanguage string values and must be `NULL` for all other
string values.
The "format" parameter uses formatting characters compatible with the
printf family of standard functions. Additional arguments follow it as
needed. The formatted string is truncated as needed to the maximum length of
the corresponding value type.
since CUPS 1.7@
Add a formatted string to an IPP message.
ipp_attribute_t *ippAddStringfv(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, const char *language, const char *format, va_list ap);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
language | Language code (NULL for default) |
format | Printf-style format string |
ap | Additional arguments |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document
(IPP_TAG_DOCUMENT
), event notification
(IPP_TAG_EVENT_NOTIFICATION
), operation (IPP_TAG_OPERATION
),
printer (IPP_TAG_PRINTER
), subscription (IPP_TAG_SUBSCRIPTION
),
or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported string values include charset (IPP_TAG_CHARSET
), keyword
(IPP_TAG_KEYWORD
), language (IPP_TAG_LANGUAGE
), mimeMediaType
(IPP_TAG_MIMETYPE
), name (IPP_TAG_NAME
), nameWithLanguage
(IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
(`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
(`IPP_TAG_URISCHEME`).
The "language" parameter must be non-`NULL` for nameWithLanguage
and textWithLanguage string values and must be `NULL` for all other
string values.
The "format" parameter uses formatting characters compatible with the
printf family of standard functions. Additional arguments are passed in the
stdarg pointer "ap". The formatted string is truncated as needed to the
maximum length of the corresponding value type.
since CUPS 1.7@
Add language-encoded strings to an IPP message.
ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag, const char *name, int num_values, const char *language, const char *const *values);
ipp | IPP message |
---|---|
group | IPP group |
value_tag | Type of attribute |
name | Name of attribute |
num_values | Number of values |
language | Language code (NULL for default) |
values | Values |
New attribute
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Supported string values include charset (IPP_TAG_CHARSET
), keyword
(IPP_TAG_KEYWORD
), language (IPP_TAG_LANGUAGE
), mimeMediaType
(IPP_TAG_MIMETYPE
), name (IPP_TAG_NAME
), nameWithLanguage
(IPP_TAG_NAMELANG), text (`IPP_TAG_TEXT`), textWithLanguage
(`IPP_TAG_TEXTLANG`), uri (`IPP_TAG_URI`), and uriScheme
(`IPP_TAG_URISCHEME`).
The "language" parameter must be non-`NULL` for nameWithLanguage and
textWithLanguage string values and must be `NULL` for all other string values.
Convert the attribute's value to a string.
size_t ippAttributeString(ipp_attribute_t *attr, char *buffer, size_t bufsize);
attr | Attribute |
---|---|
buffer | String buffer or NULL |
bufsize | Size of string buffer |
Number of bytes less nul
Returns the number of bytes that would be written, not including the trailing nul. The buffer pointer can be NULL to get the required length, just like (v)snprintf.
Determine whether an attribute contains the specified value or is within the list of ranges.
int ippContainsInteger(ipp_attribute_t *attr, int value);
attr | Attribute |
---|---|
value | Integer/enum value |
1 on a match, 0 on no match
Returns non-zero when the attribute contains either a matching integer or enum value, or the value falls within one of the rangeOfInteger values for the attribute.
Determine whether an attribute contains the specified string value.
int ippContainsString(ipp_attribute_t *attr, const char *value);
attr | Attribute |
---|---|
value | String value |
1 on a match, 0 on no match
Returns non-zero when the attribute contains a matching charset, keyword, naturalLanguage, mimeMediaType, name, text, uri, or uriScheme value.
Copy an attribute.
ipp_attribute_t *ippCopyAttribute(ipp_t *dst, ipp_attribute_t *srcattr, int quickcopy);
dst | Destination IPP message |
---|---|
srcattr | Attribute to copy |
quickcopy | 1 for a referenced copy, 0 for normal |
New attribute
The specified attribute, attr
, is copied to the destination IPP message.
When "quickcopy" is non-zero, a "shallow" reference copy of the attribute is
created - this should only be done as long as the original source IPP message will
not be freed for the life of the destination.
Copy attributes from one IPP message to another.
int ippCopyAttributes(ipp_t *dst, ipp_t *src, int quickcopy, ipp_copy_cb_t cb, void *context);
dst | Destination IPP message |
---|---|
src | Source IPP message |
quickcopy | 1 for a referenced copy, 0 for normal |
cb | Copy callback or NULL for none |
context | Context pointer |
1 on success, 0 on error
Zero or more attributes are copied from the source IPP message "src" to the
destination IPP message "dst". When "quickcopy" is non-zero, a "shallow"
reference copy of the attribute is created - this should only be done as long
as the original source IPP message will not be freed for the life of the
destination.
The "cb" and "context" parameters provide a generic way to "filter" the
attributes that are copied - the function must return 1 to copy the attribute or
0 to skip it. The function may also choose to do a partial copy of the source attribute
itself.
Copy a credentials value from an IPP attribute.
char *ippCopyCredentialsString(ipp_attribute_t *attr);
attr | Attribute |
---|
Combined string or NULL
on error
This function concatenates the 1setOf text credential values of an attribute,
separated by newlines. The returned string must be freed using the free
function.
Create a CUPS array of attribute names from the given requested-attributes attribute.
cups_array_t *ippCreateRequestedArray(ipp_t *request);
request | IPP request |
---|
CUPS array or NULL
if all
This function creates a (sorted) CUPS array of attribute names matching the
list of "requested-attribute" values supplied in an IPP request. All IANA-
registered values are supported in addition to the CUPS IPP extension
attributes.
The request
parameter specifies the request message that was read from
the client.
NULL
is returned if all attributes should be returned. Otherwise, the
result is a sorted array of attribute names, where cupsArrayFind(array,
"attribute-name")
will return a non-NULL pointer. The array must be freed
using the cupsArrayDelete
function.
Convert from RFC 2579 Date/Time format to time in seconds.
time_t ippDateToTime(const ipp_uchar_t *date);
date | RFC 2579 date info |
---|
UNIX time value
Delete an IPP message.
void ippDelete(ipp_t *ipp);
ipp | IPP message |
---|
Delete a single attribute in an IPP message.
void ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr);
ipp | IPP message |
---|---|
attr | Attribute to delete |
Delete values in an attribute.
int ippDeleteValues(ipp_t *ipp, ipp_attribute_t **attr, int element, int count);
ipp | IPP message |
---|---|
attr | Attribute |
element | Index of first value to delete (0-based) |
count | Number of values to delete |
1 on success, 0 on failure
This function deletes one or more values in an attribute. The "element"
parameter specifies the first value to delete, starting at 0. It must be
less than the number of values returned by ippGetCount
.
The "attr" parameter may be modified as a result of setting the value,
which will set the variable to NULL
.
Deleting all values in an attribute deletes the attribute.
Return a string corresponding to the enum value.
const char *ippEnumString(const char *attrname, int enumvalue);
attrname | Attribute name |
---|---|
enumvalue | Enum value |
Enum string
Return the value associated with a given enum string.
int ippEnumValue(const char *attrname, const char *enumstring);
attrname | Attribute name |
---|---|
enumstring | Enum string |
Enum value or -1 if unknown
Return a name for the given status code.
const char *ippErrorString(ipp_status_t error);
error | Error status |
---|
Text string
Return a status code for the given name.
ipp_status_t ippErrorValue(const char *name);
name | Name |
---|
IPP status code
Close an IPP data file.
bool ippFileClose(ipp_file_t *file);
file | IPP data file |
---|
true
on success, false
on error
This function closes the current IPP data file. The ipp_file_t
object can
be reused for another file as needed.
Close an IPP data file and free all memory.
bool ippFileDelete(ipp_file_t *file);
file | IPP data file |
---|
true
on success, false
on error
This function closes an IPP data file, if necessary, and frees all memory associated with it.
Expand IPP data file and environment variables in a string.
size_t ippFileExpandVars(ipp_file_t *file, char *dst, const char *src, size_t dstsize);
file | IPP data file |
---|---|
dst | Destination buffer |
src | Source string |
dstsize | Size of destination buffer |
Required size for expanded variables
This function expands IPP data file variables of the form "$name" and environment variables of the form "$ENV[name]" in the source string to the destination string. The
Get a single named attribute from an IPP data file.
ipp_attribute_t *ippFileGetAttribute(ipp_file_t *file, const char *name, ipp_tag_t value_tag);
file | IPP data file |
---|---|
name | Attribute name |
value_tag | Value tag or IPP_TAG_ZERO for any |
Attribute or NULL
if none
This function finds the first occurence of a named attribute in the current
IPP attributes in the specified data file. Unlike
ippFileGetAttributes
, this function does not clear the attribute
state.
Get the current set of attributes from an IPP data file.
ipp_t *ippFileGetAttributes(ipp_file_t *file);
file | IPP data file |
---|
IPP attributes
This function gets the current set of attributes from an IPP data file.
Get the filename for an IPP data file.
const char *ippFileGetFilename(ipp_file_t *file);
file | IPP data file |
---|
Filename
This function returns the filename associated with an IPP data file.
Get the current line number in an IPP data file.
int ippFileGetLineNumber(ipp_file_t *file);
file | IPP data file |
---|
Line number
This function returns the current line number in an IPP data file.
Get the value of an IPP data file variable.
const char *ippFileGetVar(ipp_file_t *file, const char *name);
file | IPP data file |
---|---|
name | Variable name |
Variable value or NULL
if none.
This function returns the value of an IPP data file variable. NULL
is
returned if the variable is not set.
Create a new IPP data file object for reading or writing.
ipp_file_t *ippFileNew(ipp_file_t *parent, ipp_fattr_cb_t attr_cb, ipp_ferror_cb_t error_cb, void *cb_data);
parent | Parent data file or NULL for none |
---|---|
attr_cb | Attribute filtering callback, if any |
error_cb | Error reporting callback, if any |
cb_data | Callback data, if any |
IPP data file
This function opens an IPP data file for reading (mode="r") or writing
(mode="w"). If the "parent" argument is not NULL
, all variables from the
parent data file are copied to the new file.
Open an IPP data file for reading or writing.
bool ippFileOpen(ipp_file_t *file, const char *filename, const char *mode);
file | IPP data file |
---|---|
filename | Filename to open |
mode | Open mode - "r" to read and "w" to write |
true
on success, false
on error
This function opens an IPP data file for reading (mode="r") or writing
(mode="w"). If the "parent" argument is not NULL
, all variables from the
parent data file are copied to the new file.
Read an IPP data file.
bool ippFileRead(ipp_file_t *file, ipp_ftoken_cb_t token_cb, bool with_groups);
file | IPP data file |
---|---|
token_cb | Token callback |
with_groups | Read attributes with GROUP directives |
true
on success, false
on error
Read a collection from an IPP data file.
ipp_t *ippFileReadCollection(ipp_file_t *file);
file | IPP data file |
---|
Collection value
This function reads a collection value from an IPP data file. Collection values are surrounded by curly braces ("{" and "}") and have "MEMBER" directives to define member attributes in the collection.
Read a token from an IPP data file.
bool ippFileReadToken(ipp_file_t *file, char *token, size_t tokensize);
file | IPP data file |
---|---|
token | Token buffer |
tokensize | Size of token buffer |
true
on success, false
on error
This function reads a single token or value from an IPP data file, skipping comments and whitespace as needed.
Restore the previous position in an IPP data file.
bool ippFileRestorePosition(ipp_file_t *file);
file | IPP data file |
---|
true
on success, false
on failure
This function restores the previous position in an IPP data file that is open for reading.
Save the current position in an IPP data file.
bool ippFileSavePosition(ipp_file_t *file);
file | IPP data file |
---|
true
on success, false
on failure
This function saves the current position in an IPP data file that is open for reading.
Set the attributes for an IPP data file.
bool ippFileSetAttributes(ipp_file_t *file, ipp_t *attrs);
file | IPP data file |
---|---|
attrs | IPP attributes |
true
on success, false
otherwise
This function sets the current set of attributes for an IPP data file,
typically an empty collection created with ippNew
.
Set the group tag for an IPP data file.
bool ippFileSetGroupTag(ipp_file_t *file, ipp_tag_t group_tag);
file | IPP data file |
---|---|
group_tag | Group tag |
true
on success, false
otherwise
This function sets the group tag associated with attributes that are read from an IPP data file.
Set an IPP data file variable to a constant value.
bool ippFileSetVar(ipp_file_t *file, const char *name, const char *value);
file | IPP data file |
---|---|
name | Variable name |
value | Value |
true
on success, false
on failure
This function sets an IPP data file variable to a constant value. Setting the "uri" variable also initializes the "scheme", "uriuser", "hostname", "port", and "resource" variables.
Set an IPP data file variable to a formatted value.
bool ippFileSetVarf(ipp_file_t *file, const char *name, const char *value, ...);
file | IPP data file |
---|---|
name | Variable name |
value | Printf-style value |
... | Additional arguments as needed |
true
on success, false
on error
This function sets an IPP data file variable to a formatted value. Setting the "uri" variable also initializes the "scheme", "uriuser", "hostname", "port", and "resource" variables.
Write an IPP message to an IPP data file.
bool ippFileWriteAttributes(ipp_file_t *file, ipp_t *ipp, bool with_groups);
file | IPP data file |
---|---|
ipp | IPP attributes to write |
with_groups | true to include GROUPs, false otherwise |
true
on success, false
on error
This function writes an IPP message to an IPP data file using the attribute
filter specified in the call to ippFileOpen
. If "with_group" is
true
, "GROUP" directives are written as necessary to place the attributes
in the correct groups.
Write a comment to an IPP data file.
bool ippFileWriteComment(ipp_file_t *file, const char *comment, ...);
file | IPP data file |
---|---|
comment | Printf-style comment string |
... | Additional arguments as needed |
true
on success, false
on error
This function writes a comment to an IPP data file. Every line in the string is prefixed with the "#" character and indented as needed.
Write a token or value string to an IPP data file.
bool ippFileWriteToken(ipp_file_t *file, const char *token);
file | IPP data file |
---|---|
token | Token/value string |
true
on success, false
on error
This function writes a token or value string to an IPP data file, quoting and indenting the string as needed.
Write a formatted token or value string to an IPP data file.
bool ippFileWriteTokenf(ipp_file_t *file, const char *token, ...);
file | IPP data file |
---|---|
token | Printf-style token/value string |
... | Additional arguments as needed |
true
on success, false
on error
This function writes a formatted token or value string to an IPP data file, quoting and indenting the string as needed.
Find a named attribute in a request.
ipp_attribute_t *ippFindAttribute(ipp_t *ipp, const char *name, ipp_tag_t type);
ipp | IPP message |
---|---|
name | Name of attribute |
type | Type of attribute |
Matching attribute
This function finds the first occurrence of a named attribute in an IPP message. The attribute name can contain a hierarchical list of attribute and member names separated by slashes, for example "media-col/media-size".
Find the next named attribute in a request.
ipp_attribute_t *ippFindNextAttribute(ipp_t *ipp, const char *name, ipp_tag_t type);
ipp | IPP message |
---|---|
name | Name of attribute |
type | Type of attribute |
Matching attribute
This function finds the next named attribute in an IPP message. The attribute name can contain a hierarchical list of attribute and member names separated by slashes, for example "media-col/media-size".
Get a boolean value for an attribute.
int ippGetBoolean(ipp_attribute_t *attr, int element);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
Boolean value or 0 on error
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Get a collection value for an attribute.
ipp_t *ippGetCollection(ipp_attribute_t *attr, int element);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
Collection value or NULL
on error
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Get the number of values in an attribute.
int ippGetCount(ipp_attribute_t *attr);
attr | IPP attribute |
---|
Number of values or 0 on error
Get a dateTime value for an attribute.
const ipp_uchar_t *ippGetDate(ipp_attribute_t *attr, int element);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
dateTime value or NULL
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Return the first attribute in the message.
ipp_attribute_t *ippGetFirstAttribute(ipp_t *ipp);
ipp | IPP message |
---|
First attribute or NULL
if none
Get the group associated with an attribute.
ipp_tag_t ippGetGroupTag(ipp_attribute_t *attr);
attr | IPP attribute |
---|
Group tag or IPP_TAG_ZERO
on error
Get the integer/enum value for an attribute.
int ippGetInteger(ipp_attribute_t *attr, int element);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
Value or 0 on error
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Compute the length of an IPP message.
size_t ippGetLength(ipp_t *ipp);
ipp | IPP message |
---|
Size of IPP message
Get the attribute name.
const char *ippGetName(ipp_attribute_t *attr);
attr | IPP attribute |
---|
Attribute name or NULL
for separators
Return the next attribute in the message.
ipp_attribute_t *ippGetNextAttribute(ipp_t *ipp);
ipp | IPP message |
---|
Next attribute or NULL
if none
Get an octetString value from an IPP attribute.
void *ippGetOctetString(ipp_attribute_t *attr, int element, int *datalen);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
datalen | Length of octetString data |
Pointer to octetString data
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Get the operation ID in an IPP message.
ipp_op_t ippGetOperation(ipp_t *ipp);
ipp | IPP request message |
---|
Operation ID or 0 on error
Return the default IPP port number.
int ippGetPort(void);
Port number
Get a rangeOfInteger value from an attribute.
int ippGetRange(ipp_attribute_t *attr, int element, int *uppervalue);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
uppervalue | Upper value of range |
Lower value of range or 0
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Get the request ID from an IPP message.
int ippGetRequestId(ipp_t *ipp);
ipp | IPP message |
---|
Request ID or 0 on error
Get a resolution value for an attribute.
int ippGetResolution(ipp_attribute_t *attr, int element, int *yres, ipp_res_t *units);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
yres | Vertical/feed resolution |
units | Units for resolution |
Horizontal/cross feed resolution or 0
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Get the IPP message state.
ipp_state_t ippGetState(ipp_t *ipp);
ipp | IPP message |
---|
IPP message state value
Get the status code from an IPP response or event message.
ipp_status_t ippGetStatusCode(ipp_t *ipp);
ipp | IPP response or event message |
---|
Status code in IPP message
const char *ippGetString(ipp_attribute_t *attr, int element, const char **language);
attr | IPP attribute |
---|---|
element | Value number (0-based) |
language | Language code (NULL for don't care) |
Get the string and optionally the language code for an attribute.
The "element" parameter specifies which value to get from 0 to
ippGetCount(attr)
- 1.
Get the value tag for an attribute.
ipp_tag_t ippGetValueTag(ipp_attribute_t *attr);
attr | IPP attribute |
---|
Value tag or IPP_TAG_ZERO
on error
Get the major and minor version number from an IPP message.
int ippGetVersion(ipp_t *ipp, int *minor);
ipp | IPP message |
---|---|
minor | Minor version number or NULL for don't care |
Major version number or 0 on error
Allocate a new IPP message.
ipp_t *ippNew(void);
New IPP message
Allocate a new IPP request message.
ipp_t *ippNewRequest(ipp_op_t op);
op | Operation code |
---|
IPP request message
The new request message is initialized with the "attributes-charset" and "attributes-natural-language" attributes added. The "attributes-natural-language" value is derived from the current locale.
Allocate a new IPP response message.
ipp_t *ippNewResponse(ipp_t *request);
request | IPP request message |
---|
IPP response message
The new response message is initialized with the same "version-number", "request-id", "attributes-charset", and "attributes-natural-language" as the provided request message. If the "attributes-charset" or "attributes-natural-language" attributes are missing from the request, 'utf-8' and a value derived from the current locale are substituted, respectively.
Return a name for the given operation id.
const char *ippOpString(ipp_op_t op);
op | Operation ID |
---|
Name
Return an operation id for the given name.
ipp_op_t ippOpValue(const char *name);
name | Textual name |
---|
Operation ID
Read data for an IPP message from a HTTP connection.
ipp_state_t ippRead(http_t *http, ipp_t *ipp);
http | HTTP connection |
---|---|
ipp | IPP data |
Current state
Read data for an IPP message from a file.
ipp_state_t ippReadFile(int fd, ipp_t *ipp);
fd | HTTP data |
---|---|
ipp | IPP data |
Current state
Read data for an IPP message.
ipp_state_t ippReadIO(void *src, ipp_io_cb_t cb, int blocking, ipp_t *parent, ipp_t *ipp);
src | Data source |
---|---|
cb | Read callback function |
blocking | Use blocking IO? |
parent | Parent request, if any |
ipp | IPP data |
Current state
Restore a previously saved find position.
void ippRestore(ipp_t *ipp);
ipp | IPP message |
---|
Save the current find position.
void ippSave(ipp_t *ipp);
ipp | IPP message |
---|
Set a boolean value in an attribute.
int ippSetBoolean(ipp_t *ipp, ipp_attribute_t **attr, int element, int boolvalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
boolvalue | Boolean value |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set a collection value in an attribute.
int ippSetCollection(ipp_t *ipp, ipp_attribute_t **attr, int element, ipp_t *colvalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
colvalue | Collection value |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set a dateTime value in an attribute.
int ippSetDate(ipp_t *ipp, ipp_attribute_t **attr, int element, const ipp_uchar_t *datevalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
datevalue | dateTime value |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set the group tag of an attribute.
int ippSetGroupTag(ipp_t *ipp, ipp_attribute_t **attr, ipp_tag_t group_tag);
ipp | IPP message |
---|---|
attr | Attribute |
group_tag | Group tag |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "group" parameter specifies the IPP attribute group tag: none
(IPP_TAG_ZERO
, for member attributes), document (IPP_TAG_DOCUMENT
),
event notification (IPP_TAG_EVENT_NOTIFICATION
), operation
(IPP_TAG_OPERATION
), printer (IPP_TAG_PRINTER
), subscription
(IPP_TAG_SUBSCRIPTION
), or unsupported (IPP_TAG_UNSUPPORTED_GROUP
).
Set an integer or enum value in an attribute.
int ippSetInteger(ipp_t *ipp, ipp_attribute_t **attr, int element, int intvalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
intvalue | Integer/enum value |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set the name of an attribute.
int ippSetName(ipp_t *ipp, ipp_attribute_t **attr, const char *name);
ipp | IPP message |
---|---|
attr | IPP attribute |
name | Attribute name |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
Set an octetString value in an IPP attribute.
int ippSetOctetString(ipp_t *ipp, ipp_attribute_t **attr, int element, const void *data, int datalen);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
data | Pointer to octetString data |
datalen | Length of octetString data |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set the operation ID in an IPP request message.
int ippSetOperation(ipp_t *ipp, ipp_op_t op);
ipp | IPP request message |
---|---|
op | Operation ID |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
Set the default port number.
void ippSetPort(int p);
p | Port number to use |
---|
Set a rangeOfInteger value in an attribute.
int ippSetRange(ipp_t *ipp, ipp_attribute_t **attr, int element, int lowervalue, int uppervalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
lowervalue | Lower bound for range |
uppervalue | Upper bound for range |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set the request ID in an IPP message.
int ippSetRequestId(ipp_t *ipp, int request_id);
ipp | IPP message |
---|---|
request_id | Request ID |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The request_id
parameter must be greater than 0.
Set a resolution value in an attribute.
int ippSetResolution(ipp_t *ipp, ipp_attribute_t **attr, int element, ipp_res_t unitsvalue, int xresvalue, int yresvalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
unitsvalue | Resolution units |
xresvalue | Horizontal/cross feed resolution |
yresvalue | Vertical/feed resolution |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set the current state of the IPP message.
int ippSetState(ipp_t *ipp, ipp_state_t state);
ipp | IPP message |
---|---|
state | IPP state value |
1 on success, 0 on failure
Set the status code in an IPP response or event message.
int ippSetStatusCode(ipp_t *ipp, ipp_status_t status);
ipp | IPP response or event message |
---|---|
status | Status code |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
Set a string value in an attribute.
int ippSetString(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *strvalue);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
strvalue | String value |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
Set a formatted string value of an attribute.
int ippSetStringf(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *format, ...);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
format | Printf-style format string |
... | Additional arguments as needed |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
The "format" parameter uses formatting characters compatible with the
printf family of standard functions. Additional arguments follow it as
needed. The formatted string is truncated as needed to the maximum length of
the corresponding value type.
Set a formatted string value of an attribute.
int ippSetStringfv(ipp_t *ipp, ipp_attribute_t **attr, int element, const char *format, va_list ap);
ipp | IPP message |
---|---|
attr | IPP attribute |
element | Value number (0-based) |
format | Printf-style format string |
ap | Pointer to additional arguments |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
The "element" parameter specifies which value to set from 0 to
ippGetCount(attr)
.
The "format" parameter uses formatting characters compatible with the
printf family of standard functions. Additional arguments follow it as
needed. The formatted string is truncated as needed to the maximum length of
the corresponding value type.
Set the value tag of an attribute.
int ippSetValueTag(ipp_t *ipp, ipp_attribute_t **attr, ipp_tag_t value_tag);
ipp | IPP message |
---|---|
attr | IPP attribute |
value_tag | Value tag |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The "attr" parameter may be modified as a result of setting the value.
Integer (IPP_TAG_INTEGER
) values can be promoted to rangeOfInteger
(IPP_TAG_RANGE
) values, the various string tags can be promoted to name
(IPP_TAG_NAME
) or nameWithLanguage (IPP_TAG_NAMELANG
) values, text
(IPP_TAG_TEXT
) values can be promoted to textWithLanguage
(IPP_TAG_TEXTLANG
) values, and all values can be demoted to the various
out-of-band value tags such as no-value (IPP_TAG_NOVALUE
). All other
changes will be rejected.
Promoting a string attribute to nameWithLanguage or textWithLanguage adds the language
code in the "attributes-natural-language" attribute or, if not present, the language
code for the current locale.
Set the version number in an IPP message.
int ippSetVersion(ipp_t *ipp, int major, int minor);
ipp | IPP message |
---|---|
major | Major version number (major.minor) |
minor | Minor version number (major.minor) |
1 on success, 0 on failure
The "ipp" parameter refers to an IPP message previously created using
the ippNew
, ippNewRequest
, or ippNewResponse
functions.
The valid version numbers are currently 1.0, 1.1, 2.0, 2.1, and 2.2.
Return the name corresponding to a state value.
const char *ippStateString(ipp_state_t state);
state | State value |
---|
State name
Return the tag name corresponding to a tag value.
const char *ippTagString(ipp_tag_t tag);
tag | Tag value |
---|
Tag name
The returned names are defined in RFC 8011 and the IANA IPP Registry.
Return the tag value corresponding to a tag name.
ipp_tag_t ippTagValue(const char *name);
name | Tag name |
---|
Tag value
The tag names are defined in RFC 8011 and the IANA IPP Registry.
Convert from time in seconds to RFC 2579 format.
const ipp_uchar_t *ippTimeToDate(time_t t);
t | Time in seconds |
---|
RFC-2579 date/time data
Validate the contents of an attribute.
int ippValidateAttribute(ipp_attribute_t *attr);
attr | Attribute |
---|
1 if valid, 0 otherwise
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, cupsGetErrorString
is set to a human-readable message.
Validate all attributes in an IPP message.
int ippValidateAttributes(ipp_t *ipp);
ipp | IPP message |
---|
1 if valid, 0 otherwise
This function validates the contents of the IPP message, including each
attribute. Like ippValidateAttribute
, cupsGetErrorString
is
set to a human-readable message on failure.
Write data for an IPP message to a HTTP connection.
ipp_state_t ippWrite(http_t *http, ipp_t *ipp);
http | HTTP connection |
---|---|
ipp | IPP data |
Current state
Write data for an IPP message to a file.
ipp_state_t ippWriteFile(int fd, ipp_t *ipp);
fd | HTTP data |
---|---|
ipp | IPP data |
Current state
Write data for an IPP message.
ipp_state_t ippWriteIO(void *dst, ipp_io_cb_t cb, int blocking, ipp_t *parent, ipp_t *ipp);
dst | Destination |
---|---|
cb | Write callback function |
blocking | Use blocking IO? |
parent | Parent IPP message |
ipp | IPP data |
Current state
Generate a PWG self-describing media size name.
int pwgFormatSizeName(char *keyword, size_t keysize, const char *prefix, const char *name, int width, int length, const char *units);
keyword | Keyword buffer |
---|---|
keysize | Size of keyword buffer |
prefix | Prefix for PWG size or NULL for automatic |
name | Size name or NULL |
width | Width of page in 2540ths |
length | Length of page in 2540ths |
units | Units - "in", "mm", or NULL for automatic |
1 on success, 0 on failure
This function generates a PWG self-describing media size name of the form
"prefix_name_WIDTHxLENGTHunits". The prefix is typically "custom" or "roll"
for user-supplied sizes but can also be "disc", "iso", "jis", "jpn", "na",
"oe", "om", "prc", or "roc". A value of NULL
automatically chooses
"oe" or "om" depending on the units.
The size name may only contain lowercase letters, numbers, "-", and ".". If
NULL
is passed, the size name will contain the formatted dimensions.
The width and length are specified in hundredths of millimeters, equivalent
to 1/100000th of a meter or 1/2540th of an inch. The width, length, and
units used for the generated size name are calculated automatically if the
units string is NULL
, otherwise inches ("in") or millimeters ("mm")
are used.
Initialize a pwg_size_t structure using IPP Job Template attributes.
int pwgInitSize(pwg_size_t *size, ipp_t *job, int *margins_set);
size | Size to initialize |
---|---|
job | Job template attributes |
margins_set | 1 if margins were set, 0 otherwise |
1 if size was initialized, 0 otherwise
This function initializes a pwg_size_t structure from an IPP "media" or
"media-col" attribute in the specified IPP message. 0 is returned if neither
attribute is found in the message or the values are not valid.
The "margins_set" variable is initialized to 1 if any "media-xxx-margin"
member attribute was specified in the "media-col" Job Template attribute,
otherwise it is initialized to 0.
Find a PWG media size by ISO/IPP legacy name.
pwg_media_t *pwgMediaForLegacy(const char *legacy);
legacy | Legacy size name |
---|
Matching size or NULL
The "name" argument specifies the legacy ISO media size name, for example "iso-a4" or "na-letter".
Find a PWG media size by Adobe PPD name.
pwg_media_t *pwgMediaForPPD(const char *ppd);
ppd | PPD size name |
---|
Matching size or NULL
The "ppd" argument specifies an Adobe page size name as defined in Table B.1
of the Adobe PostScript Printer Description File Format Specification Version
4.3.
If the name is non-standard, the returned PWG media size is stored in
thread-local storage and is overwritten by each call to the function in the
thread. Custom names can be of the form "Custom.WIDTHxLENGTH[units]" or
"WIDTHxLENGTH[units]".
Find a PWG media size by 5101.1 self-describing name.
pwg_media_t *pwgMediaForPWG(const char *pwg);
pwg | PWG size name |
---|
Matching size or NULL
The "pwg" argument specifies a self-describing media size name of the form
"prefix_name_WIDTHxLENGTHunits" as defined in PWG 5101.1.
If the name is non-standard, the returned PWG media size is stored in
thread-local storage and is overwritten by each call to the function in the
thread.
Get the PWG media size for the given dimensions.
pwg_media_t *pwgMediaForSize(int width, int length);
width | Width in hundredths of millimeters |
---|---|
length | Length in hundredths of millimeters |
PWG media name
The "width" and "length" are in hundredths of millimeters, equivalent to
1/100000th of a meter or 1/2540th of an inch.
If the dimensions are non-standard, the returned PWG media size is stored in
thread-local storage and is overwritten by each call to the function in the
thread.
Array element copy function
typedef void *(*)(void *element, void *data)cups_acopy_cb_t;
AdvanceMedia attribute values
typedef enum cups_adv_e cups_adv_t;
Array element free function
typedef void(*)(void *element, void *data)cups_afree_cb_t;
Array hash function
typedef int(*)(void *element, void *data)cups_ahash_cb_t;
Array comparison function
typedef int(*)(void *first, void *second, void *data)cups_array_cb_t;
CUPS array type
typedef struct _cups_array_s cups_array_t;
Boolean type
typedef enum cups_bool_e cups_bool_t;
Certificate signing subjectAltName callback
typedef bool(*)(const char *common_name, const char *subject_alt_name, void *user_data)cups_cert_san_cb_t;
Client credentials callback
typedef int(*)(http_t *http, void *tls, cups_array_t *distinguished_names, void *user_data)cups_client_cert_cb_t;
Condition variable
typedef pthread_cond_t cups_cond_t;
Combined X.509 credential purposes for cupsCreateCredentials
and cupsCreateCredentialsRequest
typedef unsigned cups_credpurpose_t;
X.509 credential types for cupsCreateCredentials
and cupsCreateCredentialsRequest
typedef enum cups_credtype_e cups_credtype_t;
Combined X.509 keyUsage flags for cupsCreateCredentials
and cupsCreateCredentialsRequest
typedef unsigned cups_credusage_t;
cupsColorSpace attribute values
typedef enum cups_cspace_e cups_cspace_t;
CutMedia attribute values
typedef enum cups_cut_e cups_cut_t;
DBCS Legacy 16-bit unit
typedef unsigned short cups_dbcs_t;
Directory entry type
typedef struct cups_dentry_s cups_dentry_t;
Destination enumeration callback
typedef int(*)(void *user_data, unsigned flags, cups_dest_t *dest)cups_dest_cb_t;
Combined flags for cupsConnectDest
and cupsEnumDests
typedef unsigned cups_dest_flags_t;
Destination
typedef struct cups_dest_s cups_dest_t;
Destination capability and status information
typedef struct _cups_dinfo_s cups_dinfo_t;
Directory type
typedef struct _cups_dir_s cups_dir_t;
DNS-SD browse callback
typedef void(*)(cups_dnssd_browse_t *browse, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *name, const char *regtype, const char *domain)cups_dnssd_browse_cb_t;
DNS-SD error callback
typedef void(*)(void *cb_data, const char *message)cups_dnssd_error_cb_t;
DNS-SD callback flag bitmask
typedef unsigned cups_dnssd_flags_t;
DNS-SD query callback
typedef void(*)(cups_dnssd_query_t *query, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, uint16_t rrtype, const void *qdata, uint16_t qlen) cups_dnssd_query_cb_t;
DNS query request
typedef struct _cups_dnssd_query_s cups_dnssd_query_t;
DNS-SD resolve callback
typedef void(*)(cups_dnssd_resolve_t *res, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, const char *host, uint16_t port, int num_txt, cups_option_t *txt)cups_dnssd_resolve_cb_t;
DNS resolve request
typedef struct _cups_dnssd_resolve_s cups_dnssd_resolve_t;
DNS record type values
typedef typedef struct _cups_dnssd_browse_s cups_dnssd_browse_t;
DNS-SD service registration callback
typedef void(*)(cups_dnssd_service_t *service, void *cb_data, cups_dnssd_flags_t flags) cups_dnssd_service_cb_t;
DNS service registration
typedef struct _cups_dnssd_service_s cups_dnssd_service_t;
DNS-SD context
typedef struct _cups_dnssd_s cups_dnssd_t;
LeadingEdge attribute values
typedef enum cups_edge_e cups_edge_t;
CUPS file type
typedef struct _cups_file_s cups_file_t;
Job information
typedef struct cups_job_s cups_job_t;
Jog attribute values
typedef enum cups_jog_e cups_jog_t;
JSON node
typedef struct _cups_json_s cups_json_t;
JSON node type
typedef enum cups_jtype_e cups_jtype_t;
JSON Web Algorithms
typedef enum cups_jwa_e cups_jwa_t;
JSON Web Signature Formats
typedef enum cups_jws_format_e cups_jws_format_t;
JSON Web Token
typedef struct _cups_jwt_s cups_jwt_t;
Language Cache Structure
typedef struct cups_lang_s cups_lang_t;
Combined flags for cupsGetDestMediaByName
and cupsGetDestMediaBySize
typedef unsigned cups_media_flags_t;
Media information
typedef struct cups_media_s cups_media_t;
Mutual exclusion lock
typedef pthread_mutex_t cups_mutex_t;
OAuth callback
typedef const char *(*)(http_t *http, const char *realm, const char *scope, const char *resource, void *user_data)cups_oauth_cb_t;
OAuth Grant Types
typedef enum cups_ogrant_e cups_ogrant_t;
Printer Options
typedef struct cups_option_s cups_option_t;
cupsColorOrder attribute values
typedef enum cups_order_e cups_order_t;
Orientation attribute values
typedef enum cups_orient_e cups_orient_t;
Version 2 page header
typedef struct cups_page_header2_s cups_page_header2_t;
Version 1 page header
typedef struct cups_page_header_s cups_page_header_t;
New password callback
typedef const char *(*)(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data)cups_password_cb2_t;
Combined printer type/capability flags
typedef unsigned cups_ptype_t;
cupsRasterOpenIO callback function
typedef ssize_t(*)(void *ctx, unsigned char *buffer, size_t length) cups_raster_cb_t;
cupsRasterOpen modes
typedef enum cups_raster_mode_e cups_raster_mode_t;
Raster stream data
typedef struct _cups_raster_s cups_raster_t;
Reader/writer lock
typedef pthread_rwlock_t cups_rwlock_t;
SBCS Legacy 8-bit unit
typedef unsigned char cups_sbcs_t;
Server credentials callback
typedef int(*)(http_t *http, void *tls, cups_array_t *certs, void *user_data)cups_server_cert_cb_t;
Media Size
typedef struct cups_size_s cups_size_t;
Thread function
typedef void *(*)(void *arg)cups_thread_func_t;
Thread data key
typedef pthread_key_t cups_thread_key_t;
Thread identifier
typedef pthread_t cups_thread_t;
UCS-2 Unicode/ISO-10646 unit
typedef unsigned short cups_ucs2_t;
UCS-4 Unicode/ISO-10646 unit
typedef unsigned long cups_ucs4_t;
UTF-32 Unicode/ISO-10646 unit
typedef unsigned long cups_utf32_t;
UTF-8 Unicode/ISO-10646 unit
typedef unsigned char cups_utf8_t;
VBCS Legacy 32-bit unit
typedef unsigned long cups_vbcs_t;
Which jobs for cupsGetJobs
typedef enum cups_whichjobs_e cups_whichjobs_t;
Socket address union, which makes using IPv6 and other address types easier and more portable.
typedef union _http_addr_u http_addr_t;
HTTP transfer encoding values
typedef enum http_encoding_e http_encoding_t;
HTTP encryption values
typedef enum http_encryption_e http_encryption_t;
HTTP field names
typedef enum http_field_e http_field_t;
HTTP keep-alive values
typedef enum http_keepalive_e http_keepalive_t;
httpResolveURI
callback
typedef bool(*)(void *data)http_resolve_cb_t;
httpResolveURI
options bitfield
typedef unsigned http_resolve_t;
HTTP state values; states are server-oriented...
typedef enum http_state_e http_state_t;
HTTP connection type
typedef struct _http_s http_t;
HTTP timeout callback
typedef int(*)(http_t *http, void *user_data)http_timeout_cb_t;
Level of trust for credentials
typedef enum http_trust_e http_trust_t;
URI en/decode flags
typedef enum http_uri_coding_e http_uri_coding_t;
URI separation status
typedef enum http_uri_status_e http_uri_status_t;
IPP attribute
typedef struct _ipp_attribute_s ipp_attribute_t;
ippCopyAttributes callback function
typedef int(*)(void *context, ipp_t *dst, ipp_attribute_t *attr)ipp_copy_cb_t;
IPP data file attribute callback
typedef bool(*)(ipp_file_t *file, void *cb_data, const char *name)ipp_fattr_cb_t;
IPP data file error callback
typedef bool(*)(ipp_file_t *file, void *cb_data, const char *error)ipp_ferror_cb_t;
IPP data file
typedef struct _ipp_file_s ipp_file_t;
IPP data file token callback
typedef bool(*)(ipp_file_t *file, void *cb_data, const char *token)ipp_ftoken_cb_t;
ippReadIO/ippWriteIO callback function
typedef ssize_t(*)(void *context, ipp_uchar_t *buffer, size_t bytes) ipp_io_cb_t;
Job states
typedef enum ipp_jstate_e ipp_jstate_t;
IPP operations
typedef enum ipp_op_e ipp_op_t;
Orientation values
typedef enum ipp_orient_e ipp_orient_t;
Printer state values
typedef enum ipp_pstate_e ipp_pstate_t;
Print quality values
typedef enum ipp_quality_e ipp_quality_t;
Resolution units
typedef enum ipp_res_e ipp_res_t;
resource-state values
typedef enum ipp_rstate_e ipp_rstate_t;
system-state values
typedef enum ipp_sstate_e ipp_sstate_t;
ipp_t state values
typedef enum ipp_state_e ipp_state_t;
IPP request/response data
typedef struct _ipp_s ipp_t;
Common media size data
typedef struct pwg_media_s pwg_media_t;
Directory entry type
struct cups_dentry_s {
struct stat fileinfo;
char filename[260];
};
fileinfo | File information |
---|---|
filename[260] | File name |
Destination
struct cups_dest_s {
char *name, *instance;
int is_default;
int num_options;
cups_option_t *options;
};
instance | Local instance name or NULL |
---|---|
is_default | Is this printer the default? |
num_options | Number of options |
options | Options |
Job information
struct cups_job_s {
time_t completed_time;
time_t creation_time;
char *dest;
char *format;
int id;
int priority;
time_t processing_time;
int size;
ipp_jstate_t state;
char *title;
char *user;
};
completed_time | Time the job was completed |
---|---|
creation_time | Time the job was created |
dest | Printer or class name |
format | Document format |
id | The job ID |
priority | Priority (1-100) |
processing_time | Time the job was processed |
size | Size in kilobytes |
state | Job state |
title | Title/job name |
user | User that submitted the job |
Language Cache Structure
struct cups_lang_s {
cups_encoding_t encoding;
char language[16];
struct cups_lang_s *next;
int used;
};
encoding | Text encoding |
---|---|
language[16] | Language/locale name |
next | Next language in cache |
used | Number of times this entry has been used. |
Media information
struct cups_media_s {
int width, length, bottom, left, right, top;
char media[128], color[128], source[128], type[128];
};
top | Top margin in hundredths of millimeters |
---|---|
type[128] | Media type (blank for any/auto) |
Printer Options
struct cups_option_s {
char *name;
char *value;
};
name | Name of option |
---|---|
value | Value of option |
Version 2 page header
struct cups_page_header2_s {
unsigned AdvanceDistance;
cups_adv_t AdvanceMedia;
cups_bool_t Collate;
cups_cut_t CutMedia;
cups_bool_t Duplex;
unsigned HWResolution[2];
unsigned ImagingBoundingBox[4];
cups_bool_t InsertSheet;
cups_jog_t Jog;
cups_edge_t LeadingEdge;
cups_bool_t ManualFeed;
unsigned Margins[2];
char MediaClass[64];
char MediaColor[64];
unsigned MediaPosition;
char MediaType[64];
unsigned MediaWeight;
cups_bool_t MirrorPrint;
cups_bool_t NegativePrint;
unsigned NumCopies;
cups_orient_t Orientation;
cups_bool_t OutputFaceUp;
char OutputType[64];
unsigned PageSize[2];
cups_bool_t Separations;
cups_bool_t TraySwitch;
cups_bool_t Tumble;
unsigned cupsBitsPerColor;
unsigned cupsBitsPerPixel;
float cupsBorderlessScalingFactor;
unsigned cupsBytesPerLine;
cups_order_t cupsColorOrder;
cups_cspace_t cupsColorSpace;
unsigned cupsCompression;
unsigned cupsHeight;
float cupsImagingBBox[4];
unsigned cupsInteger[16];
char cupsMarkerType[64];
unsigned cupsMediaType;
unsigned cupsNumColors;
char cupsPageSizeName[64];
float cupsPageSize[2];
float cupsReal[16];
char cupsRenderingIntent[64];
unsigned cupsRowCount;
unsigned cupsRowFeed;
unsigned cupsRowStep;
char cupsString[16][64];
unsigned cupsWidth;
};
AdvanceDistance | AdvanceDistance value in points |
---|---|
AdvanceMedia | AdvanceMedia value (cups_adv_t ) |
Collate | Collated copies value |
CutMedia | CutMedia value (cups_cut_t ) |
Duplex | Duplexed (double-sided) value |
HWResolution[2] | Resolution in dots-per-inch |
ImagingBoundingBox[4] | Pixel region that is painted (points, left, bottom, right, top) |
InsertSheet | InsertSheet value |
Jog | Jog value (cups_jog_t ) |
LeadingEdge | LeadingEdge value (cups_edge_t ) |
ManualFeed | ManualFeed value |
Margins[2] | Lower-lefthand margins in points |
MediaClass[64] | MediaClass string |
MediaColor[64] | MediaColor string |
MediaPosition | MediaPosition value |
MediaType[64] | MediaType string |
MediaWeight | MediaWeight value in grams/m^2 |
MirrorPrint | MirrorPrint value |
NegativePrint | NegativePrint value |
NumCopies | Number of copies to produce |
Orientation | Orientation value (cups_orient_t ) |
OutputFaceUp | OutputFaceUp value |
OutputType[64] | OutputType string |
PageSize[2] | Width and length of page in points |
Separations | Separations value |
TraySwitch | TraySwitch value |
Tumble | Tumble value |
cupsBitsPerColor | Number of bits for each color |
cupsBitsPerPixel | Number of bits for each pixel |
cupsBorderlessScalingFactor CUPS 1.2 | Scaling that was applied to page data |
cupsBytesPerLine | Number of bytes per line |
cupsColorOrder | Order of colors |
cupsColorSpace | True colorspace |
cupsCompression | Device compression to use |
cupsHeight | Height of page image in pixels |
cupsImagingBBox[4] CUPS 1.2 | Floating point ImagingBoundingBox (scaling factor not applied, left, bottom, right, top) |
cupsInteger[16] CUPS 1.2 | User-defined integer values |
cupsMarkerType[64] CUPS 1.2 | Ink/toner type |
cupsMediaType | Media type code |
cupsNumColors CUPS 1.2 | Number of color components |
cupsPageSizeName[64] CUPS 1.2 | PageSize name |
cupsPageSize[2] CUPS 1.2 | Floating point PageSize (scaling * factor not applied) |
cupsReal[16] CUPS 1.2 | User-defined floating-point values |
cupsRenderingIntent[64] CUPS 1.2 | Color rendering intent |
cupsRowCount | Rows per band |
cupsRowFeed | Feed between bands |
cupsRowStep | Spacing between lines |
cupsString[16][64] CUPS 1.2 | User-defined string values |
cupsWidth | Width of page image in pixels |
Version 1 page header
struct cups_page_header_s {
unsigned AdvanceDistance;
cups_adv_t AdvanceMedia;
cups_bool_t Collate;
cups_cut_t CutMedia;
cups_bool_t Duplex;
unsigned HWResolution[2];
unsigned ImagingBoundingBox[4];
cups_bool_t InsertSheet;
cups_jog_t Jog;
cups_edge_t LeadingEdge;
cups_bool_t ManualFeed;
unsigned Margins[2];
char MediaClass[64];
char MediaColor[64];
unsigned MediaPosition;
char MediaType[64];
unsigned MediaWeight;
cups_bool_t MirrorPrint;
cups_bool_t NegativePrint;
unsigned NumCopies;
cups_orient_t Orientation;
cups_bool_t OutputFaceUp;
char OutputType[64];
unsigned PageSize[2];
cups_bool_t Separations;
cups_bool_t TraySwitch;
cups_bool_t Tumble;
unsigned cupsBitsPerColor;
unsigned cupsBitsPerPixel;
unsigned cupsBytesPerLine;
cups_order_t cupsColorOrder;
cups_cspace_t cupsColorSpace;
unsigned cupsCompression;
unsigned cupsHeight;
unsigned cupsMediaType;
unsigned cupsRowCount;
unsigned cupsRowFeed;
unsigned cupsRowStep;
unsigned cupsWidth;
};
AdvanceDistance | AdvanceDistance value in points |
---|---|
AdvanceMedia | AdvanceMedia value (cups_adv_t ) |
Collate | Collated copies value |
CutMedia | CutMedia value (cups_cut_t ) |
Duplex | Duplexed (double-sided) value |
HWResolution[2] | Resolution in dots-per-inch |
ImagingBoundingBox[4] | Pixel region that is painted (points, left, bottom, right, top) |
InsertSheet | InsertSheet value |
Jog | Jog value (cups_jog_t ) |
LeadingEdge | LeadingEdge value (cups_edge_t ) |
ManualFeed | ManualFeed value |
Margins[2] | Lower-lefthand margins in points |
MediaClass[64] | MediaClass string |
MediaColor[64] | MediaColor string |
MediaPosition | MediaPosition value |
MediaType[64] | MediaType string |
MediaWeight | MediaWeight value in grams/m^2 |
MirrorPrint | MirrorPrint value |
NegativePrint | NegativePrint value |
NumCopies | Number of copies to produce |
Orientation | Orientation value (cups_orient_t ) |
OutputFaceUp | OutputFaceUp value |
OutputType[64] | OutputType string |
PageSize[2] | Width and length of page in points |
Separations | Separations value |
TraySwitch | TraySwitch value |
Tumble | Tumble value |
cupsBitsPerColor | Number of bits for each color |
cupsBitsPerPixel | Number of bits for each pixel |
cupsBytesPerLine | Number of bytes per line |
cupsColorOrder | Order of colors |
cupsColorSpace | True colorspace |
cupsCompression | Device compression to use |
cupsHeight | Height of page image in pixels |
cupsMediaType | Media type code |
cupsRowCount | Rows per band |
cupsRowFeed | Feed between bands |
cupsRowStep | Spacing between lines |
cupsWidth | Width of page image in pixels |
Media Size
struct cups_size_s {
char media[128];
int width, length, bottom, left, right, top;
};
media[128] | Media name to use |
---|---|
top | Top margin in hundredths of millimeters |
Common media size data
struct pwg_media_s {
int width, length;
const char *pwg, *legacy, *ppd;
};
length | Length in 2540ths |
---|---|
ppd | Standard Adobe PPD name |
AdvanceMedia attribute values
CUPS_ADVANCE_FILE | Advance the roll after this file |
---|---|
CUPS_ADVANCE_JOB | Advance the roll after this job |
CUPS_ADVANCE_NONE | Never advance the roll |
CUPS_ADVANCE_PAGE | Advance the roll after this page |
CUPS_ADVANCE_SET | Advance the roll after this set |
Boolean type
CUPS_FALSE | Logical false |
---|---|
CUPS_TRUE | Logical true |
X.509 credential purposes
CUPS_CREDPURPOSE_ALL | All purposes |
---|---|
CUPS_CREDPURPOSE_CLIENT_AUTH | clientAuth |
CUPS_CREDPURPOSE_CODE_SIGNING | codeSigning |
CUPS_CREDPURPOSE_EMAIL_PROTECTION | emailProtection |
CUPS_CREDPURPOSE_OCSP_SIGNING | OCSPSigning |
CUPS_CREDPURPOSE_SERVER_AUTH | serverAuth |
CUPS_CREDPURPOSE_TIME_STAMPING | timeStamping |
X.509 credential types for cupsCreateCredentials
and cupsCreateCredentialsRequest
CUPS_CREDTYPE_DEFAULT | Default type |
---|---|
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_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 |
X.509 keyUsage flags
CUPS_CREDUSAGE_ALL | All keyUsage flags |
---|---|
CUPS_CREDUSAGE_CRL_SIGN | cRLSign |
CUPS_CREDUSAGE_DATA_ENCIPHERMENT | dataEncipherment |
CUPS_CREDUSAGE_DECIPHER_ONLY | decipherOnly |
CUPS_CREDUSAGE_DEFAULT_CA | Defaults for CA certs |
CUPS_CREDUSAGE_DEFAULT_TLS | Defaults for TLS certs |
CUPS_CREDUSAGE_DIGITAL_SIGNATURE | digitalSignature |
CUPS_CREDUSAGE_ENCIPHER_ONLY | encipherOnly |
CUPS_CREDUSAGE_KEY_AGREEMENT | keyAgreement |
CUPS_CREDUSAGE_KEY_CERT_SIGN | keyCertSign |
CUPS_CREDUSAGE_KEY_ENCIPHERMENT | keyEncipherment |
CUPS_CREDUSAGE_NON_REPUDIATION | nonRepudiation/contentCommitment |
cupsColorSpace attribute values
CUPS_CSPACE_ADOBERGB CUPS 1.4.5 | Red, green, blue (Adobe RGB) |
---|---|
CUPS_CSPACE_CIELab CUPS 1.1.19 | CIE Lab |
CUPS_CSPACE_CIEXYZ CUPS 1.1.19 | CIE XYZ |
CUPS_CSPACE_CMY | Cyan, magenta, yellow (DeviceCMY) |
CUPS_CSPACE_CMYK | Cyan, magenta, yellow, black (DeviceCMYK) |
CUPS_CSPACE_DEVICE1 CUPS 1.4.5 | DeviceN, 1 color |
CUPS_CSPACE_DEVICE2 CUPS 1.4.5 | DeviceN, 2 colors |
CUPS_CSPACE_DEVICE3 CUPS 1.4.5 | DeviceN, 3 colors |
CUPS_CSPACE_DEVICE4 CUPS 1.4.5 | DeviceN, 4 colors |
CUPS_CSPACE_DEVICE5 CUPS 1.4.5 | DeviceN, 5 colors |
CUPS_CSPACE_DEVICE6 CUPS 1.4.5 | DeviceN, 6 colors |
CUPS_CSPACE_DEVICE7 CUPS 1.4.5 | DeviceN, 7 colors |
CUPS_CSPACE_DEVICE8 CUPS 1.4.5 | DeviceN, 8 colors |
CUPS_CSPACE_DEVICE9 CUPS 1.4.5 | DeviceN, 9 colors |
CUPS_CSPACE_DEVICEA CUPS 1.4.5 | DeviceN, 10 colors |
CUPS_CSPACE_DEVICEB CUPS 1.4.5 | DeviceN, 11 colors |
CUPS_CSPACE_DEVICEC CUPS 1.4.5 | DeviceN, 12 colors |
CUPS_CSPACE_DEVICED CUPS 1.4.5 | DeviceN, 13 colors |
CUPS_CSPACE_DEVICEE CUPS 1.4.5 | DeviceN, 14 colors |
CUPS_CSPACE_DEVICEF CUPS 1.4.5 | DeviceN, 15 colors |
CUPS_CSPACE_GMCK DEPRECATED | Gold, magenta, yellow, black |
CUPS_CSPACE_GMCS DEPRECATED | Gold, magenta, yellow, silver |
CUPS_CSPACE_GOLD DEPRECATED | Gold foil |
CUPS_CSPACE_ICC1 CUPS 1.1.19 | ICC-based, 1 color |
CUPS_CSPACE_ICC2 CUPS 1.1.19 | ICC-based, 2 colors |
CUPS_CSPACE_ICC3 CUPS 1.1.19 | ICC-based, 3 colors |
CUPS_CSPACE_ICC4 CUPS 1.1.19 | ICC-based, 4 colors |
CUPS_CSPACE_ICC5 CUPS 1.1.19 | ICC-based, 5 colors |
CUPS_CSPACE_ICC6 CUPS 1.1.19 | ICC-based, 6 colors |
CUPS_CSPACE_ICC7 CUPS 1.1.19 | ICC-based, 7 colors |
CUPS_CSPACE_ICC8 CUPS 1.1.19 | ICC-based, 8 colors |
CUPS_CSPACE_ICC9 CUPS 1.1.19 | ICC-based, 9 colors |
CUPS_CSPACE_ICCA CUPS 1.1.19 | ICC-based, 10 colors |
CUPS_CSPACE_ICCB CUPS 1.1.19 | ICC-based, 11 colors |
CUPS_CSPACE_ICCC CUPS 1.1.19 | ICC-based, 12 colors |
CUPS_CSPACE_ICCD CUPS 1.1.19 | ICC-based, 13 colors |
CUPS_CSPACE_ICCE CUPS 1.1.19 | ICC-based, 14 colors |
CUPS_CSPACE_ICCF CUPS 1.1.19 | ICC-based, 15 colors |
CUPS_CSPACE_K | Black (DeviceK) |
CUPS_CSPACE_KCMY DEPRECATED | Black, cyan, magenta, yellow |
CUPS_CSPACE_KCMYcm DEPRECATED | Black, cyan, magenta, yellow, light-cyan, light-magenta |
CUPS_CSPACE_RGB | Red, green, blue (DeviceRGB, sRGB by default) |
CUPS_CSPACE_RGBA | Red, green, blue, alpha (DeviceRGB, sRGB by default) |
CUPS_CSPACE_RGBW CUPS 1.2 | Red, green, blue, white (DeviceRGB, sRGB by default) |
CUPS_CSPACE_SILVER DEPRECATED | Silver foil |
CUPS_CSPACE_SRGB CUPS 1.4.5 | Red, green, blue (sRGB) |
CUPS_CSPACE_SW CUPS 1.4.5 | Luminance (gamma 2.2) |
CUPS_CSPACE_W | Luminance (DeviceGray, gamma 2.2 by default) |
CUPS_CSPACE_WHITE DEPRECATED | White ink (as black) |
CUPS_CSPACE_YMC DEPRECATED | Yellow, magenta, cyan |
CUPS_CSPACE_YMCK DEPRECATED | Yellow, magenta, cyan, black |
CutMedia attribute values
CUPS_CUT_FILE | Cut the roll after this file |
---|---|
CUPS_CUT_JOB | Cut the roll after this job |
CUPS_CUT_NONE | Never cut the roll |
CUPS_CUT_PAGE | Cut the roll after this page |
CUPS_CUT_SET | Cut the roll after this set |
Flags for cupsConnectDest
and cupsEnumDests
CUPS_DEST_FLAGS_CANCELED | Operation was canceled |
---|---|
CUPS_DEST_FLAGS_CONNECTING | A connection is being established |
CUPS_DEST_FLAGS_DEVICE | For cupsConnectDest : Connect to device |
CUPS_DEST_FLAGS_ERROR | An error occurred |
CUPS_DEST_FLAGS_MORE | There are more destinations |
CUPS_DEST_FLAGS_NONE | No flags are set |
CUPS_DEST_FLAGS_REMOVED | The destination has gone away |
CUPS_DEST_FLAGS_RESOLVING | The destination address is being resolved |
CUPS_DEST_FLAGS_UNCONNECTED | There is no connection |
DNS-SD callback flag values
CUPS_DNSSD_FLAGS_ADD | Added (removed if not set) |
---|---|
CUPS_DNSSD_FLAGS_COLLISION | Collision occurred |
CUPS_DNSSD_FLAGS_ERROR | Error occurred |
CUPS_DNSSD_FLAGS_HOST_CHANGE | Host name changed |
CUPS_DNSSD_FLAGS_MORE | More coming |
CUPS_DNSSD_FLAGS_NETWORK_CHANGE | Network connection changed |
CUPS_DNSSD_FLAGS_NONE | No flags |
DNS record type values
CUPS_DNSSD_RRTYPE_A | Host address |
---|---|
CUPS_DNSSD_RRTYPE_AAAA | IPv6 Address. |
CUPS_DNSSD_RRTYPE_ANY | Wildcard match |
CUPS_DNSSD_RRTYPE_CERT | Certification record |
CUPS_DNSSD_RRTYPE_CNAME | Canonical name |
CUPS_DNSSD_RRTYPE_DHCID | DHCP Client Identifier |
CUPS_DNSSD_RRTYPE_DNSKEY | DNSKEY |
CUPS_DNSSD_RRTYPE_HTTPS | HTTPS Service Binding |
CUPS_DNSSD_RRTYPE_KEY | Security key |
CUPS_DNSSD_RRTYPE_KX | Key Exchange |
CUPS_DNSSD_RRTYPE_LOC | Location Information. |
CUPS_DNSSD_RRTYPE_NS | Name server |
CUPS_DNSSD_RRTYPE_PTR | Domain name pointer |
CUPS_DNSSD_RRTYPE_RRSIG | RRSIG |
CUPS_DNSSD_RRTYPE_RT | Router |
CUPS_DNSSD_RRTYPE_SIG | Security signature |
CUPS_DNSSD_RRTYPE_SPF | Sender Policy Framework for E-Mail |
CUPS_DNSSD_RRTYPE_TXT | One or more text strings |
CUPS_DNSSD_RRTYPE_WKS | Well known service |
LeadingEdge attribute values
CUPS_EDGE_BOTTOM | Leading edge is the bottom of the page |
---|---|
CUPS_EDGE_LEFT | Leading edge is the left of the page |
CUPS_EDGE_RIGHT | Leading edge is the right of the page |
CUPS_EDGE_TOP | Leading edge is the top of the page |
Jog attribute values
CUPS_JOG_FILE | Move pages after this file |
---|---|
CUPS_JOG_JOB | Move pages after this job |
CUPS_JOG_NONE | Never move pages |
CUPS_JOG_SET | Move pages after this set |
JSON node type
CUPS_JTYPE_ARRAY | Array value |
---|---|
CUPS_JTYPE_FALSE | Boolean false value |
CUPS_JTYPE_KEY | Object key (string) |
CUPS_JTYPE_NULL | Null value |
CUPS_JTYPE_NUMBER | Number value |
CUPS_JTYPE_OBJECT | Object value |
CUPS_JTYPE_STRING | String value |
CUPS_JTYPE_TRUE | Boolean true value |
JSON Web Algorithms
CUPS_JWA_ES256 | ECDSA using P-256 and SHA-256 |
---|---|
CUPS_JWA_ES384 | ECDSA using P-384 and SHA-384 |
CUPS_JWA_ES512 | ECDSA using P-521 and SHA-512 |
CUPS_JWA_HS256 | HMAC using SHA-256 |
CUPS_JWA_HS384 | HMAC using SHA-384 |
CUPS_JWA_HS512 | HMAC using SHA-512 |
CUPS_JWA_NONE | No algorithm |
CUPS_JWA_RS256 | RSASSA-PKCS1-v1_5 using SHA-256 |
CUPS_JWA_RS384 | RSASSA-PKCS1-v1_5 using SHA-384 |
CUPS_JWA_RS512 | RSASSA-PKCS1-v1_5 using SHA-512 |
JSON Web Signature Formats
CUPS_JWS_FORMAT_COMPACT | JWS Compact Serialization |
---|---|
CUPS_JWS_FORMAT_JSON | JWS JSON Serialization |
Flags for cupsGetDestMediaByName
and cupsGetDestMediaBySize
CUPS_MEDIA_FLAGS_BORDERLESS | Find a borderless size |
---|---|
CUPS_MEDIA_FLAGS_DEFAULT | Find the closest size supported by the printer |
CUPS_MEDIA_FLAGS_DUPLEX | Find a size compatible with 2-sided printing |
CUPS_MEDIA_FLAGS_EXACT | Find an exact match for the size |
CUPS_MEDIA_FLAGS_READY | If the printer supports media sensing, find the size amongst the "ready" media. |
OAuth Grant Types
CUPS_OGRANT_AUTHORIZATION_CODE | Authorization code |
---|---|
CUPS_OGRANT_DEVICE_CODE | Device code |
CUPS_OGRANT_REFRESH_TOKEN | Refresh token |
cupsColorOrder attribute values
CUPS_ORDER_BANDED | CCC MMM YYY KKK ... |
---|---|
CUPS_ORDER_CHUNKED | CMYK CMYK CMYK ... |
CUPS_ORDER_PLANAR | CCC ... MMM ... YYY ... KKK ... |
Orientation attribute values
CUPS_ORIENT_0 | Don't rotate the page |
---|---|
CUPS_ORIENT_180 | Turn the page upside down |
CUPS_ORIENT_270 | Rotate the page clockwise |
CUPS_ORIENT_90 | Rotate the page counter-clockwise |
Printer type/capability flags
CUPS_PTYPE_AUTHENTICATED | Printer requires authentication |
---|---|
CUPS_PTYPE_BIND | Can bind output |
CUPS_PTYPE_BW | Can do B&W printing |
CUPS_PTYPE_CLASS | Printer class |
CUPS_PTYPE_COLLATE | Can quickly collate copies |
CUPS_PTYPE_COLOR | Can do color printing |
CUPS_PTYPE_COMMANDS | Printer supports maintenance commands |
CUPS_PTYPE_COPIES | Can do copies in hardware |
CUPS_PTYPE_COVER | Can cover output |
CUPS_PTYPE_DEFAULT | Default printer on network |
CUPS_PTYPE_DISCOVERED | Printer was discovered |
CUPS_PTYPE_DUPLEX | Can do two-sided printing |
CUPS_PTYPE_FAX | Fax queue |
CUPS_PTYPE_FOLD CUPS 2.5 | Can fold output |
CUPS_PTYPE_LARGE | Can print on D/E/A1/A0-size media |
CUPS_PTYPE_LOCAL | Local printer or class |
CUPS_PTYPE_MEDIUM | Can print on Tabloid/B/C/A3/A2-size media |
CUPS_PTYPE_MFP | Printer with scanning capabilities |
CUPS_PTYPE_NOT_SHARED | Printer is not shared |
CUPS_PTYPE_PUNCH | Can punch output |
CUPS_PTYPE_REJECTING | Printer is rejecting jobs |
CUPS_PTYPE_REMOTE | Remote printer or class |
CUPS_PTYPE_SCANNER | Scanner-only device |
CUPS_PTYPE_SMALL | Can print on Letter/Legal/A4-size media |
CUPS_PTYPE_SORT | Can sort output |
CUPS_PTYPE_STAPLE | Can staple output |
CUPS_PTYPE_VARIABLE | Can print on rolls and custom-size media |
cupsRasterOpen modes
CUPS_RASTER_READ | Open stream for reading |
---|---|
CUPS_RASTER_WRITE | Open stream for writing |
CUPS_RASTER_WRITE_COMPRESSED CUPS 1.3 | Open stream for compressed writing |
CUPS_RASTER_WRITE_PWG CUPS 1.5 | Open stream for compressed writing in PWG Raster mode |
Which jobs for cupsGetJobs
CUPS_WHICHJOBS_ACTIVE | Pending/held/processing jobs |
---|---|
CUPS_WHICHJOBS_ALL | All jobs |
CUPS_WHICHJOBS_COMPLETED | Completed/canceled/aborted jobs |
HTTP transfer encoding values
HTTP_ENCODING_CHUNKED | Data is chunked |
---|---|
HTTP_ENCODING_FIELDS | Sending HTTP fields |
HTTP_ENCODING_LENGTH | Data is sent with Content-Length |
HTTP encryption values
HTTP_ENCRYPTION_ALWAYS | Always encrypt (HTTPS) |
---|---|
HTTP_ENCRYPTION_IF_REQUESTED | Encrypt if requested (TLS upgrade) |
HTTP_ENCRYPTION_NEVER | Never encrypt |
HTTP_ENCRYPTION_REQUIRED | Encryption is required (TLS upgrade) |
HTTP field names
HTTP_FIELD_ACCEPT CUPS 2.5 | Accept field |
---|---|
HTTP_FIELD_ACCEPT_ENCODING CUPS 1.7 | Accepting-Encoding field |
HTTP_FIELD_ACCEPT_LANGUAGE | Accept-Language field |
HTTP_FIELD_ACCEPT_RANGES | Accept-Ranges field |
HTTP_FIELD_ACCESS_CONTROL_ALLOW_CREDENTIALS CUPS 2.4 | CORS/Fetch Access-Control-Allow-Credentials field |
HTTP_FIELD_ACCESS_CONTROL_ALLOW_HEADERS CUPS 2.4 | CORS/Fetch Access-Control-Allow-Headers field |
HTTP_FIELD_ACCESS_CONTROL_ALLOW_METHODS CUPS 2.4 | CORS/Fetch Access-Control-Allow-Methods field |
HTTP_FIELD_ACCESS_CONTROL_ALLOW_ORIGIN CUPS 2.4 | CORS/Fetch Access-Control-Allow-Origin field |
HTTP_FIELD_ACCESS_CONTROL_EXPOSE_HEADERS CUPS 2.4 | CORS/Fetch Access-Control-Expose-Headers field |
HTTP_FIELD_ACCESS_CONTROL_MAX_AGE CUPS 2.4 | CORS/Fetch Access-Control-Max-Age field |
HTTP_FIELD_ACCESS_CONTROL_REQUEST_HEADERS CUPS 2.4 | CORS/Fetch Access-Control-Request-Headers field |
HTTP_FIELD_ACCESS_CONTROL_REQUEST_METHOD CUPS 2.4 | CORS/Fetch Access-Control-Request-Method field |
HTTP_FIELD_ALLOW CUPS 1.7 | Allow field |
HTTP_FIELD_AUTHENTICATION_INFO CUPS 2.2.9 | Authentication-Info field |
HTTP_FIELD_AUTHORIZATION | Authorization field |
HTTP_FIELD_CONNECTION | Connection field |
HTTP_FIELD_CONTENT_ENCODING | Content-Encoding field |
HTTP_FIELD_CONTENT_LANGUAGE | Content-Language field |
HTTP_FIELD_CONTENT_LENGTH | Content-Length field |
HTTP_FIELD_CONTENT_LOCATION | Content-Location field |
HTTP_FIELD_CONTENT_MD5 | Content-MD5 field |
HTTP_FIELD_CONTENT_RANGE | Content-Range field |
HTTP_FIELD_CONTENT_TYPE | Content-Type field |
HTTP_FIELD_CONTENT_VERSION | Content-Version field |
HTTP_FIELD_DATE | Date field |
HTTP_FIELD_HOST | Host field |
HTTP_FIELD_IF_MODIFIED_SINCE | If-Modified-Since field |
HTTP_FIELD_IF_UNMODIFIED_SINCE | If-Unmodified-Since field |
HTTP_FIELD_KEEP_ALIVE | Keep-Alive field |
HTTP_FIELD_LAST_MODIFIED | Last-Modified field |
HTTP_FIELD_LINK | Link field |
HTTP_FIELD_LOCATION | Location field |
HTTP_FIELD_MAX | Maximum field index |
HTTP_FIELD_OPTIONAL_WWW_AUTHENTICATE CUPS 2.4 | RFC 8053 Optional-WWW-Authenticate field |
HTTP_FIELD_ORIGIN CUPS 2.4 | RFC 6454 Origin field |
HTTP_FIELD_OSCORE CUPS 2.4 | RFC 8613 OSCORE field |
HTTP_FIELD_RANGE | Range field |
HTTP_FIELD_REFERER | Referer field |
HTTP_FIELD_RETRY_AFTER | Retry-After field |
HTTP_FIELD_SERVER CUPS 1.7 | Server field |
HTTP_FIELD_STRICT_TRANSPORT_SECURITY CUPS 2.4 | HSTS Strict-Transport-Security field |
HTTP_FIELD_TRANSFER_ENCODING | Transfer-Encoding field |
HTTP_FIELD_UNKNOWN | Unknown field |
HTTP_FIELD_UPGRADE | Upgrade field |
HTTP_FIELD_USER_AGENT | User-Agent field |
HTTP_FIELD_WWW_AUTHENTICATE | WWW-Authenticate field |
HTTP keep-alive values
HTTP_KEEPALIVE_OFF | No keep alive support |
---|---|
HTTP_KEEPALIVE_ON | Use keep alive |
httpResolveURI
options bit values
HTTP_RESOLVE_DEFAULT | Resolve with default options |
---|---|
HTTP_RESOLVE_FAXOUT | Resolve FaxOut service instead of Print |
HTTP_RESOLVE_FQDN | Resolve to a FQDN |
HTTP state values; states are server-oriented...
HTTP_STATE_CONNECT | CONNECT command, waiting for blank line |
---|---|
HTTP_STATE_DELETE | DELETE command, waiting for blank line |
HTTP_STATE_ERROR | Error on socket |
HTTP_STATE_GET | GET command, waiting for blank line |
HTTP_STATE_GET_SEND | GET command, sending data |
HTTP_STATE_HEAD | HEAD command, waiting for blank line |
HTTP_STATE_OPTIONS | OPTIONS command, waiting for blank line |
HTTP_STATE_POST | POST command, waiting for blank line |
HTTP_STATE_POST_RECV | POST command, receiving data |
HTTP_STATE_POST_SEND | POST command, sending data |
HTTP_STATE_PUT | PUT command, waiting for blank line |
HTTP_STATE_PUT_RECV | PUT command, receiving data |
HTTP_STATE_STATUS | Command complete, sending status |
HTTP_STATE_TRACE | TRACE command, waiting for blank line |
HTTP_STATE_UNKNOWN_METHOD CUPS 1.7 | Unknown request method, waiting for blank line |
HTTP_STATE_UNKNOWN_VERSION CUPS 1.7 | Unknown request method, waiting for blank line |
HTTP_STATE_WAITING | Waiting for command |
HTTP status codes
HTTP_STATUS_ACCEPTED | DELETE command was successful |
---|---|
HTTP_STATUS_ALREADY_REPORTED | Already reported (WebDAV) |
HTTP_STATUS_BAD_GATEWAY | Bad gateway |
HTTP_STATUS_BAD_REQUEST | Bad request |
HTTP_STATUS_CONFLICT | Request is self-conflicting |
HTTP_STATUS_CONTENT_TOO_LARGE | Content too large |
HTTP_STATUS_CONTINUE | Everything OK, keep going... |
HTTP_STATUS_CREATED | PUT command was successful |
HTTP_STATUS_CUPS_AUTHORIZATION_CANCELED CUPS 1.4 | User canceled authorization |
HTTP_STATUS_CUPS_PKI_ERROR CUPS 1.5 | Error negotiating a secure connection |
HTTP_STATUS_ERROR | An error response from httpXxxx() |
HTTP_STATUS_EXPECTATION_FAILED | The expectation given in an Expect header field was not met |
HTTP_STATUS_FAILED_DEPENDENCY | Failed dependency (WebDAV) |
HTTP_STATUS_FORBIDDEN | Forbidden to access this URI |
HTTP_STATUS_FOUND | Document was found at a different URI |
HTTP_STATUS_GATEWAY_TIMEOUT | Gateway connection timed out |
HTTP_STATUS_GONE | Server has gone away |
HTTP_STATUS_INSUFFICIENT_STORAGE | Insufficient storage (WebDAV) |
HTTP_STATUS_LENGTH_REQUIRED | A content length or encoding is required |
HTTP_STATUS_LOCKED | Locked (WebDAV) |
HTTP_STATUS_LOOP_DETECTED | Loop detected (WebDAV) |
HTTP_STATUS_METHOD_NOT_ALLOWED | Method is not allowed |
HTTP_STATUS_MISDIRECTED_REQUEST | Misdirected request |
HTTP_STATUS_MOVED_PERMANENTLY | Document has moved permanently |
HTTP_STATUS_MULTIPLE_CHOICES | Multiple files match request |
HTTP_STATUS_MULTI_STATUS | Multiple status codes (WebDAV) |
HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED | Network Authentication Required (WebDAV) |
HTTP_STATUS_NONE CUPS 1.7 | No Expect value |
HTTP_STATUS_NOT_ACCEPTABLE | Not Acceptable |
HTTP_STATUS_NOT_AUTHORITATIVE | Information isn't authoritative |
HTTP_STATUS_NOT_FOUND | URI was not found |
HTTP_STATUS_NOT_IMPLEMENTED | Feature not implemented |
HTTP_STATUS_NOT_MODIFIED | File not modified |
HTTP_STATUS_NOT_SUPPORTED | HTTP version not supported |
HTTP_STATUS_NO_CONTENT | Successful command, no new data |
HTTP_STATUS_OK | OPTIONS/GET/HEAD/POST/TRACE command was successful |
HTTP_STATUS_PARTIAL_CONTENT | Only a partial file was received/sent |
HTTP_STATUS_PAYMENT_REQUIRED | Payment required |
HTTP_STATUS_PERMANENT_REDIRECT | Permanent redirection |
HTTP_STATUS_PRECONDITION | Precondition failed |
HTTP_STATUS_PRECONDITION_REQUIRED | Precondition required (WebDAV) |
HTTP_STATUS_PROXY_AUTHENTICATION | Proxy Authentication is Required |
HTTP_STATUS_RANGE_NOT_SATISFIABLE | The requested range is not satisfiable |
HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE | Request Header Fields Too Large (WebDAV) |
HTTP_STATUS_REQUEST_TIMEOUT | Request timed out |
HTTP_STATUS_RESET_CONTENT | Content was reset/recreated |
HTTP_STATUS_SEE_OTHER | See this other link |
HTTP_STATUS_SERVER_ERROR | Internal server error |
HTTP_STATUS_SERVICE_UNAVAILABLE | Service is unavailable |
HTTP_STATUS_SWITCHING_PROTOCOLS | HTTP upgrade to TLS/SSL |
HTTP_STATUS_TEMPORARY_REDIRECT | Temporary redirection |
HTTP_STATUS_TOO_EARLY | Too early (WebDAV) |
HTTP_STATUS_TOO_MANY_REQUESTS | Too many requests (WebDAV) |
HTTP_STATUS_UNAUTHORIZED | Unauthorized to access host |
HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS | Unavailable For Legal Reasons (RFC 7725) |
HTTP_STATUS_UNPROCESSABLE_CONTENT | Unprocessable content |
HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE | The requested media type is unsupported |
HTTP_STATUS_UPGRADE_REQUIRED | Upgrade to SSL/TLS required |
HTTP_STATUS_URI_TOO_LONG | URI too long |
HTTP_STATUS_USE_PROXY | Must use a proxy to access this URI |
Level of trust for credentials
HTTP_TRUST_CHANGED | Credentials have changed |
---|---|
HTTP_TRUST_EXPIRED | Credentials are expired |
HTTP_TRUST_INVALID | Credentials are invalid |
HTTP_TRUST_OK | Credentials are OK/trusted |
HTTP_TRUST_RENEWED | Credentials have been renewed |
HTTP_TRUST_UNKNOWN | Credentials are unknown/new |
URI en/decode flags
HTTP_URI_CODING_ALL | En/decode everything |
---|---|
HTTP_URI_CODING_HOSTNAME | En/decode the hostname portion |
HTTP_URI_CODING_MOST | En/decode all but the query |
HTTP_URI_CODING_NONE | Don't en/decode anything |
HTTP_URI_CODING_QUERY | En/decode the query portion |
HTTP_URI_CODING_RESOURCE | En/decode the resource portion |
HTTP_URI_CODING_RFC6874 | Use RFC 6874 address format |
HTTP_URI_CODING_USERNAME | En/decode the username portion |
URI separation status
HTTP_URI_STATUS_BAD_ARGUMENTS | Bad arguments to function (error) |
---|---|
HTTP_URI_STATUS_BAD_HOSTNAME | Bad hostname in URI (error) |
HTTP_URI_STATUS_BAD_PORT | Bad port number in URI (error) |
HTTP_URI_STATUS_BAD_RESOURCE | Bad resource in URI (error) |
HTTP_URI_STATUS_BAD_SCHEME | Bad scheme in URI (error) |
HTTP_URI_STATUS_BAD_URI | Bad/empty URI (error) |
HTTP_URI_STATUS_BAD_USERNAME | Bad username in URI (error) |
HTTP_URI_STATUS_MISSING_RESOURCE | Missing resource in URI (warning) |
HTTP_URI_STATUS_MISSING_SCHEME | Missing scheme in URI (warning) |
HTTP_URI_STATUS_OK | URI decoded OK |
HTTP_URI_STATUS_OVERFLOW | URI buffer for httpAssembleURI is too small |
HTTP_URI_STATUS_UNKNOWN_SCHEME | Unknown scheme in URI (warning) |
Finishings values
IPP_FINISHINGS_BALE | Bale (any type) |
---|---|
IPP_FINISHINGS_BIND | Bind |
IPP_FINISHINGS_BIND_BOTTOM | Bind on bottom |
IPP_FINISHINGS_BIND_LEFT | Bind on left |
IPP_FINISHINGS_BIND_RIGHT | Bind on right |
IPP_FINISHINGS_BIND_TOP | Bind on top |
IPP_FINISHINGS_BOOKLET_MAKER | Fold to make booklet |
IPP_FINISHINGS_COAT | Apply protective liquid or powder coating |
IPP_FINISHINGS_COVER | Add cover |
IPP_FINISHINGS_EDGE_STITCH | Stitch along any side |
IPP_FINISHINGS_EDGE_STITCH_BOTTOM | Stitch along bottom edge |
IPP_FINISHINGS_EDGE_STITCH_LEFT | Stitch along left side |
IPP_FINISHINGS_EDGE_STITCH_RIGHT | Stitch along right side |
IPP_FINISHINGS_EDGE_STITCH_TOP | Stitch along top edge |
IPP_FINISHINGS_FOLD | Fold (any type) |
IPP_FINISHINGS_FOLD_ACCORDION | Accordion-fold the paper vertically into four sections |
IPP_FINISHINGS_FOLD_DOUBLE_GATE | Fold the top and bottom quarters of the paper towards the midline, then fold in half vertically |
IPP_FINISHINGS_FOLD_ENGINEERING_Z | Fold the paper vertically into two small sections and one larger, forming an elongated Z |
IPP_FINISHINGS_FOLD_GATE | Fold the top and bottom quarters of the paper towards the midline |
IPP_FINISHINGS_FOLD_HALF | Fold the paper in half vertically |
IPP_FINISHINGS_FOLD_HALF_Z | Fold the paper in half horizontally, then Z-fold the paper vertically |
IPP_FINISHINGS_FOLD_LEFT_GATE | Fold the top quarter of the paper towards the midline |
IPP_FINISHINGS_FOLD_LETTER | Fold the paper into three sections vertically; sometimes also known as a C fold |
IPP_FINISHINGS_FOLD_PARALLEL | Fold the paper in half vertically two times, yielding four sections |
IPP_FINISHINGS_FOLD_POSTER | Fold the paper in half horizontally and vertically; sometimes also called a cross fold |
IPP_FINISHINGS_FOLD_RIGHT_GATE | Fold the bottom quarter of the paper towards the midline |
IPP_FINISHINGS_FOLD_Z | Fold the paper vertically into three sections, forming a Z |
IPP_FINISHINGS_JOG_OFFSET | Offset for binding (any type) |
IPP_FINISHINGS_LAMINATE | Apply protective (solid) material |
IPP_FINISHINGS_NONE | No finishing |
IPP_FINISHINGS_PUNCH | Punch (any location/count) |
IPP_FINISHINGS_PUNCH_BOTTOM_LEFT | Punch 1 hole bottom left |
IPP_FINISHINGS_PUNCH_BOTTOM_RIGHT | Punch 1 hole bottom right |
IPP_FINISHINGS_PUNCH_DUAL_BOTTOM | Punch 2 holes bottom edge |
IPP_FINISHINGS_PUNCH_DUAL_LEFT | Punch 2 holes left side |
IPP_FINISHINGS_PUNCH_DUAL_RIGHT | Punch 2 holes right side |
IPP_FINISHINGS_PUNCH_DUAL_TOP | Punch 2 holes top edge |
IPP_FINISHINGS_PUNCH_MULTIPLE_BOTTOM | Punch multiple holes bottom edge |
IPP_FINISHINGS_PUNCH_MULTIPLE_LEFT | Punch multiple holes left side |
IPP_FINISHINGS_PUNCH_MULTIPLE_RIGHT | Punch multiple holes right side |
IPP_FINISHINGS_PUNCH_MULTIPLE_TOP | Punch multiple holes top edge |
IPP_FINISHINGS_PUNCH_QUAD_BOTTOM | Punch 4 holes bottom edge |
IPP_FINISHINGS_PUNCH_QUAD_LEFT | Punch 4 holes left side |
IPP_FINISHINGS_PUNCH_QUAD_RIGHT | Punch 4 holes right side |
IPP_FINISHINGS_PUNCH_QUAD_TOP | Punch 4 holes top edge |
IPP_FINISHINGS_PUNCH_TOP_LEFT | Punch 1 hole top left |
IPP_FINISHINGS_PUNCH_TOP_RIGHT | Punch 1 hole top right |
IPP_FINISHINGS_PUNCH_TRIPLE_BOTTOM | Punch 3 holes bottom edge |
IPP_FINISHINGS_PUNCH_TRIPLE_LEFT | Punch 3 holes left side |
IPP_FINISHINGS_PUNCH_TRIPLE_RIGHT | Punch 3 holes right side |
IPP_FINISHINGS_PUNCH_TRIPLE_TOP | Punch 3 holes top edge |
IPP_FINISHINGS_SADDLE_STITCH | Staple interior |
IPP_FINISHINGS_STAPLE | Staple (any location/method) |
IPP_FINISHINGS_STAPLE_BOTTOM_LEFT | Staple bottom left corner |
IPP_FINISHINGS_STAPLE_BOTTOM_RIGHT | Staple bottom right corner |
IPP_FINISHINGS_STAPLE_DUAL_BOTTOM | Two staples on bottom |
IPP_FINISHINGS_STAPLE_DUAL_LEFT | Two staples on left |
IPP_FINISHINGS_STAPLE_DUAL_RIGHT | Two staples on right |
IPP_FINISHINGS_STAPLE_DUAL_TOP | Two staples on top |
IPP_FINISHINGS_STAPLE_TOP_LEFT | Staple top left corner |
IPP_FINISHINGS_STAPLE_TOP_RIGHT | Staple top right corner |
IPP_FINISHINGS_STAPLE_TRIPLE_BOTTOM | Three staples on bottom |
IPP_FINISHINGS_STAPLE_TRIPLE_LEFT | Three staples on left |
IPP_FINISHINGS_STAPLE_TRIPLE_RIGHT | Three staples on right |
IPP_FINISHINGS_STAPLE_TRIPLE_TOP | Three staples on top |
IPP_FINISHINGS_TRIM | Trim (any type) |
IPP_FINISHINGS_TRIM_AFTER_COPIES | Trim output after each copy |
IPP_FINISHINGS_TRIM_AFTER_DOCUMENTS | Trim output after each document |
IPP_FINISHINGS_TRIM_AFTER_JOB | Trim output after job |
IPP_FINISHINGS_TRIM_AFTER_PAGES | Trim output after each page |
Job states
IPP_JSTATE_ABORTED | Job has aborted due to error |
---|---|
IPP_JSTATE_CANCELED | Job has been canceled |
IPP_JSTATE_COMPLETED | Job has completed successfully |
IPP_JSTATE_HELD | Job is held for printing |
IPP_JSTATE_PENDING | Job is waiting to be printed |
IPP_JSTATE_PROCESSING | Job is currently printing |
IPP_JSTATE_STOPPED | Job has been stopped |
IPP operations
IPP_OP_ALLOCATE_PRINTER_RESOURCES | Allocate-Printer-Resources: Use resources for a printer. |
---|---|
IPP_OP_CANCEL_CURRENT_JOB | Cancel-Current-Job: Cancel the current job |
IPP_OP_CANCEL_JOB | Cancel-Job: Cancel a job |
IPP_OP_CANCEL_JOBS | Cancel-Jobs: Cancel all jobs (administrative) |
IPP_OP_CANCEL_MY_JOBS | Cancel-My-Jobs: Cancel a user's jobs |
IPP_OP_CANCEL_RESOURCE | Cancel-Resource: Uninstall a resource. |
IPP_OP_CANCEL_SUBSCRIPTION CUPS 1.2 | Cancel-Subscription: Cancel a subscription |
IPP_OP_CLOSE_JOB | Close-Job: Close a job and start printing |
IPP_OP_CREATE_JOB | Create-Job: Create an empty print job |
IPP_OP_CREATE_JOB_SUBSCRIPTIONS CUPS 1.2 | Create-Job-Subscriptions: Create one of more job subscriptions |
IPP_OP_CREATE_PRINTER | Create-Printer: Create a new service. |
IPP_OP_CREATE_PRINTER_SUBSCRIPTIONS CUPS 1.2 | Create-Printer-Subscriptions: Create one or more printer subscriptions |
IPP_OP_CREATE_RESOURCE | Create-Resource: Create a new (empty) resource. |
IPP_OP_CREATE_RESOURCE_SUBSCRIPTIONS | Create-Resource-Subscriptions: Create event subscriptions for a resource. |
IPP_OP_CREATE_SYSTEM_SUBSCRIPTIONS | Create-System-Subscriptions: Create event subscriptions for a system. |
IPP_OP_CUPS_ADD_MODIFY_CLASS | CUPS-Add-Modify-Class: Add or modify a class |
IPP_OP_CUPS_ADD_MODIFY_PRINTER | CUPS-Add-Modify-Printer: Add or modify a printer |
IPP_OP_CUPS_AUTHENTICATE_JOB CUPS 1.2 | CUPS-Authenticate-Job: Authenticate a job |
IPP_OP_CUPS_CREATE_LOCAL_PRINTER CUPS 2.2 | CUPS-Create-Local-Printer: Create a local (temporary) printer |
IPP_OP_CUPS_DELETE_CLASS | CUPS-Delete-Class: Delete a class |
IPP_OP_CUPS_DELETE_PRINTER | CUPS-Delete-Printer: Delete a printer |
IPP_OP_CUPS_GET_DEFAULT | CUPS-Get-Default: Get the default printer |
IPP_OP_CUPS_GET_DEVICES DEPRECATED | CUPS-Get-Devices: Get a list of supported devices |
IPP_OP_CUPS_GET_DOCUMENT CUPS 1.4 | CUPS-Get-Document: Get a document file |
IPP_OP_CUPS_GET_PPD DEPRECATED | CUPS-Get-PPD: Get a PPD file |
IPP_OP_CUPS_GET_PPDS DEPRECATED | CUPS-Get-PPDs: Get a list of supported drivers |
IPP_OP_CUPS_GET_PRINTERS | CUPS-Get-Printers: Get a list of printers and/or classes |
IPP_OP_CUPS_INVALID | Invalid operation name for ippOpValue |
IPP_OP_CUPS_MOVE_JOB | CUPS-Move-Job: Move a job to a different printer |
IPP_OP_CUPS_SET_DEFAULT | CUPS-Set-Default: Set the default printer |
IPP_OP_DEALLOCATE_PRINTER_RESOURCES | Deallocate-Printer-Resources: Stop using resources for a printer. |
IPP_OP_DELETE_PRINTER | Delete-Printer: Delete an existing service. |
IPP_OP_DISABLE_ALL_PRINTERS | Disable-All-Printers: Stop accepting new jobs on all services. |
IPP_OP_DISABLE_PRINTER | Disable-Printer: Reject new jobs for a printer |
IPP_OP_ENABLE_ALL_PRINTERS | Enable-All-Printers: Start accepting new jobs on all services. |
IPP_OP_ENABLE_PRINTER | Enable-Printer: Accept new jobs for a printer |
IPP_OP_GET_JOBS | Get-Jobs: Get a list of jobs |
IPP_OP_GET_JOB_ATTRIBUTES | Get-Job-Attribute: Get information about a job |
IPP_OP_GET_NOTIFICATIONS CUPS 1.2 | Get-Notifications: Get notification events |
IPP_OP_GET_PRINTERS | Get-Printers: Get a list of services. |
IPP_OP_GET_PRINTER_ATTRIBUTES | Get-Printer-Attributes: Get information about a printer |
IPP_OP_GET_PRINTER_SUPPORTED_VALUES | Get-Printer-Supported-Values: Get supported values |
IPP_OP_GET_SUBSCRIPTIONS CUPS 1.2 | Get-Subscriptions: Get list of subscriptions |
IPP_OP_GET_SUBSCRIPTION_ATTRIBUTES CUPS 1.2 | Get-Subscription-Attributes: Get subscription information |
IPP_OP_GET_SYSTEM_ATTRIBUTES | Get-System-Attributes: Get system object attributes. |
IPP_OP_GET_SYSTEM_SUPPORTED_VALUES | Get-System-Supported-Values: Get supported values for system object attributes. |
IPP_OP_HOLD_JOB | Hold-Job: Hold a job for printing |
IPP_OP_HOLD_NEW_JOBS | Hold-New-Jobs: Hold new jobs |
IPP_OP_IDENTIFY_PRINTER | Identify-Printer: Make the printer beep, flash, or display a message for identification |
IPP_OP_INSTALL_RESOURCE | Install-Resource: Install a resource. |
IPP_OP_PAUSE_ALL_PRINTERS | Pause-All-Printers: Stop all services immediately. |
IPP_OP_PAUSE_ALL_PRINTERS_AFTER_CURRENT_JOB | Pause-All-Printers-After-Current-Job: Stop all services after processing the current jobs. |
IPP_OP_PAUSE_PRINTER | Pause-Printer: Stop a printer |
IPP_OP_PAUSE_PRINTER_AFTER_CURRENT_JOB | Pause-Printer-After-Current-Job: Stop printer after the current job |
IPP_OP_PRINT_JOB | Print-Job: Print a single file |
IPP_OP_PROMOTE_JOB | Promote-Job: Promote a job to print sooner |
IPP_OP_REGISTER_OUTPUT_DEVICE | Register-Output-Device: Register a remote service. |
IPP_OP_RELEASE_HELD_NEW_JOBS | Release-Held-New-Jobs: Release new jobs that were previously held |
IPP_OP_RELEASE_JOB | Release-Job: Release a job for printing |
IPP_OP_RENEW_SUBSCRIPTION CUPS 1.2 | Renew-Subscription: Renew a printer subscription |
IPP_OP_RESTART_JOB DEPRECATED | Restart-Job: Reprint a job |
IPP_OP_RESTART_SYSTEM | Restart-System: Restart all services. |
IPP_OP_RESUME_ALL_PRINTERS | Resume-All-Printers: Start job processing on all services. |
IPP_OP_RESUME_JOB | Resume-Job: Resume the current job |
IPP_OP_RESUME_PRINTER | Resume-Printer: Start a printer |
IPP_OP_SCHEDULE_JOB_AFTER | Schedule-Job-After: Schedule a job to print after another |
IPP_OP_SEND_DOCUMENT | Send-Document: Add a file to a job |
IPP_OP_SEND_RESOURCE_DATA | Send-Resource-Data: Upload the data for a resource. |
IPP_OP_SET_JOB_ATTRIBUTES | Set-Job-Attributes: Set job values |
IPP_OP_SET_PRINTER_ATTRIBUTES | Set-Printer-Attributes: Set printer values |
IPP_OP_SET_RESOURCE_ATTRIBUTES | Set-Resource-Attributes: Set resource object attributes. |
IPP_OP_SET_SYSTEM_ATTRIBUTES | Set-System-Attributes: Set system object attributes. |
IPP_OP_SHUTDOWN_ALL_PRINTERS | Shutdown-All-Printers: Shutdown all services. |
IPP_OP_SHUTDOWN_ONE_PRINTER | Shutdown-One-Printer: Shutdown a service. |
IPP_OP_STARTUP_ALL_PRINTERS | Startup-All-Printers: Startup all services. |
IPP_OP_STARTUP_ONE_PRINTER | Startup-One-Printer: Start a service. |
IPP_OP_SUSPEND_CURRENT_JOB | Suspend-Current-Job: Suspend the current job |
IPP_OP_VALIDATE_JOB | Validate-Job: Validate job values prior to submission |
Orientation values
IPP_ORIENT_LANDSCAPE | 90 degrees counter-clockwise |
---|---|
IPP_ORIENT_NONE | No rotation |
IPP_ORIENT_PORTRAIT | No rotation |
IPP_ORIENT_REVERSE_LANDSCAPE | 90 degrees clockwise |
IPP_ORIENT_REVERSE_PORTRAIT | 180 degrees |
Printer state values
IPP_PSTATE_IDLE | Printer is idle |
---|---|
IPP_PSTATE_PROCESSING | Printer is working |
IPP_PSTATE_STOPPED | Printer is stopped |
Print quality values
IPP_QUALITY_DRAFT | Draft quality |
---|---|
IPP_QUALITY_HIGH | High quality |
IPP_QUALITY_NORMAL | Normal quality |
Resolution units
IPP_RES_PER_CM | Pixels per centimeter |
---|---|
IPP_RES_PER_INCH | Pixels per inch |
resource-state values
IPP_RSTATE_ABORTED | Resource has been aborted and is pending deletion. |
---|---|
IPP_RSTATE_AVAILABLE | Resource is available for installation. |
IPP_RSTATE_CANCELED | Resource has been canceled and is pending deletion. |
IPP_RSTATE_INSTALLED | Resource is installed. |
IPP_RSTATE_PENDING | Resource is created but has no data yet. |
system-state values
IPP_SSTATE_IDLE | At least one printer is idle and none are processing a job. |
---|---|
IPP_SSTATE_PROCESSING | At least one printer is processing a job. |
IPP_SSTATE_STOPPED | All printers are stopped. |
ipp_t state values
IPP_STATE_ATTRIBUTE | One or more attributes need to be sent/received |
---|---|
IPP_STATE_DATA | IPP request data needs to be sent/received |
IPP_STATE_ERROR | An error occurred |
IPP_STATE_HEADER | The request header needs to be sent/received |
IPP_STATE_IDLE | Nothing is happening/request completed |
IPP status code values
IPP_STATUS_CUPS_INVALID | Invalid status name for ippErrorValue |
---|---|
IPP_STATUS_ERROR_ACCOUNT_AUTHORIZATION_FAILED | client-error-account-authorization-failed |
IPP_STATUS_ERROR_ACCOUNT_CLOSED | client-error-account-closed |
IPP_STATUS_ERROR_ACCOUNT_INFO_NEEDED | client-error-account-info-needed |
IPP_STATUS_ERROR_ACCOUNT_LIMIT_REACHED | client-error-account-limit-reached |
IPP_STATUS_ERROR_ATTRIBUTES_NOT_SETTABLE | client-error-attributes-not-settable |
IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES | client-error-attributes-or-values-not-supported |
IPP_STATUS_ERROR_BAD_REQUEST | client-error-bad-request |
IPP_STATUS_ERROR_BUSY | server-error-busy |
IPP_STATUS_ERROR_CHARSET | client-error-charset-not-supported |
IPP_STATUS_ERROR_COMPRESSION_ERROR | client-error-compression-error |
IPP_STATUS_ERROR_COMPRESSION_NOT_SUPPORTED | client-error-compression-not-supported |
IPP_STATUS_ERROR_CONFLICTING | client-error-conflicting-attributes |
IPP_STATUS_ERROR_CUPS_ACCOUNT_AUTHORIZATION_FAILED DEPRECATED | cups-error-account-authorization-failed |
IPP_STATUS_ERROR_CUPS_ACCOUNT_CLOSED | cups-error-account-closed @deprecate@ |
IPP_STATUS_ERROR_CUPS_ACCOUNT_INFO_NEEDED DEPRECATED | cups-error-account-info-needed |
IPP_STATUS_ERROR_CUPS_ACCOUNT_LIMIT_REACHED DEPRECATED | cups-error-account-limit-reached |
IPP_STATUS_ERROR_CUPS_AUTHENTICATION_CANCELED CUPS 1.5 | cups-authentication-canceled - Authentication canceled by user |
IPP_STATUS_ERROR_CUPS_OAUTH | cups-oauth - OAuth error |
IPP_STATUS_ERROR_CUPS_PKI CUPS 1.5 | cups-pki-error - Error negotiating a secure connection |
IPP_STATUS_ERROR_CUPS_UPGRADE_REQUIRED CUPS 1.5 | cups-upgrade-required - TLS upgrade required |
IPP_STATUS_ERROR_DEVICE | server-error-device-error |
IPP_STATUS_ERROR_DOCUMENT_ACCESS | client-error-document-access-error |
IPP_STATUS_ERROR_DOCUMENT_FORMAT_ERROR | client-error-document-format-error |
IPP_STATUS_ERROR_DOCUMENT_FORMAT_NOT_SUPPORTED | client-error-document-format-not-supported |
IPP_STATUS_ERROR_DOCUMENT_PASSWORD | client-error-document-password-error |
IPP_STATUS_ERROR_DOCUMENT_PERMISSION | client-error-document-permission-error |
IPP_STATUS_ERROR_DOCUMENT_SECURITY | client-error-document-security-error |
IPP_STATUS_ERROR_DOCUMENT_UNPRINTABLE | client-error-document-unprintable-error |
IPP_STATUS_ERROR_FORBIDDEN | client-error-forbidden |
IPP_STATUS_ERROR_GONE | client-error-gone |
IPP_STATUS_ERROR_IGNORED_ALL_SUBSCRIPTIONS | client-error-ignored-all-subscriptions |
IPP_STATUS_ERROR_INTERNAL | server-error-internal-error |
IPP_STATUS_ERROR_JOB_CANCELED | server-error-job-canceled |
IPP_STATUS_ERROR_MULTIPLE_JOBS_NOT_SUPPORTED | server-error-multiple-document-jobs-not-supported |
IPP_STATUS_ERROR_NOT_ACCEPTING_JOBS | server-error-not-accepting-jobs |
IPP_STATUS_ERROR_NOT_AUTHENTICATED | client-error-not-authenticated |
IPP_STATUS_ERROR_NOT_AUTHORIZED | client-error-not-authorized |
IPP_STATUS_ERROR_NOT_FETCHABLE | client-error-not-fetchable |
IPP_STATUS_ERROR_NOT_FOUND | client-error-not-found |
IPP_STATUS_ERROR_NOT_POSSIBLE | client-error-not-possible |
IPP_STATUS_ERROR_OPERATION_NOT_SUPPORTED | server-error-operation-not-supported |
IPP_STATUS_ERROR_PRINTER_IS_DEACTIVATED | server-error-printer-is-deactivated |
IPP_STATUS_ERROR_REQUEST_ENTITY | client-error-request-entity-too-large |
IPP_STATUS_ERROR_REQUEST_VALUE | client-error-request-value-too-long |
IPP_STATUS_ERROR_SERVICE_UNAVAILABLE | server-error-service-unavailable |
IPP_STATUS_ERROR_TEMPORARY | server-error-temporary-error |
IPP_STATUS_ERROR_TIMEOUT | client-error-timeout |
IPP_STATUS_ERROR_TOO_MANY_DOCUMENTS | server-error-too-many-documents |
IPP_STATUS_ERROR_TOO_MANY_JOBS | server-error-too-many-jobs |
IPP_STATUS_ERROR_TOO_MANY_SUBSCRIPTIONS | client-error-too-many-subscriptions |
IPP_STATUS_ERROR_URI_SCHEME | client-error-uri-scheme-not-supported |
IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED | server-error-version-not-supported |
IPP_STATUS_OK | successful-ok |
IPP_STATUS_OK_CONFLICTING | successful-ok-conflicting-attributes |
IPP_STATUS_OK_EVENTS_COMPLETE | successful-ok-events-complete |
IPP_STATUS_OK_IGNORED_OR_SUBSTITUTED | successful-ok-ignored-or-substituted-attributes |
IPP_STATUS_OK_IGNORED_SUBSCRIPTIONS | successful-ok-ignored-subscriptions |
IPP_STATUS_OK_TOO_MANY_EVENTS | successful-ok-too-many-events |
Value and group tag values for attributes
IPP_TAG_ADMINDEFINE | Admin-defined value |
---|---|
IPP_TAG_BOOLEAN | Boolean value |
IPP_TAG_CHARSET | Character set value |
IPP_TAG_CUPS_INVALID | Invalid tag name for ippTagValue |
IPP_TAG_DATE | Date/time value |
IPP_TAG_DEFAULT | Default value |
IPP_TAG_DELETEATTR | Delete-attribute value |
IPP_TAG_DOCUMENT | Document group |
IPP_TAG_END | End-of-attributes |
IPP_TAG_ENUM | Enumeration value |
IPP_TAG_EVENT_NOTIFICATION | Event group |
IPP_TAG_EXTENSION | Extension point for 32-bit tags (part of value) |
IPP_TAG_INTEGER | Integer value |
IPP_TAG_JOB | Job group |
IPP_TAG_KEYWORD | Keyword value |
IPP_TAG_LANGUAGE | Language value |
IPP_TAG_MIMETYPE | MIME media type value |
IPP_TAG_NAME | Name value |
IPP_TAG_NAMELANG | Name-with-language value |
IPP_TAG_NOTSETTABLE | Not-settable value |
IPP_TAG_NOVALUE | No-value value |
IPP_TAG_OPERATION | Operation group |
IPP_TAG_PRINTER | Printer group |
IPP_TAG_RANGE | Range value |
IPP_TAG_RESOLUTION | Resolution value |
IPP_TAG_RESOURCE | Resource group |
IPP_TAG_STRING | Octet string value |
IPP_TAG_SUBSCRIPTION | Subscription group |
IPP_TAG_SYSTEM | System group |
IPP_TAG_TEXT | Text value |
IPP_TAG_TEXTLANG | Text-with-language value |
IPP_TAG_UNKNOWN | Unknown value |
IPP_TAG_UNSUPPORTED_GROUP | Unsupported attributes group |
IPP_TAG_UNSUPPORTED_VALUE | Unsupported value |
IPP_TAG_URI | URI value |
IPP_TAG_URISCHEME | URI scheme value |
IPP_TAG_ZERO | Zero tag - used for separators |