diff options
author | ubq323 <ubq323@ubq323.website> | 2022-10-28 01:17:59 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-10-28 01:17:59 +0100 |
commit | c524506e04927a39648d47ba55af4fdff32faab6 (patch) | |
tree | 94fb88c53b7b1530753872277ec8f3d2caaa8161 /irc.c | |
parent | 7a17c3a4ea869a04041ff2568fd02ec676ab8dff (diff) |
horrible makefile tricks, making the buffer thing actually buffer the buffers bufferously, properly, also fix typos
Diffstat (limited to 'irc.c')
-rw-r--r-- | irc.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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; |