summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-10-26 18:12:20 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-10-26 18:12:20 +0000
commitdf10f182c019e7cda96793de193e30e66ab2abfc (patch)
tree0ffaf1b0d0527637b05f596cdced17d09e0ec3ac /src
parentc6808b3724de2c5a91401ed4c9d7dbc3fb54a66a (diff)
downloadirssi-df10f182c019e7cda96793de193e30e66ab2abfc.zip
Some fixes for compiling with Win32 :)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@783 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/common.h7
-rw-r--r--src/core/misc.c23
-rw-r--r--src/core/net-internal.h6
-rw-r--r--src/core/network.c2
-rw-r--r--src/core/network.h6
-rw-r--r--src/core/settings.c2
-rw-r--r--src/core/special-vars.c14
7 files changed, 48 insertions, 12 deletions
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 <time.h>
#include <sys/types.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
@@ -32,6 +34,9 @@
# include <dirent.h>
#endif
#include <fcntl.h>
+#ifdef WIN32
+# include <win32-compat.h>
+#endif
#include <glib.h>
#include <gmodule.h>
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 <errno.h>
-#include <regex.h>
+#ifdef HAVE_REGEX_H
+# include <regex.h>
+#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 <socks.h>
#endif
-#include <netdb.h>
-#include <arpa/inet.h>
+#ifndef WIN32
+# include <netdb.h>
+# include <arpa/inet.h>
+#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 <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#ifndef WIN32
+# include <sys/socket.h>
+# include <netinet/in.h>
+#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 <sys/utsname.h>
+#ifdef HAVE_SYS_UTSNAME_H
+# include <sys/utsname.h>
+#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 */