4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1991-1995, by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * The routines are NOT part of the interface, merely internal
31 * utilities which assist in making the interface standalone.
34 #include <sys/promif.h>
35 #include <sys/promimpl.h>
38 * a version of string copy that is bounded
41 prom_strncpy(register char *s1
, register char *s2
, size_t n
)
43 register char *os1
= s1
;
46 while (--n
!= 0 && (*s1
++ = *s2
++) != '\0')
55 * and one that knows no bounds
58 prom_strcpy(register char *s1
, register char *s2
)
69 * a copy of string compare that is bounded
72 prom_strncmp(register char *s1
, register char *s2
, register size_t n
)
77 while (--n
!= 0 && *s1
== *s2
++)
80 return ((n
== 0) ? 0: (*s1
- s2
[-1]));
84 * and one that knows no bounds
87 prom_strcmp(register char *s1
, register char *s2
)
96 * finds the length of a succession of non-NULL chars
99 prom_strlen(register char *s
)
110 * return the ptr in sp at which the character c last
111 * appears; 0 if not found
114 prom_strrchr(register char *sp
, register char c
)
118 for (r
= (char *)0; *sp
!= '\0'; ++sp
)
125 * Concatenate string s2 to string s1
128 prom_strcat(register char *s1
, register char *s2
)
132 while ((*s1
) != '\0')
133 s1
++; /* find the end of string s1 */
135 while (*s1
++ = *s2
++) /* Concatenate s2 */
141 * Return the ptr in sp at which the character c first
142 * appears; NULL if not found
145 prom_strchr(register const char *sp
, register int c
)