2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: main.C /main/25 1996/11/22 11:02:05 rcs $ */
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1994, 1995, 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
34 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
35 * All rights reserved. Unpublished -- rights reserved under
36 * the Copyright Laws of the United States. USE OF A COPYRIGHT
37 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
40 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
41 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
42 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
43 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
46 * RESTRICTED RIGHTS LEGEND
47 * Use, duplication, or disclosure by the Government is subject
48 * to the restrictions as set forth in subparagraph (c)(l)(ii)
49 * of the Rights in Technical Data and Computer Software clause
50 * at DFARS 252.227-7013.
52 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
65 #if defined(sparc) && defined(MAP_ZERO)
70 #define C_WindowSystem
90 #include "Managers/CatMgr.hh"
92 #include "Exceptions.hh"
93 #include "utility/mmdb_exception.h"
97 extern void monitor(int);
98 int quantify_clear_data(void);
102 int quantify_clear_data(void);
106 #ifdef UseSessionMgmt
107 // Background task to explicitly save the initial session state.
108 // Need this work proc to run last on startup.
111 SetSession_wp( XtPointer /*fiddler_on_the_roof*/ )
113 session().set() ; // explicitly save the state
114 return (Boolean)True ; // must always return True
117 // Background task to check for and restore any prior session state
120 RestoreSession_wp( XtPointer /*fiddler_on_the_roof*/ )
122 session().restore() ; // check for saved state & process
123 return (Boolean)True ; // must always return True
129 // Background task to initialize with tooltalk.
130 // Do before initial session state saved.
133 SetTooltalk_wp( XtPointer /*fiddler_on_the_roof*/ )
135 if( !env().secondary() )
136 tt_manager().establish_server();
137 return (Boolean)True ; // must always return True
142 // Background task to launch explicit section requests at startup
145 DisplayNode_wp( XtPointer locator )
147 UrlAgent::document( (char *)locator, 1 ); // arg2 = force new window
148 delete [] (char *)locator;
150 return (Boolean)True ; // must always return True
153 // this series will window-stack multiple documents with the
154 // first in the list displayed last, and thus on top
157 DisplayDocList( UAS_List<UAS_String> docs )
159 UAS_String doc_locator, start_doc, end_doc ;
163 #ifdef UseSessionMgmt
164 if( docs.length() != 0 )
166 // the presumption for now is that any special session state
167 // info will exist only if there were node display windows...
168 XtAppAddWorkProc( window_system().app_context(),
169 RestoreSession_wp, (char *)NULL ) ;
173 // set up to display the documents
175 for (unsigned int i = 0; i < docs.length(); i++)
177 (*(docs[i])).split( '-', start_doc, end_doc ) ;
178 doc_locator = start_doc.length() ? start_doc : end_doc ;
180 // only print cares about a range of locators;
181 // for display, just do the first locator if a range
183 // allocate memory for a normal c string to pass
184 // through to the work proc
186 int len = doc_locator.length();
187 document = new char[len + 1];
188 temp = (char *)doc_locator;
189 *((char *) memcpy(document, temp, len) + len) = '\0';
191 XtAppAddWorkProc( window_system().app_context(),
192 DisplayNode_wp, document) ;
199 // Background task to launch explicit section requests at startup
202 PrintNode_wp( XtPointer locator )
204 UrlAgent::print_document( (char *)locator);
205 delete [] (char *)locator;
206 return (Boolean)True ; // must always return True
210 // PrintDocList will print a list of sections
213 PrintDocList( UAS_List<UAS_String> docs )
215 UAS_String doc_locator, start_doc, end_doc ;
219 for (unsigned int i = 0; i < docs.length(); i++)
221 (*(docs[i])).split( '-', start_doc, end_doc ) ;
222 doc_locator = start_doc.length() ? start_doc : end_doc ;
224 // only print cares about a range of locators;
225 int len = doc_locator.length();
226 document = new char[len + 1];
227 temp = (char *)doc_locator;
228 *((char *) memcpy(document, temp, len) + len) = '\0';
230 // ... needs expansion of range here if present ...
231 XtAppAddWorkProc( window_system().app_context(),
232 PrintNode_wp, document ) ;
237 main(int argc, char **argv)
241 #if defined(sparc) && defined(MAP_ZERO)
242 // to permit dtsearch to access address zero
243 mmap(NULL, 0x1000, PROT_READ, MAP_PRIVATE | MAP_FIXED,
244 open("/dev/zero", O_RDONLY), 0);
251 WindowSystem window_system (argc, argv);
252 CatMgr msg_catalog_mgr;
253 InputMgrX input_manager;
254 if (env().init(argc, argv) < 0)
260 // don't set up for session management or tooltalk if
261 // invoked for print only
262 if (!window_system.videoShell()->print_only) {
263 #ifdef UseSessionMgmt
264 // set session state register to occur after startup has settled
265 XtAppAddWorkProc( window_system.app_context(),
266 SetSession_wp, (char *)NULL ) ;
269 XtAppAddWorkProc( window_system.app_context(),
270 SetTooltalk_wp, (char *)NULL ) ;
274 // set up to process any explicit section display requests for
275 // startup. If print only, print specified sections.
276 UAS_List<UAS_String>env_sections( env().sections() );
278 if (window_system.videoShell()->print_only) {
279 PrintDocList( env_sections );
282 DisplayDocList( env_sections );
285 // request immediate loading of any/all infolibs specified
286 UAS_List<UAS_String>env_infolibs( env().infolibs() );
287 library_mgr().init( env_infolibs );
291 mcatch (Exception &, e)
294 snprintf (buffer, sizeof(buffer),
295 "Internal Error: Exception got away.\nFile: %s, Line: %d",
301 message_mgr().error_dialog (buffer);
312 void DosClose () { cerr << "DosClose\n"; }
313 void DosWrite () { cerr << "DosWrite\n"; }
314 void DosPeekNmPipe () { cerr << "DosPeekNmPipe\n"; }
315 void DosDisconnectNmPipe () { cerr << "DosDisconnectNmPipe\n"; }
316 void DosMakeNmPipe () { cerr << "DosMakeNmPipe\n"; }
317 void DosConnectNmPipe () { cerr << "DosConnectNmPipe\n"; }
318 void DosRead () { cerr << "DosRead\n"; }