patches on patches

svn:r1763
This commit is contained in:
Roger Dingledine 2004-05-02 03:15:55 +00:00
parent 138d744247
commit 25909c2c29
4 changed files with 3 additions and 46 deletions

View File

@ -115,17 +115,7 @@ static int find_mem_in_mem(const char *str, int str_len,
return -1; return -1;
} }
#if 0 /* Create and return a new buf with capacity 'size'.
/* Find the first occurence of the string_len byte string 'str' on the
* buffer 'buf'. If none exists, return -1. Otherwise, return index
* of the first character on the buffer _after_ the first instance of str.
*/
int find_on_inbuf(char *str, int string_len, buf_t *buf) {
return find_mem_in_mem(str, string_len, buf->mem, buf->datalen);
}
#endif
/* Create and return a new buf with capacity 'capacity'.
*/ */
buf_t *buf_new_with_capacity(size_t size) { buf_t *buf_new_with_capacity(size_t size) {
buf_t *buf; buf_t *buf;
@ -257,7 +247,7 @@ int read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf) {
/* Write data from 'buf' to the socket 's'. Write at most /* Write data from 'buf' to the socket 's'. Write at most
* *buf_flushlen bytes, and decrement *buf_flushlen by the number of * *buf_flushlen bytes, and decrement *buf_flushlen by the number of
* bytes actually written. Return the number of bytes written on * bytes actually written. Return the number of bytes written on
* success, -1 on failure. Returns 0 if write() would block. * success, -1 on failure. Return 0 if write() would block.
*/ */
int flush_buf(int s, buf_t *buf, int *buf_flushlen) int flush_buf(int s, buf_t *buf, int *buf_flushlen)
{ {
@ -338,7 +328,7 @@ int write_to_buf(const char *string, int string_len, buf_t *buf) {
/* Remove string_len bytes from the front of 'buf', and store them /* Remove string_len bytes from the front of 'buf', and store them
* into 'string'. Returns the new buffer size. string_len must be <= * into 'string'. Return the new buffer size. string_len must be <=
* the number of bytes on the buffer. * the number of bytes on the buffer.
*/ */
int fetch_from_buf(char *string, size_t string_len, buf_t *buf) { int fetch_from_buf(char *string, size_t string_len, buf_t *buf) {

View File

@ -655,12 +655,6 @@ int connection_fetch_from_buf(char *string, int len, connection_t *conn) {
return fetch_from_buf(string, len, conn->inbuf); return fetch_from_buf(string, len, conn->inbuf);
} }
/*
int connection_find_on_inbuf(char *string, int len, connection_t *conn) {
return find_on_inbuf(string, len, conn->inbuf);
}
*/
int connection_wants_to_flush(connection_t *conn) { int connection_wants_to_flush(connection_t *conn) {
return conn->outbuf_flushlen; return conn->outbuf_flushlen;
} }

View File

@ -646,8 +646,6 @@ struct socks_request_t {
/********************************* buffers.c ***************************/ /********************************* buffers.c ***************************/
/* int find_on_inbuf(char *string, int string_len, buf_t *buf); */
buf_t *buf_new(); buf_t *buf_new();
buf_t *buf_new_with_capacity(size_t size); buf_t *buf_new_with_capacity(size_t size);
void buf_free(buf_t *buf); void buf_free(buf_t *buf);
@ -802,7 +800,6 @@ int connection_handle_read(connection_t *conn);
int connection_read_to_buf(connection_t *conn); int connection_read_to_buf(connection_t *conn);
int connection_fetch_from_buf(char *string, int len, connection_t *conn); int connection_fetch_from_buf(char *string, int len, connection_t *conn);
/* int connection_find_on_inbuf(char *string, int len, connection_t *conn); */
int connection_wants_to_flush(connection_t *conn); int connection_wants_to_flush(connection_t *conn);
int connection_outbuf_too_full(connection_t *conn); int connection_outbuf_too_full(connection_t *conn);

View File

@ -136,30 +136,6 @@ test_buffers() {
close(s); close(s);
#if 0
/****
* find_on_inbuf
****/
buf_free(buf);
buf = buf_new();
s = open("/tmp/tor_test/data", O_RDONLY, 0);
eof = 0;
i = read_to_buf(s, 1024, buf, &eof);
test_eq(256, i);
close(s);
test_eq(((int)'d') + 1, find_on_inbuf("abcd", 4, buf));
test_eq(-1, find_on_inbuf("xyzzy", 5, buf));
/* Make sure we don't look off the end of the buffef */
((char*)_buf_peek_raw_buffer(buf))[256] = 'A';
((char*)_buf_peek_raw_buffer(buf))[257] = 'X';
test_eq(-1, find_on_inbuf("\xff" "A", 2, buf));
test_eq(-1, find_on_inbuf("AX", 2, buf));
/* Make sure we use the string length */
test_eq(((int)'d')+1, find_on_inbuf("abcdX", 4, buf));
#endif
/**** /****
* fetch_from_buf * fetch_from_buf
****/ ****/