721 |
} |
} |
722 |
| expr |
| expr |
723 |
{ |
{ |
724 |
FUNCTION main; |
FUNCTION fmain; |
725 |
|
|
726 |
if (errcnt) { |
if (errcnt) { |
727 |
YYERROR; |
YYERROR; |
729 |
|
|
730 |
mtx_return($1); |
mtx_return($1); |
731 |
|
|
732 |
memset(&main, 0, sizeof(main)); |
memset(&fmain, 0, sizeof(fmain)); |
733 |
main.name = "main"; |
fmain.name = "main"; |
734 |
main.rettype = return_type = $1->gen.datatype; |
fmain.rettype = return_type = $1->gen.datatype; |
735 |
function = &main; |
function = &fmain; |
736 |
|
|
737 |
if (optimize() == 0) { |
if (optimize() == 0) { |
738 |
codegen(); |
codegen(); |
1433 |
{ |
{ |
1434 |
int c; |
int c; |
1435 |
int base; |
int base; |
1436 |
|
int res; |
1437 |
|
|
1438 |
c = yychar; |
c = yychar; |
1439 |
if (c == '0') { |
if (c == '0') { |
1440 |
if (input() == 'x' || yychar == 'X') { |
if (input() == 'x' || yychar == 'X') { |
1445 |
} |
} |
1446 |
} else |
} else |
1447 |
base = 10; |
base = 10; |
1448 |
|
|
1449 |
return read_num(c2d(c), base); |
res = read_num(c2d(c), base); |
1450 |
|
if (base == 10 && yychar == '.') { |
1451 |
|
int n; |
1452 |
|
|
1453 |
|
for (n = 0; n < 3 && yychar == '.'; n++) { |
1454 |
|
int val; |
1455 |
|
|
1456 |
|
input(); |
1457 |
|
val = read_num(0, base); |
1458 |
|
res = (res << 8) + val; |
1459 |
|
} |
1460 |
|
if (n != 3) |
1461 |
|
res <<= 8 * (3-n); |
1462 |
|
} |
1463 |
|
return res; |
1464 |
} |
} |
1465 |
|
|
1466 |
int |
int |
5341 |
char * |
char * |
5342 |
rewrite_compile(char *expr) |
rewrite_compile(char *expr) |
5343 |
{ |
{ |
|
pctr_t save_pc = rw_pc; |
|
5344 |
int rc; |
int rc; |
5345 |
FUNCTION *fun; |
FUNCTION *fun; |
5346 |
char *name; |
char *name = emalloc(strlen(expr) + 3); |
5347 |
|
|
5348 |
asprintf(&name, "$%s$", expr); |
sprintf(name, "$%s$", expr); |
5349 |
fun = (FUNCTION*) sym_lookup(rewrite_tab, name); |
fun = (FUNCTION*) sym_lookup(rewrite_tab, name); |
5350 |
if (fun) { |
if (!fun) { |
5351 |
free(name); |
rc = parse_rewrite_string(expr); |
5352 |
return fun->name; |
if (rc) { |
5353 |
|
efree(name); |
5354 |
|
return NULL; |
5355 |
|
} |
5356 |
|
function->name = name; |
5357 |
|
function_install(function); |
5358 |
} |
} |
|
|
|
|
rc = parse_rewrite_string(expr); |
|
|
if (rc) |
|
|
return NULL; |
|
|
function->name = name; |
|
|
function_install(function); |
|
5359 |
return name; |
return name; |
5360 |
} |
} |
5361 |
|
|
5473 |
free_path(void *item, void *data ARG_UNUSED) |
free_path(void *item, void *data ARG_UNUSED) |
5474 |
{ |
{ |
5475 |
efree(item); |
efree(item); |
5476 |
|
return 0; |
5477 |
} |
} |
5478 |
|
|
5479 |
static RAD_LIST *source_candidate_list; /* List of modules that are to |
static RAD_LIST *source_candidate_list; /* List of modules that are to |
5549 |
return 0; |
return 0; |
5550 |
} |
} |
5551 |
|
|
5552 |
static void |
void |
5553 |
rewrite_after_config_hook(void *a ARG_UNUSED, void *b ARG_UNUSED) |
rewrite_load_all(void *a ARG_UNUSED, void *b ARG_UNUSED) |
5554 |
{ |
{ |
5555 |
|
if (!source_candidate_list) |
5556 |
|
return; |
5557 |
|
|
5558 |
/* For compatibility with previous versions load the |
/* For compatibility with previous versions load the |
5559 |
file $radius_dir/rewrite, if no explicit "load" statements |
file $radius_dir/rewrite, if no explicit "load" statements |
5560 |
were given */ |
were given */ |
5562 |
rewrite_load_module("rewrite"); |
rewrite_load_module("rewrite"); |
5563 |
|
|
5564 |
list_iterate(source_candidate_list, _load_module, NULL); |
list_iterate(source_candidate_list, _load_module, NULL); |
|
list_destroy(&source_candidate_list, free_path, NULL); |
|
5565 |
#if defined(MAINTAINER_MODE) |
#if defined(MAINTAINER_MODE) |
5566 |
if (debug_on(100)) |
if (debug_on(100)) |
5567 |
debug_dump_code(); |
debug_dump_code(); |
5574 |
rewrite_tab = symtab_create(sizeof(FUNCTION), function_free); |
rewrite_tab = symtab_create(sizeof(FUNCTION), function_free); |
5575 |
code_init(); |
code_init(); |
5576 |
radiusd_set_preconfig_hook(rewrite_before_config_hook, NULL, 0); |
radiusd_set_preconfig_hook(rewrite_before_config_hook, NULL, 0); |
|
radiusd_set_postconfig_hook(rewrite_after_config_hook, NULL, 0); |
|
5577 |
} |
} |
5578 |
|
|
5579 |
|
|