mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:23:07 +00:00
- Start rosapps rearrange and cleanup process.
svn path=/trunk/; revision=34303
This commit is contained in:
parent
0a0a13a41c
commit
2012315e5a
1206 changed files with 81 additions and 81 deletions
55
rosapps/applications/net/ncftp/sio/PWrite.c
Normal file
55
rosapps/applications/net/ncftp/sio/PWrite.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "syshdrs.h"
|
||||
|
||||
#if !defined(NO_SIGNALS) && defined(SIGPIPE)
|
||||
extern volatile Sjmp_buf gPipeJmp;
|
||||
#endif
|
||||
int
|
||||
PWrite(int sfd, const char *const buf0, size_t size)
|
||||
{
|
||||
volatile int nleft;
|
||||
const char *volatile buf = buf0;
|
||||
int nwrote;
|
||||
#if !defined(NO_SIGNALS) && defined(SIGPIPE)
|
||||
vsio_sigproc_t sigpipe;
|
||||
|
||||
if (SSetjmp(gPipeJmp) != 0) {
|
||||
(void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
|
||||
nwrote = size - nleft;
|
||||
if (nwrote > 0)
|
||||
return (nwrote);
|
||||
errno = EPIPE;
|
||||
return (kBrokenPipeErr);
|
||||
}
|
||||
|
||||
sigpipe = (vsio_sigproc_t) SSignal(SIGPIPE, SIOHandler);
|
||||
#endif
|
||||
|
||||
nleft = (int) size;
|
||||
forever {
|
||||
nwrote = write(sfd, buf, nleft);
|
||||
if (nwrote < 0) {
|
||||
if (errno != EINTR) {
|
||||
nwrote = size - nleft;
|
||||
if (nwrote == 0)
|
||||
nwrote = -1;
|
||||
goto done;
|
||||
} else {
|
||||
errno = 0;
|
||||
nwrote = 0;
|
||||
/* Try again. */
|
||||
}
|
||||
}
|
||||
nleft -= nwrote;
|
||||
if (nleft <= 0)
|
||||
break;
|
||||
buf += nwrote;
|
||||
}
|
||||
nwrote = size - nleft;
|
||||
|
||||
done:
|
||||
#if !defined(NO_SIGNALS) && defined(SIGPIPE)
|
||||
(void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
|
||||
#endif
|
||||
|
||||
return (nwrote);
|
||||
} /* PWrite */
|
Loading…
Add table
Add a link
Reference in a new issue