blob: 54fed7430dec532036602e86cc9256330ce936e7 [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
34/* Comment this out if you're not interested in STDWIN */
35#define USE_STDWIN
36#endif
37
Guido van Rossumce9739b1994-01-05 16:17:15 +000038#include <stdio.h>
39#include <string.h>
40
41#include "myproto.h"
42#include "mymalloc.h"
43#include "osdefs.h"
Guido van Rossumd4d77281994-08-19 10:51:31 +000044#include "intrcheck.h"
Guido van Rossumce9739b1994-01-05 16:17:15 +000045
46
47#ifndef NO_MAIN
48
49/* Normally, the main program is called from here (so everything else
50 can be in libPython.a). We save a pointer to argv[0] because it
51 may be needed for dynamic loading of modules in import.c. If you
52 have your own main program and want to use non-SunOS dynamic
53 loading, you will have to provide your own version of
54 getprogramname(). */
55
56static char *argv0;
57
58main(argc, argv)
59 int argc;
60 char **argv;
61{
Guido van Rossumce9739b1994-01-05 16:17:15 +000062 argv0 = argv[0];
63 realmain(argc, argv);
64}
65
66char *
67getprogramname()
68{
69 return argv0;
70}
71
72#endif
73
74
Guido van Rossumd4d77281994-08-19 10:51:31 +000075/* Python version information */
76
77#include "patchlevel.h"
78
79/* Return the version string. This is constructed from the official
80 version number (from patchlevel.h), and the current date (if known
81 to the compiler, else a manually inserted date). */
82
83#define VERSION "%s (%s)"
84
85#ifdef __DATE__
86#define DATE __DATE__
87#else
88#define DATE "Aug 17 1994"
89#endif
90
91char *
92getversion()
93{
94 static char version[80];
95 sprintf(version, VERSION, PATCHLEVEL, DATE);
96 return version;
97}
98
99
100/* Return the copyright string. This is updated manually. */
101
102char *
103getcopyright()
104{
105 return "Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam";
106}
107
108
Guido van Rossumce9739b1994-01-05 16:17:15 +0000109/* Return the initial python search path. This is called once from
110 initsys() to initialize sys.path.
111 The environment variable PYTHONPATH is fetched and the default path
112 appended. (The Mac has no environment variables, so there the
113 default path is always returned.) The default path may be passed
114 to the preprocessor; if not, a system-dependent default is used. */
115
116#ifndef PYTHONPATH
117#ifdef macintosh
Guido van Rossumd4d77281994-08-19 10:51:31 +0000118#define PYTHONPATH ": :Lib :Lib:stdwin :Lib:test :Lib:mac"
Guido van Rossumce9739b1994-01-05 16:17:15 +0000119#endif /* macintosh */
120#endif /* !PYTHONPATH */
121
122#ifndef PYTHONPATH
Guido van Rossumd4d77281994-08-19 10:51:31 +0000123#if defined(MSDOS) || defined(NT)
Guido van Rossumce9739b1994-01-05 16:17:15 +0000124#define PYTHONPATH ".;..\\lib;\\python\\lib"
Guido van Rossumd4d77281994-08-19 10:51:31 +0000125#endif /* MSDOS || NT */
Guido van Rossumce9739b1994-01-05 16:17:15 +0000126#endif /* !PYTHONPATH */
127
128#ifndef PYTHONPATH
129#define PYTHONPATH ".:/usr/local/lib/python"
130#endif /* !PYTHONPATH */
131
132extern char *getenv();
133
134char *
135getpythonpath()
136{
137#ifdef macintosh
138 return PYTHONPATH;
139#else /* !macintosh */
140 char *path = getenv("PYTHONPATH");
141 char *defpath = PYTHONPATH;
142 char *buf;
143 char *p;
144 int n;
145
146 if (path == 0 || *path == '\0')
147 return defpath;
148 n = strlen(path) + strlen(defpath) + 2;
149 buf = malloc(n);
150 if (buf == NULL)
151 return path; /* XXX too bad -- but not likely */
152 strcpy(buf, path);
153 p = buf + strlen(buf);
154 *p++ = DELIM;
155 strcpy(p, defpath);
156 return buf;
157#endif /* !macintosh */
158}
159
160
161/* Table of built-in modules.
162 These are initialized when first imported.
163 Note: selection of optional extensions is now generally done by the
164 makesetup script. */
165
166extern void initarray();
167extern void initmath();
168extern void initparser();
169extern void initmac();
170extern void initregex();
171extern void initstrop();
172extern void initstruct();
173extern void inittime();
174extern void initdbm();
175extern void initfcntl();
176extern void initnis();
177extern void initpwd();
178extern void initgrp();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000179extern void initcrypt();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000180extern void initselect();
181extern void initsocket();
182extern void initaudioop();
183extern void initimageop();
184extern void initrgbimg();
185extern void initstdwin();
186extern void initmd5();
187extern void initmpz();
188extern void initrotor();
189extern void inital();
190extern void initcd();
191extern void initcl();
192extern void initfm();
193extern void initgl();
194extern void initimgfile();
Guido van Rossum29e7af01994-08-23 13:28:34 +0000195extern void initimgformat();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000196extern void initsgi();
197extern void initsv();
198extern void initfl();
199extern void initthread();
200extern void inittiming();
Guido van Rossumd4d77281994-08-19 10:51:31 +0000201extern void initsignal();
202extern void initnew();
203extern void initdl();
204extern void initsyslog();
Guido van Rossum29e7af01994-08-23 13:28:34 +0000205extern void initgestalt();
Guido van Rossumce9739b1994-01-05 16:17:15 +0000206
207/* -- ADDMODULE MARKER 1 -- */
208
209extern void initmarshal();
210
211struct {
212 char *name;
213 void (*initfunc)();
214} inittab[] = {
215
216 {"array", initarray},
217 {"math", initmath},
218 {"parser", initparser},
219 {"mac", initmac},
220 {"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