]>
git.saurik.com Git - apple/boot.git/blob - i386/boot1u/string.c
75a037def230694adc058cfb81ca2e8c814051cc
2 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* string operations */
29 void * memset(void * dst
, int val
, size_t len
)
32 : "=c" (len
), "=D" (dst
)
33 : "0" (len
), "1" (dst
), "a" (val
)
39 void * memcpy(void * dst
, const void * src
, size_t len
)
42 : "=c" (len
), "=D" (dst
), "=S" (src
)
43 : "0" (len
), "1" (dst
), "2" (src
)
49 void bcopy(const void * src
, void * dst
, size_t len
)
51 memcpy(dst
, src
, len
);
54 void bzero(void * dst
, size_t len
)
60 /* #if DONT_USE_GCC_BUILT_IN_STRLEN */
62 #define tolower(c) ((int)((c) & ~0x20))
63 #define toupper(c) ((int)((c) | 0x20))
65 int strlen(const char * s
)
76 strcmp(const char * s1
, const char * s2
)
78 while (*s1
&& (*s1
== *s2
)) {
86 int strncmp(const char * s1
, const char * s2
, size_t len
)
89 while (--n
>= 0 && *s1
== *s2
++)
92 return(n
<0 ? 0 : *s1
- *--s2
);
96 strcpy(char * s1
, const char * s2
)
98 register char *ret
= s1
;
106 strncpy(char * s1
, const char * s2
, size_t n
)
108 register char *ret
= s1
;
109 while (n
&& (*s1
++ = *s2
++))
115 strlcpy(char * s1
, const char * s2
, size_t n
)
117 register char *ret
= s1
;
118 while (n
&& (*s1
++ = *s2
++))
126 ptol(const char *str
)
128 register int c
= *str
;
130 if (c
<= '7' && c
>= '0')
132 else if (c
<= 'h' && c
>= 'a')
140 atoi(const char *str
)
142 register int sum
= 0;
143 while (*str
== ' ' || *str
== '\t')
145 while (*str
>= '0' && *str
<= '9') {
153 char *strncat(char *s1
, const char *s2
, size_t n
)
155 register char *ret
= s1
;
164 char *strcat(char *s1
, const char *s2
)
166 return(strncat(s1
, s2
, strlen(s2
)));
170 int strncasecmp(const char *s1
, const char *s2
, size_t len
)
172 register int n
= len
;
173 while (--n
>= 0 && tolower(*s1
) == tolower(*s2
++))
176 return(n
<0 ? 0 : tolower(*s1
) - tolower(*--s2
));