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 | #if 0␊ |
35 | #include "C_Exception.h"␊ |
36 | #endif␊ |
37 | ␊ |
38 | /*␊ |
39 | * ctype stuff (aserebln)␊ |
40 | */␊ |
41 | static inline int isupper(char c)␊ |
42 | {␊ |
43 | return (c >= 'A' && c <= 'Z');␊ |
44 | }␊ |
45 | ␊ |
46 | static inline int islower(char c)␊ |
47 | {␊ |
48 | return (c >= 'a' && c <= 'z');␊ |
49 | }␊ |
50 | ␊ |
51 | static inline int isalpha(char c)␊ |
52 | {␊ |
53 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));␊ |
54 | }␊ |
55 | ␊ |
56 | static inline int isascii(char c)␊ |
57 | {␊ |
58 | return ( (c >= 0x20) && (c < 0x7f) );␊ |
59 | }␊ |
60 | ␊ |
61 | static inline int isspace(char c)␊ |
62 | {␊ |
63 | return (c == ' ' || c == '\t' || c == '\n' || c == '\12');␊ |
64 | }␊ |
65 | ␊ |
66 | static inline int isdigit(char c)␊ |
67 | {␊ |
68 | return (c >= '0' && c <= '9');␊ |
69 | }␊ |
70 | ␊ |
71 | static inline int isxdigit(char c)␊ |
72 | {␊ |
73 | return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));␊ |
74 | }␊ |
75 | ␊ |
76 | //Azi: TODO - add more ponctuation characters as needed; at least these two, i need for PartNo.␊ |
77 | static inline int ispunct(char c)␊ |
78 | {␊ |
79 | return (c == '.' || c == '-');␊ |
80 | }␊ |
81 | ␊ |
82 | /*␊ |
83 | * string.c␊ |
84 | */␊ |
85 | #ifndef bcopy␊ |
86 | extern void bcopy(const void * src, void * dst, size_t len);␊ |
87 | #endif␊ |
88 | ␊ |
89 | #ifndef bzero␊ |
90 | extern void bzero(void * dst, size_t len);␊ |
91 | #endif␊ |
92 | ␊ |
93 | extern void * memset(void * dst, int c, size_t n);␊ |
94 | extern void * memcpy(void * dst, const void * src, size_t len);␊ |
95 | extern int memcmp(const void * p1, const void * p2, int len);␊ |
96 | extern int strcmp(const char * s1, const char * s2);␊ |
97 | extern int strncmp(const char * s1, const char * s2, size_t n);␊ |
98 | extern char * strcpy(char * s1, const char * s2);␊ |
99 | extern char * strncpy(char * s1, const char * s2, size_t n);␊ |
100 | extern char * strlcpy(char * s1, const char * s2, size_t n);␊ |
101 | extern char * strstr(const char *in, const char *str);␊ |
102 | extern int atoi(const char * str);␊ |
103 | extern int ptol(const char * str);␊ |
104 | extern int strlen(const char * str);␊ |
105 | extern char * strcat(char * s1, const char * s2);␊ |
106 | extern char * strncat(char * s1, const char * s2, size_t n);␊ |
107 | extern char * strdup(const char *s1);␊ |
108 | ␊ |
109 | #if STRNCASECMP␊ |
110 | extern int strncasecmp(const char * s1, const char * s2, size_t n);␊ |
111 | #endif␊ |
112 | ␊ |
113 | extern char * strchr(const char *str, int c);␊ |
114 | extern char * strbreak(const char *str, char **next, long *len);␊ |
115 | ␊ |
116 | extern uint8_t checksum8( void * start, unsigned int length );␊ |
117 | ␊ |
118 | extern unsigned long␊ |
119 | adler32( unsigned char * buffer, long length );␊ |
120 | /*␊ |
121 | * error.c␊ |
122 | */␊ |
123 | extern int errno;␊ |
124 | #if UNUSED␊ |
125 | extern char * strerror(int errnum);␊ |
126 | #endif ␊ |
127 | /*␊ |
128 | * strtol.c␊ |
129 | */␊ |
130 | extern long strtol(const char * nptr, char ** endptr, int base);␊ |
131 | extern unsigned long strtoul(const char * nptr, char ** endptr, int base);␊ |
132 | extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);␊ |
133 | ␊ |
134 | /*␊ |
135 | * prf.c␊ |
136 | */␊ |
137 | extern void prf(const char * fmt, va_list ap, void (*putfn_p)(),␊ |
138 | void * putfn_arg);␊ |
139 | ␊ |
140 | /*␊ |
141 | * printf.c␊ |
142 | */␊ |
143 | extern int sprintf(char *s, const char * format, ...);␊ |
144 | extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);␊ |
145 | ␊ |
146 | /*␊ |
147 | * zalloc.c␊ |
148 | */␊ |
149 | ␊ |
150 | extern void free(void * start);␊ |
151 | extern void * realloc(void * ptr, size_t size);␊ |
152 | ␊ |
153 | //#if SAFE_MALLOC␊ |
154 | //extern size_t zalloced_size;␊ |
155 | //#endif␊ |
156 | ␊ |
157 | extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t));␊ |
158 | extern void * malloc(size_t size);␊ |
159 | ␊ |
160 | /*␊ |
161 | * rand.c␊ |
162 | *␊ |
163 | * rand & srand implementation for chameleon by Cadet-petit Armel <armelcadetpetit@gmail.com>␊ |
164 | */␊ |
165 | ␊ |
166 | ␊ |
167 | extern int rand (void);␊ |
168 | extern void srand (unsigned int seed);␊ |
169 | ␊ |
170 | ␊ |
171 | /*␊ |
172 | * C_Exception.c␊ |
173 | *␊ |
174 | */␊ |
175 | extern void␉␉exception_init (void (*exception_err_fn)(char *, int));␊ |
176 | ␊ |
177 | /*␊ |
178 | * getsegbyname.c␊ |
179 | */␊ |
180 | //extern struct segment_command *␊ |
181 | // getsegbynamefromheader(struct mach_header * mhp, char * segname);␊ |
182 | ␊ |
183 | #endif /* !__BOOT_LIBSA_H */␊ |
184 | |