dllmain.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /*
  42. * Microsoft Windows specifics for LIBRETROCL DLL
  43. */
  44. #include "ldap.h"
  45. #ifdef _WIN32
  46. /* Lifted from Q125688
  47. * How to Port a 16-bit DLL to a Win32 DLL
  48. * on the MSVC 4.0 CD
  49. */
  50. BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
  51. {
  52. switch (fdwReason)
  53. {
  54. case DLL_PROCESS_ATTACH:
  55. /* Code from LibMain inserted here. Return TRUE to keep the
  56. DLL loaded or return FALSE to fail loading the DLL.
  57. You may have to modify the code in your original LibMain to
  58. account for the fact that it may be called more than once.
  59. You will get one DLL_PROCESS_ATTACH for each process that
  60. loads the DLL. This is different from LibMain which gets
  61. called only once when the DLL is loaded. The only time this
  62. is critical is when you are using shared data sections.
  63. If you are using shared data sections for statically
  64. allocated data, you will need to be careful to initialize it
  65. only once. Check your code carefully.
  66. Certain one-time initializations may now need to be done for
  67. each process that attaches. You may also not need code from
  68. your original LibMain because the operating system may now
  69. be doing it for you.
  70. */
  71. /*
  72. * 16 bit code calls UnlockData()
  73. * which is mapped to UnlockSegment in windows.h
  74. * in 32 bit world UnlockData is not defined anywhere
  75. * UnlockSegment is mapped to GlobalUnfix in winbase.h
  76. * and the docs for both UnlockSegment and GlobalUnfix say
  77. * ".. function is oboslete. Segments have no meaning
  78. * in the 32-bit environment". So we do nothing here.
  79. */
  80. break;
  81. case DLL_THREAD_ATTACH:
  82. /* Called each time a thread is created in a process that has
  83. already loaded (attached to) this DLL. Does not get called
  84. for each thread that exists in the process before it loaded
  85. the DLL.
  86. Do thread-specific initialization here.
  87. */
  88. break;
  89. case DLL_THREAD_DETACH:
  90. /* Same as above, but called when a thread in the process
  91. exits.
  92. Do thread-specific cleanup here.
  93. */
  94. break;
  95. case DLL_PROCESS_DETACH:
  96. /* Code from _WEP inserted here. This code may (like the
  97. LibMain) not be necessary. Check to make certain that the
  98. operating system is not doing it for you.
  99. */
  100. break;
  101. }
  102. /* The return value is only used for DLL_PROCESS_ATTACH; all other
  103. conditions are ignored. */
  104. return TRUE; /* successful DLL_PROCESS_ATTACH */
  105. }
  106. #else
  107. int CALLBACK
  108. LibMain( HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine )
  109. {
  110. /*UnlockData( 0 );*/
  111. return( 1 );
  112. }
  113. #endif