aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-06-09 07:12:49 -0500
committerRob Landley <rob@landley.net>2014-06-09 07:12:49 -0500
commit8115fc121c0ee0b11ba2752438ff500cce48e347 (patch)
tree97a41f560ce8556fae7b13469c5d4d38cc4bd5ff /lib
parente031a5e24e5b0479717474d5d08ca9abda2f580a (diff)
downloadtoybox-8115fc121c0ee0b11ba2752438ff500cce48e347.tar.gz
Forgot to check in strstart().
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c10
-rw-r--r--lib/lib.h1
2 files changed, 11 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)
{
diff --git a/lib/lib.h b/lib/lib.h
index a246618b..dfbe5e1c 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -145,6 +145,7 @@ long atolx(char *c);
long atolx_range(char *numstr, long low, long high);
int numlen(long l);
int stridx(char *haystack, char needle);
+int strstart(char **a, char *b);
off_t fdlength(int fd);
void loopfiles_rw(char **argv, int flags, int permissions, int failok,
void (*function)(int fd, char *name));