home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l440 / 2.ddi / CHAP4 / COUNTF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-25  |  964 b   |  40 lines

  1. /***************************************************************
  2.  *     COUNTF.C - Jim Kyle
  3.  *  Last change : 13 August 1990
  4.  ***************************************************************/
  5. #include <stdio.h>
  6. #include <dos.h>
  7. #include <stdlib.h>
  8.  
  9. #ifndef MK_FP
  10. #define MK_FP( s, o ) (void far *)(((long)(s) << 16) | \
  11.     (unsigned)(o))
  12. #endif
  13.  
  14. unsigned files(void)
  15. { union REGS regs;
  16.   struct SREGS sregs;
  17.   unsigned int far *ptr;
  18.   int n = 0;
  19.  
  20.   if ( _osmajor < 2 )
  21.     { puts( "FILES not supported in this DOS version.");
  22.       exit(0);
  23.     }
  24.   regs.h.ah = 0x52;
  25.   intdosx( ®s, ®s, &sregs );
  26.   ptr = (unsigned int far *) MK_FP( sregs.es, regs.x.bx + 4 );
  27.   ptr = (unsigned int far *) MK_FP( ptr[1], ptr[0] );
  28.   while ( FP_OFF(ptr) != 0xFFFF )
  29.     { n += ptr[2];
  30.       ptr = (unsigned int far *) MK_FP( ptr[1], ptr[0] );
  31.     }
  32.   return n;
  33. }
  34.  
  35. #ifdef TESTING
  36. void main( void )
  37. {   printf("FILES=%d\n", files());
  38. }
  39. #endif
  40.