Ignore:
Timestamp:
Jul 2, 2013, 7:27:06 PM (12 years ago)
Author:
Herwig Bauernfeind
Message:

Samba Server 3.5: Update branch to 3.5.20

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/lib/replace/replace.c

    r414 r773  
    682682}
    683683#endif
     684
     685
     686#ifndef HAVE_MEMMEM
     687void *rep_memmem(const void *haystack, size_t haystacklen,
     688                 const void *needle, size_t needlelen)
     689{
     690        if (needlelen == 0) {
     691                return discard_const(haystack);
     692        }
     693        while (haystacklen >= needlelen) {
     694                char *p = memchr(haystack, *(const char *)needle,
     695                                 haystacklen-(needlelen-1));
     696                if (!p) return NULL;
     697                if (memcmp(p, needle, needlelen) == 0) {
     698                        return p;
     699                }
     700                haystack = p+1;
     701                haystacklen -= (p - (const char *)haystack) + 1;
     702        }
     703        return NULL;
     704}
     705#endif
     706
     707#if !defined(HAVE_VDPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     708int rep_vdprintf(int fd, const char *format, va_list ap)
     709{
     710        char *s = NULL;
     711        int ret;
     712
     713        vasprintf(&s, format, ap);
     714        if (s == NULL) {
     715                errno = ENOMEM;
     716                return -1;
     717        }
     718        ret = write(fd, s, strlen(s));
     719        free(s);
     720        return ret;
     721}
     722#endif
     723
     724#if !defined(HAVE_DPRINTF) || !defined(HAVE_C99_VSNPRINTF)
     725int rep_dprintf(int fd, const char *format, ...)
     726{
     727        int ret;
     728        va_list ap;
     729
     730        va_start(ap, format);
     731        ret = vdprintf(fd, format, ap);
     732        va_end(ap);
     733
     734        return ret;
     735}
     736#endif
     737
Note: See TracChangeset for help on using the changeset viewer.