annotate module.h @ 73:653d583376c9

Added the inifile_error() function and renamed inifile_option_simple() to _once()
author David Demelier <markand@malikania.fr>
date Sun, 13 Nov 2011 16:38:29 +0100
parents f773c76b1f3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 /*
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 * module.h -- portable functions to manipulate dynamic libraries
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 *
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 * Copyright (c) 2011, David Demelier <markand@malikania.fr>
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 *
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 * Permission to use, copy, modify, and/or distribute this software for any
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 * copyright notice and this permission notice appear in all copies.
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 *
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 */
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
19 #ifndef _MODULE_H_
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 #define _MODULE_H_
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
21
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 #if defined(_WIN32) || defined(__WIN32__)
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
23 #include <windows.h>
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 #else
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
25 #include <dlfcn.h>
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
26 #endif
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
27
66
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
28 #ifdef __cplusplus
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
29 extern "C" {
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
30 #endif
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
31
24
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 /* Unsupported on windows */
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 #if defined(_WIN32) || defined(__WIN32__)
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
34 #define MOD_LAZY 1
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 #define MOD_NOW 1
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 #else
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 #define MOD_LAZY RTLD_LAZY
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 #define MOD_NOW RTLD_NOW
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 #endif
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
40
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 struct module {
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 #if defined(_WIN32) || defined(__WIN32__)
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 HMODULE handler;
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 FARPROC sym;
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 #else
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 void *handler;
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
47 void *sym;
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 #endif
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 };
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
50
33
23a3ebcbf08e Return a module instead of an int
David Demelier <markand@malikania.fr>
parents: 24
diff changeset
51 struct module *module_load(const char *, int);
23a3ebcbf08e Return a module instead of an int
David Demelier <markand@malikania.fr>
parents: 24
diff changeset
52 int module_find(struct module *, const char *);
23a3ebcbf08e Return a module instead of an int
David Demelier <markand@malikania.fr>
parents: 24
diff changeset
53 void module_free(struct module *);
24
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
54
66
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
55 #ifdef __cplusplus
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
56 }
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
57 #endif
f773c76b1f3c Added extern C tests
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
58
24
726b181b8956 Added module.c and module.h portable way to manipulate DSO
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 #endif /* _MODULE_H_ */