]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Clean up the squid code to consistenly use [u_]int<len>_t throughout, rather than...
authorrobertc <>
Fri, 9 Aug 2002 16:57:41 +0000 (16:57 +0000)
committerrobertc <>
Fri, 9 Aug 2002 16:57:41 +0000 (16:57 +0000)
[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.

17 files changed:
.cvsignore
ChangeLog
doc/Programming-Guide/prog-guide.sgml
include/squid_types.h
lib/MemPool.c
lib/md5.c
src/CacheDigest.cc
src/acl.cc
src/fs/aufs/store_dir_aufs.cc
src/fs/coss/store_dir_coss.cc
src/fs/diskd/store_dir_diskd.cc
src/fs/ufs/store_dir_ufs.cc
src/htcp.cc
src/icp_v2.cc
src/icp_v3.cc
src/squid.h
src/structs.h

index 04290fcd2eb7256d94337562d2609bd692f99865..b21545c1097de3f474bc3c9f7740e7c4bec13985 100644 (file)
@@ -2,3 +2,4 @@ Makefile
 config.cache
 config.log
 config.status
+autom4te.cache
index ff3a39832dbbfd7569b6fe5974eebbd4aaecf71b..04bceea75b2a6d2cf0e9e0ef992bf21406e77dd2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@ Changes to squid-2.6 ():
        - 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 ():
 
index cb45cdd7242a1b084ed63f1cabcedbcd9d13fe9f..0f0cf26c10c0154fd1859d693ced6211abac852b 100644 (file)
@@ -2,7 +2,7 @@
 <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
@@ -64,6 +64,27 @@ or improve it.
        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
 
index 43c94cdf13de7cb09fd5d277315ac8b61db27f22..134649f016be133dd08652af1318de1c2c16713f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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 * * * * * * *
  *
@@ -56,6 +56,9 @@
 #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>
@@ -63,9 +66,6 @@
 #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
index f2e5d74eb0023d6d823fc1d2a1028eec88416981..daa6bf2254f91e86b71343441d3fdde834e25650 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
index 66b84df9f2f001390de6d2a4b3358bc97c41ca3c..4b8322498a7998e6feac07e9dd3b9987efd7de42 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -1,5 +1,5 @@
 /*
- * $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.
  */
index 90cb5b6fe65fcb0b6c83c5520ad1c882b38bfa1d..70f9302c7064479b325ebb1897f652bc1871a4bc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -49,7 +49,7 @@ typedef struct {
 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)
index ca7da67fd0a8f90c9240b80677d6947caf2f2a27..cbd2ee3fb1882de273b99ec7d5f6143010b333ce 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -394,7 +394,7 @@ aclParseMethodList(void *curlist)
 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)) {
@@ -417,7 +417,7 @@ decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask)
     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))
index dd3262cc10d951b4807f9f896d9f09cb5776eb02..369b1acfdf58fa3f355af5676393ac451dd0d06c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -87,8 +87,8 @@ static StoreEntry *storeAufsDirAddDiskRestore(SwapDir * SD, const cache_key * ke
     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);
@@ -783,8 +783,8 @@ storeAufsDirAddDiskRestore(SwapDir * SD, const cache_key * key,
     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;
index 75e91eac86bc8b785bbdda5422639e9ed38a56f5..011339d3f8cdc4d6d842ed47fec0dac82a20aba5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -68,8 +68,8 @@ static StoreEntry *storeCossAddDiskRestore(SwapDir * SD, const cache_key * key,
     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);
@@ -305,8 +305,8 @@ storeCossAddDiskRestore(SwapDir * SD, const cache_key * key,
     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;
index bb56a05ae86745105070e35dce0238aba32a5c75..edc64f811c23a2012a239a9a8ddd19adb3e96507 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -91,8 +91,8 @@ static StoreEntry *storeDiskdDirAddDiskRestore(SwapDir * SD, const cache_key * k
     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);
@@ -970,8 +970,8 @@ storeDiskdDirAddDiskRestore(SwapDir * SD, const cache_key * key,
     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;
index fefe6bcedcbb83418ed966fbc88bd066a948b59c..f7ad79d93e0a249bd5d846974f3fce91cb21182a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -85,8 +85,8 @@ static StoreEntry *storeUfsDirAddDiskRestore(SwapDir * SD, const cache_key * key
     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);
@@ -782,8 +782,8 @@ storeUfsDirAddDiskRestore(SwapDir * SD, const cache_key * key,
     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;
index 3bcf2c5bef942184fb94d571b646853ec89b6e08..d422d3d723cc14cd86d660d370a81e7d2aa1eac1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -44,18 +44,18 @@ typedef struct _htcpSpecifier htcpSpecifier;
 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;
@@ -72,7 +72,7 @@ struct _htcpDataHeader {
     unsigned int F1:1;
     unsigned int reserved:6;
 #endif
-    u_num32 msg_id;
+    u_int32_t msg_id;
 };
 
     /* RR == 0 --> F1 = RESPONSE DESIRED FLAG */
@@ -81,7 +81,7 @@ struct _htcpDataHeader {
     /* RR == 1 --> RESPONSE */
 
 struct _htcpAuthHeader {
-    u_short length;
+    u_int16_t length;
     time_t sig_time;
     time_t sig_expire;
     Countstr key_name;
@@ -106,7 +106,7 @@ struct _htcpStuff {
     int rr;
     int f1;
     int response;
-    u_num32 msg_id;
+    u_int32_t msg_id;
     htcpSpecifier S;
     htcpDetail D;
 };
@@ -150,7 +150,7 @@ enum {
     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
@@ -214,7 +214,7 @@ htcpBuildAuth(char *buf, size_t buflen)
 {
     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);
@@ -225,7 +225,7 @@ htcpBuildAuth(char *buf, size_t buflen)
 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)
@@ -236,7 +236,7 @@ htcpBuildCountstr(char *buf, size_t buflen, const char *s)
        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)
@@ -344,7 +344,7 @@ htcpBuildData(char *buf, size_t buflen, htcpStuff * stuff)
        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;
@@ -385,7 +385,7 @@ htcpBuildPacket(htcpStuff * stuff, ssize_t * len)
        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);
@@ -436,7 +436,7 @@ htcpFreeDetail(htcpDetail * d)
 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");
index 0b633945ec8844d8a89ed815aacf238436c69fe1..74774fb9c2cf5f67f8a1332377b872881d7af8bf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -97,19 +97,19 @@ icpCreateMessage(
     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;
 }
@@ -190,7 +190,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
     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));
@@ -211,7 +211,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
     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);
@@ -401,7 +401,7 @@ icpHandleUdp(int sock, void *data)
 void
 icpConnectionsOpen(void)
 {
-    u_short port;
+    u_int16_t port;
     struct in_addr addr;
     struct sockaddr_in xaddr;
     int x;
index 2e9e42bb5a4fd0a70f583f1705d38eed34334da0..9eb727f251076a36f48d4557a2a1a61f8e81be67 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -65,7 +65,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
     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);
index 060c24770d724f77fc01d6df25d09f0a89dde19e..5050d505e682a9e9bdb405d7227e2138c3bbe74d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
index 4b6f9c884e1e3f779b918d693e7c841c171cf9aa..d8ffa169eb95f04bcccdcc530ead6e0057b6f092 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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/
@@ -1403,10 +1403,10 @@ struct _icp_common_t {
     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 {
@@ -1967,7 +1967,7 @@ struct _FwdState {
 struct _htcpReplyData {
     int hit;
     HttpHeader hdr;
-    u_num32 msg_id;
+    u_int32_t msg_id;
     double version;
     struct {
        /* cache-to-origin */