diff options
author | Timo Sirainen <cras@irssi.org> | 2000-12-04 22:57:18 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-12-04 22:57:18 +0000 |
commit | 1c9f45b4a41e5553c89393cd3228b8e8e9d6131b (patch) | |
tree | 2431f899730d091c2185e651184693d5f1853dce /src/irc/dcc/dcc-chat.c | |
parent | e81fdd730752012a3b34af443226f50d4771cc54 (diff) | |
download | irssi-1c9f45b4a41e5553c89393cd3228b8e8e9d6131b.zip |
Use GIOChannel instead of sockets directly. Helps porting to win32 :)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@962 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/dcc/dcc-chat.c')
-rw-r--r-- | src/irc/dcc/dcc-chat.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c index 7ebac58c..e37217f1 100644 --- a/src/irc/dcc/dcc-chat.c +++ b/src/irc/dcc/dcc-chat.c @@ -190,19 +190,20 @@ static void dcc_chat_input(DCC_REC *dcc) static void dcc_chat_listen(DCC_REC *dcc) { IPADDR ip; - int handle, port; + GIOChannel *handle; + int port; g_return_if_fail(dcc != NULL); /* accept connection */ handle = net_accept(dcc->handle, &ip, &port); - if (handle == -1) + if (handle == NULL) return; /* TODO: add paranoia check - see dcc-files.c */ g_source_remove(dcc->tagconn); - close(dcc->handle); + net_disconnect(dcc->handle); dcc->starttime = time(NULL); dcc->handle = handle; @@ -243,14 +244,14 @@ static void dcc_chat_connect(DCC_REC *dcc) g_return_if_fail(dcc != NULL); if (dcc->addrstr[0] == '\0' || - dcc->starttime != 0 || dcc->handle != -1) { + dcc->starttime != 0 || dcc->handle != NULL) { /* already sent a chat request / already chatting */ return; } dcc->handle = net_connect_ip(&dcc->addr, dcc->port, source_host_ok ? source_host_ip : NULL); - if (dcc->handle != -1) { + if (dcc->handle != NULL) { dcc->tagconn = g_input_add(dcc->handle, G_INPUT_WRITE | G_INPUT_READ, (GInputFunction) sig_chat_connected, dcc); @@ -267,8 +268,9 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server) void *free_arg; DCC_REC *dcc; IPADDR own_ip; + GIOChannel *handle; char *nick, *str, host[MAX_IP_LEN]; - int port, handle; + int port; g_return_if_fail(data != NULL); @@ -288,12 +290,13 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server) if (server == NULL || !server->connected) cmd_param_error(CMDERR_NOT_CONNECTED); - if (net_getsockname(net_sendbuffer_handle(server->handle), &own_ip, NULL) == -1) + if (net_getsockname(net_sendbuffer_handle(server->handle), + &own_ip, NULL) == -1) cmd_param_error(CMDERR_ERRNO); port = settings_get_int("dcc_port"); handle = net_listen(&own_ip, &port); - if (handle == -1) + if (handle == NULL) cmd_param_error(CMDERR_ERRNO); dcc = dcc_create(DCC_TYPE_CHAT, handle, nick, "chat", server, NULL); |