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