summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/core.c4
-rw-r--r--src/core/net-disconnect.c2
-rw-r--r--src/core/net-nonblock.c10
-rw-r--r--src/core/network.c12
-rw-r--r--src/lib-popt/findme.c2
-rw-r--r--src/lib-popt/poptconfig.c2
-rw-r--r--src/lib-popt/poptparse.c5
7 files changed, 34 insertions, 3 deletions
diff --git a/src/core/core.c b/src/core/core.c
index a2a928db..ef80f2f5 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -48,7 +48,9 @@ int irssi_gui;
void core_init(void)
{
modules_init();
+#ifndef WIN32
pidwait_init();
+#endif
net_disconnect_init();
net_sendbuffer_init();
@@ -96,6 +98,8 @@ void core_deinit(void)
net_sendbuffer_deinit();
net_disconnect_deinit();
+#ifndef WIN32
pidwait_deinit();
+#endif
modules_deinit();
}
diff --git a/src/core/net-disconnect.c b/src/core/net-disconnect.c
index 0f604ab3..b5f0212b 100644
--- a/src/core/net-disconnect.c
+++ b/src/core/net-disconnect.c
@@ -111,6 +111,7 @@ void net_disconnect_init(void)
void net_disconnect_deinit(void)
{
+#ifndef WIN32
NET_DISCONNECT_REC *rec;
time_t now, max;
int first;
@@ -148,4 +149,5 @@ void net_disconnect_deinit(void)
first = 0;
}
}
+#endif
}
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c
index d8e85b0a..c6342e08 100644
--- a/src/core/net-nonblock.c
+++ b/src/core/net-nonblock.c
@@ -41,10 +41,13 @@ int net_gethostbyname_nonblock(const char *addr, int pipe)
{
RESOLVED_IP_REC rec;
const char *errorstr;
+#ifndef WIN32
int pid;
+#endif
g_return_val_if_fail(addr != NULL, FALSE);
+#ifndef WIN32
pid = fork();
if (pid > 0) {
/* parent */
@@ -57,6 +60,7 @@ int net_gethostbyname_nonblock(const char *addr, int pipe)
g_warning("net_connect_thread(): fork() failed! "
"Using blocking resolving");
}
+#endif
/* child */
memset(&rec, 0, sizeof(rec));
@@ -72,8 +76,10 @@ int net_gethostbyname_nonblock(const char *addr, int pipe)
if (rec.error != 0)
write(pipe, errorstr, rec.errlen);
+#ifndef WIN32
if (pid == 0)
_exit(99);
+#endif
/* we used blocking lookup */
return 0;
@@ -89,7 +95,9 @@ int net_gethostbyname_return(int pipe, RESOLVED_IP_REC *rec)
rec->errorstr = NULL;
/* get ip+error - try for max. 1-2 seconds */
+#ifndef WIN32
fcntl(pipe, F_SETFL, O_NONBLOCK);
+#endif
maxwait = time(NULL)+2;
len = 0;
@@ -134,7 +142,9 @@ void net_disconnect_nonblock(int pid)
{
g_return_if_fail(pid > 0);
+#ifndef WIN32
kill(pid, SIGKILL);
+#endif
}
static void simple_init(SIMPLE_THREAD_REC *rec, int handle)
diff --git a/src/core/network.c b/src/core/network.c
index 8d246bb6..d8a3a38a 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -93,7 +93,7 @@ G_INLINE_FUNC void sin_set_port(union sockaddr_union *so, int port)
so->sin6.sin6_port = htons(port);
else
#endif
- so->sin.sin_port = htons(port);
+ so->sin.sin_port = htons((unsigned short)port);
}
G_INLINE_FUNC int sin_get_port(union sockaddr_union *so)
@@ -133,7 +133,9 @@ int net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
return -1;
/* set socket options */
+#ifndef WIN32
fcntl(handle, F_SETFL, O_NONBLOCK);
+#endif
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR,
(char *) &opt, sizeof(opt));
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
@@ -150,10 +152,12 @@ int net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
sin_set_port(&so, port);
ret = connect(handle, &so.sa, sizeof(so));
+#ifndef WIN32
if (ret < 0 && errno != EINPROGRESS) {
close(handle);
return -1;
}
+#endif
return handle;
}
@@ -186,7 +190,9 @@ int net_listen(IPADDR *my_ip, int *port)
return -1;
/* set socket options */
+#ifndef WIN32
fcntl(handle, F_SETFL, O_NONBLOCK);
+#endif
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR,
(char *) &opt, sizeof(opt));
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
@@ -235,7 +241,9 @@ int net_accept(int handle, IPADDR *addr, int *port)
if (addr != NULL) sin_get_ip(&so, addr);
if (port != NULL) *port = sin_get_port(&so);
+#ifndef WIN32
fcntl(ret, F_SETFL, O_NONBLOCK);
+#endif
return ret;
}
@@ -450,7 +458,7 @@ int net_geterror(int handle)
int data;
socklen_t len = sizeof(data);
- if (getsockopt(handle, SOL_SOCKET, SO_ERROR, &data, &len) == -1)
+ if (getsockopt(handle, SOL_SOCKET, SO_ERROR, (void *) &data, &len) == -1)
return -1;
return data;
diff --git a/src/lib-popt/findme.c b/src/lib-popt/findme.c
index bcbe1941..a465a051 100644
--- a/src/lib-popt/findme.c
+++ b/src/lib-popt/findme.c
@@ -39,8 +39,10 @@ char * findProgramPath(char * argv0) {
*chptr = '\0';
sprintf(buf, "%s/%s", start, argv0);
+#ifndef WIN32
if (!access(buf, X_OK))
return buf;
+#endif
if (chptr)
start = chptr + 1;
diff --git a/src/lib-popt/poptconfig.c b/src/lib-popt/poptconfig.c
index 67c084e5..9219e9bf 100644
--- a/src/lib-popt/poptconfig.c
+++ b/src/lib-popt/poptconfig.c
@@ -127,7 +127,9 @@ int poptReadDefaultConfig(poptContext con, int useEnv) {
rc = poptReadConfigFile(con, "/etc/popt");
if (rc) return rc;
+#ifndef WIN32
if (getuid() != geteuid()) return 0;
+#endif
if ((home = getenv("HOME"))) {
fn = alloca(strlen(home) + 20);
diff --git a/src/lib-popt/poptparse.c b/src/lib-popt/poptparse.c
index 181ec1ac..6e412834 100644
--- a/src/lib-popt/poptparse.c
+++ b/src/lib-popt/poptparse.c
@@ -29,7 +29,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
int i, buflen;
buflen = strlen(s) + 1;
- bufStart = buf = alloca(buflen);
+ bufStart = buf = malloc(buflen);
memset(buf, '\0', buflen);
src = s;
@@ -43,6 +43,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
src++;
if (!*src) {
free(argv);
+ free(bufStart);
return POPT_ERROR_BADQUOTE;
}
if (*src != quote) *buf++ = '\\';
@@ -66,6 +67,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
src++;
if (!*src) {
free(argv);
+ free(bufStart);
return POPT_ERROR_BADQUOTE;
}
/* fallthrough */
@@ -95,5 +97,6 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
*argvPtr = argv2;
*argcPtr = argc;
+ free(bufStart);
return 0;
}