CAPS Universe documentation  1.0.4
All you need to know to be successful
Features
libcapsdriver: API description

CAPS universe printer driver convenience library. More...

Features

 Version info
 Info for user's code to do the right thing.
 
 Using the Printer Driver Framework from your driver
 The startup.
 
 Managing printer driver private data
 Set and get some driver private data in your callback functions.
 
 Managing some configuration information
 Configuration related helper functions.
 
 Define the printer device capabilities
 Printer Device Capabilities helper functions.
 
 Query the printer device and framework status
 Printer Device and Framework Status helper functions.
 
 Retrieving information about the job to print
 Get the information about the document and how the user wants to print it.
 
 Error handling when printing
 Provide more detailed information about failures.
 
 Retrieving information about the current page to print
 Get the information how the current page should be printed.
 
 Setting up the rasterizer for the current page
 Setup the information the rasterizer requires to rasterize the document page in a way your printer needs it.
 
 Get the full medium rasterized dot data to print
 Reading the full medium raster line by line for your own processing.
 
 Get the raw rasterized dot data to print
 Reading the raw raster line by line for your own processing.
 
 Some convenience functions
 Makes the life easier (sometimes)
 
 Access to internals
 Sometimes there is a need to get our fingers on internal data.
 
 Multi core processing framework
 Multithread framework to improve data processing.
 

Detailed Description

This library is a collection of helper functions to simplify printer driver development, since it hides all the communication, rasterization and reporting details of the CAPS universe.

Note
A skeleton implementation of a driver who uses libcapsdriver you can find in the libcapsdriver's skeleton/ subdirectory

The startup.

You mainly need to write some code to setup national language support (optional, on demand), trigger the command line parameter parsing and then call the libcapsdriver's caps_drv_run() function.

static const struct caps_generic_driver my_driver = {
// …your callback setup…
};
static struct caps_arg_parser parser[2];
int main(int argc, char *argv[])
{
.cnt = 2, .list = parser,
.errorout = stderr, .out = stdout,
};
struct caps_drv *h;
int rc;
[…]
[…]
rc = caps_drv_run(h, &my_driver, NULL);
[…]
[…]
return rc;
}
struct caps_arg_parser_list parser_list
Definition: hl1-series.c:325
static const struct caps_arg_parser parser
Definition: capsinfo.c:139
int caps_arg_parser_process(const struct caps_arg_parser_list *plist, int argc, char *argv[argc])
Definition: libcapscmdparser.c:561
int caps_drv_run(struct caps_drv *cdrv, const struct caps_generic_driver *cb, void *private)
Definition: libcapsdriver.c:781
void caps_drv_exit(struct caps_drv *cdrv)
Definition: libcapsdriver.c:617
struct caps_drv * caps_drv_init(struct caps_arg_parser parser[2])
Definition: libcapsdriver.c:593
static struct caps_si_handle h
Definition: libcapssystemintegration.c:41
int main(void)
Definition: stacktrace-test.c:35
Definition: libcapscmdparser.h:363
size_t cnt
Definition: libcapscmdparser.h:364
Definition: libcapscmdparser.h:348
libcapsdriver internal data collection
Definition: libcapsdriver-local.h:124
Printer Driver Callback declaration.
Definition: libcapsdriver.h:253

Instead of doing everything in your printer driver by your own, libcapsdriver uses callbacks into your driver to do all the required steps to start-up and dealing with print jobs. They are called at different stages to deal with print jobs in a generic manner.

Your printer driver callback functions are defined in a caps_generic_driver structure.

A special role has the caps_generic_driver::printer_monitor callback. It is intended to check the state of the printer. Depending on flags managed by libcapsdriver and INI file settings, the monitor callback is called at different points of time (refer caps_drv_printer_tweak_status).

Some printers are in trouble when their status is queried while they are printing at the same time. Thus, the monitor feature can be controlled via an INI setting.

Init Callback

It is called very early while initializing the framework.

Note
This callback is optional.

Printer Adaption Callback

Its called after the command line parameter parsing is done and all kind of information is available.

Functions related to this state:

Note
This callback is optional.

Job Start Callback

This callback is called when the framework has received a printing job. It already has checked if it can deal with the document data format, e.g. a corresponding rasterizer is already attached and now it is up to you to check if this job can be printed on your printer.

Functions related to this state:

Job Finish Callback

This callback is called once per job (even if printing has failed somehow).

Called when the job is "done" somehow, e.g.:

Printing can fail due to your own return values in Callback job_start(), or Callback page_setup(), Callback page_print() or Callback printer_monitor() or by failures detected somewhere else in the framework.

Page Setup Callback

Called when the framework has extracted all required information about the next page to print. It is called once per page.

Functions related to this state:

Page Print Callback

Called when the framework has rasterized the current page and this data is ready to be printed. It is called once per page. E.g. once per medium in simplex print and twice per medium when printing in duplex.

Note
For the case of -EINVAL and -ENXIO, you should use caps_drv_job_canceled() or caps_drv_job_aborted() to set a useful error message why the job was terminated (if you have one. Else the framework will set a generic one, which is most of the time less helpful).

Functions related to this state:

Printer Monitor Callback

Called, when the framework retrieves the status of the printer. But not always. See below.

libcapsdriver checks the printer status:

Whenever it checks the printer's status, it calls the callback only if it detects a ready printer device.

Note
This call interferes with some of the flags from caps_drv_prn_tweaks if set in your driver. E.g. it could be limited or fully disabled by these flags. Be warned about this.
This callback is optional.

Monitoring the printer device might be a sensible task somehow. Thus, its behaviour can be controlled via an INI file setting:

For how to control the behaviour, refer Feature: control printer monitoring

Exit Callback

Everything you need to clean up.

Note
This callback is optional.