Free Electron
src
platform
whereami.h
1
// dual licensed under the WTFPL v2 and MIT licenses
2
// without any warranty.
3
// by Gregory Pakosz (@gpakosz)
4
// https://github.com/gpakosz/whereami
5
6
#ifndef WHEREAMI_H
7
#define WHEREAMI_H
8
9
#ifdef __cplusplus
10
extern
"C"
11
{
12
#endif
13
14
#ifndef WAI_FUNCSPEC
15
#define WAI_FUNCSPEC
16
#endif
17
#ifndef WAI_PREFIX
18
#define WAI_PREFIX(function) wai_##function
19
#endif
20
21
/**
22
* Returns the path to the current executable.
23
*
24
* Usage:
25
* - first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to
26
* retrieve the length of the path
27
* - allocate the destination buffer with `path = (char*)malloc(length + 1);`
28
* - call `wai_getExecutablePath(path, length, NULL)` again to retrieve the
29
* path
30
* - add a terminal NUL character with `path[length] = '\0';`
31
*
32
* @param out destination buffer, optional
33
* @param capacity destination buffer capacity
34
* @param dirname_length optional recipient for the length of the dirname part
35
* of the path.
36
*
37
* @return the length of the executable path on success (without a terminal NUL
38
* character), otherwise `-1`
39
*/
40
WAI_FUNCSPEC
41
int
WAI_PREFIX(getExecutablePath)(
char
*out,
int
capacity,
int
*dirname_length);
42
43
/**
44
* Returns the path to the current module
45
*
46
* Usage:
47
* - first call `int length = wai_getModulePath(NULL, 0, NULL);` to retrieve
48
* the length of the path
49
* - allocate the destination buffer with `path = (char*)malloc(length + 1);`
50
* - call `wai_getModulePath(path, length, NULL)` again to retrieve the path
51
* - add a terminal NUL character with `path[length] = '\0';`
52
*
53
* @param out destination buffer, optional
54
* @param capacity destination buffer capacity
55
* @param dirname_length optional recipient for the length of the dirname part
56
* of the path.
57
*
58
* @return the length of the module path on success (without a terminal NUL
59
* character), otherwise `-1`
60
*/
61
WAI_FUNCSPEC
62
int
WAI_PREFIX(getModulePath)(
char
*out,
int
capacity,
int
*dirname_length);
63
64
#ifdef __cplusplus
65
}
66
#endif
67
68
#endif // #ifndef WHEREAMI_H
Generated by
1.8.13