/[cvs]/stack/stack.c
ViewVC logotype

Diff of /stack/stack.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by teddy, Mon Jan 7 23:31:34 2002 UTC revision 1.4 by masse, Mon Jan 7 23:35:37 2002 UTC
# Line 11  Line 11 
11    
12  typedef struct stack_item  typedef struct stack_item
13  {  {
14    enum {value, string, ref, func} type;    enum {value, string, ref, func, symbol} type;
15    union {    union {
16      void* ptr;      void* ptr;
17      int val;      int val;
# Line 110  void def_func(hashtbl in_hashtbl, funcp Line 110  void def_func(hashtbl in_hashtbl, funcp
110    mk_hashentry(in_hashtbl, temp, id);    mk_hashentry(in_hashtbl, temp, id);
111  }  }
112    
113    void def_sym(hashtbl in_hashtbl, const char* id)
114    {
115      stackitem* temp= malloc(sizeof(stackitem));
116      
117      temp->type= symbol;
118    
119      mk_hashentry(in_hashtbl, temp, id);
120    }
121    
122  int push_ref(stackitem** stack_head, hashtbl in_hash, const char* in_string)  int push_ref(stackitem** stack_head, hashtbl in_hash, const char* in_string)
123  {  {
124    void* handle;    void* handle;
# Line 122  int push_ref(stackitem** stack_head, has Line 131  int push_ref(stackitem** stack_head, has
131    if(new_item->content.ptr==NULL) {    if(new_item->content.ptr==NULL) {
132      handle= dlopen(NULL, RTLD_LAZY);      handle= dlopen(NULL, RTLD_LAZY);
133      symbol= dlsym(handle, in_string);      symbol= dlsym(handle, in_string);
134      if(dlerror()==NULL) {      if(dlerror()==NULL)
135        def_func(in_hash, symbol, in_string);        def_func(in_hash, symbol, in_string);
136        new_item->content.ptr= *hash(in_hash, in_string);      else
137        new_item->type= ref;        def_sym(in_hash, in_string);
138      }        
139        new_item->content.ptr= *hash(in_hash, in_string);
140        new_item->type= ref;
141    }    }
142    
143    push(stack_head, new_item);    push(stack_head, new_item);
# Line 157  void print_st(stackitem* stack_head, lon Line 168  void print_st(stackitem* stack_head, lon
168      break;      break;
169    case ref:    case ref:
170    case func:    case func:
171      case symbol:
172      printf("%ld: %p\n", counter, stack_head->content.ptr);      printf("%ld: %p\n", counter, stack_head->content.ptr);
173      break;      break;
174    }    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26