libeech

BitTorrent library
git clone git://z3bra.org/libeech.git
Log | Files | Refs | README | LICENSE

commit 5d82b5c139f3e89344a9b34ee04dcc7f666ebc40
parent 59aab58e207a45ed4a4f9a32999c4decb2bf821d
Author: z3bra <contactatz3bradotorg>
Date:   Fri Jun 29 17:58:09 +0200

Rename buffer variables

Diffstat:
libeech.c | 28++++++++++++++--------------
libeech.h | 4++--
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/libeech.c b/libeech.c @@ -280,9 +280,9 @@ addpeer(struct peer *pl, char *host, int port) p->state = 0; p->next = pl; p->port = port; - p->buflen = 0; + p->rxbufsz = 0; memcpy(p->host, host, HOST_NAME_MAX); - memset(p->buf, 0, MSGSIZ); + memset(p->rxbuf, 0, MSGSIZ); return p; } @@ -340,13 +340,13 @@ pwphsrecv(struct peer *p) { ssize_t r; - while ((r = recv(p->fd, p->buf, 68 - p->buflen, 0)) > 0) - p->buflen += r; + while ((r = recv(p->fd, p->rxbuf, 68 - p->rxbufsz, 0)) > 0) + p->rxbufsz += r; if (r < 0) return -1; - return p->buflen; + return p->rxbufsz; } static int @@ -371,20 +371,20 @@ pwprecv(struct peer *p) { ssize_t s, l, r; - if (!p->buflen) { + if (!p->rxbufsz) { /* read the first 4 bytes to get message length */ - if ((r = recv(p->fd, p->buf, 4, MSG_PEEK)) < 4) + if ((r = recv(p->fd, p->rxbuf, 4, MSG_PEEK)) < 4) return -1; } /* expected message length */ - l = U32(p->buf) + 4; + l = U32(p->rxbuf) + 4; if (l > MSGSIZ) return -1; - s = p->buflen; - while ((r = recv(p->fd, p->buf, l - s, 0)) > 0) { + s = p->rxbufsz; + while ((r = recv(p->fd, p->rxbuf, l - s, 0)) > 0) { l -= r; s += r; } @@ -441,15 +441,15 @@ pwprx(struct torrent *t, struct peer *p) /* receive and verify handshake */ if (!(p->state & HANDSHAKERCVD)) { pwphsrecv(p); - if (p->buflen >= 68 && pwphsck(t, p->buf, p->buflen)) { + if (p->rxbufsz >= 68 && pwphsck(t, p->rxbuf, p->rxbufsz)) { delpeer(t->peers, p); return -1; } - p->buflen = 0; + p->rxbufsz = 0; p->state |= HANDSHAKERCVD; } else { - if (!(p->buflen = pwprecv(p))) - printf("Message ID: %d (%d bytes)\n", p->buf[4], U32(p->buf)); + if (!(p->rxbufsz = pwprecv(p))) + printf("Message ID: %d (%d bytes)\n", p->rxbuf[4], U32(p->rxbuf)); } return 0; } diff --git a/libeech.h b/libeech.h @@ -30,8 +30,8 @@ struct peer { int state; int port; char host[HOST_NAME_MAX]; - char buf[MSGSIZ]; - long buflen; + char rxbuf[MSGSIZ]; + long rxbufsz; struct peer *next; };