Commit 3404bb72 authored by Marcus Brinkmann's avatar Marcus Brinkmann Committed by Ralf Habacker
Browse files

Add support for Windows CE to the code base.

parent 9e034bd5
......@@ -455,7 +455,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension]
AC_SEARCH_LIBS(socket,[socket network])
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll)
AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv)
#### Check for broken poll; taken from Glib's configure
......
......@@ -52,7 +52,14 @@ DBUS_LIB_arch_sources = \
dbus-server-win.c \
dbus-server-win.h
if DBUS_WINCE
wince_source = dbus-sysdeps-wince-glue.h dbus-sysdeps-wince-glue.c
else
wince_source =
endif
DBUS_SHARED_arch_sources = \
$(wince_source) \
dbus-file-win.c \
dbus-pipe-win.c \
dbus-sockets-win.h \
......
......@@ -9,9 +9,6 @@
#endif
#include <stdio.h>
#ifdef DBUS_WINCE
#include <process.h>
#endif
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-spawn-win32.c Wrapper around g_spawn
......@@ -53,7 +50,9 @@
#include <stdlib.h>
#ifndef DBUS_WINCE
#include <process.h>
#endif
/**
* Babysitter implementation details
......
......@@ -46,13 +46,17 @@ _dbus_win_get_dll_hmodule (void)
return dbus_dll_hmodule;
}
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);
#ifdef DBUS_WINCE
#define hinst_t HANDLE
#else
#define hinst_t HINSTANCE
#endif
BOOL WINAPI DllMain (hinst_t, DWORD, LPVOID);
/* We need this to free the TLS events on thread exit */
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DllMain (hinst_t hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
......
......@@ -35,19 +35,20 @@
#include "dbus-sockets-win.h"
#include "dbus-memory.h"
#include <io.h>
#include <sys/stat.h>
#include <aclapi.h>
#include <winsock2.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#include <winsock2.h> // WSA error codes
#ifndef DBUS_WINCE
#include <io.h>
#include <lm.h>
#include <sys/stat.h>
#endif
/**
* Does the chdir, fork, setsid, etc. to become a daemon process.
*
......
......@@ -57,19 +57,17 @@
extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid);
extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid);
#include <fcntl.h>
#include <process.h>
#include <stdio.h>
#include <io.h>
#include <string.h>
#include <mbstring.h>
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#ifndef DBUS_WINCE
#include <mbstring.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
#ifdef HAVE_WSPIAPI_H
// needed for w2k compatibility (getaddrinfo/freeaddrinfo/getnameinfo)
......@@ -91,7 +89,11 @@ typedef int socklen_t;
void
_dbus_win_set_errno (int err)
{
#ifdef DBUS_WINCE
SetLastError (err);
#else
errno = err;
#endif
}
......@@ -724,6 +726,8 @@ _dbus_pid_for_log (void)
return _dbus_getpid ();
}
#ifndef DBUS_WINCE
/** Gets our SID
* @param points to sid buffer, need to be freed with LocalFree()
* @returns process sid
......@@ -771,6 +775,7 @@ failed:
_dbus_verbose("_dbus_getsid() returns %d\n",retval);
return retval;
}
#endif
/************************************************************************
......@@ -1714,11 +1719,8 @@ _dbus_read_credentials_socket (int handle,
dbus_bool_t
_dbus_check_dir_is_private_to_user (DBusString *dir, DBusError *error)
{
const char *directory;
struct stat sb;
/* TODO */
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
return TRUE;
}
......@@ -2042,7 +2044,7 @@ _dbus_delete_file (const DBusString *filename,
filename_c = _dbus_string_get_const_data (filename);
if (_unlink (filename_c) < 0)
if (DeleteFileA (filename_c) == 0)
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Failed to delete file %s: %s\n",
......@@ -2055,7 +2057,7 @@ _dbus_delete_file (const DBusString *filename,
#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_BUILD_TESTS)
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(DBUS_WINCE)
# ifdef BACKTRACES
# undef BACKTRACES
# endif
......@@ -2705,8 +2707,24 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs)
if (!_dbus_string_init (&servicedir_path))
return FALSE;
#ifdef DBUS_WINCE
{
/* On Windows CE, we adjust datadir dynamically to installation location. */
const char *data_dir = _dbus_getenv ("DBUS_DATADIR");
if (data_dir != NULL)
{
if (!_dbus_string_append (&servicedir_path, data_dir))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
}
}
#else
if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR _DBUS_PATH_SEPARATOR))
goto oom;
#endif
common_progs = _dbus_getenv ("CommonProgramFiles");
......@@ -3029,7 +3047,15 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory,
}
#endif
_dbus_string_init_const (&dotdir, ".dbus-keyrings");
#ifdef DBUS_WINCE
/* It's not possible to create a .something directory in Windows CE
using the file explorer. */
#define KEYRING_DIR "dbus-keyrings"
#else
#define KEYRING_DIR ".dbus-keyrings"
#endif
_dbus_string_init_const (&dotdir, KEYRING_DIR);
if (!_dbus_concat_dir_and_file (&homedir,
&dotdir))
goto failed;
......
......@@ -36,12 +36,6 @@ extern void *_dbus_win_get_dll_hmodule (void);
#include <windows.h>
#undef interface
#include <aclapi.h>
#include <lm.h>
#include <io.h>
#include <share.h>
#define DBUS_CONSOLE_DIR "/var/run/console/"
......
This diff is collapsed.
/* -*- 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>
#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 (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 _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);
DBUS_END_DECLS
#endif /* DBUS_SYSDEPS_WINCE_GLUE_H */
......@@ -625,7 +625,7 @@ ascii_strtod (const char *nptr,
fail_pos = NULL;
#if HAVE_LOCALE_H
#if HAVE_LOCALECONV
locale_data = localeconv ();
decimal_point = locale_data->decimal_point;
#else
......@@ -1010,7 +1010,11 @@ _dbus_error_from_system_errno (void)
void
_dbus_set_errno_to_zero (void)
{
#ifdef DBUS_WINCE
SetLastError (0);
#else
errno = 0;
#endif
}
/**
......
......@@ -45,6 +45,12 @@
#include <sys/poll.h>
#endif
#ifdef DBUS_WINCE
/* Windows CE lacks some system functions (such as errno and clock).
We bring them in here. */
#include "dbus-sysdeps-wince-glue.h"
#endif
DBUS_BEGIN_DECLS
#ifdef DBUS_WIN
......
......@@ -38,7 +38,7 @@ main (int argc,
const char *test_data_dir;
const char *specific_test;
#if HAVE_LOCALE_H
#if HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment