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