summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/WebSTONE/src/nsapi-includes/base/dll.h
blob: 3b8a44d6c38bad30c59073086ca67c33e30bf094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * $Id$
 *
 * Copyright (c) 1994, 1995.  Netscape Communications Corporation.  All
 * rights reserved.
 *
 * Use of this software is governed by the terms of the license agreement for
 * the Netscape Communications or Netscape Comemrce Server between the
 * parties.
 */


/* ------------------------------------------------------------------------ */


/*
 * dll.h: Handle dynamically linked libraries
 *
 * Rob McCool
 */

#ifndef _DLL_H
#define _DLL_H

#include "systems.h"

#if defined(DLL_CAPABLE)

/* --------------------------- Data structures ---------------------------- */


#if defined(USE_NSPR)
#include <nspr/prlink.h>
typedef int DLHANDLE;

#elif defined(DLL_DLOPEN)
#include <dlfcn.h>
typedef void *DLHANDLE;  /* DLOPEN */

#elif defined(DLL_HPSHL)
#include <dl.h>
typedef shl_t DLHANDLE;  /* HP_SHL */

#elif defined(DLL_WIN32)
typedef HINSTANCE DLHANDLE; /* WIN32 */
#endif


/* ------------------------------ Prototypes ------------------------------ */


/*
 * dll_open loads the library at the given path into memory, and returns
 * a handle to be used in later calls to dll_findsym and dll_close.
 */
#if defined(USE_NSPR)
#define dll_open(libfn) PR_LoadLibrary(libfn)

#elif defined(DLL_DLOPEN)
#define dll_open(libfn) dlopen(libfn, DLL_DLOPEN_FLAGS)

#elif defined(DLL_HPSHL)
#define dll_open(libfn) shl_load((libfn), BIND_IMMEDIATE, NULL)

#elif defined(DLL_WIN32)
DLHANDLE dll_open(char *libfn);
#endif


/*
 * dll_findsym looks for a symbol with the given name in the library
 * pointed to by the given handle. Returns a pointer to the named function.
 */

#if defined(USE_NSPR)
#define dll_findsym(dlp, name) PR_FindSymbol(name)

#elif defined(DLL_DLOPEN)
#define dll_findsym(dlp, name) dlsym(dlp, name)

#elif defined(DLL_HPSHL)
void *dll_findsym(DLHANDLE dlp, char *name);

#elif defined(DLL_WIN32)
#define dll_findsym(dlp, name) GetProcAddress(dlp, name)
#endif


/*
 * dll_error returns a string describing the last error on the given handle
 */
#if defined(USE_NSPR)
#define dll_error(dlp) system_errmsg(0)

#elif defined(DLL_DLOPEN)
#define dll_error(dlp) dlerror()

#elif defined(DLL_HPSHL)
#define dll_error(dlp) system_errmsg(0)

#elif defined(DLL_WIN32)
#define dll_error(dlp) system_errmsg(0)
#endif


/*
 * dll_close closes the previously opened library given by handle
 */
#if defined(USE_NSPR)
int dll_close(void *arg);

#elif defined(DLL_DLOPEN)
#define dll_close dlclose

#elif defined (DLL_HPSHL)
#define dll_close shl_unload

#elif defined(DLL_WIN32)
#define dll_close FreeLibrary
#endif


#endif /* DLL_CAPABLE */
#endif