home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / ddjcompr / hstest / lib / farread.c < prev    next >
C/C++ Source or Header  |  1989-08-14  |  626b  |  38 lines

  1. #include <dos.h>
  2. #include <tomlib.h>
  3.  
  4. int far_read (int handle,char far *buffer,int count)
  5. {
  6.     union REGS ir;
  7.     struct SREGS sr;
  8.  
  9.     ir.h.ah = 0x3f;
  10.     ir.x.bx = handle;
  11.     ir.x.cx = count;
  12.     ir.x.dx = FP_OFF(buffer);
  13.     sr.ds   = FP_SEG(buffer);
  14.  
  15.     intdosx (&ir, &ir, &sr);
  16.     if (ir.x.cflag)
  17.         return -1;
  18.     return ir.x.ax;
  19. }
  20.  
  21. int far_write (int handle,char far *buffer,int count)
  22. {
  23.     union REGS ir;
  24.     struct SREGS sr;
  25.  
  26.     ir.h.ah = 0x40;
  27.     ir.x.bx = handle;
  28.     ir.x.cx = count;
  29.     ir.x.dx = FP_OFF(buffer);
  30.     sr.ds   = FP_SEG(buffer);
  31.  
  32.     intdosx (&ir, &ir, &sr);
  33.     if (ir.x.cflag)
  34.         return -1;
  35.     return ir.x.ax;
  36. }
  37.  
  38.