1 /*
2  * SPDX-License-Identifier: ISC
3  *
4  * Copyright (c) 2010, 2013, 2014 Todd C. Miller <Todd.Miller@sudo.ws>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef SUDO_DSO_H
20 #define SUDO_DSO_H
21 
22 /* Values for sudo_dso_load() mode. */
23 #define SUDO_DSO_LAZY	 0x1
24 #define SUDO_DSO_NOW	 0x2
25 #define SUDO_DSO_GLOBAL	 0x4
26 #define SUDO_DSO_LOCAL	 0x8
27 
28 /* Special handle arguments for sudo_dso_findsym(). */
29 #define SUDO_DSO_NEXT	 ((void *)-1)	/* Search subsequent objects. */
30 #define SUDO_DSO_DEFAULT ((void *)-2)	/* Use default search algorithm. */
31 #define SUDO_DSO_SELF	 ((void *)-3)	/* Search the caller itself. */
32 
33 /* Internal structs for static linking of plugins. */
34 struct sudo_preload_symbol {
35     const char *name;
36     void *addr;
37 };
38 struct sudo_preload_table {
39     const char *path;
40     void *handle;
41     struct sudo_preload_symbol *symbols;
42 };
43 
44 /* Public functions. */
45 sudo_dso_public char *sudo_dso_strerror_v1(void);
46 sudo_dso_public int sudo_dso_unload_v1(void *handle);
47 sudo_dso_public void *sudo_dso_findsym_v1(void *handle, const char *symbol);
48 sudo_dso_public void *sudo_dso_load_v1(const char *path, int mode);
49 sudo_dso_public void sudo_dso_preload_table_v1(struct sudo_preload_table *table);
50 
51 #define sudo_dso_strerror() sudo_dso_strerror_v1()
52 #define sudo_dso_unload(_a) sudo_dso_unload_v1((_a))
53 #define sudo_dso_findsym(_a, _b) sudo_dso_findsym_v1((_a), (_b))
54 #define sudo_dso_load(_a, _b) sudo_dso_load_v1((_a), (_b))
55 #define sudo_dso_preload_table(_a) sudo_dso_preload_table_v1((_a))
56 
57 #endif /* SUDO_DSO_H */
58