]> granicus.if.org Git - libevent/commitdiff
Actually stop using EVBUFFER_LENGTH/DATA, and move them to buffer_compat.h
authorNick Mathewson <nickm@torproject.org>
Fri, 17 Apr 2009 06:56:09 +0000 (06:56 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 17 Apr 2009 06:56:09 +0000 (06:56 +0000)
svn:r1183

14 files changed:
buffer.c
bufferevent.c
bufferevent_filter.c
bufferevent_sock.c
event_rpcgen.py
event_tagging.c
evrpc.c
http.c
include/event2/buffer.h
include/event2/buffer_compat.h
test/regress.c
test/regress_buffer.c
test/regress_bufferevent.c
test/regress_zlib.c

index 68a66d2fe38aaa2d35552b055f24bf80ddbb6d69..b506d5702bae28e340fcfddb272bce96b561d919 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -2259,7 +2259,7 @@ void
 evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb)
 {
        if (!(cb->flags & EVBUFFER_CB_SUSPENDED)) {
-               cb->size_before_suspend = EVBUFFER_LENGTH(buffer);
+               cb->size_before_suspend = evbuffer_get_length(buffer);
                cb->flags |= EVBUFFER_CB_SUSPENDED;
        }
 }
@@ -2274,7 +2274,7 @@ evbuffer_cb_unsuspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb)
                               EVBUFFER_CB_CALL_ON_UNSUSPEND);
                cb->size_before_suspend = 0;
                if (call && (cb->flags & EVBUFFER_CB_ENABLED)) {
-                       cb->cb(buffer, sz, EVBUFFER_LENGTH(buffer), cb->cbarg);
+                       cb->cb(buffer, sz, evbuffer_get_length(buffer), cb->cbarg);
                }
        }
 }
index f92a52bcd92f67d935b4cae75313913fadfb0b36..f0d7bfdfd84eb71d49c5e6e56410267cf66e964c 100644 (file)
@@ -337,9 +337,9 @@ bufferevent_setwatermark(struct bufferevent *bufev, short events,
                                              bufev_private->read_watermarks_cb,
                                              EVBUFFER_CB_ENABLED);
 
-                       if (EVBUFFER_LENGTH(bufev->input) > highmark)
+                       if (evbuffer_get_length(bufev->input) > highmark)
                                bufferevent_wm_suspend_read(bufev);
-                       else if (EVBUFFER_LENGTH(bufev->input) < highmark)
+                       else if (evbuffer_get_length(bufev->input) < highmark)
                                bufferevent_wm_unsuspend_read(bufev);
                } else {
                        /* There is now no high-water mark for read. */
index b427cfb207456e1d9b5d30f69417e23e67942534..9208300ea01ac1fd058d5d4c47a6426dac6a3efe 100644 (file)
@@ -133,7 +133,7 @@ be_underlying_writebuf_full(struct bufferevent_filtered *bevf,
         struct bufferevent *u = bevf->underlying;
         return state == BEV_NORMAL &&
             u->wm_write.high &&
-            EVBUFFER_LENGTH(u->output) >= u->wm_write.high;
+            evbuffer_get_length(u->output) >= u->wm_write.high;
 }
 
 /** Return 1 if our input buffer is at or over its high watermark such that we
@@ -145,7 +145,7 @@ be_readbuf_full(struct bufferevent_filtered *bevf,
         struct bufferevent *bufev = downcast(bevf);
         return state == BEV_NORMAL &&
             bufev->wm_read.high &&
-            EVBUFFER_LENGTH(bufev->input) >= bufev->wm_read.high;
+            evbuffer_get_length(bufev->input) >= bufev->wm_read.high;
 }
 
 
@@ -270,7 +270,7 @@ be_filter_process_input(struct bufferevent_filtered *bevf,
                 ssize_t limit = -1;
                 if (state == BEV_NORMAL && bev->wm_read.high)
                         limit = bev->wm_read.high -
-                            EVBUFFER_LENGTH(bev->input);
+                            evbuffer_get_length(bev->input);
 
                res = bevf->process_in(bevf->underlying->input,
                     bev->input, limit, state, bevf->context);
@@ -279,7 +279,7 @@ be_filter_process_input(struct bufferevent_filtered *bevf,
                        *processed_out = 1;
        } while (res == BEV_OK &&
                 (bev->enabled & EV_READ) &&
-                EVBUFFER_LENGTH(bevf->underlying->input) &&
+                evbuffer_get_length(bevf->underlying->input) &&
                 !be_readbuf_full(bevf, state));
 
        return res;
@@ -303,7 +303,7 @@ be_filter_process_output(struct bufferevent_filtered *bevf,
                  * call the filter no matter what. */
                 if (!(bufev->enabled & EV_WRITE) ||
                     be_underlying_writebuf_full(bevf, state) ||
-                    !EVBUFFER_LENGTH(bufev->output))
+                    !evbuffer_get_length(bufev->output))
                         return BEV_OK;
         }
 
