summaryrefslogtreecommitdiff
path: root/dbus/dbus-sysdeps-wince-glue.h
blob: f5ac6c8a0eb2ee0e018a04c940303f6cbba4c6eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-sysdeps-wince-glue.h Emulation of system/libc features for Windows CE (internal to D-Bus implementation)
 * 
 * Copyright (C) 2002, 2003  Red Hat, Inc.
 * Copyright (C) 2003 CodeFactory AB
 *
 * Licensed under the Academic Free License version 2.1
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef DBUS_SYSDEPS_WINCE_GLUE_H
#define DBUS_SYSDEPS_WINCE_GLUE_H

#include <time.h>
#include <stdarg.h>

/* For getaddrinfo, configure/cmake defined _WIN32_WCE to something >= 0x0401.  */
#include <windows.h>
#undef interface

DBUS_BEGIN_DECLS

/* shlobj.h declares these only for _WIN32_IE that we don't want to define.
   In any case, with mingw32ce we only get a SHGetSpecialFolderPath.  */
#define SHGetSpecialFolderPathW SHGetSpecialFolderPath
BOOL WINAPI SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL);
BOOL WINAPI SHGetSpecialFolderPathW(HWND,LPWSTR,int,BOOL);

#ifndef TLS_OUT_OF_INDEXES
#define TLS_OUT_OF_INDEXES 0xffffffff
#endif


/* Seriously.  Windows CE does not have errno.  Don't you hate it when
   that happens?  */
#define errno ((int)GetLastError ())

#define ENOENT          ERROR_FILE_NOT_FOUND
#define EMFILE          ERROR_TOO_MANY_OPEN_FILES
#define EACCES          ERROR_ACCESS_DENIED
#define EBADF           ERROR_INVALID_HANDLE
#define ENOMEM          ERROR_NOT_ENOUGH_MEMORY
#define EXDEV           ERROR_NOT_SAME_DEVICE
#define ENFILE          ERROR_NO_MORE_FILES
#define EROFS           ERROR_WRITE_PROTECT
#define ENOLCK          ERROR_SHARING_BUFFER_EXCEEDED
#define ENOSYS          ERROR_NOT_SUPPORTED
#define EEXIST          ERROR_FILE_EXISTS
#define EPERM           ERROR_CANNOT_MAKE
#define EINVAL          ERROR_INVALID_PARAMETER
#define EINTR           ERROR_INVALID_AT_INTERRUPT_TIME
#define EPIPE           ERROR_BROKEN_PIPE
#define ENOSPC          ERROR_DISK_FULL
#define ENOTEMPTY       ERROR_DIR_NOT_EMPTY
#define EBUSY           ERROR_BUSY
#define ENAMETOOLONG    ERROR_FILENAME_EXCED_RANGE
#define EAGAIN          ERROR_MORE_DATA
#define ENOTDIR         ERROR_DIRECTORY
#define ERANGE          ERROR_ARITHMETIC_OVERFLOW
#define ENXIO           ERROR_FILE_INVALID
#define EFAULT          ERROR_PROCESS_ABORTED
#define EIO             ERROR_IO_DEVICE
#define EDEADLOCK       ERROR_POSSIBLE_DEADLOCK
#define ENODEV          ERROR_BAD_DEVICE

/* Windows CE is missing more stuff that is pretty standard.  */

#define strdup _strdup
#define stricmp _stricmp
#define strnicmp _strnicmp

#define environ _dbus_wince_environ
extern char *environ[];

#define getenv _dbus_wince_getenv
char *getenv (const char *name);

#define putenv _dbus_wince_putenv
int putenv (char *str);

#define clock _dbus_wince_clock
clock_t clock (void);

#define abort _dbus_wince_abort
void abort (void);

#define _S_IFMT         0170000         /* file type mask */
#define _S_IFDIR        0040000         /* directory */
#define _S_IFCHR        0020000         /* character special */
#define _S_IFIFO        0010000         /* pipe */
#define _S_IFREG        0100000         /* regular */
#define _S_IREAD        0000400         /* read permission, owner */
#define _S_IWRITE       0000200         /* write permission, owner */
#define _S_IEXEC        0000100         /* execute/search permission, owner */

#ifndef __OFF_T_DEFINED
typedef long off_t;
#define __OFF_T_DEFINED
#endif
#ifndef _INTPTR_T_DEFINED
typedef int intptr_t;
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
typedef unsigned int uintptr_t;
#define _UINTPTR_T_DEFINED
#endif

#ifndef _MAX_FNAME
#define _MAX_FNAME 256
#endif

#ifndef _IOFBF
#define _IOFBF	0
#endif
#ifndef _IOLBF
#define _IOLBF	1
#endif
#ifndef _IONBF
#define _IONBF	2
#endif


/* Windows CE is missing some Windows functions that we want.  */

