CAPS Universe documentation
1.0.4
All you need to know to be successful
|
Some more or less useful helper/convenience functions. More...
Functions | |
char * | caps_helper_config_path_create (const char *file_name) |
int | caps_helper_config_dir_fd (void) |
char * | caps_helper_driver_db_path_create (const char *file_name) |
int | caps_helper_driver_db_dir_fd (void) |
char * | caps_helper_driver_config_path_create (const char *file_name) |
int | caps_helper_driver_config_dir_fd (void) |
char * | caps_helper_driver_path_create (const char *file_name) |
int | caps_helper_driver_dir_fd (void) |
char * | caps_helper_device_db_path_create (const char *file_name) |
int | caps_helper_device_db_dir_fd (void) |
int | caps_helper_number_convert (const char *string) |
int | caps_helper_boolean_check (const char *value, int set) |
int | caps_helper_invisible_file_create (int *fd) |
int | caps_helper_file_content_copy (int fd_to, int fd_from) |
int | caps_helper_verbosity_setup (const char *keyword, bool overwrite) |
Used all over the CAPS universe to avoid re-invention the wheel again and again. Expect the list of these function will grow.
char * caps_helper_config_path_create | ( | const char * | file_name | ) |
Get the CAPS Configuration Directory or a full qualified file name into it
[in] | file_name | The filename to build a full qualified path (can be NULL) |
file_name
to form a full qualified filenameAn example for this directory could be "/etc/caps/"
. If filename in this example is 'foo'
the function returns "/etc/caps/foo"
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_CONFIG_DIR.
int caps_helper_config_dir_fd | ( | void | ) |
Return a file descriptor to the CAPS Configuration Directory
fd | File descriptor of the directory |
negative | Negative errno else |
An example for this directory could be a file descriptor to "/etc/caps/"
.
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_CONFIG_DIR.
The file descriptor is intended to be used with the *at() functions (openat() etc.)
char * caps_helper_driver_db_path_create | ( | const char * | file_name | ) |
Get the CAPS Printer Driver Database Directory or a full qualified file name into it
[in] | file_name | The filename to build a full qualified path (can be NULL) |
file_name
to form a full qualified filenameAn example for this directory could be "/usr/share/caps/drivers"
. If filename in this example is 'foo'
the function returns "/usr/share/caps/drivers/foo"
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_PRINTER_DRIVER_DB_DIR.
int caps_helper_driver_db_dir_fd | ( | void | ) |
Return a file descriptor to the CAPS Printer Driver Database Directory
fd | File descriptor of the directory |
negative | Negative errno else |
An example for this directory could be a file descriptor to "/usr/share/caps/drivers"
.
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_PRINTER_DRIVER_DB_DIR.
The file descriptor is intended to be used with the *at() functions (openat() etc.)
char * caps_helper_driver_config_path_create | ( | const char * | file_name | ) |
Get the CAPS Printer Driver Configuration Directory or a full qualified file name into it
[in] | file_name | The filename to build a full qualified path (can be NULL) |
file_name
to form a full qualified filenameAn example for this directory could be "/etc/caps/drivers"
. If filename in this example is 'foo'
the function returns "/etc/caps/drivers/foo"
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_DRIVER_CONFIGURATION_DIR.
int caps_helper_driver_config_dir_fd | ( | void | ) |
Return a file descriptor to the CAPS Printer Driver Configuration Directory
fd | File descriptor of the directory |
negative | Negative errno else |
An example for this directory could be a file descriptor to "/etc/caps/drivers"
.
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_DRIVER_CONFIGURATION_DIR.
The file descriptor is intended to be used with the *at() functions (openat() etc.)
char * caps_helper_driver_path_create | ( | const char * | file_name | ) |
Get the directory path of the CAPS Printer Driver Executables Directory or a full qualified file name into it
[in] | file_name | The filename to build a fully qualified path (can be NULL) |
file_name
to form a full qualified filenameAn example for this directory could be "/usr/libexec/caps"
. If filename in this example is 'foo'
the function returns "/usr/libexec/caps/foo"
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_DRIVER_DIR.
int caps_helper_driver_dir_fd | ( | void | ) |
Return a file descriptor to the CAPS Printer Driver Executables Directory
fd | File descriptor of the directory |
negative | Negative errno else |
An example for this directory could be a file descriptor to "/usr/libexec/caps"
.
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_DRIVER_DIR.
The file descriptor is intended to be used with the *at() functions (openat() etc.)
char * caps_helper_device_db_path_create | ( | const char * | file_name | ) |
Get the CAPS Printer Device Database Directory or a full qualified file name into it
[in] | file_name | The filename to build a fully qualified path (can be NULL) |
file_name
to form a full qualified filenameAn example for this directory could be "/var/lib/caps"
. If filename in this example is 'foo'
the function returns "/var/lib/caps/foo"
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_PRINTER_DEVICE_DB_DIR.
int caps_helper_device_db_dir_fd | ( | void | ) |
Return a file descriptor to the CAPS Printer Device Database Directory
fd | File descriptor of the directory |
negative | Negative errno else |
An example for this directory could be a file descriptor to "/var/lib/caps"
.
When debugging is enabled it is possible to set a different directory path via the environment variable CAPS_PRINTER_DEVICE_DB_DIR.
The file descriptor is intended to be used with the *at() functions (openat() etc.)
int caps_helper_number_convert | ( | const char * | string | ) |
This function is a try to read-in a positive ASCII number with error checking to avoid bogus values
[in] | string | The ASCII string containing the positive number to convert |
Positive | The number from the ASCII string |
-EINVAL | string doesn't look like an ASCII number |
-ERANGE | string contains an invalid number for an 'int' |
If the string
isn't a valid number, this function already emits a corresponding error message.
int caps_helper_boolean_check | ( | const char * | value, |
int | set | ||
) |
Evaluate a boolean value based on a specific set of words
[in] | value | The text of a boolean value (can be NULL, read below) |
[in] | set | Check for a true or false set of words in value (read below) |
1 | E.g. true, value is part of set |
0 | E.g. false, value isn't part of set |
If set
is true
(e.g. not 0)
true
if value
words like true, on, yes or 1 are used.value
has one of the listed words, 1 is returned, else 0if set
is false
(e.g. 0)
false
if value
words like false, off, no or 0 are used.value
has one of the listed words, 1 is returned, else 0If value
it evaluates to the word set true, on, yes, 1
value
strings are case insensitive. int caps_helper_invisible_file_create | ( | int * | fd | ) |
Create an invisible and self-removing file and return the file descriptor
[out] | fd | Where to store the file descriptor |
0 | On success (*fd is valid) |
-ENOSPC | Out of space in the CAPS Document Storage Directory |
-EACCES | Insufficient directory setup of CAPS Document Storage Directory |
Invisible in this file context means, only a file descriptor is created without a visible directory entry. When the file descriptor is closed, the file's content is automatically removed from the file system.
When debugging is enabled it is possible to set a different directory path via the environment variable DOCUMENT_STORAGE_DIR.
caps_temp_file_XXXXXX
. int caps_helper_file_content_copy | ( | int | fd_to, |
int | fd_from | ||
) |
Copy the content from one file descriptor to a second one
[in] | fd_to | Copy content to this file descriptor |
[in] | fd_from | Copy content from this file descriptor |
0 | On success |
-EBADF | At least on of the file descriptors is/are invalid for this operation |
-EINVAL | The file descriptors point to the same file |
Both file descriptors are not touched after the copy process.
fd_from
file descriptor must be sought to the file's begin. fd_to
file descriptor must have write permission. int caps_helper_verbosity_setup | ( | const char * | keyword, |
bool | overwrite | ||
) |
Setup the verbosity level, based on a keyword
[in] | keyword | Keyword which describes the verbosity level (can be NULL). |
[in] | overwrite | true to set the keyword value, false to only set higher verbosity |
0 | On success |
-EINVAL | If the keyword is invalid |
-ENOTSUP | If 'debug' isn't supported due to built without debugging support |
keyword
is NULL, the function returns immediately with value 0 and the verbosity level isn't changed keyword's
case is ignored.Keywords describing the verbosity level are:
overwrite
is false, a new verbosity value is set only if the currently set value is 'lower'. E.g. if the current setting is LIBCAPS_WARN and you set 'info' it will be set to LIBCAPS_INFO. But if you want to set it to LIBCAPS_ERROR instead, it won't be set.