8fd5384b5af936ad113d35d9a289e9ab0f0bdd2b
[reactos.git] / freeldr / freeldr / include / rtl.h
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __STDLIB_H
21 #define __STDLIB_H
22
23 #include <freeldr.h>
24
25 ///////////////////////////////////////////////////////////////////////////////////////
26 //
27 // String Functions
28 //
29 ///////////////////////////////////////////////////////////////////////////////////////
30 int strlen(char *str);
31 char * strcpy(char *dest, char *src);
32 char * strncpy(char *dest, char *src, size_t count);
33 char * strcat(char *dest, char *src);
34 char * strncat(char *dst, const char *src, size_t n);
35 char * strchr(const char *s, int c);
36 char * strrchr(const char *s, int c);
37 int strcmp(const char *string1, const char *string2);
38 int stricmp(const char *string1, const char *string2);
39 int strncmp(const char *string1, const char *string2, size_t length);
40 int strnicmp(const char *string1, const char *string2, size_t length);
41
42 ///////////////////////////////////////////////////////////////////////////////////////
43 //
44 // Memory Functions
45 //
46 ///////////////////////////////////////////////////////////////////////////////////////
47 int memcmp(const void *buf1, const void *buf2, size_t count);
48 void * memcpy(void *to, const void *from, size_t count);
49 void * memmove(void *dest, const void *src, size_t count);
50 void * memset(void *src, int val, size_t count);
51
52 #define RtlCompareMemory(Source1, Source2, Length) memcmp(Source1, Source2, Length)
53 #define RtlCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
54 #define RtlFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
55 #define RtlMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
56 #define RtlZeroMemory(Destination, Length) memset(Destination, 0, Length)
57
58 ///////////////////////////////////////////////////////////////////////////////////////
59 //
60 // Standard Library Functions
61 //
62 ///////////////////////////////////////////////////////////////////////////////////////
63 int atoi(char *string);
64 char * itoa(int value, char *string, int radix);
65 int toupper(int c);
66 int tolower(int c);
67
68 int isspace(int c);
69 int isdigit(int c);
70 int isxdigit(int c);
71
72 char * convert_to_ascii(char *buf, int c, ...);
73 char * convert_i64_to_ascii(char *buf, int c, ...);
74
75 void beep(void);
76 void delay(unsigned msec);
77 void sound(int freq);
78
79 #ifndef max
80 #define max(a, b) (((a) > (b)) ? (a) : (b))
81 #endif
82
83 #ifndef min
84 #define min(a, b) (((a) < (b)) ? (a) : (b))
85 #endif
86
87 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
88 #define UINT64_C(val) val##ULL
89
90 ///////////////////////////////////////////////////////////////////////////////////////
91 //
92 // Screen Output Functions
93 //
94 ///////////////////////////////////////////////////////////////////////////////////////
95 void print(char *str);
96 void printf(char *fmt, ...);
97 void sprintf(char *buffer, char *format, ...);
98
99 ///////////////////////////////////////////////////////////////////////////////////////
100 //
101 // List Functions
102 //
103 ///////////////////////////////////////////////////////////////////////////////////////
104
105 typedef struct _LIST_ITEM
106 {
107 struct _LIST_ITEM* ListPrev;
108 struct _LIST_ITEM* ListNext;
109
110 } LIST_ITEM, *PLIST_ITEM;
111
112 VOID RtlListInitializeHead(PLIST_ITEM ListHead); // Initializes a doubly linked list
113 VOID RtlListInsertHead(PLIST_ITEM ListHead, PLIST_ITEM Entry); // Inserts an entry at the head of the list
114 VOID RtlListInsertTail(PLIST_ITEM ListHead, PLIST_ITEM Entry); // Inserts an entry at the tail of the list
115 PLIST_ITEM RtlListRemoveHead(PLIST_ITEM ListHead); // Removes the entry at the head of the list
116 PLIST_ITEM RtlListRemoveTail(PLIST_ITEM ListHead); // Removes the entry at the tail of the list
117 PLIST_ITEM RtlListGetHead(PLIST_ITEM ListHead); // Returns the entry at the head of the list
118 PLIST_ITEM RtlListGetTail(PLIST_ITEM ListHead); // Returns the entry at the tail of the list
119 BOOL RtlListIsEmpty(PLIST_ITEM ListHead); // Indicates whether a doubly linked list is empty
120 U32 RtlListCountEntries(PLIST_ITEM ListHead); // Counts the entries in a doubly linked list
121 PLIST_ITEM RtlListGetPrevious(PLIST_ITEM ListEntry); // Returns the previous item in the list
122 PLIST_ITEM RtlListGetNext(PLIST_ITEM ListEntry); // Returns the next item in the list
123 PLIST_ITEM RtlListRemoveEntry(PLIST_ITEM ListEntry); // Removes the entry from the list
124 VOID RtlListInsertEntry(PLIST_ITEM InsertAfter, PLIST_ITEM ListEntry); // Inserts a new list entry right after the specified one
125 VOID RtlListMoveEntryPrevious(PLIST_ITEM ListEntry); // Moves the list entry to before the previous entry
126 VOID RtlListMoveEntryNext(PLIST_ITEM ListEntry); // Moves the list entry to after the next entry
127
128
129 #endif // defined __STDLIB_H