Revision: 14641
Author: adrian.chadd
Date: Sun May 9 06:33:36 2010
Log: Issue #108 - flesh out a size parsing variant that will take a C
string + len rather than a String.
This is a temporary measure until String's are copy-by-reference and thus
cheap to copy around.
http://code.google.com/p/lusca-cache/source/detail?r=14641
Modified:
/branches/LUSCA_HEAD/libhttp/HttpHeaderParse.c
=======================================
--- /branches/LUSCA_HEAD/libhttp/HttpHeaderParse.c Sun May 9 03:15:48 2010
+++ /branches/LUSCA_HEAD/libhttp/HttpHeaderParse.c Sun May 9 06:33:36 2010
@@ -78,6 +78,7 @@
int HeaderEntryParsedCount = 0;
static HttpHeaderEntry * httpHeaderEntryParseCreate(HttpHeader *hdr, const
char *field_start, const char *field_end);
+int httpHeaderParseSize2(const char *start, int len, squid_off_t * value);
/*
* Check whether the given content length header value is "sensible".
@@ -328,6 +329,28 @@
debug(55, 9) ("created entry %p: '%.*s: %.*s'\n", e, strLen2(e->name),
strBuf2(e->name), strLen2(e->value), strBuf2(e->value));
return e;
}
+
+
+/*
+ * like httpHeaderParseSize(), but takes a "len" parameter for the length
+ * of the string buffer.
+ */
+int
+httpHeaderParseSize2(const char *start, int len, squid_off_t * value)
+{
+ char *end;
+ errno = 0;
+ assert(value);
+
+ *value = strtol_n(start, len, &end, 10);
+ if (start == end || errno != 0) {
+ debug(66, 2) ("httpHeaderParseSize2: failed to parse a size/offset
header field near '%s'\n", start);
+ *value = -1;
+ return 0;
+ }
+ return 1;
+}
+
/*
* parses an int field, complains if soemthing went wrong, returns true on
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.