diff options
author | Werner Koch <wk@gnupg.org> | 2010-04-14 10:57:58 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2010-04-14 10:57:58 +0000 |
commit | affc038274ff32b3b7f73a7ee9ac76aff7b32a07 (patch) | |
tree | f45bcea5f1b0909f102f5c5546104fcac89948d5 | |
parent | 62c3d9021917515daf83a89a886e180772f7a530 (diff) | |
download | libgpg-error-affc038274ff32b3b7f73a7ee9ac76aff7b32a07.tar.gz |
MAp some W32 error codes.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/Makefile.am | 13 | ||||
-rw-r--r-- | src/init.c | 11 | ||||
-rw-r--r-- | src/mkw32errmap.c | 98 |
4 files changed, 79 insertions, 51 deletions
@@ -1,3 +1,11 @@ +2010-04-14 Werner Koch <wk@g10code.com> + + * src/init.c (_gpg_w32ce_get_errno): Add native error mapping. + * src/Makefile.am (mkw32errmap.map.c): New. + * src/mkw32errmap.c (struct table_s): Add field W32CODE2. + (table): Init this field. + (main): Add option --map. + 2010-03-15 Werner Koch <wk@g10code.com> * src/mkheader.awk: Add emacs local-var line. diff --git a/src/Makefile.am b/src/Makefile.am index c211c09..2295758 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,14 +47,14 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \ BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ - gpg-error.def extra-h.in + gpg-error.def extra-h.in mkw32errmap.map.c -tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h +tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ - err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-extra/errno.h \ - extra-h.in $(tmp_files) + mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ + gpg-extra/errno.h extra-h.in $(tmp_files) if HAVE_W32_SYSTEM arch_sources = w32-gettext.c @@ -142,9 +142,14 @@ if HAVE_W32CE_SYSTEM mkw32errmap.tab.h: Makefile mkw32errmap.c $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \ grep '{&mkw32errmap_marker' >$@ +mkw32errmap.map.c: mkw32errmap + ./mkw32errmap --map > $@ gpg-extra/errno.h: mkw32errmap -$(MKDIR_P) gpg-extra ./mkw32errmap > $@ +else +mkw32errmap.map.c: + echo "/*dummy*/" > $@ endif # We use CC proper for preprocessing thus we have to convince it that @@ -31,6 +31,10 @@ #include "gettext.h" #include "init.h" +#ifdef HAVE_W32CE_SYSTEM +# include "mkw32errmap.map.c" /* Generated map_w32codes () */ +#endif + /* Locale directory support. */ @@ -239,12 +243,7 @@ get_tls (void) int _gpg_w32ce_get_errno (void) { - int err; - - err = GetLastError (); - /* FIXME: Should we fold some W32 error codes into the same errno - value? */ - return err; + return map_w32codes ( GetLastError () ); } #endif /*HAVE_W32CE_SYSTEM*/ diff --git a/src/mkw32errmap.c b/src/mkw32errmap.c index 722e07e..68d0f05 100644 --- a/src/mkw32errmap.c +++ b/src/mkw32errmap.c @@ -72,47 +72,45 @@ struct table_s int *dummy; const char *name; int w32code; + int w32code2; }; struct table_s table[] = { #ifdef RESOLVE_MACROS -#define X(a,b) \ - {&mkw32errmap_marker, (a), (b)} - X( "EPERM", ERROR_CANNOT_MAKE ), - X( "ENOENT", ERROR_FILE_NOT_FOUND ), - X( "EINTR", ERROR_INVALID_AT_INTERRUPT_TIME ), - X( "EIO", ERROR_IO_DEVICE ), - X( "ENXIO", ERROR_FILE_INVALID ), - X( "EBADF", ERROR_INVALID_HANDLE ), - X( "EAGAIN", ERROR_MORE_DATA ), - /* FIXME: Add WSAEWOULDBLOCK */ - - X( "ENOMEM", ERROR_NOT_ENOUGH_MEMORY ), - X( "EACCES", ERROR_ACCESS_DENIED ), - X( "EFAULT", ERROR_PROCESS_ABORTED ), - X( "EBUSY", ERROR_BUSY ), - X( "EEXIST", ERROR_FILE_EXISTS ), - /* FIXME: Add WSAEADDRINUSE. */ - - X( "EXDEV", ERROR_NOT_SAME_DEVICE ), - X( "ENODEV", ERROR_BAD_DEVICE ), - /* FIXME: ERROR_DEV_NOT_EXIST */ - - X( "ENOTDIR",ERROR_DIRECTORY ), - X( "EINVAL", ERROR_INVALID_PARAMETER ), - X( "ENFILE", ERROR_NO_MORE_FILES ), - X( "EMFILE", ERROR_TOO_MANY_OPEN_FILES ), - X( "ENOSPC", ERROR_DISK_FULL ), - X( "EROFS", ERROR_WRITE_PROTECT ), - X( "EPIPE", ERROR_BROKEN_PIPE ), - X( "ERANGE", ERROR_ARITHMETIC_OVERFLOW ), - X( "EDEADLOCK",ERROR_POSSIBLE_DEADLOCK ), - X( "ENAMETOOLONG", ERROR_FILENAME_EXCED_RANGE ), - X( "ENOLCK", ERROR_SHARING_BUFFER_EXCEEDED ), - X( "ENOSYS", ERROR_NOT_SUPPORTED ), - X( "ENOTEMPTY",ERROR_DIR_NOT_EMPTY ), - X( "ESPIPE", ERROR_SEEK_ON_DEVICE ), +#define X(a,b,c) \ + {&mkw32errmap_marker, (a), (b), (c)} + X( "EPERM", ERROR_CANNOT_MAKE , 0 ), + X( "ENOENT", ERROR_FILE_NOT_FOUND , ERROR_PATH_NOT_FOUND ), + X( "EINTR", ERROR_INVALID_AT_INTERRUPT_TIME , 0 ), + X( "EIO", ERROR_IO_DEVICE , 0 ), + X( "ENXIO", ERROR_FILE_INVALID , 0 ), + X( "EBADF", ERROR_INVALID_HANDLE , 0 ), + X( "EAGAIN", ERROR_MORE_DATA , WSAEWOULDBLOCK ), + + X( "ENOMEM", ERROR_NOT_ENOUGH_MEMORY , 0 ), + X( "EACCES", ERROR_ACCESS_DENIED , 0 ), + X( "EFAULT", ERROR_PROCESS_ABORTED , 0 ), + X( "EBUSY", ERROR_BUSY , 0 ), + X( "EEXIST", ERROR_FILE_EXISTS , WSAEADDRINUSE ), + + X( "EXDEV", ERROR_NOT_SAME_DEVICE , 0 ), + X( "ENODEV", ERROR_BAD_DEVICE , ERROR_DEV_NOT_EXIST ), + + X( "ENOTDIR",ERROR_DIRECTORY , 0 ), + X( "EINVAL", ERROR_INVALID_PARAMETER , 0 ), + X( "ENFILE", ERROR_NO_MORE_FILES , 0 ), + X( "EMFILE", ERROR_TOO_MANY_OPEN_FILES , 0 ), + X( "ENOSPC", ERROR_DISK_FULL , 0 ), + X( "EROFS", ERROR_WRITE_PROTECT , 0 ), + X( "EPIPE", ERROR_BROKEN_PIPE , 0 ), + X( "ERANGE", ERROR_ARITHMETIC_OVERFLOW , 0 ), + X( "EDEADLOCK",ERROR_POSSIBLE_DEADLOCK , 0 ), + X( "ENAMETOOLONG", ERROR_FILENAME_EXCED_RANGE, 0 ), + X( "ENOLCK", ERROR_SHARING_BUFFER_EXCEEDED , 0 ), + X( "ENOSYS", ERROR_NOT_SUPPORTED , 0 ), + X( "ENOTEMPTY",ERROR_DIR_NOT_EMPTY , 0 ), + X( "ESPIPE", ERROR_SEEK_ON_DEVICE , 0 ), #if 0 /* FIXME: Find appropriate mappings. */ X( "EILSEQ", ), X( "EDOM", ), @@ -152,11 +150,29 @@ main (int argc, char **argv) for (idx=0; table[idx].name; idx++) ; qsort (table, idx, sizeof *table, compare_table); - - fputs (header_gpg_extra_errno_h, stdout); - for (idx=0; table[idx].name; idx++) - printf ("#define %-12s %5d\n", table[idx].name, table[idx].w32code); - fputs (footer_gpg_extra_errno_h, stdout); + + if (argc == 2 && !strcmp (argv[1], "--map")) + { + fputs ("static int\n" + "map_w32codes (int err)\n" + "{\n" + " switch (err)\n" + " {\n", stdout ); + for (idx=0; table[idx].name; idx++) + if (table[idx].w32code2) + printf (" case %d: return %d;\n", + table[idx].w32code2, table[idx].w32code); + fputs (" default: return err;\n" + " }\n" + "}\n", stdout); + } + else + { + fputs (header_gpg_extra_errno_h, stdout); + for (idx=0; table[idx].name; idx++) + printf ("#define %-12s %5d\n", table[idx].name, table[idx].w32code); + fputs (footer_gpg_extra_errno_h, stdout); + } return 0; } |