NAME

open_config_file - Opens a configuration file

SYNOPSIS

#include "l/l_config.h"

Example compile flags (system dependent):
  -DLINUX_X86_64 -DLINUX_X86_64_OPTERON  -DGNU_COMPILER 
   -I/home/kobus/include
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 


FILE *open_config_file
(
	const char *env_var,
	const char *sub_dir,
	const char *file_name,
	const char *message_name
);

DESCRIPTION

This routine opens a configuration file, checking several possible locations for the file. If the parameter "env_var" is not NULL, then it first tries using this string as the configuration file name. Next it looks for "file_name" in the current directory. Then it looks in the user's home directory, and the a number of other locations (e.g., /work, /data, /space) using the user id as a subdirectory. . Then it does the same based on a compiled in shared login id (if different), and then it does the same for the programmers login (if different from the preceeding two). If the sub_dir argument is not NULL, then it is used as a sub-directory in all paths except the in the env_var parameter and the current directory.

RETURNS

Either NO_ERROR, or ERROR, with an appropriate error message being set.

EXAMPLE

Suppose sub_dir is "x" and file_name is "y". Suppose the user is "alice". Also supposed that the shared directory is "~vision" (compiled in constant) and the programmer's directory is "~kobus" (another compiled in constant). Finally, suppose that /work, /data, and /space are the current compiled in locations for user space that might contain configuration files. Then the following files are tried in the order listed.
            ./y
            ~/x/y
            /work/alice/x/y
            /data/alice/x/y
            /space/alice/x/y
            ~vision/x/y
            /work/vision/x/y
            /data/vision/x/y
            /space/vision/x/y
            ~kobus/x/y
            /work/kobus/x/y
            /data/kobus/x/y
            /space/kobus/x/y
The paramter message_name can be used to specify a name for the configuration file to be used in composing an error message. Otherwise "configuration" is used.

NOTE

This routine looks in a lot of places. It is not clear if looking in /work, etc., is helpful. It was developed in a different environment. A lot of the issues have changed. Hence it is possible that the directories will change.

DISCLAIMER

This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.

AUTHOR

Kobus Barnard

DOCUMENTER

Kobus Barnard

SEE ALSO

check_config_sub_dir , read_dbl_from_config_file , get_config_file