annotate src/emodules.c @ 388:aabb7f5b1c81 r21-2-9

Import from CVS: tag r21-2-9
author cvs
date Mon, 13 Aug 2007 11:09:42 +0200
parents
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
1 /* emodules.c - Support routines for dynamic module loading
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
2 (C) Copyright 1998, 1999 J. Kean Johnston. All rights reserved.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
3
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
4 This file is part of XEmacs.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
5
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
9 later version.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
10
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
14 for more details.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
15
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
20
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
21 #include "emodules.h"
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
22 #include "sysdll.h"
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
23
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
24 #ifdef HAVE_SHLIB
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
25
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
26 /* CE-Emacs version number */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
27 Lisp_Object Vmodule_version;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
28
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
29 /* Do we do our work quietly? */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
30 int load_modules_quietly;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
31
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
32 /* Load path */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
33 Lisp_Object Vmodule_load_path;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
34
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
35 typedef struct _emodules_list
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
36 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
37 int used; /* Is this slot used? */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
38 char *soname; /* Name of the shared object loaded (full path) */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
39 char *modname; /* The name of the module */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
40 char *modver; /* The version that the module is at */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
41 char *modtitle; /* How the module announces itself */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
42 dll_handle dlhandle; /* Dynamic lib handle */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
43 } emodules_list;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
44
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
45 static int emodules_depth;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
46 static dll_handle dlhandle;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
47 static emodules_list *modules;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
48 static int modnum;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
49
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
50 static int find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int make_or_find);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
51 static Lisp_Object module_load_unwind (Lisp_Object);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
52 static void attempt_module_delete (int mod);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
53
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
54 DEFUN ("load-module", Fload_module, 1, 3, "FLoad dynamic module: ", /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
55 Load in a C Emacs Extension module named FILE.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
56 The optional NAME and VERSION are used to identify specific modules.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
57
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
58 This function is similar in intent to `load' except that it loads in
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
59 pre-compiled C or C++ code, using dynamic shared objects. If NAME is
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
60 specified, then the module is only loaded if its internal name matches
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
61 the NAME specified. If VERSION is specified, then the module is only
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
62 loaded if it matches that VERSION. This function will check to make
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
63 sure that the same module is not loaded twice. Modules are searched
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
64 for in the same way as Lisp files, except that the valid file
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
65 extensions are `.so', `.dll' or `.ell'.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
66
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
67 All symbols in the shared module must be completely resolved in order
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
68 for this function to be successful. Any modules which the specified
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
69 FILE depends on will be automatically loaded. You can determine which
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
70 modules have been loaded as dynamic shared objects by examining the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
71 return value of the function `list-modules'.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
72
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
73 It is possible, although unwise, to unload modules using `unload-module'.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
74 The prefered mechanism for unloading or reloading modules is to quit
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
75 XEmacs, and then reload those new or changed modules that are required.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
76
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
77 Messages informing you of the progress of the load are displayed unless
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
78 the variable `load-modules-quietly' is non-NIL.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
79 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
80 (file,name,version))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
81 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
82 char *mod, *mname, *mver;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
83 int speccount = specpdl_depth();
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
84
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
85 CHECK_STRING(file);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
86
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
87 mod = (char *)XSTRING_DATA (file);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
88
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
89 if (NILP (name))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
90 mname = "";
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
91 else
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
92 mname = (char *)XSTRING_DATA (name);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
93
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
94 if (NILP (version))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
95 mver = "";
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
96 else
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
97 mver = (char *)XSTRING_DATA (version);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
98
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
99 dlhandle = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
100 record_unwind_protect (module_load_unwind, make_int(modnum));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
101 emodules_load (mod, mname, mver);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
102 unbind_to (speccount, Qnil);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
103
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
104 return Qt;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
105 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
106
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
107 #ifdef DANGEROUS_NASTY_SCARY_MONSTER
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
108
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
109 DEFUN ("unload-module", Fmodule_unload, 1, 3, 0, /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
110 Unload a module previously loaded with load-module.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
111
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
112 As with load-module, this function requires at least the module FILE, and
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
113 optionally the module NAME and VERSION to unload. It may not be possible
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
114 for the module to be unloaded from memory, as there may be Lisp objects
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
115 refering to variables inside the module code. However, once you have
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
116 requested a module to be unloaded, it will be unloaded from memory as
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
117 soon as the last reference to symbols within the module is destroyed.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
118 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
119 (file,name,version))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
120 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
121 int x;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
122 char *mod, *mname, *mver;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
123
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
124 CHECK_STRING(file);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
125
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
126 mod = (char *)XSTRING_DATA (file);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
127
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
128 if (NILP (name))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
129 mname = "";
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
130 else
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
131 mname = (char *)XSTRING_DATA (name);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
132
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
133 if (NILP (version))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
134 mver = "";
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
135 else
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
136 mver = (char *)XSTRING_DATA (version);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
137
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
138 x = find_make_module (mod, mname, mver, 1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
139 if (x != -1)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
140 attempt_module_delete (x);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
141 return Qt;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
142 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
143 #endif /* DANGEROUS_NASTY_SCARY_MONSTER */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
144
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
145 DEFUN ("list-modules", Flist_modules, 0, 0, "", /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
146 Produce a list of loaded dynamic modules.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
147
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
148 This function will return a list of all the loaded dynamic modules.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
149 Each element in the list is a list in the form (SONAME NAME VER DESC),
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
150 where SONAME is the name of the shared object that was loaded, NAME
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
151 is the internal module name, VER is the version of the module, and DESC
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
152 is how the module describes itself.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
153
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
154 This function returns a list, so you will need to assign the return value
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
155 to a variable and then examine the variable with `describe-variable'.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
156 For example:
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
157
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
158 (setq mylist (list-modules))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
159 (describe-variable 'mylist)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
160
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
161
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
162 NOTE: It is possible for the same module to be loaded more than once,
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
163 at different versions. However, you should never see the same module,
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
164 with the same name and version, loaded more than once. If you do, this
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
165 is a bug, and you are encouraged to report it.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
166 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
167 ())
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
168 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
169 Lisp_Object mlist = Qnil;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
170 int i;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
171
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
172 for (i = 0; i < modnum; i++)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
173 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
174 if (modules[i].used == 1)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
175 mlist = Fcons (list4 (build_string (modules[i].soname),
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
176 build_string (modules[i].modname),
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
177 build_string (modules[i].modver),
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
178 build_string (modules[i].modtitle)), mlist);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
179 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
180
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
181 return mlist;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
182 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
183
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
184 static int
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
185 find_make_module (CONST char *mod, CONST char *name, CONST char *ver, int mof)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
186 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
187 int i, fs = -1;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
188
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
189 for (i = 0; i < modnum; i++)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
190 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
191 if (fs == -1 && modules[i].used == 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
192 fs = i;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
193 if (strcmp (modules[i].soname, mod) == 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
194 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
195 if (name && name[0] && strcmp (modules[i].modname, name))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
196 continue;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
197 if (ver && ver[0] && strcmp (modules[i].modver, ver))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
198 continue;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
199 return i; /* Found a match */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
200 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
201 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
202
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
203 if (mof)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
204 return fs;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
205
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
206 if (fs != -1)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
207 return fs; /* First free slot */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
208
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
209 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
210 * We only get here if we havent found a free slot and the module was
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
211 * not previously loaded.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
212 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
213 if (modules == (emodules_list *)0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
214 modules = (emodules_list *)xmalloc (sizeof(emodules_list));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
215 modnum++;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
216 modules = xrealloc (modules, modnum * sizeof(emodules_list));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
217
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
218 fs = modnum - 1;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
219 memset (&modules[fs], 0, sizeof(emodules_list));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
220 return fs;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
221 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
222
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
223 static void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
224 attempt_module_delete (int mod)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
225 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
226 if (dll_close (modules[mod].dlhandle) == 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
227 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
228 xfree (modules[mod].soname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
229 xfree (modules[mod].modname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
230 xfree (modules[mod].modver);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
231 xfree (modules[mod].modtitle);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
232 modules[mod].dlhandle = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
233 modules[mod].used = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
234 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
235 else if (modules[mod].used > 1)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
236 modules[mod].used = 1; /* We couldn't delete it - it stays */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
237 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
238
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
239 static Lisp_Object
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
240 module_load_unwind (Lisp_Object upto)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
241 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
242 int x,l=0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
243
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
244 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
245 * First close off the current handle if it is open.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
246 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
247 if (dlhandle != 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
248 dll_close (dlhandle);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
249 dlhandle = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
250
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
251 if (CONSP (upto))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
252 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
253 if (INTP (XCAR (upto)))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
254 l = XINT (XCAR (upto));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
255 free_cons (XCONS (upto));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
256 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
257 else
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
258 l = XINT (upto);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
259
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
260 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
261 * Here we need to go through and dlclose() (IN REVERSE ORDER!) any
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
262 * modules that were loaded as part of this load chain. We only mark
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
263 * the slots as closed if the dlclose() succeeds.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
264 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
265 for (x = modnum-1; x >= l; x--)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
266 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
267 if (modules[x].used > 1)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
268 attempt_module_delete (x);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
269 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
270 emodules_depth = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
271
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
272 return Qnil;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
273 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
274
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
275 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
276 * Do the actual grunt-work of loading in a module. We first try and
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
277 * dlopen() the module. If that fails, we have an error and we bail
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
278 * out immediately. If the dlopen() succeeds, we need to check for the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
279 * existance of certain special symbols.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
280 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
281 * All modules will have complete access to the variables and functions
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
282 * defined within XEmacs itself. It is up to the module to declare any
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
283 * variables or functions it uses, however. Modules will also have access
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
284 * to other functions and variables in other loaded modules, unless they
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
285 * are defined as STATIC.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
286 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
287 * We need to be very careful with how we load modules. If we encounter an
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
288 * error along the way, we need to back out completely to the point at
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
289 * which the user started. Since we can be called resursively, we need to
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
290 * take care with marking modules as loaded. When we first start loading
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
291 * modules, we set the counter to zero. As we enter the function each time,
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
292 * we incremement the counter, and before we leave we decrement it. When
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
293 * we get back down to 0, we know we are at the end of the chain and we
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
294 * can mark all the modules in the list as loaded.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
295 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
296 * When we signal an error, we need to be sure to unwind all modules loaded
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
297 * thus far (but only for this module chain). It is assumed that if any
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
298 * modules in a chain fail, then they all do. This is logical, considering
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
299 * that the only time we recurse is when we have dependant modules. So in
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
300 * the error handler we take great care to close off the module chain before
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
301 * we call "error" and let the Fmodule_load unwind_protect() function handle
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
302 * the cleaning up.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
303 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
304 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
305 emodules_load(CONST char *module, CONST char *modname, CONST char *modver)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
306 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
307 Lisp_Object filename;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
308 Lisp_Object foundname;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
309 int fd, x, mpx;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
310 char *soname, *tmod;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
311 CONST char **f;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
312 CONST long *ellcc_rev;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
313 char *mver, *mname, *mtitle, *symname;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
314 void (*modload)(void) = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
315 void (*modsyms)(void) = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
316 void (*modvars)(void) = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
317 void (*moddocs)(void) = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
318 emodules_list *mp;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
319 struct gcpro gcpro1,gcpro2;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
320
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
321 filename = Qnil;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
322 foundname = Qnil;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
323
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
324 emodules_depth++;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
325 dlhandle = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
326
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
327 if ((module == (CONST char *)0) || (module[0] == '\0'))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
328 error ("Empty module name");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
329
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
330 /* This is to get around the fact that build_string() is not declared
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
331 as taking a const char * as an argument. I HATE compiler warnings. */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
332 tmod = (char *)alloca (strlen (module) + 1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
333 strcpy (tmod, module);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
334
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
335 GCPRO2(filename, foundname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
336 filename = build_string (tmod);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
337 fd = locate_file(Vmodule_load_path, filename, ":.ell:.so:.dll", &foundname, -1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
338 UNGCPRO;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
339
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
340 if (fd < 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
341 signal_simple_error ("Cannot open dynamic module", filename);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
342
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
343 soname = (char *)alloca (XSTRING_LENGTH (foundname) + 1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
344 strcpy (soname, (char *)XSTRING_DATA (foundname));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
345
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
346 dlhandle = dll_open (soname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
347 if (dlhandle == (dll_handle)0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
348 error ("Opening dynamic module: %s", dll_error (dlhandle));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
349
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
350 ellcc_rev = (CONST long *)dll_variable (dlhandle, "emodule_compiler");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
351 if ((ellcc_rev == (CONST long *)0) || (*ellcc_rev <= 0))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
352 error ("Missing symbol `emodule_compiler': Invalid dynamic module");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
353 if (*ellcc_rev > EMODULES_REVISION)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
354 error ("Unsupported version `%ld(%ld)': Invalid dynamic module",
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
355 *ellcc_rev, EMODULES_REVISION);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
356
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
357 f = (CONST char **)dll_variable (dlhandle, "emodule_name");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
358 if ((f == (CONST char **)0) || (*f == (CONST char *)0))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
359 error ("Missing symbol `emodule_name': Invalid dynamic module");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
360
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
361 mname = (char *)alloca (strlen (*f) + 1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
362 strcpy (mname, *f);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
363 if (mname[0] == '\0')
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
364 error ("Empty value for `emodule_name': Invalid dynamic module");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
365
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
366 f = (CONST char **)dll_variable (dlhandle, "emodule_version");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
367 if ((f == (CONST char **)0) || (*f == (CONST char *)0))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
368 error ("Missing symbol `emodule_version': Invalid dynamic module");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
369
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
370 mver = (char *)alloca (strlen (*f) + 1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
371 strcpy (mver, *f);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
372
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
373 f = (CONST char **)dll_variable (dlhandle, "emodule_title");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
374 if ((f == (CONST char **)0) || (*f == (CONST char *)0))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
375 error ("Missing symbol `emodule_title': Invalid dynamic module");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
376
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
377 mtitle = (char *)alloca (strlen (*f) + 1);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
378 strcpy (mtitle, *f);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
379
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
380 symname = (char *)alloca (strlen (mname) + 15);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
381
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
382 strcpy (symname, "modules_of_");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
383 strcat (symname, mname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
384 modload = (void (*)(void))dll_function (dlhandle, symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
385 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
386 * modload is optional. If the module doesnt require other modules it can
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
387 * be left out.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
388 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
389
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
390 strcpy (symname, "syms_of_");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
391 strcat (symname, mname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
392 modsyms = (void (*)(void))dll_function (dlhandle, symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
393 if (modsyms == (void (*)(void))0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
394 error ("Missing symbol `%s': Invalid dynamic module", symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
395
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
396 strcpy (symname, "vars_of_");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
397 strcat (symname, mname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
398 modvars = (void (*)(void))dll_function (dlhandle, symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
399 if (modvars == (void (*)(void))0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
400 error ("Missing symbol `%s': Invalid dynamic module", symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
401
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
402 strcpy (symname, "docs_of_");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
403 strcat (symname, mname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
404 moddocs = (void (*)(void))dll_function (dlhandle, symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
405 if (moddocs == (void (*)(void))0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
406 error ("Missing symbol `%s': Invalid dynamic module", symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
407
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
408 if (modname && modname[0] && strcmp (modname, mname))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
409 error ("Module name mismatch");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
410
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
411 if (modver && modver[0] && strcmp (modver, mver))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
412 error ("Module version mismatch");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
413
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
414 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
415 * Attempt to make a new slot for this module. If this really is the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
416 * first time we are loading this module, the used member will be 0.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
417 * If that is non-zero, we know that we have a previously loaded module
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
418 * of the same name and version, and we dont need to go any further.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
419 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
420 mpx = find_make_module (soname, mname, mver, 0);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
421 mp = &modules[mpx];
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
422 if (mp->used > 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
423 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
424 emodules_depth--;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
425 dll_close (dlhandle);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
426 return;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
427 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
428
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
429 if (!load_modules_quietly)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
430 message ("Loading %s v%s (%s)", mname, mver, mtitle);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
431
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
432 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
433 * We have passed the basic initialization, and can now add this
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
434 * module to the list of modules.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
435 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
436 mp->used = emodules_depth + 1;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
437 mp->soname = xstrdup (soname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
438 mp->modname = xstrdup (mname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
439 mp->modver = xstrdup (mver);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
440 mp->modtitle = xstrdup (mtitle);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
441 mp->dlhandle = dlhandle;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
442 dlhandle = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
443
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
444 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
445 * Now we need to call the module init function and perform the various
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
446 * startup tasks.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
447 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
448 if (modload != 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
449 (*modload)();
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
450
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
451 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
452 * Now we can get the module to initialize its symbols, and then its
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
453 * variables, and lastly the documentation strings.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
454 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
455 (*modsyms)();
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
456 (*modvars)();
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
457 (*moddocs)();
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
458
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
459 if (!load_modules_quietly)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
460 message ("Loaded module %s v%s (%s)", mname, mver, mtitle);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
461
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
462
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
463 emodules_depth--;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
464 if (emodules_depth == 0)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
465 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
466 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
467 * We have reached the end of the load chain. We now go through the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
468 * list of loaded modules and mark all the valid modules as just
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
469 * that.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
470 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
471 for (x = 0; x < modnum; x++)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
472 if (modules[x].used > 1)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
473 modules[x].used = 1;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
474 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
475 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
476
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
477 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
478 emodules_doc_subr(CONST char *symname, CONST char *doc)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
479 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
480 Bytecount len = strlen (symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
481 Lisp_Object sym = oblookup (Vobarray, (CONST Bufbyte *)symname, len);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
482 struct Lisp_Subr *subr;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
483
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
484 if (SYMBOLP(sym))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
485 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
486 subr = XSUBR( XSYMBOL(sym)->function);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
487 subr->doc = xstrdup (doc);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
488 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
489 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
490 * FIXME: I wish there was some way to avoid the xstrdup(). Is it
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
491 * possible to just set a pointer to the string, or somehow create a
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
492 * symbol whose value we can point to the constant string? Can someone
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
493 * look into this?
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
494 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
495 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
496
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
497 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
498 emodules_doc_sym (CONST char *symname, CONST char *doc)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
499 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
500 Bytecount len = strlen (symname);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
501 Lisp_Object sym = oblookup (Vobarray, (CONST Bufbyte *)symname, len);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
502 Lisp_Object docstr;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
503 struct gcpro gcpro1;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
504
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
505 if (SYMBOLP(sym))
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
506 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
507 docstr = build_string (doc);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
508 GCPRO1(docstr);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
509 Fput (sym, Qvariable_documentation, docstr);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
510 UNGCPRO;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
511 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
512 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
513
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
514
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
515 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
516 syms_of_module (void)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
517 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
518 DEFSUBR(Fload_module);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
519 DEFSUBR(Flist_modules);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
520 #ifdef DANGEROUS_NASTY_SCARY_MONSTER
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
521 DEFSUBR(Funload_module);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
522 #endif
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
523 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
524
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
525 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
526 vars_of_module (void)
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
527 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
528 DEFVAR_LISP ("module-version", &Vmodule_version /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
529 Emacs dynamic loading mechanism version, as a string.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
530
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
531 This string is in the form XX.YY.ppp, where XX is the major version
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
532 number, YY is the minor version number, and ppp is the patch level.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
533 This variable can be used to distinquish between different versions of
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
534 the dynamic loading technology used in Emacs, if required. It is not
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
535 a given that this value will be the same as the Emacs version number.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
536 */ );
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
537 Vmodule_version = Fpurecopy (build_string (EMODULES_VERSION));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
538
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
539 DEFVAR_BOOL ("load-modules-quietly", &load_modules_quietly /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
540 *Set to t if module loading is to be silent.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
541
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
542 Normally, when loading dynamic modules, Emacs will inform you of its
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
543 progress, and will display the module name and version if the module
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
544 is loaded correctly. Setting this variable to `t' will suppress these
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
545 messages. This would normally only be done if `load-module' was being
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
546 called by a Lisp function.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
547 */);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
548
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
549 DEFVAR_LISP ("module-load-path", &Vmodule_load_path /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
550 *List of directories to search for dynamic modules to load.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
551 Each element is a string (directory name) or nil (try default directory).
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
552
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
553 Note that elements of this list *may not* begin with "~", so you must
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
554 call `expland-file-name' on them before adding them to this list.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
555
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
556 Initialized based on EMACSMODULEPATH environment variable, if any, otherwise
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
557 to default specified the file `paths.h' when XEmacs was built. If there
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
558 were no paths specified in `paths.h', then XEmacs chooses a default
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
559 value for this variable by looking around in the file-system near the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
560 directory in which the XEmacs executable resides.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
561
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
562 Due to the nature of dynamic modules, the path names should almost always
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
563 refer to architecture-dependant directories. It is unwise to attempt to
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
564 store dynamic modules in a hetrogenous environment. Some environments
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
565 are similar enough to each other that XEmacs will be unable to determine
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
566 the correctness of a dynamic module, which can have unpredictable results
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
567 when a dynamic module is loaded.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
568 */);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
569
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
570 load_modules_quietly = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
571 emodules_depth = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
572 modules = (emodules_list *)0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
573 modnum = 0;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
574 Vmodule_load_path = Qnil;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
575 Fprovide (intern ("modules"));
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
576 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
577
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
578 #endif /* HAVE_SHLIB */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
579