now introducing the POSIX+ client DLL! (my first check-in, hope I don't f*** up somet...
[reactos.git] / posix / lib / psxdll / unistd / read.c
1 /* $Id:
2 */
3 /*
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/unistd/read.c
7 * PURPOSE: Read from a file
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
9 * UPDATE HISTORY:
10 * 15/02/2002: Created
11 */
12
13 #include <ddk/ntddk.h>
14 #include <unistd.h>
15 #include <sys/types.h>
16
17 ssize_t read(int fildes, void *buf, size_t nbyte)
18 {
19 }
20
21 ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset)
22 {
23 HANDLE hFile;
24 NTSTATUS nErrCode;
25 IO_STATUS_BLOCK isbStatus;
26
27 /* get the file handle for the specified file descriptor */
28 if(fcntl(fildes, F_GETFH, &hFile) == -1)
29 return (-1);
30
31 /* read data from file */
32 nErrCode = NtReadFile
33 (
34 hFile,
35 NULL,
36 NULL,
37 NULL,
38 &isbStatus,
39 buf,
40 nbyte,
41 (PLARGE_INTEGER)&off_t,
42 NULL
43 );
44
45 return ((ssize_t)isbStatus.Information);
46 }
47
48 /* EOF */
49