CAPS Universe documentation
1.0.4
All you need to know to be successful
|
A collection of functions used by caps-printer-prep. More...
Functions | |
void | caps_prn_print_verbose_printer_message (const struct usb_printer *prn) |
static int | caps_prn_fix_directory_permissions (const char *dir) |
static int | caps_prn_create_initial_parameter_ini (const struct usb_printer *usb_prn, const char *dir) |
static bool | whitespace_less (const char *string) |
static const char * | caps_prn_get_useful_default_name (const struct usb_printer *prn) |
static int | caps_prn_create_unique_parameter_dir (const struct usb_printer *prn, char **param_dir) |
int | caps_prn_recognize_new_printer_device (const struct usb_printer *prn, struct caps_inif_table *db) |
This collection isn't part of the main C file in order to run tests on it.
void caps_prn_print_verbose_printer_message | ( | const struct usb_printer * | prn | ) |
Fill the log with some useful information about the found printer device.
[in] | prn | The USB printer device information |
Give the user a chance to find/install the correct printer driver for this device by providing more useful information about it.
Use the libusb DEVICE ID database ("/usr/share/misc/usb.ids") to output better Vendor and Device information.
Check what the tool 'usb_printerid' is
Avoid duplicate code, refer caps_prn_print_verbose_printer_message() in caps-printer.c
|
static |
Adapt the permissions and owners of the given directory to our needs
[in] | dir | Path to a directory (not(!) a file) to adapt |
0 | On success |
negative | -errno else |
All regular CAPS components should have only read access to all kind of resources in the filesystem Expected here is, we are running as root to be able to change the owner/group of the directory.
|
static |
Create an INI file to define a default name for the new printer device
[in] | usb_prn | Printer device description from the USB point of view |
[in] | dir | Directory name of the driver's run-time parameter directory |
0 | On success |
negative | -errno else |
usb_prn is used to create a useful default name for this new printer device
|
static |
Check if a string does not contain whitespace
[in] | string | String to check for whitespaces |
true | If the string is whitespace less |
false | If the string contains whitespaces |
|
static |
Return something useful to create a directory name for a printer from it
[in] | prn | Printer Device info |
What is a useful name? Hard to say. The product name is to be preferred, because it is the best for the reader. The manufacturer name is also okay, but might be confusing, if more than one printer device of the same manufacturer is/was connected. The IEEE ID is more useful for technicians and the serial number is a pain - but can be some kind of last resourt. And if nothing of this information is available, just the name "printer" helps.
|
static |
Create a printer device unique CAPS Printer Device Parameter Directory in the main CAPS Printer Device Database Directory and return the full path to it
[in] | prn | Printer Device Info |
[out] | param_dir | Full path to the "CAPS Printer Device Parameter Directory" for this printer |
0 | On success (*param_dir is valid) |
negative | Errno code about whats failed (mkdtemp(), chown() and chmod() calls) |
This function will create a directory like: /var/lib/caps/printer_768747
with owner #CAPS_ADMIN_ID and group #CAPS_GROUP_ID and 0755 permission.
*param_dir
needs to be freed after use. int caps_prn_recognize_new_printer_device | ( | const struct usb_printer * | prn, |
struct caps_inif_table * | db | ||
) |
The printer device isn't known yet. Search the printer driver database for a corresponding printer driver.
[in] | prn | The USB printer device information |
[in,out] | db | The current device database to store the new entry to (on demand) |
0 | On success |
negative | Ernno |
If a printer driver is found, create its corresponding Instance's Parameter Directory in the Driver's Configuration Directory, create the file service.ini
with the parameter entry 'name' and a unique name (to be adpated by the user) and add this information beside some other run-time information (like the USB connection to recognize this printer device the next time) to its run-time database.
Think about: We could create everything relevant even for the case no printer driver is installed. We just skip the parameter directory and description INI in this case and stop here. But the run-time database gets updated so we know the printer the next time and amend the missing information when available.