aboutsummaryrefslogtreecommitdiff
path: root/src/common/buffers.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-08-08 15:16:39 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-05 13:57:51 -0400
commit4a7e90adc5828263a5d2dc3744818f2189c04bc7 (patch)
tree62cac4a9acefb41d9e3b9b6ee7d6501ee64efc01 /src/common/buffers.h
parent336aa21e37b6c5bd4f1215ceba27c21f6c43dce7 (diff)
downloadtor-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/common/buffers.h')
-rw-r--r--src/common/buffers.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/common/buffers.h b/src/common/buffers.h
index 77cc9ce0fb..73a688cff9 100644
--- a/src/common/buffers.h
+++ b/src/common/buffers.h
@@ -35,27 +35,27 @@ size_t buf_slack(const buf_t *buf);
uint32_t buf_get_oldest_chunk_timestamp(const buf_t *buf, uint32_t now);
size_t buf_get_total_allocation(void);
-int read_to_buf(tor_socket_t s, size_t at_most, buf_t *buf, int *reached_eof,
+int buf_read_from_socket(tor_socket_t s, size_t at_most, buf_t *buf, int *reached_eof,
int *socket_error);
-int flush_buf(tor_socket_t s, buf_t *buf, size_t sz, size_t *buf_flushlen);
+int buf_flush_to_socket(tor_socket_t s, buf_t *buf, size_t sz, size_t *buf_flushlen);
-int write_to_buf(const char *string, size_t string_len, buf_t *buf);
-int write_to_buf_compress(buf_t *buf, struct tor_compress_state_t *state,
+int buf_add(const char *string, size_t string_len, buf_t *buf);
+int buf_add_compress(buf_t *buf, struct tor_compress_state_t *state,
const char *data, size_t data_len, int done);
-int move_buf_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen);
-void peek_from_buf(char *string, size_t string_len, const buf_t *buf);
-void buf_remove_from_front(buf_t *buf, size_t n);
-int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
-int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
+int buf_move_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen);
+void buf_peek(char *string, size_t string_len, const buf_t *buf);
+void buf_drain(buf_t *buf, size_t n);
+int buf_get_bytes(char *string, size_t string_len, buf_t *buf);
+int buf_get_line(buf_t *buf, char *data_out, size_t *data_len);
#define PEEK_BUF_STARTSWITH_MAX 16
-int peek_buf_startswith(const buf_t *buf, const char *cmd);
+int buf_peek_startswith(const buf_t *buf, const char *cmd);
int buf_set_to_copy(buf_t **output,
const buf_t *input);
-void assert_buf_ok(buf_t *buf);
+void buf_assert_ok(buf_t *buf);
int buf_find_string_offset(const buf_t *buf, const char *s, size_t n);
void buf_pullup(buf_t *buf, size_t bytes,