summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2003-07-31 23:38:28 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2003-07-31 23:38:28 +0000
commit6aaa863432967b99d0e2c87116b4ec844b90436f (patch)
tree40d8a50800514332aab7e469c351e4491cab6dfe /src
parentab02f47a297693752e1d68d5eaf914c77cfb652c (diff)
downloadtinyproxy-6aaa863432967b99d0e2c87116b4ec844b90436f.tar.gz
tinyproxy-6aaa863432967b99d0e2c87116b4ec844b90436f.zip
Added appropriate casts from (void*) so that the code will compile
cleanly with a C++ compiler. (Tested using GCC 3.3)
Diffstat (limited to 'src')
-rw-r--r--src/acl.c8
-rw-r--r--src/buffer.c8
-rw-r--r--src/conns.c4
-rw-r--r--src/filter.c18
-rw-r--r--src/hashmap.c10
-rw-r--r--src/http_message.c12
-rw-r--r--src/log.c8
-rw-r--r--src/network.c18
-rw-r--r--src/reqs.c27
-rw-r--r--src/stats.c6
-rw-r--r--src/vector.c6
11 files changed, 67 insertions, 58 deletions
diff --git a/src/acl.c b/src/acl.c
index 343ea61..d56ac65 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -1,4 +1,4 @@
-/* $Id: acl.c,v 1.16 2002-06-05 16:59:21 rjkaes Exp $
+/* $Id: acl.c,v 1.17 2003-07-31 23:38:28 rjkaes Exp $
*
* This system handles Access Control for use of this daemon. A list of
* domains, or IP addresses (including IP blocks) are stored in a list
@@ -24,9 +24,11 @@
#include "log.h"
#include "sock.h"
+enum acl_type { ACL_STRING, ACL_NUMERIC };
+
struct acl_s {
acl_access_t acl_access;
- enum { ACL_STRING, ACL_NUMERIC } type;
+ enum acl_type type;
char *location;
int netmask;
struct acl_s *next;
@@ -85,7 +87,7 @@ insert_acl(char *location, acl_access_t access_type)
rev_acl_ptr = &acl_ptr->next;
acl_ptr = acl_ptr->next;
}
- new_acl_ptr = safemalloc(sizeof(struct acl_s));
+ new_acl_ptr = (struct acl_s*)safemalloc(sizeof(struct acl_s));
if (!new_acl_ptr) {
return -1;
}
diff --git a/src/buffer.c b/src/buffer.c
index 1d48e0c..db805d1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1,4 +1,4 @@
-/* $Id: buffer.c,v 1.22 2002-05-24 04:45:32 rjkaes Exp $
+/* $Id: buffer.c,v 1.23 2003-07-31 23:38:28 rjkaes Exp $
*
* The buffer used in each connection is a linked list of lines. As the lines
* are read in and written out the buffer expands and contracts. Basically,
@@ -60,10 +60,10 @@ makenewline(unsigned char *data, size_t length)
assert(data != NULL);
assert(length > 0);
- if (!(newline = safemalloc(sizeof(struct bufline_s))))
+ if (!(newline = (struct bufline_s*)safemalloc(sizeof(struct bufline_s))))
return NULL;
- if (!(newline->string = safemalloc(length))) {
+ if (!(newline->string = (unsigned char*)safemalloc(length))) {
safefree(newline);
return NULL;
}
@@ -104,7 +104,7 @@ new_buffer(void)
{
struct buffer_s *buffptr;
- if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
+ if (!(buffptr = (struct buffer_s*)safemalloc(sizeof(struct buffer_s))))
return NULL;
/*
diff --git a/src/conns.c b/src/conns.c
index 1de8f40..f25e4f4 100644
--- a/src/conns.c
+++ b/src/conns.c
@@ -1,4 +1,4 @@
-/* $Id: conns.c,v 1.17 2003-05-31 23:02:21 rjkaes Exp $
+/* $Id: conns.c,v 1.18 2003-07-31 23:38:28 rjkaes Exp $
*
* Create and free the connection structure. One day there could be
* other connection related tasks put here, but for now the header
@@ -46,7 +46,7 @@ initialize_conn(int client_fd, const char* ipaddr, const char* string_addr)
/*
* Allocate the space for the conn_s structure itself.
*/
- connptr = safemalloc(sizeof(struct conn_s));
+ connptr = (struct conn_s*)safemalloc(sizeof(struct conn_s));
if (!connptr)
goto error_exit;
diff --git a/src/filter.c b/src/filter.c
index 585b344..8684992 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -1,4 +1,4 @@
-/* $Id: filter.c,v 1.16 2003-01-27 17:57:39 rjkaes Exp $
+/* $Id: filter.c,v 1.17 2003-07-31 23:38:28 rjkaes Exp $
*
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
* Copyright (c) 2002 James E. Flemer (jflemer@acm.jhu.edu)
@@ -67,14 +67,16 @@ filter_init(void)
s = buf;
if (!p) /* head of list */
fl = p =
- safecalloc(1,
- sizeof(struct
- filter_list));
+ (struct filter_list*)
+ safecalloc(1,
+ sizeof(struct
+ filter_list));
else { /* next entry */
p->next =
- safecalloc(1,
- sizeof(struct
- filter_list));
+ (struct filter_list*)
+ safecalloc(1,
+ sizeof(struct
+ filter_list));
p = p->next;
}
@@ -96,7 +98,7 @@ filter_init(void)
continue;
p->pat = safestrdup(s);
- p->cpat = safemalloc(sizeof(regex_t));
+ p->cpat = (regex_t*)safemalloc(sizeof(regex_t));
if ((err = regcomp(p->cpat, p->pat, cflags)) != 0) {
fprintf(stderr, "Bad regex in %s: %s\n",
config.filter, p->pat);
diff --git a/src/hashmap.c b/src/hashmap.c
index 4f7773d..1c32f8a 100644
--- a/src/hashmap.c
+++ b/src/hashmap.c
@@ -1,4 +1,4 @@
-/* $Id: hashmap.c,v 1.12 2003-05-31 23:02:21 rjkaes Exp $
+/* $Id: hashmap.c,v 1.13 2003-07-31 23:38:28 rjkaes Exp $
*
* A hashmap implementation. The keys are case-insensitive NULL terminated
* strings, and the data is arbitrary lumps of data. Copies of both the
@@ -97,12 +97,14 @@ hashmap_create(unsigned int nbuckets)
if (nbuckets == 0)
return NULL;
- ptr = safecalloc(1, sizeof(struct hashmap_s));
+ ptr = (struct hashmap_s*)safecalloc(1, sizeof(struct hashmap_s));
if (!ptr)
return NULL;
ptr->size = nbuckets;
- ptr->buckets = safecalloc(nbuckets, sizeof(struct hashentry_s *));
+ ptr->buckets =
+ (struct hashentry_s**)safecalloc(nbuckets,
+ sizeof(struct hashentry_s *));
if (!ptr->buckets) {
safefree(ptr);
return NULL;
@@ -223,7 +225,7 @@ hashmap_insert(hashmap_t map, const char *key,
data_copy = NULL;
}
- ptr = safemalloc(sizeof(struct hashentry_s));
+ ptr = (struct hashentry_s*)safemalloc(sizeof(struct hashentry_s));
if (!ptr) {
safefree(key_copy);
safefree(data_copy);
diff --git a/src/http_message.c b/src/http_message.c
index 31ab03e..25ad2b6 100644
--- a/src/http_message.c
+++ b/src/http_message.c
@@ -1,4 +1,4 @@
-/* $Id: http_message.c,v 1.2 2003-05-31 23:02:21 rjkaes Exp $
+/* $Id: http_message.c,v 1.3 2003-07-31 23:38:28 rjkaes Exp $
*
* See 'http_message.h' for a detailed description.
*
@@ -81,11 +81,11 @@ http_message_create(int response_code, const char* response_string)
http_message_t msg;
int ret;
- msg = safecalloc(1, sizeof(struct http_message_s));
+ msg = (http_message_t)safecalloc(1, sizeof(struct http_message_s));
if (msg == NULL)
return NULL;
- msg->headers.strings = safecalloc(NUMBER_OF_HEADERS, sizeof(char*));
+ msg->headers.strings = (char**)safecalloc(NUMBER_OF_HEADERS, sizeof(char*));
if (msg->headers.strings == NULL) {
safefree(msg);
return NULL;
@@ -182,8 +182,8 @@ http_message_add_headers(http_message_t msg, char** headers,
* available, reallocate the memory.
*/
if (msg->headers.used + num_headers > msg->headers.total) {
- new_headers = safecalloc(msg->headers.total * 2,
- sizeof(char*));
+ new_headers = (char**)safecalloc(msg->headers.total * 2,
+ sizeof(char*));
if (new_headers == NULL)
return -ENOMEM;
@@ -215,7 +215,7 @@ http_message_send(http_message_t msg, int fd)
{
char timebuf[30];
time_t global_time;
- int i;
+ unsigned int i;
assert(is_http_message_valid(msg));
diff --git a/src/log.c b/src/log.c
index bb0d79c..2676594 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,4 +1,4 @@
-/* $Id: log.c,v 1.26 2003-05-31 23:02:21 rjkaes Exp $
+/* $Id: log.c,v 1.27 2003-07-31 23:38:28 rjkaes Exp $
*
* Logs the various messages which tinyproxy produces to either a log file or
* the syslog daemon. Not much to it...
@@ -143,7 +143,7 @@ log_message(int level, char *fmt, ...)
vsnprintf(str, STRING_LENGTH, fmt, args);
- entry_buffer = safemalloc(strlen(str) + 6);
+ entry_buffer = (char*)safemalloc(strlen(str) + 6);
if (!entry_buffer)
return;
@@ -202,12 +202,12 @@ send_stored_logs(void)
int i;
for (i = 0; i != vector_length(log_message_storage); ++i) {
- string = vector_getentry(log_message_storage, i, NULL);
+ string = (char*)vector_getentry(log_message_storage, i, NULL);
ptr = strchr(string, ' ') + 1;
level = atoi(string);
-#if NDEBUG
+#ifdef NDEBUG
if (log_level == LOG_CONN && level == LOG_INFO)
continue;
else if (log_level == LOG_INFO) {
diff --git a/src/network.c b/src/network.c
index db3000c..a66857d 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1,4 +1,4 @@
-/* $Id: network.c,v 1.1 2002-05-23 04:41:48 rjkaes Exp $
+/* $Id: network.c,v 1.2 2003-07-31 23:38:28 rjkaes Exp $
*
* The functions found here are used for communicating across a
* network. They include both safe reading and writing (which are
@@ -90,7 +90,7 @@ write_message(int fd, const char *fmt, ...)
char *buf, *tmpbuf;
va_list ap;
- if ((buf = safemalloc(size)) == NULL)
+ if ((buf = (char*)safemalloc(size)) == NULL)
return -1;
while (1) {
@@ -110,7 +110,7 @@ write_message(int fd, const char *fmt, ...)
/* twice the old size (glibc2.0) */
size *= 2;
- if ((tmpbuf = saferealloc(buf, size)) == NULL) {
+ if ((tmpbuf = (char*)saferealloc(buf, size)) == NULL) {
safefree(buf);
return -1;
} else
@@ -154,7 +154,8 @@ readline(int fd, char **whole_buffer)
};
struct read_lines_s *first_line, *line_ptr;
- first_line = safecalloc(sizeof(struct read_lines_s), 1);
+ first_line =
+ (struct read_lines_s*)safecalloc(sizeof(struct read_lines_s), 1);
if (!first_line)
return -ENOMEM;
@@ -166,7 +167,7 @@ readline(int fd, char **whole_buffer)
if (ret <= 0)
goto CLEANUP;
- ptr = memchr(buffer, '\n', ret);
+ ptr = (char*)memchr(buffer, '\n', ret);
if (ptr)
diff = ptr - buffer + 1;
else
@@ -183,7 +184,7 @@ readline(int fd, char **whole_buffer)
goto CLEANUP;
}
- line_ptr->data = safemalloc(diff);
+ line_ptr->data = (char*)safemalloc(diff);
if (!line_ptr->data) {
ret = -ENOMEM;
goto CLEANUP;
@@ -197,7 +198,8 @@ readline(int fd, char **whole_buffer)
break;
}
- line_ptr->next = safecalloc(sizeof(struct read_lines_s), 1);
+ line_ptr->next =
+ (struct read_lines_s*)safecalloc(sizeof(struct read_lines_s), 1);
if (!line_ptr->next) {
ret = -ENOMEM;
goto CLEANUP;
@@ -205,7 +207,7 @@ readline(int fd, char **whole_buffer)
line_ptr = line_ptr->next;
}
- *whole_buffer = safemalloc(whole_buffer_len + 1);
+ *whole_buffer = (char*)safemalloc(whole_buffer_len + 1);
if (!*whole_buffer) {
ret = -ENOMEM;
goto CLEANUP;
diff --git a/src/reqs.c b/src/reqs.c
index 9a44336..b2a98de 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.105 2003-06-26 18:19:57 rjkaes Exp $
+/* $Id: reqs.c,v 1.106 2003-07-31 23:38:28 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new child created for them. The child then
@@ -128,7 +128,7 @@ check_allowed_connect_ports(int port)
return 1;
for (i = 0; i != vector_length(ports_allowed_by_connect); ++i) {
- data = vector_getentry(ports_allowed_by_connect, i, NULL);
+ data = (int*)vector_getentry(ports_allowed_by_connect, i, NULL);
if (!data)
return -1;
@@ -225,8 +225,8 @@ strip_username_password(char* host)
static int
extract_http_url(const char *url, struct request_s *request)
{
- request->host = safemalloc(strlen(url) + 1);
- request->path = safemalloc(strlen(url) + 1);
+ request->host = (char*)safemalloc(strlen(url) + 1);
+ request->path = (char*)safemalloc(strlen(url) + 1);
if (!request->host || !request->path)
goto ERROR_EXIT;
@@ -267,7 +267,7 @@ extract_http_url(const char *url, struct request_s *request)
static int
extract_ssl_url(const char *url, struct request_s *request)
{
- request->host = safemalloc(strlen(url) + 1);
+ request->host = (char*)safemalloc(strlen(url) + 1);
if (!request->host)
return -1;
@@ -318,7 +318,8 @@ void
upstream_add(const char *host, int port, const char *domain)
{
char *ptr;
- struct upstream *up = safemalloc(sizeof (struct upstream));
+ struct upstream *up =
+ (struct upstream*)safemalloc(sizeof (struct upstream));
if (!up) {
log_message(LOG_ERR, "Unable to allocate memory in upstream_add()");
@@ -522,15 +523,15 @@ process_request(struct conn_s *connptr, hashmap_t hashofheaders)
size_t request_len;
/* NULL out all the fields so frees don't cause segfaults. */
- request = safecalloc(1, sizeof(struct request_s));
+ request = (struct request_s*)safecalloc(1, sizeof(struct request_s));
if (!request)
return NULL;
request_len = strlen(connptr->request_line) + 1;
- request->method = safemalloc(request_len);
- url = safemalloc(request_len);
- request->protocol = safemalloc(request_len);
+ request->method = (char*)safemalloc(request_len);
+ url = (char*)safemalloc(request_len);
+ request->protocol = (char*)safemalloc(request_len);
if (!request->method || !url || !request->protocol) {
safefree(url);
@@ -775,7 +776,7 @@ pull_client_data(struct conn_s *connptr, long int length)
char *buffer;
ssize_t len;
- buffer = safemalloc(min(MAXBUFFSIZE, length));
+ buffer = (char*)safemalloc(min(MAXBUFFSIZE, length));
if (!buffer)
return -1;
@@ -1443,7 +1444,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
if (connptr->connect_method) {
len = strlen(request->host) + 7;
- combined_string = safemalloc(len);
+ combined_string = (char*)safemalloc(len);
if (!combined_string) {
return -1;
}
@@ -1452,7 +1453,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
request->port);
} else {
len = strlen(request->host) + strlen(request->path) + 14;
- combined_string = safemalloc(len);
+ combined_string = (char*)safemalloc(len);
if (!combined_string) {
return -1;
}
diff --git a/src/stats.c b/src/stats.c
index ea0b629..88d9d0d 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1,4 +1,4 @@
-/* $Id: stats.c,v 1.13 2003-03-13 21:31:03 rjkaes Exp $
+/* $Id: stats.c,v 1.14 2003-07-31 23:38:28 rjkaes Exp $
*
* This module handles the statistics for tinyproxy. There are only two
* public API functions. The reason for the functions, rather than just a
@@ -45,7 +45,7 @@ static struct stat_s *stats;
void
init_stats(void)
{
- stats = malloc_shared_memory(sizeof(struct stat_s));
+ stats = (struct stat_s*)malloc_shared_memory(sizeof(struct stat_s));
if (stats == MAP_FAILED)
return;
@@ -81,7 +81,7 @@ showstats(struct conn_s *connptr)
snprintf(refused, sizeof(refused), "%lu", stats->num_refused);
if (!config.statpage || (!(statfile = fopen(config.statpage, "r")))) {
- message_buffer = safemalloc(MAXBUFFSIZE);
+ message_buffer = (char*)safemalloc(MAXBUFFSIZE);
if (!message_buffer)
return -1;
diff --git a/src/vector.c b/src/vector.c
index e90a3f2..fc3d4e9 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -1,4 +1,4 @@
-/* $Id: vector.c,v 1.9 2003-05-30 16:21:48 rjkaes Exp $
+/* $Id: vector.c,v 1.10 2003-07-31 23:38:28 rjkaes Exp $
*
* 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
@@ -58,7 +58,7 @@ vector_create(void)
{
vector_t vector;
- vector = safemalloc(sizeof(struct vector_s));
+ vector = (vector_t)safemalloc(sizeof(struct vector_s));
if (!vector)
return NULL;
@@ -118,7 +118,7 @@ vector_insert(vector_t vector, void *data, ssize_t len, int pos)
(pos != INSERT_PREPEND && pos != INSERT_APPEND))
return -EINVAL;
- entry = safemalloc(sizeof(struct vectorentry_s));
+ entry = (struct vectorentry_s*)safemalloc(sizeof(struct vectorentry_s));
if (!entry)
return -ENOMEM;