home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************
- Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
- The Netherlands.
-
- All Rights Reserved
-
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the names of Stichting Mathematisch
- Centrum or CWI not be used in advertising or publicity pertaining to
- distribution of the software without specific, written prior permission.
-
- STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
- THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
- FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- ******************************************************************/
-
- /* Support for dynamic loading of extension modules */
- /* If no dynamic linking is supported, this file still generates some code! */
-
- /* This version is completely rewritten for RISCOS using dlk */
-
- #include "allobjects.h"
- #include "osdefs.h"
- #include "importdl.h"
-
- extern int verbose; /* Defined in pythonrun.c */
-
- #ifdef DLK
- #define DYNAMIC_LINK
- #include "h.os"
- #include "h.dlk"
- extern char *getprogramname();
- #endif
-
- /* Max length of module suffix searched for -- accommodates "module.slb" */
- #ifndef MAXSUFFIXSIZE
- #define MAXSUFFIXSIZE 12
- #endif
-
- /* Pass it on to import.c */
- int import_maxsuffixsize = MAXSUFFIXSIZE;
-
- struct filedescr import_filetab[] = {
- #ifdef DYNAMIC_LINK
- {"d.", "rb", C_EXTENSION},
- #endif /* DYNAMIC_LINK */
- {"py.", "r", PY_SOURCE},
- {"pyc.", "rb", PY_COMPILED},
- {0, 0}
- };
-
- object *
- load_dynamic_module(name, pathname,fp)
- char *name;
- char *pathname;
- FILE *fp;
- {
- #ifndef DYNAMIC_LINK
- err_setstr(ImportError, "dynamically linked modules not supported");
- return NULL;
- #else
- object *m;
- int err;
- err=dlk_load(pathname);
- if(err) printf("dlk error %d\n\n", err);
- if (err) { err_setstr(ImportError,"dlk failure");return NULL;}
-
- m = dictlookup(import_modules, name);
- if (m == NULL) {
- if (err_occurred() == NULL)
- err_setstr(SystemError,
- "dynamic module not initialized properly");
- return NULL;
- }
- if (verbose)
- fprintf(stderr,
- "import %s # dynamically loaded from %s\n",
- name, pathname);
- INCREF(m);
- return m;
- #endif /* DYNAMIC_LINK */
- }
-