Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / DtSearch / ausexit.c
1 /*
2  *   COMPONENT_NAME: austext
3  *
4  *   FUNCTIONS: DtSearchExit
5  *              DtSearchAddUserExit
6  *              DtSearchRemoveUserExit
7  *
8  *   ORIGINS: 27
9  *
10  *
11  *   (C) COPYRIGHT International Business Machines Corp. 1993,1996
12  *   All Rights Reserved
13  *   Licensed Materials - Property of IBM
14  *   US Government Users Restricted Rights - Use, duplication or
15  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
16  */
17 /********************* AUSEXIT.C ************************
18  * $XConsortium: ausexit.c /main/6 1996/06/23 16:47:24 cde-ibm $
19  * August 1993.
20  * Performs generic exit function for AusText system ensuring
21  * graceful shutdown for vista database, curses lib, etc.
22  * Declares several global function pointers.
23  * Austext_exit has been renamed to DtSearchExit to support
24  * it's public visibility in DtSearch.
25  *
26  * Replaces both exitop.c and exitopv.c and changes the name
27  * of the function from opera_exit() to austext_exit().
28  * The name change ensures that the linker will catch all
29  * the places we have to set global 'austext_exit_dbms' to d_close().
30  * These were the former exitopV.c links; the plain exitop.c
31  * links were non-vista programs so only the name has to be changed.
32  *
33  * If austext_exit_endwin is not NULL, then a windows-oriented UI
34  * is executing and austext_exit_endwin should be called before
35  * shutting down to ensure restoration of normal terminal mode.
36  * For curses, austext_exit_endwin is set to the curses endwin()
37  * function immediately after curses initialization (initscr() call).
38  *
39  * If austext_exit_dbms is not NULL, then current process
40  * is linked to database api and function should be called
41  * to flush and close databases.  For vista, austext_exit_dbms
42  * is set to d_close() at beginning of vista-using program.
43  *
44  * If austext_exit_mem is not NULL, then current process
45  * is using shared memory and function should be called
46  * to release it to the system.
47  *
48  * If austext_exit_comm is not NULL, then current process
49  * is communicating to a remote process over a network.
50  * The function is in a local communications package and
51  * should be called to gracefully shutdown local child/parent 
52  * processes and daemons and allow a message to be sent to
53  * the remote process to do the same.
54  *
55  * Austext_exit_first and last are miscellaneous private
56  * exits which get called first and last respectively.
57  * Austext_exit_user is called just before 'last',
58  * but 'user' is public, ie known to customer developers
59  * using the DtSearch/ausapi interface, whereas 'first' and 'last'
60  * are private, reserved for the ausapi developers themselves.
61  *
62  * $Log$
63  * Revision 2.3  1996/04/10  19:45:58  miker
64  * Added DtSearchAddUserExit and DtSearchRemoveUserExit.
65  *
66  * Revision 2.2  1995/10/25  22:20:53  miker
67  * Added prolog.
68  *
69  * Revision 2.1  1995/09/22  18:51:11  miker
70  * Freeze DtSearch 0.1, AusText 2.1.8
71  *
72  * Revision 1.4  1995/08/31  21:54:23  miker
73  * Rename austext_exit() to DtSearchExit().
74  */
75 #include "Search.h"
76
77 void    (*austext_exit_first) (int) =   NULL;
78 void    (*austext_exit_dbms) (int) =    NULL;
79 void    (*austext_exit_comm) (int) =    NULL;
80 void    (*austext_exit_endwin) (int) =  NULL;
81 void    (*austext_exit_mem) (int) =     NULL;
82 void    (*austext_exit_user) (int) =    NULL;
83 void    (*austext_exit_last) (int) =    NULL;
84
85
86 /****************************************/
87 /*                                      */
88 /*              DtSearchExit            */
89 /*                                      */
90 /****************************************/
91 void    DtSearchExit (int return_code)
92 {
93     if (austext_exit_first != NULL)
94         austext_exit_first (return_code);
95     if (austext_exit_dbms != NULL)
96         austext_exit_dbms (return_code);
97     if (austext_exit_comm != NULL)
98         austext_exit_comm (return_code);
99     if (austext_exit_endwin != NULL)
100         austext_exit_endwin (return_code);
101     if (austext_exit_mem != NULL)
102         austext_exit_mem (return_code);
103     if (austext_exit_user != NULL)
104         austext_exit_user (return_code);
105     if (austext_exit_last != NULL)
106         austext_exit_last (return_code);
107     exit (return_code);
108 }
109
110 /****************************************/
111 /*                                      */
112 /*          DtSearchAddUserExit         */
113 /*                                      */
114 /****************************************/
115 void    DtSearchAddUserExit (void (*user_exit)(int))
116 { austext_exit_user = user_exit; }
117
118
119 /****************************************/
120 /*                                      */
121 /*        DtSearchRemoveUserExit        */
122 /*                                      */
123 /****************************************/
124 void    DtSearchRemoveUserExit (void)
125 { austext_exit_user = NULL; }
126
127 /********************* AUSEXIT.C ************************/