d_read.gml

来自「开放源码的编译器open watcom 1.6.0版的源代码」· GML 代码 · 共 50 行

GML
50
字号
.func _dos_read
#include <&doshdr>
unsigned _dos_read( int &fd, void __far *buffer,
                    unsigned count, unsigned *bytes );
.ixfunc2 '&DosFunc' &func
.ixfunc2 '&OsIo' &func
.funcend
.desc begin
The &func function uses system call 0x3F to read
.arg count
bytes of data from the file specified by
.arg &fd
into the buffer pointed to by
.arg buffer.
The number of bytes successfully read will be stored in the
unsigned integer pointed to by
.arg bytes.
.desc end
.return begin
The &func function returns zero if successful.
Otherwise, it returns an OS error code and sets
.kw errno
accordingly.
.return end
.see begin
.seelist _dos_read _dos_close _dos_open _dos_write
.see end
.exmp begin
#include <stdio.h>
#include <&doshdr>
#include <fcntl.h>
.exmp break
void main()
  {
    unsigned len_read;
    int      &fd;
    auto char buffer[80];
.exmp break
    if( _dos_open( "file", O_RDONLY, &amp.&fd ) != 0 ) {
      printf( "Unable to open file\n" );
    } else {
      printf( "Open succeeded\n" );
      _dos_read( &fd, buffer, 80, &len_read );
      _dos_close( &fd );
    }
  }
.exmp end
.class DOS
.system

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?