SunDtHelp.c 4.8 KB

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