aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn/msn_util.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-03-13 06:28:36 -0300
committerdequis <dx@dxzone.com.ar>2015-04-10 14:10:41 -0300
commita4be2f6df564eea09612731be194278e4fb755e0 (patch)
tree746d86bfa3691d19395802101dddf95d6e106527 /protocols/msn/msn_util.c
parent3b09b38a6f8bd15e0971085f9c6a48c31d7f1c17 (diff)
msn: add msn_queue_feed(), move read() out of msn_handler()
Diffstat (limited to 'protocols/msn/msn_util.c')
-rw-r--r--protocols/msn/msn_util.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c
index 4d9c85f2..931641ce 100644
--- a/protocols/msn/msn_util.c
+++ b/protocols/msn/msn_util.c
@@ -171,6 +171,19 @@ void msn_buddy_ask(bee_user_t *bu)
imcb_ask_with_free(bu->ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no, msn_buddy_ask_free);
}
+void msn_queue_feed(struct msn_data *h, char *bytes, int st)
+{
+ h->rxq = g_renew(char, h->rxq, h->rxlen + 1024);
+ memcpy(h->rxq + h->rxlen, bytes, st);
+ h->rxlen += st;
+
+ if (getenv("BITLBEE_DEBUG")) {
+ fprintf(stderr, "\n\x1b[92m<<< ");
+ write(2, bytes , st);
+ fprintf(stderr, "\x1b[97m");
+ }
+}
+
/* This one handles input from a MSN Messenger server. Both the NS and SB servers usually give
commands, but sometimes they give additional data (payload). This function tries to handle
this all in a nice way and send all data to the right places. */
@@ -181,23 +194,7 @@ void msn_buddy_ask(bee_user_t *bu)
int msn_handler(struct msn_data *h)
{
- struct im_connection *ic = h->ic;
- int st;
-
- h->rxq = g_renew(char, h->rxq, h->rxlen + 1024);
- st = read(h->fd, h->rxq + h->rxlen, 1024);
- h->rxlen += st;
-
- if (st <= 0) {
- fprintf(stderr, "\n\x1b[92m<<< [closed]\x1b[97m ");
- return(-1);
- }
-
- if (getenv("BITLBEE_DEBUG")) {
- fprintf(stderr, "\n\x1b[92m<<< ");
- write(2, h->rxq + h->rxlen - st, st);
- fprintf(stderr, "\x1b[97m");
- }
+ int st = 1;
while (st) {
int i;