Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | bab9d03 | 1992-04-05 14:26:55 +0000 | [diff] [blame] | 2 | Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 3 | Netherlands. |
| 4 | |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
| 9 | provided that the above copyright notice appear in all copies and that |
| 10 | both that copyright notice and this permission notice appear in |
| 11 | supporting documentation, and that the names of Stichting Mathematisch |
| 12 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 13 | distribution of the software without specific, written prior permission. |
| 14 | |
| 15 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 16 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 18 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 20 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 21 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 22 | |
| 23 | ******************************************************************/ |
| 24 | |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 25 | /* Configurable Python configuration file */ |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 26 | |
Guido van Rossum | c888bf7 | 1992-06-03 17:05:13 +0000 | [diff] [blame] | 27 | #include "PROTO.h" |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 28 | #include "mymalloc.h" |
Guido van Rossum | c888bf7 | 1992-06-03 17:05:13 +0000 | [diff] [blame] | 29 | |
Guido van Rossum | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame] | 30 | #include "patchlevel.h" |
| 31 | |
Guido van Rossum | 450ed49 | 1992-01-19 16:27:42 +0000 | [diff] [blame] | 32 | #define VERSION "0.9.%d (%s)" |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 33 | |
| 34 | #ifdef __DATE__ |
| 35 | #define DATE __DATE__ |
| 36 | #else |
Guido van Rossum | a1ed37c | 1992-08-10 14:55:00 +0000 | [diff] [blame] | 37 | #define DATE ">= 10 Aug 1992" |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 38 | #endif |
Guido van Rossum | 9f462af | 1991-12-10 13:54:12 +0000 | [diff] [blame] | 39 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 40 | #include <stdio.h> |
| 41 | |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 42 | #ifdef USE_STDWIN |
| 43 | #include <stdwin.h> |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 44 | #endif |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 45 | |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 46 | char version[80]; |
| 47 | |
Guido van Rossum | 450ed49 | 1992-01-19 16:27:42 +0000 | [diff] [blame] | 48 | char *argv0; |
| 49 | |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 50 | /*ARGSUSED*/ |
| 51 | void |
| 52 | initargs(p_argc, p_argv) |
| 53 | int *p_argc; |
| 54 | char ***p_argv; |
| 55 | { |
Guido van Rossum | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame] | 56 | sprintf(version, VERSION, PATCHLEVEL, DATE); |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 57 | |
Guido van Rossum | 450ed49 | 1992-01-19 16:27:42 +0000 | [diff] [blame] | 58 | argv0 = **p_argv; |
| 59 | |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 60 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 61 | wargs(p_argc, p_argv); |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 62 | #endif |
Guido van Rossum | 9f462af | 1991-12-10 13:54:12 +0000 | [diff] [blame] | 63 | if (*p_argc < 2 && isatty(0) && isatty(1)) |
| 64 | { |
| 65 | printf("Python %s.\n", version); |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 66 | printf( |
| 67 | "Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam\n"); |
Guido van Rossum | 9f462af | 1991-12-10 13:54:12 +0000 | [diff] [blame] | 68 | } |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | void |
| 72 | initcalls() |
| 73 | { |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | void |
| 77 | donecalls() |
| 78 | { |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 79 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 80 | wdone(); |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 81 | #endif |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 82 | #ifdef USE_AUDIO |
| 83 | asa_done(); |
| 84 | #endif |
| 85 | } |
| 86 | |
| 87 | #ifndef PYTHONPATH |
Guido van Rossum | c888bf7 | 1992-06-03 17:05:13 +0000 | [diff] [blame] | 88 | #define PYTHONPATH ".:/usr/local/lib/python" |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 89 | #endif |
| 90 | |
| 91 | extern char *getenv(); |
| 92 | |
| 93 | char * |
| 94 | getpythonpath() |
| 95 | { |
| 96 | char *path = getenv("PYTHONPATH"); |
Guido van Rossum | c888bf7 | 1992-06-03 17:05:13 +0000 | [diff] [blame] | 97 | char *defpath = PYTHONPATH; |
| 98 | char *buf; |
| 99 | int n; |
| 100 | |
| 101 | if (path == 0 || *path == '\0') |
| 102 | return defpath; |
| 103 | n = strlen(path) + strlen(defpath) + 2; |
| 104 | buf = malloc(n); |
| 105 | if (buf == NULL) |
| 106 | return path; /* XXX too bad -- but not likely */ |
| 107 | strcpy(buf, path); |
| 108 | strcat(buf, ":"); |
| 109 | strcat(buf, defpath); |
| 110 | return buf; |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 111 | } |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 112 | |
| 113 | |
| 114 | /* Table of built-in modules. |
| 115 | These are initialized when first imported. */ |
| 116 | |
| 117 | /* Standard modules */ |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 118 | extern void initgrp(); |
| 119 | extern void initmarshal(); |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 120 | extern void initmath(); |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 121 | extern void initposix(); |
Guido van Rossum | ac02948 | 1991-04-16 08:39:39 +0000 | [diff] [blame] | 122 | extern void initpwd(); |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 123 | extern void initselect(); |
Guido van Rossum | 1984f1e | 1992-08-04 12:41:02 +0000 | [diff] [blame] | 124 | extern void initsocket(); |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 125 | extern void inittime(); |
Guido van Rossum | 6f7b959 | 1991-06-04 19:47:46 +0000 | [diff] [blame] | 126 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 127 | #ifdef USE_AUDIO |
| 128 | extern void initaudio(); |
| 129 | #endif |
Guido van Rossum | 188f832 | 1991-09-10 14:55:08 +0000 | [diff] [blame] | 130 | #ifdef USE_AL |
| 131 | extern void inital(); |
| 132 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 133 | #ifdef USE_AMOEBA |
| 134 | extern void initamoeba(); |
| 135 | #endif |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 136 | #ifdef USE_CD |
| 137 | extern void initcd(); |
| 138 | #endif |
Guido van Rossum | 3fecef7 | 1991-08-16 08:58:56 +0000 | [diff] [blame] | 139 | #ifdef USE_FL |
| 140 | extern void initfl(); |
| 141 | #endif |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 142 | #ifdef USE_FM |
| 143 | extern void initfm(); |
| 144 | #endif |
| 145 | #ifdef USE_GL |
| 146 | extern void initgl(); |
| 147 | #endif |
| 148 | #ifdef USE_JPEG |
| 149 | extern void initjpeg(); |
| 150 | #endif |
| 151 | #ifdef USE_NIS |
| 152 | extern void initnis(); |
Guido van Rossum | 2abc7a6 | 1991-04-03 19:01:18 +0000 | [diff] [blame] | 153 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 154 | #ifdef USE_PANEL |
| 155 | extern void initpanel(); |
| 156 | #endif |
Guido van Rossum | 38fbf52 | 1992-08-12 15:28:52 +0000 | [diff] [blame] | 157 | #ifdef USE_REGEX |
| 158 | extern void initregex(); |
| 159 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 160 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 161 | extern void initstdwin(); |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 162 | #endif |
Guido van Rossum | 1984f1e | 1992-08-04 12:41:02 +0000 | [diff] [blame] | 163 | #ifdef USE_THREAD |
| 164 | extern void initthread(); |
| 165 | #endif |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 166 | #ifdef USE_SV |
| 167 | extern void initsv(); |
Guido van Rossum | 38fbf52 | 1992-08-12 15:28:52 +0000 | [diff] [blame] | 168 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 169 | |
| 170 | struct { |
| 171 | char *name; |
| 172 | void (*initfunc)(); |
| 173 | } inittab[] = { |
| 174 | |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 175 | /* Standard modules, in alphabetical order */ |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 176 | |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 177 | {"grp", initgrp}, |
| 178 | {"marshal", initmarshal}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 179 | {"math", initmath}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 180 | {"posix", initposix}, |
Guido van Rossum | ac02948 | 1991-04-16 08:39:39 +0000 | [diff] [blame] | 181 | {"pwd", initpwd}, |
Guido van Rossum | ed233a5 | 1992-06-23 09:07:03 +0000 | [diff] [blame] | 182 | {"select", initselect}, |
Guido van Rossum | 1984f1e | 1992-08-04 12:41:02 +0000 | [diff] [blame] | 183 | {"socket", initsocket}, |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 184 | {"time", inittime}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 185 | |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 186 | /* Optional modules, in alphabetical order */ |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 187 | |
| 188 | #ifdef USE_AUDIO |
| 189 | {"audio", initaudio}, |
| 190 | #endif |
| 191 | |
Guido van Rossum | 188f832 | 1991-09-10 14:55:08 +0000 | [diff] [blame] | 192 | #ifdef USE_AL |
| 193 | {"al", inital}, |
| 194 | #endif |
| 195 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 196 | #ifdef USE_AMOEBA |
| 197 | {"amoeba", initamoeba}, |
| 198 | #endif |
| 199 | |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 200 | #ifdef USE_CD |
| 201 | {"cd", initcd}, |
| 202 | #endif |
| 203 | |
Guido van Rossum | 3fecef7 | 1991-08-16 08:58:56 +0000 | [diff] [blame] | 204 | #ifdef USE_FL |
| 205 | {"fl", initfl}, |
| 206 | #endif |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 207 | |
| 208 | #ifdef USE_FM |
| 209 | {"fm", initfm}, |
Guido van Rossum | 2abc7a6 | 1991-04-03 19:01:18 +0000 | [diff] [blame] | 210 | #endif |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 211 | |
| 212 | #ifdef USE_GL |
| 213 | {"gl", initgl}, |
| 214 | #endif |
| 215 | |
| 216 | #ifdef USE_JPEG |
| 217 | {"jpeg", initjpeg}, |
| 218 | #endif |
| 219 | |
| 220 | #ifdef USE_NIS |
| 221 | {"nis", initnis}, |
| 222 | #endif |
| 223 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 224 | #ifdef USE_PANEL |
| 225 | {"pnl", initpanel}, |
| 226 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 227 | |
Guido van Rossum | 38fbf52 | 1992-08-12 15:28:52 +0000 | [diff] [blame] | 228 | #ifdef USE_REGEX |
| 229 | {"regex", initregex}, |
| 230 | #endif |
| 231 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 232 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 233 | {"stdwin", initstdwin}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 234 | #endif |
| 235 | |
Guido van Rossum | 1984f1e | 1992-08-04 12:41:02 +0000 | [diff] [blame] | 236 | #ifdef USE_THREAD |
| 237 | {"thread", initthread}, |
| 238 | #endif |
| 239 | |
Guido van Rossum | b001f7a | 1992-08-19 16:44:41 +0000 | [diff] [blame^] | 240 | #ifdef USE_SV |
| 241 | {"sv", initsv}, |
Guido van Rossum | 38fbf52 | 1992-08-12 15:28:52 +0000 | [diff] [blame] | 242 | #endif |
| 243 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 244 | {0, 0} /* Sentinel */ |
| 245 | }; |