summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strcasestr.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libc/string/strcasestr.c (renamed from src/lib/libc/net/sethostent.c)60
1 files changed, 29 insertions, 31 deletions
diff --git a/src/lib/libc/net/sethostent.c b/src/lib/libc/string/strcasestr.c
index 00f6499695..aa74c0176d 100644
--- a/src/lib/libc/net/sethostent.c
+++ b/src/lib/libc/string/strcasestr.c
@@ -1,9 +1,13 @@
1/* $NetBSD: sethostent.c,v 1.4 1995/02/25 06:21:03 cgd Exp $ */ 1/* $OpenBSD: strcasestr.c,v 1.3 2006/03/31 05:34:55 deraadt Exp $ */
2/* $NetBSD: strcasestr.c,v 1.2 2005/02/09 21:35:47 kleink Exp $ */
2 3
3/* 4/*-
4 * Copyright (c) 1985, 1993 5 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
6 * 7 *
8 * This code is derived from software contributed to Berkeley by
9 * Chris Torek.
10 *
7 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
9 * are met: 13 * are met:
@@ -12,11 +16,7 @@
12 * 2. Redistributions in binary form must reproduce the above copyright 16 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 17 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 18 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software 19 * 3. Neither the name of the University nor the names of its contributors
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software 20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission. 21 * without specific prior written permission.
22 * 22 *
@@ -33,30 +33,28 @@
33 * SUCH DAMAGE. 33 * SUCH DAMAGE.
34 */ 34 */
35 35
36#if defined(LIBC_SCCS) && !defined(lint) 36#include <ctype.h>
37#if 0 37#include <string.h>
38static char sccsid[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93";
39#else
40static char rcsid[] = "$NetBSD: sethostent.c,v 1.4 1995/02/25 06:21:03 cgd Exp $";
41#endif
42#endif /* LIBC_SCCS and not lint */
43 38
44#include <sys/param.h> 39/*
45#include <netinet/in.h> 40 * Find the first occurrence of find in s, ignore case.
46#include <arpa/nameser.h> 41 */
47#include <netdb.h> 42char *
48#include <resolv.h> 43strcasestr(const char *s, const char *find)
49
50void
51sethostent(stayopen)
52{ 44{
53 if (stayopen) 45 char c, sc;
54 _res.options |= RES_STAYOPEN | RES_USEVC; 46 size_t len;
55}
56 47
57void 48 if ((c = *find++) != 0) {
58endhostent() 49 c = (char)tolower((unsigned char)c);
59{ 50 len = strlen(find);
60 _res.options &= ~(RES_STAYOPEN | RES_USEVC); 51 do {
61 _res_close(); 52 do {
53 if ((sc = *s++) == 0)
54 return (NULL);
55 } while ((char)tolower((unsigned char)sc) != c);
56 } while (strncasecmp(s, find, len) != 0);
57 s--;
58 }
59 return ((char *)s);
62} 60}