open_config_file - Opens a configuration file


#include "l/l_config.h"

Example compile flags (system dependent):
   -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


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.


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


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.
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.


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.


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


Kobus Barnard


Kobus Barnard


check_config_sub_dir , read_dbl_from_config_file , get_config_file