[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    cfp_file(3) manual page Table of Contents

Name

cfp_file - find a configuration file

Synopsis


#include <cfht/cfht.h>#include <cfht/cfp.h>char *cfp_file(dest, name, suff, mode)char
*dest;char *name;char *suff;char *mode;
libcfht.a

Description

The purpose of this function is to find a configuration file by looking in standard places with standard precedence rules.

Dest is the place where the path name to the found file will be placed. If dest is NULL, then library internal space will be used. Name is the simple name of the file. Suff will be appended onto name to get the true file name. NULL is allowed for suff. The created name will be getenv()’ed for possible overrides. Mode is an access specification string such as "rw" or "r".

The current directory is checked first. If the file is there, but not accessible with the specified mode, an error will occur. The $HOME environment variable is checked next. For this check a ".," will be prepended to the file name. This allows all configuration files to be hidden and easily pattern matched. If the file is there, but not accessible with the specified mode, an error will occur. The $CFHTCONFPATH environment variable is checked last. (Programmers can get the name of the variable by using the CFHT_ECONFPATH define.) $CFHTCONFPATH should specify a directory name. If the file is found in the $CFHTCONFPATH directory, and writing is desired as specified by mode, the file will be copied to the $HOME directory (with ".," prepended), and the path to the $HOME file will be returned. If the file is found in the $CFHTCONFPATH directory, and writing is not desired as specified by mode, then the path to the $CFHTCONFPATH file will be returned. The name of the system default directory for configuration files can be found by using the CFHT_CONFPATH define.

Actually one further place is checked. If the file is not in the configuration directory, "../../conf" from the configuration directory is checked. This is a global, release independent directory, for things such as the odometer file and ioconfig file.

Return Value

The return value is a pointer to the path. If an error occurs, then NULL will be returned.

Errors

Possible errors for cfp_file:
[ENOENT]
The file was not found anywhere.
[EACCES]
The file is not accessible with the specified modes.

Environment Variables

$HOME
Used during search.
$CFHTCONFPATH
Override directory for configuration files. Should end in ’/’.

Files

$cfhtdir/base/conf
Default directory for system default configuration files.

See Also

cfp(4) .

Warnings

If NULL is used as a destination, future calls will overwrite past paths. Also, other CFHT library routines use this feature when calling cfp_file().


Table of Contents