blob: c4faf0d537eaf757eb2e91018d377beef4bd7ecc [file] [log] [blame]
Jari Aalto726f6381996-08-26 18:22:31 +00001This file is inlib.def, from which is created inlib.c.
2It implements the Apollo-specific builtin "inlib" in Bash.
3
Jari Aalto7117c2d2002-07-17 14:10:11 +00004Copyright (C) 1987-2002 Free Software Foundation, Inc.
Jari Aalto726f6381996-08-26 18:22:31 +00005
6This file is part of GNU Bash, the Bourne Again SHell.
7
Jari Aalto31859422009-01-12 13:36:28 +00008Bash is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 3 of the License, or
11(at your option) any later version.
Jari Aalto726f6381996-08-26 18:22:31 +000012
Jari Aalto31859422009-01-12 13:36:28 +000013Bash is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
Jari Aalto726f6381996-08-26 18:22:31 +000017
Jari Aalto31859422009-01-12 13:36:28 +000018You should have received a copy of the GNU General Public License
19along with Bash. If not, see <http://www.gnu.org/licenses/>.
Jari Aalto726f6381996-08-26 18:22:31 +000020
21$PRODUCES inlib.c
Jari Aaltoccc6cda1996-12-23 17:02:34 +000022#include <config.h>
23
Jari Aalto726f6381996-08-26 18:22:31 +000024#include <stdio.h>
25#include "../shell.h"
26
27$BUILTIN inlib
28$FUNCTION inlib_builtin
29$DEPENDS_ON apollo
30$SHORT_DOC inlib pathname [pathname...]
Jari Aalto31859422009-01-12 13:36:28 +000031Install user-supplied library.
32
Jari Aalto726f6381996-08-26 18:22:31 +000033Install a user-supplied library specified by pathname in the current
34shell process. The library is used to resolve external references
35in programs and libraries loaded after its installation. Note
36that the library is not loaded into the address space unless it is
37needed to resolve an external reference. The list of inlibed
38libraries is passed to all children of the current shell.
Jari Aalto31859422009-01-12 13:36:28 +000039
40Exit Status:
41Returns success unless PATHNAME is not found or an error occurs.
Jari Aalto726f6381996-08-26 18:22:31 +000042$END
43
44#if defined (apollo)
45
46#include <apollo/base.h>
47#include <apollo/loader.h>
48
49inlib_builtin (list)
50 WORD_LIST *list;
51{
52 status_$t status;
53 int return_value;
54 short len;
55
56 if (!list)
57 {
Jari Aalto7117c2d2002-07-17 14:10:11 +000058 builtin_usage ();
Jari Aalto726f6381996-08-26 18:22:31 +000059 return (EX_USAGE);
60 }
61
62 return_value = EXECUTION_SUCCESS;
63
64 while (list)
65 {
66 len = (short)strlen (list->word->word);
67 loader_$inlib (list->word->word, len, &status);
68
69 if (status.all != status_$ok)
70 {
Jari Aalto31859422009-01-12 13:36:28 +000071 builtin_error (_("%s: inlib failed"), list->word->word);
Jari Aalto726f6381996-08-26 18:22:31 +000072 return_value = EXECUTION_FAILURE;
73 }
74
75 list = list->next;
76 }
77
78 return (return_value);
79}
80#endif /* apollo */