~ubuntu-branches/ubuntu/gutsy/amsn/gutsy

« back to all changes in this revision

Viewing changes to utils/linux/capture/libng/misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Theodore Karkoulis
  • Date: 2006-01-04 15:26:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060104152602-ipe1yg00rl3nlklv
Tags: 0.95-1
New Upstream Release (closes: #345052, #278575).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "config.h"
 
2
 
 
3
#include <stdio.h>
 
4
#include <stdlib.h>
 
5
 
 
6
#include "grab-ng.h"
 
7
#include "misc.h"
 
8
 
 
9
/* ------------------------------------------------------------------------ */
 
10
/* prehistoric libc ;)                                                      */
 
11
 
 
12
#ifndef HAVE_STRCASESTR
 
13
char* __used strcasestr(char *haystack, char *needle)
 
14
{
 
15
    int hlen = strlen(haystack);
 
16
    int nlen = strlen(needle);
 
17
    int offset;
 
18
 
 
19
    for (offset = 0; offset <= hlen - nlen; offset++)
 
20
        if (0 == strncasecmp(haystack+offset,needle,nlen))
 
21
            return haystack+offset;
 
22
    return NULL;
 
23
}
 
24
#endif
 
25
 
 
26
#ifndef HAVE_MEMMEM
 
27
void __used *memmem(unsigned char *haystack, size_t haystacklen,
 
28
                    unsigned char *needle, size_t needlelen)
 
29
{
 
30
    int i;
 
31
 
 
32
    for (i = 0; i < haystacklen - needlelen; i++)
 
33
        if (0 == memcmp(haystack+i,needle,needlelen))
 
34
            return haystack+i;
 
35
    return NULL;
 
36
}
 
37
#endif