summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-12-24 00:01:02 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-12-24 00:01:02 +0000
commit475e526a487c81a74f9eb6915de53db8d89261fa (patch)
treec005eb8a9af610ee22cb08d73301fee506c57fa4 /src
parent831b00dc7ac3f7bff82142ed4aab133e8681d049 (diff)
downloadtinyproxy-475e526a487c81a74f9eb6915de53db8d89261fa.tar.gz
tinyproxy-475e526a487c81a74f9eb6915de53db8d89261fa.zip
Moved write_message() into sock.c because I'm using it in other places.
Diffstat (limited to 'src')
-rw-r--r--src/reqs.c54
1 files changed, 1 insertions, 53 deletions
diff --git a/src/reqs.c b/src/reqs.c
index da7f72e..d9c7496 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.51 2001-12-23 21:55:08 rjkaes Exp $
+/* $Id: reqs.c,v 1.52 2001-12-24 00:01:02 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new thread created for them. The thread then
@@ -200,58 +200,6 @@ extract_ssl_url(const char *url, struct request_s *request)
}
/*
- * Send a "message" to the file descriptor provided. This handles the
- * differences between the various implementations of vsnprintf. This code
- * was basically stolen from the snprintf() man page of Debian Linux
- * (although I did fix a memory leak. :)
- */
-static int
-write_message(int fd, const char *fmt, ...)
-{
- ssize_t n;
- size_t size = (1024 * 2); /* start with 2 KB and go from there */
- char *buf, *tmpbuf;
- va_list ap;
-
- if ((buf = safemalloc(size)) == NULL)
- return -1;
-
- while (1) {
- va_start(ap, fmt);
- n = vsnprintf(buf, size, fmt, ap);
- va_end(ap);
-
- /* If that worked, break out so we can send the buffer */
- if (n > -1 && n < size)
- break;
-
- /* Else, try again with more space */
- if (n > -1)
- /* precisely what is needed (glibc2.1) */
- size = n + 1;
- else
- /* twice the old size (glibc2.0) */
- size *= 2;
-
- if ((tmpbuf = saferealloc(buf, size)) == NULL) {
- safefree(buf);
- return -1;
- } else
- buf = tmpbuf;
- }
-
- if (safe_write(fd, buf, n) < 0) {
- DEBUG2("Error in write_message(): %d", fd);
-
- safefree(buf);
- return -1;
- }
-
- safefree(buf);
- return 0;
-}
-
-/*
* Create a connection for HTTP connections.
*/
static int