@@ -320,7 +320,7 @@ be_filter_process_output(struct bufferevent_filtered *bevf,
                         if (state == BEV_NORMAL &&
                             bevf->underlying->wm_write.high)
                                 limit = bevf->underlying->wm_write.high -
-                                    EVBUFFER_LENGTH(bevf->underlying->output);
+                                    evbuffer_get_length(bevf->underlying->output);
 
                         res = bevf->process_out(downcast(bevf)->output,
                             bevf->underlying->output,
@@ -336,18 +336,18 @@ be_filter_process_output(struct bufferevent_filtered *bevf,
                         (bufev->enabled & EV_WRITE) &&
                         /* Of if we have nothing more to write and we are
                          * not flushing. */
-                        EVBUFFER_LENGTH(bufev->output) &&
+                        evbuffer_get_length(bufev->output) &&
                         /* Or if we have filled the underlying output buffer. */
                         !be_underlying_writebuf_full(bevf,state));
 
                 if (processed && bufev->writecb &&
-                    EVBUFFER_LENGTH(bufev->output) <= bufev->wm_write.low) {
+                    evbuffer_get_length(bufev->output) <= bufev->wm_write.low) {
                         /* call the write callback.*/
                         (*bufev->writecb)(bufev, bufev->cbarg);
 
                         if (res == BEV_OK &&
                             (bufev->enabled & EV_WRITE) &&
-                            EVBUFFER_LENGTH(bufev->output) &&
+                            evbuffer_get_length(bufev->output) &&
                             !be_underlying_writebuf_full(bevf, state)) {
                                 again = 1;
                         }
@@ -394,7 +394,7 @@ be_filter_readcb(struct bufferevent *underlying, void *_me)
        res = be_filter_process_input(bevf, state, &processed_any);
 
        if (processed_any &&
-            EVBUFFER_LENGTH(bufev->input) >= bufev->wm_read.low &&
+            evbuffer_get_length(bufev->input) >= bufev->wm_read.low &&
             bufev->readcb != NULL)
                (*bufev->readcb)(bufev, bufev->cbarg);
 }
index 5d6b92be27fd90f24d0f666e298f76077a0f9967..614e0e56a752e82adeda867471b3b33aaadead35 100644 (file)
@@ -126,7 +126,7 @@ bufferevent_readcb(evutil_socket_t fd, short event, void *arg)
         * read more data than would make us reach the watermark.
         */
        if (bufev->wm_read.high != 0) {
-               howmuch = bufev->wm_read.high - EVBUFFER_LENGTH(input);
+               howmuch = bufev->wm_read.high - evbuffer_get_length(input);
                /* we somehow lowered the watermark, stop reading */
                if (howmuch <= 0) {
                        bufferevent_wm_suspend_read(bufev);
@@ -154,7 +154,7 @@ bufferevent_readcb(evutil_socket_t fd, short event, void *arg)
 
 
        /* Invoke the user callback - must always be called last */
-       if (EVBUFFER_LENGTH(input) >= bufev->wm_read.low &&
+       if (evbuffer_get_length(input) >= bufev->wm_read.low &&
             bufev->readcb != NULL)
                (*bufev->readcb)(bufev, bufev->cbarg);
 
@@ -181,7 +181,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
                goto error;
        }
 
-       if (EVBUFFER_LENGTH(bufev->output)) {
+       if (evbuffer_get_length(bufev->output)) {
            evbuffer_unfreeze(bufev->output, 1);
            res = evbuffer_write(bufev->output, fd);
            evbuffer_freeze(bufev->output, 1);
@@ -198,7 +198,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
                    goto error;
        }
 
-       if (EVBUFFER_LENGTH(bufev->output) == 0)
+       if (evbuffer_get_length(bufev->output) == 0)
                event_del(&bufev->ev_write);
 
        /*
@@ -206,13 +206,13 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
         * low watermark.
         */
        if (bufev->writecb != NULL &&
-           EVBUFFER_LENGTH(bufev->output) <= bufev->wm_write.low)
+           evbuffer_get_length(bufev->output) <= bufev->wm_write.low)
                (*bufev->writecb)(bufev, bufev->cbarg);
 
        return;
 
  reschedule:
-       if (EVBUFFER_LENGTH(bufev->output) == 0)
+       if (evbuffer_get_length(bufev->output) == 0)
                event_del(&bufev->ev_write);
        return;
 
index 0dd0786f91b5a927ac36812b2ec45dcccaa36fc6..536104dcbd9a6dc3956c4213d688b883154d116f 100755 (executable)
@@ -221,7 +221,7 @@ int evtag_unmarshal_%(name)s(struct evbuffer *, ev_uint32_t,
                        ' struct evbuffer *evbuf)\n'
                        '{\n'
                        '  ev_uint32_t tag;\n'
-                       '  while (EVBUFFER_LENGTH(evbuf) > 0) {\n'
+                       '  while (evbuffer_get_length(evbuf) > 0) {\n'
                        '    if (evtag_peek(evbuf, &tag) == -1)\n'
                        '      return (-1);\n'
                        '    switch (tag) {\n'
@@ -977,7 +977,7 @@ class EntryVarBytes(Entry):
         code = ['if (evtag_payload_length(%(buf)s, &%(varlen)s) == -1)',
                 '  return (-1);',
                 # We do not want DoS opportunities
-                'if (%(varlen)s > EVBUFFER_LENGTH(%(buf)s))',
+                'if (%(varlen)s > evbuffer_get_length(%(buf)s))',
                 '  return (-1);',
                 'if ((%(var)s = malloc(%(varlen)s)) == NULL)',
                 '  return (-1);',
index 001f44c10aa8a1b9e2fe9b7a9785465e30dfbc6c..4af91c23b4104fee37ba72ce50f3cc8db4b4e5f6 100644 (file)
@@ -169,7 +169,7 @@ static int
 decode_tag_internal(ev_uint32_t *ptag, struct evbuffer *evbuf, int dodrain)
 {
        ev_uint32_t number = 0;
-       int len = EVBUFFER_LENGTH(evbuf);
+       int len = evbuffer_get_length(evbuf);
        ev_uint8_t *data;
        int count = 0, shift = 0, done = 0;
 
@@ -229,7 +229,7 @@ evtag_marshal_buffer(struct evbuffer *evbuf, ev_uint32_t tag,
     struct evbuffer *data)
 {
        evtag_encode_tag(evbuf, tag);
-       encode_int(evbuf, EVBUFFER_LENGTH(data));
+       encode_int(evbuf, evbuffer_get_length(data));
        evbuffer_add_buffer(evbuf, data);
 }
 
@@ -275,7 +275,7 @@ evtag_marshal_timeval(struct evbuffer *evbuf, ev_uint32_t tag, struct timeval *t
 #define DECODE_INT_INTERNAL(number, maxnibbles, pnumber, evbuf, offset) \
 do {                                                                   \
        ev_uint8_t *data;                                               \
-       int len = EVBUFFER_LENGTH(evbuf) - offset;                      \
+       int len = evbuffer_get_length(evbuf) - offset;                  \
        int nibbles = 0;                                                \
                                                                        \
        if (len <= 0)                                                   \
@@ -390,7 +390,7 @@ evtag_unmarshal_header(struct evbuffer *evbuf, ev_uint32_t *ptag)
        if (evtag_decode_int(&len, evbuf) == -1)
                return (-1);
 
-       if (EVBUFFER_LENGTH(evbuf) < len)
+       if (evbuffer_get_length(evbuf) < len)
                return (-1);
 
        return (len);
@@ -442,7 +442,7 @@ evtag_unmarshal_int(struct evbuffer *evbuf, ev_uint32_t need_tag,
        if (evtag_decode_int(&len, evbuf) == -1)
                return (-1);
 
-       if (EVBUFFER_LENGTH(evbuf) < len)
+       if (evbuffer_get_length(evbuf) < len)
                return (-1);
 
        result = decode_int_internal(pinteger, evbuf, 0);
@@ -468,7 +468,7 @@ evtag_unmarshal_int64(struct evbuffer *evbuf, ev_uint32_t need_tag,
        if (evtag_decode_int(&len, evbuf) == -1)
                return (-1);
 
-       if (EVBUFFER_LENGTH(evbuf) < len)
+       if (evbuffer_get_length(evbuf) < len)
                return (-1);
 
        result = decode_int64_internal(pinteger, evbuf, 0);
diff --git a/evrpc.c b/evrpc.c
index a925ffb44decfe6322f0926006146cdc0d84c9c3..c1d7ebf95960b2b506ba1ba0aa96fc1faa545609 100644 (file)
--- a/evrpc.c
+++ b/evrpc.c
@@ -282,7 +282,7 @@ evrpc_request_cb(struct evhttp_request *req, void *arg)
 
        /* let's verify the outside parameters */
        if (req->type != EVHTTP_REQ_POST ||
-           EVBUFFER_LENGTH(req->input_buffer) <= 0)
+           evbuffer_get_length(req->input_buffer) <= 0)
                goto error;
 
        rpc_state = mm_calloc(1, sizeof(struct evrpc_req_generic));
diff --git a/http.c b/http.c
index c3cb41891bd24c32866941896a39f437f07e6bab..18d7e4e29f96fec83db5e503498b81327194b2ec 100644 (file)
--- a/http.c
+++ b/http.c
@@ -412,7 +412,7 @@ evhttp_make_header_request(struct evhttp_connection *evcon,
            evhttp_find_header(req->output_headers, "Content-Length") == NULL){
                char size[12];
                evutil_snprintf(size, sizeof(size), "%ld",
-                   (long)EVBUFFER_LENGTH(req->output_buffer));
+                   (long)evbuffer_get_length(req->output_buffer));
                evhttp_add_header(req->output_headers, "Content-Length", size);
        }
 }
@@ -508,7 +508,7 @@ evhttp_make_header_response(struct evhttp_connection *evcon,
                         */
                        evhttp_maybe_add_content_length_header(
                                req->output_headers,
-                               (long)EVBUFFER_LENGTH(req->output_buffer));
+                               (long)evbuffer_get_length(req->output_buffer));
                }
        }
 
@@ -552,7 +552,7 @@ evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req)
        }
        evbuffer_add(output, "\r\n", 2);
 
-       if (EVBUFFER_LENGTH(req->output_buffer) > 0) {
+       if (evbuffer_get_length(req->output_buffer) > 0) {
                /*
                 * For a request, we add the POST data, for a reply, this
                 * is the regular data.
@@ -741,7 +741,7 @@ evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf)
 {
        int len;
 
-       while ((len = EVBUFFER_LENGTH(buf)) > 0) {
+       while ((len = evbuffer_get_length(buf)) > 0) {
                if (req->ntoread < 0) {
                        /* Read chunk size */
                        ev_int64_t ntoread;
@@ -783,7 +783,7 @@ evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf)
                        req->flags |= EVHTTP_REQ_DEFER_FREE;
                        (*req->chunk_cb)(req, req->cb_arg);
                        evbuffer_drain(req->input_buffer,
-                           EVBUFFER_LENGTH(req->input_buffer));
+                           evbuffer_get_length(req->input_buffer));
                        req->flags &= ~EVHTTP_REQ_DEFER_FREE;
                        if ((req->flags & EVHTTP_REQ_NEEDS_FREE) != 0) {
                                return (REQUEST_CANCELED);
@@ -843,19 +843,19 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
                /* Read until connection close. */
                evbuffer_add_buffer(req->input_buffer, buf);
        } else if (req->chunk_cb != NULL ||
-           EVBUFFER_LENGTH(buf) >= req->ntoread) {
+           evbuffer_get_length(buf) >= req->ntoread) {
                /* We've postponed moving the data until now, but we're
                 * about to use it. */
-               req->ntoread -= EVBUFFER_LENGTH(buf);
+               req->ntoread -= evbuffer_get_length(buf);
                evbuffer_add_buffer(req->input_buffer, buf);
        }
 
-       if (EVBUFFER_LENGTH(req->input_buffer) > 0 && req->chunk_cb != NULL) {
+       if (evbuffer_get_length(req->input_buffer) > 0 && req->chunk_cb != NULL) {
                req->flags |= EVHTTP_REQ_DEFER_FREE;
                (*req->chunk_cb)(req, req->cb_arg);
                req->flags &= ~EVHTTP_REQ_DEFER_FREE;
                evbuffer_drain(req->input_buffer,
-                   EVBUFFER_LENGTH(req->input_buffer));
+                   evbuffer_get_length(req->input_buffer));
                if ((req->flags & EVHTTP_REQ_NEEDS_FREE) != 0) {
                        evhttp_request_free(req);
                        return;
@@ -1032,9 +1032,9 @@ evhttp_connection_reset(struct evhttp_connection *evcon)
 
        /* we need to clean up any buffered data */
        tmp = bufferevent_get_output(evcon->bufev);
-       evbuffer_drain(tmp, EVBUFFER_LENGTH(tmp));
+       evbuffer_drain(tmp, evbuffer_get_length(tmp));
        tmp = bufferevent_get_input(evcon->bufev);
-       evbuffer_drain(tmp, EVBUFFER_LENGTH(tmp));
+       evbuffer_drain(tmp, evbuffer_get_length(tmp));
 
        evcon->state = EVCON_DISCONNECTED;
 }
@@ -1575,7 +1575,7 @@ evhttp_get_body_length(struct evhttp_request *req)
 
        event_debug(("%s: bytes to read: %d (in buffer %ld)\n",
                __func__, req->ntoread,
-               EVBUFFER_LENGTH(bufferevent_get_input(req->evcon->bufev))));
+               evbuffer_get_length(bufferevent_get_input(req->evcon->bufev))));
 
        return (0);
 }
@@ -2029,13 +2029,13 @@ void
 evhttp_send_reply_chunk(struct evhttp_request *req, struct evbuffer *databuf)
 {
        struct evbuffer *output = bufferevent_get_output(req->evcon->bufev);
-       if (EVBUFFER_LENGTH(databuf) == 0)
+       if (evbuffer_get_length(databuf) == 0)
                return;
        if (!evhttp_response_needs_body(req))
                return;
        if (req->chunked) {
                evbuffer_add_printf(output, "%x\r\n",
-                                   (unsigned)EVBUFFER_LENGTH(databuf));
+                                   (unsigned)evbuffer_get_length(databuf));
        }
        evbuffer_add_buffer(output, databuf);
        if (req->chunked) {
@@ -2054,7 +2054,7 @@ evhttp_send_reply_end(struct evhttp_request *req)
                evbuffer_add(output, "0\r\n\r\n", 5);
                evhttp_write_buffer(req->evcon, evhttp_send_done, NULL);
                req->chunked = 0;
-       } else if (EVBUFFER_LENGTH(output) == 0) {
+       } else if (evbuffer_get_length(output) == 0) {
                /* let the connection know that we are done with the request */
                evhttp_send_done(evcon, NULL);
        } else {
@@ -2132,7 +2132,7 @@ evhttp_encode_uri(const char *uri)
                }
        }
        evbuffer_add(buf, "", 1);
-       p = mm_strdup((char *)EVBUFFER_DATA(buf));
+       p = mm_strdup((char*)evbuffer_pullup(buf, -1));
        evbuffer_free(buf);
 
        return (p);
index 0256e568f98b5c4723cb750e465b9a4e3773743f..c624d6abd3e882b02821a8d802163de480a9500f 100644 (file)
@@ -559,11 +559,6 @@ int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size);
 */
 int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer* src);
 
