From 4e3f29ebcad2966064d8161ec84628d71b7ea1de Mon Sep 17 00:00:00 2001 From: wessels <> Date: Thu, 30 Oct 1997 10:31:17 +0000 Subject: [PATCH] gindent and formatting --- include/splay.h | 6 +++--- lib/snprintf.c | 8 ++++---- lib/splay.c | 4 ++-- src/client.cc | 3 ++- src/client_side.cc | 3 +-- src/errorpage.cc | 33 +++++++++++++++++++-------------- src/ftp.cc | 15 +-------------- src/http.cc | 11 +---------- src/pconn.cc | 7 ++++--- src/protos.h | 1 - src/ssl.cc | 9 ++------- src/tunnel.cc | 9 ++------- src/wais.cc | 19 ++----------------- 13 files changed, 43 insertions(+), 85 deletions(-) diff --git a/include/splay.h b/include/splay.h index d2ae8d58e8..f1d22fa2d1 100644 --- a/include/splay.h +++ b/include/splay.h @@ -5,10 +5,10 @@ typedef struct _splay_node { 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 *)); diff --git a/lib/snprintf.c b/lib/snprintf.c index 48d8953ecb..75bbbd1629 100644 --- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -512,7 +512,7 @@ conv_p2(register u_wide_int num, register int nbits, /* * Do format conversion placing the output in buffer */ -static int +static int format_converter(register buffy * odp, const char *fmt, va_list ap) { @@ -879,7 +879,7 @@ format_converter(register buffy * odp, const char *fmt, /* * 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) { @@ -906,7 +906,7 @@ strx_printv(int *ccp, char *buf, size_t len, const char *format, #endif #if !HAVE_SNPRINTF -int +int snprintf(char *buf, size_t len, const char *format,...) { int cc; @@ -919,7 +919,7 @@ snprintf(char *buf, size_t len, const char *format,...) #endif #if !HAVE_VSNPRINTF -int +int vsnprintf(char *buf, size_t len, const char *format, va_list ap) { diff --git a/lib/splay.c b/lib/splay.c index 400925010d..72b439950a 100644 --- a/lib/splay.c +++ b/lib/splay.c @@ -17,7 +17,7 @@ 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; @@ -44,7 +44,7 @@ splay_insert(void *data, splayNode * top, SPCMP compare) } splayNode * -splay_splay(const void *data, splayNode * top, SPCMP compare) +splay_splay(const void *data, splayNode * top, SPCMP *compare) { splayNode N; splayNode *l; diff --git a/src/client.cc b/src/client.cc index d5d98d7dfc..0d3f09fde5 100644 --- a/src/client.cc +++ b/src/client.cc @@ -1,7 +1,8 @@ + /* - * $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 diff --git a/src/client_side.cc b/src/client_side.cc index c9f142660e..ebefcb099b 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -100,7 +100,6 @@ clientAccessCheckDone(int answer, void *data) 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 */ diff --git a/src/errorpage.cc b/src/errorpage.cc index e0135532f1..3df4a9ef02 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -30,10 +30,10 @@ */ /* - * 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" @@ -123,9 +123,10 @@ errorCon(err_type type, http_status status) * 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) @@ -134,6 +135,9 @@ 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) @@ -149,11 +153,11 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err) * * 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) @@ -170,7 +174,8 @@ 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. diff --git a/src/ftp.cc b/src/ftp.cc index f188af1f05..623308a973 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -662,7 +662,6 @@ ftpReadData(int fd, void *data) err->xerrno = errno; err->request = requestLink(ftpState->request); errorAppendEntry(entry, err); - storeAbort(entry, 0); ftpDataTransferDone(ftpState); } else if (len == 0) { @@ -795,7 +794,6 @@ ftpCleanupUrlpath(FtpStateData * ftpState) } while (again); } - static void ftpBuildTitleUrl(FtpStateData * ftpState) { @@ -821,7 +819,6 @@ ftpBuildTitleUrl(FtpStateData * ftpState) strcat(t, request->urlpath); } - void ftpStart(request_t * request, StoreEntry * entry) { @@ -868,12 +865,10 @@ 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; } @@ -897,23 +892,19 @@ ftpConnectDone(int fd, int status, void *data) 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 { @@ -931,7 +922,6 @@ ftpConnectDone(int fd, int status, void *data) /* ====================================================================== */ - static void ftpWriteCommand(const char *buf, FtpStateData * ftpState) { @@ -1357,7 +1347,6 @@ ftpPasvCallback(int fd, int status, void *data) err->port = ftpState->data.port; err->request = requestLink(request); errorAppendEntry(ftpState->entry, err); - storeAbort(ftpState->entry, 0); comm_close(fd); return; @@ -1584,7 +1573,6 @@ const char *ftpAuthText = "

from this cache. Please check with the\n" "cache administrator\n" "if you believe this is incorrect.\n" - "

\n" "%s\n" "


\n" @@ -1593,7 +1581,6 @@ const char *ftpAuthText = "\n" "\n"; - static char * ftpAuthRequired(const request_t * request, const char *realm) { diff --git a/src/http.cc b/src/http.cc index 0a18403bac..787b77bc0f 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -632,12 +632,10 @@ httpReadReply(int fd, void *data) 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); } @@ -685,7 +683,6 @@ httpSendComplete(int fd, char *buf, int size, int errflag, void *data) err->xerrno = errno; err->request = requestLink(httpState->request); errorAppendEntry(entry, err); - storeAbort(entry, 0); comm_close(fd); return; @@ -930,13 +927,11 @@ httpSocketOpen(StoreEntry * entry, request_t * request) 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; @@ -1050,23 +1045,19 @@ httpConnectDone(int fd, int status, void *data) 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); diff --git a/src/pconn.cc b/src/pconn.cc index 4e1a5de55d..ef42627c20 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,5 +1,6 @@ + /* - * $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 @@ -130,7 +131,7 @@ void 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); @@ -155,7 +156,7 @@ pconnPop(const char *host, u_short port) 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); diff --git a/src/protos.h b/src/protos.h index 94933c6bbf..96bbf7458a 100644 --- a/src/protos.h +++ b/src/protos.h @@ -561,4 +561,3 @@ extern void dump_peers(StoreEntry *, peer *); extern void pconnPush(int, const char *host, u_short port); extern int pconnPop(const char *host, u_short port); extern void pconnInit(void); - diff --git a/src/ssl.cc b/src/ssl.cc index 522cecd4d2..ee9046f216 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -321,14 +321,12 @@ sslConnectDone(int fd, int status, void *data) 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; @@ -338,11 +336,10 @@ sslConnectDone(int fd, int status, void *data) 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); } } @@ -365,7 +362,6 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr) 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); @@ -455,7 +451,6 @@ sslPeerSelectFail(peer * p, void *data) { SslStateData *sslState = data; ErrorState *err; - err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE); err->request = requestLink(sslState->request); err->callback = sslErrorComplete; diff --git a/src/tunnel.cc b/src/tunnel.cc index c2d667a84a..1a796c578e 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -321,14 +321,12 @@ sslConnectDone(int fd, int status, void *data) 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; @@ -338,11 +336,10 @@ sslConnectDone(int fd, int status, void *data) 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); } } @@ -365,7 +362,6 @@ sslStart(int fd, const char *url, request_t * request, size_t * size_ptr) 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); @@ -455,7 +451,6 @@ sslPeerSelectFail(peer * p, void *data) { SslStateData *sslState = data; ErrorState *err; - err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE); err->request = requestLink(sslState->request); err->callback = sslErrorComplete; diff --git a/src/wais.cc b/src/wais.cc index 0b9cd903b6..51351a9e06 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -150,8 +150,6 @@ waisTimeout(int fd, void *data) comm_close(fd); } - - /* This will be called when data is ready to be read from fd. Read until * error or connection closed. */ static void @@ -166,11 +164,9 @@ waisReadReply(int fd, void *data) 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; @@ -203,7 +199,6 @@ waisReadReply(int fd, void *data) err->xerrno = errno; err->request = urlParse(METHOD_CONNECT, waisState->request); errorAppendEntry(entry, err); - storeAbort(entry, 0); comm_close(fd); } @@ -213,7 +208,6 @@ waisReadReply(int fd, void *data) err->xerrno = errno; err->request = urlParse(METHOD_CONNECT, waisState->request); errorAppendEntry(entry, err); - storeAbort(entry, 0); comm_close(fd); } else if (len == 0) { @@ -269,28 +263,19 @@ waisSendRequest(int fd, void *data) 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 */ } -- 2.47.3