1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | */␊ |
24 | ␊ |
25 | #ifndef __BOOT_LIBSA_H␊ |
26 | #define __BOOT_LIBSA_H␊ |
27 | ␊ |
28 | /* Exported API for standalone library */␊ |
29 | ␊ |
30 | #include <mach-o/loader.h>␊ |
31 | #include <stdarg.h>␊ |
32 | #include <stddef.h>␊ |
33 | #include <stdbool.h>␊ |
34 | ␊ |
35 | /*␊ |
36 | * ctype stuff (aserebln)␊ |
37 | */␊ |
38 | static inline int isupper(char c)␊ |
39 | {␊ |
40 | return (c >= 'A' && c <= 'Z');␊ |
41 | }␊ |
42 | ␊ |
43 | static inline int islower(char c)␊ |
44 | {␊ |
45 | return (c >= 'a' && c <= 'z');␊ |
46 | }␊ |
47 | ␊ |
48 | static inline int isalpha(char c)␊ |
49 | {␊ |
50 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));␊ |
51 | }␊ |
52 | ␊ |
53 | static inline int isspace(char c)␊ |
54 | {␊ |
55 | return (c == ' ' || c == '\t' || c == '\n' || c == '\12');␊ |
56 | }␊ |
57 | ␊ |
58 | static inline int isdigit(char c)␊ |
59 | {␊ |
60 | return (c >= '0' && c <= '9');␊ |
61 | }␊ |
62 | ␊ |
63 | static inline int isxdigit(char c)␊ |
64 | {␊ |
65 | return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));␊ |
66 | }␊ |
67 | ␊ |
68 | ␊ |
69 | /*␊ |
70 | * string.c␊ |
71 | */␊ |
72 | #ifndef bcopy␊ |
73 | extern void bcopy(const void * src, void * dst, size_t len);␊ |
74 | #endif␊ |
75 | ␊ |
76 | #ifndef bzero␊ |
77 | extern void bzero(void * dst, size_t len);␊ |
78 | #endif␊ |
79 | ␊ |
80 | extern void * memset(void * dst, int c, size_t n);␊ |
81 | extern void * memcpy(void * dst, const void * src, size_t len);␊ |
82 | extern int memcmp(const void * p1, const void * p2, int len);␊ |
83 | extern int strcmp(const char * s1, const char * s2);␊ |
84 | extern int strncmp(const char * s1, const char * s2, size_t n);␊ |
85 | extern char * strcpy(char * s1, const char * s2);␊ |
86 | extern char * strncpy(char * s1, const char * s2, size_t n);␊ |
87 | extern char * strlcpy(char * s1, const char * s2, size_t n);␊ |
88 | extern char * strstr(const char *in, const char *str);␊ |
89 | extern int atoi(const char * str);␊ |
90 | extern int ptol(const char * str);␊ |
91 | extern int strlen(const char * str);␊ |
92 | extern char * strcat(char * s1, const char * s2);␊ |
93 | extern char * strncat(char * s1, const char * s2, size_t n);␊ |
94 | extern char * strdup(const char *s1);␊ |
95 | ␊ |
96 | #if STRNCASECMP␊ |
97 | extern int strncasecmp(const char * s1, const char * s2, size_t n);␊ |
98 | #endif␊ |
99 | ␊ |
100 | extern uint8_t checksum8( void * start, unsigned int length );␊ |
101 | ␊ |
102 | /*␊ |
103 | * error.c␊ |
104 | */␊ |
105 | extern int errno;␊ |
106 | extern char * strerror(int errnum);␊ |
107 | ␊ |
108 | /*␊ |
109 | * strtol.c␊ |
110 | */␊ |
111 | extern long strtol(const char * nptr, char ** endptr, int base);␊ |
112 | extern unsigned long strtoul(const char * nptr, char ** endptr, int base);␊ |
113 | extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);␊ |
114 | ␊ |
115 | /*␊ |
116 | * prf.c␊ |
117 | */␊ |
118 | extern void prf(const char * fmt, va_list ap, void (*putfn_p)(),␊ |
119 | void * putfn_arg);␊ |
120 | ␊ |
121 | /*␊ |
122 | * printf.c␊ |
123 | */␊ |
124 | extern int sprintf(char *s, const char * format, ...);␊ |
125 | extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);␊ |
126 | ␊ |
127 | /*␊ |
128 | * zalloc.c␊ |
129 | */␊ |
130 | #define malloc(size)␉safe_malloc(size, __FILE__, __LINE__)␊ |
131 | extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));␊ |
132 | extern void * safe_malloc(size_t size,const char *file, int line);␊ |
133 | extern void free(void * start);␊ |
134 | extern void * realloc(void * ptr, size_t size);␊ |
135 | ␊ |
136 | /*␊ |
137 | * getsegbyname.c␊ |
138 | */␊ |
139 | extern struct segment_command *␊ |
140 | getsegbynamefromheader(struct mach_header * mhp, char * segname);␊ |
141 | ␊ |
142 | #endif /* !__BOOT_LIBSA_H */␊ |
143 | |