This commit was manufactured by cvs2svn to create tag 'release101'.
[python/dscho.git] / Modules / config.c.in
blob461ceb9a07f14239de462e35f95577d86e38f60d
1 /* -*- C -*- ***********************************************
2 Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
3 Amsterdam, 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 #include <stdio.h>
32 #include <string.h>
34 #include "myproto.h"
35 #include "mymalloc.h"
36 #include "osdefs.h"
37 #include "intrcheck.h"
40 #ifndef NO_MAIN
42 /* Normally, the main program is called from here (so everything else
43 can be in libPython.a). We save a pointer to argv[0] because it
44 may be needed for dynamic loading of modules in import.c. If you
45 have your own main program and want to use non-SunOS dynamic
46 loading, you will have to provide your own version of
47 getprogramname(). */
49 static char *argv0;
51 main(argc, argv)
52 int argc;
53 char **argv;
55 #ifdef macintosh
56 wargs(&argc, &argv);
57 #endif
58 argv0 = argv[0];
59 realmain(argc, argv);
62 char *
63 getprogramname()
65 return argv0;
68 #endif
71 /* Return the initial python search path. This is called once from
72 initsys() to initialize sys.path.
73 The environment variable PYTHONPATH is fetched and the default path
74 appended. (The Mac has no environment variables, so there the
75 default path is always returned.) The default path may be passed
76 to the preprocessor; if not, a system-dependent default is used. */
78 #ifndef PYTHONPATH
79 #ifdef macintosh
80 #define PYTHONPATH ": :Lib :Lib:stdwin :Demo"
81 #endif /* macintosh */
82 #endif /* !PYTHONPATH */
84 #ifndef PYTHONPATH
85 #ifdef MSDOS
86 #define PYTHONPATH ".;..\\lib;\\python\\lib"
87 #endif /* MSDOS */
88 #endif /* !PYTHONPATH */
90 #ifndef PYTHONPATH
91 #define PYTHONPATH ".:/usr/local/lib/python"
92 #endif /* !PYTHONPATH */
94 extern char *getenv();
96 char *
97 getpythonpath()
99 #ifdef macintosh
100 return PYTHONPATH;
101 #else /* !macintosh */
102 char *path = getenv("PYTHONPATH");
103 char *defpath = PYTHONPATH;
104 char *buf;
105 char *p;
106 int n;
108 if (path == 0 || *path == '\0')
109 return defpath;
110 n = strlen(path) + strlen(defpath) + 2;
111 buf = malloc(n);
112 if (buf == NULL)
113 return path; /* XXX too bad -- but not likely */
114 strcpy(buf, path);
115 p = buf + strlen(buf);
116 *p++ = DELIM;
117 strcpy(p, defpath);
118 return buf;
119 #endif /* !macintosh */
123 /* Table of built-in modules.
124 These are initialized when first imported.
125 Note: selection of optional extensions is now generally done by the
126 makesetup script. */
128 /* -- ADDMODULE MARKER 1 -- */
130 extern void initmarshal();
132 struct {
133 char *name;
134 void (*initfunc)();
135 } inittab[] = {
137 /* -- ADDMODULE MARKER 2 -- */
139 /* This module "lives in" with marshal.c */
140 {"marshal", initmarshal},
142 /* These entries are here for sys.builtin_module_names */
143 {"__main__", NULL},
144 {"__builtin__", NULL},
145 {"sys", NULL},
147 /* Sentinel */
148 {0, 0}
151 #ifdef USE_FROZEN
152 #include "frozen.c"
153 #else
154 struct frozen {
155 char *name;
156 char *code;
157 int size;
158 } frozen_modules[] = {
159 {0, 0, 0}
161 #endif