comparison lib/safe-read.c @ 1320:abeaa95922bd

(noinst_HEADERS): Add safe-read.h.
author Jim Meyering <jim@meyering.net>
date Sat, 11 Apr 1998 17:53:09 +0000
parents 2f2ee0189bb5
children 5cd2eca6193e
comparison
equal deleted inserted replaced
1319:f03cfd0c1aa4 1320:abeaa95922bd
1 /* safe-read.c -- an interface to read that retries after interrupts 1 /* safe-read.c -- an interface to read that retries after interrupts
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. 2 Copyright (C) 1993, 1994, 1998 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option) 6 the Free Software Foundation; either version 2, or (at your option)
7 any later version. 7 any later version.
29 #include <errno.h> 29 #include <errno.h>
30 #ifndef errno 30 #ifndef errno
31 extern int errno; 31 extern int errno;
32 #endif 32 #endif
33 33
34 #include "safe-read.h"
35
34 /* Read LEN bytes at PTR from descriptor DESC, retrying if interrupted. 36 /* Read LEN bytes at PTR from descriptor DESC, retrying if interrupted.
35 Return the actual number of bytes read, zero for EOF, or negative 37 Return the actual number of bytes read, zero for EOF, or negative
36 for an error. */ 38 for an error. */
37 39
38 int 40 ssize_t
39 safe_read (desc, ptr, len) 41 safe_read (int desc, char *ptr, size_t len)
40 int desc;
41 char *ptr;
42 int len;
43 { 42 {
44 int n_chars; 43 ssize_t n_chars;
45 44
46 if (len <= 0) 45 if (len <= 0)
47 return len; 46 return len;
48 47
49 #ifdef EINTR 48 #ifdef EINTR