Ethereal-dev: Re: [Ethereal-dev] Ethereal addition for analysing RTP data

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Thu, 6 Mar 2003 14:24:46 -0800
On Thu, Mar 06, 2003 at 05:04:35PM +0100, Miha Jemec wrote:
> Ok, I made a few changes.

OK, we'll have to make some more.

As per Greg Morris's mail, you can't just include <unistd.h>, as it's
not present on all platforms on which Ethereal runs.

In particular, it's missing on these platforms:

	http://www.microsoft.com/windows95/

	http://www.microsoft.com/windows98/

	http://www.microsoft.com/windowsme/

	http://www.microsoft.com/ntworkstation/

	http://www.microsoft.com/ntserver/

	http://www.microsoft.com/windows2000/

	http://www.microsoft.com/windowsxp/default.asp

	http://www.microsoft.com/windowsserver2003/default.mspx

at least if you're compiling without some "pretend to be UNIX" wrapper.

You have to do

	#ifdef HAVE_UNISTD_H
	#include <unistd.h>
	#endif

It's included because "open()" is being used, which raises *another*
issue - by default, the "open()" wrapper on Windows opens in text mode,
not binary mode, so you need to use O_BINARY.

There are also "fopen()" calls that open with "w" - those files also
appear to be binary, so you need "wb".

(Note also that no check is done whether writes succeed - there is no
guarantee that they will; you could run out of space on the file
system.)

There is also a comment about "%lu" working with guint32 but getting a
warning from the compiler; that warning is there because that will *NOT*
work on platforms with 64-bit "long"s.  There is also a comment saying
that "%d" doesn't work with guint32 - that's because guint32 is
unsigned, not signed.  "%u", which is what is being used, is the right
answer.

(Also, all the CRs in the file cause at least some UNIX C compilers not
to like the code.)

I'll check in fixes for those.