Unix Programming - setlinebuf(): void or int?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2004 > setlinebuf(): void or int?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author setlinebuf(): void or int?
William Ahern

2004-03-25, 12:43 pm

Does anybody know what the story is behind setlinebuf()? On *BSD it seems
to return an int, but on Linux void. And yet, the Linux man page seems to be
lifted straight from *BSD.

setbuf() and setbuffer() return void, so why would *BSD have setlinebuf()
return int?

Curious,

Bill
Rich Teer

2004-03-25, 2:35 pm

On Thu, 25 Mar 2004, William Ahern wrote:

> Does anybody know what the story is behind setlinebuf()? On *BSD it seems
> to return an int, but on Linux void. And yet, the Linux man page seems to be
> lifted straight from *BSD.
>
> setbuf() and setbuffer() return void, so why would *BSD have setlinebuf()
> return int?


Good question. setlinebuf() isn't specified by the Single UNIX Spec,
so I would be more inclined to use a standard function (like setvbuf)
than worry about these inconsistancies. :-)

--
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net
Nick Landsberg

2004-03-25, 2:35 pm

Rich Teer wrote:
> On Thu, 25 Mar 2004, William Ahern wrote:
>
>
>
>
> Good question. setlinebuf() isn't specified by the Single UNIX Spec,
> so I would be more inclined to use a standard function (like setvbuf)
> than worry about these inconsistancies. :-)
>


From the man page:

The setlinebuf() function is exactly equivalent to the call:

setvbuf(stream, (char *)NULL, _IOLBF, 0);


--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
Marc Rochkind

2004-03-25, 3:35 pm


"Nick Landsberg" <hukolau@NOSPAM.att.net> wrote in message
news:cAG8c.38561$PY1.724855@bgtnsc05-news.ops.worldnet.att.net...
> Rich Teer wrote:
seems[color=darkred]
to be[color=darkred]
setlinebuf()[color=darkred]
>
> From the man page:
>
> The setlinebuf() function is exactly equivalent to the call:
>
> setvbuf(stream, (char *)NULL, _IOLBF, 0);
>
>
> --
> "It is impossible to make anything foolproof
> because fools are so ingenious"
> - A. Bloch


Yes, but on my RedHat system the same man page shows the function as void,
so the original question, while probably not of earthshaking importance,
still makes sense. Looking in the headers, I find both a macro and a genuine
function declaration, but I didn't wind my way through the #ifdefs to
discover when each is used.

--
Marc Rochkind
"Advanced UNIX Programming" (publishing April 2004)
www.basepath.com/aup


Nick Landsberg

2004-03-25, 3:35 pm

Marc Rochkind wrote:

> "Nick Landsberg" <hukolau@NOSPAM.att.net> wrote in message
> news:cAG8c.38561$PY1.724855@bgtnsc05-news.ops.worldnet.att.net...
>
>
> seems
>
>
> to be
>
>
> setlinebuf()
>
>
>
> Yes, but on my RedHat system the same man page shows the function as void,
> so the original question, while probably not of earthshaking importance,
> still makes sense. Looking in the headers, I find both a macro and a genuine
> function declaration, but I didn't wind my way through the #ifdefs to
> discover when each is used.
>


Thank you for the correction Marc.

I should have noted that my system is a BSD derivative.

From my <stdio.h>:
....
int setlinebuf(FILE *);
....
int setvbuf(FILE *, char *, int, size_t);

And no macros present.



--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com