home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 5.ddi / CLIBSRC2.ZIP / RANDBLK.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  3.4 KB  |  108 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - randblk.cas
  3.  *
  4.  * function(s)
  5.  *        randbrd - random block read
  6.  *        randbwr - random block write
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <dos.h>
  21.  
  22. /*-----------------------------------------------------------------------*
  23.  
  24. Name            randbrd - random block read
  25.  
  26. Usage           #include <dos.h>
  27.                 int randbrd(struct fcb *fcbptr, int reccnt);
  28.  
  29. Related
  30. functions usage int randbwr(struct fcb *fcbptr, int reccnt);
  31.  
  32. Prototype in    dos.h
  33.  
  34. Description     randbrd reads reccnt number of records using the
  35.                 open FCB pointed to by fcbptr. The records are read into memory
  36.                 at the current disk transfer address. They are read from the
  37.                 disk record indicated in the random record field of the FCB.
  38.                 This is accomplished by calling DOS system call 0x27.
  39.  
  40.                 randbwr performs essentially the same function as randbrd,
  41.                 except that data is written to disk instead of read from disk.
  42.                 This is accomplished using DOS system call DOS 0x28. If reccnt
  43.                 is 0, the file is truncated to the length indicated by the
  44.                 random record field.
  45.  
  46.                 The actual number of records read or written can be determined
  47.                 by examining the random record field of the FCB. The random
  48.                 record field will be advanced by the number of records actually
  49.                 read or written.
  50.  
  51. Return value    The following values are returned, depending upon
  52.                 the result of the randbrd or randbwr operation:
  53.  
  54.                         0       All records are read or written.
  55.  
  56.                         1       End-of-file is reached and the last record
  57.                                 read is complete.
  58.  
  59.                         2       Reading records would have wrapped around
  60.                                 address 0xFFFF (as many records as possible
  61.                                 are read).
  62.  
  63.                         3       End-of-file is reached with the last record
  64.                                 incomplete.
  65.  
  66.                 randbwr returns 1 if there is not enough disk space to write
  67.                 the records (no records are written).
  68.  
  69. *------------------------------------------------------------------------*/
  70. int randbrd(struct fcb *fcb, int rcnt)
  71. {
  72.         pushDS_
  73. asm     mov     ah, 027h
  74. asm     mov     cx, rcnt
  75. asm     LDS_    dx, fcb
  76. asm     int     021h
  77. asm     cbw
  78.         popDS_
  79.  
  80.         return( _AX );
  81. }
  82.  
  83.  
  84. /*-----------------------------------------------------------------------*
  85.  
  86. Name            randbwr - random block write
  87.  
  88. Usage           #include <dos.h>
  89.                 int randbwr(struct fcb *fcbptr, int reccnt);
  90.  
  91. Prototype in    dos.h
  92.  
  93. Description     see randbrd above
  94.  
  95. *------------------------------------------------------------------------*/
  96. int randbwr(struct fcb *fcb, int rcnt)
  97. {
  98.         pushDS_
  99. asm     mov     ah, 028h
  100. asm     mov     cx, rcnt
  101. asm     LDS_    dx, fcb
  102. asm     int     021h
  103. asm     cbw
  104.         popDS_
  105.  
  106.         return( _AX );
  107. }
  108.