× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 05/02/2009, at 7:44 AM, Adam Glauser wrote:

I have a routine which reads a stream file byte by byte looking for
record start and end delimiters. I have implemented my own buffering.
Now I'm looking at trying to separate the buffered reading from the
actual parsing so that I can handle records without start delimiters, as
well as delimiters of arbitrary length.

I presume this is using the Unix APIs open, read, close?

It should be relatively easy to modify my current buffering code to work
with different delimiters, but I wonder if I'd be better off just using
the _C_IFS_(fopen,fclose,fread) functions.

These functions automatically perform buffering for you (which is probably why you're asking about them). You can set the buffering to fully-buffered, line-buffered, or no buffering.

Note that line-buffering only works on new-line and not an arbitrary end-of-line delimiter.

One can presume these APIs will perform faster than the Unix APIs due to the buffering but whether they're faster than your own buffering routines can only be answered by empirical testing.

What would you choose and why?


Depends entirely on my needs, I've used open to get more control than fopen provides, then used fdopen to associate a stream with the file descriptor, then used the fxxxx functions to get the OS to buffer for me.

Other times I do my own buffering--especially with socket data.

Whether you do your own buffering or use the OS buffering you'll still have to deal with incomplete data where you have part of the desired data in the buffer but the buffer is full. Dealing with this situation may be easier when you control the buffering.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.