-/** deprecated in favor of calling the functions directly */
-#define EVBUFFER_LENGTH(x)     evbuffer_get_length(x)
-/** deprecated in favor of calling the functions directly */
-#define EVBUFFER_DATA(x)       evbuffer_pullup(x, -1)
-
 /**
    Prevent calls that modify an evbuffer from succeeding. A buffer may
    frozen at the front, at the back, or at both the front and the back.
index 88a4599ccdb98d7065e8984ac4e88fe4b2b45a4f..4e400b0bfcdc5b0972a6cda2c5338c0d10e945d2 100644 (file)
@@ -76,5 +76,10 @@ void evbuffer_setcb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg);
  */
 unsigned char *evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len);
 
+/** deprecated in favor of calling the functions directly */
+#define EVBUFFER_LENGTH(x)     evbuffer_get_length(x)
+/** deprecated in favor of calling the functions directly */
+#define EVBUFFER_DATA(x)       evbuffer_pullup(x, -1)
+
 #endif
 
index de49131a4e43489b6482d29652932b7fe4c4f4a5..03b2a21e55b82c82da2cb863a79a292c7b9d78a7 100644 (file)
@@ -60,6 +60,7 @@
 #include "event2/event_compat.h"
 #include "event2/tag.h"
 #include "event2/buffer.h"
