pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: dynamic_load.c,v 1.78 2004/03/21 19:44:23 grubba Exp $ + || $Id: dynamic_load.c,v 1.79 2004/03/22 17:42:07 mast Exp $   */      #ifdef TESTING   #define NO_PIKE_INCLUDES   #define CREATE_MAIN   #define NO_PIKE_GUTS   #endif      #ifndef NO_PIKE_INCLUDES   # include "global.h"   # include "interpret.h"   # include "constants.h"   # include "pike_error.h"   # include "module.h"   # include "stralloc.h"   # include "pike_macros.h"   # include "main.h"   # include "constants.h"   # include "language.h"   # include "lex.h" -  + # include "object.h"    - RCSID("$Id: dynamic_load.c,v 1.78 2004/03/21 19:44:23 grubba Exp $"); + RCSID("$Id: dynamic_load.c,v 1.79 2004/03/22 17:42:07 mast Exp $");      #else /* TESTING */      #include <stdio.h>      #endif /* !TESTING */      #ifdef HAVE_ERRNO_H   #include <errno.h>   #endif /* HAVE_ERRNO_H */
pike.git/src/dynamic_load.c:433:    struct pike_string *module_name;       ONERROR err;       struct compilation_save save;       module_name = Pike_sp[-args].u.string;       if((Pike_sp[-args].type != T_STRING) ||    (module_name->size_shift) || -  (strlen(module_name->str) != module_name->len)) { +  ((INT32) strlen(module_name->str) != module_name->len)) {    Pike_error("Bad argument 1 to load_module()\n");    }       {    struct module_list *mp;    for (mp = dynamic_module_list; mp; mp = mp->next)    if (mp->name == module_name && mp->module_prog) {    pop_n_elems(args);    ref_push_program(mp->module_prog);    return;
pike.git/src/dynamic_load.c:456:       /* Removing RTLD_GLOBAL breaks some PiGTK themes - Hubbe */    /* Using RTLD_LAZY is faster, but makes it impossible to    * detect linking problems at runtime..    */    module=dlopen(module_name->str,    RTLD_NOW /*|RTLD_GLOBAL*/ );       if(!module)    { +  struct object *err_obj = low_clone (dlopen_error_program); + #define DLERR_STRUCT(OBJ) \ +  ((struct dlopen_error_struct *) (err_obj->storage + dlopen_error_offset)) +     const char *err = dlerror(); -  if(!err) err = "Unknown reason"; +  if (err) { +  if (err[strlen (err) - 1] == '\n') +  push_string (make_shared_binary_string (err, strlen (err) - 1)); +  else +  push_text (err); +  } +  else +  push_constant_text ("Unknown reason"); +  +  add_ref (DLERR_STRUCT (err_obj)->path = Pike_sp[-args - 1].u.string); +  add_ref (DLERR_STRUCT (err_obj)->dlerror = Pike_sp[-1].u.string); +     if (Pike_sp[-args].u.string->len < 1024) { -  Pike_error("load_module(\"%s\") failed: %s\n", -  module_name->str, err); +  throw_error_object (err_obj, "load_module", Pike_sp - args - 1, args, +  "load_module(\"%s\") failed: %s\n", +  module_name->str, Pike_sp[-1].u.string->str);    } else { -  Pike_error("load_module() failed: %s\n", err); +  throw_error_object (err_obj, "load_module", Pike_sp - args - 1, args, +  "load_module() failed: %s\n", +  Pike_sp[-1].u.string->str);    }    }      #ifdef PIKE_DEBUG    {    struct module_list *mp;    for (mp = dynamic_module_list; mp; mp = mp->next)    if (mp->module == module && mp->module_prog) {    fprintf(stderr, "load_module(): Module loaded twice:\n"    "Old name: %s\n"