mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 12:23:37 +02:00
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
This commit is contained in:
parent
9f99376a8a
commit
f053542dcf
12 changed files with 33 additions and 50 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue