CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Retrieve available printers and their state. More...
Data Structures | |
struct | caps_cl_printer_list |
struct | caps_cl_printer_info |
struct | caps_cl_printer_state |
Functions | |
int | caps_cl_printer_list_get (struct caps_cl_handle *instance, struct caps_cl_printer_list **list) |
int | caps_cl_printer_info_get (struct caps_cl_handle *instance, caps_identifier printer_id, struct caps_cl_printer_info **info) |
void | caps_cl_printer_info_destroy (struct caps_cl_handle *instance, struct caps_cl_printer_info *info) |
int | caps_cl_printer_state_get (struct caps_cl_handle *instance, caps_identifier printer_id, struct caps_cl_printer_state *state) |
int | caps_cl_printer_PPD_get (struct caps_cl_handle *instance, caps_identifier printer_id, int *ppdfh) |
int | caps_cl_printer_name_to_id (struct caps_cl_handle *instance, const char *name, caps_identifier *printer_id) |
Some descriptions here use the description printer, some other the description printing provider. A printer is always the physical device, the printing provider the logical unit to manage this printer. It's a piece of software only and thus, can be run anywhere. Please bear with me if I don't use these two descriptions consequently. But most of the time it makes no difference, which one I use.
A printing provider is always identified by its identifier. This identifier is a 63 bit unique value (yes! sixty three) and names exactly one printing provider.
You can retrieve the currently know printing providers with a call to caps_cl_printer_list_get(). It returns a list of printing provider identifiers. The content of this list you can use to retrieve the details for each entry in a second step.
In your program it looks like that:
Knowing the printer ID is the key to retrieve other information/data of the printer as well.
Using the function caps_cl_printer_state_get() let you retrieve the current state the printer is in. Refer Printer State Definitions for details about states a printer can be in.
You can also request for the PostScript Printer Description file (aka PPD) for a more detailed feature description of the printer via the function caps_cl_printer_PPD_get(). Content from this file let you control the print job later on.
int caps_cl_printer_list_get | ( | struct caps_cl_handle * | instance, |
struct caps_cl_printer_list ** | list | ||
) |
Request for a list of IDs of currently known printing providers
[in] | instance | Client instance |
[in,out] | list | Where to store the result |
0 | Success and *list is valid |
-ENODEV | If no printers are available (*list is invalid) |
-EIO | Real communication error with the Printing Coordinator (should not happen) |
-EINVAL | Bad/unexpected reply from the Printing Coordinator (should not happen) |
The communication with the printing coordinator:
The full call stack:
int caps_cl_printer_info_get | ( | struct caps_cl_handle * | instance, |
caps_identifier | printer_id, | ||
struct caps_cl_printer_info ** | info | ||
) |
Retrieve a printing provider's base information
[in] | instance | Client instance |
[in] | printer_id | The printing provider's identifier to query |
[out] | info | Where to store the pointer to the information |
0 | On success (*info is valid) |
-ENODEV | printer_id invalid or outdated (*info is invalid) |
-EIO | Real communication error with the Printing Coordinator (should not happen, *info is invalid) |
-EINVAL | Bad/unexpected reply from the Printing Coordinator (should not happen, *info is invalid) |
Returns some generic information about the printer_id printing provider. This information is mostly originated by some admin when installing the printer and connecting a printing provider to it. The language is unknown. Encoding of all strings is utf8.
The returned information in info is inspired by the IPP protocol and the PPD file content. It should enable the client to select a specific printing provider later on.
As an example it could look like this:
Typ | String Content |
---|---|
name | Main Office Printer |
info | Don't use for mass printing |
location | 2nd floor |
vendor | Acme |
model | Laser Printer |
The communication with the printing coordinator:
The full call stack:
void caps_cl_printer_info_destroy | ( | struct caps_cl_handle * | instance, |
struct caps_cl_printer_info * | info | ||
) |
Free resources from caps_cl_printer_info_get()
[in] | instance | Client instance |
[in] | info | Printer information to destroy |
The full call stack:
int caps_cl_printer_state_get | ( | struct caps_cl_handle * | instance, |
caps_identifier | printer_id, | ||
struct caps_cl_printer_state * | state | ||
) |
Get the state of a specific printer/printing provider
[in] | instance | Client instance |
[in] | printer_id | The printing provider's identifier |
[out] | state | Where to store the printing provider's state |
0 | On success (*state is valid) |
-ENODEV | printer_id invalid (*state is invalid) |
-EIO | Real communication error with the Printing Coordinator (should not happen, *state is invalid) |
-EINVAL | Bad/unexpected reply from the Printing Coordinator (should not happen, *state is invalid) |
From the client point of view, a printer can be in one of the following active states:
Or in one of the tear down states (e.g. no acceptance of new print jobs anymore):
Refer Printer State Definitions for details about printing provider states.
The communication with the printing coordinator:
The full call stack:
int caps_cl_printer_PPD_get | ( | struct caps_cl_handle * | instance, |
caps_identifier | printer_id, | ||
int * | ppdfh | ||
) |
Get the printer's PPD file as a file descriptor
[in] | instance | Client instance |
[in] | printer_id | The printing provider's identifier to query |
[out] | ppdfh | Where to store the PPD's file descriptor |
0 | On success (*ppdfh is valid) |
-ENODEV | printer_id invalid (*ppdfh is invalid) |
-EIO | Real communication error with the Printing Coordinator (should not happen, *ppdfh is invalid) |
-EINVAL | Bad/unexpected reply from the Printing Coordinator (should not happen, *ppdfh is invalid) |
After the call the PPD file's read pointer is at the beginning of the file. This returned file descriptor isn't a shared resource - this function delivers a self removing copy instead. If you close the file descriptor the file is gone.
The communication with the printing coordinator:
The full call stack:
int caps_cl_printer_name_to_id | ( | struct caps_cl_handle * | instance, |
const char * | name, | ||
caps_identifier * | printer_id | ||
) |
Get the unique ID of a named printing provider
[in] | instance | Client instance |
[in] | name | The name of the printer (from the caps_cl_printer_info::name member) |
[out] | printer_id | The ID of the requested printer |
0 | On success (*printer_id is valid) |
-ENODEV | No printer with name found (*printer_id is invalid) |
If you know the name of a printer, but not its identifier, you can call this function.
The communication with the printing coordinator: