mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 04:43:34 +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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue