blob: a41a0d650ae69f743f99c5b37c584fd93c70380c [file] [log] [blame]
Guido van Rossumce9739b1994-01-05 16:17:15 +00001/***********************************************************
2Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
3Amsterdam, The Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
25/* Universal Python configuration file */
26
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
31#include <stdio.h>
32#include <string.h>
33
34#include "myproto.h"
35#include "mymalloc.h"
36#include "osdefs.h"
37#include "intrcheck.h"
38
39
40#ifndef NO_MAIN
41
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(). */
48
49static char *argv0;
50
51main(argc, argv)
52 int argc;
53 char **argv;
54{
55#ifdef macintosh
56 wargs(&argc, &argv);
57#endif
58 argv0 = argv[0];
59 realmain(argc, argv);
60}
61
62char *
63getprogramname()
64{
65 return argv0;
66}
67
68#endif
69
70
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. */
77
78#ifndef PYTHONPATH
79#ifdef macintosh
80#define PYTHONPATH ": :Lib :Lib:stdwin :Demo"
81#endif /* macintosh */
82#endif /* !PYTHONPATH */
83
84#ifndef PYTHONPATH
85#ifdef MSDOS
86#define PYTHONPATH ".;..\\lib;\\python\\lib"
87#endif /* MSDOS */
88#endif /* !PYTHONPATH */
89
90#ifndef PYTHONPATH
91#define PYTHONPATH ".:/usr/local/lib/python"
92#endif /* !PYTHONPATH */
93
94extern char *getenv();
95
96char *
97getpythonpath()
98{
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;
107
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 */
120}
121
122
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. */
127
128extern void initarray();
129extern void initmath();
130extern void initparser();
131extern void initmac();
132extern void initregex();
133extern void initstrop();
134extern void initstruct();
135extern void inittime();
136extern void initdbm();
137extern void initfcntl();
138extern void initnis();
139extern void initpwd();
140extern void initgrp();
141extern void initselect();
142extern void initsocket();
143extern void initaudioop();
144extern void initimageop();
145extern void initrgbimg();
146extern void initstdwin();
147extern void initmd5();
148extern void initmpz();
149extern void initrotor();
150extern void inital();
151extern void initcd();
152extern void initcl();
153extern void initfm();
154extern void initgl();
155extern void initimgfile();
156extern void initsgi();
157extern void initsv();
158extern void initfl();
159extern void initthread();
160extern void inittiming();
161
162/* -- ADDMODULE MARKER 1 -- */
163
164extern void initmarshal();
165
166struct {
167 char *name;
168 void (*initfunc)();
169} inittab[] = {
170
171 {"array", initarray},
172 {"math", initmath},
173 {"parser", initparser},
174 {"mac", initmac},
175 {"regex", initregex},
176 {"strop", initstrop},
177 {"struct", initstruct},
178 {"time", inittime},
179 {"audioop", initaudioop},
180 {"imageop", initimageop},
181 {"rgbimg", initrgbimg},
182 {"stdwin", initstdwin},
183 {"md5", initmd5},
184 {"rotor", initrotor},
185
186/* -- ADDMODULE MARKER 2 -- */
187
188 /* This module "lives in" with marshal.c */
189 {"marshal", initmarshal},
190
191 /* These entries are here for sys.builtin_module_names */
192 {"__main__", NULL},
193 {"__builtin__", NULL},
194 {"sys", NULL},
195
196 /* Sentinel */
197 {0, 0}
198};
199
200#ifdef USE_FROZEN
201#include "frozen.c"
202#else
203struct frozen {
204 char *name;
205 char *code;
206 int size;
207} frozen_modules[] = {
208 {0, 0, 0}
209};
210#endif