CAPS Universe documentation  1.0.4
All you need to know to be successful
Functions
caps-printer-usb-detection.c File Reference

USB Printer Device Detection. More...

Functions

static int caps_prn_compare_serial_string (const struct usb_printer *pr, const struct caps_prn_printer_description *desc)
 
static int caps_prn_compare_vendor_id (const struct usb_printer *pr, const struct caps_prn_printer_description *desc)
 
static int caps_prn_compare_product_id (const struct usb_printer *pr, const struct caps_prn_printer_description *desc)
 
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)
 

Detailed Description

Author
Jürgen Borleis
Warning
Use as experimental

Routines to recognize a USB printer based on data stored in the CAPS Device Database (Printer Device Database)

Function Documentation

◆ caps_prn_compare_serial_string()

static int caps_prn_compare_serial_string ( const struct usb_printer pr,
const struct caps_prn_printer_description desc 
)
static

Check the serial string of the printer device and the database entry

Parameters
[in]prInformation about the connected printer device
[in]descInformation about a printer from the database
Return values
0The serial strings match
-ENODEVNo match

The serial string is the most important key to recognize an already known printer. If its not available, it will be ignored and the only used keys are VID and PID.

◆ caps_prn_compare_vendor_id()

static int caps_prn_compare_vendor_id ( const struct usb_printer pr,
const struct caps_prn_printer_description desc 
)
static

Check the USB vendor ID (aka "VID") of the printer device and the database entry

Parameters
[in]prInformation about the connected printer device
[in]descInformation about a printer from the database
Return values
0VID in pr and desc matches
-ENODEVNo match

◆ caps_prn_compare_product_id()

static int caps_prn_compare_product_id ( const struct usb_printer pr,
const struct caps_prn_printer_description desc 
)
static

Check the USB product ID (aka "PID") of the printer device and the database entry

Parameters
[in]prInformation about the connected printer device
[in]descInformation about a printer from the database
Return values
0PID in pr and desc matches
-ENODEVNo match

◆ 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