diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-05-22 22:38:29 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-05-22 22:38:29 +0000 |
commit | f053542dcfd1739152c57eede2b882894911ca48 (patch) | |
tree | ec5f8f8b4a0c78d0dd5dcb76847a29e329de0d1f /src/core | |
parent | 9f99376a8ac3d86d09bb5358753df2c3eaca5cae (diff) | |
download | irssi-f053542dcfd1739152c57eede2b882894911ca48.zip |
Extend net_sendbuffer by adding a LINEBUF_REC member and a net_sendbuffer_receive_line
function to read linewise from the associated io channel.
Rewrite irc/dcc/proxy read logic on top of it.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4841 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/net-sendbuffer.c | 13 | ||||
-rw-r--r-- | src/core/net-sendbuffer.h | 3 | ||||
-rw-r--r-- | src/core/server-rec.h | 1 | ||||
-rw-r--r-- | src/core/servers.c | 2 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/core/net-sendbuffer.c b/src/core/net-sendbuffer.c index eb01aa47..0170325b 100644 --- a/src/core/net-sendbuffer.c +++ b/src/core/net-sendbuffer.c @@ -22,6 +22,7 @@ #include "network.h" #include "net-sendbuffer.h" +#include "line-split.h" static GSList *buffers; @@ -50,6 +51,7 @@ void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close) if (rec->send_tag != -1) g_source_remove(rec->send_tag); if (close) net_disconnect(rec->handle); + if (rec->readbuffer != NULL) line_split_free(rec->readbuffer); g_free_not_null(rec->buffer); g_free(rec); } @@ -142,6 +144,17 @@ int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size) return buffer_add(rec, data, size) ? 0 : -1; } +int net_sendbuffer_receive_line(NET_SENDBUF_REC *rec, char **str, int read_socket) +{ + char tmpbuf[512]; + int recvlen = 0; + + if (read_socket) + recvlen = net_receive(rec->handle, tmpbuf, sizeof(tmpbuf)); + + return line_split(tmpbuf, recvlen, str, &rec->readbuffer); +} + /* Flush the buffer, blocks until finished. */ void net_sendbuffer_flush(NET_SENDBUF_REC *rec) { diff --git a/src/core/net-sendbuffer.h b/src/core/net-sendbuffer.h index 3c377110..82f4bb39 100644 --- a/src/core/net-sendbuffer.h +++ b/src/core/net-sendbuffer.h @@ -6,6 +6,7 @@ struct _NET_SENDBUF_REC { GIOChannel *handle; + LINEBUF_REC *readbuffer; /* receive buffer */ int send_tag; int bufsize; @@ -26,6 +27,8 @@ void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close); occured. */ int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size); +int net_sendbuffer_receive_line(NET_SENDBUF_REC *rec, char **str, int read_socket); + /* Flush the buffer, blocks until finished. */ void net_sendbuffer_flush(NET_SENDBUF_REC *rec); diff --git a/src/core/server-rec.h b/src/core/server-rec.h index bc8124dc..726d1c14 100644 --- a/src/core/server-rec.h +++ b/src/core/server-rec.h @@ -27,7 +27,6 @@ int connect_tag; int connect_pid; RAWLOG_REC *rawlog; -LINEBUF_REC *buffer; /* receive buffer */ GHashTable *module_data; char *version; /* server version */ diff --git a/src/core/servers.c b/src/core/servers.c index 95748081..3e1d83f0 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -21,7 +21,6 @@ #include "module.h" #include "signals.h" #include "commands.h" -#include "line-split.h" #include "net-disconnect.h" #include "net-nonblock.h" #include "net-sendbuffer.h" @@ -536,7 +535,6 @@ int server_unref(SERVER_REC *server) MODULE_DATA_DEINIT(server); server_connect_unref(server->connrec); if (server->rawlog != NULL) rawlog_destroy(server->rawlog); - if (server->buffer != NULL) line_split_free(server->buffer); g_free(server->version); g_free(server->away_reason); g_free(server->nick); |