GPGME callback function problem
wk at gnupg.org
Tue Sep 11 09:27:02 CEST 2007
On Tue, 11 Sep 2007 02:24, hira at atlas-is.co.jp said:
> I failed using _write(),(infinit loop?) so I replace it to _gpgme_io_write().
> I think the reason is _gpgme_io_write() can handle CriticalSection in sema.h.
You may not use any function prefixed with "_gpgme"! These are internal
functions and may change without notice.
Under Windows you need to use WriteFile and ReadFile and not write (or
_write which is identical to write). Marcus already mentioned this.
Translation between the libc and system handles can be done with code
/* This function is a NOP for POSIX systems but required under Windows
as the file handles as returned by OS calls (like CreateFile) are
different from the libc file descriptors (like open). This function
translates system file handles to libc file handles. FOR_WRITE
gives the direction of the handle. */
translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
if (fd == GNUPG_INVALID_FD)
/* Note that _open_osfhandle is currently defined to take and return
a long. */
x = _open_osfhandle ((long)fd, for_write ? 1 : 0);
if (x == -1)
log_error ("failed to translate osfhandle %p\n", (void *) fd);
#else /*!HAVE_W32_SYSTEM */
If you are interested in the Windows API design, you should get Johnson
M. Hart's "Windows System Programming". Actually this book a must have
for all Unix hackers who need to work for Windows.
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.
More information about the Gnupg-devel