diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2021-05-05 19:58:47 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2021-05-05 19:58:47 -0400 |
commit | 70c312779ecad328a8003b93ebe253c4598b6980 (patch) | |
tree | edd173bbba824632cb55b7818367744a6a4de691 /include | |
parent | a92b4038179c3706bd176097be1caabd88824755 (diff) | |
download | cleanpath-70c312779ecad328a8003b93ebe253c4598b6980.tar.gz |
Add
* OS detection
* linux specfic limits header
Diffstat (limited to 'include')
-rw-r--r-- | include/cleanpath.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/include/cleanpath.h b/include/cleanpath.h index 4e7d35d..321f921 100644 --- a/include/cleanpath.h +++ b/include/cleanpath.h @@ -1,6 +1,32 @@ #ifndef CLEANPATH_CLEANPATH_H #define CLEANPATH_CLEANPATH_H +// Define some platform detection shortcuts +#define OS_DARWIN 0 +#define OS_WINDOWS 0 +#define OS_LINUX 0 +#define OS_SUPPORTED 0 + +#if defined(__APPLE__) && defined(__MACH__) +# undef OS_DARWIN +# define OS_DARWIN 1 +# undef OS_SUPPORTED +# define OS_SUPPORTED 1 + +#elif defined(_WIN32) +# undef OS_WINDOWS +# define OS_WINDOWS 1 + +#elif defined(__linux) || defined(__linux__) +# undef OS_LINUX +# define OS_LINUX 1 +# undef OS_SUPPORTED +# define OS_SUPPORTED 1 +#endif + +#include <stdlib.h> +#include <string.h> + #define CLEANPATH_VERSION "0.1.0" #define CLEANPATH_FILTER_NONE -1 #define CLEANPATH_FILTER_EXACT 0 @@ -11,11 +37,11 @@ #define CLEANPATH_SEP ":" struct CleanPath { - char *data; // Pointer to the path string - size_t data_len; // Length of the path string - char *sep; // Pointer to the separator used to split the data string + char *data; // Pointer to the path string + size_t data_len; // Length of the path string + char *sep; // Pointer to the separator used to split the data string char *part[CLEANPATH_PART_MAX]; // Array of pointers to path elements - size_t part_nelem; // Total number of elements in part array + size_t part_nelem; // Total number of elements in part array }; // Prototypes |