[or-cvs] [tor/master 09/40] Create buffers.h
nickm at torproject.org
nickm at torproject.org
Fri Jul 30 01:56:56 UTC 2010
Author: Sebastian Hahn <sebastian at torproject.org>
Date: Thu, 22 Jul 2010 00:46:18 +0200
Subject: Create buffers.h
Commit: 34dfce0d82b7660ccf80da8314ca664a44b24126
---
src/or/buffers.c | 1 +
src/or/buffers.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++
src/or/connection.c | 1 +
src/or/connection_edge.c | 1 +
src/or/connection_or.c | 1 +
src/or/control.c | 1 +
src/or/cpuworker.c | 1 +
src/or/directory.c | 1 +
src/or/dirserv.c | 1 +
src/or/main.c | 1 +
src/or/or.h | 45 -----------------------------------
src/or/relay.c | 1 +
src/test/test.c | 1 +
13 files changed, 70 insertions(+), 45 deletions(-)
create mode 100644 src/or/buffers.h
diff --git a/src/or/buffers.c b/src/or/buffers.c
index c4ebc81..807ca50 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -12,6 +12,7 @@
**/
#define BUFFERS_PRIVATE
#include "or.h"
+#include "buffers.h"
#include "../common/util.h"
#include "../common/torlog.h"
#ifdef HAVE_UNISTD_H
diff --git a/src/or/buffers.h b/src/or/buffers.h
new file mode 100644
index 0000000..42d92dd
--- /dev/null
+++ b/src/or/buffers.h
@@ -0,0 +1,59 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2010, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file buffers.h
+ * \brief Header file for buffers.c.
+ **/
+
+#ifndef _TOR_BUFFERS_H
+#define _TOR_BUFFERS_H
+
+buf_t *buf_new(void);
+buf_t *buf_new_with_capacity(size_t size);
+void buf_free(buf_t *buf);
+void buf_clear(buf_t *buf);
+void buf_shrink(buf_t *buf);
+void buf_shrink_freelists(int free_all);
+void buf_dump_freelist_sizes(int severity);
+
+size_t buf_datalen(const buf_t *buf);
+size_t buf_allocation(const buf_t *buf);
+size_t buf_slack(const buf_t *buf);
+const char *_buf_peek_raw_buffer(const buf_t *buf);
+
+int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof,
+ int *socket_error);
+int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf);
+
+int flush_buf(int s, buf_t *buf, size_t sz, size_t *buf_flushlen);
+int flush_buf_tls(tor_tls_t *tls, 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_zlib(buf_t *buf, tor_zlib_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);
+int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
+int fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto);
+int fetch_from_buf_http(buf_t *buf,
+ char **headers_out, size_t max_headerlen,
+ char **body_out, size_t *body_used, size_t max_bodylen,
+ int force_complete);
+int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
+ int log_sockstype, int safe_socks);
+int fetch_from_buf_socks_client(buf_t *buf, int state, char **reason);
+int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
+
+int peek_buf_has_control0_command(buf_t *buf);
+
+void assert_buf_ok(buf_t *buf);
+
+#ifdef BUFFERS_PRIVATE
+int buf_find_string_offset(const buf_t *buf, const char *s, size_t n);
+#endif
+
+#endif
+
diff --git a/src/or/connection.c b/src/or/connection.c
index e8b78ea..0f0d4e1 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -11,6 +11,7 @@
**/
#include "or.h"
+#include "buffers.h"
#include "dnsserv.h"
#include "geoip.h"
#include "rendclient.h"
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 44e366b..84752f1 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -10,6 +10,7 @@
**/
#include "or.h"
+#include "buffers.h"
#include "dnsserv.h"
#include "rendclient.h"
#include "rendcommon.h"
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index b1ed174..d7958cb 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -11,6 +11,7 @@
**/
#include "or.h"
+#include "buffers.h"
#include "geoip.h"
#include "router.h"
#include "routerlist.h"
diff --git a/src/or/control.c b/src/or/control.c
index b994513..1c61a08 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -11,6 +11,7 @@
#define CONTROL_PRIVATE
#include "or.h"
+#include "buffers.h"
#include "dnsserv.h"
#include "geoip.h"
#include "router.h"
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index b3514af..e5e4a3e 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -13,6 +13,7 @@
**/
#include "or.h"
+#include "buffers.h"
#include "router.h"
/** The maximum number of cpuworker processes we will keep around. */
diff --git a/src/or/directory.c b/src/or/directory.c
index d1bb78f..591377a 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -4,6 +4,7 @@
/* See LICENSE for licensing information */
#include "or.h"
+#include "buffers.h"
#include "geoip.h"
#include "rendclient.h"
#include "rendcommon.h"
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 59a8fdc..d24fca0 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -5,6 +5,7 @@
#define DIRSERV_PRIVATE
#include "or.h"
+#include "buffers.h"
#include "router.h"
#include "routerlist.h"
diff --git a/src/or/main.c b/src/or/main.c
index 4bd3b0a..f206a46 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -12,6 +12,7 @@
#define MAIN_PRIVATE
#include "or.h"
+#include "buffers.h"
#include "dnsserv.h"
#include "geoip.h"
#include "rendclient.h"
diff --git a/src/or/or.h b/src/or/or.h
index ef2a303..e3d6543 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2911,51 +2911,6 @@ struct socks_request_t {
/* all the function prototypes go here */
-/********************************* buffers.c ***************************/
-
-buf_t *buf_new(void);
-buf_t *buf_new_with_capacity(size_t size);
-void buf_free(buf_t *buf);
-void buf_clear(buf_t *buf);
-void buf_shrink(buf_t *buf);
-void buf_shrink_freelists(int free_all);
-void buf_dump_freelist_sizes(int severity);
-
-size_t buf_datalen(const buf_t *buf);
-size_t buf_allocation(const buf_t *buf);
-size_t buf_slack(const buf_t *buf);
-const char *_buf_peek_raw_buffer(const buf_t *buf);
-
-int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof,
- int *socket_error);
-int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf);
-
-int flush_buf(int s, buf_t *buf, size_t sz, size_t *buf_flushlen);
-int flush_buf_tls(tor_tls_t *tls, 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_zlib(buf_t *buf, tor_zlib_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);
-int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
-int fetch_var_cell_from_buf(buf_t *buf, var_cell_t **out, int linkproto);
-int fetch_from_buf_http(buf_t *buf,
- char **headers_out, size_t max_headerlen,
- char **body_out, size_t *body_used, size_t max_bodylen,
- int force_complete);
-int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
- int log_sockstype, int safe_socks);
-int fetch_from_buf_socks_client(buf_t *buf, int state, char **reason);
-int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
-
-int peek_buf_has_control0_command(buf_t *buf);
-
-void assert_buf_ok(buf_t *buf);
-
-#ifdef BUFFERS_PRIVATE
-int buf_find_string_offset(const buf_t *buf, const char *s, size_t n);
-#endif
-
/********************************* circuitbuild.c **********************/
/** How many hops does a general-purpose circuit have by default? */
diff --git a/src/or/relay.c b/src/or/relay.c
index 2b0a7d3..c7d6eda 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -12,6 +12,7 @@
#include <math.h>
#include "or.h"
+#include "buffers.h"
#include "geoip.h"
#include "mempool.h"
#include "rendcommon.h"
diff --git a/src/test/test.c b/src/test/test.c
index 6cf9ea0..baffd9e 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -43,6 +43,7 @@ long int lround(double x);
double fabs(double x);
#include "or.h"
+#include "buffers.c"
#include "geoip.h"
#include "rendcommon.h"
#include "test.h"
--
1.7.1
More information about the tor-commits
mailing list