Ethereal-dev: Re: [ethereal-dev] suggestion for useful macros/subroutines

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: Mon, 6 Dec 1999 16:08:48 -0800 (PST)
> 	pull a CR/NL terminated line from a packet, starting at an offset,
> 		return the offsets of the string end, cr, nl, and the string (null
> terminated)

"find_line_end()" takes, as arguments:

	a data pointer;

	a pointer to the end of the buffer into which said data pointer
	points;

	a pointer to a "u_char *";

and treats the data pointer as pointing to the beginning of a string
with either LF, CR/LF, or LF/CR at the end.  It scans for an LF (but
doesn't go past the "end of buffer" pointer), and:

	returns a pointer to the character past the end-of-line
	indicator;

	sets the pointer pointed to by the third argument to point to
	the end-of-line indicator (if LF, the LF; if CR/LF, the CR; if
	LF/CR, the LF).