struct _splay_node *right;
} splayNode;
-typedef int (*SPCMP)(const void *, splayNode *);
+typedef int SPCMP (const void *, splayNode *);
extern int splayLastResult;
-splayNode *splay_insert(void *, splayNode *, SPCMP);
-splayNode *splay_splay(const void *, splayNode *, SPCMP);
+splayNode *splay_insert(void *, splayNode *, SPCMP *);
+splayNode *splay_splay(const void *, splayNode *, SPCMP* );
void splay_destroy(splayNode *, void (*)(void *));
/*
* Do format conversion placing the output in buffer
*/
-static int
+static int
format_converter(register buffy * odp, const char *fmt,
va_list ap)
{
/*
* This is the general purpose conversion function.
*/
-static void
+static void
strx_printv(int *ccp, char *buf, size_t len, const char *format,
va_list ap)
{
#endif
#if !HAVE_SNPRINTF
-int
+int
snprintf(char *buf, size_t len, const char *format,...)
{
int cc;
#endif
#if !HAVE_VSNPRINTF
-int
+int
vsnprintf(char *buf, size_t len, const char *format,
va_list ap)
{
int splayLastResult = 0;
splayNode *
-splay_insert(void *data, splayNode * top, SPCMP compare)
+splay_insert(void *data, splayNode * top, SPCMP *compare)
{
splayNode *new = xcalloc(sizeof(splayNode), 1);
new->data = data;
}
splayNode *
-splay_splay(const void *data, splayNode * top, SPCMP compare)
+splay_splay(const void *data, splayNode * top, SPCMP *compare)
{
splayNode N;
splayNode *l;
+
/*
- * $Id: client.cc,v 1.38 1997/10/30 00:51:03 wessels Exp $
+ * $Id: client.cc,v 1.39 1997/10/30 03:31:19 wessels Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
/*
- * $Id: client_side.cc,v 1.136 1997/10/30 02:40:57 wessels Exp $
+ * $Id: client_side.cc,v 1.137 1997/10/30 03:31:19 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
err->src_addr = http->conn->peer.sin_addr;
err->redirect_url = xstrdup(redirectUrl);
errorSend(fd, err);
-
} else {
/* NOTE: don't use HTTP_UNAUTHORIZED because then the
* stupid browser wants us to authenticate */
/*
- * $Id: errorpage.cc,v 1.95 1997/10/30 02:40:58 wessels Exp $
+ * $Id: errorpage.cc,v 1.96 1997/10/30 03:31:20 wessels Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
*/
/*
- * Abstract: These routines are used to generate error messages to be
- * sent to clients. The error type is used to select between
- * the various message formats. (formats are stored in the
- * Config.errorDirectory)
+ * Abstract: These routines are used to generate error messages to be
+ * sent to clients. The error type is used to select between
+ * the various message formats. (formats are stored in the
+ * Config.errorDirectory)
*/
#include "squid.h"
* Arguments: err - This object is destroyed after use in this function.
*
* Abstract: This function generates a error page from the info contained
- * by 'err' and then attaches it to the specified 'entry'
- *
- * Note: The above abstract is should be check for correctness!!!!
+ * by 'err' and then stores the text in the specified store
+ * entry. This function should only be called by ``server
+ * side routines'' which need to communicate errors to the
+ * client side. The client side should call errorSend().
*/
void
errorAppendEntry(StoreEntry * entry, ErrorState * err)
MemObject *mem = entry->mem_obj;
int len;
assert(entry->store_status == STORE_PENDING);
+#if WE_SHOULD_PROBABLY_REQUIRE_THIS
+ assert(mem->inmem_hi == 0);
+#endif
buf = errorBuildBuf(err, &len);
storeAppend(entry, buf, len);
if (mem)
*
* Abstract: This function generates a error page from the info contained
* by 'err' and then sends it to the client.
- *
- * Note: The callback function errorSendComplete() cleans up 'err'
- *
- * Note: I don't think we need to add 'err' to the callback table
- * since the only path ends up a errorSendComplete().
+ * The callback function errorSendComplete() is called after
+ * the page has been written to the client socket (fd).
+ * errorSendComplete() deallocates 'err'. We need to add
+ * 'err' to the cbdata because comm_write() requires it
+ * for all callback data pointers.
*/
void
errorSend(int fd, ErrorState * err)
/*
* Function: errorSendComplete
*
- * Abstract: This function
+ * Abstract: Called by commHandleWrite() after data has been written
+ * to the client socket.
*
* Note: If there is a callback, the callback is responsible for
* closeing the FD, otherwise we do it ourseves.
/*
- * $Id: ftp.cc,v 1.159 1997/10/30 02:49:00 wessels Exp $
+ * $Id: ftp.cc,v 1.160 1997/10/30 03:31:21 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
err->xerrno = errno;
err->request = requestLink(ftpState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
ftpDataTransferDone(ftpState);
} else if (len == 0) {
} while (again);
}
-
static void
ftpBuildTitleUrl(FtpStateData * ftpState)
{
strcat(t, request->urlpath);
}
-
void
ftpStart(request_t * request, StoreEntry * entry)
{
url);
if (fd == COMM_ERROR) {
debug(9, 4) ("ftpStart: Failed to open a socket.\n");
-
err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
err->xerrno = errno;
err->request = requestLink(ftpState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
return;
}
debug(9, 3) ("ftpConnectDone, status = %d\n", status);
if (status == COMM_ERR_DNS) {
debug(9, 4) ("ftpConnectDone: Unknown host: %s\n", request->host);
-
err = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE);
err->dnsserver_msg = xstrdup(dns_error_message);
err->request = requestLink(request);
errorAppendEntry(ftpState->entry, err);
-
storeAbort(ftpState->entry, 0);
comm_close(fd);
} else if (status != COMM_OK) {
-
err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
err->xerrno = errno;
err->host = xstrdup(request->host);
err->port = request->port;
err->request = requestLink(request);
errorAppendEntry(ftpState->entry, err);
-
storeAbort(ftpState->entry, 0);
comm_close(fd);
} else {
/* ====================================================================== */
-
static void
ftpWriteCommand(const char *buf, FtpStateData * ftpState)
{
err->port = ftpState->data.port;
err->request = requestLink(request);
errorAppendEntry(ftpState->entry, err);
-
storeAbort(ftpState->entry, 0);
comm_close(fd);
return;
"<P>from this cache. Please check with the\n"
"<A HREF=\"mailto:%s\">cache administrator</A>\n"
"if you believe this is incorrect.\n"
-
"<P>\n"
"%s\n"
"<HR>\n"
"</ADDRESS></BODY></HTML>\n"
"\n";
-
static char *
ftpAuthRequired(const request_t * request, const char *realm)
{
/*
- * $Id: http.cc,v 1.207 1997/10/30 02:41:02 wessels Exp $
+ * $Id: http.cc,v 1.208 1997/10/30 03:31:22 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
httpRestart(httpState);
} else {
httpState->eof = 1;
-
err = errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE);
err->xerrno = errno;
err->request = requestLink(httpState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
comm_close(fd);
}
err->xerrno = errno;
err->request = requestLink(httpState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
comm_close(fd);
return;
entry->url);
if (fd < 0) {
debug(11, 4) ("httpSocketOpen: Failed because we're out of sockets.\n");
-
err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
err->xerrno = errno;
if (request)
err->request = requestLink(request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
}
return fd;
ErrorState *err;
if (status == COMM_ERR_DNS) {
debug(11, 4) ("httpConnectDone: Unknown host: %s\n", request->host);
-
err = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE);
err->dnsserver_msg = xstrdup(dns_error_message);
err->request = requestLink(request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
comm_close(fd);
} else if (status != COMM_OK) {
-
err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
err->xerrno = errno;
err->host = xstrdup(request->host);
err->port = request->port;
err->request = requestLink(request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
if (httpState->neighbor)
peerCheckConnectStart(httpState->neighbor);
+
/*
- * $Id: pconn.cc,v 1.8 1997/10/30 02:41:06 wessels Exp $
+ * $Id: pconn.cc,v 1.9 1997/10/30 03:31:24 wessels Exp $
*
* DEBUG: section 48 Persistent Connections
* AUTHOR: Duane Wessels
pconnPush(int fd, const char *host, u_short port)
{
struct _pconn *p;
- LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10); /* MO why static array? */
+ LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10);
assert(table != NULL);
strcpy(key, pconnKey(host, port));
p = (struct _pconn *) hash_lookup(table, key);
struct _pconn *p;
hash_link *hptr;
int fd = -1;
- LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10); /* MO why static array? */
+ LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10);
assert(table != NULL);
strcpy(key, pconnKey(host, port));
hptr = hash_lookup(table, key);
extern void pconnPush(int, const char *host, u_short port);
extern int pconnPop(const char *host, u_short port);
extern void pconnInit(void);
-
/*
- * $Id: ssl.cc,v 1.66 1997/10/30 02:41:08 wessels Exp $
+ * $Id: ssl.cc,v 1.67 1997/10/30 03:31:26 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
ErrorState *err = NULL;
if (status == COMM_ERR_DNS) {
debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host);
-
err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND);
err->request = requestLink(request);
err->dnsserver_msg = xstrdup(dns_error_message);
err->callback = sslErrorComplete;
err->callback_data = sslState;
errorSend(sslState->client.fd, err);
-
} else if (status != COMM_OK) {
err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
err->xerrno = errno;
err->callback = sslErrorComplete;
err->callback_data = sslState;
errorSend(sslState->client.fd, err);
-
} else {
if (sslState->proxying)
sslProxyConnected(sslState->server.fd, sslState);
- else
+ else
sslConnected(sslState->server.fd, sslState);
}
}
url);
if (sock == COMM_ERROR) {
debug(26, 4) ("sslStart: Failed because we're out of sockets.\n");
-
err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
err->xerrno = errno;
err->request = requestLink(request);
{
SslStateData *sslState = data;
ErrorState *err;
-
err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE);
err->request = requestLink(sslState->request);
err->callback = sslErrorComplete;
/*
- * $Id: tunnel.cc,v 1.66 1997/10/30 02:41:08 wessels Exp $
+ * $Id: tunnel.cc,v 1.67 1997/10/30 03:31:26 wessels Exp $
*
* DEBUG: section 26 Secure Sockets Layer Proxy
* AUTHOR: Duane Wessels
ErrorState *err = NULL;
if (status == COMM_ERR_DNS) {
debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host);
-
err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND);
err->request = requestLink(request);
err->dnsserver_msg = xstrdup(dns_error_message);
err->callback = sslErrorComplete;
err->callback_data = sslState;
errorSend(sslState->client.fd, err);
-
} else if (status != COMM_OK) {
err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
err->xerrno = errno;
err->callback = sslErrorComplete;
err->callback_data = sslState;
errorSend(sslState->client.fd, err);
-
} else {
if (sslState->proxying)
sslProxyConnected(sslState->server.fd, sslState);
- else
+ else
sslConnected(sslState->server.fd, sslState);
}
}
url);
if (sock == COMM_ERROR) {
debug(26, 4) ("sslStart: Failed because we're out of sockets.\n");
-
err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR);
err->xerrno = errno;
err->request = requestLink(request);
{
SslStateData *sslState = data;
ErrorState *err;
-
err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE);
err->request = requestLink(sslState->request);
err->callback = sslErrorComplete;
/*
- * $Id: wais.cc,v 1.93 1997/10/30 02:41:09 wessels Exp $
+ * $Id: wais.cc,v 1.94 1997/10/30 03:31:26 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
comm_close(fd);
}
-
-
/* This will be called when data is ready to be read from fd. Read until
* error or connection closed. */
static void
int bin;
if (protoAbortFetch(entry)) {
ErrorState *err;
-
err = errorCon(ERR_CLIENT_ABORT, HTTP_INTERNAL_SERVER_ERROR);
err->request = urlParse(METHOD_CONNECT, waisState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
comm_close(fd);
return;
err->xerrno = errno;
err->request = urlParse(METHOD_CONNECT, waisState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
comm_close(fd);
}
err->xerrno = errno;
err->request = urlParse(METHOD_CONNECT, waisState->request);
errorAppendEntry(entry, err);
-
storeAbort(entry, 0);
comm_close(fd);
} else if (len == 0) {
int len = strlen(waisState->request) + 4;
char *buf = NULL;
const char *Method = RequestMethodStr[waisState->method];
-
debug(24, 5) ("waisSendRequest: FD %d\n", fd);
-
if (Method)
len += strlen(Method);
if (waisState->request_hdr)
len += strlen(waisState->request_hdr);
-
buf = xcalloc(1, len + 1);
-
if (waisState->request_hdr)
snprintf(buf, len + 1, "%s %s %s\r\n", Method, waisState->request,
waisState->request_hdr);
else
snprintf(buf, len + 1, "%s %s\r\n", Method, waisState->request);
debug(24, 6) ("waisSendRequest: buf: %s\n", buf);
- comm_write(fd,
- buf,
- len,
- waisSendComplete,
- (void *) waisState,
- xfree);
+ comm_write(fd, buf, len, waisSendComplete, waisState, xfree);
if (BIT_TEST(waisState->entry->flag, ENTRY_CACHABLE))
storeSetPublicKey(waisState->entry); /* Make it public */
}