improve treatment of multi-line replies, ignore empty lines
[python/dscho.git] / Modules / config.c.in
blob0c2f114489d1be952ac687d11b8642ebaa851748
1 /* -*- C -*- ***********************************************
2 Copyright 1991-1994 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 #if defined(__cplusplus)
66 int realmain(int, char**);
67 main(int argc, char **argv)
68 #else
69 main(argc, argv)
70 int argc;
71 char **argv;
72 #endif
74 orig_argc = argc;
75 orig_argv = argv;
76 argv0 = argv[0];
77 realmain(argc, argv);
80 char *
81 getprogramname()
83 return argv0;
86 void
87 #if defined(__cplusplus)
88 getargcargv(int *argc, char ***argv)
89 #else
90 getargcargv(argc,argv)
91 int *argc;
92 char ***argv;
93 #endif
95 *argc = orig_argc;
96 *argv = orig_argv;
99 #endif
102 /* Python version information */
104 #include "patchlevel.h"
106 /* Return the version string. This is constructed from the official
107 version number (from patchlevel.h), and the current date (if known
108 to the compiler, else a manually inserted date). */
110 #define VERSION "%s (%s)"
112 #ifdef __DATE__
113 #define DATE __DATE__
114 #else
115 #define DATE "Aug 17 1994"
116 #endif
118 char *
119 getversion()
121 static char version[80];
122 sprintf(version, VERSION, PATCHLEVEL, DATE);
123 return version;
127 /* Return the copyright string. This is updated manually. */
129 char *
130 getcopyright()
132 return "Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam";
136 /* Return the initial python search path. This is called once from
137 initsys() to initialize sys.path.
138 The environment variable PYTHONPATH is fetched and the default path
139 appended. (The Mac has no environment variables, so there the
140 default path is always returned.) The default path may be passed
141 to the preprocessor; if not, a system-dependent default is used. */
143 #ifndef PYTHONPATH
144 #ifdef macintosh
145 #define PYTHONPATH ": :Lib :Lib:stdwin :Lib:test :Lib:mac"
146 #endif /* macintosh */
147 #endif /* !PYTHONPATH */
149 #ifndef PYTHONPATH
150 #if defined(MSDOS) || defined(NT)
151 #define PYTHONPATH ".;..\\lib;\\python\\lib"
152 #endif /* MSDOS || NT */
153 #endif /* !PYTHONPATH */
155 #ifndef PYTHONPATH
156 #define PYTHONPATH ".:/usr/local/lib/python"
157 #endif /* !PYTHONPATH */
159 #ifndef __cplusplus
160 extern char *getenv();
161 #endif
163 char *
164 getpythonpath()
166 #ifdef __cplusplus
167 void fatal(char *);
168 #endif
169 char *path = getenv("PYTHONPATH");
170 char *defpath = PYTHONPATH;
171 static char *buf = NULL;
172 char *p;
173 int n;
175 if (path == NULL)
176 path = "";
177 n = strlen(path) + strlen(defpath) + 2;
178 if (buf != NULL) {
179 free(buf);
180 buf = NULL;
182 buf = malloc(n);
183 if (buf == NULL)
184 fatal("not enough memory to copy module search path");
185 strcpy(buf, path);
186 p = buf + strlen(buf);
187 if (p != buf)
188 *p++ = DELIM;
189 strcpy(p, defpath);
190 return buf;
194 /* Table of built-in modules.
195 These are initialized when first imported.
196 Note: selection of optional extensions is now generally done by the
197 makesetup script. */
199 /* -- ADDMODULE MARKER 1 -- */
201 extern void initmarshal();
202 extern void initimp();
204 struct {
205 char *name;
206 void (*initfunc)();
207 } inittab[] = {
209 /* -- ADDMODULE MARKER 2 -- */
211 /* This module "lives in" with marshal.c */
212 {"marshal", initmarshal},
214 /* This lives it with import.c */
215 {"imp", initimp},
217 /* These entries are here for sys.builtin_module_names */
218 {"__main__", NULL},
219 {"__builtin__", NULL},
220 {"sys", NULL},
222 /* Sentinel */
223 {0, 0}
226 #ifndef USE_FROZEN
227 struct frozen {
228 char *name;
229 char *code;
230 int size;
231 } frozen_modules[] = {
232 {0, 0, 0}
234 #endif
236 #if defined(__cplusplus)
238 #endif