Navigation


Changeset 947:cce5d4bace82 in freeDiameter


Ignore:
Timestamp:
Feb 13, 2013, 10:47:47 PM (11 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

Make config file parameter const and convert another fprintf to TRACE_DEBUG_ERROR.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdcore.h

    r904 r947  
    8787
    8888/* Parse the freeDiameter.conf configuration file, load the extensions */
    89 int fd_core_parseconf(char * conffile);
     89int fd_core_parseconf(const char * conffile);
    9090
    9191/* Start the server & client threads */
     
    111111        int              cnf_eyec;      /* Eye catcher: EYEC_CONFIG */
    112112       
    113         char            *cnf_file;      /* Configuration file to parse, default is DEFAULT_CONF_FILE */
     113        const char      *cnf_file;      /* Configuration file to parse, default is DEFAULT_CONF_FILE */
    114114       
    115115        DiamId_t         cnf_diamid;    /* Diameter Identity of the local peer (FQDN -- ASCII) */
     
    350350 *    ENOMEM    : Memory allocation for the new object element failed.)
    351351 */
    352 int fd_peer_add ( struct peer_info * info, char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data );
     352int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data );
    353353
    354354/*
  • libfdcore/config.c

    r946 r947  
    230230{
    231231        extern FILE * fddin;
    232         char * orig = NULL;
     232        const char * orig = NULL;
    233233       
    234234        /* Attempt to find the configuration file */
     
    238238        fddin = fopen(fd_g_config->cnf_file, "r");
    239239        if ((fddin == NULL) && (*fd_g_config->cnf_file != '/')) {
     240                char * new_cnf = NULL;
    240241                /* We got a relative path, attempt to add the default directory prefix */
    241242                orig = fd_g_config->cnf_file;
    242                 CHECK_MALLOC( fd_g_config->cnf_file = malloc(strlen(orig) + strlen(DEFAULT_CONF_PATH) + 2) ); /* we will not free it, but not important */
    243                 sprintf( fd_g_config->cnf_file, DEFAULT_CONF_PATH "/%s", orig );
     243                CHECK_MALLOC( new_cnf = malloc(strlen(orig) + strlen(DEFAULT_CONF_PATH) + 2) ); /* we will not free it, but not important */
     244                sprintf( new_cnf, DEFAULT_CONF_PATH "/%s", orig );
     245                fd_g_config->cnf_file = new_cnf;
    244246                fddin = fopen(fd_g_config->cnf_file, "r");
    245247        }
    246248        if (fddin == NULL) {
    247249                int ret = errno;
    248                 if (orig) {
    249                         fprintf(stderr, "Unable to open configuration file for reading\n"
    250                                         "Tried the following locations:\n"
    251                                         " - %s\n"
    252                                         " - %s\n"
    253                                         "Error: %s\n", orig, fd_g_config->cnf_file, strerror(ret));
    254                 } else {
    255                         fprintf(stderr, "Unable to open '%s' for reading: %s\n", fd_g_config->cnf_file, strerror(ret));
    256                 }
     250                TRACE_DEBUG_ERROR("Unable to open configuration file for reading; tried the following locations: %s%s%s; Error: %s\n",
     251                                  orig ?: "", orig? " and " : "", fd_g_config->cnf_file, strerror(ret));
    257252                return ret;
    258253        }
  • libfdcore/core.c

    r908 r947  
    226226
    227227/* Parse the freeDiameter.conf configuration file, load the extensions */
    228 int fd_core_parseconf(char * conffile)
     228int fd_core_parseconf(const char * conffile)
    229229{
    230230        TRACE_ENTRY("%p", conffile);
  • libfdcore/peers.c

    r908 r947  
    9191
    9292/* Add a new peer entry */
    93 int fd_peer_add ( struct peer_info * info, char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )
     93int fd_peer_add ( struct peer_info * info, const char * orig_dbg, void (*cb)(struct peer_info *, void *), void * cb_data )
    9494{
    9595        struct fd_peer *p = NULL;
Note: See TracChangeset for help on using the changeset viewer.