CAPS Universe documentation  1.0.4
All you need to know to be successful
Data Structures | Enumerations | Functions
caps-printer.h File Reference

Prototypes for all source files. More...

Go to the source code of this file.

Data Structures

struct  usb_printer
 
struct  caps_prn_usb_description
 
struct  caps_prn_printer_description
 

Enumerations

enum  caps_prn_printer_type { CAPS_PRN_USB }
 

Functions

int caps_prn_usb_printer_identify (const struct usb_printer *pr, const struct caps_inif_table *db, const char **descr_ini, const char **param_dir)
 
int caps_prn_usb_printer_driver_get (const struct usb_printer *pr, const struct caps_inif_table *db, char **descr_ini)
 
int caps_prn_usb_printer_get_info (struct usb_printer *printer, const char *dnode)
 
int caps_prn_get_printer_driver_database (struct caps_inif_table *db)
 
int caps_prn_get_printing_providers_description (struct caps_inif_table *db, const char *filename)
 
struct caps_inif_lockcaps_prn_get_printer_device_database_locked (struct caps_inif_table *db)
 
int caps_prn_check_printer_entry (const struct caps_inif_table *db, const char *drv, const struct usb_printer *pr)
 
int caps_prn_set_printer_description (struct caps_inif_table *db, const char *section, struct caps_prn_printer_description *desc)
 
int caps_prn_get_printer_device_database (struct caps_inif_table *db)
 
int caps_prn_get_printer_device_description (const struct caps_inif_table *db, const char *section, struct caps_prn_printer_description *desc)
 
int caps_prn_launch_printer_provider (const char *descr_ini, const char *param_dir)
 

Detailed Description

Author
Jürgen Borleis
Warning
Use as experimental

Enumeration Type Documentation

◆ caps_prn_printer_type

Enumerator
CAPS_PRN_USB 

Function Documentation

◆ caps_prn_usb_printer_identify()

int caps_prn_usb_printer_identify ( const struct usb_printer pr,
const struct caps_inif_table db,
const char **  descr_ini,
const char **  param_dir 
)

Identify a USB printer device if it is already known

Parameters
[in]prThe USB printer description
[in]dbThe run-time device database of currently known printer devices
[out]descr_iniName of the Printing Provider Description INI File
[out]param_dirName of the Printer Device Parameter Directory
Return values
0On success (descr_ini and param_dir are valid)
-ENODEVThe requested printer isn't known, yet
negativeErrno else

On success this function provides valid descr_ini and param_dir pointers.

◆ caps_prn_usb_printer_driver_get()

int caps_prn_usb_printer_driver_get ( const struct usb_printer pr,
const struct caps_inif_table db,
char **  descr_ini 
)

Search for a printer driver for the given USB printer device

Parameters
[in]prThe USB printer device to search for its driver
[in]dbPrinter driver's database
[out]descr_iniWhere to store the pointer to the name of the driver's description INI file (must be freed after use)
Return values
0on success *descr_ini is valid
-ENODEVNo printer driver for the requested printer device found
negative-errno else

Walk trough the printer driver database entries and try to identify the corresponding driver for the given printer dervice.

The printer driver database is organized in levels. Each driver has a new level: It's filename (without the '.ini' extension).

Note
The pointer in descr_ini must be freed after use

◆ caps_prn_usb_printer_get_info()

int caps_prn_usb_printer_get_info ( struct usb_printer printer,
const char *  dnode 
)

Get the info about a printer, based on its device node

Parameters
[out]printerWhere to store the printer's information
[in]dnodeDevice node in question
Return values
0On success
-EINVALUSB enumeration failed, USB detection failed
-ENOENTdnode seems invalid

◆ caps_prn_get_printer_driver_database()

int caps_prn_get_printer_driver_database ( struct caps_inif_table db)

Read in the persistent printer driver database

Parameters
[out]dbWhere to store the content (expected to be already initialised)
Return values
0on success
-ENODEVno drivers installed

