Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / nsapi-includes / base / dll.h
blob5eac7fb0151ac0aae5d09c491d4b2f21e54d6739
1 /*
2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
3 * rights reserved.
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
7 * parties.
8 */
11 /* ------------------------------------------------------------------------ */
15 * dll.h: Handle dynamically linked libraries
17 * Rob McCool
20 #ifndef _DLL_H
21 #define _DLL_H
23 #include "systems.h"
25 #if defined(DLL_CAPABLE)
27 /* --------------------------- Data structures ---------------------------- */
30 #if defined(USE_NSPR)
31 #include <nspr/prlink.h>
32 typedef int DLHANDLE;
34 #elif defined(DLL_DLOPEN)
35 #include <dlfcn.h>
36 typedef void *DLHANDLE; /* DLOPEN */
38 #elif defined(DLL_HPSHL)
39 #include <dl.h>
40 typedef shl_t DLHANDLE; /* HP_SHL */
42 #elif defined(DLL_WIN32)
43 typedef HINSTANCE DLHANDLE; /* WIN32 */
44 #endif
47 /* ------------------------------ Prototypes ------------------------------ */
51 * dll_open loads the library at the given path into memory, and returns
52 * a handle to be used in later calls to dll_findsym and dll_close.
54 #if defined(USE_NSPR)
55 #define dll_open(libfn) PR_LoadLibrary(libfn)
57 #elif defined(DLL_DLOPEN)
58 #define dll_open(libfn) dlopen(libfn, DLL_DLOPEN_FLAGS)
60 #elif defined(DLL_HPSHL)
61 #define dll_open(libfn) shl_load((libfn), BIND_IMMEDIATE, 0)
63 #elif defined(DLL_WIN32)
64 DLHANDLE dll_open(char *libfn);
65 #endif
69 * dll_findsym looks for a symbol with the given name in the library
70 * pointed to by the given handle. Returns a pointer to the named function.
73 #if defined(USE_NSPR)
74 #define dll_findsym(dlp, name) PR_FindSymbol(name)
76 #elif defined(DLL_DLOPEN)
77 #define dll_findsym(dlp, name) dlsym(dlp, name)
79 #elif defined(DLL_HPSHL)
80 void *dll_findsym(DLHANDLE dlp, char *name);
82 #elif defined(DLL_WIN32)
83 #define dll_findsym(dlp, name) GetProcAddress(dlp, name)
84 #endif
88 * dll_error returns a string describing the last error on the given handle
90 #if defined(USE_NSPR)
91 #define dll_error(dlp) system_errmsg(0)
93 #elif defined(DLL_DLOPEN)
94 #define dll_error(dlp) dlerror()
96 #elif defined(DLL_HPSHL)
97 #define dll_error(dlp) system_errmsg(0)
99 #elif defined(DLL_WIN32)
100 #define dll_error(dlp) system_errmsg(0)
101 #endif
105 * dll_close closes the previously opened library given by handle
107 #if defined(USE_NSPR)
108 int dll_close(void *arg);
110 #elif defined(DLL_DLOPEN)
111 #define dll_close dlclose
113 #elif defined (DLL_HPSHL)
114 #define dll_close shl_unload
116 #elif defined(DLL_WIN32)
117 #define dll_close FreeLibrary
118 #endif
121 #endif /* DLL_CAPABLE */
122 #endif