24 if ((c >=
'A' && c <=
'Z')
25 || (c >=
'a' && c <=
'z') || (c >=
'0' && c <=
'9') || (c ==
'_'))
40 return (*fp) (mm, complain);
54 key = (
u8 *) (p->
key);
66 u8 *key_copy, *value_copy;
71 key_copy =
format (0,
"%s%c", name, 0);
72 value_copy =
format (0,
"%s%c", value, 0);
98 i8 *varname, *varvalue;
120 while (*s && (
macro_isalnum (*s) || (*s ==
'_') || (*s ==
'(')))
127 while (*s && *s !=
')')
149 varvalue = (
i8 *)
format (0,
"%s%c", tmp, 0);
155 char *tmp = getenv ((
char *) varname);
157 varvalue = (
i8 *)
format (0,
"%s%c", tmp, 0);
169 _vec_len (rv) =
vec_len (rv) - 1;
175 clib_warning (
"Undefined Variable Reference: %s\n", varname);
177 _vec_len (rv) =
vec_len (rv) - 1;
197 s2 = (
i8 *)
format (0,
"$(%s)%c", s, 0);
214 if (gethostname (tmp,
sizeof (tmp)))
215 return ((
i8 *)
format (0,
"gethostname-error%c", 0));
216 return ((
i8 *)
format (0,
"%s%c", tmp, 0));
241 u8 **strings_to_free = 0;
249 vec_add1 (strings_to_free, (u8 *) (p->key));
250 vec_add1 (strings_to_free, (u8 *) (p->value[0]));
254 for (i = 0; i <
vec_len (strings_to_free); i++)
i8 * clib_macro_eval_dollar(macro_main_t *mm, i8 *s, i32 complain)
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 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)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
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)
Iterate over hash pairs.
#define hash_get_mem(h, key)