blob: fbd1a55db8f3b0edb1587ddd398b442907abb15e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* $Id: compat.c,v 1.2 1997/04/13 05:51:35 dps Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif /* HAVE_CTYPE_H */
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HAVE_STRCASECMP
int strcasecmp(const char *s, const char *t)
{
register unsigned char a,b;
while (*s && *t)
{
a=tolower(*s);
b=tolower(*t);
if (a<b)
return -1;
if (a>b)
return 1;
s++;
t++;
}
if (*s!='\0')
return -1;
if (*t!='\0')
return 1;
return 0;
}
#endif
#ifndef HAVE_STRNCASECMP
int strncasecmp(const char *s, const char *t, int n)
{
register unsigned char a,b;
while (*s && *t)
{
if (n--==0)
return 0;
a=tolower(*s);
b=tolower(*t);
if (a<b)
return -1;
if (a>b)
return 1;
s++;
t++;
}
if (*s!='\0')
return -1;
if (*t!='\0')
return 1;
return 0;
}
#endif
#ifndef HAVE_STRDUP
char *strdup(const char *s)
{
char *t;
t=malloc(strlen(s)+1);
strcpy(t,s);
return t;
}
#endif /* HAVE_STRDUP */
#ifdef __cplusplus
}
#endif
|