File: dynamiclib.h.html

package info (click to toggle)
rudiments 0.31-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,516 kB
  • ctags: 3,248
  • sloc: asm: 23,776; cpp: 22,792; sh: 7,769; ansic: 1,769; makefile: 1,054; xml: 169; perl: 19
file content (78 lines) | stat: -rw-r--r-- 4,993 bytes parent folder | download | duplicates (2)
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
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/dynamiclib.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2004 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>

<font color="#a020f0">#ifndef RUDIMENTS_DYNAMICLIB_H</font>
<font color="#a020f0">#define RUDIMENTS_DYNAMICLIB_H</font>

<font color="#a020f0">#include </font><font color="#ff00ff">&lt;rudiments/private/dynamiclibincludes.h&gt;</font>

<font color="#0000ff">// The dynamiclib class provides methods for loading, unloading and calling</font>
<font color="#0000ff">// functions from dynamically linked libraries.</font>

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>

<font color="#2e8b57"><b>class</b></font> dynamiclibprivate;

<font color="#2e8b57"><b>class</b></font> dynamiclib {
        <font color="#a52a2a"><b>public</b></font>:
                        dynamiclib();
                        ~dynamiclib();

                <font color="#2e8b57"><b>bool</b></font>  open(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *library,
                                <font color="#2e8b57"><b>bool</b></font> loaddependencies,
                                <font color="#2e8b57"><b>bool</b></font> global);
                        <font color="#0000ff">// Opens library &quot;library&quot;.  If &quot;loaddependencies&quot;</font>
                        <font color="#0000ff">// is true, then all libraries required by this library</font>
                        <font color="#0000ff">// are also loaded, if it is false, they are loaded</font>
                        <font color="#0000ff">// later, as needed.  If &quot;global&quot; is true, then the</font>
                        <font color="#0000ff">// symbols defined in the library are made available</font>
                        <font color="#0000ff">// to libraries which are loaded later.</font>
                        <font color="#0000ff">//</font>
                        <font color="#0000ff">// Returns true on success and false on failure.</font>
                <font color="#2e8b57"><b>bool</b></font>  close();
                        <font color="#0000ff">// Closes and unloads the previously opened library.</font>
                <font color="#2e8b57"><b>void</b></font>  *getSymbol(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *symbol) <font color="#2e8b57"><b>const</b></font>;
                        <font color="#0000ff">// Returns a handle to &quot;symbol&quot; (exported function or</font>
                        <font color="#0000ff">// variable) in the currently open library or NULL if</font>
                        <font color="#0000ff">// an error occurs or if no library is currently open.</font>
                <font color="#2e8b57"><b>char</b></font>  *getError() <font color="#2e8b57"><b>const</b></font>;
                        <font color="#0000ff">// Returns a human-readable description of the previous</font>
                        <font color="#0000ff">// error that occurred, or NULL if no error has</font>
                        <font color="#0000ff">// occurred.</font>
                        <font color="#0000ff">//</font>
                        <font color="#0000ff">// This method allocates a buffer internally and</font>
                        <font color="#0000ff">// returns it.  The calling program must deallocate</font>
                        <font color="#0000ff">// the buffer.</font>

                <font color="#0000ff">// getError() is not reentrant and thus not thread safe.  If</font>
                <font color="#0000ff">// your application is multi-threaded and you use getError(),</font>
                <font color="#0000ff">// you must use this method to supply a mutex and ensure thread</font>
                <font color="#0000ff">// safety.</font>
                <font color="#0000ff">//</font>
                <font color="#0000ff">// If you don't supply a mutex, getError() will still work, but</font>
                <font color="#0000ff">// will not be thread-safe.</font>
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>void</b></font>   setErrorMutex(mutex *mtx);
                                <font color="#0000ff">// Allows you to supply a mutex to regulate</font>
                                <font color="#0000ff">// access to getError().</font>

<font color="#a020f0">        #include </font><font color="#ff00ff">&lt;rudiments/private/dynamiclib.h&gt;</font>
};

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>

<font color="#a020f0">#endif</font>
</pre>
</body>
</html>