blob: b1c6e2c8aa08ff40942462c4cd11429ad823a8e6 [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();
Guido van Rossume433c971994-09-29 10:02:56 +0000168extern void MacOS_Init();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000169extern void initregex();
170extern void initstrop();
171extern void initstruct();
172extern void inittime();
173extern void initdbm();
174extern void initfcntl();
175extern void initnis();
176extern void initpwd();
177extern void initgrp();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000178extern void initcrypt();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000179extern void initselect();
180extern void initsocket();
181extern void initaudioop();
182extern void initimageop();
183extern void initrgbimg();
184extern void initstdwin();
185extern void initmd5();
186extern void initmpz();
187extern void initrotor();
188extern void inital();
189extern void initcd();
190extern void initcl();
191extern void initfm();
192extern void initgl();
193extern void initimgfile();
Guido van Rossum29e7af01994-08-23 13:28:34 +0000194extern void initimgformat();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000195extern void initsgi();
196extern void initsv();
197extern void initfl();
198extern void initthread();
199extern void inittiming();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000200extern void initsignal();
201extern void initnew();
202extern void initdl();
203extern void initsyslog();
Guido van Rossum29e7af01994-08-23 13:28:34 +0000204extern void initgestalt();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000205
206/* -- ADDMODULE MARKER 1 -- */
207
208extern void initmarshal();
209
210struct {
211 char *name;
212 void (*initfunc)();
213} inittab[] = {
214
215 {"array", initarray},
216 {"math", initmath},
217 {"parser", initparser},
218 {"mac", initmac},
Guido van Rossume433c971994-09-29 10:02:56 +0000219 {"MacOS", MacOS_Init},
Guido van Rossumce9739b1994-01-05 16:17:15 +0000220 {"regex", initregex},
221 {"strop", initstrop},
222 {"struct", initstruct},
223 {"time", inittime},
224 {"audioop", initaudioop},
225 {"imageop", initimageop},
226 {"rgbimg", initrgbimg},
Guido van Rossum29e7af01994-08-23 13:28:34 +0000227#ifdef USE_STDWIN
228 {"stdwin", initstdwin},
229#endif
Guido van Rossumce9739b1994-01-05 16:17:15 +0000230 {"md5", initmd5},
231 {"rotor", initrotor},
Guido van Rossumd4d77281994-08-19 10:51:31 +0000232 {"new", initnew},
Guido van Rossum29e7af01994-08-23 13:28:34 +0000233 {"gestalt", initgestalt},
234 {"imgformat", initimgformat},
Guido van Rossumce9739b1994-01-05 16:17:15 +0000235
236/* -- ADDMODULE MARKER 2 -- */
237
238 /* This module "lives in" with marshal.c */
239 {"marshal", initmarshal},
240
241 /* These entries are here for sys.builtin_module_names */
242 {"__main__", NULL},
243 {"__builtin__", NULL},
244 {"sys", NULL},
245
246 /* Sentinel */
247 {0, 0}
248};
249
250#ifdef USE_FROZEN
251#include "frozen.c"
252#else
253struct frozen {
254 char *name;
255 char *code;
256 int size;
257} frozen_modules[] = {
258 {0, 0, 0}
259};
260#endif