summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-22 02:20:52 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-22 02:20:52 +0000
commit4ec5e139c8442b321ef9b58684da547ea0388261 (patch)
tree70601b682cc85875f18891293e182770cab2fc95 /src/common/util.c
parentd23cb33a1a7c2fb8e16040826ec2bbda607468c5 (diff)
downloadtor-4ec5e139c8442b321ef9b58684da547ea0388261.tar.gz
tor-4ec5e139c8442b321ef9b58684da547ea0388261.zip
r12850@catbus: nickm | 2007-05-21 22:20:42 -0400
Partial backport candidate: do not rely on finding a \0 after an mmaped() router/extrainfo file. Also, set journal length correctly when starting up. svn:r10248
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 0c420f4602..18d9fcba2c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -418,6 +418,35 @@ eat_whitespace(const char *s)
}
}
+/** Return a pointer to the first char of s that is not whitespace and
+ * not a comment, or to the terminating NUL if no such character exists.
+ */
+const char *
+eat_whitespace_eos(const char *s, const char *eos)
+{
+ tor_assert(s);
+ tor_assert(eos && s <= eos);
+
+ while (s < eos) {
+ switch (*s) {
+ case '\0':
+ default:
+ return s;
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ ++s;
+ break;
+ case '#':
+ ++s;
+ while (s < eos && *s && *s != '\n')
+ ++s;
+ }
+ }
+ return s;
+}
+
/** Return a pointer to the first char of s that is not a space or a tab,
* or to the terminating NUL if no such character exists. */
const char *