+#include "event2/buffer_compat.h"
 #include "event2/util.h"
 #include "event-internal.h"
 #include "log-internal.h"
index 076f024e5f2fc073e67c8d7cbd28000e9dbc0b85..071c134bf0536f2ca8efb4f10c8fae1635ccf47f 100644 (file)
@@ -115,7 +115,7 @@ test_evbuffer(void *ptr)
        evbuffer_add_printf(evb, "%s/%d", "hello", 1);
        evbuffer_validate(evb);
 
-       tt_assert(EVBUFFER_LENGTH(evb) == 7);
+       tt_assert(evbuffer_get_length(evb) == 7);
        tt_assert(!memcmp((char*)EVBUFFER_DATA(evb), "hello/1", 1));
 
        evbuffer_add_buffer(evb, evb_two);
@@ -123,7 +123,7 @@ test_evbuffer(void *ptr)
 
        evbuffer_drain(evb, strlen("hello/"));
        evbuffer_validate(evb);
-       tt_assert(EVBUFFER_LENGTH(evb) == 1);
+       tt_assert(evbuffer_get_length(evb) == 1);
        tt_assert(!memcmp((char*)EVBUFFER_DATA(evb), "1", 1));
 
        evbuffer_add_printf(evb_two, "%s", "/hello");
