KernRead
"KernOpen()", "KernClose()", "KernRead()" are functions from KEE32 intended to read text files with settings during a boot time, such as "Protocol.ini"
- AI Generated
KernRead is a function that is used to read data from a file or other input stream. It is part of the OS/2 kernel's input/output (I/O) system and is used by programs to read data from files, pipes, sockets, and other types of input streams. KernRead takes a handle to an input stream and a buffer, and it reads a specified number of bytes from the stream into the buffer. It returns the number of bytes that were actually read, or an error code if an error occurred. KernRead is often used in conjunction with other I/O functions, such as KernOpen and KernClose, to perform input and output operations on files and other types of streams.
Syntax
The syntax for the KernRead function in the OS/2 operating system is as follows:
unsigned long KernRead( HFILE hFile, void *pBuffer, unsigned long cbRead );
Parameters
The hFile parameter is a handle to an input stream, such as a file or pipe. The pBuffer parameter is a pointer to a buffer that will receive the data that is read from the stream. The cbRead parameter specifies the number of bytes to read from the stream.
The KernRead function returns the number of bytes that were actually read from the stream, or an error code if an error occurred. If the number of bytes returned is less than the number requested, it may indicate that the end of the input stream has been reached.
Sample
Here is an example of how KernRead might be used in a program:
#include <os2.h> int main() { HFILE hFile; ULONG ulAction; char buffer[1024]; ULONG cbRead; // Open a file for reading if (DosOpen("c:\\example.txt", &hFile, &ulAction, 0, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL)) { // An error occurred return -1; } // Read 1024 bytes from the file into the buffer cbRead = KernRead(hFile, buffer, 1024); if (cbRead == -1) { // An error occurred DosClose(hFile); return -1; } // Do something with the data that was read // Close the file DosClose(hFile); return 0; }