2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
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
11 /* ------------------------------------------------------------------------ */
15 * dll.h: Handle dynamically linked libraries
25 #if defined(DLL_CAPABLE)
27 /* --------------------------- Data structures ---------------------------- */
31 #include <nspr/prlink.h>
34 #elif defined(DLL_DLOPEN)
36 typedef void *DLHANDLE
; /* DLOPEN */
38 #elif defined(DLL_HPSHL)
40 typedef shl_t DLHANDLE
; /* HP_SHL */
42 #elif defined(DLL_WIN32)
43 typedef HINSTANCE DLHANDLE
; /* WIN32 */
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.
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
);
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.
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)
88 * dll_error returns a string describing the last error on the given handle
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)
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
121 #endif /* DLL_CAPABLE */