@@ -131,14 +131,14 @@ test_evbuffer(void *ptr)
        evbuffer_add_buffer(evb, evb_two);
        evbuffer_validate(evb);
 
-       tt_assert(EVBUFFER_LENGTH(evb_two) == 0);
-       tt_assert(EVBUFFER_LENGTH(evb) == 7);
+       tt_assert(evbuffer_get_length(evb_two) == 0);
+       tt_assert(evbuffer_get_length(evb) == 7);
        tt_assert(!memcmp((char*)EVBUFFER_DATA(evb), "1/hello", 7) != 0);
 
        memset(buffer, 0, sizeof(buffer));
        evbuffer_add(evb, buffer, sizeof(buffer));
        evbuffer_validate(evb);
-       tt_assert(EVBUFFER_LENGTH(evb) == 7 + 512);
+       tt_assert(evbuffer_get_length(evb) == 7 + 512);
 
        tmp = (char *)evbuffer_pullup(evb, 7 + 512);
        tt_assert(tmp);
@@ -168,14 +168,14 @@ test_evbuffer(void *ptr)
                evbuffer_validate(evb_two);
        }
 
-       tt_assert(EVBUFFER_LENGTH(evb_two) == 0);
-       tt_assert(EVBUFFER_LENGTH(evb) == i * sizeof(buffer));
+       tt_assert(evbuffer_get_length(evb_two) == 0);
+       tt_assert(evbuffer_get_length(evb) == i * sizeof(buffer));
 
        /* test remove buffer */
        sz_tmp = sizeof(buffer)*2.5;
        evbuffer_remove_buffer(evb, evb_two, sz_tmp);
