--- stack/stack.c 2002/01/07 23:31:34 1.3 +++ stack/stack.c 2002/01/07 23:35:37 1.4 @@ -11,7 +11,7 @@ typedef struct stack_item { - enum {value, string, ref, func} type; + enum {value, string, ref, func, symbol} type; union { void* ptr; int val; @@ -110,6 +110,15 @@ mk_hashentry(in_hashtbl, temp, id); } +void def_sym(hashtbl in_hashtbl, const char* id) +{ + stackitem* temp= malloc(sizeof(stackitem)); + + temp->type= symbol; + + mk_hashentry(in_hashtbl, temp, id); +} + int push_ref(stackitem** stack_head, hashtbl in_hash, const char* in_string) { void* handle; @@ -122,11 +131,13 @@ if(new_item->content.ptr==NULL) { handle= dlopen(NULL, RTLD_LAZY); symbol= dlsym(handle, in_string); - if(dlerror()==NULL) { + if(dlerror()==NULL) def_func(in_hash, symbol, in_string); - new_item->content.ptr= *hash(in_hash, in_string); - new_item->type= ref; - } + else + def_sym(in_hash, in_string); + + new_item->content.ptr= *hash(in_hash, in_string); + new_item->type= ref; } push(stack_head, new_item); @@ -157,6 +168,7 @@ break; case ref: case func: + case symbol: printf("%ld: %p\n", counter, stack_head->content.ptr); break; }