blob: 543672309d224fb82cf95f9c8215be6b3789b894 [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();
Guido van Rossumac029481991-04-16 08:39:39 +0000129extern void initpwd();
130extern void initgrp();
Guido van Rossum59e53a51991-02-19 12:22:24 +0000131#ifdef USE_AUDIO
132extern void initaudio();
133#endif
134#ifdef USE_AMOEBA
135extern void initamoeba();
136#endif
137#ifdef USE_GL
138extern void initgl();
Guido van Rossum2abc7a61991-04-03 19:01:18 +0000139#ifdef USE_FM
140extern void initfm();
141#endif
Guido van Rossum59e53a51991-02-19 12:22:24 +0000142#ifdef USE_PANEL
143extern void initpanel();
144#endif
145#endif
146#ifdef USE_STDWIN
147extern void maybeinitstdwin();
148#endif
149
150struct {
151 char *name;
152 void (*initfunc)();
153} inittab[] = {
154
155 /* Standard modules */
156
157 {"time", inittime},
158 {"math", initmath},
159 {"regexp", initregexp},
160 {"posix", initposix},
Guido van Rossumac029481991-04-16 08:39:39 +0000161 {"pwd", initpwd},
162 {"grp", initgrp},
Guido van Rossum59e53a51991-02-19 12:22:24 +0000163
164
165 /* Optional modules */
166
167#ifdef USE_AUDIO
168 {"audio", initaudio},
169#endif
170
171#ifdef USE_AMOEBA
172 {"amoeba", initamoeba},
173#endif
174
175#ifdef USE_GL
176 {"gl", initgl},
Guido van Rossum2abc7a61991-04-03 19:01:18 +0000177#ifdef USE_FM
178 {"fm", initfm},
179#endif
Guido van Rossum59e53a51991-02-19 12:22:24 +0000180#ifdef USE_PANEL
181 {"pnl", initpanel},
182#endif
183#endif
184
185#ifdef USE_STDWIN
186 {"stdwin", maybeinitstdwin},
187#endif
188
189 {0, 0} /* Sentinel */
190};