2.7.1.2. cft_GetConfigFileName()

[<<<] [>>>]

This function tries to locate the configuration file. The working of this function is system dependant. There are two different implementations: one for UNIX and one for Win32.

WIN32

On Win32 systems the function tries to read the system registry. The value of the key given in the argument env is used and returned as the config file name. For example if the argument env is Software\myprog\conf then the registry value of the key HKEY_LOCAL_MACHINE\Software\myprog\conf will be returned as configuration file name. The program does not check that the file really exists. It only checks that the registry key exists, it is a string and has some value.

If the registry key does not exists the program tries to locate the system directory getting the environment variable windir, then systemroot and finally taking c:\WINDOWS. The argument DefaultFileName is appended to the directory name and is returned.

UNIX

On UNIX it is more simple. The environment variable env is used as a file name. If this does not exists the DefaultFileName is used and returned.

BOTH

The return value of the function is zero if no error has happened. A pointer to the resulting file name is returned in the variable ppszConfigFile. The space to hold the resulting file name is allocated via the allocation function given by the tConfigTree structure pointed by pCT.

int cft_GetConfigFileName(ptConfigTree pCT,
                          char **ppszConfigFile,
                          char *env,/* environment variable or registry key on win32 */
                          char *DefaultFileName
  )@{
This function is static and can not be called from outside of this module.
[<<<] [>>>]