Mercurial > hg > xemacs-beta
diff src/emodules.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | aabb7f5b1c81 |
children | 697ef44129c6 |
line wrap: on
line diff
--- a/src/emodules.c Mon Aug 13 11:12:06 2007 +0200 +++ b/src/emodules.c Mon Aug 13 11:13:30 2007 +0200 @@ -42,12 +42,14 @@ dll_handle dlhandle; /* Dynamic lib handle */ } emodules_list; +static Lisp_Object Vmodule_extensions; + static int emodules_depth; static dll_handle dlhandle; static emodules_list *modules; static int modnum; -static int find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int make_or_find); +static int find_make_module (const char *mod, const char *name, const char *ver, int make_or_find); static Lisp_Object module_load_unwind (Lisp_Object); static void attempt_module_delete (int mod); @@ -182,7 +184,7 @@ } static int -find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int mof) +find_make_module (const char *mod, const char *name, const char *ver, int mof) { int i, fs = -1; @@ -211,9 +213,9 @@ * not previously loaded. */ if (modules == (emodules_list *)0) - modules = (emodules_list *)xmalloc (sizeof(emodules_list)); + modules = (emodules_list *) xmalloc (sizeof (emodules_list)); modnum++; - modules = xrealloc (modules, modnum * sizeof(emodules_list)); + modules = (emodules_list *) xrealloc (modules, modnum * sizeof (emodules_list)); fs = modnum - 1; memset (&modules[fs], 0, sizeof(emodules_list)); @@ -302,14 +304,14 @@ * the cleaning up. */ void -emodules_load(CONST char *module, CONST char *modname, CONST char *modver) +emodules_load(const char *module, const char *modname, const char *modver) { Lisp_Object filename; Lisp_Object foundname; int fd, x, mpx; char *soname, *tmod; - CONST char **f; - CONST long *ellcc_rev; + const char **f; + const long *ellcc_rev; char *mver, *mname, *mtitle, *symname; void (*modload)(void) = 0; void (*modsyms)(void) = 0; @@ -324,7 +326,7 @@ emodules_depth++; dlhandle = 0; - if ((module == (CONST char *)0) || (module[0] == '\0')) + if ((module == (const char *)0) || (module[0] == '\0')) error ("Empty module name"); /* This is to get around the fact that build_string() is not declared @@ -334,7 +336,8 @@ GCPRO2(filename, foundname); filename = build_string (tmod); - fd = locate_file(Vmodule_load_path, filename, ":.ell:.so:.dll", &foundname, -1); + fd = locate_file(Vmodule_load_path, filename, Vmodule_extensions, + &foundname, -1); UNGCPRO; if (fd < 0) @@ -347,15 +350,15 @@ if (dlhandle == (dll_handle)0) error ("Opening dynamic module: %s", dll_error (dlhandle)); - ellcc_rev = (CONST long *)dll_variable (dlhandle, "emodule_compiler"); - if ((ellcc_rev == (CONST long *)0) || (*ellcc_rev <= 0)) + ellcc_rev = (const long *)dll_variable (dlhandle, "emodule_compiler"); + if ((ellcc_rev == (const long *)0) || (*ellcc_rev <= 0)) error ("Missing symbol `emodule_compiler': Invalid dynamic module"); if (*ellcc_rev > EMODULES_REVISION) error ("Unsupported version `%ld(%ld)': Invalid dynamic module", *ellcc_rev, EMODULES_REVISION); - f = (CONST char **)dll_variable (dlhandle, "emodule_name"); - if ((f == (CONST char **)0) || (*f == (CONST char *)0)) + f = (const char **)dll_variable (dlhandle, "emodule_name"); + if ((f == (const char **)0) || (*f == (const char *)0)) error ("Missing symbol `emodule_name': Invalid dynamic module"); mname = (char *)alloca (strlen (*f) + 1); @@ -363,15 +366,15 @@ if (mname[0] == '\0') error ("Empty value for `emodule_name': Invalid dynamic module"); - f = (CONST char **)dll_variable (dlhandle, "emodule_version"); - if ((f == (CONST char **)0) || (*f == (CONST char *)0)) + f = (const char **)dll_variable (dlhandle, "emodule_version"); + if ((f == (const char **)0) || (*f == (const char *)0)) error ("Missing symbol `emodule_version': Invalid dynamic module"); mver = (char *)alloca (strlen (*f) + 1); strcpy (mver, *f); - f = (CONST char **)dll_variable (dlhandle, "emodule_title"); - if ((f == (CONST char **)0) || (*f == (CONST char *)0)) + f = (const char **)dll_variable (dlhandle, "emodule_title"); + if ((f == (const char **)0) || (*f == (const char *)0)) error ("Missing symbol `emodule_title': Invalid dynamic module"); mtitle = (char *)alloca (strlen (*f) + 1); @@ -475,11 +478,11 @@ } void -emodules_doc_subr(CONST char *symname, CONST char *doc) +emodules_doc_subr(const char *symname, const char *doc) { Bytecount len = strlen (symname); - Lisp_Object sym = oblookup (Vobarray, (CONST Bufbyte *)symname, len); - struct Lisp_Subr *subr; + Lisp_Object sym = oblookup (Vobarray, (const Bufbyte *)symname, len); + Lisp_Subr *subr; if (SYMBOLP(sym)) { @@ -495,10 +498,10 @@ } void -emodules_doc_sym (CONST char *symname, CONST char *doc) +emodules_doc_sym (const char *symname, const char *doc) { Bytecount len = strlen (symname); - Lisp_Object sym = oblookup (Vobarray, (CONST Bufbyte *)symname, len); + Lisp_Object sym = oblookup (Vobarray, (const Bufbyte *)symname, len); Lisp_Object docstr; struct gcpro gcpro1; @@ -523,8 +526,18 @@ } void +reinit_vars_of_module (void) +{ + emodules_depth = 0; + modules = (emodules_list *)0; + modnum = 0; +} + +void vars_of_module (void) { + reinit_vars_of_module (); + DEFVAR_LISP ("module-version", &Vmodule_version /* Emacs dynamic loading mechanism version, as a string. @@ -534,7 +547,7 @@ the dynamic loading technology used in Emacs, if required. It is not a given that this value will be the same as the Emacs version number. */ ); - Vmodule_version = Fpurecopy (build_string (EMODULES_VERSION)); + Vmodule_version = build_string (EMODULES_VERSION); DEFVAR_BOOL ("load-modules-quietly", &load_modules_quietly /* *Set to t if module loading is to be silent. @@ -567,10 +580,11 @@ when a dynamic module is loaded. */); + /* #### Export this to Lisp */ + Vmodule_extensions = build_string (":.ell:.so:.dll"); + staticpro (&Vmodule_extensions); + load_modules_quietly = 0; - emodules_depth = 0; - modules = (emodules_list *)0; - modnum = 0; Vmodule_load_path = Qnil; Fprovide (intern ("modules")); }