blob: 40facc271fd7734ac4ab3eb5b33d6405388a4669 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001/***********************************************************
2Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
3Netherlands.
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 Rossum28a83ab1991-01-18 15:32:01 +000025/* Configurable Python configuration file */
Guido van Rossumaec78551990-12-20 23:03:58 +000026
Guido van Rossum59e53a51991-02-19 12:22:24 +000027#include <stdio.h>
28
Guido van Rossum28a83ab1991-01-18 15:32:01 +000029#ifdef USE_STDWIN
30#include <stdwin.h>
Guido van Rossumaec78551990-12-20 23:03:58 +000031
32static int use_stdwin;
Guido van Rossum28a83ab1991-01-18 15:32:01 +000033#endif
Guido van Rossumaec78551990-12-20 23:03:58 +000034
35/*ARGSUSED*/
36void
37initargs(p_argc, p_argv)
38 int *p_argc;
39 char ***p_argv;
40{
Guido van Rossum28a83ab1991-01-18 15:32:01 +000041#ifdef USE_STDWIN
Guido van Rossumaec78551990-12-20 23:03:58 +000042 extern char *getenv();
43 char *display;
Guido van Rossum6607f441991-01-02 13:50:48 +000044
45 /* Ignore an initial argument of '-s', for backward compatibility */
46 if (*p_argc > 1 && strcmp((*p_argv)[1], "-s") == 0) {
47 (*p_argv)[1] = (*p_argv)[0];
48 (*p_argc)--, (*p_argv)++;
49 }
50
Guido van Rossumaec78551990-12-20 23:03:58 +000051 /* Assume we have to initialize stdwin if either of the following
52 conditions holds:
53 - the environment variable $DISPLAY is set
54 - there is an argument "-display" somewhere
55 */
56
57 display = getenv("DISPLAY");
58 if (display != 0)
59 use_stdwin = 1;
60 else {
61 int i;
62 /* Scan through the arguments looking for "-display" */
63 for (i = 1; i < *p_argc; i++) {
64 if (strcmp((*p_argv)[i], "-display") == 0) {
65 use_stdwin = 1;
66 break;
67 }
68 }
69 }
70
71 if (use_stdwin)
Guido van Rossum59e53a51991-02-19 12:22:24 +000072 wargs(p_argc, p_argv);
Guido van Rossum28a83ab1991-01-18 15:32:01 +000073#endif
Guido van Rossumaec78551990-12-20 23:03:58 +000074}
75
76void
77initcalls()
78{
Guido van Rossumaec78551990-12-20 23:03:58 +000079}
80
81void
82donecalls()
83{
Guido van Rossum28a83ab1991-01-18 15:32:01 +000084#ifdef USE_STDWIN
Guido van Rossumaec78551990-12-20 23:03:58 +000085 if (use_stdwin)
86 wdone();
Guido van Rossum28a83ab1991-01-18 15:32:01 +000087#endif
Guido van Rossumaec78551990-12-20 23:03:58 +000088#ifdef USE_AUDIO
89 asa_done();
90#endif
91}
92
Guido van Rossum59e53a51991-02-19 12:22:24 +000093#ifdef USE_STDWIN
94static void
95maybeinitstdwin()
96{
97 if (use_stdwin)
98 initstdwin();
99 else
100 fprintf(stderr,
101 "No $DISPLAY nor -display arg -- stdwin not available\n");
102}
103#endif
104
Guido van Rossumaec78551990-12-20 23:03:58 +0000105#ifndef PYTHONPATH
106#define PYTHONPATH ".:/usr/local/lib/python"
107#endif
108
109extern char *getenv();
110
111char *
112getpythonpath()
113{
114 char *path = getenv("PYTHONPATH");
115 if (path == 0)
116 path = PYTHONPATH;
117 return path;
118}
Guido van Rossum59e53a51991-02-19 12:22:24 +0000119
120
121/* Table of built-in modules.
122 These are initialized when first imported. */
123
124/* Standard modules */
125extern void inittime();
126extern void initmath();
127extern void initregexp();
128extern void initposix();
129#ifdef USE_AUDIO
130extern void initaudio();
131#endif
132#ifdef USE_AMOEBA
133extern void initamoeba();
134#endif
135#ifdef USE_GL
136extern void initgl();
Guido van Rossum2abc7a61991-04-03 19:01:18 +0000137#ifdef USE_FM
138extern void initfm();
139#endif
Guido van Rossum59e53a51991-02-19 12:22:24 +0000140#ifdef USE_PANEL
141extern void initpanel();
142#endif
143#endif
144#ifdef USE_STDWIN
145extern void maybeinitstdwin();
146#endif
147
148struct {
149 char *name;
150 void (*initfunc)();
151} inittab[] = {
152
153 /* Standard modules */
154
155 {"time", inittime},
156 {"math", initmath},
157 {"regexp", initregexp},
158 {"posix", initposix},
159
160
161 /* Optional modules */
162
163#ifdef USE_AUDIO
164 {"audio", initaudio},
165#endif
166
167#ifdef USE_AMOEBA
168 {"amoeba", initamoeba},
169#endif
170
171#ifdef USE_GL
172 {"gl", initgl},
Guido van Rossum2abc7a61991-04-03 19:01:18 +0000173#ifdef USE_FM
174 {"fm", initfm},
175#endif
Guido van Rossum59e53a51991-02-19 12:22:24 +0000176#ifdef USE_PANEL
177 {"pnl", initpanel},
178#endif
179#endif
180
181#ifdef USE_STDWIN
182 {"stdwin", maybeinitstdwin},
183#endif
184
185 {0, 0} /* Sentinel */
186};