ReactOS  0.4.13-dev-242-g611e6d7
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 
66 done:
67 #if !defined(NO_SIGNALS) && defined(SIGPIPE)
68  (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
69 #endif
70  return (nread);
71 } /* PRead */
#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
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
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
void SIOHandler(int)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31