# HG changeset patch # User Rob Landley # Date 1402315969 18000 # Node ID b7598d21ca10255012074721ad116d8923096de0 # Parent 788c6c097fa2ce83240640cd6a29d44ec346b949 Forgot to check in strstart(). diff -r 788c6c097fa2 -r b7598d21ca10 lib/lib.c --- a/lib/lib.c Mon Jun 09 07:07:33 2014 -0500 +++ b/lib/lib.c Mon Jun 09 07:12:49 2014 -0500 @@ -280,6 +280,16 @@ 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 -r 788c6c097fa2 -r b7598d21ca10 lib/lib.h --- a/lib/lib.h Mon Jun 09 07:07:33 2014 -0500 +++ b/lib/lib.h Mon Jun 09 07:12:49 2014 -0500 @@ -145,6 +145,7 @@ 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));