![]() |
![]() |
![]() |
Open a configuration file
#include <cfgopen.h> int cfgopen( const char * path, unsigned flags, const char * historical, char * namebuf, int nblen );
libc
The cfgopen() function opens the configuration file named by path. A cover function for open(), it 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 three values (file access modes) below in the value of flag:
Any combination of these flags may be specified for 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:
$HOME/.cfg/confstr(CS_HOSTNAME)/path
$HOME/.cfg/path
/etc/host_cfg/confstr(CS_HOSTNAME)/path
path
![]() |
If the directory /etc/host_cfg doesn't exist on the system, then the following flags are transformed automatically: CFGFILE_USER_NODE becomes CFGFILE_USER |
When creating a file, or opening a file for writing, only one of the above location flags may be specified. Set CFGFILE_NOFD when only the pathname to be been used is required and an fd isn't. If a directory path doesn't exist when a file is opened for creation, cfgopen() attempts to create the path.
Specifying the following arguments is optional:
A valid fd if CFGFILE_NOFD isn't specified, a nonnegative value if CFGFILE_NOFD is specified, or -1 if an error occurs.
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
mib.txt, snmpd.conf in the Utilities reference
![]() |
![]() |
![]() |