summaryrefslogtreecommitdiff
path: root/navit/support
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-09-30 12:31:02 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-09-30 12:31:02 +0000
commit83b5af044639b76a611b1c440a831bd98dda69f8 (patch)
tree0ce18b8943b37ae92c8601a923b971fe5f697309 /navit/support
parent50fc8bff9611c50d7c2c425081f8a239ed581822 (diff)
downloadnavit-83b5af044639b76a611b1c440a831bd98dda69f8.tar.gz
Add:support_libc:Missing functions for vc
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4813 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/support')
-rw-r--r--navit/support/libc/CMakeLists.txt2
-rw-r--r--navit/support/libc/_mingw.h307
-rw-r--r--navit/support/libc/abort.c9
-rw-r--r--navit/support/libc/bsearch.c81
-rw-r--r--navit/support/libc/calloc.c8
-rw-r--r--navit/support/libc/chsize.c51
-rw-r--r--navit/support/libc/close.c27
-rw-r--r--navit/support/libc/fcntl.h75
-rw-r--r--navit/support/libc/getopt.h111
-rw-r--r--navit/support/libc/gmtime.c25
-rw-r--r--navit/support/libc/io.h372
-rw-r--r--navit/support/libc/libc.c2
-rw-r--r--navit/support/libc/localtime.c38
-rw-r--r--navit/support/libc/lseek.c41
-rw-r--r--navit/support/libc/math.h13
-rw-r--r--navit/support/libc/mkdir.c29
-rw-r--r--navit/support/libc/mktime.c32
-rw-r--r--navit/support/libc/open.c135
-rw-r--r--navit/support/libc/process.h147
-rw-r--r--navit/support/libc/read.c30
-rw-r--r--navit/support/libc/rename.c27
-rw-r--r--navit/support/libc/stat.c151
-rw-r--r--navit/support/libc/time.c28
-rw-r--r--navit/support/libc/timeutil.c126
-rw-r--r--navit/support/libc/timeutil.h17
-rw-r--r--navit/support/libc/unistd.h48
-rw-r--r--navit/support/libc/unlink.c29
-rw-r--r--navit/support/libc/write.c29
28 files changed, 1988 insertions, 2 deletions
diff --git a/navit/support/libc/CMakeLists.txt b/navit/support/libc/CMakeLists.txt
index 44fb89c62..81489da01 100644
--- a/navit/support/libc/CMakeLists.txt
+++ b/navit/support/libc/CMakeLists.txt
@@ -1 +1 @@
-supportlib_add_library(support_libc libc.c libc_init.c)
+supportlib_add_library(support_libc libc.c libc_init.c unlink.c rename.c time.c open.c abort.c mkdir.c lseek.c stat.c close.c chsize.c read.c write.c strcasecmp localtime.c gmtime.c mktime.c timeutil.c calloc.c bsearch.c)
diff --git a/navit/support/libc/_mingw.h b/navit/support/libc/_mingw.h
new file mode 100644
index 000000000..fb0638d09
--- /dev/null
+++ b/navit/support/libc/_mingw.h
@@ -0,0 +1,307 @@
+#ifndef __MINGW_H
+/*
+ * _mingw.h
+ *
+ * Mingw specific macros included by ALL include files.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ * Created by Mumit Khan <khan@xraylith.wisc.edu>
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAIMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#define __MINGW_H
+
+#define __MINGW32_VERSION 3.16
+#define __MINGW32_MAJOR_VERSION 3
+#define __MINGW32_MINOR_VERSION 16
+#define __MINGW32_PATCHLEVEL 0
+
+#if __GNUC__ >= 3
+#pragma GCC system_header
+#endif
+
+/* These are defined by the user (or the compiler)
+ to specify how identifiers are imported from a DLL.
+
+ __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported.
+ __MINGW_IMPORT The attribute definition to specify imported
+ variables/functions.
+ _CRTIMP As above. For MS compatibility.
+ __MINGW32_VERSION Runtime version.
+ __MINGW32_MAJOR_VERSION Runtime major version.
+ __MINGW32_MINOR_VERSION Runtime minor version.
+ __MINGW32_BUILD_DATE Runtime build date.
+
+ Macros to enable MinGW features which deviate from standard MSVC
+ compatible behaviour; these may be specified directly in user code,
+ activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
+ or by inclusion in __MINGW_FEATURES__:
+
+ __USE_MINGW_ANSI_STDIO Select a more ANSI C99 compatible
+ implementation of printf() and friends.
+
+ Other macros:
+
+ __int64 define to be long long. Using a typedef
+ doesn't work for "unsigned __int64"
+
+ All headers should include this first, and then use __DECLSPEC_SUPPORTED
+ to choose between the old ``__imp__name'' style or __MINGW_IMPORT
+ style declarations. */
+
+
+/* Manifest definitions identifying the flag bits, controlling activation
+ * of MinGW features, as specified by the user in __MINGW_FEATURES__.
+ */
+#define __MINGW_ANSI_STDIO__ 0x0000000000000001ULL
+/*
+ * The following three are not yet formally supported; they are
+ * included here, to document anticipated future usage.
+ */
+#define __MINGW_LC_EXTENSIONS__ 0x0000000000000050ULL
+#define __MINGW_LC_MESSAGES__ 0x0000000000000010ULL
+#define __MINGW_LC_ENVVARS__ 0x0000000000000040ULL
+
+/* Try to avoid problems with outdated checks for GCC __attribute__ support. */
+#undef __attribute__
+
+#if defined (__PCC__)
+# undef __DECLSPEC_SUPPORTED
+# ifndef __MINGW_IMPORT
+# define __MINGW_IMPORT extern
+# endif
+# ifndef _CRTIMP
+# define _CRTIMP
+# endif
+# ifndef __cdecl
+# define __cdecl _Pragma("cdecl")
+# endif
+# ifndef __stdcall
+# define __stdcall _Pragma("stdcall")
+# endif
+# ifndef __int64
+# define __int64 long long
+# endif
+# ifndef __int32
+# define __int32 long
+# endif
+# ifndef __int16
+# define __int16 short
+# endif
+# ifndef __int8
+# define __int8 char
+# endif
+# ifndef __small
+# define __small char
+# endif
+# ifndef __hyper
+# define __hyper long long
+# endif
+# ifndef __volatile__
+# define __volatile__ volatile
+# endif
+# ifndef __restrict__
+# define __restrict__ restrict
+# endif
+# define NONAMELESSUNION
+#elif defined(__GNUC__)
+# ifdef __declspec
+# ifndef __MINGW_IMPORT
+ /* Note the extern. This is needed to work around GCC's
+ limitations in handling dllimport attribute. */
+# define __MINGW_IMPORT extern __attribute__ ((__dllimport__))
+# endif
+# ifndef _CRTIMP
+# ifdef __USE_CRTIMP
+# define _CRTIMP __attribute__ ((dllimport))
+# else
+# define _CRTIMP
+# endif
+# endif
+# define __DECLSPEC_SUPPORTED
+# else /* __declspec */
+# undef __DECLSPEC_SUPPORTED
+# undef __MINGW_IMPORT
+# ifndef _CRTIMP
+# define _CRTIMP
+# endif
+# endif /* __declspec */
+/*
+ * The next two defines can cause problems if user code adds the
+ * __cdecl attribute like so:
+ * void __attribute__ ((__cdecl)) foo(void);
+ */
+# ifndef __cdecl
+# define __cdecl __attribute__ ((__cdecl__))
+# endif
+# ifndef __stdcall
+# define __stdcall __attribute__ ((__stdcall__))
+# endif
+# ifndef __int64
+# define __int64 long long
+# endif
+# ifndef __int32
+# define __int32 long
+# endif
+# ifndef __int16
+# define __int16 short
+# endif
+# ifndef __int8
+# define __int8 char
+# endif
+# ifndef __small
+# define __small char
+# endif
+# ifndef __hyper
+# define __hyper long long
+# endif
+#else /* ! __GNUC__ && ! __PCC__ */
+# ifndef __MINGW_IMPORT
+# define __MINGW_IMPORT __declspec(dllimport)
+# endif
+# ifndef _CRTIMP
+# define _CRTIMP __declspec(dllimport)
+# endif
+# define __DECLSPEC_SUPPORTED
+# define __attribute__(x) /* nothing */
+#endif
+
+#if defined (__GNUC__) && defined (__GNUC_MINOR__)
+#define __MINGW_GNUC_PREREQ(major, minor) \
+ (__GNUC__ > (major) \
+ || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
+#else
+#define __MINGW_GNUC_PREREQ(major, minor) 0
+#endif
+
+#ifdef __cplusplus
+#abort1
+# define __CRT_INLINE inline
+#else
+# if __GNUC_STDC_INLINE__
+#abort2
+# define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
+# else
+# ifdef __COREDLL__
+#abort3
+ /* There isn't any out-of-line version of most of
+ these functions in coredll.dll, so we need this for -O0,
+ or for -fno-inline. This is still problematic if the user
+ tries t o take the address of these functions. We will slowly
+ add out-of-line copies as those cases are found.
+ Note: We can't use static inline here, as most of these functions
+ will be declared elsew here with external linkage, and gcc will
+ barf on that. */
+# define __CRT_INLINE extern __inline__ __attribute__((__always_inline__))
+# else
+# define __CRT_INLINE
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+# define __UNUSED_PARAM(x)
+#else
+# ifdef __GNUC__
+# define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
+# else
+# define __UNUSED_PARAM(x) x
+# endif
+#endif
+
+#ifdef __GNUC__
+#define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
+#define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
+#else
+#define __MINGW_ATTRIB_NORETURN
+#define __MINGW_ATTRIB_CONST
+#endif
+
+#if __MINGW_GNUC_PREREQ (3, 0)
+#define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
+#define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
+#else
+#define __MINGW_ATTRIB_MALLOC
+#define __MINGW_ATTRIB_PURE
+#endif
+
+/* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
+ variadiac macro facility, because variadic macros cause syntax
+ errors with --traditional-cpp. */
+#if __MINGW_GNUC_PREREQ (3, 3)
+#define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
+#else
+#define __MINGW_ATTRIB_NONNULL(arg)
+#endif /* GNUC >= 3.3 */
+
+#if defined(UNDER_CE) && defined(__arm__)
+/* ARM Windows CE is not underscored. */
+# define __U(SYM) _ ## SYM
+# define __IMP(S) __imp_ ## S
+#elif defined(UNDER_CE) && defined(i386)
+/* i386 Windows CE versions are underscored. */
+# define __U(SYM) SYM
+# define __IMP(S) _imp__ ## S
+#else
+/* Desktop i386 Windows versions are underscored. */
+# define __U(SYM) SYM
+# define __IMP(S) _imp__ ## S
+#endif
+
+#if __MINGW_GNUC_PREREQ (3, 1)
+#define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
+#else
+#define __MINGW_ATTRIB_DEPRECATED
+#endif /* GNUC >= 3.1 */
+
+#if __MINGW_GNUC_PREREQ (3, 3)
+#define __MINGW_NOTHROW __attribute__ ((__nothrow__))
+#else
+#define __MINGW_NOTHROW
+#endif /* GNUC >= 3.3 */
+
+
+/* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
+allow GCC to optimize away some EH unwind code, at least in DW2 case. */
+
+#if defined __MSVCRT__ && !defined (__MSVCRT_VERSION__)
+/* High byte is the major version, low byte is the minor. */
+# define __MSVCRT_VERSION__ 0x0600
+#endif
+
+/* Activation of MinGW specific extended features:
+ */
+#ifndef __USE_MINGW_ANSI_STDIO
+/*
+ * If user didn't specify it explicitly...
+ */
+# if defined __STRICT_ANSI__ || defined _ISOC99_SOURCE \
+ || defined _POSIX_SOURCE || defined _POSIX_C_SOURCE \
+ || defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED \
+ || defined _GNU_SOURCE || defined _BSD_SOURCE \
+ || defined _SVID_SOURCE
+ /*
+ * but where any of these source code qualifiers are specified,
+ * then assume ANSI I/O standards are preferred over Microsoft's...
+ */
+# define __USE_MINGW_ANSI_STDIO 1
+# else
+ /*
+ * otherwise use whatever __MINGW_FEATURES__ specifies...
+ */
+# define __USE_MINGW_ANSI_STDIO (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
+# endif
+#endif
+
+#endif /* __MINGW_H */
diff --git a/navit/support/libc/abort.c b/navit/support/libc/abort.c
new file mode 100644
index 000000000..11d405c5b
--- /dev/null
+++ b/navit/support/libc/abort.c
@@ -0,0 +1,9 @@
+#include <windows.h>
+
+/* Only needed on Windows CE. */
+
+void abort(void)
+{
+ TerminateProcess (GetCurrentProcess(), 1);
+ while (1); /* Kill 'noreturn function does return' warning. */
+}
diff --git a/navit/support/libc/bsearch.c b/navit/support/libc/bsearch.c
new file mode 100644
index 000000000..2708688ce
--- /dev/null
+++ b/navit/support/libc/bsearch.c
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* <wince> */
+
+/* bsearch is in both stdlib.h and search.h. We include both
+ to catch possible differences. */
+#include <stdlib.h>
+/* #include <search.h> */
+#include <stdint.h>
+
+/* </wince> */
+
+
+/*
+ * Perform a binary search.
+ *
+ * The code below is a bit sneaky. After a comparison fails, we
+ * divide the work in half by moving either left or right. If lim
+ * is odd, moving left simply involves halving lim: e.g., when lim
+ * is 5 we look at item 2, so we change lim to 2 so that we will
+ * look at items 0 & 1. If lim is even, the same applies. If lim
+ * is odd, moving right again involes halving lim, this time moving
+ * the base up one item past p: e.g., when lim is 5 we change base
+ * to item 3 and make lim 2 so that we will look at items 3 and 4.
+ * If lim is even, however, we have to shrink it by one before
+ * halving: e.g., when lim is 4, we still looked at item 2, so we
+ * have to make lim 3, then halve, obtaining 1, so that we will only
+ * look at item 3.
+ */
+void *
+bsearch(key, base0, nmemb, size, compar)
+ const void *key;
+ const void *base0;
+ size_t nmemb;
+ size_t size;
+ int (*compar)(const void *, const void *);
+{
+ const char *base = base0;
+ size_t lim;
+ int cmp;
+ const void *p;
+
+ for (lim = nmemb; lim != 0; lim >>= 1) {
+ p = base + (lim >> 1) * size;
+ cmp = (*compar)(key, p);
+ if (cmp == 0)
+ return ((void *)(unsigned int *)p);
+ if (cmp > 0) { /* key > p: move right */
+ base = (const char *)p + size;
+ lim--;
+ } /* else move left */
+ }
+ return (NULL);
+}
diff --git a/navit/support/libc/calloc.c b/navit/support/libc/calloc.c
new file mode 100644
index 000000000..147ea73a4
--- /dev/null
+++ b/navit/support/libc/calloc.c
@@ -0,0 +1,8 @@
+void *
+calloc(int nelem, int size)
+{
+ void *ret=malloc(nelem*size);
+ if (ret)
+ memset(ret, 0, nelem*size);
+ return ret;
+}
diff --git a/navit/support/libc/chsize.c b/navit/support/libc/chsize.c
new file mode 100644
index 000000000..778949a46
--- /dev/null
+++ b/navit/support/libc/chsize.c
@@ -0,0 +1,51 @@
+/*
+ * chsize.c: _chsize and chsize implementations for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public
+ * Domain. This file is a part of the mingw32ce package. No
+ * warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> 24 Jun 2007
+ *
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+int
+_chsize (int fd, long size)
+{
+ DWORD cur;
+ DWORD new;
+ HANDLE h;
+ BOOL ret;
+
+ h = (HANDLE) fd;
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ SetLastError (ERROR_INVALID_PARAMETER);
+ return -1;
+ }
+
+ cur = SetFilePointer (h, 0, NULL, FILE_CURRENT);
+ if (cur == 0xffffffff)
+ return -1;
+
+ /* Move to where we want it. */
+ new = SetFilePointer (h, size, NULL, FILE_BEGIN);
+ if (new == 0xffffffff)
+ return -1;
+
+ /* And commit it as eof, effectivelly growing or shrinking. */
+ ret = SetEndOfFile (h);
+
+ SetFilePointer (h, cur, NULL, FILE_BEGIN);
+
+ return ret ? 0 : -1;
+}
+
+int
+chsize (int fd, long size)
+{
+ return _chsize (fd, size);
+}
diff --git a/navit/support/libc/close.c b/navit/support/libc/close.c
new file mode 100644
index 000000000..3b04734ce
--- /dev/null
+++ b/navit/support/libc/close.c
@@ -0,0 +1,27 @@
+/*
+ * close.c: close implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include <windows.h>
+#include <unistd.h>
+
+int
+_close (int fildes)
+{
+ if (CloseHandle ((HANDLE) fildes))
+ return 0;
+ return -1;
+}
+
+int
+close (int fildes)
+{
+ return _close (fildes);
+}
diff --git a/navit/support/libc/fcntl.h b/navit/support/libc/fcntl.h
new file mode 100644
index 000000000..9bff9352a
--- /dev/null
+++ b/navit/support/libc/fcntl.h
@@ -0,0 +1,75 @@
+/*
+ * fcntl.h
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Access constants for _open. Note that the permissions constants are
+ * in sys/stat.h (ick).
+ *
+ */
+#ifndef _FCNTL_H_
+#define _FCNTL_H_
+
+/* All the headers include this file. */
+#include <_mingw.h>
+
+/*
+ * It appears that fcntl.h should include io.h for compatibility...
+ */
+#include <io.h>
+
+/* Specifiy one of these flags to define the access mode. */
+#define _O_RDONLY 0
+#define _O_WRONLY 1
+#define _O_RDWR 2
+
+/* Mask for access mode bits in the _open flags. */
+#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
+
+#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */
+
+#define _O_RANDOM 0x0010
+#define _O_SEQUENTIAL 0x0020
+#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
+ * WARNING: Even if not created by _open! */
+#define _O_NOINHERIT 0x0080
+
+#define _O_CREAT 0x0100 /* Create the file if it does not exist. */
+#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */
+#define _O_EXCL 0x0400 /* Open only if the file does not exist. */
+
+#define _O_SHORT_LIVED 0x1000
+
+/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
+#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */
+#define _O_BINARY 0x8000 /* Input and output is not translated. */
+#define _O_RAW _O_BINARY
+
+#if (__MSVCRT_VERSION__ >= 0x0800)
+#define _O_WTEXT 0x10000
+#define _O_U16TEXT 0x20000
+#define _O_U8TEXT 0x40000
+#endif
+
+#ifndef _NO_OLDNAMES
+
+/* POSIX/Non-ANSI names for increased portability */
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_RDWR _O_RDWR
+#define O_ACCMODE _O_ACCMODE
+#define O_APPEND _O_APPEND
+#define O_CREAT _O_CREAT
+#define O_TRUNC _O_TRUNC
+#define O_EXCL _O_EXCL
+#define O_TEXT _O_TEXT
+#define O_BINARY _O_BINARY
+#define O_TEMPORARY _O_TEMPORARY
+#define O_NOINHERIT _O_NOINHERIT
+#define O_SEQUENTIAL _O_SEQUENTIAL
+#define O_RANDOM _O_RANDOM
+
+#endif /* Not _NO_OLDNAMES */
+
+#endif /* Not _FCNTL_H_ */
diff --git a/navit/support/libc/getopt.h b/navit/support/libc/getopt.h
new file mode 100644
index 000000000..406bbf594
--- /dev/null
+++ b/navit/support/libc/getopt.h
@@ -0,0 +1,111 @@
+#ifndef __GETOPT_H__
+/*
+ * getopt.h
+ *
+ * $Id: getopt.h,v 1.4 2009/01/04 17:35:36 keithmarshall Exp $
+ *
+ * Defines constants and function prototypes required to implement
+ * the `getopt', `getopt_long' and `getopt_long_only' APIs.
+ *
+ * This file is part of the MinGW32 package set.
+ *
+ * Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
+ *
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAIMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.4 $
+ * $Author: keithmarshall $
+ * $Date: 2009/01/04 17:35:36 $
+ *
+ */
+#define __GETOPT_H__
+
+/* All the headers include this file. */
+#include <_mingw.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int optind; /* index of first non-option in argv */
+extern int optopt; /* single option character, as parsed */
+extern int opterr; /* flag to enable built-in diagnostics... */
+ /* (user may set to zero, to suppress) */
+
+extern char *optarg; /* pointer to argument of current option */
+
+extern int getopt( int, char * const [], const char * );
+
+#ifdef _BSD_SOURCE
+/*
+ * BSD adds the non-standard `optreset' feature, for reinitialisation
+ * of `getopt' parsing. We support this feature, for applications which
+ * proclaim their BSD heritage, before including this header; however,
+ * to maintain portability, developers are advised to avoid it.
+ */
+# define optreset __mingw_optreset
+
+extern int optreset;
+#endif
+#ifdef __cplusplus
+}
+#endif
+/*
+ * POSIX requires the `getopt' API to be specified in `unistd.h';
+ * thus, `unistd.h' includes this header. However, we do not want
+ * to expose the `getopt_long' or `getopt_long_only' APIs, when
+ * included in this manner. Thus, close the standard __GETOPT_H__
+ * declarations block, and open an additional __GETOPT_LONG_H__
+ * specific block, only when *not* __UNISTD_H_SOURCED__, in which
+ * to declare the extended API.
+ */
+#endif /* !defined(__GETOPT_H__) */
+#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
+#define __GETOPT_LONG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct option /* specification for a long form option... */
+{
+ const char *name; /* option name, without leading hyphens */
+ int has_arg; /* does it take an argument? */
+ int *flag; /* where to save its status, or NULL */
+ int val; /* its associated status value */
+};
+
+enum /* permitted values for its `has_arg' field... */
+{
+ no_argument = 0, /* option never takes an argument */
+ required_argument, /* option always requires an argument */
+ optional_argument /* option may take an argument */
+};
+
+extern int getopt_long( int, char * const [], const char *, const struct option *, int * );
+extern int getopt_long_only( int, char * const [], const char *, const struct option *, int * );
+/*
+ * Previous MinGW implementation had...
+ */
+#ifndef HAVE_DECL_GETOPT
+/*
+ * ...for the long form API only; keep this for compatibility.
+ */
+# define HAVE_DECL_GETOPT 1
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
+/* $RCSfile: getopt.h,v $Revision: 1.4 $: end of file */
diff --git a/navit/support/libc/gmtime.c b/navit/support/libc/gmtime.c
new file mode 100644
index 000000000..aa33e0906
--- /dev/null
+++ b/navit/support/libc/gmtime.c
@@ -0,0 +1,25 @@
+/*
+ * gmtime.c: gmtime implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include "timeutil.h"
+
+struct tm *
+gmtime(const time_t *t)
+{
+ FILETIME f;
+ SYSTEMTIME s;
+ static struct tm tms;
+
+ __time_t_to_FILETIME (*t, &f);
+ FileTimeToSystemTime (&f, &s);
+ __SYSTEMTIME_to_tm (&s, &tms);
+ return &tms;
+}
diff --git a/navit/support/libc/io.h b/navit/support/libc/io.h
new file mode 100644
index 000000000..9c3da7c5d
--- /dev/null
+++ b/navit/support/libc/io.h
@@ -0,0 +1,372 @@
+/*
+ * io.h
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * System level I/O functions and types.
+ *
+ */
+#ifndef _IO_H_
+#define _IO_H_
+
+/* All the headers include this file. */
+#include <_mingw.h>
+
+/* MSVC's io.h contains the stuff from dir.h, so I will too.
+ * NOTE: This also defines off_t, the file offset type, through
+ * an inclusion of sys/types.h */
+
+#include <sys/types.h> /* To get time_t. */
+
+/*
+ * Attributes of files as returned by _findfirst et al.
+ */
+#define _A_NORMAL 0x00000000
+#define _A_RDONLY 0x00000001
+#define _A_HIDDEN 0x00000002
+#define _A_SYSTEM 0x00000004
+#define _A_VOLID 0x00000008
+#define _A_SUBDIR 0x00000010
+#define _A_ARCH 0x00000020
+
+
+#ifndef RC_INVOKED
+
+#ifndef _INTPTR_T_DEFINED
+#define _INTPTR_T_DEFINED
+#ifdef _WIN64
+ typedef __int64 intptr_t;
+#else
+ typedef int intptr_t;
+#endif
+#endif
+
+#ifndef _FSIZE_T_DEFINED
+typedef unsigned long _fsize_t;
+#define _FSIZE_T_DEFINED
+#endif
+
+/*
+ * The maximum length of a file name. You should use GetVolumeInformation
+ * instead of this constant. But hey, this works.
+ * Also defined in stdio.h.
+ */
+#ifndef FILENAME_MAX
+#define FILENAME_MAX (260)
+#endif
+
+/*
+ * The following structure is filled in by _findfirst or _findnext when
+ * they succeed in finding a match.
+ */
+#ifndef _FINDDATA_T_DEFINED
+struct _finddata_t
+{
+ unsigned attrib; /* Attributes, see constants above. */
+ time_t time_create;
+ time_t time_access; /* always midnight local time */
+ time_t time_write;
+ _fsize_t size;
+ char name[FILENAME_MAX]; /* may include spaces. */
+};
+
+#ifndef __COREDLL__
+
+struct _finddatai64_t {
+ unsigned attrib;
+ time_t time_create;
+ time_t time_access;
+ time_t time_write;
+ __int64 size;
+ char name[FILENAME_MAX];
+};
+
+#if __MSVCRT_VERSION__ >= 0x0601
+struct __finddata64_t {
+ unsigned attrib;
+ __time64_t time_create;
+ __time64_t time_access;
+ __time64_t time_write;
+/* 8 bytes are returned so it can't be _fsize_t */
+ __int64 size;
+ char name[FILENAME_MAX];
+};
+#endif
+
+#endif
+
+#define _FINDDATA_T_DEFINED
+#endif /* _FINDDATA_T_DEFINED */
+
+#ifndef _WFINDDATA_T_DEFINED
+struct _wfinddata_t {
+ unsigned attrib;
+ time_t time_create; /* -1 for FAT file systems */
+ time_t time_access; /* -1 for FAT file systems */
+ time_t time_write;
+ _fsize_t size;
+ wchar_t name[FILENAME_MAX]; /* may include spaces. */
+};
+
+#ifndef __COREDLL__
+
+struct _wfinddatai64_t {
+ unsigned attrib;
+ time_t time_create;
+ time_t time_access;
+ time_t time_write;
+ __int64 size;
+ wchar_t name[FILENAME_MAX];
+};
+
+#if __MSVCRT_VERSION__ >= 0x0601
+struct __wfinddata64_t {
+ unsigned attrib;
+ __time64_t time_create;
+ __time64_t time_access;
+ __time64_t time_write;
+/* 8 bytes are returned so it can't be _fsize_t */
+ __int64 size;
+ wchar_t name[FILENAME_MAX];
+};
+#endif
+
+#endif /* __COREDLL__ */
+
+#define _WFINDDATA_T_DEFINED
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Functions for searching for files. _findfirst returns -1 if no match
+ * is found. Otherwise it returns a handle to be used in _findnext and
+ * _findclose calls. _findnext also returns -1 if no match could be found,
+ * and 0 if a match was found. Call _findclose when you are finished.
+ */
+/* FIXME: Should these all use intptr_t, as per recent MSDN docs? */
+_CRTIMP long __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _findnext (long, struct _finddata_t*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _findclose (long);
+
+#ifndef UNDER_CE
+_CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
+_CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
+_CRTIMP char* __cdecl __MINGW_NOTHROW _mktemp (char*);
+#endif
+_CRTIMP int __cdecl __MINGW_NOTHROW _mkdir (const char*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _rmdir (const char*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
+
+#ifdef __MSVCRT__
+_CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
+_CRTIMP long __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(long, struct _finddatai64_t*);
+_CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int);
+_CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
+/* These require newer versions of msvcrt.dll (6.1 or higher). */
+#if __MSVCRT_VERSION__ >= 0x0601
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst64(const char*, struct __finddata64_t*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findnext64(intptr_t, struct __finddata64_t*);
+#endif /* __MSVCRT_VERSION__ >= 0x0601 */
+#ifndef __NO_MINGW_LFS
+__CRT_INLINE off64_t lseek64 (int, off64_t, int);
+__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence)
+{
+ return _lseeki64(fd, (__int64) offset, whence);
+}
+#endif
+
+#endif /* __MSVCRT__ */
+
+#ifndef _NO_OLDNAMES
+
+#ifndef _UWIN
+#ifndef UNDER_CE
+_CRTIMP int __cdecl __MINGW_NOTHROW chdir (const char*);
+_CRTIMP char* __cdecl __MINGW_NOTHROW getcwd (char*, int);
+_CRTIMP char* __cdecl __MINGW_NOTHROW mktemp (char*);
+#endif
+_CRTIMP int __cdecl __MINGW_NOTHROW mkdir (const char*);
+_CRTIMP int __cdecl __MINGW_NOTHROW rmdir (const char*);
+_CRTIMP int __cdecl __MINGW_NOTHROW chmod (const char*, int);
+#endif /* _UWIN */
+
+#endif /* Not _NO_OLDNAMES */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* Not RC_INVOKED */
+
+/* TODO: Maximum number of open handles has not been tested, I just set
+ * it the same as FOPEN_MAX. */
+#define HANDLE_MAX FOPEN_MAX
+
+/* Some defines for _access nAccessMode (MS doesn't define them, but
+ * it doesn't seem to hurt to add them). */
+#define F_OK 0 /* Check for file existence */
+/* Well maybe it does hurt. On newer versions of MSVCRT, an access mode
+ of 1 causes invalid parameter error. */
+#define X_OK 1 /* MS access() doesn't check for execute permission. */
+#define W_OK 2 /* Check for write permission */
+#define R_OK 4 /* Check for read permission */
+
+#ifndef RC_INVOKED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_CRTIMP int __cdecl __MINGW_NOTHROW _access (const char*, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _chsize (int, long);
+_CRTIMP int __cdecl __MINGW_NOTHROW _close (int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _commit(int);
+
+/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
+ * the "owner write permission" bit (on FAT). */
+_CRTIMP int __cdecl __MINGW_NOTHROW _creat (const char*, int);
+
+_CRTIMP int __cdecl __MINGW_NOTHROW _dup (int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _dup2 (int, int);
+_CRTIMP long __cdecl __MINGW_NOTHROW _filelength (int);
+_CRTIMP long __cdecl __MINGW_NOTHROW _get_osfhandle (int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _isatty (int);
+
+/* In a very odd turn of events this function is excluded from those
+ * files which define _STREAM_COMPAT. This is required in order to
+ * build GNU libio because of a conflict with _eof in streambuf.h
+ * line 107. Actually I might just be able to change the name of
+ * the enum member in streambuf.h... we'll see. TODO */
+#ifndef _STREAM_COMPAT
+_CRTIMP int __cdecl __MINGW_NOTHROW _eof (int);
+#endif
+
+/* LK_... locking commands defined in sys/locking.h. */
+_CRTIMP int __cdecl __MINGW_NOTHROW _locking (int, int, long);
+
+_CRTIMP long __cdecl __MINGW_NOTHROW _lseek (int, long, int);
+
+/* Optional third argument is unsigned unPermissions. */
+_CRTIMP int __cdecl __MINGW_NOTHROW _open (const char*, int, ...);
+
+#ifndef __COREDLL__
+_CRTIMP int __cdecl __MINGW_NOTHROW _open_osfhandle (long, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _pipe (int *, unsigned int, int);
+#endif /* __COREDLL__ */
+_CRTIMP int __cdecl __MINGW_NOTHROW _read (int, void*, unsigned int);
+#ifndef __COREDLL__
+_CRTIMP int __cdecl __MINGW_NOTHROW _setmode (int, int);
+/* MS puts remove & rename (but not wide versions) in io.h as well
+ as in stdio.h. */
+_CRTIMP int __cdecl __MINGW_NOTHROW remove (const char*);
+#endif
+_CRTIMP int __cdecl __MINGW_NOTHROW rename (const char*, const char*);
+#ifndef __COREDLL__
+/* SH_... flags for nShFlags defined in share.h
+ * Optional fourth argument is unsigned unPermissions */
+_CRTIMP int __cdecl __MINGW_NOTHROW _sopen (const char*, int, int, ...);
+
+_CRTIMP long __cdecl __MINGW_NOTHROW _tell (int);
+/* Should umask be in sys/stat.h and/or sys/types.h instead? */
+_CRTIMP int __cdecl __MINGW_NOTHROW _umask (int);
+#endif /* __COREDLL__ */
+_CRTIMP int __cdecl __MINGW_NOTHROW _unlink (const char*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _write (int, const void*, unsigned int);
+
+/* Wide character versions. Also declared in wchar.h. */
+/* Not in crtdll.dll */
+#if !defined (_WIO_DEFINED)
+#if defined (__MSVCRT__)
+_CRTIMP int __cdecl __MINGW_NOTHROW _waccess(const wchar_t*, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wchmod(const wchar_t*, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wcreat(const wchar_t*, int);
+#endif
+#if defined (__MSVCRT__) || defined (__COREDLL__)
+_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext(long, struct _wfinddata_t *);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
+#endif
+#if defined (__MSVCRT__)
+_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_t*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
+_CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
+_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(long, struct _wfinddatai64_t*);
+#if __MSVCRT_VERSION__ >= 0x0601
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);
+#endif
+#endif /* defined (__MSVCRT__) */
+#define _WIO_DEFINED
+#endif /* _WIO_DEFINED */
+
+#ifndef _NO_OLDNAMES
+/*
+ * Non-underscored versions of non-ANSI functions to improve portability.
+ * These functions live in libmoldname.a.
+ */
+
+#ifndef _UWIN
+_CRTIMP int __cdecl __MINGW_NOTHROW access (const char*, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW chsize (int, long );
+_CRTIMP int __cdecl __MINGW_NOTHROW close (int);
+#ifndef __COREDLL__
+_CRTIMP int __cdecl __MINGW_NOTHROW creat (const char*, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW dup (int);
+_CRTIMP int __cdecl __MINGW_NOTHROW dup2 (int, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW eof (int);
+_CRTIMP long __cdecl __MINGW_NOTHROW filelength (int);
+#endif /* __COREDLL__ */
+_CRTIMP int __cdecl __MINGW_NOTHROW isatty (int);
+_CRTIMP long __cdecl __MINGW_NOTHROW lseek (int, long, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW open (const char*, int, ...);
+_CRTIMP int __cdecl __MINGW_NOTHROW read (int, void*, unsigned int);
+#ifndef __COREDLL__
+_CRTIMP int __cdecl __MINGW_NOTHROW setmode (int, int);
+_CRTIMP int __cdecl __MINGW_NOTHROW sopen (const char*, int, int, ...);
+_CRTIMP long __cdecl __MINGW_NOTHROW tell (int);
+_CRTIMP int __cdecl __MINGW_NOTHROW umask (int);
+#endif /* __COREDLL__ */
+_CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*);
+_CRTIMP int __cdecl __MINGW_NOTHROW write (int, const void*, unsigned int);
+#endif /* _UWIN */
+
+#ifdef __USE_MINGW_ACCESS
+/* Old versions of MSVCRT access() just ignored X_OK, while the version
+ shipped with Vista, returns an error code. This will restore the
+ old behaviour */
+static inline int __mingw_access (const char* __fname, int __mode)
+ { return _access (__fname, __mode & ~X_OK); }
+#define access(__f,__m) __mingw_access (__f, __m)
+#endif
+
+/* Wide character versions. Also declared in wchar.h. */
+/* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
+#if 0
+int waccess(const wchar_t *, int);
+int wchmod(const wchar_t *, int);
+int wcreat(const wchar_t *, int);
+long wfindfirst(wchar_t *, struct _wfinddata_t *);
+int wfindnext(long, struct _wfinddata_t *);
+int wunlink(const wchar_t *);
+int wrename(const wchar_t *, const wchar_t *);
+int wopen(const wchar_t *, int, ...);
+int wsopen(const wchar_t *, int, int, ...);
+wchar_t * wmktemp(wchar_t *);
+#endif
+
+#endif /* Not _NO_OLDNAMES */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* Not RC_INVOKED */
+
+#endif /* _IO_H_ not defined */
diff --git a/navit/support/libc/libc.c b/navit/support/libc/libc.c
index 17b20792c..a71f32994 100644
--- a/navit/support/libc/libc.c
+++ b/navit/support/libc/libc.c
@@ -184,7 +184,7 @@ __int64 _lseeki64(int FileHandle, __int64 Offset, int Origin)
return 0;
}
-intptr_t _get_osfhandle(int FileHandle)
+int * _get_osfhandle(int FileHandle)
{
return 0;
}
diff --git a/navit/support/libc/localtime.c b/navit/support/libc/localtime.c
new file mode 100644
index 000000000..245b51c5a
--- /dev/null
+++ b/navit/support/libc/localtime.c
@@ -0,0 +1,38 @@
+/*
+ * localtime.c: localtime implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include "timeutil.h"
+
+struct tm *
+localtime(const time_t *timer)
+{
+ SYSTEMTIME ss, ls, s;
+ FILETIME sf, lf, f;
+ long long t, diff;
+
+ static struct tm tms;
+
+ GetSystemTime (&ss);
+ GetLocalTime (&ls);
+
+ SystemTimeToFileTime (&ss, &sf);
+ SystemTimeToFileTime (&ls, &lf);
+
+ diff = __FILETIME_to_ll (&sf) - __FILETIME_to_ll (&lf);
+
+ __time_t_to_FILETIME (*timer, &f);
+ t = __FILETIME_to_ll (&f) - diff;
+ __ll_to_FILETIME (t, &f);
+ FileTimeToSystemTime (&f, &s);
+ __SYSTEMTIME_to_tm (&s, &tms);
+
+ return &tms;
+}
diff --git a/navit/support/libc/lseek.c b/navit/support/libc/lseek.c
new file mode 100644
index 000000000..4600c0d11
--- /dev/null
+++ b/navit/support/libc/lseek.c
@@ -0,0 +1,41 @@
+/*
+ * lseek.c: lseek implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include <windows.h>
+#include <unistd.h>
+
+long
+_lseek (int fildes, long offset, int whence)
+{
+ DWORD mode;
+ switch (whence)
+ {
+ case SEEK_SET:
+ mode = FILE_BEGIN;
+ break;
+ case SEEK_CUR:
+ mode = FILE_CURRENT;
+ break;
+ case SEEK_END:
+ mode = FILE_END;
+ break;
+ default:
+ /* Specify an invalid mode so SetFilePointer catches it. */
+ mode = (DWORD)-1;
+ }
+ return (long) SetFilePointer ((HANDLE) fildes, offset, NULL, mode);
+}
+
+long
+lseek (int fildes, long offset, int whence)
+{
+ return _lseek (fildes, offset, whence);
+}
diff --git a/navit/support/libc/math.h b/navit/support/libc/math.h
new file mode 100644
index 000000000..e85a89455
--- /dev/null
+++ b/navit/support/libc/math.h
@@ -0,0 +1,13 @@
+#define M_E 2.7182818284590452354
+#define M_LOG2E 1.4426950408889634074
+#define M_LOG10E 0.43429448190325182765
+#define M_LN2 0.69314718055994530942
+#define M_LN10 2.30258509299404568402
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
+#define M_PI_4 0.78539816339744830962
+#define M_1_PI 0.31830988618379067154
+#define M_2_PI 0.63661977236758134308
+#define M_2_SQRTPI 1.12837916709551257390
+#define M_SQRT2 1.41421356237309504880
+#define M_SQRT1_2 0.70710678118654752440
diff --git a/navit/support/libc/mkdir.c b/navit/support/libc/mkdir.c
new file mode 100644
index 000000000..ae8d21d85
--- /dev/null
+++ b/navit/support/libc/mkdir.c
@@ -0,0 +1,29 @@
+/*
+ * mkdir.c: mkdir implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public
+ * Domain. This file is a part of the mingw32ce package. No
+ * warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> 24 Jun 2007
+ *
+ */
+
+#include <windows.h>
+#include <io.h>
+
+int
+_mkdir (const char *dirname)
+{
+ wchar_t dirnamew[MAX_PATH];
+ mbstowcs (dirnamew, dirname, MAX_PATH);
+ if (!CreateDirectoryW (dirnamew, NULL))
+ return -1;
+ return 0;
+}
+
+int
+mkdir (const char *dirname)
+{
+ return _mkdir (dirname);
+}
diff --git a/navit/support/libc/mktime.c b/navit/support/libc/mktime.c
new file mode 100644
index 000000000..bd34fbf61
--- /dev/null
+++ b/navit/support/libc/mktime.c
@@ -0,0 +1,32 @@
+/*
+ * mktime.c: mktime implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include "timeutil.h"
+
+time_t
+mktime (struct tm *pt)
+{
+ SYSTEMTIME ss, ls, s;
+ FILETIME sf, lf, f;
+ long long diff;
+
+ GetSystemTime (&ss);
+ GetLocalTime (&ls);
+ SystemTimeToFileTime (&ss, &sf);
+ SystemTimeToFileTime (&ls, &lf);
+
+ diff = __FILETIME_to_ll (&lf) - __FILETIME_to_ll (&sf);
+ diff /= _onesec_in100ns;
+
+ __tm_to_SYSTEMTIME (pt, &s);
+ SystemTimeToFileTime (&s, &f);
+ return __FILETIME_to_time_t (&f) - (time_t)diff;
+}
diff --git a/navit/support/libc/open.c b/navit/support/libc/open.c
new file mode 100644
index 000000000..210281706
--- /dev/null
+++ b/navit/support/libc/open.c
@@ -0,0 +1,135 @@
+/*
+ * open.c: open, _open and_wopen implementations for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include <windows.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+static int
+vwopen (const wchar_t *wpath, int oflag, va_list ap)
+{
+ DWORD fileaccess;
+ DWORD fileshare;
+ DWORD filecreate;
+ DWORD fileattrib;
+ HANDLE hnd;
+
+ switch (oflag & (O_RDONLY | O_WRONLY | O_RDWR))
+ {
+ case O_RDONLY:
+ fileaccess = GENERIC_READ;
+ break;
+ case O_WRONLY:
+ fileaccess = GENERIC_WRITE;
+ break;
+ case O_RDWR:
+ fileaccess = GENERIC_READ | GENERIC_WRITE;
+ break;
+ default:
+ return -1;
+ }
+
+ switch (oflag & (O_CREAT | O_EXCL | O_TRUNC))
+ {
+ case 0:
+ case O_EXCL: /* ignore EXCL w/o CREAT */
+ filecreate = OPEN_EXISTING;
+ break;
+ case O_CREAT:
+ filecreate = OPEN_ALWAYS;
+ break;
+ case O_CREAT | O_EXCL:
+ case O_CREAT | O_TRUNC | O_EXCL:
+ filecreate = CREATE_NEW;
+ break;
+
+ case O_TRUNC:
+ case O_TRUNC | O_EXCL: /* ignore EXCL w/o CREAT */
+ filecreate = TRUNCATE_EXISTING;
+ break;
+ case O_CREAT | O_TRUNC:
+ filecreate = CREATE_ALWAYS;
+ break;
+ default:
+ /* this can't happen ... all cases are covered */
+ return -1;
+ }
+
+ fileshare = 0;
+ if (oflag & O_CREAT)
+ {
+ int pmode = va_arg (ap, int);
+ if ((pmode & S_IREAD) == S_IREAD)
+ fileshare |= FILE_SHARE_READ;
+ if ((pmode & S_IWRITE) == S_IWRITE)
+ fileshare |= FILE_SHARE_WRITE;
+ }
+
+ fileattrib = FILE_ATTRIBUTE_NORMAL;
+
+ hnd = CreateFileW (wpath, fileaccess, fileshare, NULL, filecreate,
+ fileattrib, NULL);
+ if (hnd == INVALID_HANDLE_VALUE)
+ return -1;
+
+ if (oflag & O_APPEND)
+ SetFilePointer (hnd, 0, NULL, FILE_END);
+
+ return (int) hnd;
+}
+
+static int
+vopen (const char *path, int oflag, va_list ap)
+{
+ wchar_t wpath[MAX_PATH];
+
+ size_t path_len = strlen (path);
+ if (path_len >= MAX_PATH)
+ return -1;
+
+ mbstowcs (wpath, path, path_len + 1);
+
+ return vwopen (wpath, oflag, ap);
+}
+
+int
+_open (const char *path, int oflag, ...)
+{
+ va_list ap;
+ int ret;
+ va_start (ap, oflag);
+ ret = vopen (path, oflag, ap);
+ va_end (ap);
+ return ret;
+}
+
+int
+open (const char *path, int oflag, ...)
+{
+ va_list ap;
+ int ret;
+ va_start (ap, oflag);
+ ret = vopen (path, oflag, ap);
+ va_end (ap);
+ return ret;
+}
+
+int
+_wopen (const wchar_t *path, int oflag, ...)
+{
+ va_list ap;
+ int ret;
+ va_start (ap, oflag);
+ ret = vwopen (path, oflag, ap);
+ va_end (ap);
+ return ret;
+}
diff --git a/navit/support/libc/process.h b/navit/support/libc/process.h
new file mode 100644
index 000000000..ecd67a555
--- /dev/null
+++ b/navit/support/libc/process.h
@@ -0,0 +1,147 @@
+/*
+ * process.h
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Function calls for spawning child processes.
+ *
+ */
+
+#ifndef _PROCESS_H_
+#define _PROCESS_H_
+#if 0
+
+/* All the headers include this file. */
+#include <_mingw.h>
+
+#include <sys/types.h> /* For _pid_t and pid_t. */
+#include <stdint.h> /* For intptr_t. */
+/*
+ * Constants for cwait actions.
+ * Obsolete for Win32.
+ */
+#define _WAIT_CHILD 0
+#define _WAIT_GRANDCHILD 1
+
+#ifndef _NO_OLDNAMES
+#define WAIT_CHILD _WAIT_CHILD
+#define WAIT_GRANDCHILD _WAIT_GRANDCHILD
+#endif /* Not _NO_OLDNAMES */
+
+/*
+ * Mode constants for spawn functions.
+ */
+#define _P_WAIT 0
+#define _P_NOWAIT 1
+#define _P_OVERLAY 2
+#define _OLD_P_OVERLAY _P_OVERLAY
+#define _P_NOWAITO 3
+#define _P_DETACH 4
+
+#ifndef _NO_OLDNAMES
+#define P_WAIT _P_WAIT
+#define P_NOWAIT _P_NOWAIT
+#define P_OVERLAY _P_OVERLAY
+#define OLD_P_OVERLAY _OLD_P_OVERLAY
+#define P_NOWAITO _P_NOWAITO
+#define P_DETACH _P_DETACH
+#endif /* Not _NO_OLDNAMES */
+
+
+#ifndef RC_INVOKED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __COREDLL__
+
+_CRTIMP void __cdecl __MINGW_NOTHROW _cexit(void);
+_CRTIMP void __cdecl __MINGW_NOTHROW _c_exit(void);
+
+_CRTIMP int __cdecl __MINGW_NOTHROW _cwait (int*, _pid_t, int);
+
+_CRTIMP _pid_t __cdecl __MINGW_NOTHROW _getpid(void);
+
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execl (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execle (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execlp (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execlpe (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execv (const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execve (const char*, const char* const*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execvp (const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execvpe (const char*, const char* const*, const char* const*);
+
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnl (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnle (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnlp (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnlpe (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnv (int, const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnve (int, const char*, const char* const*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnvp (int, const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnvpe (int, const char*, const char* const*, const char* const*);
+
+#endif /* !__COREDLL__*/
+
+/*
+ * The functions _beginthreadex and _endthreadex are not provided by CRTDLL.
+ * They are provided by MSVCRT.
+ *
+ * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread,
+ * making for race conditions if you are not careful. Basically you have to
+ * make sure that no-one is going to do *anything* with the thread handle
+ * after the thread calls _endthread or returns from the thread function.
+ *
+ * NOTE: No old names for these functions. Use the underscore.
+ */
+#if defined (__MSVCRT__) || defined (__CRTDLL__)
+_CRTIMP unsigned long __cdecl __MINGW_NOTHROW
+ _beginthread (void (*)(void *), unsigned, void*);
+_CRTIMP void __cdecl __MINGW_NOTHROW _endthread (void);
+#endif
+
+#ifdef __MSVCRT__
+_CRTIMP unsigned long __cdecl __MINGW_NOTHROW
+ _beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *),
+ void*, unsigned, unsigned*);
+_CRTIMP void __cdecl __MINGW_NOTHROW _endthreadex (unsigned);
+#endif
+
+
+#ifndef _NO_OLDNAMES
+#ifndef __COREDLL__
+/*
+ * Functions without the leading underscore, for portability. These functions
+ * live in liboldnames.a.
+ */
+_CRTIMP int __cdecl __MINGW_NOTHROW cwait (int*, pid_t, int);
+_CRTIMP pid_t __cdecl __MINGW_NOTHROW getpid (void);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execl (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execle (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execlp (const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execlpe (const char*, const char*,...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execv (const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execve (const char*, const char* const*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execvp (const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execvpe (const char*, const char* const*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnl (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnle (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnlp (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnlpe (int, const char*, const char*, ...);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnv (int, const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnve (int, const char*, const char* const*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnvp (int, const char*, const char* const*);
+_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnvpe (int, const char*, const char* const*, const char* const*);
+#endif /* Not __COREDLL__ */
+
+#endif /* Not _NO_OLDNAMES */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* Not RC_INVOKED */
+#endif
+
+#endif /* _PROCESS_H_ not defined */
diff --git a/navit/support/libc/read.c b/navit/support/libc/read.c
new file mode 100644
index 000000000..8ce99d8ff
--- /dev/null
+++ b/navit/support/libc/read.c
@@ -0,0 +1,30 @@
+/*
+ * read.c: read and _read implementations for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include <windows.h>
+#include <unistd.h>
+
+int
+_read (int fildes, void *buf, unsigned int bufsize)
+{
+ DWORD NumberOfBytesRead;
+ if (bufsize > 0x7fffffff)
+ bufsize = 0x7fffffff;
+ if (!ReadFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesRead, NULL))
+ return -1;
+ return (int) NumberOfBytesRead;
+}
+
+int
+read (int fildes, void *buf, unsigned int bufsize)
+{
+ return _read (fildes, buf, bufsize);
+}
diff --git a/navit/support/libc/rename.c b/navit/support/libc/rename.c
new file mode 100644
index 000000000..23ca19630
--- /dev/null
+++ b/navit/support/libc/rename.c
@@ -0,0 +1,27 @@
+/*
+ * rename.c: rename implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include <windows.h>
+
+/* We return an error if the TO file already exists,
+ like the Windows NT/9x 'rename' does. */
+
+int
+rename (const char* from, const char* to)
+{
+ wchar_t fromw[MAX_PATH + 1];
+ wchar_t tow[MAX_PATH + 1];
+ mbstowcs (fromw, from, MAX_PATH);
+ mbstowcs (tow, to, MAX_PATH);
+ if (MoveFileW (fromw, tow))
+ return 0;
+ return -1;
+}
diff --git a/navit/support/libc/stat.c b/navit/support/libc/stat.c
new file mode 100644
index 000000000..e6ed452e0
--- /dev/null
+++ b/navit/support/libc/stat.c
@@ -0,0 +1,151 @@
+/*
+ * stat.c: _stat, stat and fstat implementations for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> 10 Feb 2007
+ *
+ */
+
+#include <windows.h>
+#include <time.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include "debug.h"
+
+#include "timeutil.h"
+
+struct stat_file_info_t
+{
+ DWORD dwFileAttributes;
+ FILETIME ftLastWriteTime;
+ FILETIME ftCreationTime;
+ FILETIME ftLastAccessTime;
+ DWORD nFileSizeLow;
+};
+
+#define COPY_MEMBER(DEST, SRC, MEMBER) \
+ do { \
+ (DEST)->MEMBER = (SRC)->MEMBER; \
+ } while (0)
+
+#define TO_STAT_FILE_INFO(DEST, SRC) \
+ do { \
+ COPY_MEMBER (DEST, SRC, dwFileAttributes); \
+ COPY_MEMBER (DEST, SRC, ftLastWriteTime); \
+ COPY_MEMBER (DEST, SRC, ftCreationTime); \
+ COPY_MEMBER (DEST, SRC, ftLastAccessTime); \
+ COPY_MEMBER (DEST, SRC, nFileSizeLow); \
+ } while (0)
+
+static int
+__stat_by_file_info (struct stat_file_info_t *fi, struct _stat *st, int exec)
+{
+ int permission = _S_IREAD;
+
+ memset (st, 0, sizeof (*st));
+
+ st->st_size = fi->nFileSizeLow;
+ st->st_mode = _S_IFREG;
+
+ if((fi->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ st->st_mode = _S_IFDIR | _S_IEXEC;
+ else if (exec)
+ permission |= _S_IEXEC;
+
+ if((fi->dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0)
+ permission |= _S_IWRITE;
+
+ st->st_mode |= permission | (permission >> 3) | (permission >> 6);
+
+ st->st_nlink = 1; /* always 1? */
+ st->st_rdev = 1; /* Where to get drive info? */
+ st->st_ino = 0; /* always 0 on Windows */
+
+ st->st_mtime = __FILETIME_to_time_t (&fi->ftLastWriteTime);
+ st->st_ctime = __FILETIME_to_time_t (&fi->ftCreationTime);
+ st->st_atime = __FILETIME_to_time_t (&fi->ftLastAccessTime);
+
+ /* Looks like the code below is never triggered.
+ Windows CE always only keeps the LastWriteTime, and
+ copies it to the CreationTime and LastAccessTime fields. */
+ if (st->st_ctime == 0)
+ st->st_ctime = st->st_mtime;
+ if (st->st_atime == 0)
+ {
+ /* On XP, at least, the st_atime is always set to the same as
+ the st_mtime, except the hour/min/sec == 00:00:00. */
+ SYSTEMTIME s;
+ FILETIME f = fi->ftLastWriteTime;
+ FileTimeToSystemTime (&f, &s);
+ s.wHour = 0; s.wMinute = 0;
+ s.wSecond = 0; s.wMilliseconds = 0;
+ SystemTimeToFileTime (&s, &f);
+ st->st_atime = __FILETIME_to_time_t (&f);
+ /* st->st_atime = st->st_mtime; */
+ }
+ return 0;
+}
+
+int
+_fstat (int fd, struct _stat *st)
+{
+ BY_HANDLE_FILE_INFORMATION fi;
+ struct stat_file_info_t sfi;
+
+ if (!GetFileInformationByHandle ((HANDLE) fd, &fi))
+ return -1;
+ TO_STAT_FILE_INFO (&sfi, &fi);
+ return __stat_by_file_info (&sfi, st, 0);
+}
+
+int
+fstat (int fd, struct stat *st)
+{
+ return _fstat (fd, (struct _stat *)st);
+}
+
+int
+_stat (const char *path, struct _stat *st)
+{
+ WIN32_FIND_DATAW fd;
+ HANDLE h;
+ int ret;
+ struct stat_file_info_t sfi;
+ wchar_t pathw[MAX_PATH + 1];
+ size_t len;
+ int exec;
+
+ dbg(0,"path=%s\n",path);
+ mbstowcs (pathw, path, MAX_PATH);
+ dbg(0,"wide path=%S\n",pathw);
+ if((h = FindFirstFileW (pathw, &fd)) == INVALID_HANDLE_VALUE)
+ {
+ DWORD dwError = GetLastError ();
+ dbg(0,"no file\n");
+ if(dwError == ERROR_NO_MORE_FILES)
+ /* Convert error to something more sensible. */
+ SetLastError (ERROR_FILE_NOT_FOUND);
+ return -1;
+ }
+
+ TO_STAT_FILE_INFO (&sfi, &fd);
+
+ len = strlen (path);
+ exec = (len >= 4
+ && strcasecmp (path + len - 4, ".exe") == 0);
+ ret = __stat_by_file_info (&sfi, st, exec);
+ dbg(0,"ret=%d\n",ret);
+ FindClose (h);
+ return ret;
+}
+
+int
+stat (const char *path, struct stat *st)
+{
+ return _stat (path, (struct _stat *)st);
+}
diff --git a/navit/support/libc/time.c b/navit/support/libc/time.c
new file mode 100644
index 000000000..b167d5e30
--- /dev/null
+++ b/navit/support/libc/time.c
@@ -0,0 +1,28 @@
+/*
+ * time.c: time implementation for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include "timeutil.h"
+
+time_t
+time (time_t *timer)
+{
+ SYSTEMTIME s;
+ FILETIME f;
+ time_t t;
+
+ if (timer == NULL)
+ timer = &t;
+
+ GetSystemTime (&s);
+ SystemTimeToFileTime (&s, &f);
+ *timer = __FILETIME_to_time_t (&f);
+ return *timer;
+}
diff --git a/navit/support/libc/timeutil.c b/navit/support/libc/timeutil.c
new file mode 100644
index 000000000..433bbbb58
--- /dev/null
+++ b/navit/support/libc/timeutil.c
@@ -0,0 +1,126 @@
+#include "timeutil.h"
+
+/* Originally based on code found in the Ruby WinCE support, which
+ had the following notice: */
+
+/* start original header */
+
+/***************************************************************
+ time.c
+
+ author : uema2
+ date : Nov 30, 2002
+
+ You can freely use, copy, modify, and redistribute
+ the whole contents.
+***************************************************************/
+
+/* end original header */
+
+/* Note: The original filename was: wince/time_wce.c */
+
+/* Adapted to mingw32ce by Pedro Alves <pedro_alves@portugalmail.pt>
+ 10 Feb 2007 - Initial revision. */
+
+#define DELTA_EPOCH 116444736000000000LL
+
+#if 0
+how_to_calc_delta_epoch ()
+{
+ FILETIME f1601, f1970;
+ __FILETIME_from_Year (1601, &f1601);
+ __FILETIME_from_Year (1970, &f1970);
+ DELTA_EPOCH = __FILETIME_to_ll (&f1970) - __FILETIME_to_ll (&f1601);
+}
+#endif
+
+long long
+__FILETIME_to_ll (const FILETIME *f)
+{
+ long long t;
+ t = (long long)f->dwHighDateTime << 32;
+ t |= f->dwLowDateTime;
+ return t;
+}
+
+void
+__ll_to_FILETIME (long long t, FILETIME* f)
+{
+ f->dwHighDateTime = (DWORD)((t >> 32) & 0x00000000FFFFFFFF);
+ f->dwLowDateTime = (DWORD)(t & 0x00000000FFFFFFFF);
+}
+
+void
+__tm_to_SYSTEMTIME (struct tm *t, SYSTEMTIME *s)
+{
+ s->wYear = t->tm_year + 1900;
+ s->wMonth = t->tm_mon + 1;
+ s->wDayOfWeek = t->tm_wday;
+ s->wDay = t->tm_mday;
+ s->wHour = t->tm_hour;
+ s->wMinute = t->tm_min;
+ s->wSecond = t->tm_sec;
+ s->wMilliseconds = 0;
+}
+
+static void
+__FILETIME_from_Year (WORD year, FILETIME *f)
+{
+ SYSTEMTIME s = {0};
+
+ s.wYear = year;
+ s.wMonth = 1;
+ s.wDayOfWeek = 1;
+ s.wDay = 1;
+
+ SystemTimeToFileTime (&s, f);
+}
+
+static int
+__Yday_from_SYSTEMTIME (const SYSTEMTIME *s)
+{
+ long long t;
+ FILETIME f1, f2;
+
+ __FILETIME_from_Year (s->wYear, &f1);
+ SystemTimeToFileTime (s, &f2);
+
+ t = __FILETIME_to_ll (&f2) - __FILETIME_to_ll (&f1);
+
+ return ((t / _onesec_in100ns) / (60 * 60 * 24));
+}
+
+void
+__SYSTEMTIME_to_tm (SYSTEMTIME *s, struct tm *tm)
+{
+ tm->tm_year = s->wYear - 1900;
+ tm->tm_mon = s->wMonth- 1;
+ tm->tm_wday = s->wDayOfWeek;
+ tm->tm_mday = s->wDay;
+ tm->tm_yday = __Yday_from_SYSTEMTIME (s);
+ tm->tm_hour = s->wHour;
+ tm->tm_min = s->wMinute;
+ tm->tm_sec = s->wSecond;
+ tm->tm_isdst = 0;
+}
+
+time_t
+__FILETIME_to_time_t (const FILETIME* f)
+{
+ long long t;
+ t = __FILETIME_to_ll (f);
+ t -= DELTA_EPOCH;
+ return (time_t)(t / _onesec_in100ns);
+}
+
+void
+__time_t_to_FILETIME (time_t t, FILETIME *f)
+{
+ long long time;
+
+ time = t;
+ time *= _onesec_in100ns;
+ time += DELTA_EPOCH;
+
+ __ll_to_FILETIME (time, f);
+}
diff --git a/navit/support/libc/timeutil.h b/navit/support/libc/timeutil.h
new file mode 100644
index 000000000..9e5f70886
--- /dev/null
+++ b/navit/support/libc/timeutil.h
@@ -0,0 +1,17 @@
+#ifndef __TIMEUTIL_H
+#define __TIMEUTIL_H
+
+#include <windows.h>
+#include <sys/time.h>
+#include <_mingw.h>
+
+#define _onesec_in100ns 10000000LL
+
+extern long long __FILETIME_to_ll (const FILETIME *f);
+extern void __ll_to_FILETIME (long long t, FILETIME* f);
+extern void __tm_to_SYSTEMTIME (struct tm *, SYSTEMTIME *);
+extern void __SYSTEMTIME_to_tm (SYSTEMTIME *, struct tm *);
+extern time_t __FILETIME_to_time_t (const FILETIME *);
+extern void __time_t_to_FILETIME (time_t, FILETIME *);
+
+#endif
diff --git a/navit/support/libc/unistd.h b/navit/support/libc/unistd.h
new file mode 100644
index 000000000..d1a435168
--- /dev/null
+++ b/navit/support/libc/unistd.h
@@ -0,0 +1,48 @@
+#ifndef _UNISTD_H
+/*
+ * This file is part of the Mingw32 package.
+ *
+ * unistd.h maps (roughly) to io.h
+ * Other headers included by unistd.h may be selectively processed;
+ * __UNISTD_H_SOURCED__ enables such selective processing.
+ */
+#define _UNISTD_H
+#define __UNISTD_H_SOURCED__ 1
+
+#include <io.h>
+#include <process.h>
+#include <getopt.h>
+
+/* These are also defined in stdio.h. */
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END 2
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined __NO_ISOCEXT
+#include <sys/types.h> /* For useconds_t. */
+
+int __cdecl __MINGW_NOTHROW usleep(useconds_t useconds);
+#endif /* Not __NO_ISOCEXT */
+
+/* This is defined as a real library function to allow autoconf
+ to verify its existence. */
+int ftruncate(int, off_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef __UNISTD_H_SOURCED__
+#endif /* _UNISTD_H */
diff --git a/navit/support/libc/unlink.c b/navit/support/libc/unlink.c
new file mode 100644
index 000000000..9e3f9b582
--- /dev/null
+++ b/navit/support/libc/unlink.c
@@ -0,0 +1,29 @@
+/*
+ * unlink.c: unlink and _unlink implementations for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+
+#include <stdio.h>
+#include <windows.h>
+
+int
+_unlink (const char *file)
+{
+ wchar_t wfile[MAX_PATH];
+ size_t conv = mbstowcs (wfile, file, MAX_PATH);
+ if (conv > 0 && conv < MAX_PATH && DeleteFileW (wfile))
+ return 0;
+ return -1;
+}
+
+int
+unlink (const char *file)
+{
+ return _unlink (file);
+}
diff --git a/navit/support/libc/write.c b/navit/support/libc/write.c
new file mode 100644
index 000000000..b9521aefc
--- /dev/null
+++ b/navit/support/libc/write.c
@@ -0,0 +1,29 @@
+/*
+ * write.c: write and _write implementations for WinCE.
+ *
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is a part of the mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within the package.
+ *
+ * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
+ *
+ */
+#include <windows.h>
+#include <unistd.h>
+
+int
+_write (int fildes, const void *buf, unsigned int bufsize)
+{
+ DWORD NumberOfBytesWritten;
+ if (bufsize > 0x7fffffff)
+ bufsize = 0x7fffffff;
+ if (!WriteFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesWritten, NULL))
+ return -1;
+ return (int) NumberOfBytesWritten;
+}
+
+int
+write (int fildes, const void *buf, unsigned int bufsize)
+{
+ return _write (fildes, buf, bufsize);
+}