diff --git a/configure.in b/configure.in index e20e00ea..19b5776a 100644 --- a/configure.in +++ b/configure.in @@ -27,6 +27,8 @@ $libtool_flags --disable-static --output=libtool-static --no-verify $ac_aux_dir/ AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h sys/ioctl.h libintl.h) +# check posix headers.. +AC_CHECK_HEADERS(sys/time.h sys/utsname.h regex.h) AC_ARG_WITH(socks, [ --with-socks Build with socks support], diff --git a/src/common.h b/src/common.h index 8fa76d78..762d3dec 100644 --- a/src/common.h +++ b/src/common.h @@ -22,7 +22,9 @@ #include #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #ifdef HAVE_UNISTD_H @@ -32,6 +34,9 @@ # include #endif #include +#ifdef WIN32 +# include +#endif #include #include diff --git a/src/core/misc.c b/src/core/misc.c index 55f61dda..73b66128 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -23,7 +23,9 @@ #include "pidwait.h" #include -#include +#ifdef HAVE_REGEX_H +# include +#endif typedef struct { GInputCondition condition; @@ -168,10 +170,13 @@ int strarray_find(char **array, const char *item) int execute(const char *cmd) { char **args; +#ifndef WIN32 int pid; +#endif g_return_val_if_fail(cmd != NULL, -1); +#ifndef WIN32 pid = fork(); if (pid == -1) return FALSE; if (pid != 0) { @@ -185,6 +190,12 @@ int execute(const char *cmd) _exit(99); return -1; +#else + args = g_strsplit(cmd, " ", -1); + _spawnvp(_P_DETACH, args[0], args); + g_strfreev(args); + return 0; +#endif } GSList *gslist_find_string(GSList *list, const char *key) @@ -337,6 +348,7 @@ char *stristr_full(const char *data, const char *key) int regexp_match(const char *str, const char *regexp) { +#ifdef HAVE_REGEX_H regex_t preg; int ret; @@ -347,13 +359,16 @@ int regexp_match(const char *str, const char *regexp) regfree(&preg); return ret == 0; +#else + return FALSE; +#endif } /* Create the directory and all it's parent directories */ int mkpath(const char *path, int mode) { struct stat statbuf; - const char *p; + const char *p; char *dir; g_return_val_if_fail(path != NULL, -1); @@ -367,7 +382,11 @@ int mkpath(const char *path, int mode) dir = g_strndup(path, (int) (p-path)); if (stat(dir, &statbuf) != 0) { +#ifndef WIN32 if (mkdir(dir, mode) == -1) { +#else + if (_mkdir(dir) == -1) { +#endif g_free(dir); return -1; } diff --git a/src/core/net-internal.h b/src/core/net-internal.h index 79da708e..dd870a1b 100644 --- a/src/core/net-internal.h +++ b/src/core/net-internal.h @@ -2,5 +2,7 @@ #include #endif -#include -#include +#ifndef WIN32 +# include +# include +#endif diff --git a/src/core/network.c b/src/core/network.c index 4a60a963..8d246bb6 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -303,7 +303,7 @@ int net_getsockname(int handle, IPADDR *addr, int *port) #ifdef HAVE_IPV6 if (getsockname(handle, &so.sin6, &len) == -1) #else - if (getsockname(handle, &so.sin, &len) == -1) + if (getsockname(handle, (struct sockaddr *) &so.sin, &len) == -1) #endif return -1; diff --git a/src/core/network.h b/src/core/network.h index 613434c4..31817cdb 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -2,8 +2,10 @@ #define __NETWORK_H #include -#include -#include +#ifndef WIN32 +# include +# include +#endif struct _ipaddr { unsigned short family; diff --git a/src/core/settings.c b/src/core/settings.c index 80406261..3bfddec5 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -310,7 +310,7 @@ static void init_configfile(void) str = g_strdup_printf("%s/.irssi", g_get_home_dir()); if (stat(str, &statbuf) != 0) { /* ~/.irssi not found, create it. */ - if (mkdir(str, 0700) != 0) { + if (mkpath(str, 0700) != 0) { g_error(_("Couldn't create %s/.irssi directory"), g_get_home_dir()); } diff --git a/src/core/special-vars.c b/src/core/special-vars.c index 1aa081e9..0b83658f 100644 --- a/src/core/special-vars.c +++ b/src/core/special-vars.c @@ -29,7 +29,9 @@ #include "queries.h" #include "window-item-def.h" -#include +#ifdef HAVE_SYS_UTSNAME_H +# include +#endif #define ALIGN_RIGHT 0x01 #define ALIGN_CUT 0x02 @@ -673,6 +675,7 @@ static char *expando_dollar(SERVER_REC *server, void *item, int *free_ret) /* system name */ static char *expando_sysname(SERVER_REC *server, void *item, int *free_ret) { +#ifdef HAVE_SYS_UTSNAME_H struct utsname un; if (uname(&un) == -1) @@ -680,12 +683,15 @@ static char *expando_sysname(SERVER_REC *server, void *item, int *free_ret) *free_ret = TRUE; return g_strdup(un.sysname); - +#else + return NULL; +#endif } /* system release */ static char *expando_sysrelease(SERVER_REC *server, void *item, int *free_ret) { +#ifdef HAVE_SYS_UTSNAME_H struct utsname un; if (uname(&un) == -1) @@ -693,7 +699,9 @@ static char *expando_sysrelease(SERVER_REC *server, void *item, int *free_ret) *free_ret = TRUE; return g_strdup(un.release); - +#else + return NULL; +#endif } /* Server tag */