/[hydra]/hydra/src/hic_modules.c
ViewVC logotype

Diff of /hydra/src/hic_modules.c

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

revision 1.6 by nmav, Sat Sep 28 18:32:05 2002 UTC revision 1.7 by nmav, Wed Jan 22 07:51:50 2003 UTC
# Line 106  hic_module_st* old, *start; Line 106  hic_module_st* old, *start;
106    
107      handle = dlopen( module, RTLD_NOW);      handle = dlopen( module, RTLD_NOW);
108      if ( handle==NULL) {      if ( handle==NULL) {
109         fprintf(stderr, "Could not load module '%s'. Dlopen failed.\n", module);         fprintf(stderr, "Could not load module '%s'. Dlopen failed: %s\n", module, dlerror());
110         exit(1);         exit(1);
111      }      }
112      old->dl_handle = handle;      old->dl_handle = handle;
# Line 154  hic_module_st* old, *start; Line 154  hic_module_st* old, *start;
154  #endif  #endif
155  }  }
156    
157    
158    /* add_hic_action
159     *
160     * Like add_hic_module() but associates the file type with a
161     * specific action (executable to run with)
162     */
163    
164    void add_hic_action(const char *action, const char* file_type)
165    {
166    int hash;
167    hic_module_st* old, *start;
168    
169        /* sanity checking */
170        if (action == NULL || file_type == NULL) {
171            DIE("NULL values sent to add_hic_action");
172        }
173    
174        hash = get_hic_module_hash_value( file_type);
175        start = old = module_hashtable[hash];
176        
177        if ( old != NULL) {
178           /* find next empty */
179           do {
180              hash = (hash + 1) % MODULE_HASHTABLE_SIZE;
181              
182              old = module_hashtable[hash];
183    
184              if (start == old) {
185                 DIE("Module hashtable is full.");
186              }
187              
188           } while( old != NULL);
189        }
190        
191        /* old was found, and is empty. */
192        
193        old = malloc( sizeof(hic_module_st));
194        if (old==NULL) {
195           DIE("malloc() failed.");
196        }
197    
198        old->sym_prefix = NULL;
199    
200        old->content_type = strdup( file_type);
201        if (old->content_type == NULL) {
202           DIE("strdup() failed.");
203        }
204    
205        old->content_type_len = strlen( file_type);
206    
207        old->action = strdup( action);
208        if ( old->action == NULL) {
209           DIE("strdup() failed.");    
210        }
211    
212        old->dl_handle = NULL;
213        old->shutdown = NULL;
214        old->init = NULL;
215        old->request = NULL;
216    
217        module_hashtable[hash] = old;
218    
219        return;
220    }
221    
222  /*  /*
223   * Name: find_hic_appr_module   * Name: find_hic_appr_module
224   *   *
# Line 196  int i, hash; Line 261  int i, hash;
261    
262  void dump_hic_modules(void)  void dump_hic_modules(void)
263  {  {
 #ifdef ENABLE_HIC  
264  int i;  int i;
265    
266      for (i = 0; i < MODULE_HASHTABLE_SIZE; ++i) { /* these limits OK? */      for (i = 0; i < MODULE_HASHTABLE_SIZE; ++i) { /* these limits OK? */
267          if (!module_hashtable[i]) continue;          if (!module_hashtable[i]) continue;
268    
269    #ifdef ENABLE_HIC
270          free( module_hashtable[i]->sym_prefix);          free( module_hashtable[i]->sym_prefix);
271          free( module_hashtable[i]->content_type);          free( module_hashtable[i]->content_type);
272          module_hashtable[i]->shutdown(); /* Run the deinitialization stuff */  
273          dlclose( module_hashtable[i]->dl_handle);          if (module_hashtable[i]->shutdown)
274               module_hashtable[i]->shutdown(); /* Run the deinitialization stuff */
275    
276            if (module_hashtable[i]->dl_handle)
277               dlclose( module_hashtable[i]->dl_handle);
278    #endif
279    
280            free( module_hashtable[i]->action);
281    
282          free( module_hashtable[i]);          free( module_hashtable[i]);
283          module_hashtable[i] = NULL;          module_hashtable[i] = NULL;
284      }      }
 #endif  
285  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26