/*
- * $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
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;
+}
/*
- * $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
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 */