🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5403

Re: What's a good prototype for write(2)?

#5403
From: Rahul Dhesi
Date: Wed, 26 Oct 1988 21:50
23 lines
1328 bytes
In article <902@vsi.COM> friedl@vsi.COM (Stephen J. Friedl) wants
to choose between
>	extern int write(int, const void *, unsigned);
and
>	extern int write(int, const void *, int);

If you assume the ability to write more bytes than will fit in an int,
then neither is correct, since write() returns the number of bytes
actually written.  A correct form is, with the exception that
I'm not sure if "const" is needed, is:

     extern unsigned int write (int fd, void *, unsigned int count);

The return value from write is then the number of bytes actually
written, or defined to be ERR_UNSIGNED in case of an error.  Naturally,
you would have to make sure that write() does indeed return
ERR_UNSIGNED and change the manuals accordingly.

Also:

#define   ERR_UNSIGNED    ((unsigned int) -1)
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee}!bsu-cs!dhesi
Technical Details
Message-ID: <4507@bsu-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!yunexus!geac!syntron!jtsv16!uunet!tank!ncar!mailrus!iuvax!bsu-cs!dhesi
References: <902@vsi.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!yunexus!geac!syntron!jtsv16!uunet!tank!ncar!mailrus!iuvax!bsu-cs!dhesi
From: dhesi@bsu-cs.UUCP (Rahul Dhesi)
Newsgroups: comp.std.c
Subject: Re: What's a good prototype for write(2)?
Message-ID: <4507@bsu-cs.UUCP>
Date: 26 Oct 88 21:50:31 GMT
Article-I.D.: bsu-cs.4507
References: <902@vsi.COM>
Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi)
Distribution: comp
Organization: CS Dept, Ball St U, Muncie, Indiana
Lines: 23