This reads in all existing INI files in the CAPS Printer Driver Database Directory

◆ caps_prn_get_printing_providers_description()

int caps_prn_get_printing_providers_description ( struct caps_inif_table db,
const char *  filename 
)

Read in one printing provider's description INI from the CAPS driver database directory

Parameters
[out]dbWhere to store the content (expected to be already initialised)
[in]filenamePrinting provider's description INI file name (name only, no path)
Returns
0 on success, negative errno else

This reads in an INI file with filename from the CAPS Printer Driver Database Directory

◆ caps_prn_get_printer_device_database_locked()

struct caps_inif_lock * caps_prn_get_printer_device_database_locked ( struct caps_inif_table db)

Read in the run-time printer device database and lock the corresponding INI file

Parameters
[in,out]dbWhere to store the content (expected to be already initialised)
Returns
Pointer to transparent info or NULL in case of a disaster
Note
The INI file is locked! Must be freed with caps_inif_locked_file_close()
Keep in mind, the file is locked and prevents other caps-printer instances doing their job.
Precondition
The CAPS Printer Device Database Directory must already exist
Needs root permissions
Todo:
Check if CAPS Printer Device Database Directory exists and output a useful error message if not

◆ caps_prn_check_printer_entry()

int caps_prn_check_printer_entry ( const struct caps_inif_table db,
const char *  drv,
const struct usb_printer pr 
)

Check if one given driver from the printer driver database corresponds to the given USB printing device

Parameters
[in]dbThe driver database
[in]drvThe 'level' where to search in the database
[in]prThe USB printer device description/information
Return values
0The given driver corresponds to the USB printer device
-ENODEVThe USB printer device doesn't match

Compares USB specific information with a driver database entry.

◆ caps_prn_set_printer_description()

int caps_prn_set_printer_description ( struct caps_inif_table db,
const char *  section,
struct caps_prn_printer_description desc 
)

Add a new printer device to the list/database of known devices

Parameters
[in,out]dbThe device database
[in]sectionThe specific printer section of this new data
[in]descThe printer device description
Return values
0On success
-EINVALYou add a non-USB device (not yet supported)

◆ caps_prn_get_printer_device_database()

int caps_prn_get_printer_device_database ( struct caps_inif_table db)

Read in the run-time printer device database

Parameters
[in,out]dbWhere to store the content
Return values
0On success
-EINVALError in INI file
negativeErrno else (from open() for example)
Note
The db doesn't include the content of the "Printer Device Parameter Directories" (CAPS Printer Device Parameter Directory)
Precondition
db must be already initialised and thus, empty

◆ caps_prn_get_printer_device_description()

int caps_prn_get_printer_device_description ( const struct caps_inif_table db,
const char *  section,
struct caps_prn_printer_description desc 
)

Convert a device data base entry into our local description structure

Parameters
[in]dbThe run-time device database of currently known printer devices
[in]sectionThe section to examine
[in]desc
Returns
0 on success, negative errno else
Todo:

This functionname should show we work with the persistent printer database -> run-time database

Error handling. Print correct missing entry if any!

Todo:
We do support nothing else than USB printers, yet

◆ caps_prn_launch_printer_provider()

int caps_prn_launch_printer_provider ( const char *  descr_ini,
const char *  param_dir 
)

Launch a printing provider

Parameters
[in]descr_iniPrinting provider's description INI file (file name only)
[in]param_dirParameter directory for this device (directory name only)
Return values
0On success
negative-errno else

File descriptors:

  • 0 stdin is closed
  • 1 stdout
  • 2 stderr
  • 3 Line printer device node

Keep stdout and stderr open, the filedescriptor to the printer device node as well.

Calls the printer driver as:

</path/to/caps/exec/dir>/<drivername> --driver-ini=<driverdefault.ini> --parameter-dir=<parameterdir>

These specific options are expected when the printing provider uses libcapsprovider.