Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/libsa/libsa.h

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
64extern char * strbreak(const char *str, char **next, long *len);
65extern int ptol(const char * str);
66
67extern voidbcopy(const void *, void *, size_t);
68extern voidbzero(void *, size_t);
69
70extern void*memcpy(void *, const void *, size_t);
71extern intmemcmp(const void *, const void *, size_t);
72extern void*memmove(void *, const void *, size_t);
73extern void*memset(void *, int, size_t);
74
75extern size_tstrlen(const char *);
76extern size_tstrnlen(const char *, size_t);
77
78/* strcpy() is being deprecated. Please use strlcpy() instead. */
79extern char*strcpy(char *, const char *);
80extern char*strncpy(char *, const char *, size_t);
81
82extern size_tstrlcat(char *, const char *, size_t);
83extern size_tstrlcpy(char *, const char *, size_t);
84
85/* strcat() is being deprecated. Please use strlcat() instead. */
86extern char*strcat(char *, const char *);
87extern char * strncat(char * s1, const char * s2, size_t n);
88
89/* strcmp() is being deprecated. Please use strncmp() instead. */
90extern intstrcmp(const char *, const char *);
91extern intstrncmp(const char *,const char *, size_t);
92
93#if STRNCASECMP
94extern intstrcasecmp(const char *s1, const char *s2);
95extern intstrncasecmp(const char *s1, const char *s2, size_t n);
96#endif
97extern char*strdup(const char *);
98extern char*strchr(const char *s, int c);
99extern int atoi(const char *);
100extern char *itoa(int,char*);
101extern const char *strstr(const char *, const char *);
102
103extern uint8_t checksum8( void * start, unsigned int length );
104extern unsigned long
105adler32( unsigned char * buffer, long length );
106
107/*
108 * strtol.c
109 */
110extern long strtol(const char * nptr, char ** endptr, int base);
111extern unsigned long strtoul(const char * nptr, char ** endptr, int base);
112extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);
113
114/*
115 * prf.c
116 */
117extern int prf(const char * fmt, va_list ap, void (*putfn_p)(),
118 void * putfn_arg);
119
120/*
121 * printf.c
122 */
123extern int sprintf(char *s, const char * format, ...);
124extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
125
126/*
127 * zalloc.c
128 */
129
130extern void free(void * start);
131extern void * realloc(void * ptr, size_t size);
132
133//#if SAFE_MALLOC
134//extern size_t zalloced_size;
135//#endif
136
137extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t));
138extern 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
147extern int rand (void);
148extern void srand (unsigned int seed);
149
150
151/*
152 * C_Exception.c
153 *
154 */
155extern voidexception_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

Archive Download this file

Revision: 1809