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);
__clib_export void clib_macro_free(clib_macro_main_t *mm)
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)
__clib_export i8 * clib_macro_eval(clib_macro_main_t *mm, i8 *s, i32 complain, u16 level, u16 max_level)
__clib_export int clib_macro_unset(clib_macro_main_t *mm, char *name)
__clib_export void clib_macro_init(clib_macro_main_t *mm)
__clib_export u8 * format_clib_macro_main(u8 *s, va_list *args)
description fragment has unexpected format
#define hash_get_pair(h, key)
#define hash_create_string(elts, value_bytes)
#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).
#define clib_warning(format, args...)
uword * the_builtin_eval_hash
__clib_export int clib_macro_set_value(clib_macro_main_t *mm, char *name, char *value)
#define vec_append(v1, v2)
Append v2 after v1.
#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)
#define hash_get_mem(h, key)
__clib_export void clib_macro_add_builtin(clib_macro_main_t *mm, char *name, void *eval_fn)
i8 * clib_macro_get_value(clib_macro_main_t *mm, char *name)