Navigation


Changeset 304:ad3c46016584 in freeDiameter for freeDiameter/fdd.y


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/fdd.y

    r258 r304  
    309309loadext:                LOADEXT '=' QSTRING extconf ';'
    310310                        {
    311                                 CHECK_FCT_DO( fd_ext_add( $3, $4 ),
     311                                char * fname;
     312                                char * cfname;
     313                                FILE * fd;
     314                               
     315                                /* Try and open the extension file */
     316                                fname = $3;
     317                                fd = fopen(fname, "r");
     318                                if ((fd == NULL) && (*fname != '/')) {
     319                                        char * bkp = fname;
     320                                        CHECK_MALLOC_DO( fname = malloc( strlen(bkp) + strlen(DEFAULT_EXTENSIONS_PATH) + 2 ),
     321                                                { yyerror (&yylloc, conf, "Not enough memory"); YYERROR; } );
     322                                        sprintf(fname, DEFAULT_EXTENSIONS_PATH "/%s", bkp);
     323                                        free(bkp);
     324                                        fd = fopen(fname, "r");
     325                                }
     326                                if (fd == NULL) {
     327                                        int ret = errno;
     328                                        TRACE_DEBUG(INFO, "Unable to open extension file %s for reading: %s\n", fname, strerror(ret));
     329                                        yyerror (&yylloc, conf, "Error adding extension");
     330                                        YYERROR;
     331                                }
     332                                fclose(fd);
     333                               
     334                                /* Try and open the configuration file (optional) */
     335                                cfname = $4;
     336                                if (cfname) {
     337                                        fd = fopen(cfname, "r");
     338                                        if ((fd == NULL) && (*cfname != '/')) {
     339                                                char * test;
     340                                                CHECK_MALLOC_DO( test = malloc( strlen(cfname) + strlen(DEFAULT_CONF_PATH) + 2 ),
     341                                                        { yyerror (&yylloc, conf, "Not enough memory"); YYERROR; } );
     342                                                sprintf(test, DEFAULT_CONF_PATH "/%s", cfname);
     343                                                fd = fopen(test, "r");
     344                                                if (fd) {
     345                                                        free(cfname);
     346                                                        cfname=test;
     347                                                } else {
     348                                                        /* This is not an error, we allow an extension to wait for something else than a real conf file. */
     349                                                        free(test);
     350                                                }
     351                                        }
     352                                        if (fd)
     353                                                fclose(fd);
     354                                }
     355                               
     356                                CHECK_FCT_DO( fd_ext_add( fname, cfname ),
    312357                                        { yyerror (&yylloc, conf, "Error adding extension"); YYERROR; } );
    313358                        }
Note: See TracChangeset for help on using the changeset viewer.