[svn] gpg-error - r259 - in trunk: . src
svn author marcus
cvs at cvs.gnupg.org
Fri Oct 29 20:10:12 CEST 2010
Author: marcus
Date: 2010-10-29 20:10:11 +0200 (Fri, 29 Oct 2010)
New Revision: 259
Modified:
trunk/ChangeLog
trunk/src/init.c
trunk/src/w32-gettext.c
Log:
2010-10-29 Marcus Brinkmann <marcus.brinkmann at ruhr-uni-bochum.de>
* src/w32-gettext.c: Guard include of <sys/types.h>. Do not
include <sys/stat.h>.
(CreateFileA) [HAVE_W32CE_SYSTEM]: New wrapper function.
(load_domain): Use native Windows API.
* src/init.c (TLS_OUT_OF_INDEXES) [HAVE_W32CE_SYSTEM,
!TLS_OUT_OF_INDEXES]: Define it.
(abort) [!__MINGW32CE__]: Define it.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-10-29 18:07:14 UTC (rev 258)
+++ trunk/ChangeLog 2010-10-29 18:10:11 UTC (rev 259)
@@ -1,3 +1,14 @@
+2010-10-29 Marcus Brinkmann <marcus.brinkmann at ruhr-uni-bochum.de>
+
+ * src/w32-gettext.c: Guard include of <sys/types.h>. Do not
+ include <sys/stat.h>.
+ (CreateFileA) [HAVE_W32CE_SYSTEM]: New wrapper function.
+ (load_domain): Use native Windows API.
+
+ * src/init.c (TLS_OUT_OF_INDEXES) [HAVE_W32CE_SYSTEM,
+ !TLS_OUT_OF_INDEXES]: Define it.
+ (abort) [!__MINGW32CE__]: Define it.
+
2010-10-28 Werner Koch <wk at g10code.com>
* contrib/conf-w32ce-msc/build.mk: New.
Modified: trunk/src/init.c
===================================================================
--- trunk/src/init.c 2010-10-29 18:07:14 UTC (rev 258)
+++ trunk/src/init.c 2010-10-29 18:10:11 UTC (rev 259)
@@ -33,6 +33,12 @@
#ifdef HAVE_W32CE_SYSTEM
# include "mkw32errmap.map.c" /* Generated map_w32codes () */
+# ifndef TLS_OUT_OF_INDEXES
+# define TLS_OUT_OF_INDEXES 0xFFFFFFFF
+# endif
+# ifndef __MINGW32CE__
+# define abort() exit(1)
+# endif
#endif
Modified: trunk/src/w32-gettext.c
===================================================================
--- trunk/src/w32-gettext.c 2010-10-29 18:07:14 UTC (rev 258)
+++ trunk/src/w32-gettext.c 2010-10-29 18:10:11 UTC (rev 259)
@@ -30,8 +30,9 @@
#include <string.h>
#include <errno.h>
#include <ctype.h>
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
-#include <sys/stat.h>
+#endif
#include <stdint.h>
#ifndef HAVE_W32CE_SYSTEM
# include <locale.h>
@@ -52,6 +53,36 @@
#include "init.h"
#include "gpg-error.h"
+#ifdef HAVE_W32CE_SYSTEM
+/* Forward declaration. */
+static wchar_t *utf8_to_wchar (const char *string, size_t length, size_t *retlen);
+
+static HANDLE
+CreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwSharedMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
+ HANDLE hTemplateFile)
+{
+ wchar_t *filename;
+ HANDLE result;
+ int err;
+ size_t size;
+
+ filename = utf8_to_wchar (lpFileName, -1, &size);
+ if (!filename)
+ return INVALID_HANDLE_VALUE;
+
+ result = CreateFileW (filename, dwDesiredAccess, dwSharedMode,
+ lpSecurityAttributes, dwCreationDisposition,
+ dwFlagsAndAttributes, hTemplateFile);
+
+ err = GetLastError ();
+ free (filename);
+ SetLastError (err);
+ return result;
+}
+#endif
+
/* localname.c from gettext BEGIN. */
@@ -611,7 +642,9 @@
static const char *
my_nl_locale_name (const char *categoryname)
{
+#ifndef HAVE_W32CE_SYSTEM
const char *retval;
+#endif
LCID lcid;
LANGID langid;
int primary, sub;
@@ -1194,31 +1227,28 @@
static struct loaded_domain *
load_domain (const char *filename)
{
- FILE *fp;
- size_t size;
- struct stat st;
+ HANDLE fh;
+ DWORD size;
struct mo_file_header *data = NULL;
struct loaded_domain *domain = NULL;
size_t to_read;
char *read_ptr;
-
- fp = fopen (filename, "rb");
- if (!fp)
+
+ fh = CreateFileA (filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ if (fh == INVALID_HANDLE_VALUE)
+ return NULL;
+
+ size = GetFileSize (fh, NULL);
+ if (size == INVALID_FILE_SIZE)
{
+ CloseHandle (fh);
return NULL;
}
- if (fstat (fileno (fp), &st)
- || (size = (size_t) st.st_size) != st.st_size
- || size < sizeof (struct mo_file_header))
- {
- fclose (fp);
- return NULL;
- }
data = (2*size <= size)? NULL : jnlib_malloc (2*size);
if (!data)
{
- fclose (fp);
+ CloseHandle (fh);
return NULL;
}
@@ -1226,10 +1256,13 @@
read_ptr = (char *) data;
do
{
- long int nb = fread (read_ptr, 1, to_read, fp);
- if (nb < to_read)
+ BOOL res;
+ DWORD nb;
+
+ res = ReadFile (fh, read_ptr, to_read, &nb, NULL);
+ if (! res || nb < to_read)
{
- fclose (fp);
+ CloseHandle (fh);
jnlib_free (data);
return NULL;
}
@@ -1237,7 +1270,7 @@
to_read -= nb;
}
while (to_read > 0);
- fclose (fp);
+ CloseHandle (fh);
/* Using the magic number we can test whether it really is a message
catalog file. */
More information about the Gnupg-commits
mailing list