Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | /*********************************************************** |
| 2 | Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The |
| 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 | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame^] | 27 | #include "patchlevel.h" |
| 28 | |
| 29 | #define VERSION "0.9.%d alpha (%s)" |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 30 | |
| 31 | #ifdef __DATE__ |
| 32 | #define DATE __DATE__ |
| 33 | #else |
Guido van Rossum | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame^] | 34 | #define DATE ">= Dec 27 1991" |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 35 | #endif |
Guido van Rossum | 9f462af | 1991-12-10 13:54:12 +0000 | [diff] [blame] | 36 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 37 | #include <stdio.h> |
| 38 | |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 39 | #ifdef USE_STDWIN |
| 40 | #include <stdwin.h> |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 41 | #endif |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 42 | |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 43 | char version[80]; |
| 44 | |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 45 | /*ARGSUSED*/ |
| 46 | void |
| 47 | initargs(p_argc, p_argv) |
| 48 | int *p_argc; |
| 49 | char ***p_argv; |
| 50 | { |
Guido van Rossum | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame^] | 51 | sprintf(version, VERSION, PATCHLEVEL, DATE); |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 52 | |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 53 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 54 | wargs(p_argc, p_argv); |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 55 | #endif |
Guido van Rossum | 9f462af | 1991-12-10 13:54:12 +0000 | [diff] [blame] | 56 | if (*p_argc < 2 && isatty(0) && isatty(1)) |
| 57 | { |
| 58 | printf("Python %s.\n", version); |
Guido van Rossum | aa01141 | 1991-12-16 13:05:20 +0000 | [diff] [blame] | 59 | printf( |
| 60 | "Copyright 1990, 1991, 1992 Stichting Mathematisch Centrum, Amsterdam\n"); |
Guido van Rossum | 9f462af | 1991-12-10 13:54:12 +0000 | [diff] [blame] | 61 | } |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void |
| 65 | initcalls() |
| 66 | { |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void |
| 70 | donecalls() |
| 71 | { |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 72 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 73 | wdone(); |
Guido van Rossum | 28a83ab | 1991-01-18 15:32:01 +0000 | [diff] [blame] | 74 | #endif |
Guido van Rossum | aec7855 | 1990-12-20 23:03:58 +0000 | [diff] [blame] | 75 | #ifdef USE_AUDIO |
| 76 | asa_done(); |
| 77 | #endif |
| 78 | } |
| 79 | |
| 80 | #ifndef PYTHONPATH |
| 81 | #define PYTHONPATH ".:/usr/local/lib/python" |
| 82 | #endif |
| 83 | |
| 84 | extern char *getenv(); |
| 85 | |
| 86 | char * |
| 87 | getpythonpath() |
| 88 | { |
| 89 | char *path = getenv("PYTHONPATH"); |
| 90 | if (path == 0) |
| 91 | path = PYTHONPATH; |
| 92 | return path; |
| 93 | } |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 94 | |
| 95 | |
| 96 | /* Table of built-in modules. |
| 97 | These are initialized when first imported. */ |
| 98 | |
| 99 | /* Standard modules */ |
| 100 | extern void inittime(); |
| 101 | extern void initmath(); |
Guido van Rossum | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame^] | 102 | extern void initregex(); |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 103 | extern void initposix(); |
Guido van Rossum | ac02948 | 1991-04-16 08:39:39 +0000 | [diff] [blame] | 104 | extern void initpwd(); |
| 105 | extern void initgrp(); |
Guido van Rossum | 6f7b959 | 1991-06-04 19:47:46 +0000 | [diff] [blame] | 106 | extern void initmarshal(); |
| 107 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 108 | #ifdef USE_AUDIO |
| 109 | extern void initaudio(); |
| 110 | #endif |
Guido van Rossum | 188f832 | 1991-09-10 14:55:08 +0000 | [diff] [blame] | 111 | #ifdef USE_AL |
| 112 | extern void inital(); |
| 113 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 114 | #ifdef USE_AMOEBA |
| 115 | extern void initamoeba(); |
| 116 | #endif |
| 117 | #ifdef USE_GL |
| 118 | extern void initgl(); |
Guido van Rossum | 2abc7a6 | 1991-04-03 19:01:18 +0000 | [diff] [blame] | 119 | #ifdef USE_FM |
| 120 | extern void initfm(); |
Guido van Rossum | 3fecef7 | 1991-08-16 08:58:56 +0000 | [diff] [blame] | 121 | #ifdef USE_FL |
| 122 | extern void initfl(); |
| 123 | #endif |
Guido van Rossum | 2abc7a6 | 1991-04-03 19:01:18 +0000 | [diff] [blame] | 124 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 125 | #ifdef USE_PANEL |
| 126 | extern void initpanel(); |
| 127 | #endif |
| 128 | #endif |
| 129 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 130 | extern void initstdwin(); |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 131 | #endif |
Guido van Rossum | 49955ae | 1991-07-01 18:45:17 +0000 | [diff] [blame] | 132 | #ifdef USE_SOCKET |
| 133 | extern void initsocket(); |
| 134 | #endif |
Guido van Rossum | 56a5afc | 1991-11-12 15:40:36 +0000 | [diff] [blame] | 135 | #ifdef USE_JPEG |
| 136 | extern void initjpeg(); |
| 137 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 138 | |
| 139 | struct { |
| 140 | char *name; |
| 141 | void (*initfunc)(); |
| 142 | } inittab[] = { |
| 143 | |
| 144 | /* Standard modules */ |
| 145 | |
| 146 | {"time", inittime}, |
| 147 | {"math", initmath}, |
Guido van Rossum | 9b4e1b3 | 1991-12-30 01:43:49 +0000 | [diff] [blame^] | 148 | {"regex", initregex}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 149 | {"posix", initposix}, |
Guido van Rossum | ac02948 | 1991-04-16 08:39:39 +0000 | [diff] [blame] | 150 | {"pwd", initpwd}, |
| 151 | {"grp", initgrp}, |
Guido van Rossum | 6f7b959 | 1991-06-04 19:47:46 +0000 | [diff] [blame] | 152 | {"marshal", initmarshal}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 153 | |
| 154 | |
| 155 | /* Optional modules */ |
| 156 | |
| 157 | #ifdef USE_AUDIO |
| 158 | {"audio", initaudio}, |
| 159 | #endif |
| 160 | |
Guido van Rossum | 188f832 | 1991-09-10 14:55:08 +0000 | [diff] [blame] | 161 | #ifdef USE_AL |
| 162 | {"al", inital}, |
| 163 | #endif |
| 164 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 165 | #ifdef USE_AMOEBA |
| 166 | {"amoeba", initamoeba}, |
| 167 | #endif |
| 168 | |
| 169 | #ifdef USE_GL |
| 170 | {"gl", initgl}, |
Guido van Rossum | 2abc7a6 | 1991-04-03 19:01:18 +0000 | [diff] [blame] | 171 | #ifdef USE_FM |
| 172 | {"fm", initfm}, |
Guido van Rossum | 3fecef7 | 1991-08-16 08:58:56 +0000 | [diff] [blame] | 173 | #ifdef USE_FL |
| 174 | {"fl", initfl}, |
| 175 | #endif |
Guido van Rossum | 2abc7a6 | 1991-04-03 19:01:18 +0000 | [diff] [blame] | 176 | #endif |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 177 | #ifdef USE_PANEL |
| 178 | {"pnl", initpanel}, |
| 179 | #endif |
| 180 | #endif |
| 181 | |
| 182 | #ifdef USE_STDWIN |
Guido van Rossum | 5b02dbc | 1991-06-07 13:55:41 +0000 | [diff] [blame] | 183 | {"stdwin", initstdwin}, |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 184 | #endif |
| 185 | |
Guido van Rossum | 49955ae | 1991-07-01 18:45:17 +0000 | [diff] [blame] | 186 | #ifdef USE_SOCKET |
| 187 | {"socket", initsocket}, |
| 188 | #endif |
| 189 | |
Guido van Rossum | 56a5afc | 1991-11-12 15:40:36 +0000 | [diff] [blame] | 190 | #ifdef USE_JPEG |
| 191 | {"jpeg", initjpeg}, |
| 192 | #endif |
| 193 | |
Guido van Rossum | 59e53a5 | 1991-02-19 12:22:24 +0000 | [diff] [blame] | 194 | {0, 0} /* Sentinel */ |
| 195 | }; |