summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@0x90.dk>2015-01-04 01:57:21 +0100
committerAlexander Færøy <ahf@irssi.org>2018-02-26 23:32:57 +0100
commit016b42baea9d7dcd2a284f873246c06259c560dd (patch)
tree8c5382398598851bd23b8ca3d439d580f224d684 /src/core
parentad4324d24210f30646575b8bcbae8b50d2149224 (diff)
downloadirssi-016b42baea9d7dcd2a284f873246c06259c560dd.zip
Add OTR support.
This patch adds support for the OTR protocol to irssi. This is an import of the external irssi-otr project that we are now taking over maintership for. Major thanks to the original authors of Irssi-OTR: Uli Meis and David Goulet. Thanks to the OTR community in #OTR on OFTC, thanks to everyone who have helped testing the patches and submitted UI suggestions.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/net-nonblock.c35
-rw-r--r--src/core/network.c33
-rw-r--r--src/core/network.h2
3 files changed, 35 insertions, 35 deletions
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c
index d6e767b6..94c53e74 100644
--- a/src/core/net-nonblock.c
+++ b/src/core/net-nonblock.c
@@ -35,41 +35,6 @@ typedef struct {
int tag;
} SIMPLE_THREAD_REC;
-static int g_io_channel_write_block(GIOChannel *channel, void *data, int len)
-{
- gsize ret;
- int sent;
- GIOStatus status;
-
- sent = 0;
- do {
- status = g_io_channel_write_chars(channel, (char *) data + sent,
- len-sent, &ret, NULL);
- sent += ret;
- } while (sent < len && status != G_IO_STATUS_ERROR);
-
- return sent < len ? -1 : 0;
-}
-
-static int g_io_channel_read_block(GIOChannel *channel, void *data, int len)
-{
- time_t maxwait;
- gsize ret;
- int received;
- GIOStatus status;
-
- maxwait = time(NULL)+2;
- received = 0;
- do {
- status = g_io_channel_read_chars(channel, (char *) data + received,
- len-received, &ret, NULL);
- received += ret;
- } while (received < len && time(NULL) < maxwait &&
- status != G_IO_STATUS_ERROR && status != G_IO_STATUS_EOF);
-
- return received < len ? -1 : 0;
-}
-
/* nonblocking gethostbyname(), ip (IPADDR) + error (int, 0 = not error) is
written to pipe when found PID of the resolver child is returned */
int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
diff --git a/src/core/network.c b/src/core/network.c
index d280b463..0e326e22 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -48,6 +48,39 @@ GIOChannel *g_io_channel_new(int handle)
return chan;
}
+int g_io_channel_write_block(GIOChannel *channel, void *data, int len)
+{
+ gsize ret;
+ int sent;
+ GIOStatus status;
+
+ sent = 0;
+ do {
+ status = g_io_channel_write_chars(channel, (char *) data + sent, len - sent, &ret, NULL);
+ sent += ret;
+ } while (sent < len && status != G_IO_STATUS_ERROR);
+
+ return sent < len ? -1 : 0;
+}
+
+int g_io_channel_read_block(GIOChannel *channel, void *data, int len)
+{
+ time_t maxwait;
+ gsize ret;
+ int received;
+ GIOStatus status;
+
+ maxwait = time(NULL)+2;
+ received = 0;
+ do {
+ status = g_io_channel_read_chars(channel, (char *) data + received, len - received, &ret, NULL);
+ received += ret;
+ } while (received < len && time(NULL) < maxwait &&
+ status != G_IO_STATUS_ERROR && status != G_IO_STATUS_EOF);
+
+ return received < len ? -1 : 0;
+}
+
IPADDR ip4_any = {
AF_INET,
#if defined(IN6ADDR_ANY_INIT)
diff --git a/src/core/network.h b/src/core/network.h
index e60f607f..30fd6aab 100644
--- a/src/core/network.h
+++ b/src/core/network.h
@@ -36,6 +36,8 @@ GIOChannel *g_io_channel_new(int handle);
/* Returns 1 if IPADDRs are the same. */
/* Deprecated since it is unused. It will be deleted in a later release. */
int net_ip_compare(IPADDR *ip1, IPADDR *ip2) G_GNUC_DEPRECATED;
+int g_io_channel_write_block(GIOChannel *channel, void *data, int len);
+int g_io_channel_read_block(GIOChannel *channel, void *data, int len);
int net_connect_ip_handle(const IPADDR *ip, int port, const IPADDR *my_ip);