This provides a way for an application or library to manage its installation directories. Prefix substitutions are handled by allowing each directory to refer to any of the others as its prefix.
A C source file which defines cu_installdirs_t with preliminary initialisation for a package is generated by invoking the Autoconf macro
CUAC_CONFIG_INSTALLDIRS(foo_installdirs.c, foo_installdirs)
Then foo_installdirs can be used as
#include <cu/installdirs.h> extern struct cu_installdirs foo_installdirs; void foo_init(void) { // ... cu_installdirs_finish(&foo_installdirs); // ... } char const *foo_get_installdir(cu_installdir_key_t key) { return foo_installdirs[key].dir; }
| typedef struct cu_installdirs* cu_installdirs_t |
An array describing the installation directories of a package.
| enum cu_installdir_key_t |
A reference to one of the installation directories in cu_installdirs_t. In the following, typical values for a prefix of /usr are shown in paretheses.
| void cu_installdirs_dump | ( | cu_installdirs_t | installdirs | ) |
Prints out installdirs.
| void cu_installdirs_finish | ( | cu_installdirs_t | installdirs | ) |
Completes the dir fields of the application's installation directory mapping, assuming the first two components have been initialised. This function is typically called during program initialisation.
| char const* cu_installdirs_get | ( | cu_installdirs_t | installdirs, | |
| cu_installdir_key_t | key | |||
| ) |
Return the directory identified by key from installdirs.
| void cu_installdirs_set | ( | cu_installdirs_t | installdirs, | |
| cu_installdir_key_t | key, | |||
| char const * | dir | |||
| ) |
Set the installation directory indicated by key to dir. The directory may be a prefix for other directories, in which case cu_installdirs_finish will substitute it. This function must be called before cu_installdirs_finish.
| void cu_installdirs_set_byenv | ( | cu_installdirs_t | installdirs, | |
| char const * | var_prefix | |||
| ) |
Set installdirs according to environment variables named var_prefix followed by the common installation directory names. If var_prefix starts with an uppercase, the directory names are uppercased as well. E.g. calling cu_installdirs_set_byenv(&mydirs, "MYAPP_") will pick up $MYAPP_PREFIX, $MYAPP_EXEC_PREFIX, $MYAPP_SYSCONFDIR, etc. This function must be called before cu_installdirs_finish.
| cu_bool_t cu_installdirs_set_byname | ( | cu_installdirs_t | installdirs, | |
| char const * | name, | |||
| char const * | dir | |||
| ) |
If found, sets the configuration directory named name in lowercase to dir and returns true, else returns false. This function must be called before cu_installdirs_finish.
| char const* cuconf_get_installdir | ( | cu_installdir_key_t | key | ) |
The culibs installation directory key.