Gordian Klein wrote:
> Hello,
> 
> i want to use gpgme with Visual Studio on Windows.
> Therefore i downloaded gpg4win and now succesfully use the
> libgpgme-11.dll from it with VS.
> But i have some trouble with the password callback function.
> It looks like this:
> 
> static gpgme_error_t passphrase_cb (void *hook,
>               const char *uid_hint,
>               const char *passphrase_info,
>               int prev_was_bad,
>               int fd)
> 
> It gets called successfully but i dont know how to write to fd.
> Because unistd.h does not exist on Windows and so write() is not
> avilable i used write from Windows <io.h>. But that did crash the
> programm with this line of code from write.c:
> 
> _VALIDATE_CLEAR_OSSERR_RETURN((fh >= 0 && (unsigned)fh <
> (unsigned)_nhandle), EBADF, -1);
> In this case fd was 148 and _nhandle 32.
> 
> I also tried converting fd somehow to a FILE but it didnt work neither.
> 
> Whats my Problem here? Im stuck..

Try something like this:

int translate_fd(int fd, int for_write) {
#ifdef WIN32
    int x;

    if (fd == -1) {
        return -1;
    }

    x = _open_osfhandle ((long)fd, for_write ? 1 : 0);
    if (x == -1) {
        printf("Failed to translate osfhandle %p\n", (void *) fd);
    }
    return x;
#else /*!WIN32 */
    return fd;
#endif
}

http://msdn.microsoft.com/en-us/library/bdts1c9x(VS.71).aspx

> Thank you for any suggestions.
> 
> Regards,
> Gordian

Best Regards
Florian



_______________________________________________
Gnupg-users mailing list
[email protected]
http://lists.gnupg.org/mailman/listinfo/gnupg-users

Reply via email to