about summary refs log tree commit diff stats
path: root/vendor/whereami/whereami.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-11-26 14:05:29 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2023-11-26 14:05:29 -0500
commit2adce1795211fd0a42c3b4e03ab35a90bb01bccf (patch)
tree7fda2f874f0653e4c74edaaf1547fe9802b2005a /vendor/whereami/whereami.h
parent7fc0e0f50ae961efbe0cac1032b03a42d41d87d5 (diff)
downloadlingo-ap-tracker-2adce1795211fd0a42c3b4e03ab35a90bb01bccf.tar.gz
lingo-ap-tracker-2adce1795211fd0a42c3b4e03ab35a90bb01bccf.tar.bz2
lingo-ap-tracker-2adce1795211fd0a42c3b4e03ab35a90bb01bccf.zip
Stop relying on correctly set working directory
Diffstat (limited to 'vendor/whereami/whereami.h')
-rw-r--r--vendor/whereami/whereami.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/vendor/whereami/whereami.h b/vendor/whereami/whereami.h new file mode 100644 index 0000000..8988f1d --- /dev/null +++ b/vendor/whereami/whereami.h
@@ -0,0 +1,67 @@
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
10extern "C" {
11#endif
12
13#ifndef WAI_FUNCSPEC
14#define WAI_FUNCSPEC
15#endif
16#ifndef WAI_PREFIX
17#define WAI_PREFIX(function) wai_##function
18#endif
19
20/**
21 * Returns the path to the current executable.
22 *
23 * Usage:
24 * - first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to
25 * retrieve the length of the path
26 * - allocate the destination buffer with `path = (char*)malloc(length + 1);`
27 * - call `wai_getExecutablePath(path, length, NULL)` again to retrieve the
28 * path
29 * - add a terminal NUL character with `path[length] = '\0';`
30 *
31 * @param out destination buffer, optional
32 * @param capacity destination buffer capacity
33 * @param dirname_length optional recipient for the length of the dirname part
34 * of the path.
35 *
36 * @return the length of the executable path on success (without a terminal NUL
37 * character), otherwise `-1`
38 */
39WAI_FUNCSPEC
40int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length);
41
42/**
43 * Returns the path to the current module
44 *
45 * Usage:
46 * - first call `int length = wai_getModulePath(NULL, 0, NULL);` to retrieve
47 * the length of the path
48 * - allocate the destination buffer with `path = (char*)malloc(length + 1);`
49 * - call `wai_getModulePath(path, length, NULL)` again to retrieve the path
50 * - add a terminal NUL character with `path[length] = '\0';`
51 *
52 * @param out destination buffer, optional
53 * @param capacity destination buffer capacity
54 * @param dirname_length optional recipient for the length of the dirname part
55 * of the path.
56 *
57 * @return the length of the module path on success (without a terminal NUL
58 * character), otherwise `-1`
59 */
60WAI_FUNCSPEC
61int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length);
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif // #ifndef WHEREAMI_H