Guido van Rossum | be0e942 | 1993-12-24 10:32:00 +0000 | [diff] [blame] | 1 | /*********************************************************** |
| 2 | Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, |
| 3 | Amsterdam, The 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 | |
| 25 | /* Python version information */ |
| 26 | |
| 27 | /* Return the version string. This is constructed from the official |
| 28 | version number, the patch level, and the current date (if known to |
| 29 | the compiler, else a manually inserted date). */ |
| 30 | |
| 31 | #define VERSION "1.0.%d ALPHA (%s)" |
| 32 | |
| 33 | #ifdef __DATE__ |
| 34 | #define DATE __DATE__ |
| 35 | #else |
| 36 | #define DATE ">= 21 Dec 1993" |
| 37 | #endif |
| 38 | |
| 39 | char * |
| 40 | getversion() |
| 41 | { |
| 42 | static char version[80]; |
| 43 | sprintf(version, VERSION, PATCHLEVEL, DATE); |
| 44 | return version; |
| 45 | } |
| 46 | |
| 47 | |
| 48 | /* Return the copyright string. This is updated manually. */ |
| 49 | |
| 50 | char * |
| 51 | getcopyright() |
| 52 | { |
| 53 | return |
| 54 | "Copyright 1990, 1991, 1992, 1993 Stichting Mathematisch Centrum, Amsterdam"; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /* Return the initial python search path. This is called once from |
| 59 | initsys() to initialize sys.path. |
| 60 | The environment variable PYTHONPATH is fetched and the default path |
| 61 | appended. (The Mac has no environment variables, so there the |
| 62 | default path is always returned.) The default path may be passed |
| 63 | to the preprocessor; if not, a system-dependent default is used. */ |
| 64 | |
| 65 | #ifndef PYTHONPATH |
| 66 | #ifdef macintosh |
| 67 | #define PYTHONPATH ": :lib :demo" |
| 68 | #endif /* macintosh */ |
| 69 | #endif /* !PYTHONPATH */ |
| 70 | |
| 71 | #ifndef PYTHONPATH |
| 72 | #ifdef MSDOS |
| 73 | #define PYTHONPATH ".;..\\lib;\\python\\lib" |
| 74 | #endif /* MSDOS */ |
| 75 | #endif /* !PYTHONPATH */ |
| 76 | |
| 77 | #ifndef PYTHONPATH |
| 78 | #define PYTHONPATH ".:/usr/local/lib/python" |
| 79 | #endif /* !PYTHONPATH */ |
| 80 | |
| 81 | extern char *getenv(); |
| 82 | |
| 83 | char * |
| 84 | getpythonpath() |
| 85 | { |
| 86 | #ifdef macintosh |
| 87 | return PYTHONPATH; |
| 88 | #else /* !macintosh */ |
| 89 | char *path = getenv("PYTHONPATH"); |
| 90 | char *defpath = PYTHONPATH; |
| 91 | char *buf; |
| 92 | char *p; |
| 93 | int n; |
| 94 | |
| 95 | if (path == 0 || *path == '\0') |
| 96 | return defpath; |
| 97 | n = strlen(path) + strlen(defpath) + 2; |
| 98 | buf = malloc(n); |
| 99 | if (buf == NULL) |
| 100 | return path; /* XXX too bad -- but not likely */ |
| 101 | strcpy(buf, path); |
| 102 | p = buf + strlen(buf); |
| 103 | *p++ = DELIM; |
| 104 | strcpy(p, defpath); |
| 105 | return buf; |
| 106 | #endif /* !macintosh */ |
| 107 | } |
| 108 | |
| 109 | |
| 110 | /* Table of built-in modules. |
| 111 | These are initialized when first imported. |
| 112 | Note: selection of optional extensions is now generally done by the |
| 113 | mkext.py script in ../Extensions, but for non-UNIX systems most |
| 114 | well-known extensions are still listed here. */ |
| 115 | |
| 116 | /* Standard modules */ |
| 117 | |
| 118 | #ifdef USE_AL |
| 119 | extern void inital(); |
| 120 | #endif |
| 121 | #ifdef USE_AMOEBA |
| 122 | extern void initamoeba(); |
| 123 | #endif |
| 124 | #ifdef USE_AUDIO |
| 125 | extern void initaudio(); |
| 126 | #endif |
| 127 | #ifdef USE_AUDIOOP |
| 128 | extern void initaudioop(); |
| 129 | #endif |
| 130 | #ifdef USE_CD |
| 131 | extern void initcd(); |
| 132 | #endif |
| 133 | #ifdef USE_CL |
| 134 | extern void initcl(); |
| 135 | #endif |
| 136 | #ifdef USE_DBM |
| 137 | extern void initdbm(); |
| 138 | #endif |
| 139 | #ifdef USE_FCNTL |
| 140 | extern void initfcntl(); |
| 141 | #endif |
| 142 | #ifdef USE_FL |
| 143 | extern void initfl(); |
| 144 | #endif |
| 145 | #ifdef USE_FM |
| 146 | extern void initfm(); |
| 147 | #endif |
| 148 | #ifdef USE_GL |
| 149 | extern void initgl(); |
| 150 | #endif |
| 151 | #ifdef USE_GRP |
| 152 | extern void initgrp(); |
| 153 | #endif |
| 154 | #ifdef USE_IMGFILE |
| 155 | extern void initimgfile(); |
| 156 | #endif |
| 157 | #ifdef USE_JPEG |
| 158 | extern void initjpeg(); |
| 159 | #endif |
| 160 | #ifdef USE_MAC |
| 161 | extern void initmac(); |
| 162 | #endif |
| 163 | #ifdef USE_MARSHAL |
| 164 | extern void initmarshal(); |
| 165 | #endif |
| 166 | #ifdef USE_MATH |
| 167 | extern void initmath(); |
| 168 | #endif |
| 169 | #ifdef USE_NIS |
| 170 | extern void initnis(); |
| 171 | #endif |
| 172 | #ifdef USE_PANEL |
| 173 | extern void initpanel(); |
| 174 | #endif |
| 175 | #ifdef USE_POSIX |
| 176 | extern void initposix(); |
| 177 | #endif |
| 178 | #ifdef USE_PWD |
| 179 | extern void initpwd(); |
| 180 | #endif |
| 181 | #ifdef USE_REGEX |
| 182 | extern void initregex(); |
| 183 | #endif |
| 184 | #ifdef USE_ROTOR |
| 185 | extern void initrotor(); |
| 186 | #endif |
| 187 | #ifdef USE_SELECT |
| 188 | extern void initselect(); |
| 189 | #endif |
| 190 | #ifdef USE_SGI |
| 191 | extern void initsgi(); |
| 192 | #endif |
| 193 | #ifdef USE_SOCKET |
| 194 | extern void initsocket(); |
| 195 | #endif |
| 196 | #ifdef USE_STDWIN |
| 197 | extern void initstdwin(); |
| 198 | #endif |
| 199 | #ifdef USE_STROP |
| 200 | extern void initstrop(); |
| 201 | #endif |
| 202 | #ifdef USE_STRUCT |
| 203 | extern void initstruct(); |
| 204 | #endif |
| 205 | #ifdef USE_SUNAUDIODEV |
| 206 | extern void initsunaudiodev(); |
| 207 | #endif |
| 208 | #ifdef USE_SV |
| 209 | extern void initsv(); |
| 210 | #endif |
| 211 | #ifdef USE_TIME |
| 212 | extern void inittime(); |
| 213 | #endif |
| 214 | #ifdef USE_IMAGEOP |
| 215 | extern void initimageop(); |
| 216 | #endif |
| 217 | #ifdef USE_MPZ |
| 218 | extern void initmpz(); |
| 219 | #endif |
| 220 | #ifdef USE_MD5 |
| 221 | extern void initmd5(); |
| 222 | #endif |
| 223 | #ifdef USE_ARRAY |
| 224 | extern void initarray(); |
| 225 | #endif |
| 226 | #ifdef USE_XT |
| 227 | extern void initXt(); |
| 228 | #endif |
| 229 | #ifdef USE_XAW |
| 230 | extern void initXaw(); |
| 231 | #endif |
| 232 | #ifdef USE_XM |
| 233 | extern void initXm(); |
| 234 | #endif |
| 235 | #ifdef USE_GLX |
| 236 | extern void initGlx(); |
| 237 | #endif |
| 238 | #ifdef USE_HTML |
| 239 | extern void initHTML(); |
| 240 | #endif |
| 241 | #ifdef USE_XLIB |
| 242 | extern void initXlib(); |
| 243 | #endif |
| 244 | #ifdef USE_PARSER |
| 245 | extern void initparser(); |
| 246 | #endif |
| 247 | /* -- ADDMODULE MARKER 1 -- */ |
| 248 | |
| 249 | struct { |
| 250 | char *name; |
| 251 | void (*initfunc)(); |
| 252 | } inittab[] = { |
| 253 | |
| 254 | #ifdef USE_AL |
| 255 | {"al", inital}, |
| 256 | #endif |
| 257 | |
| 258 | #ifdef USE_AMOEBA |
| 259 | {"amoeba", initamoeba}, |
| 260 | #endif |
| 261 | |
| 262 | #ifdef USE_AUDIO |
| 263 | {"audio", initaudio}, |
| 264 | #endif |
| 265 | |
| 266 | #ifdef USE_AUDIOOP |
| 267 | {"audioop", initaudioop}, |
| 268 | #endif |
| 269 | |
| 270 | #ifdef USE_CD |
| 271 | {"cd", initcd}, |
| 272 | #endif |
| 273 | |
| 274 | #ifdef USE_CL |
| 275 | {"cl", initcl}, |
| 276 | #endif |
| 277 | |
| 278 | #ifdef USE_DBM |
| 279 | {"dbm", initdbm}, |
| 280 | #endif |
| 281 | |
| 282 | #ifdef USE_FCNTL |
| 283 | {"fcntl", initfcntl}, |
| 284 | #endif |
| 285 | |
| 286 | #ifdef USE_FL |
| 287 | {"fl", initfl}, |
| 288 | #endif |
| 289 | |
| 290 | #ifdef USE_FM |
| 291 | {"fm", initfm}, |
| 292 | #endif |
| 293 | |
| 294 | #ifdef USE_GL |
| 295 | {"gl", initgl}, |
| 296 | #endif |
| 297 | |
| 298 | #ifdef USE_GRP |
| 299 | {"grp", initgrp}, |
| 300 | #endif |
| 301 | |
| 302 | #ifdef USE_IMGFILE |
| 303 | {"imgfile", initimgfile}, |
| 304 | #endif |
| 305 | |
| 306 | #ifdef USE_JPEG |
| 307 | {"jpeg", initjpeg}, |
| 308 | #endif |
| 309 | |
| 310 | #ifdef USE_MAC |
| 311 | {"mac", initmac}, |
| 312 | #endif |
| 313 | |
| 314 | #ifdef USE_MARSHAL |
| 315 | {"marshal", initmarshal}, |
| 316 | #endif |
| 317 | |
| 318 | #ifdef USE_MATH |
| 319 | {"math", initmath}, |
| 320 | #endif |
| 321 | |
| 322 | #ifdef USE_NIS |
| 323 | {"nis", initnis}, |
| 324 | #endif |
| 325 | |
| 326 | #ifdef USE_PANEL |
| 327 | {"pnl", initpanel}, |
| 328 | #endif |
| 329 | |
| 330 | #ifdef USE_POSIX |
| 331 | {"posix", initposix}, |
| 332 | #endif |
| 333 | |
| 334 | #ifdef USE_PWD |
| 335 | {"pwd", initpwd}, |
| 336 | #endif |
| 337 | |
| 338 | #ifdef USE_REGEX |
| 339 | {"regex", initregex}, |
| 340 | #endif |
| 341 | |
| 342 | #ifdef USE_ROTOR |
| 343 | {"rotor", initrotor}, |
| 344 | #endif |
| 345 | |
| 346 | #ifdef USE_SELECT |
| 347 | {"select", initselect}, |
| 348 | #endif |
| 349 | |
| 350 | #ifdef USE_SGI |
| 351 | {"sgi", initsgi}, |
| 352 | #endif |
| 353 | |
| 354 | #ifdef USE_SOCKET |
| 355 | {"socket", initsocket}, |
| 356 | #endif |
| 357 | |
| 358 | #ifdef USE_STDWIN |
| 359 | {"stdwin", initstdwin}, |
| 360 | #endif |
| 361 | |
| 362 | #ifdef USE_STROP |
| 363 | {"strop", initstrop}, |
| 364 | #endif |
| 365 | |
| 366 | #ifdef USE_STRUCT |
| 367 | {"struct", initstruct}, |
| 368 | #endif |
| 369 | |
| 370 | #ifdef USE_SUNAUDIODEV |
| 371 | {"sunaudiodev", initsunaudiodev}, |
| 372 | #endif |
| 373 | |
| 374 | #ifdef USE_SV |
| 375 | {"sv", initsv}, |
| 376 | #endif |
| 377 | |
| 378 | #ifdef USE_TIME |
| 379 | {"time", inittime}, |
| 380 | #endif |
| 381 | |
| 382 | #ifdef USE_IMAGEOP |
| 383 | {"imageop", initimageop}, |
| 384 | #endif |
| 385 | |
| 386 | #ifdef USE_MPZ |
| 387 | {"mpz", initmpz}, |
| 388 | #endif |
| 389 | |
| 390 | #ifdef USE_MD5 |
| 391 | {"md5", initmd5}, |
| 392 | #endif |
| 393 | |
| 394 | #ifdef USE_ARRAY |
| 395 | {"array", initarray}, |
| 396 | #endif |