Imported from ../bash-2.0.tar.gz.
[platform/upstream/bash.git] / builtins / inlib.def
1 This file is inlib.def, from which is created inlib.c.
2 It implements the Apollo-specific builtin "inlib" in Bash.
3
4 Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
5
6 This file is part of GNU Bash, the Bourne Again SHell.
7
8 Bash is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 1, or (at your option) any later
11 version.
12
13 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with Bash; see the file COPYING.  If not, write to the Free Software
20 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 $PRODUCES inlib.c
23 #include <config.h>
24
25 #include <stdio.h>
26 #include "../shell.h"
27
28 $BUILTIN inlib
29 $FUNCTION inlib_builtin
30 $DEPENDS_ON apollo
31 $SHORT_DOC inlib pathname [pathname...]
32 Install a user-supplied library specified by pathname in the current
33 shell process. The library is used to resolve external references
34 in programs and libraries loaded after its installation.  Note
35 that the library is not loaded into the address space unless it is
36 needed to resolve an external reference.  The list of inlibed
37 libraries is passed to all children of the current shell.
38 $END
39
40 #if defined (apollo)
41
42 #include <apollo/base.h>
43 #include <apollo/loader.h>
44
45 inlib_builtin (list)
46      WORD_LIST *list;
47 {
48   status_$t status;
49   int return_value;
50   short len;
51
52   if (!list)
53     {
54       builtin_error ("usage: inlib pathname [pathname...]");
55       return (EX_USAGE);
56     }
57
58   return_value = EXECUTION_SUCCESS;
59
60   while (list)
61     {
62       len = (short)strlen (list->word->word);
63       loader_$inlib (list->word->word, len, &status);
64
65       if (status.all != status_$ok)
66         {
67           builtin_error ("inlib failed for %s", list->word->word);
68           return_value = EXECUTION_FAILURE;
69         }
70
71       list = list->next;
72     }
73
74   return (return_value);
75 }
76 #endif /* apollo */