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
|
|
|
|
2019-03-22 18:19:02 +00:00
|
|
|
#include <unistd.h>
|
2006-07-18 17:10:29 +00:00
|
|
|
#include "system.h"
|
1987-01-06 11:41:50 +00:00
|
|
|
|
2022-07-16 23:58:16 +00:00
|
|
|
int sys_read(File* fp, char* bufptr, int bufsiz, int* pnbytes)
|
1987-01-06 11:41:50 +00:00
|
|
|
{
|
2022-07-16 23:58:16 +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
|
|
|
}
|