CAPS Printer Device Database handler routines.
More...
|
int | caps_prn_get_printer_device_database (struct caps_inif_table *db) |
|
static int | caps_prn_create_run_time_database (char *devices_database_path) |
|
struct caps_inif_lock * | caps_prn_get_printer_device_database_locked (struct caps_inif_table *db) |
|
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) |
|
static const char * | caps_prn_get_parameter (const struct caps_inif_table *db, const char *section, const char *key) |
|
int | caps_prn_get_printer_device_description (const struct caps_inif_table *db, const char *section, struct caps_prn_printer_description *desc) |
|
static int | caps_prn_set_parameter (struct caps_inif_table *db, const char *section, const char *key, const char *value) |
|
static int | caps_prn_set_number (struct caps_inif_table *db, const char *section, const char *key, int value) |
|
int | caps_prn_set_printer_description (struct caps_inif_table *db, const char *section, struct caps_prn_printer_description *desc) |
|
int | caps_prn_check_printer_entry (const struct caps_inif_table *db, const char *drv, const struct usb_printer *pr) |
|
- Copyright
- GNU Lesser General Public License 2.1
- Author
- Jürgen Borleis
- Warning
- Use as experimental
◆ PRINTER_DATABASE_NAME
#define PRINTER_DATABASE_NAME "printer-devices.ini" |
Name of the CAPS database of already known printers, located in the CAPS Printer Device Database Directory. "Already known" means, the printer device was at least attached once to the host and a driver was available at this time, e.g. the discover process was fully successful.
◆ caps_prn_get_printer_device_database()
Read in the run-time printer device database
- Parameters
-
[in,out] | db | Where to store the content |
- Return values
-
0 | On success |
-EINVAL | Error in INI file |
negative | Errno 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_create_run_time_database()
static int caps_prn_create_run_time_database |
( |
char * |
devices_database_path | ) |
|
|
static |
Create an empty run-time printer database INI file with correct permissions
- Parameters
-
[in] | devices_database_path | Name of the INI file to be created |
- Return values
-
0 | On success |
-EINVAL | Process does not run as 'root' |
open | Everything from open() |
- Precondition
- The CAPS Printer Device Database Directory must already exist
-
Needs root permissions
- Todo:
- The open() and chown() operation must be atomic (or should?)!
◆ caps_prn_get_printer_device_database_locked()
Read in the run-time printer device database and lock the corresponding INI file
- Parameters
-
[in,out] | db | Where 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_get_printer_driver_database()
Read in the persistent printer driver database
- Parameters
-
[out] | db | Where to store the content (expected to be already initialised) |
- Return values
-
0 | on success |
-ENODEV | no 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] | db | Where to store the content (expected to be already initialised) |
[in] | filename | Printing 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_parameter()
static const char * caps_prn_get_parameter |
( |
const struct caps_inif_table * |
db, |
|
|
const char * |
section, |
|
|
const char * |
key |
|
) |
| |
|
static |
◆ caps_prn_get_printer_device_description()
Convert a device data base entry into our local description structure
- Parameters
-
[in] | db | The run-time device database of currently known printer devices |
[in] | section | The 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_set_parameter()
static int caps_prn_set_parameter |
( |
struct caps_inif_table * |
db, |
|
|
const char * |
section, |
|
|
const char * |
key, |
|
|
const char * |
value |
|
) |
| |
|
static |
Set an entry in the device database with a string value
- Parameters
-
[in,out] | db | The device database |
[in] | section | In which section |
[in] | key | The name of the key |
[in] | value | The value of the key as a string |
- Returns
- Anything from caps_inif_option_add()
◆ caps_prn_set_number()
static int caps_prn_set_number |
( |
struct caps_inif_table * |
db, |
|
|
const char * |
section, |
|
|
const char * |
key, |
|
|
int |
value |
|
) |
| |
|
static |
Set an entry in the device database with an integer value
- Parameters
-
[in,out] | db | The device database |
[in] | section | In which section |
[in] | key | The name of the key |
[in] | value | The value of the key as an integer |
- Returns
- Anything from caps_inif_option_add()
Just a convenience function, since 'values' are always strings in the device database.
◆ caps_prn_set_printer_description()
Add a new printer device to the list/database of known devices
- Parameters
-
[in,out] | db | The device database |
[in] | section | The specific printer section of this new data |
[in] | desc | The printer device description |
- Return values
-
0 | On success |
-EINVAL | You add a non-USB device (not yet supported) |
◆ caps_prn_check_printer_entry()
Check if one given driver from the printer driver database corresponds to the given USB printing device
- Parameters
-
[in] | db | The driver database |
[in] | drv | The 'level' where to search in the database |
[in] | pr | The USB printer device description/information |
- Return values
-
0 | The given driver corresponds to the USB printer device |
-ENODEV | The USB printer device doesn't match |
Compares USB specific information with a driver database entry.