Root/
Source at commit HEAD created 5 years 6 days ago. By ifabio, Few update to kernelPatcher (Credits to CrazyBirdy) | |
---|---|
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(int c)␊ |
39 | {␊ |
40 | ␉return (c >= 'A' && c <= 'Z');␊ |
41 | }␊ |
42 | ␊ |
43 | static inline int islower(int c)␊ |
44 | {␊ |
45 | ␉return (c >= 'a' && c <= 'z');␊ |
46 | }␊ |
47 | ␊ |
48 | static inline int isalpha(int c)␊ |
49 | {␊ |
50 | ␉return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));␊ |
51 | }␊ |
52 | ␊ |
53 | static inline int isascii(int c)␊ |
54 | {␊ |
55 | ␉return ( (c >= 0x20) && (c < 0x7f) );␊ |
56 | }␊ |
57 | ␊ |
58 | static inline int isspace(int c)␊ |
59 | {␊ |
60 | ␉return (c == ' ' || c == '\t' || c == '\n' || c == '\12');␊ |
61 | }␊ |
62 | ␊ |
63 | static inline int isdigit(int c)␊ |
64 | {␊ |
65 | ␉return (c >= '0' && c <= '9');␊ |
66 | }␊ |
67 | ␊ |
68 | static inline int isxdigit(int c)␊ |
69 | {␊ |
70 | ␉return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));␊ |
71 | }␊ |
72 | ␊ |
73 | static inline int ispunct(int c)␊ |
74 | {␊ |
75 | ␉return (c == '.' || c == '-');␊ |
76 | }␊ |
77 | ␊ |
78 | /*␊ |
79 | * string.c␊ |
80 | */␊ |
81 | #ifndef bcopy␊ |
82 | extern void bcopy(const void * src, void * dst, size_t len);␊ |
83 | #endif␊ |
84 | ␊ |
85 | #ifndef bzero␊ |
86 | extern void bzero(void * dst, size_t len);␊ |
87 | #else␊ |
88 | #error bzero is defined.␊ |
89 | #endif␊ |
90 | ␊ |
91 | extern void␉*memset(void * dst, int c, size_t n);␊ |
92 | extern void␉*memcpy(void * dst, const void * src, size_t len);␊ |
93 | extern int␉memcmp(const void * p1, const void * p2, size_t len);␊ |
94 | extern int␉strcmp(const char * s1, const char * s2);␊ |
95 | extern int␉strncmp(const char * s1, const char * s2, size_t n);␊ |
96 | extern char␉*strcpy(char * s1, const char * s2);␊ |
97 | extern char␉*stpcpy(char * s1, const char * s2);␊ |
98 | extern char␉*strncpy(char * s1, const char * s2, size_t n);␊ |
99 | extern char␉*strpcpy(char * s1, const char * s2, size_t n);␊ |
100 | extern size_t␉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 size_t␉strlen(const char * str);␊ |
105 | extern size_t␉strlcat(char *, const char *, size_t);␊ |
106 | extern char␉*strcat(char * s1, const char * s2);␊ |
107 | extern char␉*strncat(char * s1, const char * s2, size_t n);␊ |
108 | extern char␉*strdup(const char *s1);␊ |
109 | ␊ |
110 | extern char␉*strpbrk_c(const char *s, const char *accept);␊ |
111 | extern char␉*strsep_c(char **stringp, const char *delim);␊ |
112 | extern size_t␉__strxspn_c(const char *s, const char *map, int parity);␊ |
113 | ␊ |
114 | #if STRNCASECMP␊ |
115 | extern int strncasecmp(const char *s1, const char *s2, size_t n);␊ |
116 | #endif␊ |
117 | ␊ |
118 | extern char *strchr(const char *str, int c);␊ |
119 | extern char *strbreak(const char *str, char **next, long *len);␊ |
120 | ␊ |
121 | extern uint8_t checksum8( void * start, unsigned int length );␊ |
122 | ␊ |
123 | /*␊ |
124 | * error.c␊ |
125 | */␊ |
126 | extern int␉errno;␊ |
127 | extern char␉*strerror(int errnum);␊ |
128 | ␊ |
129 | /*␊ |
130 | * strtol.c␊ |
131 | */␊ |
132 | extern long strtol(const char *nptr, char **endptr, int base);␊ |
133 | extern unsigned long strtoul(const char *nptr, char **endptr, int base);␊ |
134 | extern unsigned long long strtouq(const char *nptr, char **endptr, int base);␊ |
135 | ␊ |
136 | /*␊ |
137 | * prf.c␊ |
138 | */␊ |
139 | extern void prf(const char *fmt, va_list ap, int (*putfn_p)(), void *putfn_arg);␊ |
140 | ␊ |
141 | /*␊ |
142 | * printf.c␊ |
143 | */␊ |
144 | extern int sprintf(char *s, const char *format, ...) __attribute__((format(printf,2,3)));␊ |
145 | extern int snprintf(char *s, size_t size, const char *format, ...) __attribute__((format(printf,3,4)));␊ |
146 | extern int slvprintf(char *buffer, int len, const char *fmt, va_list arg);␊ |
147 | ␊ |
148 | /*␊ |
149 | * zalloc.c␊ |
150 | */␊ |
151 | #define malloc(size) safe_malloc(size, __FILE__, __LINE__)␊ |
152 | extern void␉malloc_init(char *start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));␊ |
153 | extern void␉*safe_malloc(size_t size,const char *file, int line);␊ |
154 | extern void␉free(void *start);␊ |
155 | extern void␉*realloc(void *ptr, size_t size);␊ |
156 | ␊ |
157 | /*␊ |
158 | * getsegbyname.c␊ |
159 | */␊ |
160 | extern struct segment_command *getsegbynamefromheader(struct mach_header *mhp, char *segname);␊ |
161 | ␊ |
162 | /*␊ |
163 | * interrupts.c␊ |
164 | */␊ |
165 | #ifdef __i386__␊ |
166 | extern int SetupInterrupts(void);␊ |
167 | static inline void EnableInterrupts(void) { __asm__ volatile ("sti"); }␊ |
168 | static inline void DisableInterrupts(void) { __asm__ volatile ("cli"); }␊ |
169 | extern void ShowInterruptCounters(void);␊ |
170 | #else␊ |
171 | static inline int SetupInterrupts(void) { return 0; }␊ |
172 | static inline void EnableInterrupts(void) { }␊ |
173 | static inline void DisableInterrupts(void) { }␊ |
174 | static inline void ShowInterruptCounters(void) { }␊ |
175 | #endif␊ |
176 | ␊ |
177 | #endif /* !__BOOT_LIBSA_H */␊ |
178 |