home *** CD-ROM | disk | FTP | other *** search
- #include <mintbind.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- #ifdef __GNUC__
- /* minimal stuff */
-
- #include <minimal.h>
- #include <stdarg.h>
-
- int printf(const char *fmt,...)
- {
- va_list args;
- char buf[128];
- va_start(args,fmt);
- vsprintf(buf,fmt,args);
- Cconws(buf);
- return 0;
- }
-
- #undef putchar
- #define putchar(c) Cconout(c)
- #endif
-
- char * HardDrives( void );
- void df( register char *p );
-
- int main( int argc, char **argv, char **envp )
- {
- printf( "Device Total Used Free\r\n" );
- if ( argc == 1 )
- df( HardDrives() );
- else
- while( --argc )
- df( *++argv );
- return 0;
- }
-
- void df( register char *p )
- {
- register int c;
- long nb, total, used;
- struct {
- unsigned long free;
- unsigned long cpd;
- unsigned long bps;
- unsigned long spc;
- } v;
-
- while ( c = *p++ )
- {
- if ( ( 'A' <= c ) && ( c <= 'P' ) )
- c -= 'A' - 1;
- else if ( ( 'a' <= c ) && ( c <= 'p' ) )
- c -= 'a' - 1;
- else
- break;
-
- if ( Dfree( &v, c ) >= 0L )
- {
- nb = v.bps * v.spc;
- total = v.cpd * nb;
- nb *= v.free;
- used = total - nb;
- printf( " %c: % 10ld% 10ld% 10ld %ldK\r\n",
- c + 'a' - 1, total, used, nb, nb/1024 );
- }
- }
- }
-
- /*
- * Build a list of the mounted drives, skipping the floppy drives, and
- * MiNT's pseudo drives
- */
-
- char * HardDrives( void )
- { register long n;
- register char *p, c;
- static char dmap[27];
-
- n = Drvmap();
- p = dmap;
- for ( c = 'a'; c < 'z'; c++ )
- {
- if ( n & 1L )
- if ( c > 'b' && c < 'p' )
- *p++ = c;
- n >>= 1;
- }
- *p = '\0';
- return dmap;
- }
-
-