summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-16 02:37:05 +0100
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-16 02:39:09 +0100
commit683a3541968681c3753954dd724db58b24a1db33 (patch)
tree9442214ce8485158936f47a831541549334b4554 /src
parent06c96761d56dca11f580ece1cca8ff2294c7f536 (diff)
remove vector remains
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/conf.h2
-rw-r--r--src/reqs.c2
-rw-r--r--src/vector.c214
-rw-r--r--src/vector.h77
5 files changed, 2 insertions, 294 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 4973eb7..51665f0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,6 @@ tinyproxy_SOURCES = \
text.c text.h \
main.c main.h \
utils.c utils.h \
- vector.c vector.h \
upstream.c upstream.h \
basicauth.c basicauth.h \
base64.c base64.h \
diff --git a/src/conf.h b/src/conf.h
index e0fbb51..d71208c 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -23,7 +23,7 @@
#define TINYPROXY_CONF_H
#include "hsearch.h"
-#include "vector.h"
+#include "sblist.h"
#include "acl.h"
/*
diff --git a/src/reqs.c b/src/reqs.c
index 5f26333..49f77b6 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -43,7 +43,7 @@
#include "stats.h"
#include "text.h"
#include "utils.h"
-#include "vector.h"
+#include "sblist.h"
#include "reverse-proxy.h"
#include "transparent-proxy.h"
#include "upstream.h"
diff --git a/src/vector.c b/src/vector.c
deleted file mode 100644
index cf9fc75..0000000
--- a/src/vector.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/* tinyproxy - A fast light-weight HTTP proxy
- * Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/* A vector implementation. The vector can be of an arbitrary length, and
- * the data for each entry is an lump of data (the size is stored in the
- * vector.)
- */
-
-#include "main.h"
-
-#include "heap.h"
-#include "vector.h"
-
-/*
- * These structures are the storage for the "vector". Entries are
- * stored in struct vectorentry_s (the data and the length), and the
- * "vector" structure is implemented as a linked-list. The struct
- * vector_s stores a pointer to the first vector (vector[0]) and a
- * count of the number of entries (or how long the vector is.)
- */
-struct vectorentry_s {
- void *data;
- size_t len;
-
- struct vectorentry_s *next;
-};
-
-struct vector_s {
- size_t num_entries;
- struct vectorentry_s *head;
- struct vectorentry_s *tail;
-};
-
-/*
- * Create an vector. The vector initially has no elements and no
- * storage has been allocated for the entries.
- *
- * A NULL is returned if memory could not be allocated for the
- * vector.
- */
-vector_t vector_create (void)
-{
- vector_t vector;
-
- vector = (vector_t) safemalloc (sizeof (struct vector_s));
- if (!vector)
- return NULL;
-
- vector->num_entries = 0;
- vector->head = vector->tail = NULL;
-
- return vector;
-}
-
-/*
- * Deletes an vector. All the entries when this function is run.
- *
- * Returns: 0 on success
- * negative if a NULL vector is supplied
- */
-int vector_delete (vector_t vector)
-{
- struct vectorentry_s *ptr, *next;
-
- if (!vector)
- return -EINVAL;
-
- ptr = vector->head;
- while (ptr) {
- next = ptr->next;
- safefree (ptr->data);
- safefree (ptr);
-
- ptr = next;
- }
-
- safefree (vector);
-
- return 0;
-}
-
-/*
- * Appends an entry into the vector. The entry is an arbitrary
- * collection of bytes of _len_ octets. The data is copied into the
- * vector, so the original data must be freed to avoid a memory leak.
- * The "data" must be non-NULL and the "len" must be greater than zero.
- * "pos" is either 0 to prepend the data, or 1 to append the data.
- *
- * Returns: 0 on success
- * negative number if there are errors
- */
-
-typedef enum {
- INSERT_PREPEND,
- INSERT_APPEND
-} vector_pos_t;
-
-static int
-vector_insert (vector_t vector,
- void *data,
- size_t len,
- vector_pos_t pos)
-{
- struct vectorentry_s *entry;
-
- if (!vector || !data || len <= 0 ||
- (pos != INSERT_PREPEND && pos != INSERT_APPEND))
- return -EINVAL;
-
- entry =
- (struct vectorentry_s *) safemalloc (sizeof (struct vectorentry_s));
- if (!entry)
- return -ENOMEM;
-
- entry->data = safemalloc (len);
- if (!entry->data) {
- safefree (entry);
- return -ENOMEM;
- }
-
- memcpy (entry->data, data, len);
- entry->len = len;
- entry->next = NULL;
-
- /* If there is no head or tail, create them */
- if (!vector->head && !vector->tail)
- vector->head = vector->tail = entry;
- else if (pos == INSERT_PREPEND) {
- /* prepend the entry */
- entry->next = vector->head;
- vector->head = entry;
- } else {
- /* append the entry */
- vector->tail->next = entry;
- vector->tail = entry;
- }
-
- vector->num_entries++;
-
- return 0;
-}
-
-/*
- * The following two function are used to make the API clearer. As you
- * can see they simply call the vector_insert() function with appropriate
- * arguments.
- */
-int vector_append (vector_t vector, void *data, size_t len)
-{
- return vector_insert (vector, data, len, INSERT_APPEND);
-}
-
-int vector_prepend (vector_t vector, void *data, size_t len)
-{
- return vector_insert (vector, data, len, INSERT_PREPEND);
-}
-
-/*
- * A pointer to the data at position "pos" (zero based) is returned.
- * If the vector is out of bound, data is set to NULL.
- *
- * Returns: negative upon an error
- * length of data if position is valid
- */
-void *vector_getentry (vector_t vector, size_t pos, size_t * size)
-{
- struct vectorentry_s *ptr;
- size_t loc;
-
- if (!vector || pos >= vector->num_entries)
- return NULL;
-
- loc = 0;
- ptr = vector->head;
-
- while (loc != pos) {
- ptr = ptr->next;
- loc++;
- }
-
- if (size)
- *size = ptr->len;
-
- return ptr->data;
-}
-
-/*
- * Returns the number of entries (or the length) of the vector.
- *
- * Returns: negative if vector is not valid
- * positive length of vector otherwise
- */
-ssize_t vector_length (vector_t vector)
-{
- if (!vector)
- return -EINVAL;
-
- return vector->num_entries;
-}
diff --git a/src/vector.h b/src/vector.h
deleted file mode 100644
index 45a78d4..0000000
--- a/src/vector.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* tinyproxy - A fast light-weight HTTP proxy
- * Copyright (C) 2002 Robert James Kaes <rjkaes@users.sourceforge.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/* See 'vector.c' for detailed information. */
-
-#ifndef _VECTOR_H
-#define _VECTOR_H
-
-#include <unistd.h>
-
-/*
- * We're using a typedef here to "hide" the implementation details of the
- * vector. Sure, it's a pointer, but the struct is hidden in the C file.
- * So, just use the vector_t like it's a cookie. :)
- */
-typedef struct vector_s *vector_t;
-
-/*
- * vector_create() takes no arguments.
- * vector_delete() is self explanatory.
- */
-extern vector_t vector_create (void);
-extern int vector_delete (vector_t vector);
-
-/*
- * When you insert a piece of data into the vector, the data will be
- * duplicated, so you must free your copy if it was created on the heap.
- * The data must be non-NULL and the length must be greater than zero.
- *
- * Returns: negative on error
- * 0 upon successful insert.
- */
-extern int vector_append (vector_t vector, void *data, size_t len);
-extern int vector_prepend (vector_t vector, void *data, size_t len);
-
-/*
- * A pointer to the data at position "pos" (zero based) is returned and the
- * size pointer contains the length of the data stored.
- *
- * The pointer points to the actual data in the vector, so you have
- * the power to modify the data, but do it responsibly since the
- * library doesn't take any steps to prevent you from messing up the
- * vector. (A better rule is, don't modify the data since you'll
- * likely mess up the "length" parameter of the data.) However, DON'T
- * try to realloc or free the data; doing so will break the vector.
- *
- * If "size" is NULL the size of the data is not returned.
- *
- * Returns: NULL on error
- * valid pointer to data
- */
-extern void *vector_getentry (vector_t vector, size_t pos, size_t * size);
-
-/*
- * Returns the number of enteries (or the length) of the vector.
- *
- * Returns: negative if vector is not valid
- * positive length of vector otherwise
- */
-extern ssize_t vector_length (vector_t vector);
-
-#endif /* _VECTOR_H */