ReactOS  0.4.13-dev-259-g5ca9c9c
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 
49 done:
50 #if !defined(NO_SIGNALS) && defined(SIGPIPE)
51  (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
52 #endif
53 
54  return (nwrote);
55 } /* PWrite */
#define EPIPE
Definition: acclib.h:91
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define EINTR
Definition: acclib.h:80
int errno
#define write
Definition: acwin.h:73
GLsizeiptr size
Definition: glext.h:5919
#define SIGPIPE
Definition: signal.h:35
#define SSetjmp(a)
Definition: sio.h:39
#define forever
Definition: ncftp.h:73
#define kBrokenPipeErr
Definition: sio.h:59
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
void(* sio_sigproc_t)(int)
Definition: sio.h:123
void SIOHandler(int)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31