diff options
author | Christoph Junghans <ottxor@gentoo.org> | 2012-05-17 00:43:06 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-05-17 00:44:06 -0400 |
commit | a9f55f411d42fc5f60c099d7d9bc432f0be3852d (patch) | |
tree | 95e7ec59a7ae41b4e662f14abf0445fcb3ee450c | |
parent | improve local symlink management (diff) | |
download | rpm2targz-a9f55f411d42fc5f60c099d7d9bc432f0be3852d.tar.gz rpm2targz-a9f55f411d42fc5f60c099d7d9bc432f0be3852d.tar.bz2 rpm2targz-a9f55f411d42fc5f60c099d7d9bc432f0be3852d.zip |
rpmoffset: provide a local memmem for non-glibc systems
URL: https://bugs.gentoo.org/397835
Reported-by: Christoph Junghans <ottxor@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | rpmoffset.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/rpmoffset.c b/rpmoffset.c index 0a3c488..628af93 100644 --- a/rpmoffset.c +++ b/rpmoffset.c @@ -19,6 +19,26 @@ # define BUFSIZ 8192 #endif +#if !defined(__GLIBC__) +static void *rp_memmem(const void *buf, size_t buflen, const void *pattern, size_t len) +{ + char *bf = (char *)buf, *pt = (char *)pattern, *p = bf; + + while (len <= (buflen - (p - bf))) { + if (NULL != (p = memchr(p, (int)(*pt), buflen - (p - bf)))) { + if (0 == memcmp(p, pattern, len)) + return p; + else + ++p; + } + else + break; + } + return NULL; +} +#define memmem(a,b,c,d) rp_memmem(a,b,c,d) +#endif + typedef struct { const char *type; const unsigned char *magic; |