-       tt_assert(EVBUFFER_LENGTH(evb_two) == sz_tmp);
-       tt_assert(EVBUFFER_LENGTH(evb) == sizeof(buffer) / 2);
+       tt_assert(evbuffer_get_length(evb_two) == sz_tmp);
+       tt_assert(evbuffer_get_length(evb) == sizeof(buffer) / 2);
        evbuffer_validate(evb);
 
        if (memcmp(evbuffer_pullup(
@@ -327,7 +327,7 @@ test_evbuffer_readln(void *ptr)
        cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_ANY);
        if (!cp || sz != 5 || memcmp(cp, "more\0\0", 6))
                tt_abort_msg("Not as expected");
-       tt_uint_op(EVBUFFER_LENGTH(evb), ==, 0);
+       tt_uint_op(evbuffer_get_length(evb), ==, 0);
        evbuffer_validate(evb);
        s = "\nno newline";
        evbuffer_add(evb, s, strlen(s));
@@ -340,8 +340,8 @@ test_evbuffer_readln(void *ptr)
        cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_ANY);
        tt_assert(!cp);
        evbuffer_validate(evb);
-       evbuffer_drain(evb, EVBUFFER_LENGTH(evb));
-       tt_assert(EVBUFFER_LENGTH(evb) == 0);
+       evbuffer_drain(evb, evbuffer_get_length(evb));
+       tt_assert(evbuffer_get_length(evb) == 0);
        evbuffer_validate(evb);
 
        /* Test EOL_CRLF */
@@ -398,7 +398,7 @@ test_evbuffer_readln(void *ptr)
        cp = evbuffer_readln(evb, &sz, EVBUFFER_EOL_CRLF_STRICT);
        tt_line_eq("More");
        free(cp);
-       tt_assert(EVBUFFER_LENGTH(evb) == 0);
+       tt_assert(evbuffer_get_length(evb) == 0);
        evbuffer_validate(evb);
 
        /* Test LF */
@@ -463,7 +463,7 @@ test_evbuffer_readln(void *ptr)
        tt_line_eq("More");
        free(cp); cp = NULL;
        evbuffer_validate(evb);
-       tt_assert(EVBUFFER_LENGTH(evb) == 0);
+       tt_assert(evbuffer_get_length(evb) == 0);
 
        test_ok = 1;
  end:
@@ -492,7 +492,7 @@ test_evbuffer_iterative(void *ptr)
                }
        }
 
