1 |
%{ |
%{ |
2 |
/* This file is part of GNU RADIUS. |
/* This file is part of GNU Radius. |
3 |
Copyright (C) 2000,2001 Sergey Poznyakoff |
Copyright (C) 2000,2001,2002,2003 Sergey Poznyakoff |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
GNU Radius is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
8 |
(at your option) any later version. |
(at your option) any later version. |
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
GNU Radius is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
GNU General Public License for more details. |
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software Foundation, |
along with GNU Radius; if not, write to the Free Software Foundation, |
17 |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
18 |
|
|
19 |
#define RADIUS_MODULE_REWRITE_Y |
#define RADIUS_MODULE_REWRITE_Y |
36 |
# include <radscm.h> |
# include <radscm.h> |
37 |
#endif |
#endif |
38 |
|
|
|
#ifndef lint |
|
|
static char rcsid[] = |
|
|
"@(#) $Id$"; |
|
|
#endif |
|
|
|
|
39 |
typedef long RWSTYPE; |
typedef long RWSTYPE; |
40 |
|
|
41 |
/* |
/* |
1204 |
%% |
%% |
1205 |
|
|
1206 |
int |
int |
1207 |
yyerror(s) |
yyerror(char *s) |
|
char *s; |
|
1208 |
{ |
{ |
1209 |
radlog(L_ERR, "%s:%d: %s", |
radlog(L_ERR, "%s:%d: %s", |
1210 |
input_filename, input_line, s); |
input_filename, input_line, s); |
1215 |
* Interface functions |
* Interface functions |
1216 |
*/ |
*/ |
1217 |
int |
int |
1218 |
parse_rewrite(path) |
parse_rewrite(char *path) |
|
char *path; |
|
1219 |
{ |
{ |
1220 |
input_filename = path; |
input_filename = path; |
1221 |
infile = fopen(input_filename, "r"); |
infile = fopen(input_filename, "r"); |
1300 |
* greater than any number base allowed. |
* greater than any number base allowed. |
1301 |
*/ |
*/ |
1302 |
int |
int |
1303 |
c2d(c) |
c2d(int c) |
|
int c; |
|
1304 |
{ |
{ |
1305 |
switch (c) { |
switch (c) { |
1306 |
case '0': |
case '0': |
1356 |
} |
} |
1357 |
|
|
1358 |
int |
int |
1359 |
read_num(n, base) |
read_num(int n, int base) |
|
int n; |
|
|
int base; |
|
1360 |
{ |
{ |
1361 |
int d; |
int d; |
1362 |
|
|
1419 |
* Read everything up to the given delimiter |
* Read everything up to the given delimiter |
1420 |
*/ |
*/ |
1421 |
char * |
char * |
1422 |
read_to_delim(c) |
read_to_delim(int c) |
|
int c; |
|
1423 |
{ |
{ |
1424 |
while (input() && yychar != c) |
while (input() && yychar != c) |
1425 |
obstack_1grow(&input_stk, yychar); |
obstack_1grow(&input_stk, yychar); |
1436 |
* Read identifier |
* Read identifier |
1437 |
*/ |
*/ |
1438 |
char * |
char * |
1439 |
read_ident(c) |
read_ident(int c) |
|
int c; |
|
1440 |
{ |
{ |
1441 |
obstack_1grow(&input_stk, c); |
obstack_1grow(&input_stk, c); |
1442 |
while (input() && isword(yychar)) |
while (input() && isword(yychar)) |
1759 |
} |
} |
1760 |
|
|
1761 |
RWLIST * |
RWLIST * |
1762 |
_list_insert(first, last, prev, obj, before) |
_list_insert(RWLIST **first, RWLIST **last, RWLIST *prev, RWLIST *obj, |
1763 |
RWLIST **first, **last, *prev, *obj; |
int before) |
|
int before; |
|
1764 |
{ |
{ |
1765 |
RWLIST *next; |
RWLIST *next; |
1766 |
|
|
1803 |
} |
} |
1804 |
|
|
1805 |
RWLIST * |
RWLIST * |
1806 |
_list_remove(first, last, obj) |
_list_remove(RWLIST **first, RWLIST **last, RWLIST *obj) |
|
RWLIST **first, **last, *obj; |
|
1807 |
{ |
{ |
1808 |
RWLIST *temp; |
RWLIST *temp; |
1809 |
|
|
1831 |
|
|
1832 |
|
|
1833 |
void * |
void * |
1834 |
obj_alloc(bucket) |
obj_alloc(OBUCKET *bucket) |
|
OBUCKET *bucket; |
|
1835 |
{ |
{ |
1836 |
OBJECT *optr; |
OBJECT *optr; |
1837 |
|
|
1844 |
} |
} |
1845 |
|
|
1846 |
void |
void |
1847 |
obj_free_all(bucket) |
obj_free_all(OBUCKET *bucket) |
|
OBUCKET *bucket; |
|
1848 |
{ |
{ |
1849 |
OBJECT *obj, *next; |
OBJECT *obj, *next; |
1850 |
|
|
1945 |
|
|
1946 |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
1947 |
void |
void |
1948 |
loop_push(mtx) |
loop_push(MTX *mtx) |
|
MTX *mtx; |
|
1949 |
{ |
{ |
1950 |
LOOP *this_loop = obj_alloc(&loop_bkt); |
LOOP *this_loop = obj_alloc(&loop_bkt); |
1951 |
list_append(&loop_first, &loop_last, this_loop); |
list_append(&loop_first, &loop_last, this_loop); |
1958 |
} |
} |
1959 |
|
|
1960 |
void |
void |
1961 |
loop_fixup(list, target) |
loop_fixup(JUMP_MTX *list, MTX *target) |
|
JUMP_MTX *list; |
|
|
MTX *target; |
|
1962 |
{ |
{ |
1963 |
JUMP_MTX *jp; |
JUMP_MTX *jp; |
1964 |
|
|
1979 |
} |
} |
1980 |
|
|
1981 |
VAR * |
VAR * |
1982 |
var_alloc(type, name, grow) |
var_alloc(Datatype type, char *name, int grow) |
|
Datatype type; |
|
|
char *name; |
|
|
int grow; |
|
1983 |
{ |
{ |
1984 |
VAR *var; |
VAR *var; |
1985 |
|
|
2019 |
} |
} |
2020 |
|
|
2021 |
void |
void |
2022 |
var_type(type, var) |
var_type(Datatype type, VAR *var) |
|
Datatype type; |
|
|
VAR *var; |
|
2023 |
{ |
{ |
2024 |
for (; var; var = var->dcllink) |
for (; var; var = var->dcllink) |
2025 |
var->datatype = type; |
var->datatype = type; |
2033 |
} |
} |
2034 |
|
|
2035 |
VAR * |
VAR * |
2036 |
var_lookup(name) |
var_lookup(char *name) |
|
char *name; |
|
2037 |
{ |
{ |
2038 |
VAR *var; |
VAR *var; |
2039 |
|
|
2058 |
#define mtx_append(mtx) list_append(&mtx_first, &mtx_last, mtx) |
#define mtx_append(mtx) list_append(&mtx_first, &mtx_last, mtx) |
2059 |
|
|
2060 |
void |
void |
2061 |
mtx_insert(prev, mtx) |
mtx_insert(MTX *prev, MTX *mtx) |
|
MTX *prev, *mtx; |
|
2062 |
{ |
{ |
2063 |
MTX *up; |
MTX *up; |
2064 |
|
|
2112 |
} |
} |
2113 |
|
|
2114 |
MTX * |
MTX * |
2115 |
mtx_frame(type, stksize) |
mtx_frame(Mtxtype type, stkoff_t stksize) |
|
Mtxtype type; |
|
|
stkoff_t stksize; |
|
2116 |
{ |
{ |
2117 |
FRAME_MTX *mtx = (FRAME_MTX *)mtx_alloc(type); |
FRAME_MTX *mtx = (FRAME_MTX *)mtx_alloc(type); |
2118 |
mtx_append(mtx); |
mtx_append(mtx); |
2154 |
|
|
2155 |
|
|
2156 |
MTX * |
MTX * |
2157 |
mtx_return(arg) |
mtx_return(MTX *arg) |
|
MTX *arg; |
|
2158 |
{ |
{ |
2159 |
MTX *mtx = mtx_alloc(Return); |
MTX *mtx = mtx_alloc(Return); |
2160 |
|
|
2168 |
* Allocate a matrix of given type and append it to the list |
* Allocate a matrix of given type and append it to the list |
2169 |
*/ |
*/ |
2170 |
MTX * |
MTX * |
2171 |
mtx_alloc(type) |
mtx_alloc(Mtxtype type) |
|
Mtxtype type; |
|
2172 |
{ |
{ |
2173 |
MTX *mtx = obj_alloc(&mtx_bucket); |
MTX *mtx = obj_alloc(&mtx_bucket); |
2174 |
|
|
2184 |
* Create a Constant matrix |
* Create a Constant matrix |
2185 |
*/ |
*/ |
2186 |
MTX * |
MTX * |
2187 |
mtx_const(type, data) |
mtx_const(Datatype type, void *data) |
|
Datatype type; |
|
|
void *data; |
|
2188 |
{ |
{ |
2189 |
CONST_MTX *mtx = (CONST_MTX *)mtx_alloc(Constant); |
CONST_MTX *mtx = (CONST_MTX *)mtx_alloc(Constant); |
2190 |
|
|
2204 |
* Create a Reference matrix |
* Create a Reference matrix |
2205 |
*/ |
*/ |
2206 |
MTX * |
MTX * |
2207 |
mtx_ref(num) |
mtx_ref(int num) |
|
int num; |
|
2208 |
{ |
{ |
2209 |
MATCHREF_MTX *mtx = (MATCHREF_MTX*)mtx_alloc(Matchref); |
MATCHREF_MTX *mtx = (MATCHREF_MTX*)mtx_alloc(Matchref); |
2210 |
mtx_append(mtx); |
mtx_append(mtx); |
2214 |
} |
} |
2215 |
|
|
2216 |
MTX * |
MTX * |
2217 |
mtx_var(var) |
mtx_var(VAR *var) |
|
VAR *var; |
|
2218 |
{ |
{ |
2219 |
VAR_MTX *mtx = (VAR_MTX*)mtx_alloc(Variable); |
VAR_MTX *mtx = (VAR_MTX*)mtx_alloc(Variable); |
2220 |
mtx_append(mtx); |
mtx_append(mtx); |
2224 |
} |
} |
2225 |
|
|
2226 |
MTX * |
MTX * |
2227 |
mtx_asgn(var, arg) |
mtx_asgn(VAR *var, MTX *arg) |
|
VAR *var; |
|
|
MTX *arg; |
|
2228 |
{ |
{ |
2229 |
ASGN_MTX *mtx = (ASGN_MTX*)mtx_alloc(Asgn); |
ASGN_MTX *mtx = (ASGN_MTX*)mtx_alloc(Asgn); |
2230 |
|
|
2239 |
|
|
2240 |
|
|
2241 |
Datatype |
Datatype |
2242 |
attr_datatype(type) |
attr_datatype(int type) |
|
int type; |
|
2243 |
{ |
{ |
2244 |
switch (type) { |
switch (type) { |
2245 |
case TYPE_STRING: |
case TYPE_STRING: |
2255 |
} |
} |
2256 |
|
|
2257 |
MTX * |
MTX * |
2258 |
mtx_attr(attr, index) |
mtx_attr(DICT_ATTR *attr, MTX *index) |
|
DICT_ATTR *attr; |
|
|
MTX *index; |
|
2259 |
{ |
{ |
2260 |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr); |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr); |
2261 |
mtx_append(mtx); |
mtx_append(mtx); |
2266 |
} |
} |
2267 |
|
|
2268 |
MTX * |
MTX * |
2269 |
mtx_attr_check(attr, index) |
mtx_attr_check(DICT_ATTR *attr, MTX *index) |
|
DICT_ATTR *attr; |
|
|
MTX *index; |
|
2270 |
{ |
{ |
2271 |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr_check); |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr_check); |
2272 |
mtx_append(mtx); |
mtx_append(mtx); |
2278 |
|
|
2279 |
|
|
2280 |
void |
void |
2281 |
rw_coercion_warning (from, to, pref) |
rw_coercion_warning(Datatype from, Datatype to, char *pref) |
|
Datatype from; |
|
|
Datatype to; |
|
|
char *pref; |
|
2282 |
{ |
{ |
2283 |
radlog(L_WARN, |
radlog(L_WARN, |
2284 |
_("%s:%d: %s implicit %s %s coercion"), |
_("%s:%d: %s implicit %s %s coercion"), |
2290 |
|
|
2291 |
|
|
2292 |
MTX * |
MTX * |
2293 |
mtx_attr_asgn(attr, index, rval) |
mtx_attr_asgn(DICT_ATTR *attr, MTX *index, MTX *rval) |
|
DICT_ATTR *attr; |
|
|
MTX *index; |
|
|
MTX *rval; |
|
2294 |
{ |
{ |
2295 |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr_asgn); |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr_asgn); |
2296 |
mtx_append(mtx); |
mtx_append(mtx); |
2306 |
} |
} |
2307 |
|
|
2308 |
MTX * |
MTX * |
2309 |
mtx_attr_delete(attr, index) |
mtx_attr_delete(DICT_ATTR *attr, MTX *index) |
|
DICT_ATTR *attr; |
|
|
MTX *index; |
|
2310 |
{ |
{ |
2311 |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr_delete); |
ATTR_MTX *mtx = (ATTR_MTX*)mtx_alloc(Attr_delete); |
2312 |
mtx_append(mtx); |
mtx_append(mtx); |
2317 |
} |
} |
2318 |
|
|
2319 |
MTX * |
MTX * |
2320 |
mtx_bin(opcode, arg1, arg2) |
mtx_bin(Bopcode opcode, MTX *arg1, MTX *arg2) |
|
Bopcode opcode; |
|
|
MTX *arg1, *arg2; |
|
2321 |
{ |
{ |
2322 |
BIN_MTX *mtx = (BIN_MTX*)mtx_alloc(Binary); |
BIN_MTX *mtx = (BIN_MTX*)mtx_alloc(Binary); |
2323 |
|
|
2366 |
} |
} |
2367 |
|
|
2368 |
MTX * |
MTX * |
2369 |
mtx_un(opcode, arg) |
mtx_un(Uopcode opcode, MTX *arg) |
|
Uopcode opcode; |
|
|
MTX *arg; |
|
2370 |
{ |
{ |
2371 |
UN_MTX *mtx = (UN_MTX*)mtx_alloc(Unary); |
UN_MTX *mtx = (UN_MTX*)mtx_alloc(Unary); |
2372 |
|
|
2383 |
} |
} |
2384 |
|
|
2385 |
MTX * |
MTX * |
2386 |
mtx_match(negated, arg, rx) |
mtx_match(int negated, MTX *arg, COMP_REGEX *rx) |
|
int negated; |
|
|
MTX *arg; |
|
|
COMP_REGEX *rx; |
|
2387 |
{ |
{ |
2388 |
MATCH_MTX *mtx = (MATCH_MTX*)mtx_alloc(Match); |
MATCH_MTX *mtx = (MATCH_MTX*)mtx_alloc(Match); |
2389 |
|
|
2400 |
} |
} |
2401 |
|
|
2402 |
MTX * |
MTX * |
2403 |
mtx_cond(cond, if_true, if_false) |
mtx_cond(MTX *cond, MTX *if_true, MTX *if_false) |
|
MTX *cond; |
|
|
MTX *if_true; |
|
|
MTX *if_false; |
|
2404 |
{ |
{ |
2405 |
COND_MTX *mtx = (COND_MTX*)mtx_alloc(Cond); |
COND_MTX *mtx = (COND_MTX*)mtx_alloc(Cond); |
2406 |
|
|
2412 |
} |
} |
2413 |
|
|
2414 |
MTX * |
MTX * |
2415 |
mtx_coerce(type, arg) |
mtx_coerce(Datatype type, MTX *arg) |
|
Datatype type; |
|
|
MTX *arg; |
|
2416 |
{ |
{ |
2417 |
if (type == arg->gen.datatype) |
if (type == arg->gen.datatype) |
2418 |
return mtx_cur(); |
return mtx_cur(); |
2420 |
} |
} |
2421 |
|
|
2422 |
MTX * |
MTX * |
2423 |
coerce(arg, type) |
coerce(MTX *arg, Datatype type) |
|
MTX *arg; |
|
|
Datatype type; |
|
2424 |
{ |
{ |
2425 |
COERCE_MTX *mtx = (COERCE_MTX*)mtx_alloc(Coercion); |
COERCE_MTX *mtx = (COERCE_MTX*)mtx_alloc(Coercion); |
2426 |
|
|
2427 |
mtx_insert(arg, mtx); |
mtx_insert(arg, (MTX*) mtx); |
2428 |
mtx->datatype = type; |
mtx->datatype = type; |
2429 |
mtx->arg = arg; |
mtx->arg = arg; |
2430 |
return (MTX*)mtx; |
return (MTX*)mtx; |
2431 |
} |
} |
2432 |
|
|
2433 |
MTX * |
MTX * |
2434 |
mtx_call(fun, args) |
mtx_call(FUNCTION *fun, MTX *args) |
|
FUNCTION *fun; |
|
|
MTX *args; |
|
2435 |
{ |
{ |
2436 |
MTX *argp; |
MTX *argp; |
2437 |
CALL_MTX *call; |
CALL_MTX *call; |
2485 |
} |
} |
2486 |
|
|
2487 |
MTX * |
MTX * |
2488 |
mtx_builtin(bin, args) |
mtx_builtin(builtin_t *bin, MTX *args) |
|
builtin_t *bin; |
|
|
MTX *args; |
|
2489 |
{ |
{ |
2490 |
MTX *argp; |
MTX *argp; |
2491 |
BTIN_MTX *call; |
BTIN_MTX *call; |
2552 |
* Code optimizer (rudimentary) |
* Code optimizer (rudimentary) |
2553 |
*/ |
*/ |
2554 |
|
|
|
|
|
2555 |
char * |
char * |
2556 |
datatype_str_nom(type) |
datatype_str_nom(Datatype type) |
|
Datatype type; |
|
2557 |
{ |
{ |
2558 |
switch (type) { |
switch (type) { |
2559 |
case Undefined: |
case Undefined: |
2568 |
} |
} |
2569 |
|
|
2570 |
char * |
char * |
2571 |
datatype_str_abl(type) |
datatype_str_abl(Datatype type) |
|
Datatype type; |
|
2572 |
{ |
{ |
2573 |
switch (type) { |
switch (type) { |
2574 |
case Undefined: |
case Undefined: |
2583 |
} |
} |
2584 |
|
|
2585 |
char * |
char * |
2586 |
datatype_str_acc(type) |
datatype_str_acc(Datatype type) |
|
Datatype type; |
|
2587 |
{ |
{ |
2588 |
switch (type) { |
switch (type) { |
2589 |
case Undefined: |
case Undefined: |
2650 |
#define LINK(m) (m ? m->gen.id : 0) |
#define LINK(m) (m ? m->gen.id : 0) |
2651 |
|
|
2652 |
void |
void |
2653 |
debug_print_datum(fp, type, datum) |
debug_print_datum(FILE *fp, Datatype type, Datum *datum) |
|
FILE *fp; |
|
|
Datatype type; |
|
|
Datum *datum; |
|
2654 |
{ |
{ |
2655 |
fprintf(fp, "%3.3s ", datatype_str_nom(type)); |
fprintf(fp, "%3.3s ", datatype_str_nom(type)); |
2656 |
switch (type) { |
switch (type) { |
2663 |
} |
} |
2664 |
|
|
2665 |
void |
void |
2666 |
debug_print_var(fp, var) |
debug_print_var(FILE *fp, VAR *var) |
|
FILE *fp; |
|
|
VAR *var; |
|
2667 |
{ |
{ |
2668 |
fprintf(fp, "%3.3s %s L:%d S:%d", |
fprintf(fp, "%3.3s %s L:%d S:%d", |
2669 |
datatype_str_nom(var->datatype), |
datatype_str_nom(var->datatype), |
2677 |
} |
} |
2678 |
|
|
2679 |
void |
void |
2680 |
debug_print_unary(fp, mtx) |
debug_print_unary(FILE *fp, UN_MTX *mtx) |
|
FILE *fp; |
|
|
UN_MTX *mtx; |
|
2681 |
{ |
{ |
2682 |
fprintf(fp, "OP:%s M:%d", |
fprintf(fp, "OP:%s M:%d", |
2683 |
u_opstr[mtx->opcode], LINK(mtx->arg)); |
u_opstr[mtx->opcode], LINK(mtx->arg)); |
2684 |
} |
} |
2685 |
|
|
2686 |
void |
void |
2687 |
debug_print_binary(fp, mtx) |
debug_print_binary(FILE *fp, BIN_MTX *mtx) |
|
FILE *fp; |
|
|
BIN_MTX *mtx; |
|
2688 |
{ |
{ |
2689 |
fprintf(fp, "OP:%s M1:%d M2:%d", |
fprintf(fp, "OP:%s M1:%d M2:%d", |
2690 |
b_opstr[mtx->opcode], |
b_opstr[mtx->opcode], |
2694 |
|
|
2695 |
|
|
2696 |
void |
void |
2697 |
debug_print_mtxlist(s) |
debug_print_mtxlist(char *s) |
|
char *s; |
|
2698 |
{ |
{ |
2699 |
FILE *fp; |
FILE *fp; |
2700 |
MTX *mtx, *tmp; |
MTX *mtx, *tmp; |
2954 |
* Perform immediate unary calculations |
* Perform immediate unary calculations |
2955 |
*/ |
*/ |
2956 |
int |
int |
2957 |
pass2_unary(mtx) |
pass2_unary(MTX *mtx) |
|
MTX *mtx; |
|
2958 |
{ |
{ |
2959 |
MTX *arg = mtx->un.arg; |
MTX *arg = mtx->un.arg; |
2960 |
|
|
2976 |
* Perform immediate binary computations |
* Perform immediate binary computations |
2977 |
*/ |
*/ |
2978 |
int |
int |
2979 |
pass2_binary(mtx) |
pass2_binary(MTX *mtx) |
|
MTX *mtx; |
|
2980 |
{ |
{ |
2981 |
MTX *arg0 = mtx->bin.arg[0]; |
MTX *arg0 = mtx->bin.arg[0]; |
2982 |
MTX *arg1 = mtx->bin.arg[1]; |
MTX *arg1 = mtx->bin.arg[1]; |
3062 |
} |
} |
3063 |
|
|
3064 |
MTX * |
MTX * |
3065 |
mtx_branch(cond, target) |
mtx_branch(int cond, MTX *target) |
|
int cond; |
|
|
MTX *target; |
|
3066 |
{ |
{ |
3067 |
MTX *nop = mtx_alloc(Nop); |
MTX *nop = mtx_alloc(Nop); |
3068 |
MTX *mtx = mtx_alloc(Branch); |
MTX *mtx = mtx_alloc(Branch); |
3073 |
} |
} |
3074 |
|
|
3075 |
void |
void |
3076 |
mtx_bool(mtx) |
mtx_bool(MTX *mtx) |
|
MTX *mtx; |
|
3077 |
{ |
{ |
3078 |
MTX *j_mtx, *p, *p1; |
MTX *j_mtx, *p, *p1; |
3079 |
|
|
3346 |
|
|
3347 |
|
|
3348 |
void |
void |
3349 |
add_target(mtx, pc) |
add_target(NOP_MTX *mtx, pctr_t pc) |
|
NOP_MTX *mtx; |
|
|
pctr_t pc; |
|
3350 |
{ |
{ |
3351 |
TGT_MTX *tgt = (TGT_MTX *)mtx_alloc(Target); |
TGT_MTX *tgt = (TGT_MTX *)mtx_alloc(Target); |
3352 |
tgt->next = (MTX*)mtx->tgt; |
tgt->next = (MTX*)mtx->tgt; |
3355 |
} |
} |
3356 |
|
|
3357 |
void |
void |
3358 |
fixup_target(mtx, pc) |
fixup_target(NOP_MTX *mtx, pctr_t pc) |
|
NOP_MTX *mtx; |
|
|
pctr_t pc; |
|
3359 |
{ |
{ |
3360 |
TGT_MTX *tgt; |
TGT_MTX *tgt; |
3361 |
|
|
3561 |
} |
} |
3562 |
|
|
3563 |
void |
void |
3564 |
check_codesize(delta) |
check_codesize(int delta) |
|
int delta; |
|
3565 |
{ |
{ |
3566 |
if (rw_pc + delta >= rw_codesize) { |
if (rw_pc + delta >= rw_codesize) { |
3567 |
INSTR *p = emalloc((rw_codesize + 4096) * sizeof(rw_code[0])); |
INSTR *p = emalloc((rw_codesize + 4096) * sizeof(rw_code[0])); |
3573 |
} |
} |
3574 |
|
|
3575 |
int |
int |
3576 |
code(instr) |
code(INSTR instr) |
|
INSTR instr; |
|
3577 |
{ |
{ |
3578 |
check_codesize(1); |
check_codesize(1); |
3579 |
rw_code[rw_pc] = instr; |
rw_code[rw_pc] = instr; |
3581 |
} |
} |
3582 |
|
|
3583 |
int |
int |
3584 |
data(val) |
data(int val) |
|
int val; |
|
3585 |
{ |
{ |
3586 |
return code((INSTR)(RWSTYPE)val); |
return code((INSTR)(RWSTYPE)val); |
3587 |
} |
} |
3588 |
|
|
3589 |
int |
int |
3590 |
data_str(ptr) |
data_str(char *ptr) |
|
char *ptr; |
|
3591 |
{ |
{ |
3592 |
int len = strlen(ptr) + 1; |
int len = strlen(ptr) + 1; |
3593 |
RWSTYPE delta = (len + sizeof(rw_code[0])) / sizeof(rw_code[0]); |
RWSTYPE delta = (len + sizeof(rw_code[0])) / sizeof(rw_code[0]); |
3605 |
*/ |
*/ |
3606 |
|
|
3607 |
COMP_REGEX * |
COMP_REGEX * |
3608 |
rx_alloc(regex, nmatch) |
rx_alloc(regex_t *regex, int nmatch) |
|
regex_t *regex; |
|
|
int nmatch; |
|
3609 |
{ |
{ |
3610 |
COMP_REGEX *rx; |
COMP_REGEX *rx; |
3611 |
|
|
3617 |
} |
} |
3618 |
|
|
3619 |
void |
void |
3620 |
rx_free(rx) |
rx_free(COMP_REGEX *rx) |
|
COMP_REGEX *rx; |
|
3621 |
{ |
{ |
3622 |
COMP_REGEX *next; |
COMP_REGEX *next; |
3623 |
|
|
3630 |
} |
} |
3631 |
|
|
3632 |
COMP_REGEX * |
COMP_REGEX * |
3633 |
compile_regexp(str) |
compile_regexp(char *str) |
|
char *str; |
|
3634 |
{ |
{ |
3635 |
char *p; |
char *p; |
3636 |
regex_t regex; |
regex_t regex; |
3683 |
* Push a number on stack |
* Push a number on stack |
3684 |
*/ |
*/ |
3685 |
int |
int |
3686 |
pushn(mach, n) |
pushn(RWMACH *mach, RWSTYPE n) |
|
RWMACH *mach; |
|
|
RWSTYPE n; |
|
3687 |
{ |
{ |
3688 |
if (mach->st >= mach->ht) { |
if (mach->st >= mach->ht) { |
3689 |
/*FIXME: gc();*/ |
/*FIXME: gc();*/ |
3698 |
* Push a string on stack |
* Push a string on stack |
3699 |
*/ |
*/ |
3700 |
void |
void |
3701 |
pushs(mach, sptr, len) |
pushs(RWMACH *mach, RWSTYPE *sptr, int len) |
|
RWMACH *mach; |
|
|
RWSTYPE *sptr; |
|
|
int len; |
|
3702 |
{ |
{ |
3703 |
if (mach->ht - len <= mach->st) { |
if (mach->ht - len <= mach->st) { |
3704 |
/* Heap overrun: */ |
/* Heap overrun: */ |
3713 |
} |
} |
3714 |
|
|
3715 |
void |
void |
3716 |
pushstr(mach, str, len) |
pushstr(RWMACH *mach, char *str, int len) |
|
RWMACH *mach; |
|
|
char *str; |
|
|
int len; |
|
3717 |
{ |
{ |
3718 |
char *s; |
char *s; |
3719 |
strncpy(s = heap_reserve(mach, len+1), str, len); |
strncpy(s = heap_reserve(mach, len+1), str, len); |
3722 |
} |
} |
3723 |
|
|
3724 |
char * |
char * |
3725 |
heap_reserve(mach, size) |
heap_reserve(RWMACH *mach, int size) |
|
RWMACH *mach; |
|
|
int size; |
|
3726 |
{ |
{ |
3727 |
int len = (size + sizeof(mach->stack[0])) / sizeof(mach->stack[0]); |
int len = (size + sizeof(mach->stack[0])) / sizeof(mach->stack[0]); |
3728 |
|
|
3740 |
* Pop number from stack and store into NP. |
* Pop number from stack and store into NP. |
3741 |
*/ |
*/ |
3742 |
int |
int |
3743 |
cpopn(mach, np) |
cpopn(RWMACH *mach, RWSTYPE *np) |
|
RWMACH *mach; |
|
|
RWSTYPE *np; |
|
3744 |
{ |
{ |
3745 |
if (mach->st <= 0) { |
if (mach->st <= 0) { |
3746 |
rw_error(mach, _("out of popup")); |
rw_error(mach, _("out of popup")); |
3754 |
* should be called before calling this one. |
* should be called before calling this one. |
3755 |
*/ |
*/ |
3756 |
RWSTYPE |
RWSTYPE |
3757 |
popn(mach) |
popn(RWMACH *mach) |
|
RWMACH *mach; |
|
3758 |
{ |
{ |
3759 |
return mach->stack[--mach->st]; |
return mach->stack[--mach->st]; |
3760 |
} |
} |
3761 |
|
|
3762 |
RWSTYPE |
RWSTYPE |
3763 |
tos(mach) |
tos(RWMACH *mach) |
|
RWMACH *mach; |
|
3764 |
{ |
{ |
3765 |
return mach->stack[mach->st-1]; |
return mach->stack[mach->st-1]; |
3766 |
} |
} |
3769 |
* Check if the stack contains at list CNT elements. |
* Check if the stack contains at list CNT elements. |
3770 |
*/ |
*/ |
3771 |
int |
int |
3772 |
checkpop(mach, cnt) |
checkpop(RWMACH *mach, int cnt) |
|
RWMACH *mach; |
|
|
int cnt; |
|
3773 |
{ |
{ |
3774 |
if (mach->st >= cnt) |
if (mach->st >= cnt) |
3775 |
return 0; |
return 0; |
3784 |
* to -- end of reference in string |
* to -- end of reference in string |
3785 |
*/ |
*/ |
3786 |
int |
int |
3787 |
pushref(mach, str, from, to) |
pushref(RWMACH *mach, char *str, int from, int to) |
|
RWMACH *mach; |
|
|
char *str; |
|
|
int from; |
|
|
int to; |
|
3788 |
{ |
{ |
3789 |
int len = to - from + 1; |
int len = to - from + 1; |
3790 |
char *s = heap_reserve(mach, len); |
char *s = heap_reserve(mach, len); |
3800 |
* Create a stack frame and enter the function |
* Create a stack frame and enter the function |
3801 |
*/ |
*/ |
3802 |
void |
void |
3803 |
enter(mach, n) |
enter(RWMACH *mach, int n) |
|
RWMACH *mach; |
|
|
int n; |
|
3804 |
{ |
{ |
3805 |
pushn(mach, mach->sb); |
pushn(mach, mach->sb); |
3806 |
mach->sb = mach->st; |
mach->sb = mach->st; |
3811 |
* Destroy the stack frame and leave the function |
* Destroy the stack frame and leave the function |
3812 |
*/ |
*/ |
3813 |
void |
void |
3814 |
leave(mach) |
leave(RWMACH *mach) |
|
RWMACH *mach; |
|
3815 |
{ |
{ |
3816 |
/* Save return value */ |
/* Save return value */ |
3817 |
mach->rA = popn(mach); |
mach->rA = popn(mach); |
3822 |
} |
} |
3823 |
|
|
3824 |
RWSTYPE |
RWSTYPE |
3825 |
getarg(mach, num) |
getarg(RWMACH *mach, int num) |
|
RWMACH *mach; |
|
|
int num; |
|
3826 |
{ |
{ |
3827 |
return mach->stack[mach->sb - (STACK_BASE + num)]; |
return mach->stack[mach->sb - (STACK_BASE + num)]; |
3828 |
} |
} |
3833 |
static RWSTYPE nil = 0; |
static RWSTYPE nil = 0; |
3834 |
|
|
3835 |
int |
int |
3836 |
rw_error(mach, msg) |
rw_error(RWMACH *mach, char *msg) |
|
RWMACH *mach; |
|
|
char *msg; |
|
3837 |
{ |
{ |
3838 |
radlog(L_ERR, |
radlog(L_ERR, |
3839 |
"%s: %s", |
"%s: %s", |
3843 |
} |
} |
3844 |
|
|
3845 |
void |
void |
3846 |
rw_call(mach) |
rw_call(RWMACH *mach) |
|
RWMACH *mach; |
|
3847 |
{ |
{ |
3848 |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
3849 |
pushn(mach, mach->pc); /* save return address */ |
pushn(mach, mach->pc); /* save return address */ |
3851 |
} |
} |
3852 |
|
|
3853 |
void |
void |
3854 |
rw_adjstk(mach) |
rw_adjstk(RWMACH *mach) |
|
RWMACH *mach; |
|
3855 |
{ |
{ |
3856 |
int delta = (int) rw_code[mach->pc++]; |
int delta = (int) rw_code[mach->pc++]; |
3857 |
mach->st -= delta; |
mach->st -= delta; |
3859 |
} |
} |
3860 |
|
|
3861 |
void |
void |
3862 |
rw_enter(mach) |
rw_enter(RWMACH *mach) |
|
RWMACH *mach; |
|
3863 |
{ |
{ |
3864 |
/*FIXME: runtime checking */ |
/*FIXME: runtime checking */ |
3865 |
int n = (int) rw_code[mach->pc++]; |
int n = (int) rw_code[mach->pc++]; |
3867 |
} |
} |
3868 |
|
|
3869 |
void |
void |
3870 |
rw_leave(mach) |
rw_leave(RWMACH *mach) |
|
RWMACH *mach; |
|
3871 |
{ |
{ |
3872 |
leave(mach); |
leave(mach); |
3873 |
} |
} |
3876 |
* Push a number on stack |
* Push a number on stack |
3877 |
*/ |
*/ |
3878 |
void |
void |
3879 |
rw_pushn(mach) |
rw_pushn(RWMACH *mach) |
|
RWMACH *mach; |
|
3880 |
{ |
{ |
3881 |
RWSTYPE n = (RWSTYPE) rw_code[mach->pc++]; |
RWSTYPE n = (RWSTYPE) rw_code[mach->pc++]; |
3882 |
pushn(mach, n); |
pushn(mach, n); |
3886 |
* Push a reference value on stack |
* Push a reference value on stack |
3887 |
*/ |
*/ |
3888 |
void |
void |
3889 |
rw_pushref(mach) |
rw_pushref(RWMACH *mach) |
|
RWMACH *mach; |
|
3890 |
{ |
{ |
3891 |
int i = (int) rw_code[mach->pc++]; |
int i = (int) rw_code[mach->pc++]; |
3892 |
|
|
3897 |
* Push a variable on stack |
* Push a variable on stack |
3898 |
*/ |
*/ |
3899 |
void |
void |
3900 |
rw_pushv(mach) |
rw_pushv(RWMACH *mach) |
|
RWMACH *mach; |
|
3901 |
{ |
{ |
3902 |
stkoff_t n = (stkoff_t) rw_code[mach->pc++]; |
stkoff_t n = (stkoff_t) rw_code[mach->pc++]; |
3903 |
|
|
3905 |
} |
} |
3906 |
|
|
3907 |
void |
void |
3908 |
rw_pushs(mach) |
rw_pushs(RWMACH *mach) |
|
RWMACH *mach; |
|
3909 |
{ |
{ |
3910 |
int len = (int) rw_code[mach->pc++]; |
int len = (int) rw_code[mach->pc++]; |
3911 |
RWSTYPE *sptr = (RWSTYPE*) (rw_code + mach->pc); |
RWSTYPE *sptr = (RWSTYPE*) (rw_code + mach->pc); |
3918 |
* Assign a value to a variable |
* Assign a value to a variable |
3919 |
*/ |
*/ |
3920 |
void |
void |
3921 |
rw_asgn(mach) |
rw_asgn(RWMACH *mach) |
|
RWMACH *mach; |
|
3922 |
{ |
{ |
3923 |
stkoff_t off = (stkoff_t) rw_code[mach->pc++]; |
stkoff_t off = (stkoff_t) rw_code[mach->pc++]; |
3924 |
RWSTYPE n; |
RWSTYPE n; |
3930 |
} |
} |
3931 |
|
|
3932 |
void |
void |
3933 |
assert_request_presence(mach) |
assert_request_presence(RWMACH *mach) |
|
RWMACH *mach; |
|
3934 |
{ |
{ |
3935 |
if (!mach->req) |
if (!mach->req) |
3936 |
rw_error(mach, _("code requires that the request be present")); |
rw_error(mach, _("code requires that the request be present")); |
3939 |
/* Check if the A/V pair is supplied in the request |
/* Check if the A/V pair is supplied in the request |
3940 |
*/ |
*/ |
3941 |
void |
void |
3942 |
rw_attrcheck0(mach) |
rw_attrcheck0(RWMACH *mach) |
|
RWMACH *mach; |
|
3943 |
{ |
{ |
3944 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
3945 |
|
|
3947 |
} |
} |
3948 |
|
|
3949 |
void |
void |
3950 |
rw_attrcheck(mach) |
rw_attrcheck(RWMACH *mach) |
|
RWMACH *mach; |
|
3951 |
{ |
{ |
3952 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
3953 |
RWSTYPE index; |
RWSTYPE index; |
3961 |
* Assign a value to an A/V pair |
* Assign a value to an A/V pair |
3962 |
*/ |
*/ |
3963 |
void |
void |
3964 |
attrasgn_internal(mach, attr, pair, val) |
attrasgn_internal(RWMACH *mach, int attr, VALUE_PAIR *pair, RWSTYPE val) |
|
RWMACH *mach; |
|
|
int attr; |
|
|
VALUE_PAIR *pair; |
|
|
RWSTYPE val; |
|
3965 |
{ |
{ |
3966 |
assert_request_presence(mach); |
assert_request_presence(mach); |
3967 |
if (!pair) { |
if (!pair) { |
3988 |
} |
} |
3989 |
|
|
3990 |
void |
void |
3991 |
rw_attrasgn0(mach) |
rw_attrasgn0(RWMACH *mach) |
|
RWMACH *mach; |
|
3992 |
{ |
{ |
3993 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
3994 |
RWSTYPE val; |
RWSTYPE val; |
3998 |
} |
} |
3999 |
|
|
4000 |
void |
void |
4001 |
rw_attrasgn(mach) |
rw_attrasgn(RWMACH *mach) |
|
RWMACH *mach; |
|
4002 |
{ |
{ |
4003 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4004 |
RWSTYPE val; |
RWSTYPE val; |
4012 |
} |
} |
4013 |
|
|
4014 |
void |
void |
4015 |
rw_attrs0(mach) |
rw_attrs0(RWMACH *mach) |
|
RWMACH *mach; |
|
4016 |
{ |
{ |
4017 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4018 |
VALUE_PAIR *pair; |
VALUE_PAIR *pair; |
4030 |
} |
} |
4031 |
|
|
4032 |
void |
void |
4033 |
rw_attrn0(mach) |
rw_attrn0(RWMACH *mach) |
|
RWMACH *mach; |
|
4034 |
{ |
{ |
4035 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4036 |
VALUE_PAIR *pair; |
VALUE_PAIR *pair; |
4042 |
} |
} |
4043 |
|
|
4044 |
void |
void |
4045 |
rw_attrs(mach) |
rw_attrs(RWMACH *mach) |
|
RWMACH *mach; |
|
4046 |
{ |
{ |
4047 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4048 |
VALUE_PAIR *pair; |
VALUE_PAIR *pair; |
4056 |
} |
} |
4057 |
|
|
4058 |
void |
void |
4059 |
rw_attrn(mach) |
rw_attrn(RWMACH *mach) |
|
RWMACH *mach; |
|
4060 |
{ |
{ |
4061 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4062 |
VALUE_PAIR *pair; |
VALUE_PAIR *pair; |
4070 |
} |
} |
4071 |
|
|
4072 |
void |
void |
4073 |
rw_attr_delete0(mach) |
rw_attr_delete0(RWMACH *mach) |
|
RWMACH *mach; |
|
4074 |
{ |
{ |
4075 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4076 |
avl_delete(&mach->req->request, attr); |
avl_delete(&mach->req->request, attr); |
4077 |
} |
} |
4078 |
|
|
4079 |
void |
void |
4080 |
rw_attr_delete(mach) |
rw_attr_delete(RWMACH *mach) |
|
RWMACH *mach; |
|
4081 |
{ |
{ |
4082 |
int attr = (int) rw_code[mach->pc++]; |
int attr = (int) rw_code[mach->pc++]; |
4083 |
RWSTYPE index; |
RWSTYPE index; |
4091 |
* Pop (and discard) a value from stack |
* Pop (and discard) a value from stack |
4092 |
*/ |
*/ |
4093 |
void |
void |
4094 |
rw_popn(mach) |
rw_popn(RWMACH *mach) |
|
RWMACH *mach; |
|
4095 |
{ |
{ |
4096 |
RWSTYPE n; |
RWSTYPE n; |
4097 |
cpopn(mach, &n); |
cpopn(mach, &n); |
4101 |
* Pop a value from stack into the accumulator |
* Pop a value from stack into the accumulator |
4102 |
*/ |
*/ |
4103 |
void |
void |
4104 |
rw_popa(mach) |
rw_popa(RWMACH *mach) |
|
RWMACH *mach; |
|
4105 |
{ |
{ |
4106 |
cpopn(mach, &mach->rA); |
cpopn(mach, &mach->rA); |
4107 |
} |
} |
4110 |
* Push accumulator on stack |
* Push accumulator on stack |
4111 |
*/ |
*/ |
4112 |
void |
void |
4113 |
rw_pusha(mach) |
rw_pusha(RWMACH *mach) |
|
RWMACH *mach; |
|
4114 |
{ |
{ |
4115 |
pushn(mach, mach->rA); |
pushn(mach, mach->rA); |
4116 |
} |
} |
4119 |
* String concatenation |
* String concatenation |
4120 |
*/ |
*/ |
4121 |
void |
void |
4122 |
rw_adds(mach) |
rw_adds(RWMACH *mach) |
|
RWMACH *mach; |
|
4123 |
{ |
{ |
4124 |
char *s1, *s2, *s; |
char *s1, *s2, *s; |
4125 |
|
|
4135 |
* Unary negation |
* Unary negation |
4136 |
*/ |
*/ |
4137 |
void |
void |
4138 |
rw_neg(mach) |
rw_neg(RWMACH *mach) |
|
RWMACH *mach; |
|
4139 |
{ |
{ |
4140 |
checkpop(mach, 1); |
checkpop(mach, 1); |
4141 |
pushn(mach, -popn(mach)); |
pushn(mach, -popn(mach)); |
4145 |
* Bitwise operations |
* Bitwise operations |
4146 |
*/ |
*/ |
4147 |
void |
void |
4148 |
rw_b_and(mach) |
rw_b_and(RWMACH *mach) |
|
RWMACH *mach; |
|
4149 |
{ |
{ |
4150 |
int n1, n2; |
int n1, n2; |
4151 |
|
|
4156 |
} |
} |
4157 |
|
|
4158 |
void |
void |
4159 |
rw_b_or(mach) |
rw_b_or(RWMACH *mach) |
|
RWMACH *mach; |
|
4160 |
{ |
{ |
4161 |
int n1, n2; |
int n1, n2; |
4162 |
|
|
4167 |
} |
} |
4168 |
|
|
4169 |
void |
void |
4170 |
rw_b_xor(mach) |
rw_b_xor(RWMACH *mach) |
|
RWMACH *mach; |
|
4171 |
{ |
{ |
4172 |
int n1, n2; |
int n1, n2; |
4173 |
|
|
4178 |
} |
} |
4179 |
|
|
4180 |
void |
void |
4181 |
rw_shl(mach) |
rw_shl(RWMACH *mach) |
|
RWMACH *mach; |
|
4182 |
{ |
{ |
4183 |
int n1, n2; |
int n1, n2; |
4184 |
|
|
4189 |
} |
} |
4190 |
|
|
4191 |
void |
void |
4192 |
rw_shr(mach) |
rw_shr(RWMACH *mach) |
|
RWMACH *mach; |
|
4193 |
{ |
{ |
4194 |
int n1, n2; |
int n1, n2; |
4195 |
|
|
4203 |
* Addition |
* Addition |
4204 |
*/ |
*/ |
4205 |
void |
void |
4206 |
rw_add(mach) |
rw_add(RWMACH *mach) |
|
RWMACH *mach; |
|
4207 |
{ |
{ |
4208 |
int n1, n2; |
int n1, n2; |
4209 |
|
|
4217 |
* Subtraction |
* Subtraction |
4218 |
*/ |
*/ |
4219 |
void |
void |
4220 |
rw_sub(mach) |
rw_sub(RWMACH *mach) |
|
RWMACH *mach; |
|
4221 |
{ |
{ |
4222 |
int n1, n2; |
int n1, n2; |
4223 |
|
|
4231 |
* Multiplication |
* Multiplication |
4232 |
*/ |
*/ |
4233 |
void |
void |
4234 |
rw_mul(mach) |
rw_mul(RWMACH *mach) |
|
RWMACH *mach; |
|
4235 |
{ |
{ |
4236 |
int n1, n2; |
int n1, n2; |
4237 |
|
|
4245 |
* Division |
* Division |
4246 |
*/ |
*/ |
4247 |
void |
void |
4248 |
rw_div(mach) |
rw_div(RWMACH *mach) |
|
RWMACH *mach; |
|
4249 |
{ |
{ |
4250 |
int n1, n2; |
int n1, n2; |
4251 |
|
|
4275 |
} |
} |
4276 |
|
|
4277 |
void |
void |
4278 |
rw_int(mach) |
rw_int(RWMACH *mach) |
|
RWMACH *mach; |
|
4279 |
{ |
{ |
4280 |
char *s = (char *)popn(mach); |
char *s = (char *)popn(mach); |
4281 |
pushn(mach, strtol(s, NULL, 0)); |
pushn(mach, strtol(s, NULL, 0)); |
4282 |
} |
} |
4283 |
|
|
4284 |
void |
void |
4285 |
rw_string(mach) |
rw_string(RWMACH *mach) |
|
RWMACH *mach; |
|
4286 |
{ |
{ |
4287 |
int n = popn(mach); |
int n = popn(mach); |
4288 |
RWSTYPE buf[64]; |
RWSTYPE buf[64]; |
4292 |
} |
} |
4293 |
|
|
4294 |
void |
void |
4295 |
rw_eq(mach) |
rw_eq(RWMACH *mach) |
|
RWMACH *mach; |
|
4296 |
{ |
{ |
4297 |
int n1, n2; |
int n1, n2; |
4298 |
|
|
4303 |
} |
} |
4304 |
|
|
4305 |
void |
void |
4306 |
rw_ne(mach) |
rw_ne(RWMACH *mach) |
|
RWMACH *mach; |
|
4307 |
{ |
{ |
4308 |
int n1, n2; |
int n1, n2; |
4309 |
|
|
4314 |
} |
} |
4315 |
|
|
4316 |
void |
void |
4317 |
rw_lt(mach) |
rw_lt(RWMACH *mach) |
|
RWMACH *mach; |
|
4318 |
{ |
{ |
4319 |
int n1, n2; |
int n1, n2; |
4320 |
|
|
4325 |
} |
} |
4326 |
|
|
4327 |
void |
void |
4328 |
rw_le(mach) |
rw_le(RWMACH *mach) |
|
RWMACH *mach; |
|
4329 |
{ |
{ |
4330 |
int n1, n2; |
int n1, n2; |
4331 |
|
|
4336 |
} |
} |
4337 |
|
|
4338 |
void |
void |
4339 |
rw_gt(mach) |
rw_gt(RWMACH *mach) |
|
RWMACH *mach; |
|
4340 |
{ |
{ |
4341 |
int n1, n2; |
int n1, n2; |
4342 |
|
|
4347 |
} |
} |
4348 |
|
|
4349 |
void |
void |
4350 |
rw_ge(mach) |
rw_ge(RWMACH *mach) |
|
RWMACH *mach; |
|
4351 |
{ |
{ |
4352 |
int n1, n2; |
int n1, n2; |
4353 |
|
|
4358 |
} |
} |
4359 |
|
|
4360 |
void |
void |
4361 |
rw_eqs(mach) |
rw_eqs(RWMACH *mach) |
|
RWMACH *mach; |
|
4362 |
{ |
{ |
4363 |
char *s1, *s2; |
char *s1, *s2; |
4364 |
|
|
4369 |
} |
} |
4370 |
|
|
4371 |
void |
void |
4372 |
rw_nes(mach) |
rw_nes(RWMACH *mach) |
|
RWMACH *mach; |
|
4373 |
{ |
{ |
4374 |
char *s1, *s2; |
char *s1, *s2; |
4375 |
|
|
4380 |
} |
} |
4381 |
|
|
4382 |
void |
void |
4383 |
rw_lts(mach) |
rw_lts(RWMACH *mach) |
|
RWMACH *mach; |
|
4384 |
{ |
{ |
4385 |
char *s1, *s2; |
char *s1, *s2; |
4386 |
|
|
4391 |
} |
} |
4392 |
|
|
4393 |
void |
void |
4394 |
rw_les(mach) |
rw_les(RWMACH *mach) |
|
RWMACH *mach; |
|
4395 |
{ |
{ |
4396 |
char *s1, *s2; |
char *s1, *s2; |
4397 |
|
|
4402 |
} |
} |
4403 |
|
|
4404 |
void |
void |
4405 |
rw_gts(mach) |
rw_gts(RWMACH *mach) |
|
RWMACH *mach; |
|
4406 |
{ |
{ |
4407 |
char *s1, *s2; |
char *s1, *s2; |
4408 |
|
|
4413 |
} |
} |
4414 |
|
|
4415 |
void |
void |
4416 |
rw_ges(mach) |
rw_ges(RWMACH *mach) |
|
RWMACH *mach; |
|
4417 |
{ |
{ |
4418 |
char *s1, *s2; |
char *s1, *s2; |
4419 |
|
|
4424 |
} |
} |
4425 |
|
|
4426 |
void |
void |
4427 |
rw_not(mach) |
rw_not(RWMACH *mach) |
|
RWMACH *mach; |
|
4428 |
{ |
{ |
4429 |
int n; |
int n; |
4430 |
|
|
4434 |
} |
} |
4435 |
|
|
4436 |
void |
void |
4437 |
rw_match(mach) |
rw_match(RWMACH *mach) |
|
RWMACH *mach; |
|
4438 |
{ |
{ |
4439 |
COMP_REGEX *rx = (COMP_REGEX *)rw_code[mach->pc++]; |
COMP_REGEX *rx = (COMP_REGEX *)rw_code[mach->pc++]; |
4440 |
char *s = (char*)popn(mach); |
char *s = (char*)popn(mach); |
4463 |
} |
} |
4464 |
|
|
4465 |
void |
void |
4466 |
rw_jmp(mach) |
rw_jmp(RWMACH *mach) |
|
RWMACH *mach; |
|
4467 |
{ |
{ |
4468 |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
4469 |
mach->pc = pc; |
mach->pc = pc; |
4470 |
} |
} |
4471 |
|
|
4472 |
void |
void |
4473 |
rw_jne(mach) |
rw_jne(RWMACH *mach) |
|
RWMACH *mach; |
|
4474 |
{ |
{ |
4475 |
int n; |
int n; |
4476 |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
4481 |
} |
} |
4482 |
|
|
4483 |
void |
void |
4484 |
rw_je(mach) |
rw_je(RWMACH *mach) |
|
RWMACH *mach; |
|
4485 |
{ |
{ |
4486 |
int n; |
int n; |
4487 |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
pctr_t pc = (pctr_t) rw_code[mach->pc++]; |
4492 |
} |
} |
4493 |
|
|
4494 |
void |
void |
4495 |
rw_builtin(mach) |
rw_builtin(RWMACH *mach) |
|
RWMACH *mach; |
|
4496 |
{ |
{ |
4497 |
INSTR fun = (INSTR) rw_code[mach->pc++]; |
INSTR fun = (INSTR) rw_code[mach->pc++]; |
4498 |
pushn(mach, mach->pc); |
pushn(mach, mach->pc); |
4502 |
} |
} |
4503 |
|
|
4504 |
void |
void |
4505 |
run(mach, pc) |
run(RWMACH *mach, pctr_t pc) |
|
RWMACH *mach; |
|
|
pctr_t pc; |
|
4506 |
{ |
{ |
4507 |
mach->pc = pc; |
mach->pc = pc; |
4508 |
while (rw_code[mach->pc]) { |
while (rw_code[mach->pc]) { |
4517 |
*/ |
*/ |
4518 |
|
|
4519 |
void |
void |
4520 |
gc(mach) |
gc(RWMACH *mach) |
|
RWMACH *mach; |
|
4521 |
{ |
{ |
4522 |
} |
} |
4523 |
|
|
4542 |
* integer length(string s) |
* integer length(string s) |
4543 |
*/ |
*/ |
4544 |
void |
void |
4545 |
bi_length(mach) |
bi_length(RWMACH *mach) |
|
RWMACH *mach; |
|
4546 |
{ |
{ |
4547 |
pushn(mach, strlen((char*)getarg(mach, 1))); |
pushn(mach, strlen((char*)getarg(mach, 1))); |
4548 |
} |
} |
4551 |
* integer index(string s, integer a) |
* integer index(string s, integer a) |
4552 |
*/ |
*/ |
4553 |
void |
void |
4554 |
bi_index(mach) |
bi_index(RWMACH *mach) |
|
RWMACH *mach; |
|
4555 |
{ |
{ |
4556 |
char *s, *p; |
char *s, *p; |
4557 |
int c; |
int c; |
4566 |
* integer rindex(string s, integer a) |
* integer rindex(string s, integer a) |
4567 |
*/ |
*/ |
4568 |
void |
void |
4569 |
bi_rindex(mach) |
bi_rindex(RWMACH *mach) |
|
RWMACH *mach; |
|
4570 |
{ |
{ |
4571 |
char *s, *p; |
char *s, *p; |
4572 |
int c; |
int c; |
4580 |
* integer substr(string s, int start, int length) |
* integer substr(string s, int start, int length) |
4581 |
*/ |
*/ |
4582 |
void |
void |
4583 |
bi_substr(mach) |
bi_substr(RWMACH *mach) |
|
RWMACH *mach; |
|
4584 |
{ |
{ |
4585 |
char *src, *dest; |
char *src, *dest; |
4586 |
int start, length; |
int start, length; |
4599 |
} |
} |
4600 |
|
|
4601 |
void |
void |
4602 |
bi_field(mach) |
bi_field(RWMACH *mach) |
|
RWMACH *mach; |
|
4603 |
{ |
{ |
4604 |
char *str = (char*) getarg(mach, 2); |
char *str = (char*) getarg(mach, 2); |
4605 |
int fn = getarg(mach, 1); |
int fn = getarg(mach, 1); |
4628 |
} |
} |
4629 |
|
|
4630 |
void |
void |
4631 |
bi_logit(mach) |
bi_logit(RWMACH *mach) |
|
RWMACH *mach; |
|
4632 |
{ |
{ |
4633 |
char *msg = (char*) getarg(mach, 1); |
char *msg = (char*) getarg(mach, 1); |
4634 |
radlog(L_INFO, "%s", msg); |
radlog(L_INFO, "%s", msg); |
4636 |
} |
} |
4637 |
|
|
4638 |
void |
void |
4639 |
bi_htonl(mach) |
bi_htonl(RWMACH *mach) |
|
RWMACH *mach; |
|
4640 |
{ |
{ |
4641 |
pushn(mach, htonl(getarg(mach, 1))); |
pushn(mach, htonl(getarg(mach, 1))); |
4642 |
} |
} |
4643 |
|
|
4644 |
void |
void |
4645 |
bi_ntohl(mach) |
bi_ntohl(RWMACH *mach) |
|
RWMACH *mach; |
|
4646 |
{ |
{ |
4647 |
pushn(mach, ntohl(getarg(mach, 1))); |
pushn(mach, ntohl(getarg(mach, 1))); |
4648 |
} |
} |
4649 |
|
|
4650 |
void |
void |
4651 |
bi_htons(mach) |
bi_htons(RWMACH *mach) |
|
RWMACH *mach; |
|
4652 |
{ |
{ |
4653 |
pushn(mach, htons(getarg(mach, 1) & 0xffff)); |
pushn(mach, htons(getarg(mach, 1) & 0xffff)); |
4654 |
} |
} |
4655 |
|
|
4656 |
void |
void |
4657 |
bi_ntohs(mach) |
bi_ntohs(RWMACH *mach) |
|
RWMACH *mach; |
|
4658 |
{ |
{ |
4659 |
pushn(mach, ntohs(getarg(mach, 1) & 0xffff)); |
pushn(mach, ntohs(getarg(mach, 1) & 0xffff)); |
4660 |
} |
} |
4661 |
|
|
4662 |
void |
void |
4663 |
bi_inet_ntoa(mach) |
bi_inet_ntoa(RWMACH *mach) |
|
RWMACH *mach; |
|
4664 |
{ |
{ |
4665 |
char buffer[DOTTED_QUAD_LEN]; |
char buffer[DOTTED_QUAD_LEN]; |
4666 |
char *s = ip_iptostr(getarg(mach, 1), buffer); |
char *s = ip_iptostr(getarg(mach, 1), buffer); |
4668 |
} |
} |
4669 |
|
|
4670 |
void |
void |
4671 |
bi_inet_aton(mach) |
bi_inet_aton(RWMACH *mach) |
|
RWMACH *mach; |
|
4672 |
{ |
{ |
4673 |
/* Note: inet_aton is not always present. See lib/iputils.c */ |
/* Note: inet_aton is not always present. See lib/iputils.c */ |
4674 |
pushn(mach, ip_strtoip((char*)getarg(mach, 1))); |
pushn(mach, ip_strtoip((char*)getarg(mach, 1))); |
4676 |
|
|
4677 |
|
|
4678 |
static builtin_t builtin[] = { |
static builtin_t builtin[] = { |
4679 |
bi_length, "length", Integer, "s", |
{ bi_length, "length", Integer, "s" }, |
4680 |
bi_index, "index", Integer, "si", |
{ bi_index, "index", Integer, "si" }, |
4681 |
bi_rindex, "rindex", Integer, "si", |
{ bi_rindex, "rindex", Integer, "si" }, |
4682 |
bi_substr, "substr", String, "sii", |
{ bi_substr, "substr", String, "sii" }, |
4683 |
bi_logit, "logit", Integer, "s", |
{ bi_logit, "logit", Integer, "s" }, |
4684 |
bi_field, "field", String, "si", |
{ bi_field, "field", String, "si" }, |
4685 |
bi_ntohl, "ntohl", Integer, "i", |
{ bi_ntohl, "ntohl", Integer, "i" }, |
4686 |
bi_htonl, "htonl", Integer, "i", |
{ bi_htonl, "htonl", Integer, "i" }, |
4687 |
bi_ntohs, "ntohs", Integer, "i", |
{ bi_ntohs, "ntohs", Integer, "i" }, |
4688 |
bi_htons, "htons", Integer, "i", |
{ bi_htons, "htons", Integer, "i" }, |
4689 |
bi_inet_ntoa, "inet_ntoa", String, "i", |
{ bi_inet_ntoa, "inet_ntoa", String, "i" }, |
4690 |
bi_inet_aton, "inet_aton", Integer, "s", |
{ bi_inet_aton, "inet_aton", Integer, "s" }, |
4691 |
NULL |
NULL |
4692 |
}; |
}; |
4693 |
|
|
4694 |
builtin_t * |
builtin_t * |
4695 |
builtin_lookup(name) |
builtin_lookup(char *name) |
|
char *name; |
|
4696 |
{ |
{ |
4697 |
int i; |
int i; |
4698 |
|
|
4707 |
*/ |
*/ |
4708 |
|
|
4709 |
int |
int |
4710 |
function_free(f) |
function_free(FUNCTION *f) |
|
FUNCTION *f; |
|
4711 |
{ |
{ |
4712 |
PARAMETER *parm, *next; |
PARAMETER *parm, *next; |
4713 |
|
|
4722 |
} |
} |
4723 |
|
|
4724 |
FUNCTION * |
FUNCTION * |
4725 |
function_install(fun) |
function_install(FUNCTION *fun) |
|
FUNCTION *fun; |
|
4726 |
{ |
{ |
4727 |
FUNCTION *fp; |
FUNCTION *fp; |
4728 |
|
|
4752 |
*/ |
*/ |
4753 |
|
|
4754 |
void |
void |
4755 |
rw_mach_init(mach, stacksize) |
rw_mach_init(RWMACH *mach, size_t stacksize) |
|
RWMACH *mach; |
|
|
size_t stacksize; |
|
4756 |
{ |
{ |
4757 |
memset(mach, 0, sizeof(*mach)); |
memset(mach, 0, sizeof(*mach)); |
4758 |
|
|
4763 |
} |
} |
4764 |
|
|
4765 |
void |
void |
4766 |
rw_mach_destroy(mach) |
rw_mach_destroy(RWMACH *mach) |
|
RWMACH *mach; |
|
4767 |
{ |
{ |
4768 |
efree(mach->stack); |
efree(mach->stack); |
4769 |
} |
} |
4770 |
|
|
4771 |
void |
void |
4772 |
run_init(pc, request) |
run_init(pctr_t pc, RADIUS_REQ *request) |
|
pctr_t pc; |
|
|
RADIUS_REQ *request; |
|
4773 |
{ |
{ |
4774 |
FILE *fp; |
FILE *fp; |
4775 |
RWMACH mach; |
RWMACH mach; |
4888 |
|
|
4889 |
|
|
4890 |
int |
int |
4891 |
interpret(fcall, req, type, datum) |
interpret(char *fcall, RADIUS_REQ *req, Datatype *type, Datum *datum) |
|
char *fcall; |
|
|
RADIUS_REQ *req; |
|
|
Datatype *type; |
|
|
Datum *datum; |
|
4892 |
{ |
{ |
4893 |
FILE *fp; |
FILE *fp; |
4894 |
FUNCTION *fun; |
FUNCTION *fun; |
5029 |
} |
} |
5030 |
|
|
5031 |
int |
int |
5032 |
run_rewrite(name, req) |
run_rewrite(char *name, RADIUS_REQ *req) |
|
char *name; |
|
|
RADIUS_REQ *req; |
|
5033 |
{ |
{ |
5034 |
FUNCTION *fun; |
FUNCTION *fun; |
5035 |
|
|
5064 |
#ifdef USE_SERVER_GUILE |
#ifdef USE_SERVER_GUILE |
5065 |
|
|
5066 |
SCM |
SCM |
5067 |
radscm_datum_to_scm(type, datum) |
radscm_datum_to_scm(Datatype type, Datum datum) |
|
Datatype type; |
|
|
Datum datum; |
|
5068 |
{ |
{ |
5069 |
switch (type) { |
switch (type) { |
5070 |
case Integer: |
case Integer: |
5078 |
} |
} |
5079 |
|
|
5080 |
int |
int |
5081 |
radscm_scm_to_ival(cell, val) |
radscm_scm_to_ival(SCM cell, int *val) |
|
SCM cell; |
|
|
int *val; |
|
5082 |
{ |
{ |
5083 |
if (SCM_IMP(cell)) { |
if (SCM_IMP(cell)) { |
5084 |
if (SCM_INUMP(cell)) |
if (SCM_INUMP(cell)) |