]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added StringToInt(), currently used when parsing chunked encoding messages.
authorwessels <>
Tue, 22 Nov 2005 06:06:51 +0000 (06:06 +0000)
committerwessels <>
Tue, 22 Nov 2005 06:06:51 +0000 (06:06 +0000)
This was added for ICAP integration.

src/Parsing.cc
src/Parsing.h

index 6e7e5a7b6876c7586c9a89c7d9890625f3306dfe..1b8c03651205a222404c7be9198f767c1a8ebf15 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: Parsing.cc,v 1.1 2005/01/03 16:08:25 robertc Exp $
+ * $Id: Parsing.cc,v 1.2 2005/11/21 23:06:51 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -72,3 +72,22 @@ GetInteger(void)
     return i;
 }
 
+bool
+StringToInt(const char *s, int &result, const char **p, int base)
+{
+    if (s) {
+        char *ptr = 0;
+        const int h = (int) strtol(s, &ptr, base);
+
+        if (ptr != s && ptr) {
+            result = h;
+
+            if (p)
+                *p = ptr;
+
+            return true;
+        }
+    }
+
+    return false;
+}
index e4f5d599e705a050fb31ee9d17c6f5e661a39b9f..182251e9ace57186c6c5ee4cb3907a01ac8334b7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: Parsing.h,v 1.1 2005/01/03 16:08:25 robertc Exp $
+ * $Id: Parsing.h,v 1.2 2005/11/21 23:06:51 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -42,4 +42,7 @@ extern long xatol(const char *token);
 extern int xatoi(const char *token);
 extern int GetInteger(void);
 
+// on success, returns true and sets *p (if any) to the end of the integer
+extern bool StringToInt(const char *str, int &result, const char **p, int base);
+
 #endif /* SQUID_PARSING_H */