kpathsea: Programming with config files
7.4 Programming with config files
=================================
You can (and probably should) use the same 'texmf.cnf' configuration
file that Kpathsea uses for your program. This helps installers by
keeping all configuration in one place.
To retrieve a value for a configuration variable VAR, the best way is
to call 'kpathsea_var_value' on the string 'VAR'. This will look first
for an environment variable VAR, then a config file value. The result
will be the value found or 'NULL'. This function is declared in
'kpathsea/variable.h'. For an example, see the 'shell_escape' code in
'web2c/lib/texmfmp.c'.
The routine to do full variable and tilde expansion of an arbitrary
string in the context of a search path (as opposed to simply retrieving
a value) is 'kpathsea_var_expand', also declared in
'kpathsea/variable.h'. However, it's generally only necessary to set
the search path structure components as explained in the previous
section instead of using this directly. Because of its usage with any
input string, undefined '$FOO' constructs in the argument to
'kpathsea_var_expand' are returned literally ('"$FOO"'), while undefined
'${FOO}' constructs are expanded to the empty string.
If for some reason you want to retrieve a value _only_ from a config
file, not automatically looking for a corresponding environment
variable, call 'kpathsea_cnf_get' (declared in 'kpathsea/cnf.h') with
the string VAR.
No initialization calls are needed.