Cleanup armsrc/string.c and string.h (#964)
[legacy-proxmark3.git] / client / whereami.h
blob6c81af818734157187e6076534aded07235ec0aa
1 // (‑●‑●)> released under the WTFPL v2 license, by Gregory Pakosz (@gpakosz)
2 // https://github.com/gpakosz/whereami
4 #ifndef WHEREAMI_H
5 #define WHEREAMI_H
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
11 #ifndef WAI_FUNCSPEC
12 #define WAI_FUNCSPEC
13 #endif
14 #ifndef WAI_PREFIX
15 #define WAI_PREFIX(function) wai_##function
16 #endif
18 /**
19 * Returns the path to the current executable.
21 * Usage:
22 * - first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to
23 * retrieve the length of the path
24 * - allocate the destination buffer with `path = (char*)malloc(length + 1);`
25 * - call `wai_getExecutablePath(path, length, NULL)` again to retrieve the
26 * path
27 * - add a terminal NUL character with `path[length] = '\0';`
29 * @param out destination buffer, optional
30 * @param capacity destination buffer capacity
31 * @param dirname_length optional recipient for the length of the dirname part
32 * of the path.
34 * @return the length of the executable path on success (without a terminal NUL
35 * character), otherwise `-1`
37 WAI_FUNCSPEC
38 int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length);
40 /**
41 * Returns the path to the current module
43 * Usage:
44 * - first call `int length = wai_getModulePath(NULL, 0, NULL);` to retrieve
45 * the length of the path
46 * - allocate the destination buffer with `path = (char*)malloc(length + 1);`
47 * - call `wai_getModulePath(path, length, NULL)` again to retrieve the path
48 * - add a terminal NUL character with `path[length] = '\0';`
50 * @param out destination buffer, optional
51 * @param capacity destination buffer capacity
52 * @param dirname_length optional recipient for the length of the dirname part
53 * of the path.
55 * @return the length of the module path on success (without a terminal NUL
56 * character), otherwise `-1`
58 WAI_FUNCSPEC
59 int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length);
61 #ifdef __cplusplus
63 #endif
65 #endif // #ifndef WHEREAMI_H