106c1483markm/*
206c1483markm * Copyright (c) 1987 Regents of the University of California.
306c1483markm * All rights reserved.
406c1483markm *
506c1483markm * Redistribution and use in source and binary forms are permitted
606c1483markm * provided that the above copyright notice and this paragraph are
706c1483markm * duplicated in all such forms and that any documentation,
806c1483markm * advertising materials, and other materials related to such
906c1483markm * distribution and use acknowledge that the software was developed
1006c1483markm * by the University of California, Berkeley.  The name of the
1106c1483markm * University may not be used to endorse or promote products derived
1206c1483markm * from this software without specific prior written permission.
1306c1483markm * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1406c1483markm * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1506c1483markm * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1606c1483markm */
1706c1483markm
1806c1483markm#if defined(LIBC_SCCS) && !defined(lint)
1906c1483markmstatic char sccsid[] = "@(#)strcasecmp.c	5.6 (Berkeley) 6/27/88";
2006c1483markm#endif /* LIBC_SCCS and not lint */
2106c1483markm
2206c1483markm/* Some environments don't define u_char -- WZV */
2306c1483markm#if 0
2406c1483markm#include <sys/types.h>
2506c1483markm#else
2606c1483markmtypedef unsigned char u_char;
2706c1483markm#endif
2806c1483markm
2906c1483markm/*
3006c1483markm * This array is designed for mapping upper and lower case letter
3106c1483markm * together for a case independent comparison.  The mappings are
3206c1483markm * based upon ascii character sequences.
3306c1483markm */
3406c1483markmstatic u_char charmap[] = {
3506c1483markm	'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
3606c1483markm	'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
3706c1483markm	'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
3806c1483markm	'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
3906c1483markm	'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
4006c1483markm	'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
4106c1483markm	'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
4206c1483markm	'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
4306c1483markm	'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
4406c1483markm	'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
4506c1483markm	'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
4606c1483markm	'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
4706c1483markm	'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
4806c1483markm	'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
4906c1483markm	'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
5006c1483markm	'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
5106c1483markm	'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
5206c1483markm	'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
5306c1483markm	'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
5406c1483markm	'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
5506c1483markm	'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
5606c1483markm	'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
5706c1483markm	'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
5806c1483markm	'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
5906c1483markm	'\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
6006c1483markm	'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
6106c1483markm	'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
6206c1483markm	'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
6306c1483markm	'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
6406c1483markm	'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
6506c1483markm	'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
6606c1483markm	'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
6706c1483markm};
6806c1483markm
6906c1483markmstrcasecmp(s1, s2)
7006c1483markm	char *s1, *s2;
7106c1483markm{
7206c1483markm	register u_char	*cm = charmap,
7306c1483markm			*us1 = (u_char *)s1,
7406c1483markm			*us2 = (u_char *)s2;
7506c1483markm
7606c1483markm	while (cm[*us1] == cm[*us2++])
7706c1483markm		if (*us1++ == '\0')
7806c1483markm			return(0);
7906c1483markm	return(cm[*us1] - cm[*--us2]);
8006c1483markm}
8106c1483markm
8206c1483markmstrncasecmp(s1, s2, n)
8306c1483markm	char *s1, *s2;
8406c1483markm	register int n;
8506c1483markm{
8606c1483markm	register u_char	*cm = charmap,
8706c1483markm			*us1 = (u_char *)s1,
8806c1483markm			*us2 = (u_char *)s2;
8906c1483markm
9006c1483markm	while (--n >= 0 && cm[*us1] == cm[*us2++])
9106c1483markm		if (*us1++ == '\0')
9206c1483markm			return(0);
9306c1483markm	return(n < 0 ? 0 : cm[*us1] - cm[*--us2]);
9406c1483markm}
95