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
17 #define WAI_PREFIX(function) wai_##function
21 * Returns the path to the current executable.
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
29 * - add a terminal NUL character with `path[length] = '\0';`
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
36 * @return the length of the executable path on success (without a terminal NUL
37 * character), otherwise `-1`
40 int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length);
43 * Returns the path to the current module
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';`
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
57 * @return the length of the module path on success (without a terminal NUL
58 * character), otherwise `-1`
61 int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length);
67 #endif // #ifndef WHEREAMI_H