-       tt_uint_op(sum, ==, EVBUFFER_LENGTH(buf));
+       tt_uint_op(sum, ==, evbuffer_get_length(buf));
 
  end:
        evbuffer_free(buf);
@@ -665,7 +665,7 @@ test_evbuffer_callbacks(void *ptr)
        evbuffer_cb_set_flags(buf, cb2, EVBUFFER_CB_ENABLED);
        evbuffer_add_reference(buf, "Goodbye", 7, NULL, NULL); /*31->38*/
        evbuffer_remove_cb_entry(buf, cb1);
-       evbuffer_drain(buf, EVBUFFER_LENGTH(buf)); /*38->0*/;
+       evbuffer_drain(buf, evbuffer_get_length(buf)); /*38->0*/;
        tt_assert(-1 == evbuffer_remove_cb(buf, log_change_callback, NULL));
        evbuffer_add(buf, "X", 1); /* 0->1 */
        tt_assert(!evbuffer_remove_cb(buf, log_change_callback, buf_out2));
@@ -674,22 +674,22 @@ test_evbuffer_callbacks(void *ptr)
                  "0->36; 36->26; 26->31; 31->38; ");
        tt_str_op(evbuffer_pullup(buf_out2, -1), ==,
                  "0->36; 31->38; 38->0; 0->1; ");
-       evbuffer_drain(buf_out1, EVBUFFER_LENGTH(buf_out1));
-       evbuffer_drain(buf_out2, EVBUFFER_LENGTH(buf_out2));
+       evbuffer_drain(buf_out1, evbuffer_get_length(buf_out1));
+       evbuffer_drain(buf_out2, evbuffer_get_length(buf_out2));
 
        /* Let's test the obsolete buffer_setcb function too. */
        cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1);
        cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2);
        evbuffer_setcb(buf, self_draining_callback, NULL);
        evbuffer_add_printf(buf, "This should get drained right away.");
-       tt_uint_op(EVBUFFER_LENGTH(buf), ==, 0);
-       tt_uint_op(EVBUFFER_LENGTH(buf_out1), ==, 0);
-       tt_uint_op(EVBUFFER_LENGTH(buf_out2), ==, 0);
+       tt_uint_op(evbuffer_get_length(buf), ==, 0);
+       tt_uint_op(evbuffer_get_length(buf_out1), ==, 0);
+       tt_uint_op(evbuffer_get_length(buf_out2), ==, 0);
        evbuffer_setcb(buf, NULL, NULL);
        evbuffer_add_printf(buf, "This will not.");
        tt_str_op(evbuffer_pullup(buf, -1), ==, "This will not.");
 
-       evbuffer_drain(buf, EVBUFFER_LENGTH(buf));
+       evbuffer_drain(buf, evbuffer_get_length(buf));
 
 #if 0
        /* Now let's try a suspended callback. */
@@ -703,7 +703,7 @@ test_evbuffer_callbacks(void *ptr)
        evbuffer_cb_unsuspend(buf,cb2);
        evbuffer_drain(buf, 4); /* 15->11 */
        evbuffer_cb_unsuspend(buf,cb1);
-       evbuffer_drain(buf, EVBUFFER_LENGTH(buf)); /* 11->0 */
+       evbuffer_drain(buf, evbuffer_get_length(buf)); /* 11->0 */
 
        tt_str_op(evbuffer_pullup(buf_out1, -1), ==,
                  "0->11; 11->11; 11->0; ");
