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)
|
void core_init(void)
|
||||||
{
|
{
|
||||||
modules_init();
|
modules_init();
|
||||||
|
#ifndef WIN32
|
||||||
pidwait_init();
|
pidwait_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
net_disconnect_init();
|
net_disconnect_init();
|
||||||
net_sendbuffer_init();
|
net_sendbuffer_init();
|
||||||
@ -96,6 +98,8 @@ void core_deinit(void)
|
|||||||
net_sendbuffer_deinit();
|
net_sendbuffer_deinit();
|
||||||
net_disconnect_deinit();
|
net_disconnect_deinit();
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
pidwait_deinit();
|
pidwait_deinit();
|
||||||
|
#endif
|
||||||
modules_deinit();
|
modules_deinit();
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ void net_disconnect_init(void)
|
|||||||
|
|
||||||
void net_disconnect_deinit(void)
|
void net_disconnect_deinit(void)
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
NET_DISCONNECT_REC *rec;
|
NET_DISCONNECT_REC *rec;
|
||||||
time_t now, max;
|
time_t now, max;
|
||||||
int first;
|
int first;
|
||||||
@ -148,4 +149,5 @@ void net_disconnect_deinit(void)
|
|||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,13 @@ int net_gethostbyname_nonblock(const char *addr, int pipe)
|
|||||||
{
|
{
|
||||||
RESOLVED_IP_REC rec;
|
RESOLVED_IP_REC rec;
|
||||||
const char *errorstr;
|
const char *errorstr;
|
||||||
|
#ifndef WIN32
|
||||||
int pid;
|
int pid;
|
||||||
|
#endif
|
||||||
|
|
||||||
g_return_val_if_fail(addr != NULL, FALSE);
|
g_return_val_if_fail(addr != NULL, FALSE);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
/* parent */
|
/* parent */
|
||||||
@ -57,6 +60,7 @@ int net_gethostbyname_nonblock(const char *addr, int pipe)
|
|||||||
g_warning("net_connect_thread(): fork() failed! "
|
g_warning("net_connect_thread(): fork() failed! "
|
||||||
"Using blocking resolving");
|
"Using blocking resolving");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* child */
|
/* child */
|
||||||
memset(&rec, 0, sizeof(rec));
|
memset(&rec, 0, sizeof(rec));
|
||||||
@ -72,8 +76,10 @@ int net_gethostbyname_nonblock(const char *addr, int pipe)
|
|||||||
if (rec.error != 0)
|
if (rec.error != 0)
|
||||||
write(pipe, errorstr, rec.errlen);
|
write(pipe, errorstr, rec.errlen);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
_exit(99);
|
_exit(99);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* we used blocking lookup */
|
/* we used blocking lookup */
|
||||||
return 0;
|
return 0;
|
||||||
@ -89,7 +95,9 @@ int net_gethostbyname_return(int pipe, RESOLVED_IP_REC *rec)
|
|||||||
rec->errorstr = NULL;
|
rec->errorstr = NULL;
|
||||||
|
|
||||||
/* get ip+error - try for max. 1-2 seconds */
|
/* get ip+error - try for max. 1-2 seconds */
|
||||||
|
#ifndef WIN32
|
||||||
fcntl(pipe, F_SETFL, O_NONBLOCK);
|
fcntl(pipe, F_SETFL, O_NONBLOCK);
|
||||||
|
#endif
|
||||||
|
|
||||||
maxwait = time(NULL)+2;
|
maxwait = time(NULL)+2;
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -134,7 +142,9 @@ void net_disconnect_nonblock(int pid)
|
|||||||
{
|
{
|
||||||
g_return_if_fail(pid > 0);
|
g_return_if_fail(pid > 0);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void simple_init(SIMPLE_THREAD_REC *rec, int handle)
|
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);
|
so->sin6.sin6_port = htons(port);
|
||||||
else
|
else
|
||||||
#endif
|
#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)
|
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;
|
return -1;
|
||||||
|
|
||||||
/* set socket options */
|
/* set socket options */
|
||||||
|
#ifndef WIN32
|
||||||
fcntl(handle, F_SETFL, O_NONBLOCK);
|
fcntl(handle, F_SETFL, O_NONBLOCK);
|
||||||
|
#endif
|
||||||
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR,
|
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(char *) &opt, sizeof(opt));
|
(char *) &opt, sizeof(opt));
|
||||||
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
|
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);
|
sin_set_port(&so, port);
|
||||||
ret = connect(handle, &so.sa, sizeof(so));
|
ret = connect(handle, &so.sa, sizeof(so));
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
if (ret < 0 && errno != EINPROGRESS) {
|
if (ret < 0 && errno != EINPROGRESS) {
|
||||||
close(handle);
|
close(handle);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@ -186,7 +190,9 @@ int net_listen(IPADDR *my_ip, int *port)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* set socket options */
|
/* set socket options */
|
||||||
|
#ifndef WIN32
|
||||||
fcntl(handle, F_SETFL, O_NONBLOCK);
|
fcntl(handle, F_SETFL, O_NONBLOCK);
|
||||||
|
#endif
|
||||||
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR,
|
setsockopt(handle, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(char *) &opt, sizeof(opt));
|
(char *) &opt, sizeof(opt));
|
||||||
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
|
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 (addr != NULL) sin_get_ip(&so, addr);
|
||||||
if (port != NULL) *port = sin_get_port(&so);
|
if (port != NULL) *port = sin_get_port(&so);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
fcntl(ret, F_SETFL, O_NONBLOCK);
|
fcntl(ret, F_SETFL, O_NONBLOCK);
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +458,7 @@ int net_geterror(int handle)
|
|||||||
int data;
|
int data;
|
||||||
socklen_t len = sizeof(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 -1;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -39,8 +39,10 @@ char * findProgramPath(char * argv0) {
|
|||||||
*chptr = '\0';
|
*chptr = '\0';
|
||||||
sprintf(buf, "%s/%s", start, argv0);
|
sprintf(buf, "%s/%s", start, argv0);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
if (!access(buf, X_OK))
|
if (!access(buf, X_OK))
|
||||||
return buf;
|
return buf;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (chptr)
|
if (chptr)
|
||||||
start = chptr + 1;
|
start = chptr + 1;
|
||||||
|
@ -127,7 +127,9 @@ int poptReadDefaultConfig(poptContext con, int useEnv) {
|
|||||||
|
|
||||||
rc = poptReadConfigFile(con, "/etc/popt");
|
rc = poptReadConfigFile(con, "/etc/popt");
|
||||||
if (rc) return rc;
|
if (rc) return rc;
|
||||||
|
#ifndef WIN32
|
||||||
if (getuid() != geteuid()) return 0;
|
if (getuid() != geteuid()) return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((home = getenv("HOME"))) {
|
if ((home = getenv("HOME"))) {
|
||||||
fn = alloca(strlen(home) + 20);
|
fn = alloca(strlen(home) + 20);
|
||||||
|
@ -29,7 +29,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
|
|||||||
int i, buflen;
|
int i, buflen;
|
||||||
|
|
||||||
buflen = strlen(s) + 1;
|
buflen = strlen(s) + 1;
|
||||||
bufStart = buf = alloca(buflen);
|
bufStart = buf = malloc(buflen);
|
||||||
memset(buf, '\0', buflen);
|
memset(buf, '\0', buflen);
|
||||||
|
|
||||||
src = s;
|
src = s;
|
||||||
@ -43,6 +43,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
|
|||||||
src++;
|
src++;
|
||||||
if (!*src) {
|
if (!*src) {
|
||||||
free(argv);
|
free(argv);
|
||||||
|
free(bufStart);
|
||||||
return POPT_ERROR_BADQUOTE;
|
return POPT_ERROR_BADQUOTE;
|
||||||
}
|
}
|
||||||
if (*src != quote) *buf++ = '\\';
|
if (*src != quote) *buf++ = '\\';
|
||||||
@ -66,6 +67,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
|
|||||||
src++;
|
src++;
|
||||||
if (!*src) {
|
if (!*src) {
|
||||||
free(argv);
|
free(argv);
|
||||||
|
free(bufStart);
|
||||||
return POPT_ERROR_BADQUOTE;
|
return POPT_ERROR_BADQUOTE;
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
@ -95,5 +97,6 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
|
|||||||
*argvPtr = argv2;
|
*argvPtr = argv2;
|
||||||
*argcPtr = argc;
|
*argcPtr = argc;
|
||||||
|
|
||||||
|
free(bufStart);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user