--------------------- PatchSet 479 Date: 2002/12/24 21:25:34 Author: rbcollins Branch: esi Tag: (none) Log: tidyups Members: src/ESI.cc:1.1.2.83->1.1.2.84 src/ESISegment.cc:1.1.2.8->1.1.2.9 src/ESISegment.h:1.1.2.8->1.1.2.9 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.83 retrieving revision 1.1.2.84 diff -u -r1.1.2.83 -r1.1.2.84 --- squid3/src/ESI.cc 24 Dec 2002 20:51:17 -0000 1.1.2.83 +++ squid3/src/ESI.cc 24 Dec 2002 21:25:34 -0000 1.1.2.84 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.83 2002/12/24 20:51:17 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.84 2002/12/24 21:25:34 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -1939,7 +1939,7 @@ return ESI_PROCESS_COMPLETE; } -esiLiteral::esiLiteral(esiLiteral const &old) : buffer (old.buffer->clone()), +esiLiteral::esiLiteral(esiLiteral const &old) : buffer (old.buffer->cloneList()), varState (NULL) { flags.donevars = 0; @@ -2472,6 +2472,7 @@ if (success) { /* copy the lead segment */ debug (86,3)("esiIncludeSubRequestDone: Src OK - include PASSED.\n"); + assert (!srccontent.getRaw()); copyLeadSegment (srccontent, stream->localbuffer); /* we're done! */ flags.finished = 1; @@ -2492,6 +2493,7 @@ if (success) { debug (86,3)("esiIncludeSubRequestDone: ALT OK.\n"); /* copy the lead segment */ + assert (!altcontent.getRaw()); copyLeadSegment (altcontent, stream->localbuffer); /* we're done! */ if (!(src || srccontent.getRaw())) { @@ -3103,7 +3105,7 @@ { /* TODO: if needed - tune to skip segment iteration */ debug (86,6)("esiVarState::feedData: accepting %d bytes\n", len); - ESISegmentListAppend (input, buf, len); + ESISegment::ListAppend (input, buf, len); } ESISegment::Pointer @@ -3122,7 +3124,7 @@ if (!input.getRaw()) fatal ("Attempt to extract variable state with no data fed in \n"); doIt(); - char *rv = ESISegmentListToChar(output); + char *rv = output->listToChar(); ESISegmentFreeList (output); debug (86,6)("esiVarStateExtractList: Extracted char\n"); return rv; @@ -3168,7 +3170,7 @@ if (!subref && httpHeaderHas(&hdr,HDR_HOST)) { s = httpHeaderGetStr (&hdr, HDR_HOST); } else s = found_default; - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); break; case ESI_VAR_COOKIE: flags.cookie = 1; @@ -3178,15 +3180,15 @@ else { String S = httpHeaderGetListMember (&hdr, HDR_COOKIE, subref, ';'); if (strLen(S)) - ESISegmentListAppend (output, strBuf(S), strLen (S)); + ESISegment::ListAppend (output, strBuf(S), strLen (S)); else if (found_default) - ESISegmentListAppend (output, found_default, strlen (found_default)); + ESISegment::ListAppend (output, found_default, strlen (found_default)); stringClean (&S); } } else s = found_default; if (s) - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); break; case ESI_VAR_REFERER: flags.referer = 1; @@ -3194,7 +3196,7 @@ s = httpHeaderGetStr (&hdr, HDR_REFERER); else s = found_default; - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); break; case ESI_QUERY_STRING: if (!subref) @@ -3209,7 +3211,7 @@ if (!s) s = found_default; } - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); break; case ESI_VAR_USERAGENT: flags.useragent = 1; @@ -3227,14 +3229,14 @@ s = ""; } } else s = found_default; - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); break; case ESI_VAR_LANGUAGE: flags.language = 1; if (httpHeaderHas(&hdr, HDR_ACCEPT_LANGUAGE)) { if (!subref) { String S = httpHeaderGetList (&hdr, HDR_ACCEPT_LANGUAGE); - ESISegmentListAppend (output, strBuf(S), strLen (S)); + ESISegment::ListAppend (output, strBuf(S), strLen (S)); stringClean (&S); } else { if (httpHeaderHasListMember (&hdr, HDR_ACCEPT_LANGUAGE, subref, ',')) { @@ -3242,17 +3244,17 @@ } else { s = "false"; } - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); } } else { s = found_default; - ESISegmentListAppend (output, s, strlen (s)); + ESISegment::ListAppend (output, s, strlen (s)); } break; case ESI_VAR_OTHER: /* No-op. We swallow it */ if (found_default) { - ESISegmentListAppend (output, found_default, strlen (found_default)); + ESISegment::ListAppend (output, found_default, strlen (found_default)); } break; } @@ -3319,7 +3321,7 @@ { assert (output == NULL); int state = 0; - char *string = ESISegmentListToChar(input); + char *string = input->listToChar(); size_t len = strlen (string); size_t pos = 0; size_t var_pos = 0; @@ -3336,7 +3338,7 @@ } else { if (pos - done_pos) /* extract known good text */ - ESISegmentListAppend (output, string + done_pos, pos - done_pos); + ESISegment::ListAppend (output, string + done_pos, pos - done_pos); done_pos = pos; state = 1; ++pos; @@ -3443,7 +3445,7 @@ } /* pos-done_pos chars are ready to copy */ if (pos-done_pos) - ESISegmentListAppend (output, string+done_pos, pos - done_pos); + ESISegment::ListAppend (output, string+done_pos, pos - done_pos); safe_free (found_default); safe_free (found_subref); } Index: squid3/src/ESISegment.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESISegment.cc,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid3/src/ESISegment.cc 24 Dec 2002 21:04:47 -0000 1.1.2.8 +++ squid3/src/ESISegment.cc 24 Dec 2002 21:25:34 -0000 1.1.2.9 @@ -1,6 +1,6 @@ /* - * $Id: ESISegment.cc,v 1.1.2.8 2002/12/24 21:04:47 rbcollins Exp $ + * $Id: ESISegment.cc,v 1.1.2.9 2002/12/24 21:25:34 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -60,12 +60,6 @@ from = NULL; } -char * -ESISegmentListToChar (ESISegment::Pointer const &head) -{ - return head->listToChar(); -} - size_t ESISegment::listLength() const { @@ -97,14 +91,13 @@ } void -ESISegmentListAppend (ESISegment::Pointer &head, char const *s, size_t len) +ESISegment::ListAppend (ESISegment::Pointer &head, char const *s, size_t len) { - ESISegment::Pointer output; - size_t pos=0; if (!head.getRaw()) head = new ESISegment; - output = head->tail(); + ESISegment::Pointer output = head->tail(); /* copy the string to output */ + size_t pos=0; while (pos < len) { if (output->len == sizeof (output->buf)) { assert (output->next.getRaw() == NULL); @@ -139,10 +132,10 @@ /* XXX: if needed, make this iterative */ ESISegment::Pointer -ESISegment::clone () const +ESISegment::cloneList () const { ESISegment::Pointer result = new ESISegment (*this); - result->next = next.getRaw() ? next->clone() : NULL; + result->next = next.getRaw() ? next->cloneList() : NULL; return result; } Index: squid3/src/ESISegment.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESISegment.h,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid3/src/ESISegment.h 24 Dec 2002 21:04:47 -0000 1.1.2.8 +++ squid3/src/ESISegment.h 24 Dec 2002 21:25:34 -0000 1.1.2.9 @@ -1,5 +1,5 @@ /* - * $Id: ESISegment.h,v 1.1.2.8 2002/12/24 21:04:47 rbcollins Exp $ + * $Id: ESISegment.h,v 1.1.2.9 2002/12/24 21:25:34 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -42,13 +42,14 @@ class ESISegment : public RefCountable { public: typedef RefCount Pointer; + static void ListAppend (Pointer &, char const *, size_t); void *operator new (size_t byteCount); void operator delete (void *address); void deleteSelf() const; ESISegment(); ESISegment(ESISegment const &); - ESISegment::Pointer clone() const; + ESISegment::Pointer cloneList() const; char *listToChar() const; char buf[HTTP_REQBUF_SZ]; @@ -63,7 +64,5 @@ extern void ESISegmentFreeList (ESISegment::Pointer &head); extern void ESISegmentTransferList (ESISegment::Pointer &from, ESISegment::Pointer &to); -extern char *ESISegmentListToChar (ESISegment::Pointer const &); -extern void ESISegmentListAppend (ESISegment::Pointer &, char const *, size_t); #endif /* SQUID_ESISEGMENT_H */