aboutsummaryrefslogtreecommitdiff
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/irc.c b/irc.c
index 5c206bd..314c3b7 100644
--- a/irc.c
+++ b/irc.c
@@ -13,6 +13,8 @@ irc_connect()
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+ printf("connecting to %s:%s....\n",HOST,PORT);
+
int status;
struct addrinfo *res;
if ((status = getaddrinfo(HOST, PORT, &hints, &res)) != 0) {
@@ -103,10 +105,16 @@ irc_recv()
return -1;
}
+ DPf("recieved %ld ",amt);
+
// find the end of a message
char *c;
char *end = recv_cur+amt;
char *msg_start = recv_buf;
+
+
+ DPn("BUF",recv_buf,end-recv_buf);
+
for (c=recv_buf; c<end; c++) {
if (*c == '\r' && *(c+1) == '\n') {
handle(msg_start, (c+2)-msg_start);
@@ -123,7 +131,11 @@ irc_recv()
fprintf(stderr,"my receive buffer is filled with NONSENSE!!!\n");
return -1;
}
- memmove(recv_buf, msg_start, remlen);
+ if (recv_buf != msg_start) {
+ DPf("mem moving %ld\n",remlen);
+ memmove(recv_buf, msg_start, remlen);
+ }
+ recv_cur = recv_buf + remlen;
}
return 0;