#define GetSystemTimeAsFileTime _dbus_wince_GetSystemTimeAsFileTime
void GetSystemTimeAsFileTime (LPFILETIME ftp);

#define _mbsrchr _dbus_wince_mbsrchr
unsigned char* _mbsrchr (const unsigned char*, unsigned int);

#define OpenFileMappingA _dbus_wince_OpenFileMappingA
HANDLE OpenFileMappingA(DWORD,BOOL,LPCSTR);

#define MoveFileExA _dbus_wince_MoveFileExA
BOOL MoveFileExA(LPCSTR,LPCSTR,DWORD);
#ifndef MOVEFILE_REPLACE_EXISTING
#define MOVEFILE_REPLACE_EXISTING 0x00000001
#endif

#define SetHandleInformation _dbus_wince_SetHandleInformation
BOOL SetHandleInformation(HANDLE,DWORD,DWORD);
#ifndef HANDLE_FLAG_INHERIT
#define HANDLE_FLAG_INHERIT 0x01
#endif
#ifndef HANDLE_FLAG_PROTECT
#define HANDLE_FLAG_PROTECT_FROM_CLOSE 0x02
#endif

#define SearchPathA _dbus_wince_SearchPathA
DWORD SearchPathA(LPCSTR,LPCSTR,LPCSTR,DWORD,LPSTR,LPSTR*);

/* Instead of emulating all functions needed for this, we replace the
   whole thing.  */
dbus_bool_t _dbus_getsid(char **sid);


#define LookupAccountNameW _dbus_wince_LookupAccountNameW
BOOL LookupAccountNameW(LPCWSTR,LPCWSTR,PSID,PDWORD,LPWSTR,PDWORD,PSID_NAME_USE);

#define IsValidSid _dbus_wince_IsValidSid
BOOL IsValidSid(PSID);


/* Windows CE does only have the UNICODE interfaces (FooW), but we
   want to use the ASCII interfaces (FooA).  We implement them
   here.  */

#define CreateFileA _dbus_wince_CreateFileA
HANDLE CreateFileA(LPCSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE);

#define DeleteFileA _dbus_wince_DeleteFileA
BOOL DeleteFileA(LPCSTR);

#define GetFileAttributesA _dbus_wince_GetFileAttributesA
DWORD GetFileAttributesA(LPCSTR);

#define GetFileAttributesExA _dbus_wince_GetFileAttributesExA
BOOL GetFileAttributesExA(LPCSTR,GET_FILEEX_INFO_LEVELS,PVOID);

#define CreateFileMappingA _dbus_wince_CreateFileMappingA
HANDLE CreateFileMappingA(HANDLE,LPSECURITY_ATTRIBUTES,DWORD,DWORD,DWORD,LPCSTR);

#define CreateDirectoryA _dbus_wince_CreateDirectoryA
BOOL CreateDirectoryA(LPCSTR,LPSECURITY_ATTRIBUTES);

#define RemoveDirectoryA _dbus_wince_RemoveDirectoryA
BOOL RemoveDirectoryA(LPCSTR);

#define FindFirstFileA _dbus_wince_FindFirstFileA
HANDLE FindFirstFileA(LPCSTR,LPWIN32_FIND_DATAA);

#define FindNextFileA _dbus_wince_FindNextFileA
BOOL FindNextFileA(HANDLE,LPWIN32_FIND_DATAA);

#define CreateMutexA _dbus_wince_CreateMutexA
HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES,BOOL,LPCSTR);

#define CreateProcessA _dbus_wince_CreateProcessA
BOOL CreateProcessA(LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,PVOID,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION);
#ifndef CREATE_NO_WINDOW
#define CREATE_NO_WINDOW 0x08000000
#endif


#define RegOpenKeyExA _dbus_wince_RegOpenKeyExA
LONG RegOpenKeyExA(HKEY,LPCSTR,DWORD,REGSAM,PHKEY);

#define RegQueryValueExA _dbus_wince_RegQueryValueExA
LONG WINAPI RegQueryValueExA(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);


#define FormatMessageA _dbus_wince_FormatMessageA
DWORD FormatMessageA(DWORD,PCVOID,DWORD,DWORD,LPSTR,DWORD,va_list*);

#define GetModuleFileNameA _dbus_wince_GetModuleFileNameA
DWORD GetModuleFileNameA(HINSTANCE,LPSTR,DWORD);

#define GetTempPathA _dbus_wince_GetTempPathA
DWORD GetTempPathA(DWORD,LPSTR);

#define SHGetSpecialFolderPathA _dbus_wince_SHGetSpecialFolderPathA
BOOL SHGetSpecialFolderPathA(HWND,LPSTR,int,BOOL);


#define OutputDebugStringA _dbus_wince_OutputDebugStringA
void OutputDebugStringA(LPCSTR);


DBUS_END_DECLS

#endif /* DBUS_SYSDEPS_WINCE_GLUE_H */