blob: 3595a9ea81bc3408b8d5d6bc5379ae9a71102373 [file] [log] [blame]
Guido van Rossumd4d77281994-08-19 10:51:31 +00001/* -*- C -*- ***********************************************
2Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Guido van Rossumce9739b1994-01-05 16:17:15 +00003Amsterdam, 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
Guido van Rossum29e7af01994-08-23 13:28:34 +000025/* Macintosh Python configuration file */
Guido van Rossumce9739b1994-01-05 16:17:15 +000026
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif
30
Guido van Rossum29e7af01994-08-23 13:28:34 +000031#ifdef macintosh
32/* The Macintosh main program is in macmain.c */
33#define NO_MAIN
Guido van Rossum29e7af01994-08-23 13:28:34 +000034#endif
35
Guido van Rossumce9739b1994-01-05 16:17:15 +000036#include <stdio.h>
37#include <string.h>
38
39#include "myproto.h"
40#include "mymalloc.h"
41#include "osdefs.h"
Guido van Rossumd4d77281994-08-19 10:51:31 +000042#include "intrcheck.h"
Guido van Rossumce9739b1994-01-05 16:17:15 +000043
44
45#ifndef NO_MAIN
46
47/* Normally, the main program is called from here (so everything else
48 can be in libPython.a). We save a pointer to argv[0] because it
49 may be needed for dynamic loading of modules in import.c. If you
50 have your own main program and want to use non-SunOS dynamic
51 loading, you will have to provide your own version of
52 getprogramname(). */
53
54static char *argv0;
55
56main(argc, argv)
57 int argc;
58 char **argv;
59{
Guido van Rossumce9739b1994-01-05 16:17:15 +000060 argv0 = argv[0];
61 realmain(argc, argv);
62}
63
64char *
65getprogramname()
66{
67 return argv0;
68}
69
70#endif
71
72
Guido van Rossumd4d77281994-08-19 10:51:31 +000073/* Python version information */
74
75#include "patchlevel.h"
76
77/* Return the version string. This is constructed from the official
78 version number (from patchlevel.h), and the current date (if known
79 to the compiler, else a manually inserted date). */
80
81#define VERSION "%s (%s)"
82
83#ifdef __DATE__
84#define DATE __DATE__
85#else
86#define DATE "Aug 17 1994"
87#endif
88
89char *
90getversion()
91{
92 static char version[80];
93 sprintf(version, VERSION, PATCHLEVEL, DATE);
94 return version;
95}
96
97
98/* Return the copyright string. This is updated manually. */
99
100char *
101getcopyright()
102{
103 return "Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam";
104}
105
106
Guido van Rossumce9739b1994-01-05 16:17:15 +0000107/* Return the initial python search path. This is called once from
108 initsys() to initialize sys.path.
109 The environment variable PYTHONPATH is fetched and the default path
110 appended. (The Mac has no environment variables, so there the
111 default path is always returned.) The default path may be passed
112 to the preprocessor; if not, a system-dependent default is used. */
113
114#ifndef PYTHONPATH
115#ifdef macintosh
Guido van Rossumd4d77281994-08-19 10:51:31 +0000116#define PYTHONPATH ": :Lib :Lib:stdwin :Lib:test :Lib:mac"
Guido van Rossumce9739b1994-01-05 16:17:15 +0000117#endif /* macintosh */
118#endif /* !PYTHONPATH */
119
120#ifndef PYTHONPATH
Guido van Rossumd4d77281994-08-19 10:51:31 +0000121#if defined(MSDOS) || defined(NT)
Guido van Rossumce9739b1994-01-05 16:17:15 +0000122#define PYTHONPATH ".;..\\lib;\\python\\lib"
Guido van Rossumd4d77281994-08-19 10:51:31 +0000123#endif /* MSDOS || NT */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000124#endif /* !PYTHONPATH */
125
126#ifndef PYTHONPATH
127#define PYTHONPATH ".:/usr/local/lib/python"
128#endif /* !PYTHONPATH */
129
130extern char *getenv();
131
132char *
133getpythonpath()
134{
135#ifdef macintosh
136 return PYTHONPATH;
137#else /* !macintosh */
138 char *path = getenv("PYTHONPATH");
139 char *defpath = PYTHONPATH;
140 char *buf;
141 char *p;
142 int n;
143
144 if (path == 0 || *path == '\0')
145 return defpath;
146 n = strlen(path) + strlen(defpath) + 2;
147 buf = malloc(n);
148 if (buf == NULL)
149 return path; /* XXX too bad -- but not likely */
150 strcpy(buf, path);
151 p = buf + strlen(buf);
152 *p++ = DELIM;
153 strcpy(p, defpath);
154 return buf;
155#endif /* !macintosh */
156}
157
158
159/* Table of built-in modules.
160 These are initialized when first imported.
161 Note: selection of optional extensions is now generally done by the
162 makesetup script. */
163
164extern void initarray();
165extern void initmath();
166extern void initparser();
167extern void initmac();
168extern void initregex();
169extern void initstrop();
170extern void initstruct();
171extern void inittime();
172extern void initdbm();
173extern void initfcntl();
174extern void initnis();
175extern void initpwd();
176extern void initgrp();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000177extern void initcrypt();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000178extern void initselect();
179extern void initsocket();
180extern void initaudioop();
181extern void initimageop();
182extern void initrgbimg();
183extern void initstdwin();
184extern void initmd5();
185extern void initmpz();
186extern void initrotor();
187extern void inital();
188extern void initcd();
189extern void initcl();
190extern void initfm();
191extern void initgl();
192extern void initimgfile();
Guido van Rossum29e7af01994-08-23 13:28:34 +0000193extern void initimgformat();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000194extern void initsgi();
195extern void initsv();
196extern void initfl();
197extern void initthread();
198extern void inittiming();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000199extern void initsignal();
200extern void initnew();
201extern void initdl();
202extern void initsyslog();
Guido van Rossum29e7af01994-08-23 13:28:34 +0000203extern void initgestalt();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000204
205/* -- ADDMODULE MARKER 1 -- */
206
207extern void initmarshal();
208
209struct {
210 char *name;
211 void (*initfunc)();
212} inittab[] = {
213
214 {"array", initarray},
215 {"math", initmath},
216 {"parser", initparser},
217 {"mac", initmac},
218 {"regex", initregex},
219 {"strop", initstrop},
220 {"struct", initstruct},
221 {"time", inittime},
222 {"audioop", initaudioop},
223 {"imageop", initimageop},
224 {"rgbimg", initrgbimg},
Guido van Rossum29e7af01994-08-23 13:28:34 +0000225#ifdef USE_STDWIN
226 {"stdwin", initstdwin},
227#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +0000228 {"md5", initmd5},
229 {"rotor", initrotor},
Guido van Rossumd4d77281994-08-19 10:51:31 +0000230 {"new", initnew},
Guido van Rossum29e7af01994-08-23 13:28:34 +0000231 {"gestalt", initgestalt},
232 {"imgformat", initimgformat},
Guido van Rossumce9739b1994-01-05 16:17:15 +0000233
234/* -- ADDMODULE MARKER 2 -- */
235
236 /* This module "lives in" with marshal.c */
237 {"marshal", initmarshal},
238
239 /* These entries are here for sys.builtin_module_names */
240 {"__main__", NULL},
241 {"__builtin__", NULL},
242 {"sys", NULL},
243
244 /* Sentinel */
245 {0, 0}
246};
247
248#ifdef USE_FROZEN
249#include "frozen.c"
250#else
251struct frozen {
252 char *name;
253 char *code;
254 int size;
255} frozen_modules[] = {
256 {0, 0, 0}
257};
258#endif