mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Win32 updates
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@784 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
df10f182c0
commit
e0bc134d66
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user