edfb3e24a3
bshell: the front-end binary bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts bshell.core: contains the builtin commandlets and aliases
36 lines
705 B
C
36 lines
705 B
C
#include "var-map.h"
|
|
|
|
void var_map_cleanup(struct var_map *map)
|
|
{
|
|
}
|
|
|
|
enum bshell_status var_map_put(struct var_map *map, bshell_variable *var)
|
|
{
|
|
const char *name = bshell_variable_get_name(var);
|
|
struct var_map_entry *entry = malloc(sizeof *entry);
|
|
if (!entry) {
|
|
return BSHELL_ERR_NO_MEMORY;
|
|
}
|
|
|
|
memset(entry, 0x0, sizeof *entry);
|
|
|
|
entry->e_var = var;
|
|
|
|
fx_namemap_put(&map->m_vars, name, &entry->e_entry);
|
|
return BSHELL_SUCCESS;
|
|
}
|
|
|
|
bshell_variable *var_map_get(struct var_map *map, const char *name)
|
|
{
|
|
fx_namemap_entry *e = fx_namemap_get(&map->m_vars, name);
|
|
if (!e) {
|
|
return NULL;
|
|
}
|
|
|
|
struct var_map_entry *entry = fx_unbox(
|
|
struct var_map_entry,
|
|
e,
|
|
e_entry);
|
|
return entry->e_var;
|
|
}
|