diff options
Diffstat (limited to 'vendor/whereami/whereami.h')
| -rw-r--r-- | vendor/whereami/whereami.h | 67 |
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 | ||
| 10 | extern "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 | */ | ||
| 39 | WAI_FUNCSPEC | ||
| 40 | int 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 | */ | ||
| 60 | WAI_FUNCSPEC | ||
| 61 | int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length); | ||
| 62 | |||
| 63 | #ifdef __cplusplus | ||
| 64 | } | ||
| 65 | #endif | ||
| 66 | |||
| 67 | #endif // #ifndef WHEREAMI_H | ||
