File: dynamiclib.h

package info (click to toggle)
librudiments0 0.27-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,528 kB
  • ctags: 2,284
  • sloc: cpp: 14,657; sh: 7,547; ansic: 2,664; makefile: 945; xml: 15
file content (55 lines) | stat: -rw-r--r-- 1,813 bytes parent folder | download
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
// Copyright (c) 2004 David Muse
// See the COPYING file for more information.

#ifndef RUDIMENTS_DYNAMICLIB_H
#define RUDIMENTS_DYNAMICLIB_H

#include <rudiments/private/dynamiclibincludes.h>

// The dynamiclib class provides methods for loading, unloading and calling
// functions from dynamically linked libraries.

class dynamiclib {
	public:
			dynamiclib();
			~dynamiclib();

		bool	open(const char *library,
				bool loaddependencies,
				bool global);
			// Opens library "library".  If "loaddependencies"
			// is true, then all libraries required by this library
			// are also loaded, if it is false, they are loaded
			// later, as needed.  If "global" is true, then the
			// symbols defined in the library are made available
			// to libraries which are loaded later.
			//
			// Returns true on success and false on failure.
		bool	close();
			// Closes and unloads the previously opened library.
		void	*getSymbol(const char *symbol) const;
			// Returns a handle to "symbol" (exported function or
			// variable) in the currently open library or NULL if
			// an error occurs or if no library is currently open.
		char	*getError() const;
			// Returns a human-readable description of the previous
			// error that occurred, or NULL if no error has
			// occurred.
		
#ifdef RUDIMENTS_HAS_THREADS
		// getError() is not reentrant and thus not thread safe.  If
		// your application is multi-threaded and you use getError(),
		// you must use this method to supply a mutex and ensure thread
		// safety.
		//
		// If you don't supply a mutex, getError() will still work, but
		// will not be thread-safe.
		static	void	setErrorMutex(pthread_mutex_t *mutex);
				// Allows you to supply a mutex to regulate
				// access to getError().
#endif

	#include <rudiments/private/dynamiclib.h>
};

#endif