#changed all email address to go through python.org
[python/dscho.git] / Modules / config.c.in
blob327b9a0ceaa15225af20a2ebce269763c173fc40
1 /* -*- C -*- ***********************************************
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3 The Netherlands.
5 All Rights Reserved
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.
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.
23 ******************************************************************/
25 /* Universal Python configuration file */
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
31 #ifdef macintosh
32 /* The Macintosh main program is in macmain.c */
33 #define NO_MAIN
34 #endif
36 #include <stdio.h>
37 #include <string.h>
39 #include "myproto.h"
40 #include "mymalloc.h"
41 #include "osdefs.h"
42 #include "intrcheck.h"
44 #if defined(__cplusplus)
45 extern "C" {
46 #endif
48 #ifndef NO_MAIN
50 /* Normally, the main program is called from here (so everything else
51 can be in libPython.a). We save a pointer to argv[0] because it
52 may be needed for dynamic loading of modules in import.c. If you
53 have your own main program and want to use non-SunOS dynamic
54 loading, you will have to provide your own version of
55 getprogramname(). */
57 static char *argv0;
59 /* These are made available for other modules that might need them.
60 This is rare, but it is needed by the secureware module. */
62 static char **orig_argv;
63 static int orig_argc;
65 extern int realmain PROTO((int, char**));
67 #if defined(__cplusplus)
68 main(int argc, char **argv)
69 #else
70 main(argc, argv)
71 int argc;
72 char **argv;
73 #endif
75 orig_argc = argc;
76 orig_argv = argv;
77 argv0 = argv[0];
78 realmain(argc, argv);
81 char *
82 getprogramname()
84 return argv0;
87 void
88 #if defined(__cplusplus)
89 getargcargv(int *argc, char ***argv)
90 #else
91 getargcargv(argc,argv)
92 int *argc;
93 char ***argv;
94 #endif
96 *argc = orig_argc;
97 *argv = orig_argv;
100 #endif
103 /* Python version information */
105 #include "patchlevel.h"
107 /* Return the version string. This is constructed from the official
108 version number (from patchlevel.h), and the current date (if known
109 to the compiler, else a manually inserted date). */
111 #define VERSION "%s (%s)%s"
113 #ifdef __DATE__
114 #define DATE __DATE__
115 #else
116 #define DATE "Feb 13 1995"
117 #endif
119 #ifdef THINK_C
120 #define COMPILER " [THINK C]"
121 #endif
123 #ifdef __MWERKS__
124 #ifdef __powerc
125 #define COMPILER " [CW PPC]"
126 #else
127 #define COMPILER " [CW 68K]"
128 #endif
129 #endif
131 #ifdef MPW
132 #ifdef __SC__
133 #define COMPILER " [Symantec MPW]"
134 #else
135 #define COMPILER " [Apple MPW]"
136 #endif
137 #endif
139 #ifdef __GNUC__
140 #define COMPILER " [GCC " __VERSION__ "]"
141 #endif
143 #ifndef COMPILER
144 #define COMPILER ""
145 #endif
147 char *
148 getversion()
150 static char version[80];
151 sprintf(version, VERSION, PATCHLEVEL, DATE, COMPILER);
152 return version;
156 /* Return the copyright string. This is updated manually. */
158 char *
159 getcopyright()
161 return "Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam";
165 /* Return the initial python search path. This is called once from
166 initsys() to initialize sys.path.
167 The environment variable PYTHONPATH is fetched and the default path
168 appended. (The Mac has no environment variables, so there the
169 default path is always returned.) The default path may be passed
170 to the preprocessor; if not, a system-dependent default is used. */
172 #ifndef PYTHONPATH
173 #ifdef macintosh
174 #define PYTHONPATH ": :Lib :Lib:stdwin :Lib:test :Lib:mac"
175 #endif /* macintosh */
176 #endif /* !PYTHONPATH */
178 #ifndef PYTHONPATH
179 #if defined(MSDOS) || defined(NT)
180 #define PYTHONPATH ".;..\\lib;\\python\\lib"
181 #endif /* MSDOS || NT */
182 #endif /* !PYTHONPATH */
184 #ifndef PYTHONPATH
185 #define PYTHONPATH ".:/usr/local/lib/python"
186 #endif /* !PYTHONPATH */
188 #ifndef __cplusplus
189 extern char *getenv();
190 #endif
192 char *
193 getpythonpath()
195 #ifdef __cplusplus
196 void fatal(char *);
197 #endif
198 char *path = getenv("PYTHONPATH");
199 char *defpath = PYTHONPATH;
200 static char *buf = NULL;
201 char *p;
202 int n;
204 if (path == NULL)
205 path = "";
206 n = strlen(path) + strlen(defpath) + 2;
207 if (buf != NULL) {
208 free(buf);
209 buf = NULL;
211 buf = malloc(n);
212 if (buf == NULL)
213 fatal("not enough memory to copy module search path");
214 strcpy(buf, path);
215 p = buf + strlen(buf);
216 if (p != buf)
217 *p++ = DELIM;
218 strcpy(p, defpath);
219 return buf;
223 /* Table of built-in modules.
224 These are initialized when first imported.
225 Note: selection of optional extensions is now generally done by the
226 makesetup script. */
228 /* -- ADDMODULE MARKER 1 -- */
230 extern void initmarshal();
231 extern void initimp();
233 struct {
234 char *name;
235 void (*initfunc)();
236 } inittab[] = {
238 /* -- ADDMODULE MARKER 2 -- */
240 /* This module "lives in" with marshal.c */
241 {"marshal", initmarshal},
243 /* This lives it with import.c */
244 {"imp", initimp},
246 /* These entries are here for sys.builtin_module_names */
247 {"__main__", NULL},
248 {"__builtin__", NULL},
249 {"sys", NULL},
251 /* Sentinel */
252 {0, 0}
255 #ifndef USE_FROZEN
256 struct frozen {
257 char *name;
258 char *code;
259 int size;
260 } frozen_modules[] = {
261 {0, 0, 0}
263 #endif
265 #if defined(__cplusplus)
267 #endif