home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ncftp.com
/
ftp.ncftp.com.zip
/
ftp.ncftp.com
/
libncftp
/
older_versions
/
libncftp-3.2.2-src.tar.bz2
/
libncftp-3.2.2-src.tar
/
libncftp-3.2.2
/
sio
/
PWrite.c
< prev
next >
Wrap
C/C++ Source or Header
|
2003-08-31
|
838b
|
46 lines
#include "syshdrs.h"
#ifdef PRAGMA_HDRSTOP
# pragma hdrstop
#endif
int
PWrite(int sfd, const char *const buf0, size_t size)
{
write_return_t nwrote;
write_size_t nleft;
const char *buf = buf0;
DECL_SIGPIPE_VARS
if ((buf == NULL) || (size == 0)) {
errno = EINVAL;
return (-1);
}
IGNORE_SIGPIPE
nleft = (write_size_t) size;
forever {
nwrote = write(sfd, buf, nleft);
if (nwrote < 0) {
if (errno != EINTR) {
nwrote = (write_return_t) size - (write_return_t) nleft;
if (nwrote == 0)
nwrote = (write_return_t) -1;
goto done;
} else {
errno = 0;
nwrote = 0;
/* Try again. */
}
}
nleft -= (write_size_t) nwrote;
if (nleft == 0)
break;
buf += nwrote;
}
nwrote = (write_return_t) size - (write_return_t) nleft;
done:
RESTORE_SIGPIPE
return ((int) nwrote);
} /* PWrite */