Merge branch 'linux1'
[oweals/cde.git] / cde / programs / dtmail / MotifApp / Main.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: Main.C /main/5 1996/10/17 17:00:51 drk $ */
24 /*
25  *+SNOTICE
26  *
27  *      $XConsortium: Main.C /main/5 1996/10/17 17:00:51 drk $
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *      
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement bertween
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
35  *      Sun's specific written approval.  This documment and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  *+ENOTICE
42  */
43 ///////////////////////////////////////////////////////////////////////////////
44 //////////////////////////////////////////////////////////////////////////////
45 //         This example code is from the book:
46 //
47 //           Object-Oriented Programming with C++ and OSF/Motif
48 //         by
49 //           Douglas Young
50 //           Prentice Hall, 1992
51 //           ISBN 0-13-630252-1 
52 //
53 //         Copyright 1991 by Prentice Hall
54 //         All Rights Reserved
55 //
56 //  Permission to use, copy, modify, and distribute this software for 
57 //  any purpose except publication and without fee is hereby granted, provided 
58 //  that the above copyright notice appear in all copies of the software.
59 ///////////////////////////////////////////////////////////////////////////////
60 //////////////////////////////////////////////////////////////////////////////
61
62
63 //////////////////////////////////////////////////////////
64 // Main.C: Generic main program used by all applications
65 //////////////////////////////////////////////////////////
66 #include "Application.h"
67 #include <assert.h>
68
69 // We can implement main() in the library because the 
70 // framework completely encapsulates all Xt boilerplate 
71 // and all central flow of control. 
72
73
74 #ifdef _AIX
75 #include <signal.h>
76 #include <stdlib.h>
77 #include <stdio.h>
78 static struct sigaction action;
79
80 void _signal( int Sig )
81 {
82     if ( getenv( "_ILS_DEBUG_" ) ) {
83         printf( "Got signal[%d]. Generate full core...\n", Sig );
84         sigaction( SIGIOT, NULL, &action );
85         action.sa_flags |= SA_FULLDUMP;
86         action.sa_flags &= ~SA_PARTDUMP;
87         sigaction( SIGIOT, &action, NULL );
88         abort();
89     }
90 }
91 #endif /* _AIX */
92
93
94 int main ( int argc, char **argv )
95 {
96
97 #ifdef _AIX
98     //
99     // With Defect 174851, a lot of codes are changed to make dtmail i18n'ze.
100     // Especially, dtmail allocates the memory dynamically to convert the mail
101     // body. Therefore, I believe no defects there, but it will cause the
102     // potential coredump. If coredump will happen, to get the FULLCORE image,
103     // please set // _ILS_DEBUG_ environment variable on, like
104     //     export _ILS_DEBUG_=:
105     //     dtmail
106     // and do the same operation as that of when coredump will have occured.
107     // If the signal will be received, dtmail generates full core dump image.
108     // Note: This core file size will be big. So be aware of "ulimit" of sh.
109     //
110     if ( getenv( "_ILS_DEBUG_" ) )
111         (void)signal( SIGILL|SIGIOT|SIGKILL|SIGBUS|SIGSEGV, _signal );
112 #endif /* _AIX */
113
114     // Make sure the programmer has remembered to 
115     // instantiate an Application object
116     
117     assert ( theApplication != NULL ); 
118     
119     // Init Intrinsics, build all windows, and enter event loop
120     
121     theApplication->initialize ( &argc, argv );
122     
123     theApplication->handleEvents();
124     return(0);
125 }