From: rousskov <> Date: Wed, 4 Mar 1998 12:39:27 +0000 (+0000) Subject: - httpHeaderGet() is no longer public. This allows us to change internal X-Git-Tag: SQUID_3_0_PRE1~3936 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c525cc2b50ecfc95632c77c523a1efa69360e2d;p=thirdparty%2Fsquid.git - httpHeaderGet() is no longer public. This allows us to change internal representation of header fields without danger of somebody still using the wrong type. - added missing httpHeaderGetInt(). --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 72fa5c1b12..b9468f997e 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,5 +1,5 @@ /* - * $Id: HttpHeader.cc,v 1.12 1998/03/03 22:17:50 rousskov Exp $ + * $Id: HttpHeader.cc,v 1.13 1998/03/04 05:39:28 rousskov Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -252,6 +252,7 @@ static HttpHeaderEntry *httpHeaderGetEntry(const HttpHeader * hdr, HttpHeaderPos static void httpHeaderDelAt(HttpHeader * hdr, HttpHeaderPos pos); static void httpHeaderAddParsedEntry(HttpHeader * hdr, HttpHeaderEntry * e); static void httpHeaderAddNewEntry(HttpHeader * hdr, const HttpHeaderEntry * e); +static field_store httpHeaderGet(const HttpHeader * hdr, http_hdr_type id); static void httpHeaderSet(HttpHeader * hdr, http_hdr_type id, const field_store value); static void httpHeaderSyncMasks(HttpHeader * hdr, const HttpHeaderEntry * e, int add); static int httpHeaderIdByName(const char *name, int name_len, const field_attrs_t * attrs, int end, int mask); @@ -300,6 +301,10 @@ static void freeShortString(char *str); static int strListGetItem(const char *str, char del, const char **item, int *ilen, const char **pos); static const char *getStringPrefix(const char *str); + +/* delete this when everybody remembers that ':' is not a part of a name */ +#define conversion_period_name_check(name) assert(!strchr((name), ':')) + /* handy to determine the #elements in a static array */ #define countof(arr) (sizeof(arr)/sizeof(*arr)) @@ -840,7 +845,7 @@ httpHeaderAddExt(HttpHeader * hdr, const char *name, const char *value) } /* get a value of a field (not lvalue though) */ -field_store +static field_store httpHeaderGet(const HttpHeader * hdr, http_hdr_type id) { HttpHeaderEntry *e; @@ -854,11 +859,19 @@ httpHeaderGet(const HttpHeader * hdr, http_hdr_type id) return httpHeaderFieldBadValue(Headers[id].type); } +int +httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id) +{ + assert_eid(id); + assert(Headers[id].type == ftInt); /* must be of an apropriate type */ + return httpHeaderGet(hdr, id).v_int; +} + const char * httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id) { assert_eid(id); - assert(Headers[id].type == ftPChar); /* must be of an apropriate type */ + assert(Headers[id].type == ftPChar); /* must be of an apropriate type */ return httpHeaderGet(hdr, id).v_pchar; } diff --git a/src/HttpReply.cc b/src/HttpReply.cc index b1ee9c232f..6efd533a1b 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.8 1998/03/03 22:17:50 rousskov Exp $ + * $Id: HttpReply.cc,v 1.9 1998/03/04 05:39:27 rousskov Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -280,7 +280,7 @@ int httpReplyContentLen(const HttpReply * rep) { assert(rep); - return httpHeaderGet(&rep->hdr, HDR_CONTENT_LENGTH).v_int; + return httpHeaderGetInt(&rep->hdr, HDR_CONTENT_LENGTH); } /* should we return "" or NULL if no content-type? Return NULL for now @?@ */ diff --git a/src/protos.h b/src/protos.h index 2132e8e0e1..d218e06544 100644 --- a/src/protos.h +++ b/src/protos.h @@ -278,10 +278,10 @@ extern void httpHeaderSetTime(HttpHeader * hdr, http_hdr_type type, time_t time) extern void httpHeaderSetStr(HttpHeader * hdr, http_hdr_type type, const char *str); extern void httpHeaderSetAuth(HttpHeader * hdr, const char *authScheme, const char *realm); extern void httpHeaderAddExt(HttpHeader * hdr, const char *name, const char *value); -extern const char *httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id); +extern int httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id); extern time_t httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id); +extern const char *httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id); extern HttpScc *httpHeaderGetScc(const HttpHeader * hdr); -extern field_store httpHeaderGet(const HttpHeader * hdr, http_hdr_type id); int httpHeaderDelFields(HttpHeader * hdr, const char *name); /* store report about current header usage and other stats */ extern void httpHeaderStoreReport(StoreEntry * e);