Build with debug symbols enabled.
[oweals/cde.git] / cde / lib / DtSvc / DtUtil2 / SunDtHelp.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: SunDtHelp.c /main/6 1996/08/22 10:39:25 rswiston $
24  *
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 1996 FUJITSU LIMITED.
31  * (c) Copyright 1996 Hitachi.
32  */
33
34 /*
35  *+SNOTICE
36  *
37  *      RESTRICTED CONFIDENTIAL INFORMATION:
38  *
39  *      The information in this document is subject to special
40  *      restrictions in a confidential disclosure agreement bertween
41  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
42  *      document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
43  *      Sun's specific written approval.  This documment and all copies
44  *      and derivative works thereof must be returned or destroyed at
45  *      Sun's request.
46  *
47  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
48  *
49  *+ENOTICE
50  */
51
52 #include <stdio.h>
53 #include <dlfcn.h>
54 #include "Help.h"
55 #include "DtSvcLock.h"
56
57 #pragma weak DtCreateHelpDialog = _DtCreateHelpDialog
58 #pragma weak DtCreateHelpQuickDialog = _DtCreateHelpQuickDialog
59 #pragma weak DtHelpQuickDialogGetChild = _DtHelpQuickDialogGetChild
60 #pragma weak DtHelpReturnSelectedWidgetId = _DtHelpReturnSelectedWidgetId
61
62 typedef Widget (*SUNWWidgetProc)();
63 typedef int (*SUNWIntProc)();
64
65 typedef struct _SUNWHelpProcList {
66     SUNWWidgetProc      DtCreateHelpDialogSym;
67     SUNWWidgetProc      DtCreateHelpQuickDialogSym;
68     SUNWWidgetProc      DtHelpQuickDialogGetChildSym;
69     SUNWIntProc         DtHelpReturnSelectedWidgetIdSym;
70 } SUNWHelpProcList;
71
72 static SUNWHelpProcList         *pmySUNWProcList = NULL;
73
74 int SUNWDtHelpdlopen()
75 {
76     void *libDtHelpHandle = NULL;
77
78     _DtSvcProcessLock();
79     pmySUNWProcList = (SUNWHelpProcList *)malloc(sizeof(SUNWHelpProcList));
80     libDtHelpHandle = dlopen("libDtHelp.so.1", RTLD_LAZY | RTLD_GLOBAL);
81     if (libDtHelpHandle == NULL) {
82         char *my_err_msg;
83
84         my_err_msg = dlerror();
85         printf("%s\n", my_err_msg);
86         _DtSvcProcessUnlock();
87         return(FALSE);
88     }
89     pmySUNWProcList->DtCreateHelpDialogSym = (SUNWWidgetProc)
90                          dlsym(libDtHelpHandle, "DtCreateHelpDialog");
91     pmySUNWProcList->DtCreateHelpQuickDialogSym = (SUNWWidgetProc)
92                          dlsym(libDtHelpHandle, "DtCreateHelpQuickDialog");
93     pmySUNWProcList->DtHelpQuickDialogGetChildSym = (SUNWWidgetProc)
94                          dlsym(libDtHelpHandle, "DtHelpQuickDialogGetChild");
95     pmySUNWProcList->DtHelpReturnSelectedWidgetIdSym = (SUNWIntProc)
96                          dlsym(libDtHelpHandle, "DtHelpReturnSelectedWidgetId");
97
98     _DtSvcProcessUnlock();
99     return(TRUE);
100 }
101
102 Widget _DtCreateHelpDialog(
103     Widget parent,
104     char *name,
105     ArgList al,
106     Cardinal ac)
107 {
108     int status;
109
110     _DtSvcProcessLock();
111     status = pmySUNWProcList  || SUNWDtHelpdlopen();
112     _DtSvcProcessUnlock();
113
114     if (!status)
115         return(NULL);
116
117     return ((*pmySUNWProcList->DtCreateHelpDialogSym)(parent, name, al, ac));
118 }
119
120 Widget _DtCreateHelpQuickDialog(
121     Widget parent,
122     char *name,
123     ArgList al,
124     Cardinal ac)
125 {
126     int status;
127
128     _DtSvcProcessLock();
129     status = pmySUNWProcList  || SUNWDtHelpdlopen();
130     _DtSvcProcessUnlock();
131
132     if (!status)
133         return(NULL);
134
135     return ((*pmySUNWProcList->DtCreateHelpQuickDialogSym)(parent, name, al, ac));
136 }
137
138 Widget _DtHelpQuickDialogGetChild(
139         Widget widget,
140         unsigned char child )
141 {
142     int status;
143
144     _DtSvcProcessLock();
145     status = pmySUNWProcList  || SUNWDtHelpdlopen();
146     _DtSvcProcessUnlock();
147
148     if (!status)
149         return(NULL);
150
151     return ((*pmySUNWProcList->DtHelpQuickDialogGetChildSym)(widget, child));
152 }
153
154 int _DtHelpReturnSelectedWidgetId(
155     Widget parent,
156     Cursor cursor,
157     Widget  *widget)
158 {
159     int status;
160
161     _DtSvcProcessLock();
162     status = pmySUNWProcList  || SUNWDtHelpdlopen();
163     _DtSvcProcessUnlock();
164
165     if (!status)
166         return(NULL);
167
168     return ((*pmySUNWProcList->DtHelpReturnSelectedWidgetIdSym)(parent, cursor,
169                                                             widget));
170 }