[gnutls-dev] Gnutls4win: Problem with custom push/pull functions, errno and Visual Studio (Workaround included)
tim.kosse at filezilla-project.org
Sat Nov 4 16:30:44 CET 2006
-----BEGIN PGP SIGNED MESSAGE-----
I encountered some problems while trying to use custom push/pull
functions in a program compiled with Visual Studio.
Just setting errno to EAGAIN and returning -1 caused gnutls to fail with
I found out that libgnutls-13.dll is linked against msvcrt.dll, whereas
visual studio programs use a different runtime library (msvcr71.dll for
example). These libraries bring along their own version of errno.
So the errno inside the program is different from the one used in GnuTLS.
A workaround is to load the correct errno from msvcrt.dll:
HMODULE crtdll = LoadLibrary(_T("msvcrt.dll"));
typedef int* (*t_errno)(void);
t_errno pErrno = (t_errno)GetProcAddress(crtdll, "_errno");
*pErrno() = EAGAIN;
Would it be possible to add a function like for example void
gnutls_transport_set_errno(int), which does nothing else than setting
errno to the provided value?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Gnutls-devel