aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index bbe8f33c..fa0b777f 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -280,6 +280,16 @@ int stridx(char *haystack, char needle)
return off-haystack;
}
+// If *a starts with b, advance *a past it and return 1, else return 0;
+int strstart(char **a, char *b)
+{
+ int len = strlen(b), i = !strncmp(*a, b, len);
+
+ if (i) *a += len;
+
+ return i;
+}
+
// Return how long the file at fd is, if there's any way to determine it.
off_t fdlength(int fd)
{