Commit | Line | Data |
---|---|---|
2ade72d7 | 1 | /* Copyright (C) 1995,1996,1998,1999,2000,2001 Free Software Foundation, Inc. |
0f2d19dd JB |
2 | * |
3 | * This program is free software; you can redistribute it and/or modify | |
4 | * it under the terms of the GNU General Public License as published by | |
5 | * the Free Software Foundation; either version 2, or (at your option) | |
6 | * any later version. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this software; see the file COPYING. If not, write to | |
82892bed JB |
15 | * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
16 | * Boston, MA 02111-1307 USA | |
0f2d19dd JB |
17 | * |
18 | * As a special exception, the Free Software Foundation gives permission | |
19 | * for additional uses of the text contained in its release of GUILE. | |
20 | * | |
21 | * The exception is that, if you link the GUILE library with other files | |
22 | * to produce an executable, this does not by itself cause the | |
23 | * resulting executable to be covered by the GNU General Public License. | |
24 | * Your use of that executable is in no way restricted on account of | |
25 | * linking the GUILE library code into it. | |
26 | * | |
27 | * This exception does not however invalidate any other reasons why | |
28 | * the executable file might be covered by the GNU General Public License. | |
29 | * | |
30 | * This exception applies only to the code released by the | |
31 | * Free Software Foundation under the name GUILE. If you copy | |
32 | * code from other Free Software Foundation releases into a copy of | |
33 | * GUILE, as the General Public License permits, the exception does | |
34 | * not apply to the code that you add in this way. To avoid misleading | |
35 | * anyone as to the status of such modified files, you must delete | |
36 | * this exception notice from them. | |
37 | * | |
38 | * If you write modifications of your own for GUILE, it is your choice | |
39 | * whether to permit this exception to apply to your modifications. | |
82892bed | 40 | * If you do not wish that, delete this exception notice. */ |
1bbd0b84 | 41 | |
1bbd0b84 | 42 | |
0f2d19dd JB |
43 | \f |
44 | ||
13070bd3 DH |
45 | #include <string.h> |
46 | ||
a0599745 MD |
47 | #include "libguile/_scm.h" |
48 | #include "libguile/libpath.h" | |
49 | #include "libguile/fports.h" | |
50 | #include "libguile/read.h" | |
51 | #include "libguile/eval.h" | |
52 | #include "libguile/throw.h" | |
53 | #include "libguile/alist.h" | |
54 | #include "libguile/dynwind.h" | |
55 | #include "libguile/root.h" | |
56 | #include "libguile/strings.h" | |
f33b174d | 57 | #include "libguile/modules.h" |
c96d76b8 | 58 | #include "libguile/lang.h" |
a0599745 MD |
59 | |
60 | #include "libguile/validate.h" | |
61 | #include "libguile/load.h" | |
06721500 JB |
62 | |
63 | #include <sys/types.h> | |
64 | #include <sys/stat.h> | |
65 | ||
66 | #ifdef HAVE_UNISTD_H | |
67 | #include <unistd.h> | |
68 | #endif /* HAVE_UNISTD_H */ | |
69 | ||
70 | #ifndef R_OK | |
71 | #define R_OK 4 | |
72 | #endif | |
0f2d19dd JB |
73 | |
74 | \f | |
06721500 | 75 | /* Loading a file, given an absolute filename. */ |
0f2d19dd | 76 | |
26544b96 JB |
77 | /* Hook to run when we load a file, perhaps to announce the fact somewhere. |
78 | Applied to the full name of the file. */ | |
79 | static SCM *scm_loc_load_hook; | |
80 | ||
c7023c69 | 81 | static void |
d7834b91 MD |
82 | swap_port (void *data) |
83 | { | |
84 | SCM *save_port = data, tmp = scm_cur_loadp; | |
85 | scm_cur_loadp = *save_port; | |
86 | *save_port = tmp; | |
87 | } | |
88 | ||
89 | static SCM | |
90 | load (void *data) | |
91 | { | |
54778cd3 | 92 | SCM port = SCM_PACK (data); |
d7834b91 MD |
93 | while (1) |
94 | { | |
54778cd3 | 95 | SCM form = scm_read (port); |
d7834b91 MD |
96 | if (SCM_EOF_OBJECT_P (form)) |
97 | break; | |
f1b7a066 | 98 | scm_primitive_eval_x (form); |
d7834b91 MD |
99 | } |
100 | return SCM_UNSPECIFIED; | |
101 | } | |
102 | ||
3b3b36dd | 103 | SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0, |
1bbd0b84 | 104 | (SCM filename), |
67e8151b MG |
105 | "Load the file named @var{filename} and evaluate its contents in\n" |
106 | "the top-level environment. The load paths are not searched;\n" | |
107 | "@var{filename} must either be a full pathname or be a pathname\n" | |
108 | "relative to the current directory. If the variable\n" | |
109 | "@code{%load-hook} is defined, it should be bound to a procedure\n" | |
110 | "that will be called before any code is loaded. See the\n" | |
111 | "documentation for @code{%load-hook} later in this section.") | |
1bbd0b84 | 112 | #define FUNC_NAME s_scm_primitive_load |
0f2d19dd | 113 | { |
26544b96 | 114 | SCM hook = *scm_loc_load_hook; |
a6d9e5ab | 115 | SCM_VALIDATE_STRING (1, filename); |
2ade72d7 DH |
116 | if (!SCM_FALSEP (hook) && !SCM_EQ_P (scm_procedure_p (hook), SCM_BOOL_T)) |
117 | SCM_MISC_ERROR ("value of %load-hook is neither a procedure nor #f", | |
118 | SCM_EOL); | |
26544b96 | 119 | |
54778cd3 | 120 | if (! SCM_FALSEP (hook)) |
fdc28395 | 121 | scm_call_1 (hook, filename); |
26544b96 | 122 | |
1bbd0b84 | 123 | { /* scope */ |
d7834b91 | 124 | SCM port, save_port; |
36284627 | 125 | port = scm_open_file (filename, scm_mem2string ("r", sizeof (char))); |
d7834b91 MD |
126 | save_port = port; |
127 | scm_internal_dynamic_wind (swap_port, | |
128 | load, | |
129 | swap_port, | |
54778cd3 | 130 | (void *) SCM_UNPACK (port), |
d7834b91 | 131 | &save_port); |
0f2d19dd JB |
132 | scm_close_port (port); |
133 | } | |
b59b97ba | 134 | return SCM_UNSPECIFIED; |
0f2d19dd | 135 | } |
1bbd0b84 | 136 | #undef FUNC_NAME |
0f2d19dd | 137 | |
c519b272 MV |
138 | SCM |
139 | scm_c_primitive_load (const char *filename) | |
140 | { | |
141 | return scm_primitive_load (scm_makfrom0str (filename)); | |
142 | } | |
143 | ||
0f2d19dd | 144 | \f |
3feedb00 MD |
145 | /* Builtin path to scheme library files. */ |
146 | #ifdef SCM_PKGDATA_DIR | |
a1ec6916 | 147 | SCM_DEFINE (scm_sys_package_data_dir, "%package-data-dir", 0, 0, 0, |
1bbd0b84 | 148 | (), |
b380b885 MD |
149 | "Return the name of the directory where Scheme packages, modules and\n" |
150 | "libraries are kept. On most Unix systems, this will be\n" | |
151 | "@samp{/usr/local/share/guile}.") | |
1bbd0b84 | 152 | #define FUNC_NAME s_scm_sys_package_data_dir |
3feedb00 MD |
153 | { |
154 | return scm_makfrom0str (SCM_PKGDATA_DIR); | |
155 | } | |
1bbd0b84 | 156 | #undef FUNC_NAME |
3feedb00 MD |
157 | #endif /* SCM_PKGDATA_DIR */ |
158 | ||
e8e9b690 | 159 | #ifdef SCM_LIBRARY_DIR |
a1ec6916 | 160 | SCM_DEFINE (scm_sys_library_dir, "%library-dir", 0,0,0, |
e8e9b690 | 161 | (), |
b380b885 MD |
162 | "Return the directory where the Guile Scheme library files are installed.\n" |
163 | "E.g., may return \"/usr/share/guile/1.3.5\".") | |
e8e9b690 GB |
164 | #define FUNC_NAME s_scm_sys_library_dir |
165 | { | |
166 | return scm_makfrom0str(SCM_LIBRARY_DIR); | |
167 | } | |
168 | #undef FUNC_NAME | |
169 | #endif /* SCM_LIBRARY_DIR */ | |
170 | ||
171 | #ifdef SCM_SITE_DIR | |
a1ec6916 | 172 | SCM_DEFINE (scm_sys_site_dir, "%site-dir", 0,0,0, |
e8e9b690 | 173 | (), |
b380b885 MD |
174 | "Return the directory where the Guile site files are installed.\n" |
175 | "E.g., may return \"/usr/share/guile/site\".") | |
e8e9b690 GB |
176 | #define FUNC_NAME s_scm_sys_site_dir |
177 | { | |
178 | return scm_makfrom0str(SCM_SITE_DIR); | |
179 | } | |
180 | #undef FUNC_NAME | |
181 | #endif /* SCM_SITE_DIR */ | |
182 | ||
183 | ||
184 | ||
3feedb00 | 185 | \f |
06721500 | 186 | /* Initializing the load path, and searching it. */ |
0f2d19dd | 187 | |
26544b96 | 188 | /* List of names of directories we search for files to load. */ |
06721500 JB |
189 | static SCM *scm_loc_load_path; |
190 | ||
26544b96 JB |
191 | /* List of extensions we try adding to the filenames. */ |
192 | static SCM *scm_loc_load_extensions; | |
193 | ||
01cddfc1 JB |
194 | |
195 | /* Parse the null-terminated string PATH as if it were a standard path | |
196 | environment variable (i.e. a colon-separated list of strings), and | |
197 | prepend the elements to TAIL. */ | |
198 | SCM | |
04e8fb0a | 199 | scm_internal_parse_path (char *path, SCM tail) |
01cddfc1 JB |
200 | { |
201 | if (path && path[0] != '\0') | |
202 | { | |
203 | char *scan, *elt_end; | |
204 | ||
205 | /* Scan backwards from the end of the string, to help | |
206 | construct the list in the right order. */ | |
207 | scan = elt_end = path + strlen (path); | |
208 | do { | |
209 | /* Scan back to the beginning of the current element. */ | |
210 | do scan--; | |
211 | while (scan >= path && *scan != ':'); | |
36284627 | 212 | tail = scm_cons (scm_mem2string (scan + 1, elt_end - (scan + 1)), |
01cddfc1 JB |
213 | tail); |
214 | elt_end = scan; | |
215 | } while (scan >= path); | |
216 | } | |
217 | ||
218 | return tail; | |
219 | } | |
220 | ||
221 | ||
a1ec6916 | 222 | SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0, |
1bbd0b84 | 223 | (SCM path, SCM tail), |
d91788cb MG |
224 | "Parse @var{path}, which is expected to be a colon-separated\n" |
225 | "string, into a list and return the resulting list with\n" | |
226 | "@var{tail} appended. If @var{path} is @code{#f}, @var{tail}\n" | |
227 | "is returned.") | |
1bbd0b84 | 228 | #define FUNC_NAME s_scm_parse_path |
04e8fb0a | 229 | { |
a6d9e5ab | 230 | SCM_ASSERT (SCM_FALSEP (path) || (SCM_STRINGP (path)), |
04e8fb0a | 231 | path, |
1bbd0b84 | 232 | SCM_ARG1, FUNC_NAME); |
04e8fb0a MD |
233 | if (SCM_UNBNDP (tail)) |
234 | tail = SCM_EOL; | |
235 | return (SCM_FALSEP (path) | |
236 | ? tail | |
34f0f2b8 | 237 | : scm_internal_parse_path (SCM_STRING_CHARS (path), tail)); |
04e8fb0a | 238 | } |
1bbd0b84 | 239 | #undef FUNC_NAME |
04e8fb0a MD |
240 | |
241 | ||
06721500 | 242 | /* Initialize the global variable %load-path, given the value of the |
3feedb00 | 243 | SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the |
01cddfc1 | 244 | GUILE_LOAD_PATH environment variable. */ |
0f2d19dd | 245 | void |
06721500 JB |
246 | scm_init_load_path () |
247 | { | |
248 | SCM path = SCM_EOL; | |
249 | ||
3feedb00 | 250 | #ifdef SCM_LIBRARY_DIR |
1afff620 KN |
251 | path = scm_list_3 (scm_makfrom0str (SCM_SITE_DIR), |
252 | scm_makfrom0str (SCM_LIBRARY_DIR), | |
253 | scm_makfrom0str (SCM_PKGDATA_DIR)); | |
3feedb00 | 254 | #endif /* SCM_LIBRARY_DIR */ |
06721500 | 255 | |
04e8fb0a | 256 | path = scm_internal_parse_path (getenv ("GUILE_LOAD_PATH"), path); |
01cddfc1 | 257 | |
06721500 JB |
258 | *scm_loc_load_path = path; |
259 | } | |
260 | ||
04e8fb0a | 261 | SCM scm_listofnullstr; |
06721500 | 262 | |
04e8fb0a | 263 | /* Search PATH for a directory containing a file named FILENAME. |
06721500 | 264 | The file must be readable, and not a directory. |
26544b96 | 265 | If we find one, return its full filename; otherwise, return #f. |
56384176 JB |
266 | If FILENAME is absolute, return it unchanged. |
267 | If given, EXTENSIONS is a list of strings; for each directory | |
268 | in PATH, we search for FILENAME concatenated with each EXTENSION. */ | |
3b3b36dd | 269 | SCM_DEFINE (scm_search_path, "search-path", 2, 1, 0, |
1bbd0b84 | 270 | (SCM path, SCM filename, SCM extensions), |
d91788cb MG |
271 | "Search @var{path} for a directory containing a file named\n" |
272 | "@var{filename}. The file must be readable, and not a directory.\n" | |
273 | "If we find one, return its full filename; otherwise, return\n" | |
274 | "@code{#f}. If @var{filename} is absolute, return it unchanged.\n" | |
275 | "If given, @var{extensions} is a list of strings; for each\n" | |
276 | "directory in @var{path}, we search for @var{filename}\n" | |
277 | "concatenated with each @var{extension}.") | |
1bbd0b84 | 278 | #define FUNC_NAME s_scm_search_path |
06721500 | 279 | { |
56384176 | 280 | char *filename_chars; |
06721500 | 281 | int filename_len; |
56384176 JB |
282 | size_t max_path_len; /* maximum length of any PATH element */ |
283 | size_t max_ext_len; /* maximum length of any EXTENSIONS element */ | |
06721500 | 284 | |
34d19ef6 | 285 | SCM_VALIDATE_LIST (1, path); |
a6d9e5ab | 286 | SCM_VALIDATE_STRING (2, filename); |
04e8fb0a | 287 | if (SCM_UNBNDP (extensions)) |
56384176 | 288 | extensions = SCM_EOL; |
04e8fb0a | 289 | else |
34d19ef6 | 290 | SCM_VALIDATE_LIST (3, extensions); |
56384176 | 291 | |
34f0f2b8 | 292 | filename_chars = SCM_STRING_CHARS (filename); |
a6d9e5ab | 293 | filename_len = SCM_STRING_LENGTH (filename); |
06721500 | 294 | |
26544b96 | 295 | /* If FILENAME is absolute, return it unchanged. */ |
56384176 | 296 | if (filename_len >= 1 && filename_chars[0] == '/') |
26544b96 JB |
297 | return filename; |
298 | ||
299 | /* Find the length of the longest element of path. */ | |
300 | { | |
301 | SCM walk; | |
302 | ||
303 | max_path_len = 0; | |
c96d76b8 | 304 | for (walk = path; !SCM_NULL_OR_NIL_P (walk); walk = SCM_CDR (walk)) |
26544b96 JB |
305 | { |
306 | SCM elt = SCM_CAR (walk); | |
2ade72d7 DH |
307 | SCM_ASSERT_TYPE (SCM_STRINGP (elt), path, 1, FUNC_NAME, |
308 | "list of strings"); | |
a6d9e5ab DH |
309 | if (SCM_STRING_LENGTH (elt) > max_path_len) |
310 | max_path_len = SCM_STRING_LENGTH (elt); | |
26544b96 JB |
311 | } |
312 | } | |
313 | ||
56384176 JB |
314 | /* If FILENAME has an extension, don't try to add EXTENSIONS to it. */ |
315 | { | |
316 | char *endp; | |
317 | ||
318 | for (endp = filename_chars + filename_len - 1; | |
319 | endp >= filename_chars; | |
320 | endp--) | |
321 | { | |
322 | if (*endp == '.') | |
323 | { | |
324 | /* This filename already has an extension, so cancel the | |
325 | list of extensions. */ | |
326 | extensions = SCM_EOL; | |
327 | break; | |
328 | } | |
329 | else if (*endp == '/') | |
330 | /* This filename has no extension, so keep the current list | |
331 | of extensions. */ | |
332 | break; | |
333 | } | |
334 | } | |
335 | ||
26544b96 JB |
336 | /* Find the length of the longest element of the load extensions |
337 | list. */ | |
1bbd0b84 | 338 | { /* scope */ |
26544b96 JB |
339 | SCM walk; |
340 | ||
341 | max_ext_len = 0; | |
c96d76b8 | 342 | for (walk = extensions; !SCM_NULL_OR_NIL_P (walk); walk = SCM_CDR (walk)) |
26544b96 JB |
343 | { |
344 | SCM elt = SCM_CAR (walk); | |
2ade72d7 DH |
345 | SCM_ASSERT_TYPE (SCM_STRINGP (elt), elt, 3, FUNC_NAME, |
346 | "list of strings"); | |
a6d9e5ab DH |
347 | if (SCM_STRING_LENGTH (elt) > max_ext_len) |
348 | max_ext_len = SCM_STRING_LENGTH (elt); | |
26544b96 JB |
349 | } |
350 | } | |
351 | ||
06721500 JB |
352 | SCM_DEFER_INTS; |
353 | ||
1bbd0b84 | 354 | { /* scope */ |
56384176 | 355 | SCM result = SCM_BOOL_F; |
1be6b49c | 356 | size_t buf_size = max_path_len + 1 + filename_len + max_ext_len + 1; |
4c9419ac | 357 | char *buf = scm_malloc (buf_size); |
06721500 | 358 | |
56384176 | 359 | /* This simplifies the loop below a bit. */ |
c96d76b8 | 360 | if (SCM_NULL_OR_NIL_P (extensions)) |
56384176 | 361 | extensions = scm_listofnullstr; |
0a74e31d | 362 | |
56384176 JB |
363 | /* Try every path element. At this point, we know the path is a |
364 | proper list of strings. */ | |
c96d76b8 | 365 | for (; !SCM_NULL_OR_NIL_P (path); path = SCM_CDR (path)) |
56384176 | 366 | { |
1be6b49c | 367 | size_t len; |
56384176 JB |
368 | SCM dir = SCM_CAR (path); |
369 | SCM exts; | |
370 | ||
371 | /* Concatenate the path name and the filename. */ | |
a6d9e5ab | 372 | len = SCM_STRING_LENGTH (dir); |
34f0f2b8 | 373 | memcpy (buf, SCM_STRING_CHARS (dir), len); |
56384176 JB |
374 | if (len >= 1 && buf[len - 1] != '/') |
375 | buf[len++] = '/'; | |
376 | memcpy (buf + len, filename_chars, filename_len); | |
377 | len += filename_len; | |
378 | ||
379 | /* Try every extension. At this point, we know the extension | |
380 | list is a proper, nonempty list of strings. */ | |
c96d76b8 | 381 | for (exts = extensions; !SCM_NULL_OR_NIL_P (exts); exts = SCM_CDR (exts)) |
56384176 JB |
382 | { |
383 | SCM ext = SCM_CAR (exts); | |
1be6b49c | 384 | size_t ext_len = SCM_STRING_LENGTH (ext); |
56384176 JB |
385 | struct stat mode; |
386 | ||
387 | /* Concatenate the extension. */ | |
34f0f2b8 | 388 | memcpy (buf + len, SCM_STRING_CHARS (ext), ext_len); |
56384176 JB |
389 | buf[len + ext_len] = '\0'; |
390 | ||
391 | /* If the file exists at all, we should return it. If the | |
392 | file is inaccessible, then that's an error. */ | |
393 | if (stat (buf, &mode) == 0 | |
394 | && ! (mode.st_mode & S_IFDIR)) | |
395 | { | |
36284627 | 396 | result = scm_mem2string (buf, len + ext_len); |
56384176 JB |
397 | goto end; |
398 | } | |
399 | } | |
400 | } | |
401 | ||
402 | end: | |
4c9419ac | 403 | free (buf); |
56384176 JB |
404 | SCM_ALLOW_INTS; |
405 | return result; | |
406 | } | |
06721500 | 407 | } |
1bbd0b84 | 408 | #undef FUNC_NAME |
06721500 JB |
409 | |
410 | ||
04e8fb0a MD |
411 | /* Search %load-path for a directory containing a file named FILENAME. |
412 | The file must be readable, and not a directory. | |
413 | If we find one, return its full filename; otherwise, return #f. | |
414 | If FILENAME is absolute, return it unchanged. */ | |
3b3b36dd | 415 | SCM_DEFINE (scm_sys_search_load_path, "%search-load-path", 1, 0, 0, |
67e8151b MG |
416 | (SCM filename), |
417 | "Search @var{%load-path} for the file named @var{filename},\n" | |
418 | "which must be readable by the current user. If @var{filename}\n" | |
419 | "is found in the list of paths to search or is an absolute\n" | |
420 | "pathname, return its full pathname. Otherwise, return\n" | |
421 | "@code{#f}. Filenames may have any of the optional extensions\n" | |
422 | "in the @code{%load-extensions} list; @code{%search-load-path}\n" | |
423 | "will try each extension automatically.") | |
1bbd0b84 | 424 | #define FUNC_NAME s_scm_sys_search_load_path |
04e8fb0a MD |
425 | { |
426 | SCM path = *scm_loc_load_path; | |
427 | SCM exts = *scm_loc_load_extensions; | |
a6d9e5ab | 428 | SCM_VALIDATE_STRING (1, filename); |
1bbd0b84 | 429 | |
2ade72d7 DH |
430 | if (scm_ilength (path) < 0) |
431 | SCM_MISC_ERROR ("%load-path is not a proper list", SCM_EOL); | |
432 | if (scm_ilength (exts) < 0) | |
433 | SCM_MISC_ERROR ("%load-extension list is not a proper list", SCM_EOL); | |
1bbd0b84 | 434 | return scm_search_path (path, filename, exts); |
04e8fb0a | 435 | } |
1bbd0b84 | 436 | #undef FUNC_NAME |
04e8fb0a MD |
437 | |
438 | ||
3b3b36dd | 439 | SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 1, 0, 0, |
67e8151b MG |
440 | (SCM filename), |
441 | "Search @var{%load-path} for the file named @var{filename} and\n" | |
442 | "load it into the top-level environment. If @var{filename} is a\n" | |
443 | "relative pathname and is not found in the list of search paths,\n" | |
444 | "an error is signalled.") | |
1bbd0b84 | 445 | #define FUNC_NAME s_scm_primitive_load_path |
06721500 | 446 | { |
26544b96 JB |
447 | SCM full_filename; |
448 | ||
a6d9e5ab | 449 | SCM_VALIDATE_STRING (1, filename); |
26544b96 JB |
450 | |
451 | full_filename = scm_sys_search_load_path (filename); | |
452 | ||
dbece3a2 GH |
453 | if (SCM_FALSEP (full_filename)) |
454 | { | |
a6d9e5ab | 455 | int absolute = (SCM_STRING_LENGTH (filename) >= 1 |
34f0f2b8 | 456 | && SCM_STRING_CHARS (filename)[0] == '/'); |
5d2d2ffc | 457 | SCM_MISC_ERROR ((absolute |
70d63753 GB |
458 | ? "Unable to load file ~S" |
459 | : "Unable to find file ~S in load path"), | |
1afff620 | 460 | scm_list_1 (filename)); |
dbece3a2 | 461 | } |
26544b96 | 462 | |
deca31e1 | 463 | return scm_primitive_load (full_filename); |
06721500 | 464 | } |
1bbd0b84 | 465 | #undef FUNC_NAME |
06721500 | 466 | |
c519b272 MV |
467 | SCM |
468 | scm_c_primitive_load_path (const char *filename) | |
469 | { | |
470 | return scm_primitive_load_path (scm_makfrom0str (filename)); | |
471 | } | |
472 | ||
06721500 | 473 | \f |
e151bee6 | 474 | /* Information about the build environment. */ |
06721500 | 475 | |
e151bee6 JB |
476 | /* Initialize the scheme variable %guile-build-info, based on data |
477 | provided by the Makefile, via libpath.h. */ | |
478 | static void | |
479 | init_build_info () | |
480 | { | |
481 | static struct { char *name; char *value; } info[] = SCM_BUILD_INFO; | |
86d31dfe | 482 | SCM *loc = SCM_VARIABLE_LOC (scm_c_define ("%guile-build-info", SCM_EOL)); |
c014a02e | 483 | unsigned long i; |
e151bee6 JB |
484 | |
485 | for (i = 0; i < (sizeof (info) / sizeof (info[0])); i++) | |
38ae064c | 486 | *loc = scm_acons (scm_str2symbol (info[i].name), |
e151bee6 JB |
487 | scm_makfrom0str (info[i].value), |
488 | *loc); | |
489 | } | |
490 | ||
491 | ||
492 | \f | |
0f2d19dd JB |
493 | void |
494 | scm_init_load () | |
0f2d19dd | 495 | { |
1afff620 | 496 | scm_listofnullstr = scm_permanent_object (scm_list_1 (scm_nullstr)); |
86d31dfe | 497 | scm_loc_load_path = SCM_VARIABLE_LOC (scm_c_define ("%load-path", SCM_EOL)); |
26544b96 | 498 | scm_loc_load_extensions |
86d31dfe | 499 | = SCM_VARIABLE_LOC (scm_c_define ("%load-extensions", |
1afff620 KN |
500 | scm_list_2 (scm_makfrom0str (".scm"), |
501 | scm_nullstr))); | |
86d31dfe | 502 | scm_loc_load_hook = SCM_VARIABLE_LOC (scm_c_define ("%load-hook", SCM_BOOL_F)); |
06721500 | 503 | |
e151bee6 JB |
504 | init_build_info (); |
505 | ||
a0599745 | 506 | #include "libguile/load.x" |
0f2d19dd | 507 | } |
89e00824 ML |
508 | |
509 | /* | |
510 | Local Variables: | |
511 | c-file-style: "gnu" | |
512 | End: | |
513 | */ |