23 if ((c >=
'A' && c <=
'Z')
24 || (c >=
'a' && c <=
'z')
25 || (c >=
'0' && c <=
'9')
40 return (*fp)(mm, complain);
64 u8 * key_copy, *value_copy;
69 key_copy =
format (0,
"%s%c", name, 0);
70 value_copy =
format (0,
"%s%c", value, 0);
94 i8 *varname, *varvalue;
116 while (*s && (
macro_isalnum (*s) || (*s ==
'_') || (*s ==
'(')))
123 while (*s && *s !=
')')
145 varvalue = (
i8 *)
format (0,
"%s%c", tmp, 0);
151 char * tmp = getenv (varname);
153 varvalue = (
i8 *)
format (0,
"%s%c", tmp, 0);
171 clib_warning (
"Undefined Variable Reference: %s\n", varname);
192 s2 = (
i8 *)
format (0,
"$(%s)%c", s, 0);
207 if (gethostname (tmp,
sizeof(tmp)))
208 return ((
i8 *)
format (0,
"gethostname-error%c", 0));
209 return ((
i8 *)
format (0,
"%s%c", tmp, 0));
233 u8 ** strings_to_free = 0;
240 vec_add1 (strings_to_free, (u8 *) (p->key));
241 vec_add1 (strings_to_free, (u8 *) (p->value[0]));
244 for (i = 0; i <
vec_len (strings_to_free); i++)
i8 * clib_macro_eval_dollar(macro_main_t *mm, i8 *s, i32 complain)
sll srl srl sll sra u16x4 i
void clib_macro_free(macro_main_t *mm)
static int macro_isalnum(i8 c)
i8 * clib_macro_get_value(macro_main_t *mm, char *name)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define hash_set_mem(h, key, value)
#define clib_warning(format, args...)
#define hash_get_pair(h, key)
uword * the_value_table_hash
#define hash_create_string(elts, value_bytes)
#define hash_unset_mem(h, key)
static i8 * eval_hostname(macro_main_t *mm, i32 complain)
void clib_macro_add_builtin(macro_main_t *mm, char *name, void *eval_fn)
#define vec_free(V)
Free vector's memory (no header).
i8 * clib_macro_eval(macro_main_t *mm, i8 *s, i32 complain)
int clib_macro_unset(macro_main_t *mm, char *name)
static i8 * builtin_eval(macro_main_t *mm, i8 *varname, i32 complain)
#define vec_append(v1, v2)
Append v2 after v1.
int clib_macro_set_value(macro_main_t *mm, char *name, char *value)
uword * the_builtin_eval_hash
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void clib_macro_init(macro_main_t *mm)
#define hash_foreach_pair(p, v, body)
#define hash_get_mem(h, key)