MEDIUM: buffers: rename a number of buffer management functions
The following renaming took place :
1) buffer input functions
buffer_put_block => bi_putblk
buffer_put_char => bi_putchr
buffer_put_string => bi_putstr
buffer_put_chunk => bi_putchk
buffer_feed => bi_putstr
buffer_feed_chunk => bi_putchk
buffer_cut_tail => bi_erase
buffer_ignore => bi_fast_delete
2) buffer output functions
buffer_get_char => bo_getchr
buffer_get_line => bo_getline
buffer_get_block => bo_getblk
buffer_skip => bo_skip
buffer_write => bo_inject
3) buffer input avail/full functions were introduced :
bi_avail
bi_full
diff --git a/src/peers.c b/src/peers.c
index 6c25dcd..3d2fd01 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -232,7 +232,7 @@
si->applet.st0 = PEER_SESSION_GETVERSION;
/* fall through */
case PEER_SESSION_GETVERSION:
- reql = buffer_get_line(si->ob, trash, sizeof(trash));
+ reql = bo_getline(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
@@ -248,7 +248,7 @@
else
trash[reql-1] = 0;
- buffer_skip(si->ob, reql);
+ bo_skip(si->ob, reql);
/* test version */
if (strcmp(PEER_SESSION_PROTO_NAME " 1.0", trash) != 0) {
@@ -263,7 +263,7 @@
si->applet.st0 = PEER_SESSION_GETHOST;
/* fall through */
case PEER_SESSION_GETHOST:
- reql = buffer_get_line(si->ob, trash, sizeof(trash));
+ reql = bo_getline(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
@@ -279,7 +279,7 @@
else
trash[reql-1] = 0;
- buffer_skip(si->ob, reql);
+ bo_skip(si->ob, reql);
/* test hostname match */
if (strcmp(localpeer, trash) != 0) {
@@ -293,7 +293,7 @@
case PEER_SESSION_GETPEER: {
struct peer *curpeer;
char *p;
- reql = buffer_get_line(si->ob, trash, sizeof(trash));
+ reql = bo_getline(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
@@ -310,7 +310,7 @@
else
trash[reql-1] = 0;
- buffer_skip(si->ob, reql);
+ bo_skip(si->ob, reql);
/* parse line "<peer name> <pid>" */
p = strchr(trash, ' ');
@@ -346,7 +346,7 @@
size_t key_size;
char *p;
- reql = buffer_get_line(si->ob, trash, sizeof(trash));
+ reql = bo_getline(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
@@ -367,7 +367,7 @@
else
trash[reql-1] = 0;
- buffer_skip(si->ob, reql);
+ bo_skip(si->ob, reql);
/* Parse line "<table name> <type> <size>" */
p = strchr(trash, ' ');
@@ -448,7 +448,7 @@
struct peer_session *ps = (struct peer_session *)si->applet.private;
repl = snprintf(trash, sizeof(trash), "%d\n", PEER_SESSION_SUCCESSCODE);
- repl = buffer_put_block(si->ib, trash, repl);
+ repl = bi_putblk(si->ib, trash, repl);
if (repl <= 0) {
if (repl == -1)
goto out;
@@ -512,7 +512,7 @@
goto switchstate;
}
- repl = buffer_put_block(si->ib, trash, repl);
+ repl = bi_putblk(si->ib, trash, repl);
if (repl <= 0) {
if (repl == -1)
goto out;
@@ -530,7 +530,7 @@
if (si->ib->flags & BF_WRITE_PARTIAL)
ps->statuscode = PEER_SESSION_CONNECTEDCODE;
- reql = buffer_get_line(si->ob, trash, sizeof(trash));
+ reql = bo_getline(si->ob, trash, sizeof(trash));
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0)
goto out;
@@ -547,7 +547,7 @@
else
trash[reql-1] = 0;
- buffer_skip(si->ob, reql);
+ bo_skip(si->ob, reql);
/* Register status code */
ps->statuscode = atoi(trash);
@@ -600,7 +600,7 @@
char c;
int totl = 0;
- reql = buffer_get_block(si->ob, (char *)&c, sizeof(c), totl);
+ reql = bo_getblk(si->ob, (char *)&c, sizeof(c), totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
/* nothing to read */
@@ -625,7 +625,7 @@
pushack = ps->pushack + (unsigned int)(c & 0x7F);
}
else {
- reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+ reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -642,7 +642,7 @@
/* type string */
stkey.key = stkey.data.buf;
- reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+ reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -653,7 +653,7 @@
totl += reql;
stkey.key_len = ntohl(netinteger);
- reql = buffer_get_block(si->ob, stkey.key, stkey.key_len, totl);
+ reql = bo_getblk(si->ob, stkey.key, stkey.key_len, totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -668,7 +668,7 @@
stkey.key_len = (size_t)-1;
stkey.key = &stkey.data.integer;
- reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+ reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -684,7 +684,7 @@
stkey.key_len = (size_t)-1;
stkey.key = stkey.data.buf;
- reql = buffer_get_block(si->ob, (char *)&stkey.data.buf, ps->table->table->key_size, totl);
+ reql = bo_getblk(si->ob, (char *)&stkey.data.buf, ps->table->table->key_size, totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -697,7 +697,7 @@
}
/* read server id */
- reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+ reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -806,7 +806,7 @@
/* ack message */
uint32_t netinteger;
- reql = buffer_get_block(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
+ reql = bo_getblk(si->ob, (char *)&netinteger, sizeof(netinteger), totl);
if (reql <= 0) { /* closed or EOL not found */
if (reql == 0) {
goto incomplete;
@@ -826,7 +826,7 @@
}
/* skip consumed message */
- buffer_skip(si->ob, totl);
+ bo_skip(si->ob, totl);
/* loop on that state to peek next message */
continue;
@@ -836,7 +836,7 @@
/* Confirm finished or partial messages */
while (ps->confirm) {
/* There is a confirm messages to send */
- repl = buffer_put_char(si->ib, 'c');
+ repl = bi_putchr(si->ib, 'c');
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -853,7 +853,7 @@
!(ps->table->flags & SHTABLE_F_RESYNC_PROCESS)) {
/* Current peer was elected to request a resync */
- repl = buffer_put_char(si->ib, 'R');
+ repl = bi_putchr(si->ib, 'R');
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -872,7 +872,7 @@
netinteger = htonl(ps->pushack);
memcpy(&trash[1], &netinteger, sizeof(netinteger));
- repl = buffer_put_block(si->ib, trash, 1+sizeof(netinteger));
+ repl = bi_putblk(si->ib, trash, 1+sizeof(netinteger));
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -908,7 +908,7 @@
msglen = peer_prepare_datamsg(ts, ps, trash, sizeof(trash));
if (msglen) {
/* message to buffer */
- repl = buffer_put_block(si->ib, trash, msglen);
+ repl = bi_putblk(si->ib, trash, msglen);
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -942,7 +942,7 @@
msglen = peer_prepare_datamsg(ts, ps, trash, sizeof(trash));
if (msglen) {
/* message to buffer */
- repl = buffer_put_block(si->ib, trash, msglen);
+ repl = bi_putblk(si->ib, trash, msglen);
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -958,7 +958,7 @@
if (!(ps->flags & PEER_F_TEACH_FINISHED)) {
/* process final lesson message */
- repl = buffer_put_char(si->ib, ((ps->table->flags & SHTABLE_RESYNC_STATEMASK) == SHTABLE_RESYNC_FINISHED) ? 'F' : 'C');
+ repl = bi_putchr(si->ib, ((ps->table->flags & SHTABLE_RESYNC_STATEMASK) == SHTABLE_RESYNC_FINISHED) ? 'F' : 'C');
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -1000,7 +1000,7 @@
msglen = peer_prepare_datamsg(ts, ps, trash, sizeof(trash));
if (msglen) {
/* message to buffer */
- repl = buffer_put_block(si->ib, trash, msglen);
+ repl = bi_putblk(si->ib, trash, msglen);
if (repl <= 0) {
/* no more write possible */
if (repl == -1)
@@ -1019,7 +1019,7 @@
case PEER_SESSION_EXIT:
repl = snprintf(trash, sizeof(trash), "%d\n", si->applet.st1);
- if (buffer_put_block(si->ib, trash, repl) == -1)
+ if (bi_putblk(si->ib, trash, repl) == -1)
goto out;
si->applet.st0 = PEER_SESSION_END;
/* fall through */