home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************
- * COUNTF.C - Jim Kyle
- * Last change : 13 August 1990
- ***************************************************************/
- #include <stdio.h>
- #include <dos.h>
- #include <stdlib.h>
-
- #ifndef MK_FP
- #define MK_FP( s, o ) (void far *)(((long)(s) << 16) | \
- (unsigned)(o))
- #endif
-
- unsigned files(void)
- { union REGS regs;
- struct SREGS sregs;
- unsigned int far *ptr;
- int n = 0;
-
- if ( _osmajor < 2 )
- { puts( "FILES not supported in this DOS version.");
- exit(0);
- }
- regs.h.ah = 0x52;
- intdosx( ®s, ®s, &sregs );
- ptr = (unsigned int far *) MK_FP( sregs.es, regs.x.bx + 4 );
- ptr = (unsigned int far *) MK_FP( ptr[1], ptr[0] );
- while ( FP_OFF(ptr) != 0xFFFF )
- { n += ptr[2];
- ptr = (unsigned int far *) MK_FP( ptr[1], ptr[0] );
- }
- return n;
- }
-
- #ifdef TESTING
- void main( void )
- { printf("FILES=%d\n", files());
- }
- #endif
-