ReactOS 0.4.15-dev-7093-g01a8288
PWrite.c File Reference
#include "syshdrs.h"
Include dependency graph for PWrite.c:

Go to the source code of this file.

Functions

int PWrite (int sfd, const char *const buf0, size_t size)
 

Function Documentation

◆ PWrite()

int PWrite ( int  sfd,
const char *const  buf0,
size_t  size 
)

Definition at line 7 of file PWrite.c.

8{
9 volatile int nleft;
10 const char *volatile buf = buf0;
11 int nwrote;
12#if !defined(NO_SIGNALS) && defined(SIGPIPE)
13 vsio_sigproc_t sigpipe;
14
15 if (SSetjmp(gPipeJmp) != 0) {
16 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
17 nwrote = size - nleft;
18 if (nwrote > 0)
19 return (nwrote);
20 errno = EPIPE;
21 return (kBrokenPipeErr);
22 }
23
25#endif
26
27 nleft = (int) size;
28 forever {
29 nwrote = write(sfd, buf, nleft);
30 if (nwrote < 0) {
31 if (errno != EINTR) {
32 nwrote = size - nleft;
33 if (nwrote == 0)
34 nwrote = -1;
35 goto done;
36 } else {
37 errno = 0;
38 nwrote = 0;
39 /* Try again. */
40 }
41 }
42 nleft -= nwrote;
43 if (nleft <= 0)
44 break;
45 buf += nwrote;
46 }
47 nwrote = size - nleft;
48
49done:
50#if !defined(NO_SIGNALS) && defined(SIGPIPE)
51 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
52#endif
53
54 return (nwrote);
55} /* PWrite */
#define EINTR
Definition: acclib.h:80
#define EPIPE
Definition: acclib.h:91
#define write
Definition: acwin.h:97
#define SIGPIPE
Definition: signal.h:35
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define kBrokenPipeErr
Definition: sio.h:59
void SIOHandler(int)
#define SSetjmp(a)
Definition: sio.h:39
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
void(* sio_sigproc_t)(int)
Definition: sio.h:123
#define forever
Definition: ncftp.h:73
#define errno
Definition: errno.h:18