index 53c29925c949a8a5df1130907581bacd96d77931..c8753b081220cf43d48fc2583c62a1c6feaf5681 100644 (file)
@@ -77,7 +77,7 @@
 static void
 readcb(struct bufferevent *bev, void *arg)
 {
-       if (EVBUFFER_LENGTH(bev->input) == 8333) {
+       if (evbuffer_get_length(bev->input) == 8333) {
                struct evbuffer *evbuf = evbuffer_new();
                assert(evbuf != NULL);
 
@@ -86,7 +86,7 @@ readcb(struct bufferevent *bev, void *arg)
 
                bufferevent_disable(bev, EV_READ);
 
-               if (EVBUFFER_LENGTH(evbuf) == 8333) {
+               if (evbuffer_get_length(evbuf) == 8333) {
                        test_ok++;
                 }
 
@@ -97,7 +97,7 @@ readcb(struct bufferevent *bev, void *arg)
 static void
 writecb(struct bufferevent *bev, void *arg)
 {
-       if (EVBUFFER_LENGTH(bev->output) == 0) {
+       if (evbuffer_get_length(bev->output) == 0) {
                test_ok++;
         }
 }
@@ -166,7 +166,7 @@ static void
 wm_readcb(struct bufferevent *bev, void *arg)
 {
        struct evbuffer *evbuf = evbuffer_new();
-       int len = EVBUFFER_LENGTH(bev->input);
+       int len = evbuffer_get_length(bev->input);
        static int nread;
 
        assert(len >= 10 && len <= 20);
@@ -188,9 +188,9 @@ wm_readcb(struct bufferevent *bev, void *arg)
 static void
 wm_writecb(struct bufferevent *bev, void *arg)
 {
-        assert(EVBUFFER_LENGTH(bev->output) <= 100);
-       if (EVBUFFER_LENGTH(bev->output) == 0) {
-                evbuffer_drain(bev->output, EVBUFFER_LENGTH(bev->output));
+        assert(evbuffer_get_length(bev->output) <= 100);
+       if (evbuffer_get_length(bev->output) == 0) {
+                evbuffer_drain(bev->output, evbuffer_get_length(bev->output));
                test_ok++;
         }
 }
@@ -273,12 +273,12 @@ bufferevent_input_filter(struct evbuffer *src, struct evbuffer *dst,
        const unsigned char *buffer;
        int i;
 
-       buffer = evbuffer_pullup(src, EVBUFFER_LENGTH(src));
-       for (i = 0; i < EVBUFFER_LENGTH(src); i += 2) {
+       buffer = evbuffer_pullup(src, evbuffer_get_length(src));
+       for (i = 0; i < evbuffer_get_length(src); i += 2) {
                assert(buffer[i] == 'x');
                evbuffer_add(dst, buffer + i + 1, 1);
 
-               if (i + 2 > EVBUFFER_LENGTH(src))
+               if (i + 2 > evbuffer_get_length(src))
                        break;
        }
 
@@ -295,13 +295,13 @@ bufferevent_output_filter(struct evbuffer *src, struct evbuffer *dst,
        const unsigned char *buffer;
        int i;
 
-       buffer = evbuffer_pullup(src, EVBUFFER_LENGTH(src));
-       for (i = 0; i < EVBUFFER_LENGTH(src); ++i) {
+       buffer = evbuffer_pullup(src, evbuffer_get_length(src));
+       for (i = 0; i < evbuffer_get_length(src); ++i) {
                evbuffer_add(dst, "x", 1);
                evbuffer_add(dst, buffer + i, 1);
        }
 
-       evbuffer_drain(src, EVBUFFER_LENGTH(src));
+       evbuffer_drain(src, evbuffer_get_length(src));
        return (BEV_OK);
 }
 
index 6dabfb2f37cf8c579fd4a1ac7d4e7296bb348bc9..6e6ce504945e00cea8c4a359d8b974c52d1e983b 100644 (file)
@@ -139,7 +139,7 @@ zlib_input_filter(struct evbuffer *src, struct evbuffer *dst,
                        assert(res == Z_OK || res == Z_STREAM_END);
                }
 
-       } while (EVBUFFER_LENGTH(src) > 0);
+       } while (evbuffer_get_length(src) > 0);
 
         ++infilter_calls;
 
@@ -184,7 +184,7 @@ zlib_output_filter(struct evbuffer *src, struct evbuffer *dst,
                        assert(res == Z_OK || res == Z_STREAM_END);
                }
 
-       } while (EVBUFFER_LENGTH(src) > 0);
+       } while (evbuffer_get_length(src) > 0);
 
        ++outfilter_calls;
 
@@ -198,7 +198,7 @@ zlib_output_filter(struct evbuffer *src, struct evbuffer *dst,
 static void
 readcb(struct bufferevent *bev, void *arg)
 {
-       if (EVBUFFER_LENGTH(bufferevent_get_input(bev)) == 8333) {
+       if (evbuffer_get_length(bufferevent_get_input(bev)) == 8333) {
                struct evbuffer *evbuf = evbuffer_new();
                assert(evbuf != NULL);
 
@@ -207,7 +207,7 @@ readcb(struct bufferevent *bev, void *arg)
 
                bufferevent_disable(bev, EV_READ);
 
-               if (EVBUFFER_LENGTH(evbuf) == 8333) {
+               if (evbuffer_get_length(evbuf) == 8333) {
                        ++readcb_finished;
                 }
 
@@ -218,7 +218,7 @@ readcb(struct bufferevent *bev, void *arg)
 static void
 writecb(struct bufferevent *bev, void *arg)
 {
-       if (EVBUFFER_LENGTH(bufferevent_get_output(bev)) == 0) {
+       if (evbuffer_get_length(bufferevent_get_output(bev)) == 0) {
                ++writecb_finished;
         }
 }