xref: /onnv-gate/usr/src/lib/libuutil/common/uu_string.c (revision 12890:16985853e3aa)
1*12890SJoyce.McIntosh@Sun.COM /*
2*12890SJoyce.McIntosh@Sun.COM  * CDDL HEADER START
3*12890SJoyce.McIntosh@Sun.COM  *
4*12890SJoyce.McIntosh@Sun.COM  * The contents of this file are subject to the terms of the
5*12890SJoyce.McIntosh@Sun.COM  * Common Development and Distribution License (the "License").
6*12890SJoyce.McIntosh@Sun.COM  * You may not use this file except in compliance with the License.
7*12890SJoyce.McIntosh@Sun.COM  *
8*12890SJoyce.McIntosh@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12890SJoyce.McIntosh@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*12890SJoyce.McIntosh@Sun.COM  * See the License for the specific language governing permissions
11*12890SJoyce.McIntosh@Sun.COM  * and limitations under the License.
12*12890SJoyce.McIntosh@Sun.COM  *
13*12890SJoyce.McIntosh@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*12890SJoyce.McIntosh@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12890SJoyce.McIntosh@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*12890SJoyce.McIntosh@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*12890SJoyce.McIntosh@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*12890SJoyce.McIntosh@Sun.COM  *
19*12890SJoyce.McIntosh@Sun.COM  * CDDL HEADER END
20*12890SJoyce.McIntosh@Sun.COM  */
21*12890SJoyce.McIntosh@Sun.COM 
22*12890SJoyce.McIntosh@Sun.COM /*
23*12890SJoyce.McIntosh@Sun.COM  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24*12890SJoyce.McIntosh@Sun.COM  */
25*12890SJoyce.McIntosh@Sun.COM 
26*12890SJoyce.McIntosh@Sun.COM /*
27*12890SJoyce.McIntosh@Sun.COM  * String helper functions
28*12890SJoyce.McIntosh@Sun.COM  */
29*12890SJoyce.McIntosh@Sun.COM 
30*12890SJoyce.McIntosh@Sun.COM #include <string.h>
31*12890SJoyce.McIntosh@Sun.COM #include <sys/types.h>
32*12890SJoyce.McIntosh@Sun.COM #include <stdio.h>
33*12890SJoyce.McIntosh@Sun.COM #include <malloc.h>
34*12890SJoyce.McIntosh@Sun.COM #include <ctype.h>
35*12890SJoyce.McIntosh@Sun.COM #include "libuutil.h"
36*12890SJoyce.McIntosh@Sun.COM 
37*12890SJoyce.McIntosh@Sun.COM /* Return true if strings are equal */
38*12890SJoyce.McIntosh@Sun.COM boolean_t
uu_streq(const char * a,const char * b)39*12890SJoyce.McIntosh@Sun.COM uu_streq(const char *a, const char *b)
40*12890SJoyce.McIntosh@Sun.COM {
41*12890SJoyce.McIntosh@Sun.COM 	return (strcmp(a, b) == 0);
42*12890SJoyce.McIntosh@Sun.COM }
43*12890SJoyce.McIntosh@Sun.COM 
44*12890SJoyce.McIntosh@Sun.COM /* Return true if strings are equal, case-insensitively */
45*12890SJoyce.McIntosh@Sun.COM boolean_t
uu_strcaseeq(const char * a,const char * b)46*12890SJoyce.McIntosh@Sun.COM uu_strcaseeq(const char *a, const char *b)
47*12890SJoyce.McIntosh@Sun.COM {
48*12890SJoyce.McIntosh@Sun.COM 	return (strcasecmp(a, b) == 0);
49*12890SJoyce.McIntosh@Sun.COM }
50*12890SJoyce.McIntosh@Sun.COM 
51*12890SJoyce.McIntosh@Sun.COM /* Return true if string a Begins With string b */
52*12890SJoyce.McIntosh@Sun.COM boolean_t
uu_strbw(const char * a,const char * b)53*12890SJoyce.McIntosh@Sun.COM uu_strbw(const char *a, const char *b)
54*12890SJoyce.McIntosh@Sun.COM {
55*12890SJoyce.McIntosh@Sun.COM 	return (strncmp(a, b, strlen(b)) == 0);
56*12890SJoyce.McIntosh@Sun.COM }
57