Mercurial > hg > freeDiameter
comparison freeDiameter/fdd.y @ 304:ad3c46016584
Added install directives for cmake; also allow default directory to seek for extensions and configuration files
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 14 May 2010 17:26:53 +0900 |
parents | 5df55136361b |
children | 5f882de409eb |
comparison
equal
deleted
inserted
replaced
303:32ba9cf7ba87 | 304:ad3c46016584 |
---|---|
306 } | 306 } |
307 ; | 307 ; |
308 | 308 |
309 loadext: LOADEXT '=' QSTRING extconf ';' | 309 loadext: LOADEXT '=' QSTRING extconf ';' |
310 { | 310 { |
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 ), | |
312 { yyerror (&yylloc, conf, "Error adding extension"); YYERROR; } ); | 357 { yyerror (&yylloc, conf, "Error adding extension"); YYERROR; } ); |
313 } | 358 } |
314 ; | 359 ; |
315 | 360 |
316 extconf: /* empty */ | 361 extconf: /* empty */ |