ack/modules/src/system/read.c

31 lines
529 B
C
Raw Normal View History

1987-03-09 15:15:03 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1994-06-24 11:31:16 +00:00
/* $Id$ */
1987-01-06 11:41:50 +00:00
#include <unistd.h>
#include "system.h"
1987-01-06 11:41:50 +00:00
int sys_read(File* fp, char* bufptr, int bufsiz, int* pnbytes)
1987-01-06 11:41:50 +00:00
{
if (!fp)
return 0;
*pnbytes = 0;
while (bufsiz != 0)
{
int len = read(fp->o_fd, bufptr, bufsiz);
if (len < 0)
return 0;
if (len == 0)
return *pnbytes != 0;
*pnbytes += len;
bufptr += len;
bufsiz -= len;
}
return 1;
1987-01-06 11:41:50 +00:00
}