forked from alandipert/ncsa-mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
261 lines (223 loc) · 8.59 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/****************************************************************************
* NCSA Mosaic for the X Window System *
* Software Development Group *
* National Center for Supercomputing Applications *
* University of Illinois at Urbana-Champaign *
* 605 E. Springfield, Champaign IL 61820 *
* *
* Copyright (C) 1993, Board of Trustees of the University of Illinois *
* *
* NCSA Mosaic software, both binary and source (hereafter, Software) is *
* copyrighted by The Board of Trustees of the University of Illinois *
* (UI), and ownership remains with the UI. *
* *
* The UI grants you (hereafter, Licensee) a license to use the Software *
* for academic, research and internal business purposes only, without a *
* fee. Licensee may distribute the binary and source code (if released) *
* to third parties provided that the copyright notice and this statement *
* appears on all copies and that no charge is associated with such *
* copies. *
* *
* Licensee may make derivative works. However, if Licensee distributes *
* any derivative work based on or derived from the Software, then *
* Licensee will (1) notify NCSA regarding its distribution of the *
* derivative work, and (2) clearly notify users that such derivative *
* work is a modified version and not the original NCSA Mosaic *
* distributed by the UI. *
* *
* Any Licensee wishing to make commercial use of the Software should *
* contact the UI, c/o NCSA, to negotiate an appropriate license for such *
* commercial use. Commercial use includes (1) integration of all or *
* part of the source code into a product for sale or license by or on *
* behalf of Licensee to third parties, or (2) distribution of the binary *
* code or source code to third parties that need it to utilize a *
* commercial product sold or licensed by or on behalf of Licensee. *
* *
* UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR *
* ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED *
* WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE *
* USERS OF THIS SOFTWARE. *
* *
* By using or copying this Software, Licensee agrees to abide by the *
* copyright law and all other applicable laws of the U.S. including, but *
* not limited to, export control laws, and the terms of this license. *
* UI shall have the right to terminate this license immediately by *
* written notice upon Licensee's breach of, or non-compliance with, any *
* of its terms. Licensee may be held legally responsible for any *
* copyright infringement that is caused or encouraged by Licensee's *
* failure to abide by the terms of this license. *
* *
* Comments and questions are welcome and can be sent to *
* [email protected]. *
****************************************************************************/
/* SOCKS mods by:
* Ying-Da Lee, <[email protected]>
* NEC Systems Laboratory
* C&C Software Technology Center
*/
#include "../config.h"
#include "mosaic.h"
#include "main.h"
#include "gui.h"
#include "pan.h"
#include "child.h"
#include "newsrc.h"
#include "hotlist.h"
#include "globalhist.h"
#include "cciBindings2.h"
#include <signal.h>
#include <sys/utsname.h>
#include <string.h>
#include <malloc.h>
/* swp */
#define _KCMS_H_
#include "kcms.h"
char *userPath=NULL;
void mo_exit (void)
{
mo_write_default_hotlist ();
newsrc_kill ();
if (get_pref_boolean(eUSE_GLOBAL_HISTORY))
mo_write_global_history ();
mo_write_pan_list ();
preferences_armegeddon();
#ifdef HAVE_DTM
mo_dtm_disconnect ();
#endif
exit (0);
}
#ifndef VMS
MO_SIGHANDLER_RETURNTYPE ProcessExternalDirective (MO_SIGHANDLER_ARGS)
{
char filename[64];
char line[MO_LINE_LENGTH], *status, *directive, *url;
FILE *fp;
signal (SIGUSR1, SIG_IGN);
/* Construct filename from our pid. */
sprintf (filename, "/tmp/Mosaic.%d", getpid ());
fp = fopen (filename, "r");
if (!fp)
goto done;
status = fgets (line, MO_LINE_LENGTH, fp);
if (!status || !(*line)) {
fclose(fp);
goto done;
}
directive = strdup (line);
/* We now allow URL to not exist, since some directives
don't need it. */
status = fgets (line, MO_LINE_LENGTH, fp);
if (!status || !(*line))
url = strdup ("dummy");
else
url = strdup (line);
mo_process_external_directive (directive, url);
free (directive);
free (url);
fclose(fp);
done:
signal (SIGUSR1, (void *)ProcessExternalDirective);
return;
}
#endif
static void RealFatal (void)
{
signal (SIGBUS, 0);
signal (SIGSEGV, 0);
signal (SIGILL, 0);
abort ();
}
#ifdef __STDC__
static void FatalProblem (int sig)
#else /* not __STDC__ */
#ifdef _HPUX_SOURCE
static MO_SIGHANDLER_RETURNTYPE FatalProblem
(int sig, int code, struct sigcontext *scp,
char *addr)
#else
static MO_SIGHANDLER_RETURNTYPE FatalProblem
(int sig, int code, struct sigcontext *scp, char *addr)
#endif
#endif /* not __STDC__ */
{
fprintf (stderr, "\nCongratulations, you have found a bug in\n");
fprintf (stderr, "NCSA Mosaic %s on %s.\n\n", MO_VERSION_STRING,
MO_MACHINE_TYPE);
fprintf (stderr, "If a core file was generated in your directory,\n");
fprintf (stderr, "please do one of the following:\n\n");
fprintf (stderr, " %% dbx /path/to/Mosaic /path/to/core\n");
fprintf (stderr, " dbx> where\n\n");
fprintf (stderr, "OR\n\n");
fprintf (stderr, " %% gdb /path/to/Mosaic /path/to/core\n");
fprintf (stderr, " gdb> where\n\n");
fprintf (stderr, "Mail the results, and a description of what you were doing at the time,\n");
fprintf (stderr, "(include any URLs involved!) to %s.\n\nWe thank you for your support.\n\n",
MO_DEVELOPER_ADDRESS);
fprintf (stderr, "...exiting NCSA Mosaic now.\n\n");
RealFatal ();
}
main (int argc, char **argv, char **envp)
{
struct utsname u;
FILE *fp;
int i;
userPath=getenv("PATH");
/*
if (getenv("XKEYSYMDB")==NULL) {
fprintf(stderr,"If you have key binding problems, set the environment variable XKEYSYMDB\nto the location of the correct XKeysymDB file on your system.\n");
}
*/
/*
if (uname(&u)<0) {
perror("uname");
}
else {
if (!strcmp(u.sysname,"SunOS") &&
(!strcmp(u.release,"5.0")
|| !strcmp(u.release,"5.1")
|| !strcmp(u.release,"5.2")
|| !strcmp(u.release,"5.3")
|| !strcmp(u.release,"5.4")
|| !strcmp(u.release,"5.5"))) {
if (getenv("XKEYSYMDB")==NULL) {
if (!(fp=fopen("/usr/openwin/lib/X11/XKeysymDB","r"))) {
if (!(fp=fopen("/usr/openwin/lib/XKeysymDB","r"))) {
}
else {
fclose(fp);
putenv("XKEYSYMDB=/usr/openwin/lib/XKeysymDB");
}
}
else {
fclose(fp);
putenv("XKEYSYMDB=/usr/openwin/lib/X11/XKeysymDB");
}
}
}
}
*/
signal (SIGBUS, FatalProblem);
signal (SIGSEGV, FatalProblem);
signal (SIGILL, FatalProblem);
/* Since we're doing lots of TCP, just ignore SIGPIPE altogether. */
signal (SIGPIPE, SIG_IGN);
#ifdef M_CHECK_ACTION
/* some code here has the habit of freeing pointers twice. The glibc
catches this and causes the program to abort. In order to make the
code somehow work, we turn aborting the program off. */
mallopt(M_CHECK_ACTION,5);
#endif
InitChildProcessor();
MoCCIPreInitialize();
#ifdef SVR4
signal(SIGCLD, (void (*)())ChildTerminated);
#else
signal(SIGCHLD, (void (*)())ChildTerminated);
#endif
#ifdef SOCKS
SOCKSinit(argv[0]);
#endif
CheckKCMS();
mo_do_gui (argc, argv);
}