version 1.51, 2000/12/07 00:15:43 |
version 1.52, 2001/03/02 16:57:26 |
|
|
char name[1]; /* the variable's name */ |
char name[1]; /* the variable's name */ |
} Var; |
} Var; |
|
|
static struct hash_info var_info = { |
static struct ohash_info var_info = { |
offsetof(Var, name), |
offsetof(Var, name), |
NULL, hash_alloc, hash_free, element_alloc }; |
NULL, hash_alloc, hash_free, element_alloc }; |
static int quick_lookup __P((const char *, const char **, u_int32_t *)); |
static int quick_lookup __P((const char *, const char **, u_int32_t *)); |
|
|
{ |
{ |
size_t len; |
size_t len; |
|
|
*pk = hash_interval(name, end); |
*pk = ohash_interval(name, end); |
len = *end - name; |
len = *end - name; |
/* substitute short version for long local name */ |
/* substitute short version for long local name */ |
switch (*pk % MAGICSLOTS) { /* MAGICSLOTS should be the */ |
switch (*pk % MAGICSLOTS) { /* MAGICSLOTS should be the */ |
|
|
Var *v; |
Var *v; |
const char *end = NULL; |
const char *end = NULL; |
|
|
v = hash_create_entry(&var_info, name, &end); |
v = ohash_create_entry(&var_info, name, &end); |
|
|
if (val != NULL) { |
if (val != NULL) { |
size_t len = strlen(val); |
size_t len = strlen(val); |
|
|
const char *end; |
const char *end; |
u_int32_t k; |
u_int32_t k; |
{ |
{ |
return hash_find(ctxt, hash_lookup_interval(ctxt, name, end, k)); |
return ohash_find(ctxt, ohash_lookup_interval(ctxt, name, end, k)); |
} |
} |
|
|
/*- |
/*- |
|
|
Parse_Error(PARSE_FATAL, "Trying to set dynamic variable %s", |
Parse_Error(PARSE_FATAL, "Trying to set dynamic variable %s", |
v->name); |
v->name); |
else |
else |
hash_insert(ctxt, hash_lookup_interval(ctxt, name, end, k), v); |
ohash_insert(ctxt, ohash_lookup_interval(ctxt, name, end, k), v); |
return v; |
return v; |
} |
} |
|
|
|
|
if (DEBUG(VAR)) |
if (DEBUG(VAR)) |
printf("%s:delete %s\n", context_name(ctxt), name); |
printf("%s:delete %s\n", context_name(ctxt), name); |
(void)quick_lookup(name, &end, &k); |
(void)quick_lookup(name, &end, &k); |
v = hash_remove(ctxt, hash_lookup_interval(ctxt, name, end, k)); |
v = ohash_remove(ctxt, ohash_lookup_interval(ctxt, name, end, k)); |
|
|
if (v != NULL) |
if (v != NULL) |
VarDelete(v); |
VarDelete(v); |
|
|
VAR_GLOBAL = &global_vars; |
VAR_GLOBAL = &global_vars; |
VAR_CMD = &cmd_vars; |
VAR_CMD = &cmd_vars; |
VAR_ENV = &env_vars; |
VAR_ENV = &env_vars; |
hash_init(VAR_GLOBAL, 10, &var_info); |
ohash_init(VAR_GLOBAL, 10, &var_info); |
hash_init(VAR_CMD, 5, &var_info); |
ohash_init(VAR_CMD, 5, &var_info); |
hash_init(VAR_ENV, 5, &var_info); |
ohash_init(VAR_ENV, 5, &var_info); |
CTXT_GLOBAL = (SymTable *)VAR_GLOBAL; |
CTXT_GLOBAL = (SymTable *)VAR_GLOBAL; |
CTXT_CMD = (SymTable *)VAR_CMD; |
CTXT_CMD = (SymTable *)VAR_CMD; |
CTXT_ENV = (SymTable *)VAR_ENV; |
CTXT_ENV = (SymTable *)VAR_ENV; |
|
|
Var *v; |
Var *v; |
unsigned int i; |
unsigned int i; |
|
|
for (v = hash_first(VAR_GLOBAL, &i); v != NULL; |
for (v = ohash_first(VAR_GLOBAL, &i); v != NULL; |
v = hash_next(VAR_GLOBAL, &i)) |
v = ohash_next(VAR_GLOBAL, &i)) |
VarDelete(v); |
VarDelete(v); |
for (v = hash_first(VAR_CMD, &i); v != NULL; |
for (v = ohash_first(VAR_CMD, &i); v != NULL; |
v = hash_next(VAR_CMD, &i)) |
v = ohash_next(VAR_CMD, &i)) |
VarDelete(v); |
VarDelete(v); |
for (v = hash_first(VAR_ENV, &i); v != NULL; |
for (v = ohash_first(VAR_ENV, &i); v != NULL; |
v = hash_next(VAR_ENV, &i)) |
v = ohash_next(VAR_ENV, &i)) |
VarDelete(v); |
VarDelete(v); |
#endif |
#endif |
} |
} |
|
|
Var *v; |
Var *v; |
unsigned int i; |
unsigned int i; |
|
|
for (v = hash_first(ctxt, &i); v != NULL; |
for (v = ohash_first(ctxt, &i); v != NULL; |
v = hash_next(ctxt, &i)) |
v = ohash_next(ctxt, &i)) |
VarPrintVar(v); |
VarPrintVar(v); |
} |
} |
|
|
|
|
|
|
Buf_Init(&buf, MAKE_BSIZE); |
Buf_Init(&buf, MAKE_BSIZE); |
|
|
for (v = hash_first(VAR_CMD, &i); v != NULL; |
for (v = ohash_first(VAR_CMD, &i); v != NULL; |
v = hash_next(VAR_CMD, &i)) { |
v = ohash_next(VAR_CMD, &i)) { |
/* We assume variable names don't need quoting */ |
/* We assume variable names don't need quoting */ |
Buf_AddString(&buf, v->name); |
Buf_AddString(&buf, v->name); |
Buf_AddChar(&buf, '='); |
Buf_AddChar(&buf, '='); |