Add support for Windows CE to the code base.
[platform/upstream/dbus.git] / dbus / dbus-sysdeps-wince-glue.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-sysdeps-wince-glue.h Emulation of system/libc features for Windows CE (internal to D-Bus implementation)
3  * 
4  * Copyright (C) 2002, 2003  Red Hat, Inc.
5  * Copyright (C) 2003 CodeFactory AB
6  *
7  * Licensed under the Academic Free License version 2.1
8  * 
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  * 
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #ifndef DBUS_SYSDEPS_WINCE_GLUE_H
26 #define DBUS_SYSDEPS_WINCE_GLUE_H
27
28 #include <time.h>
29 #include <stdarg.h>
30
31 #include <windows.h>
32 #undef interface
33
34 DBUS_BEGIN_DECLS
35
36 /* shlobj.h declares these only for _WIN32_IE that we don't want to define.
37    In any case, with mingw32ce we only get a SHGetSpecialFolderPath.  */
38 #define SHGetSpecialFolderPathW SHGetSpecialFolderPath
39 BOOL WINAPI SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL);
40 BOOL WINAPI SHGetSpecialFolderPathW(HWND,LPWSTR,int,BOOL);
41
42 #ifndef TLS_OUT_OF_INDEXES
43 #define TLS_OUT_OF_INDEXES 0xffffffff
44 #endif
45
46
47 /* Seriously.  Windows CE does not have errno.  Don't you hate it when
48    that happens?  */
49 #define errno (GetLastError ())
50
51 #define ENOENT          ERROR_FILE_NOT_FOUND
52 #define EMFILE          ERROR_TOO_MANY_OPEN_FILES
53 #define EACCES          ERROR_ACCESS_DENIED
54 #define EBADF           ERROR_INVALID_HANDLE
55 #define ENOMEM          ERROR_NOT_ENOUGH_MEMORY
56 #define EXDEV           ERROR_NOT_SAME_DEVICE
57 #define ENFILE          ERROR_NO_MORE_FILES
58 #define EROFS           ERROR_WRITE_PROTECT
59 #define ENOLCK          ERROR_SHARING_BUFFER_EXCEEDED
60 #define ENOSYS          ERROR_NOT_SUPPORTED
61 #define EEXIST          ERROR_FILE_EXISTS
62 #define EPERM           ERROR_CANNOT_MAKE
63 #define EINVAL          ERROR_INVALID_PARAMETER
64 #define EINTR           ERROR_INVALID_AT_INTERRUPT_TIME
65 #define EPIPE           ERROR_BROKEN_PIPE
66 #define ENOSPC          ERROR_DISK_FULL
67 #define ENOTEMPTY       ERROR_DIR_NOT_EMPTY
68 #define EBUSY           ERROR_BUSY
69 #define ENAMETOOLONG    ERROR_FILENAME_EXCED_RANGE
70 #define EAGAIN          ERROR_MORE_DATA
71 #define ENOTDIR         ERROR_DIRECTORY
72 #define ERANGE          ERROR_ARITHMETIC_OVERFLOW
73 #define ENXIO           ERROR_FILE_INVALID
74 #define EFAULT          ERROR_PROCESS_ABORTED
75 #define EIO             ERROR_IO_DEVICE
76 #define EDEADLOCK       ERROR_POSSIBLE_DEADLOCK
77 #define ENODEV          ERROR_BAD_DEVICE
78
79 /* Windows CE is missing more stuff that is pretty standard.  */
80
81 #define strdup _strdup
82 #define stricmp _stricmp
83 #define strnicmp _strnicmp
84
85 #define environ _dbus_wince_environ
86 extern char *environ[];
87
88 #define getenv _dbus_wince_getenv
89 char *getenv (const char *name);
90
91 #define putenv _dbus_wince_putenv
92 int putenv (char *str);
93
94 #define clock _dbus_wince_clock
95 clock_t clock (void);
96
97 #define abort _dbus_wince_abort
98 void abort (void);
99
100 #define _S_IFMT         0170000         /* file type mask */
101 #define _S_IFDIR        0040000         /* directory */
102 #define _S_IFCHR        0020000         /* character special */
103 #define _S_IFIFO        0010000         /* pipe */
104 #define _S_IFREG        0100000         /* regular */
105 #define _S_IREAD        0000400         /* read permission, owner */
106 #define _S_IWRITE       0000200         /* write permission, owner */
107 #define _S_IEXEC        0000100         /* execute/search permission, owner */
108 #ifndef __OFF_T_DEFINED
109 typedef long off_t;
110 #define __OFF_T_DEFINED
111 #endif
112
113 #ifndef _MAX_FNAME
114 #define _MAX_FNAME 256
115 #endif
116
117 #ifndef _IOFBF
118 #define _IOFBF  0
119 #endif
120 #ifndef _IOLBF
121 #define _IOLBF  1
122 #endif
123 #ifndef _IONBF
124 #define _IONBF  2
125 #endif
126
127
128 /* Windows CE is missing some Windows functions that we want.  */
129
130 #define GetSystemTimeAsFileTime _dbus_wince_GetSystemTimeAsFileTime
131 void GetSystemTimeAsFileTime (LPFILETIME ftp);
132
133 #define _mbsrchr _dbus_wince_mbsrchr
134 unsigned char* _mbsrchr (const unsigned char*, unsigned int);
135
136 #define OpenFileMappingA _dbus_wince_OpenFileMappingA
137 HANDLE OpenFileMappingA(DWORD,BOOL,LPCSTR);
138
139 #define MoveFileExA _dbus_wince_MoveFileExA
140 BOOL MoveFileExA(LPCSTR,LPCSTR,DWORD);
141 #ifndef MOVEFILE_REPLACE_EXISTING
142 #define MOVEFILE_REPLACE_EXISTING 0x00000001
143 #endif
144
145 #define SetHandleInformation _dbus_wince_SetHandleInformation
146 BOOL SetHandleInformation(HANDLE,DWORD,DWORD);
147 #ifndef HANDLE_FLAG_INHERIT
148 #define HANDLE_FLAG_INHERIT 0x01
149 #endif
150 #ifndef HANDLE_FLAG_PROTECT
151 #define HANDLE_FLAG_PROTECT_FROM_CLOSE 0x02
152 #endif
153
154 #define SearchPathA _dbus_wince_SearchPathA
155 DWORD SearchPathA(LPCSTR,LPCSTR,LPCSTR,DWORD,LPSTR,LPSTR*);
156
157 /* Instead of emulating all functions needed for this, we replace the
158    whole thing.  */
159 dbus_bool_t _dbus_getsid(char **sid);
160
161
162 #define LookupAccountNameW _dbus_wince_LookupAccountNameW
163 BOOL LookupAccountNameW(LPCWSTR,LPCWSTR,PSID,PDWORD,LPWSTR,PDWORD,PSID_NAME_USE);
164
165 #define IsValidSid _dbus_wince_IsValidSid
166 BOOL IsValidSid(PSID);
167
168
169 /* Windows CE does only have the UNICODE interfaces (FooW), but we
170    want to use the ASCII interfaces (FooA).  We implement them
171    here.  */
172
173 #define CreateFileA _dbus_wince_CreateFileA
174 HANDLE CreateFileA(LPCSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE);
175
176 #define DeleteFileA _dbus_wince_DeleteFileA
177 BOOL DeleteFileA(LPCSTR);
178
179 #define GetFileAttributesA _dbus_wince_GetFileAttributesA
180 DWORD GetFileAttributesA(LPCSTR);
181
182 #define GetFileAttributesExA _dbus_wince_GetFileAttributesExA
183 BOOL GetFileAttributesExA(LPCSTR,GET_FILEEX_INFO_LEVELS,PVOID);
184
185 #define CreateFileMappingA _dbus_wince_CreateFileMappingA
186 HANDLE CreateFileMappingA(HANDLE,LPSECURITY_ATTRIBUTES,DWORD,DWORD,DWORD,LPCSTR);
187
188 #define CreateDirectoryA _dbus_wince_CreateDirectoryA
189 BOOL CreateDirectoryA(LPCSTR,LPSECURITY_ATTRIBUTES);
190
191 #define RemoveDirectoryA _dbus_wince_RemoveDirectoryA
192 BOOL RemoveDirectoryA(LPCSTR);
193
194 #define FindFirstFileA _dbus_wince_FindFirstFileA
195 HANDLE FindFirstFileA(LPCSTR,LPWIN32_FIND_DATAA);
196
197 #define FindNextFileA _dbus_wince_FindNextFileA
198 BOOL FindNextFileA(HANDLE,LPWIN32_FIND_DATAA);
199
200 #define CreateMutexA _dbus_wince_CreateMutexA
201 HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES,BOOL,LPCSTR);
202
203 #define CreateProcessA _dbus_wince_CreateProcessA
204 BOOL CreateProcessA(LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,PVOID,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION);
205 #ifndef CREATE_NO_WINDOW
206 #define CREATE_NO_WINDOW 0x08000000
207 #endif
208
209
210 #define RegOpenKeyExA _dbus_wince_RegOpenKeyExA
211 LONG RegOpenKeyExA(HKEY,LPCSTR,DWORD,REGSAM,PHKEY);
212
213 #define RegQueryValueExA _dbus_wince_RegQueryValueExA
214 LONG WINAPI RegQueryValueExA(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
215
216
217 #define FormatMessageA _dbus_wince_FormatMessageA
218 DWORD FormatMessageA(DWORD,PCVOID,DWORD,DWORD,LPSTR,DWORD,va_list*);
219
220 #define GetModuleFileNameA _dbus_wince_GetModuleFileNameA
221 DWORD GetModuleFileNameA(HINSTANCE,LPSTR,DWORD);
222
223 #define GetTempPathA _dbus_wince_GetTempPathA
224 DWORD GetTempPathA(DWORD,LPSTR);
225
226 #define SHGetSpecialFolderPathA _dbus_wince_SHGetSpecialFolderPathA
227 BOOL SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL);
228
229
230 DBUS_END_DECLS
231
232 #endif /* DBUS_SYSDEPS_WINCE_GLUE_H */