ReactOS  0.4.11-dev-433-g473ca91
acclib.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Name: acclib.h -- C library support. Prototypes for the (optional) local
4  * implementations of required C library functions.
5  *
6  *****************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2017, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions, and the following disclaimer,
17  * without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  * substantially similar to the "NO WARRANTY" disclaimer below
20  * ("Disclaimer") and any redistribution must be conditioned upon
21  * including a substantially similar Disclaimer requirement for further
22  * binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  * of any contributors may be used to endorse or promote products derived
25  * from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44 
45 #ifndef _ACCLIB_H
46 #define _ACCLIB_H
47 
48 
49 /*
50  * Prototypes and macros for local implementations of C library functions
51  */
52 
53 /* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */
54 
55 extern const UINT8 AcpiGbl_Ctypes[];
56 
57 #define _ACPI_XA 0x00 /* extra alphabetic - not supported */
58 #define _ACPI_XS 0x40 /* extra space */
59 #define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
60 #define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
61 #define _ACPI_DI 0x04 /* '0'-'9' */
62 #define _ACPI_LO 0x02 /* 'a'-'z' */
63 #define _ACPI_PU 0x10 /* punctuation */
64 #define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */
65 #define _ACPI_UP 0x01 /* 'A'-'Z' */
66 #define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
67 
68 #define isdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI))
69 #define isspace(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP))
70 #define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD))
71 #define isupper(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP))
72 #define islower(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO))
73 #define isprint(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
74 #define isalpha(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
75 
76 /* Error code */
77 
78 #define EPERM 1 /* Operation not permitted */
79 #define ENOENT 2 /* No such file or directory */
80 #define EINTR 4 /* Interrupted system call */
81 #define EIO 5 /* I/O error */
82 #define EBADF 9 /* Bad file number */
83 #define EAGAIN 11 /* Try again */
84 #define ENOMEM 12 /* Out of memory */
85 #define EACCES 13 /* Permission denied */
86 #define EFAULT 14 /* Bad address */
87 #define EBUSY 16 /* Device or resource busy */
88 #define EEXIST 17 /* File exists */
89 #define ENODEV 19 /* No such device */
90 #define EINVAL 22 /* Invalid argument */
91 #define EPIPE 32 /* Broken pipe */
92 #define ERANGE 34 /* Math result not representable */
93 
94 /* Strings */
95 
96 char *
97 strcat (
98  char *DstString,
99  const char *SrcString);
100 
101 char *
102 strchr (
103  const char *String,
104  int ch);
105 
106 char *
107 strpbrk (
108  const char *String,
109  const char *Delimiters);
110 
111 char *
112 strtok (
113  char *String,
114  const char *Delimiters);
115 
116 char *
117 strcpy (
118  char *DstString,
119  const char *SrcString);
120 
121 int
122 strcmp (
123  const char *String1,
124  const char *String2);
125 
126 ACPI_SIZE
127 strlen (
128  const char *String);
129 
130 char *
131 strncat (
132  char *DstString,
133  const char *SrcString,
134  ACPI_SIZE Count);
135 
136 int
137 strncmp (
138  const char *String1,
139  const char *String2,
140  ACPI_SIZE Count);
141 
142 char *
143 strncpy (
144  char *DstString,
145  const char *SrcString,
146  ACPI_SIZE Count);
147 
148 char *
149 strstr (
150  char *String1,
151  char *String2);
152 
153 
154 /* Conversion */
155 
156 UINT32
157 strtoul (
158  const char *String,
159  char **Terminator,
160  UINT32 Base);
161 
162 
163 /* Memory */
164 
165 int
166 memcmp (
167  void *Buffer1,
168  void *Buffer2,
169  ACPI_SIZE Count);
170 
171 void *
172 memcpy (
173  void *Dest,
174  const void *Src,
175  ACPI_SIZE Count);
176 
177 void *
178 memmove (
179  void *Dest,
180  const void *Src,
181  ACPI_SIZE Count);
182 
183 void *
184 memset (
185  void *Dest,
186  int Value,
187  ACPI_SIZE Count);
188 
189 
190 /* upper/lower case */
191 
192 int
193 tolower (
194  int c);
195 
196 int
197 toupper (
198  int c);
199 
200 /*
201  * utprint - printf/vprintf output functions
202  */
203 const char *
205  const char *String,
206  UINT64 *NumberPtr);
207 
208 const char *
210  char *String,
211  UINT64 Number);
212 
213 int
214 vsnprintf (
215  char *String,
216  ACPI_SIZE Size,
217  const char *Format,
218  va_list Args);
219 
220 int
221 snprintf (
222  char *String,
223  ACPI_SIZE Size,
224  const char *Format,
225  ...);
226 
227 int
228 sprintf (
229  char *String,
230  const char *Format,
231  ...);
232 
233 #ifdef ACPI_APPLICATION
234 #define SEEK_SET 0
235 #define SEEK_CUR 1
236 #define SEEK_END 2
237 
238 /*
239  * NOTE: Currently we only need to update errno for file IOs. Other
240  * Clibrary invocations in ACPICA do not make descisions according to
241  * the errno.
242  */
243 extern int errno;
244 
245 #ifndef EOF
246 #define EOF (-1)
247 #endif
248 
249 #define putchar(c) fputc(stdout, c)
250 #define getchar(c) fgetc(stdin)
251 
252 int
253 vprintf (
254  const char *Format,
255  va_list Args);
256 
257 int
258 printf (
259  const char *Format,
260  ...);
261 
262 int
263 vfprintf (
264  FILE *File,
265  const char *Format,
266  va_list Args);
267 
268 int
269 fprintf (
270  FILE *File,
271  const char *Format,
272  ...);
273 
274 FILE *
275 fopen (
276  const char *Path,
277  const char *Modes);
278 
279 void
280 fclose (
281  FILE *File);
282 
283 int
284 fread (
285  void *Buffer,
286  ACPI_SIZE Size,
287  ACPI_SIZE Count,
288  FILE *File);
289 
290 int
291 fwrite (
292  void *Buffer,
293  ACPI_SIZE Size,
294  ACPI_SIZE Count,
295  FILE *File);
296 
297 int
298 fseek (
299  FILE *File,
300  long Offset,
301  int From);
302 
303 long
304 ftell (
305  FILE *File);
306 
307 int
308 fgetc (
309  FILE *File);
310 
311 int
312 fputc (
313  FILE *File,
314  char c);
315 
316 char *
317 fgets (
318  char *s,
319  ACPI_SIZE Size,
320  FILE *File);
321 #endif
322 
323 #endif /* _ACCLIB_H */
int snprintf(char *String, ACPI_SIZE Size, const char *Format,...)
Definition: utprint.c:729
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:605
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strpbrk(const char *String, const char *Delimiters)
Definition: utclib.c:302
void * memmove(void *Dest, const void *Src, ACPI_SIZE Count)
Definition: utclib.c:145
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
static const VBE_MODE Modes[VBE_MODE_COUNT]
Definition: vbe.c:189
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2327
const char * AcpiUtPrintNumber(char *String, UINT64 Number)
Definition: utprint.c:249
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int errno
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
void * memcpy(void *Dest, const void *Src, ACPI_SIZE Count)
Definition: utclib.c:200
CHAR16 * String
Definition: acefiex.h:201
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned int UINT32
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
char * va_list
Definition: acmsvcex.h:78
char ** Args
Definition: acdebug.h:342
Definition: bufpool.h:45
UINTN Size
Definition: acefiex.h:555
int toupper(int c)
Definition: utclib.c:881
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
const GLubyte * c
Definition: glext.h:8905
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
GLdouble s
Definition: gl.h:2039
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
UINTN UINT8 Value
Definition: acefiex.h:751
int sprintf(char *String, const char *Format,...)
Definition: utprint.c:761
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
PRTL_UNICODE_STRING_BUFFER Path
void * memset(void *Dest, int Value, ACPI_SIZE Count)
Definition: utclib.c:236
int vsnprintf(char *String, ACPI_SIZE Size, const char *Format, va_list Args)
Definition: utprint.c:433
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char * strchr(const char *String, int ch)
Definition: utclib.c:501
_In_ const STRING * String2
Definition: rtlfuncs.h:2245
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
Definition: File.h:15
unsigned long long UINT64
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
const char * AcpiUtScanNumber(const char *String, UINT64 *NumberPtr)
Definition: utprint.c:217
unsigned char UINT8
int tolower(int c)
Definition: utclib.c:902
#define printf
Definition: config.h:203
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
const UINT8 AcpiGbl_Ctypes[]
Definition: utclib.c:918