Changeset 180 for trunk/sm/mm.c

Show
Ignore:
Timestamp:
28/04/07 23:56:58 (19 months ago)
Author:
smoku
Message:

Dynamically loading auth/reg/storage modules. Closes #52

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/sm/mm.c

    r161 r180  
    4646    mm_t mm; 
    4747    int celem, melem, attr, *nlist = NULL; 
    48     char id[13], name[32], mod_fullpath[512], arg[1024], *modules_path; 
     48    char id[13], name[32], mod_fullpath[PATH_MAX], arg[1024], *modules_path; 
    4949    mod_chain_t chain = (mod_chain_t) NULL; 
    5050    mod_instance_t **list = NULL, mi; 
     
    6464        log_write(sm->log, LOG_NOTICE, "modules search path: %s", modules_path); 
    6565    else 
    66         log_write(sm->log, LOG_WARNING, "modules search path undefined !"); 
     66        log_write(sm->log, LOG_NOTICE, "modules search path undefined, using deafult: "LIBRARY_DIR); 
    6767 
    6868    celem = nad_find_elem(sm->config->nad, celem, -1, "chain", 1); 
     
    173173                #ifndef WIN32 
    174174                  if (modules_path != NULL) 
    175                       snprintf(mod_fullpath, 512, "%s/mod_%s.so", modules_path, name); 
     175                      snprintf(mod_fullpath, PATH_MAX, "%s/mod_%s.so", modules_path, name); 
    176176                  else 
    177                       snprintf(mod_fullpath, 512, "%s/mod_%s.so", LIBRARY_DIR, name); 
     177                      snprintf(mod_fullpath, PATH_MAX, "%s/mod_%s.so", LIBRARY_DIR, name); 
    178178                  mod->handle = dlopen(mod_fullpath, RTLD_LAZY); 
    179179                  if (mod->handle != NULL) 
     
    181181                #else 
    182182                  if (modules_path != NULL) 
    183                       snprintf(mod_fullpath, 512, "%smod_%s.dll", modules_path, name); 
     183                      snprintf(mod_fullpath, PATH_MAX, "%s\\mod_%s.dll", modules_path, name); 
    184184                  else 
    185                       snprintf(mod_fullpath, 512, "mod_%s.dll", name); 
     185                      snprintf(mod_fullpath, PATH_MAX, "mod_%s.dll", name); 
    186186                  mod->handle = (void*) LoadLibrary(mod_fullpath); 
    187187                  if (mod->handle != NULL)