Interface Cups
- All Superinterfaces:
Library
<cups/cups.h>.
CUPS provides a portable printing layer for UNIX-based operating systems. It uses the Internet Printing Protocol (IPP) as the basis for managing print jobs, queues, and printers.
Reference: CUPS Programming Manual
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classCUPS destination (printer or class) structure.static classCUPS job structure.static classCUPS option (name/value pair) structure.Nested classes/interfaces inherited from interface Library
Library.Handler -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPrinter requires authentication.static final intCan bind output.static final intCan do B&W printing.static final intPrinter class (group of printers).static final intCan quickly collate copies.static final intCan do color printing.static final intPrinter supports maintenance commands.static final intCan do copies in hardware.static final intCan cover output.static final intDefault printer on network.static final intPrinter was discovered (not configured locally).static final intCan do two-sided printing.static final intFax queue.static final intCan print on D/E/A1/A0-size media.static final intCan print on Tabloid/B/C/A3/A2-size media.static final intPrinter is not shared.static final intCan punch output.static final intPrinter is rejecting jobs.static final intRemote printer or class.static final intCan print on Letter/Legal/A4-size media.static final intCan sort output.static final intCan staple output.static final intCan print on rolls and custom-size media.static final intReturn active (pending, processing, held) jobs.static final intReturn all jobs regardless of state.static final intReturn completed (stopped, canceled, aborted, completed) jobs.static final Cupsstatic final intJob has been aborted due to an error.static final intJob has been canceled.static final intJob has completed successfully.static final intJob has been held for printing.static final intJob is waiting to be printed.static final intJob is currently printing.static final intJob has been stopped.static final intThe printer is idle and ready to accept jobs.static final intThe printer is currently processing a job.static final intThe printer is stopped (paused or has an error). -
Method Summary
Modifier and TypeMethodDescriptionintcupsAddOption(String name, String value, int num_options, PointerByReference options) Adds an option to an options array.intcupsCancelJob(String name, int job_id) Cancels a job on a destination.voidcupsFreeDests(int num_dests, Pointer dests) Frees the memory used by a destination array returned bycupsGetDests(PointerByReference)orcupsGetDests2(Pointer, PointerByReference).voidcupsFreeJobs(int num_jobs, Pointer jobs) Frees the memory used by a job array returned bycupsGetJobs2(Pointer, PointerByReference, String, int, int).voidcupsFreeOptions(int num_options, Pointer options) Frees the memory used by an options array.Gets the default printer name.cupsGetDest(String name, String instance, int num_dests, Pointer dests) Gets the named destination from a destination list.intcupsGetDests(PointerByReference dests) Gets all available destinations (printers and classes) from the default server.intcupsGetDests2(Pointer http, PointerByReference dests) Gets all available destinations (printers and classes) from the specified server.intcupsGetJobs2(Pointer http, PointerByReference jobs, String name, int myjobs, int whichjobs) Gets the jobs from the specified server.cupsGetNamedDest(Pointer http, String name, String instance) Gets options for the named destination, optimized for retrieving a single destination.cupsGetOption(String name, int num_options, Pointer options) Gets an option value from a destination's options array.intReturns the last IPP status code from a CUPS operation.Returns a human-readable message for the last IPP error.Returns the hostname or address of the current CUPS server.voidcupsSetServer(String server) Sets the default CUPS server name and port.voidcupsSetUser(String user) Sets the default user name for CUPS operations.cupsUser()Returns the current user's name as known to CUPS.
-
Field Details
-
INSTANCE
-
IPP_PRINTER_IDLE
static final int IPP_PRINTER_IDLEThe printer is idle and ready to accept jobs.- See Also:
-
IPP_PRINTER_PROCESSING
static final int IPP_PRINTER_PROCESSINGThe printer is currently processing a job.- See Also:
-
IPP_PRINTER_STOPPED
static final int IPP_PRINTER_STOPPEDThe printer is stopped (paused or has an error).- See Also:
-
CUPS_PRINTER_CLASS
static final int CUPS_PRINTER_CLASSPrinter class (group of printers).- See Also:
-
CUPS_PRINTER_REMOTE
static final int CUPS_PRINTER_REMOTERemote printer or class.- See Also:
-
CUPS_PRINTER_BW
static final int CUPS_PRINTER_BWCan do B&W printing.- See Also:
-
CUPS_PRINTER_COLOR
static final int CUPS_PRINTER_COLORCan do color printing.- See Also:
-
CUPS_PRINTER_DUPLEX
static final int CUPS_PRINTER_DUPLEXCan do two-sided printing.- See Also:
-
CUPS_PRINTER_STAPLE
static final int CUPS_PRINTER_STAPLECan staple output.- See Also:
-
CUPS_PRINTER_COPIES
static final int CUPS_PRINTER_COPIESCan do copies in hardware.- See Also:
-
CUPS_PRINTER_COLLATE
static final int CUPS_PRINTER_COLLATECan quickly collate copies.- See Also:
-
CUPS_PRINTER_PUNCH
static final int CUPS_PRINTER_PUNCHCan punch output.- See Also:
-
CUPS_PRINTER_COVER
static final int CUPS_PRINTER_COVERCan cover output.- See Also:
-
CUPS_PRINTER_BIND
static final int CUPS_PRINTER_BINDCan bind output.- See Also:
-
CUPS_PRINTER_SORT
static final int CUPS_PRINTER_SORTCan sort output.- See Also:
-
CUPS_PRINTER_SMALL
static final int CUPS_PRINTER_SMALLCan print on Letter/Legal/A4-size media.- See Also:
-
CUPS_PRINTER_MEDIUM
static final int CUPS_PRINTER_MEDIUMCan print on Tabloid/B/C/A3/A2-size media.- See Also:
-
CUPS_PRINTER_LARGE
static final int CUPS_PRINTER_LARGECan print on D/E/A1/A0-size media.- See Also:
-
CUPS_PRINTER_VARIABLE
static final int CUPS_PRINTER_VARIABLECan print on rolls and custom-size media.- See Also:
-
CUPS_PRINTER_DEFAULT
static final int CUPS_PRINTER_DEFAULTDefault printer on network.- See Also:
-
CUPS_PRINTER_FAX
static final int CUPS_PRINTER_FAXFax queue.- See Also:
-
CUPS_PRINTER_REJECTING
static final int CUPS_PRINTER_REJECTINGPrinter is rejecting jobs.- See Also:
-
CUPS_PRINTER_NOT_SHARED
static final int CUPS_PRINTER_NOT_SHAREDPrinter is not shared. @since CUPS 1.2- See Also:
-
CUPS_PRINTER_AUTHENTICATED
static final int CUPS_PRINTER_AUTHENTICATEDPrinter requires authentication. @since CUPS 1.2- See Also:
-
CUPS_PRINTER_COMMANDS
static final int CUPS_PRINTER_COMMANDSPrinter supports maintenance commands. @since CUPS 1.2- See Also:
-
CUPS_PRINTER_DISCOVERED
static final int CUPS_PRINTER_DISCOVEREDPrinter was discovered (not configured locally). @since CUPS 1.2- See Also:
-
IPP_JSTATE_PENDING
static final int IPP_JSTATE_PENDINGJob is waiting to be printed.- See Also:
-
IPP_JSTATE_HELD
static final int IPP_JSTATE_HELDJob has been held for printing.- See Also:
-
IPP_JSTATE_PROCESSING
static final int IPP_JSTATE_PROCESSINGJob is currently printing.- See Also:
-
IPP_JSTATE_STOPPED
static final int IPP_JSTATE_STOPPEDJob has been stopped.- See Also:
-
IPP_JSTATE_CANCELED
static final int IPP_JSTATE_CANCELEDJob has been canceled.- See Also:
-
IPP_JSTATE_ABORTED
static final int IPP_JSTATE_ABORTEDJob has been aborted due to an error.- See Also:
-
IPP_JSTATE_COMPLETED
static final int IPP_JSTATE_COMPLETEDJob has completed successfully.- See Also:
-
CUPS_WHICHJOBS_ALL
static final int CUPS_WHICHJOBS_ALLReturn all jobs regardless of state.- See Also:
-
CUPS_WHICHJOBS_ACTIVE
static final int CUPS_WHICHJOBS_ACTIVEReturn active (pending, processing, held) jobs.- See Also:
-
CUPS_WHICHJOBS_COMPLETED
static final int CUPS_WHICHJOBS_COMPLETEDReturn completed (stopped, canceled, aborted, completed) jobs.- See Also:
-
-
Method Details
-
cupsGetDests
Gets all available destinations (printers and classes) from the default server.The returned list includes options containing printer attributes. Use
cupsGetOption(String, int, Pointer)to retrieve specific attribute values from a destination's options.Use
cupsFreeDests(int, Pointer)to free the returned destination list.- Parameters:
dests- pointer to receive the destination array- Returns:
- the number of destinations
- See Also:
-
cupsGetDests2
Gets all available destinations (printers and classes) from the specified server.Pass
nullfor thehttpparameter to use the default server connection (equivalent toCUPS_HTTP_DEFAULT).Use
cupsFreeDests(int, Pointer)to free the returned destination list.- Parameters:
http- connection to server ornullfor the default connectiondests- pointer to receive the destination array- Returns:
- the number of destinations
- Since:
- CUPS 1.1.21
- See Also:
-
cupsFreeDests
Frees the memory used by a destination array returned bycupsGetDests(PointerByReference)orcupsGetDests2(Pointer, PointerByReference).- Parameters:
num_dests- number of destinationsdests- pointer to the destination array- See Also:
-
cupsGetDest
Gets the named destination from a destination list.Use
cupsGetDests(PointerByReference)orcupsGetDests2(Pointer, PointerByReference)to get the list, then call this function to find a specific destination by name.- Parameters:
name- destination name ornullfor the default destinationinstance- instance name ornullnum_dests- number of destinations in the listdests- pointer to the destination array- Returns:
- pointer to the matching destination or
nullif not found - See Also:
-
cupsGetNamedDest
Gets options for the named destination, optimized for retrieving a single destination.This function is preferred over
cupsGetDests2(Pointer, PointerByReference)followed bycupsGetDest(String, String, int, Pointer)when you know the destination name or want the default destination.The returned destination must be freed using
cupsFreeDests(int, Pointer)with anum_destsvalue of 1.- Parameters:
http- connection to server ornullfor the default connectionname- destination name ornullfor the default destinationinstance- instance name ornull- Returns:
- pointer to the destination or
nullif not found - Since:
- CUPS 1.4
- See Also:
-
cupsGetDefault
String cupsGetDefault()Gets the default printer name.- Returns:
- the default printer name or
nullif no default is set - See Also:
-
cupsGetOption
Gets an option value from a destination's options array.Common option names include "printer-info", "printer-state", "printer-make-and-model", "printer-type", "printer-state-reasons", "printer-is-accepting-jobs", and "printer-uri-supported".
- Parameters:
name- option name to look upnum_options- number of options in the arrayoptions- pointer to the options array- Returns:
- the option value or
nullif not found - See Also:
-
cupsAddOption
Adds an option to an options array.If the named option already exists, its value is replaced.
- Parameters:
name- option namevalue- option valuenum_options- current number of optionsoptions- pointer to the options array (updated on return)- Returns:
- the new number of options
- See Also:
-
cupsFreeOptions
Frees the memory used by an options array.- Parameters:
num_options- number of optionsoptions- pointer to the options array- See Also:
-
cupsGetJobs2
Gets the jobs from the specified server.Use
cupsFreeJobs(int, Pointer)to free the returned job array.- Parameters:
http- connection to server ornullfor the default connectionjobs- pointer to receive the job arrayname- destination name ornullfor all destinationsmyjobs- 0 for all users' jobs, 1 for only the current user's jobswhichjobs- one ofCUPS_WHICHJOBS_ALL,CUPS_WHICHJOBS_ACTIVE, orCUPS_WHICHJOBS_COMPLETED- Returns:
- the number of jobs
- Since:
- CUPS 1.1.21
- See Also:
-
cupsFreeJobs
Frees the memory used by a job array returned bycupsGetJobs2(Pointer, PointerByReference, String, int, int).- Parameters:
num_jobs- number of jobsjobs- pointer to the job array- See Also:
-
cupsCancelJob
Cancels a job on a destination.- Parameters:
name- destination namejob_id- the job ID to cancelhttp- connection to server ornullfor the default connection- Returns:
- 0 on success, non-zero on failure
- See Also:
-
cupsServer
String cupsServer()Returns the hostname or address of the current CUPS server.The default server comes from the
CUPS_SERVERenvironment variable, then~/.cups/client.conf, and finally/etc/cups/client.conf. If not set, the default is "localhost" or a domain socket path.- Returns:
- the server name
- See Also:
-
cupsSetServer
Sets the default CUPS server name and port.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 optionally be followed by a colon and port number. Pass
nullto restore the default server.- Parameters:
server- server name ornullto restore default- See Also:
-
cupsUser
String cupsUser()Returns the current user's name as known to CUPS.Note: The current user name is tracked separately for each thread.
- Returns:
- the user name
- See Also:
-
cupsSetUser
Sets the default user name for CUPS operations.Pass
nullto restore the default user name. Note: The user name is tracked per-thread.- Parameters:
user- user name ornullto restore default- See Also:
-
cupsLastError
int cupsLastError()Returns the last IPP status code from a CUPS operation.- Returns:
- the IPP status code
-
cupsLastErrorString
String cupsLastErrorString()Returns a human-readable message for the last IPP error.- Returns:
- the error message string
-