Open a configuration file
#include <cfgopen.h> int cfgopen( const char * path, unsigned flags, const char * historical, char * namebuf, int nblen );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
|This function is in libc.a, but not in libc.so (in order to save space).|
The cfgopen() function opens the configuration file named by path. This function is a cover function for open() that searches several default system locations for your files, based on specified characteristics.
The value of flags correspond to, and have similar limitations of, the standard open() flags. The flags value is constructed by the bitwise ORing of values from the following list, defined in the <cfgopen.h> header file. Applications must specify exactly one of these file-access modes in the value of flag:
You can also include any combination of these bits in the value of flag:
In order to hint to the function where it should access or construct (in the case of CFGFILE_CREAT) path, there are several bits that you can specify and OR into flags. When specified, the bits are accessed using the following search order:
where node_name is the value you get by calling confstr() for CS_HOSTNAME.
|If the directory /etc/host_cfg doesn't exist on the system,
the following flags are transformed automatically:
When creating a file or opening a file for writing, you can specify only one of the above location flags. Set CFGFILE_NOFD when you need only the pathname, not the file descriptor. If a directory path doesn't exist when a file is opened for creation, cfgopen() attempts to create the path.
A valid file descriptor if CFGFILE_NOFD isn't specified, a nonnegative value if CFGFILE_NOFD is specified, or -1 if an error occurs.
confstr(), fcfgopen(), open()
mib.txt, snmpd.conf in the Utilities Reference