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);
99 i8 *varname, *varvalue;
102 if (level >= max_level)
106 return (
i8 *)
format (0,
" CIRCULAR ");
128 while (*s && (
macro_isalnum (*s) || (*s ==
'_') || (*s ==
'(')))
135 while (*s && *s !=
')')
157 varvalue = (
i8 *)
format (0,
"%s%c", tmp, 0);
163 char *tmp = getenv ((
char *) varname);
165 varvalue = (
i8 *)
format (0,
"%s%c", tmp, 0);
178 _vec_len (rv) =
vec_len (rv) - 1;
184 clib_warning (
"Undefined Variable Reference: %s\n", varname);
186 _vec_len (rv) =
vec_len (rv) - 1;
206 s2 = (
i8 *)
format (0,
"$(%s)%c", s, 0);
223 if (gethostname (tmp,
sizeof (tmp)))
224 return ((
i8 *)
format (0,
"gethostname-error%c", 0));
225 return ((
i8 *)
format (0,
"%s%c", tmp, 0));
250 u8 **strings_to_free = 0;
258 vec_add1 (strings_to_free, (u8 *) (p->key));
259 vec_add1 (strings_to_free, (u8 *) (p->value[0]));
263 for (i = 0; i <
vec_len (strings_to_free); i++)
281 return strcmp ((
char *) ns1->
name, (
char *) ns2->
name);
289 int evaluate = va_arg (*args,
int);
297 vec_add2 (nses, ns, 1);
298 ns->name = (u8 *)(p->key);
299 ns->value = (u8 *)(p->value[0]);
308 for (i = 0; i <
vec_len (nses); i++)
317 s =
format (s,
"%s\n", rv);
static int macro_isalnum(i8 c)
uword * the_value_table_hash
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define hash_set_mem(h, key, value)
void clib_macro_add_builtin(clib_macro_main_t *mm, char *name, void *eval_fn)
#define hash_get_pair(h, key)
#define hash_create_string(elts, value_bytes)
int clib_macro_set_value(clib_macro_main_t *mm, char *name, char *value)
#define hash_unset_mem(h, key)
static i8 * eval_hostname(clib_macro_main_t *mm, i32 complain)
i8 * clib_macro_eval_dollar(clib_macro_main_t *mm, i8 *s, i32 complain)
static i8 * builtin_eval(clib_macro_main_t *mm, i8 *varname, i32 complain)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
void clib_macro_free(clib_macro_main_t *mm)
#define clib_warning(format, args...)
uword * the_builtin_eval_hash
#define vec_append(v1, v2)
Append v2 after v1.
u8 * format_clib_macro_main(u8 *s, va_list *args)
int clib_macro_unset(clib_macro_main_t *mm, char *name)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static int name_compare(void *a1, void *a2)
void clib_macro_init(clib_macro_main_t *mm)
#define hash_get_mem(h, key)
i8 * clib_macro_eval(clib_macro_main_t *mm, i8 *s, i32 complain, u16 level, u16 max_level)
i8 * clib_macro_get_value(clib_macro_main_t *mm, char *name)