Navigation


Changeset 304:ad3c46016584 in freeDiameter for freeDiameter/config.c


Ignore:
Timestamp:
May 14, 2010, 5:26:53 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added install directives for cmake; also allow default directory to seek for extensions and configuration files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/config.c

    r258 r304  
    3535
    3636#include "fD.h"
     37#include <sys/stat.h>
    3738
    3839/* Configuration management */
     
    5152       
    5253        fd_g_config->cnf_eyec = EYEC_CONFIG;
    53         fd_g_config->cnf_file = DEFAULT_CONF_FILE;
    5454       
    5555        fd_g_config->cnf_timer_tc = 30;
     
    145145        extern FILE * fddin;
    146146       
    147         TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->cnf_file);
     147        /* Attempt to find the configuration file */
     148        if (!fd_g_config->cnf_file)
     149                fd_g_config->cnf_file = FD_DEFAULT_CONF_FILENAME;
    148150       
    149151        fddin = fopen(fd_g_config->cnf_file, "r");
     152        if ((fddin == NULL) && (*fd_g_config->cnf_file != '/')) {
     153                /* We got a relative path, attempt to add the default directory prefix */
     154                char * bkp = fd_g_config->cnf_file;
     155                CHECK_MALLOC( fd_g_config->cnf_file = malloc(strlen(bkp) + strlen(DEFAULT_CONF_PATH) + 2) ); /* we will not free it, but not important */
     156                sprintf( fd_g_config->cnf_file, DEFAULT_CONF_PATH "/%s", bkp );
     157                fddin = fopen(fd_g_config->cnf_file, "r");
     158        }
    150159        if (fddin == NULL) {
    151160                int ret = errno;
     
    155164       
    156165        /* call yacc parser */
     166        TRACE_DEBUG (FULL, "Parsing configuration file: %s", fd_g_config->cnf_file);
    157167        CHECK_FCT(  fddparse(fd_g_config)  );
    158168       
Note: See TracChangeset for help on using the changeset viewer.