[u_]num<len> and some [u_]<len>_t instances.
This also makes the autoconf 2.5 patch less intrusive, and thus easier to
maintain as a long term branch.
config.cache
config.log
config.status
+autom4te.cache
- http_port is now optional, allowing for SSL only operation
- Satellite and other high latency peering relations enhancements
(Robert Cohren)
+ - Nuked num32 types, and made type detection more robust by the
+ use of typedefs rather than #defines.
Changes to squid-2.5 ():
<article>
<title>Squid Programmers Guide</title>
<author>Squid Developers</author>
-<date>$Id: prog-guide.sgml,v 1.50 2002/06/19 06:29:45 hno Exp $</date>
+<date>$Id: prog-guide.sgml,v 1.51 2002/08/09 10:57:41 robertc Exp $</date>
<abstract>
Squid is a WWW Cache application developed by the National Laboratory
structures and their members will be written in an italicized
font, such as <em/StoreEntry/.
+<sect>Coding Conventions
+
+<sect1>Infrastructure
+
+ <P>
+ Most custom types and tools are documented in the code or the relevant
+ portions of this manual. Some key points apply globally however.
+
+<sect2>Fixed width types
+ <P>
+ If you need to use specific width types - such as
+ a 16 bit unsigned integer, use one of the following types. To access
+ them simply include "config.h".
+ <enum>
+ <item>int16_t - 16 bit signed.
+ <item>u_int16_t - 16 bit unsigned.
+ <item>int32t - 32 bit signed.
+ <item>u_int32_t - 32 bit unsigned.
+ <item>int64_t - 64 bit signed.
+ <item>u_int64_t - 64 bit unsigned.
+ </enum>
<sect>Overview of Squid Components
/*
- * $Id: squid_types.h,v 1.4 2002/06/17 18:28:13 hno Exp $
+ * $Id: squid_types.h,v 1.5 2002/08/09 10:57:42 robertc Exp $
*
* * * * * * * * Legal stuff * * * * * * *
*
#include "autoconf.h"
/* This should be in synch with what we have in acinclude.m4 */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
#if HAVE_SYS_BITYPES_H
#include <sys/bitypes.h>
#endif
/*
- * $Id: MemPool.c,v 1.11 2002/04/16 00:33:29 hno Exp $
+ * $Id: MemPool.c,v 1.12 2002/08/09 10:57:42 robertc Exp $
*
* DEBUG: section 63 Low Level Memory Pool Management
* AUTHOR: Alex Rousskov, Andres Kroonmaa
* Andres Kroonmaa.
*/
+#include "config.h"
+
#define FLUSH_LIMIT 1000 /* Flush memPool counters to memMeters after flush limit calls */
#define MEM_MAX_MMAP_CHUNKS 2048
#include <assert.h>
-#include "config.h"
#if HAVE_STRING_H
#include <string.h>
#endif
/*
- * $Id: md5.c,v 1.14 2001/11/21 23:47:12 hno Exp $
+ * $Id: md5.c,v 1.15 2002/08/09 10:57:42 robertc Exp $
*/
/* taken from RFC-1321/Appendix A.3 */
* documentation and/or software.
*/
-#include "config.h"
+#include "md5.h"
#if HAVE_STRING_H
#include <string.h>
#endif
-#include "md5.h"
-
/*
* Constants for MD5Transform routine.
*/
/*
- * $Id: CacheDigest.cc,v 1.32 2001/01/12 00:37:13 wessels Exp $
+ * $Id: CacheDigest.cc,v 1.33 2002/08/09 10:57:43 robertc Exp $
*
* DEBUG: section 70 Cache Digest
* AUTHOR: Alex Rousskov
static void cacheDigestHashKey(const CacheDigest * cd, const cache_key * key);
/* static array used by cacheDigestHashKey for optimization purposes */
-static u_num32 hashed_keys[4];
+static u_int32_t hashed_keys[4];
static void
cacheDigestInit(CacheDigest * cd, int capacity, int bpe)
/*
- * $Id: acl.cc,v 1.280 2002/06/23 13:32:23 hno Exp $
+ * $Id: acl.cc,v 1.281 2002/08/09 10:57:43 robertc Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
static int
decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask)
{
- u_num32 a;
+ u_int32_t a;
int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
switch (sscanf(asc, "%d.%d.%d.%d", &a1, &a2, &a3, &a4)) {
if (mask != NULL) { /* mask == NULL if called to decode a netmask */
/* Guess netmask */
- a = (u_num32) ntohl(addr->s_addr);
+ a = (u_int32_t) ntohl(addr->s_addr);
if (!(a & 0xFFFFFFFFul))
mask->s_addr = htonl(0x00000000ul);
else if (!(a & 0x00FFFFFF))
/*
- * $Id: store_dir_aufs.cc,v 1.47 2002/07/21 00:25:45 hno Exp $
+ * $Id: store_dir_aufs.cc,v 1.48 2002/08/09 10:57:44 robertc Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean);
static void storeAufsDirRebuild(SwapDir * sd);
static void storeAufsDirCloseTmpSwapLog(SwapDir * sd);
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean)
{
StoreEntry *e = NULL;
/*
- * $Id: store_dir_coss.cc,v 1.37 2002/07/21 00:25:45 hno Exp $
+ * $Id: store_dir_coss.cc,v 1.38 2002/08/09 10:57:45 robertc Exp $
*
* DEBUG: section 47 Store COSS Directory Routines
* AUTHOR: Eric Stern
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean);
static void storeCossDirRebuild(SwapDir * sd);
static void storeCossDirCloseTmpSwapLog(SwapDir * sd);
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean)
{
StoreEntry *e = NULL;
/*
- * $Id: store_dir_diskd.cc,v 1.69 2002/07/21 00:25:46 hno Exp $
+ * $Id: store_dir_diskd.cc,v 1.70 2002/08/09 10:57:46 robertc Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean);
static void storeDiskdDirRebuild(SwapDir * sd);
static void storeDiskdDirCloseTmpSwapLog(SwapDir * sd);
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean)
{
StoreEntry *e = NULL;
/*
- * $Id: store_dir_ufs.cc,v 1.47 2002/07/22 00:05:20 hno Exp $
+ * $Id: store_dir_ufs.cc,v 1.48 2002/08/09 10:57:46 robertc Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean);
static void storeUfsDirRebuild(SwapDir * sd);
static void storeUfsDirCloseTmpSwapLog(SwapDir * sd);
time_t timestamp,
time_t lastref,
time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
int clean)
{
StoreEntry *e = NULL;
/*
- * $Id: htcp.cc,v 1.40 2002/04/30 07:59:49 hno Exp $
+ * $Id: htcp.cc,v 1.41 2002/08/09 10:57:43 robertc Exp $
*
* DEBUG: section 31 Hypertext Caching Protocol
* AUTHOR: Duane Wesssels
typedef struct _htcpDetail htcpDetail;
struct _Countstr {
- u_short length;
+ u_int16_t length;
char *text;
};
struct _htcpHeader {
- u_short length;
+ u_int16_t length;
u_char major;
u_char minor;
};
struct _htcpDataHeader {
- u_short length;
+ u_int16_t length;
#if !WORDS_BIGENDIAN
unsigned int opcode:4;
unsigned int response:4;
unsigned int F1:1;
unsigned int reserved:6;
#endif
- u_num32 msg_id;
+ u_int32_t msg_id;
};
/* RR == 0 --> F1 = RESPONSE DESIRED FLAG */
/* RR == 1 --> RESPONSE */
struct _htcpAuthHeader {
- u_short length;
+ u_int16_t length;
time_t sig_time;
time_t sig_expire;
Countstr key_name;
int rr;
int f1;
int response;
- u_num32 msg_id;
+ u_int32_t msg_id;
htcpSpecifier S;
htcpDetail D;
};
RR_RESPONSE
};
-static u_num32 msg_id_counter = 0;
+static u_int32_t msg_id_counter = 0;
static int htcpInSocket = -1;
static int htcpOutSocket = -1;
#define N_QUERIED_KEYS 256
{
htcpAuthHeader auth;
size_t copy_sz = 0;
- assert(2 == sizeof(u_short));
+ assert(2 == sizeof(u_int16_t));
auth.length = htons(2);
copy_sz += 2;
assert(buflen >= copy_sz);
static ssize_t
htcpBuildCountstr(char *buf, size_t buflen, const char *s)
{
- u_short length;
+ u_int16_t length;
size_t len;
off_t off = 0;
if (buflen - off < 2)
len = 0;
debug(31, 3) ("htcpBuildCountstr: LENGTH = %d\n", len);
debug(31, 3) ("htcpBuildCountstr: TEXT = {%s}\n", s ? s : "<NULL>");
- length = htons((u_short) len);
+ length = htons((u_int16_t) len);
xmemcpy(buf + off, &length, 2);
off += 2;
if (buflen - off < len)
return op_data_sz;
off += op_data_sz;
debug(31, 3) ("htcpBuildData: hdr.length = %d\n", (int) off);
- hdr.length = (u_short) off;
+ hdr.length = (u_int16_t) off;
hdr.opcode = stuff->op;
hdr.response = stuff->response;
hdr.RR = stuff->rr;
return NULL;
}
off += s;
- hdr.length = htons((u_short) off);
+ hdr.length = htons((u_int16_t) off);
hdr.major = 0;
hdr.minor = 0;
xmemcpy(buf, &hdr, hdr_sz);
static int
htcpUnpackCountstr(char *buf, int sz, char **str)
{
- u_short l;
+ u_int16_t l;
debug(31, 3) ("htcpUnpackCountstr: sz = %d\n", sz);
if (sz < 2) {
debug(31, 3) ("htcpUnpackCountstr: sz < 2\n");
/*
- * $Id: icp_v2.cc,v 1.66 2001/05/04 13:37:42 hno Exp $
+ * $Id: icp_v2.cc,v 1.67 2002/08/09 10:57:43 robertc Exp $
*
* DEBUG: section 12 Internet Cache Protocol
* AUTHOR: Duane Wessels
int buf_len;
buf_len = sizeof(icp_common_t) + strlen(url) + 1;
if (opcode == ICP_QUERY)
- buf_len += sizeof(u_num32);
+ buf_len += sizeof(u_int32_t);
buf = xcalloc(buf_len, 1);
headerp = (icp_common_t *) (void *) buf;
headerp->opcode = (char) opcode;
headerp->version = ICP_VERSION_CURRENT;
- headerp->length = (u_short) htons(buf_len);
+ headerp->length = (u_int16_t) htons(buf_len);
headerp->reqnum = htonl(reqnum);
headerp->flags = htonl(flags);
headerp->pad = htonl(pad);
headerp->shostid = theOutICPAddr.s_addr;
urloffset = buf + sizeof(icp_common_t);
if (opcode == ICP_QUERY)
- urloffset += sizeof(u_num32);
+ urloffset += sizeof(u_int32_t);
xmemcpy(urloffset, url, strlen(url));
return buf;
}
aclCheck_t checklist;
icp_common_t *reply;
int src_rtt = 0;
- u_num32 flags = 0;
+ u_int32_t flags = 0;
int rtt = 0;
int hops = 0;
xmemcpy(&header, buf, sizeof(icp_common_t));
switch (header.opcode) {
case ICP_QUERY:
/* We have a valid packet */
- url = buf + sizeof(icp_common_t) + sizeof(u_num32);
+ url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
if (strpbrk(url, w_space)) {
url = rfc1738_escape(url);
reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
void
icpConnectionsOpen(void)
{
- u_short port;
+ u_int16_t port;
struct in_addr addr;
struct sockaddr_in xaddr;
int x;
/*
- * $Id: icp_v3.cc,v 1.33 2001/01/12 00:37:18 wessels Exp $
+ * $Id: icp_v3.cc,v 1.34 2002/08/09 10:57:43 robertc Exp $
*
* DEBUG: section 12 Internet Cache Protocol
* AUTHOR: Duane Wessels
switch (header.opcode) {
case ICP_QUERY:
/* We have a valid packet */
- url = buf + sizeof(icp_common_t) + sizeof(u_num32);
+ url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
if (strpbrk(url, w_space)) {
url = rfc1738_escape(url);
reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
/*
- * $Id: squid.h,v 1.220 2002/05/19 14:32:09 hno Exp $
+ * $Id: squid.h,v 1.221 2002/08/09 10:57:43 robertc Exp $
*
* AUTHOR: Duane Wessels
*
#define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
#endif
-
-/* 32 bit integer compatability */
-#include "squid_types.h"
-#define num32 int32_t
-#define u_num32 u_int32_t
-
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
/*
- * $Id: structs.h,v 1.422 2002/06/23 14:50:07 hno Exp $
+ * $Id: structs.h,v 1.423 2002/08/09 10:57:43 robertc Exp $
*
*
* SQUID Web Proxy Cache http://www.squid-cache.org/
unsigned char opcode; /* opcode */
unsigned char version; /* version number */
unsigned short length; /* total length (bytes) */
- u_num32 reqnum; /* req number (req'd for UDP) */
- u_num32 flags;
- u_num32 pad;
- u_num32 shostid; /* sender host id */
+ u_int32_t reqnum; /* req number (req'd for UDP) */
+ u_int32_t flags;
+ u_int32_t pad;
+ u_int32_t shostid; /* sender host id */
};
struct _iostats {
struct _htcpReplyData {
int hit;
HttpHeader hdr;
- u_num32 msg_id;
+ u_int32_t msg_id;
double version;
struct {
/* cache-to-origin */