Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/libsa/libsa.h

Source at commit 426 created 13 years 10 months ago.
By azimutz, Doc edit. CHANGES.txt and README.txt are final for now, though README can suffer changes at any time, since it's an introduction file. On to FileLoad.txt and TODO.txt.
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 */
38static inline int isupper(char c)
39{
40 return (c >= 'A' && c <= 'Z');
41}
42
43static inline int islower(char c)
44{
45 return (c >= 'a' && c <= 'z');
46}
47
48static inline int isalpha(char c)
49{
50 return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
51}
52
53static inline int isascii(char c)
54{
55 return ( (c >= 0x20) && (c < 0x7f) );
56}
57
58static inline int isspace(char c)
59{
60 return (c == ' ' || c == '\t' || c == '\n' || c == '\12');
61}
62
63static inline int isdigit(char c)
64{
65 return (c >= '0' && c <= '9');
66}
67
68static inline int isxdigit(char c)
69{
70 return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
71}
72
73
74/*
75 * string.c
76 */
77#ifndef bcopy
78extern void bcopy(const void * src, void * dst, size_t len);
79#endif
80
81#ifndef bzero
82extern void bzero(void * dst, size_t len);
83#endif
84
85extern void * memset(void * dst, int c, size_t n);
86extern void * memcpy(void * dst, const void * src, size_t len);
87extern int memcmp(const void * p1, const void * p2, int len);
88extern int strcmp(const char * s1, const char * s2);
89extern int strncmp(const char * s1, const char * s2, size_t n);
90extern char * strcpy(char * s1, const char * s2);
91extern char * strncpy(char * s1, const char * s2, size_t n);
92extern char * strlcpy(char * s1, const char * s2, size_t n);
93extern char * strstr(const char *in, const char *str);
94extern int atoi(const char * str);
95extern int ptol(const char * str);
96extern int strlen(const char * str);
97extern char * strcat(char * s1, const char * s2);
98extern char * strncat(char * s1, const char * s2, size_t n);
99extern char * strdup(const char *s1);
100
101#if STRNCASECMP
102extern int strncasecmp(const char * s1, const char * s2, size_t n);
103#endif
104
105extern uint8_t checksum8( void * start, unsigned int length );
106
107/*
108 * error.c
109 */
110extern int errno;
111extern char * strerror(int errnum);
112
113/*
114 * strtol.c
115 */
116extern long strtol(const char * nptr, char ** endptr, int base);
117extern unsigned long strtoul(const char * nptr, char ** endptr, int base);
118extern unsigned long long strtouq(const char *nptr, char ** endptr, int base);
119
120/*
121 * prf.c
122 */
123extern void prf(const char * fmt, va_list ap, void (*putfn_p)(),
124 void * putfn_arg);
125
126/*
127 * printf.c
128 */
129extern int sprintf(char *s, const char * format, ...);
130extern int slvprintf(char * buffer, int len, const char * fmt, va_list arg);
131
132/*
133 * zalloc.c
134 */
135#define malloc(size)safe_malloc(size, __FILE__, __LINE__)
136extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
137extern void * safe_malloc(size_t size,const char *file, int line);
138extern void free(void * start);
139extern void * realloc(void * ptr, size_t size);
140
141/*
142 * getsegbyname.c
143 */
144extern struct segment_command *
145 getsegbynamefromheader(struct mach_header * mhp, char * segname);
146
147#endif /* !__BOOT_LIBSA_H */
148

Archive Download this file

Revision: 426