Ethereal-dev: Re: [Ethereal-dev] Wiretap as DLL, again

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxx>
Date: Fri, 27 Oct 2000 17:25:43 -0400
On Thu, Oct 26, 2000 at 12:44:15AM -0400, Gilbert Ramirez wrote:
> Tonight I once again tried to get Wiretap on Win32 to work as a DLL,
> and found the point at which it fails. It was unexpected.
> Tethereal (and ethereal, but I'm testing Tethereal) cannot fstat()
> the file descriptor passed back from wiretap, even though the
> open (wtap_open_offline()) succeeds. But when wiretap
> is compiled as an archive library, the fstat() succeeds.

Thanks to some help from Steve Nicolai, I've made progress on Wiretap
as a DLL. He pointed me to:

http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_CRT_C_Run.2d.Time_Libraries.htm

it turns out that I was statically linking the C libraries into
both wiretap.dll and tethereal.exe, and each copy of the library had its
own table of file descriptors, causing the discrepancy.

I've modified the build to link against the DLL version of the C library.
But when doing so, <errno.h> on Win32 defines errno as a dereference
of an integer pointer returned from a function _errno():

/* declare reference to errno */

#if     (defined(_MT) || defined(_DLL)) && !defined(_MAC)
_CRTIMP extern int * __cdecl _errno(void);
#define errno   (*_errno())
#else   /* ndef _MT && ndef _DLL */
_CRTIMP extern int errno;
#endif  /* _MT || _DLL */

This prevents wiretap.dll from linking because in various places
we try to set errno. So I'll work on a change to wiretap where the
C library's errno is *not* set by wiretap.

--gilbert