diff options
author | Martin Willi <martin@revosec.ch> | 2014-06-04 16:26:58 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2014-06-04 16:26:58 +0200 |
commit | 8c55f8ef42816a695895990cf89697a30c235355 (patch) | |
tree | c4aa8a3f0f08166b37369bb93132d0ece470af42 /src/libstrongswan/utils/utils.h | |
parent | b4c51061c3c649e948324d1f3ad37ef6e48f8b96 (diff) | |
parent | d930d184177ef352c4b5def4e5848463819435ec (diff) | |
download | strongswan-8c55f8ef42816a695895990cf89697a30c235355.tar.bz2 strongswan-8c55f8ef42816a695895990cf89697a30c235355.tar.xz |
Merge branch 'win'
Ports the strongSwan core libraries and some plugins to the Windows platform
using a MinGW based toolchain. Beside generic platform abstraction and
the windows.[ch] compatibility layer, this merge introduces a Windows native
threading backend and a charon-svc Windows IKE service.
Travis adds a MinGW cross-compile build to Windows, and further enables -Werror
to let builds fail for all compiler warnings with gcc and Clang.
Diffstat (limited to 'src/libstrongswan/utils/utils.h')
-rw-r--r-- | src/libstrongswan/utils/utils.h | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h index 392f24e63..961ddb583 100644 --- a/src/libstrongswan/utils/utils.h +++ b/src/libstrongswan/utils/utils.h @@ -26,9 +26,19 @@ #include <stdlib.h> #include <stddef.h> #include <sys/time.h> -#include <arpa/inet.h> #include <string.h> +#ifdef WIN32 +# include "windows.h" +#else +# define _GNU_SOURCE +# include <arpa/inet.h> +# include <sys/socket.h> +# include <netdb.h> +# include <netinet/in.h> +# include <sched.h> +#endif + /** * strongSwan program return codes */ @@ -74,6 +84,25 @@ #include "utils/strerror.h" /** + * Directory separator character in paths on this platform + */ +#ifdef WIN32 +# define DIRECTORY_SEPARATOR "\\" +#else +# define DIRECTORY_SEPARATOR "/" +#endif + +/** + * Initialize utility functions + */ +void utils_init(); + +/** + * Deinitialize utility functions + */ +void utils_deinit(); + +/** * Helper function that compares two strings for equality */ static inline bool streq(const char *x, const char *y) @@ -273,7 +302,7 @@ static inline bool memeq(const void *x, const void *y, size_t len) * TODO: since the uintXX_t types are defined by the C99 standard we should * probably use those anyway */ -#ifdef __sun +#if defined __sun || defined WIN32 #include <stdint.h> typedef uint8_t u_int8_t; typedef uint16_t u_int16_t; @@ -514,6 +543,11 @@ char *translate(char *str, const char *from, const char *to); char *strreplace(const char *str, const char *search, const char *replace); /** + * Portable function to wait for SIGINT/SIGTERM (or equivalent). + */ +void wait_sigint(); + +/** * Like dirname(3) returns the directory part of the given null-terminated * pathname, up to but not including the final '/' (or '.' if no '/' is found). * Trailing '/' are not counted as part of the pathname. @@ -540,6 +574,14 @@ char *path_dirname(const char *path); char *path_basename(const char *path); /** + * Check if a given path is absolute. + * + * @param path path to check + * @return TRUE if absolute, FALSE if relative + */ +bool path_absolute(const char *path); + +/** * Creates a directory and all required parent directories. * * @param path path to the new directory |