ReactOS 0.4.15-dev-7887-g64a59a1
PRead.c File Reference
#include "syshdrs.h"
Include dependency graph for PRead.c:

Go to the source code of this file.

Functions

int PRead (int sfd, char *const buf0, size_t size, int retry)
 

Function Documentation

◆ PRead()

int PRead ( int  sfd,
char *const  buf0,
size_t  size,
int  retry 
)

Definition at line 19 of file PRead.c.

20{
21 int nread;
22 volatile int nleft;
23 char *volatile buf = buf0;
24#if !defined(NO_SIGNALS) && defined(SIGPIPE)
25 vsio_sigproc_t sigpipe;
26
27 if (SSetjmp(gPipeJmp) != 0) {
28 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
29 nread = size - nleft;
30 if (nread > 0)
31 return (nread);
32 errno = EPIPE;
33 return (kBrokenPipeErr);
34 }
35
37#endif
38 errno = 0;
39
40 nleft = (int) size;
41 forever {
42 nread = read(sfd, buf, nleft);
43 if (nread <= 0) {
44 if (nread == 0) {
45 /* EOF */
46 nread = size - nleft;
47 goto done;
48 } else if (errno != EINTR) {
49 nread = size - nleft;
50 if (nread == 0)
51 nread = -1;
52 goto done;
53 } else {
54 errno = 0;
55 nread = 0;
56 /* Try again. */
57 }
58 }
59 nleft -= nread;
60 if ((nleft <= 0) || (retry == 0))
61 break;
62 buf += nread;
63 }
64 nread = size - nleft;
65
66done:
67#if !defined(NO_SIGNALS) && defined(SIGPIPE)
68 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
69#endif
70 return (nread);
71} /* PRead */
#define EINTR
Definition: acclib.h:80
#define EPIPE
Definition: acclib.h:91
#define read
Definition: acwin.h:96
#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