Commit | Line | Data |
---|---|---|
7ad3c1e7 | 1 | /* Copyright (C) 1995,1996,1997 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. */ |
0f2d19dd JB |
41 | \f |
42 | ||
43 | #include <stdio.h> | |
44 | #include "_scm.h" | |
95b88819 | 45 | |
20e6290e JB |
46 | #include "scmsigs.h" |
47 | #include "simpos.h" | |
48 | ||
95b88819 GH |
49 | #ifdef HAVE_STRING_H |
50 | #include <string.h> | |
51 | #endif | |
0f2d19dd JB |
52 | #ifdef HAVE_UNISTD_H |
53 | #include <unistd.h> | |
54 | #endif | |
55 | ||
56 | \f | |
57 | extern int system(); | |
58 | \f | |
59 | ||
60 | #ifndef _Windows | |
61 | SCM_PROC(s_system, "system", 1, 0, 0, scm_system); | |
1cc91f1b | 62 | |
0f2d19dd JB |
63 | SCM |
64 | scm_system(cmd) | |
65 | SCM cmd; | |
0f2d19dd JB |
66 | { |
67 | SCM_ASSERT(SCM_NIMP(cmd) && SCM_ROSTRINGP(cmd), cmd, SCM_ARG1, s_system); | |
68 | if (SCM_ROSTRINGP (cmd)) | |
69 | cmd = scm_makfromstr (SCM_ROCHARS (cmd), SCM_ROLENGTH (cmd), 0); | |
0f2d19dd JB |
70 | # ifdef AZTEC_C |
71 | cmd = SCM_MAKINUM(Execute(SCM_ROCHARS(cmd), 0, 0)); | |
72 | # else | |
73 | cmd = SCM_MAKINUM(0L+system(SCM_ROCHARS(cmd))); | |
74 | # endif | |
0f2d19dd JB |
75 | return cmd; |
76 | } | |
77 | #endif | |
78 | ||
79 | extern char *getenv(); | |
f93ddd39 | 80 | SCM_PROC (s_getenv, "getenv", 1, 0, 0, scm_getenv); |
1cc91f1b | 81 | |
0f2d19dd | 82 | SCM |
f93ddd39 | 83 | scm_getenv(nam) |
0f2d19dd | 84 | SCM nam; |
0f2d19dd JB |
85 | { |
86 | char *val; | |
f93ddd39 | 87 | SCM_ASSERT(SCM_NIMP(nam) && SCM_ROSTRINGP(nam), nam, SCM_ARG1, s_getenv); |
0f2d19dd JB |
88 | if (SCM_ROSTRINGP (nam)) |
89 | nam = scm_makfromstr (SCM_ROCHARS (nam), SCM_ROLENGTH (nam), 0); | |
90 | val = getenv(SCM_CHARS(nam)); | |
9373b387 | 91 | return (val) ? scm_makfromstr(val, (scm_sizet)strlen(val), 0) : SCM_BOOL_F; |
0f2d19dd JB |
92 | } |
93 | ||
7ad3c1e7 GH |
94 | SCM_PROC (s_primitive_exit, "primitive-exit", 0, 1, 0, scm_primitive_exit); |
95 | SCM | |
96 | scm_primitive_exit (SCM status) | |
97 | { | |
98 | int cstatus = 0; | |
99 | if (!SCM_UNBNDP (status)) | |
100 | { | |
101 | SCM_ASSERT (SCM_INUMP (status), status, SCM_ARG1, s_primitive_exit); | |
102 | cstatus = SCM_INUM (status); | |
103 | } | |
104 | exit (cstatus); | |
105 | } | |
106 | ||
10a12f9f JB |
107 | /* I have a feeling this whole arrangement below is a bad idea. One |
108 | should always test for the presence or absence of a particular | |
109 | feature, instead of checking the system name. Older versions of a | |
110 | system may lack features posessed by new ones, and a feature | |
111 | appearing on one system will soon appear on others. And autoconf | |
112 | provides the mechanisms for detecting features. -JimB */ | |
113 | ||
114 | #ifdef _AIX | |
115 | # define SYSTNAME "AIX" | |
116 | #endif | |
0f2d19dd JB |
117 | #ifdef vms |
118 | # define SYSTNAME "VMS" | |
119 | #endif | |
0e958795 | 120 | #if defined (unix) || defined (__unix) || defined(__CYGWIN32__) |
0f2d19dd JB |
121 | # define SYSTNAME "UNIX" |
122 | #endif | |
123 | #ifdef MWC | |
124 | # define SYSTNAME "COHERENT" | |
125 | #endif | |
126 | #ifdef _Windows | |
127 | # define SYSTNAME "WINDOWS" | |
128 | #else | |
129 | # ifdef MSDOS | |
130 | # define SYSTNAME "MS-DOS" | |
131 | # endif | |
132 | #endif | |
133 | #ifdef __EMX__ | |
134 | # define SYSTNAME "OS/2" | |
135 | #endif | |
136 | #ifdef __IBMC__ | |
137 | # define SYSTNAME "OS/2" | |
138 | #endif | |
139 | #ifdef THINK_C | |
140 | # define SYSTNAME "THINKC" | |
141 | #endif | |
142 | #ifdef AMIGA | |
143 | # define SYSTNAME "AMIGA" | |
144 | #endif | |
145 | #ifdef atarist | |
146 | # define SYSTNAME "ATARIST" | |
147 | #endif | |
148 | #ifdef mach | |
149 | # define SYSTNAME "MACH" | |
150 | #endif | |
151 | #ifdef ARM_ULIB | |
152 | # define SYSTNAME "ACORN" | |
153 | #endif | |
154 | ||
155 | SCM_PROC(s_software_type, "software-type", 0, 0, 0, scm_software_type); | |
1cc91f1b | 156 | |
0f2d19dd JB |
157 | SCM |
158 | scm_software_type() | |
0f2d19dd JB |
159 | { |
160 | #ifdef nosve | |
161 | return SCM_CAR(scm_intern("nosve", 5)); | |
162 | #else | |
163 | return SCM_CAR(scm_intern(SYSTNAME, sizeof SYSTNAME/sizeof(char) -1)); | |
164 | #endif | |
165 | } | |
166 | ||
1cc91f1b | 167 | |
0f2d19dd JB |
168 | void |
169 | scm_init_simpos () | |
0f2d19dd JB |
170 | { |
171 | #include "simpos.x" | |
172 | } | |
173 |