diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-08-08 15:16:39 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-05 13:57:51 -0400 |
commit | 4a7e90adc5828263a5d2dc3744818f2189c04bc7 (patch) | |
tree | 62cac4a9acefb41d9e3b9b6ee7d6501ee64efc01 /src/test/test_extorport.c | |
parent | 336aa21e37b6c5bd4f1215ceba27c21f6c43dce7 (diff) | |
download | tor-4a7e90adc5828263a5d2dc3744818f2189c04bc7.tar.gz tor-4a7e90adc5828263a5d2dc3744818f2189c04bc7.zip |
Repair buffer API so everything starts with buf_.
Our convention is that functions which manipulate a type T should be
named T_foo. But the buffer functions were super old, and followed
all kinds of conventions. Now they're uniform.
Here's the perl I used to do this:
\#!/usr/bin/perl -w -i -p
s/read_to_buf\(/buf_read_from_socket\(/;
s/flush_buf\(/buf_flush_to_socket\(/;
s/read_to_buf_tls\(/buf_read_from_tls\(/;
s/flush_buf_tls\(/buf_flush_to_tls\(/;
s/write_to_buf\(/buf_add\(/;
s/write_to_buf_compress\(/buf_add_compress\(/;
s/move_buf_to_buf\(/buf_move_to_buf\(/;
s/peek_from_buf\(/buf_peek\(/;
s/fetch_from_buf\(/buf_get_bytes\(/;
s/fetch_from_buf_line\(/buf_get_line\(/;
s/fetch_from_buf_line\(/buf_get_line\(/;
s/buf_remove_from_front\(/buf_drain\(/;
s/peek_buf_startswith\(/buf_peek_startswith\(/;
s/assert_buf_ok\(/buf_assert_ok\(/;
Diffstat (limited to 'src/test/test_extorport.c')
-rw-r--r-- | src/test/test_extorport.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/test_extorport.c b/src/test/test_extorport.c index fc9f27a5ac..f8ee94c3ac 100644 --- a/src/test/test_extorport.c +++ b/src/test/test_extorport.c @@ -78,7 +78,7 @@ connection_write_to_buf_impl_replacement(const char *string, size_t len, tor_assert(string); tor_assert(conn); - write_to_buf(string, len, conn->outbuf); + buf_add(string, len, conn->outbuf); } static char * @@ -89,7 +89,7 @@ buf_get_contents(buf_t *buf, size_t *sz_out) if (*sz_out >= ULONG_MAX) return NULL; /* C'mon, really? */ out = tor_malloc(*sz_out + 1); - if (fetch_from_buf(out, (unsigned long)*sz_out, buf) != 0) { + if (buf_get_bytes(out, (unsigned long)*sz_out, buf) != 0) { tor_free(out); return NULL; } @@ -399,14 +399,14 @@ handshake_start(or_connection_t *conn, int receiving) #define WRITE(s,n) \ do { \ - write_to_buf((s), (n), TO_CONN(conn)->inbuf); \ + buf_add((s), (n), TO_CONN(conn)->inbuf); \ } while (0) #define CONTAINS(s,n) \ do { \ tt_int_op((n), OP_LE, sizeof(b)); \ tt_int_op(buf_datalen(TO_CONN(conn)->outbuf), OP_EQ, (n)); \ if ((n)) { \ - fetch_from_buf(b, (n), TO_CONN(conn)->outbuf); \ + buf_get_bytes(b, (n), TO_CONN(conn)->outbuf); \ tt_mem_op(b, OP_EQ, (s), (n)); \ } \ } while (0) |