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