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
-
- struct states {
- int attribute;
- char *desc;
- } proc_state[] = {
- 0x00, "Currently Running",
- 0x01, "Ready to Run",
- 0x20, "Waiting for an event",
- 0x21, "Waiting for I/O",
- 0x22, "Zombie",
- 0x02, "TSR",
- 0x24, "Stopped",
- 0, ""
- };
-
- char *stateOf( int attr )
- {
- struct states *st = proc_state;
-
- do
- {
- if ( st->attribute == attr )
- return st->desc;
- } while( (++st)->desc );
- return "Invalid attributes";
- }
-
- int main( int argc, char **argv, char **envp )
- {
- struct _dta dta, *olddta;
-
- olddta = (struct _dta *)Fgetdta();
-
- (void)Pdomain(1);
- Fsetdta( &dta );
-
- printf(" %3s %8s %7s %-20.20s %-13.13s\n\r\n\r",
- "PID", "Time", "Size", "State", "Process Name" );
-
- if ( ! Fsfirst( "x:/*.*", 0 ) )
- do
- {
- int i;
- char tmp[9];
- unsigned t;
-
- t = dta.dta_time;
-
- i = strcspn( dta.dta_name, "." );
- memcpy( tmp, dta.dta_name, i );
- tmp[i] = '\0';
-
- printf( " %3d %02d:%02d:%02d %7ld %-20.20s %-13.13s\n\r",
- atoi( &dta.dta_name[i+1] ),
- (t >> 11) & 31, (t >> 5) & 63, (t & 31) << 1,
- dta.dta_size, stateOf(dta.dta_attribute), tmp );
- } while ( ! Fsnext() );
-
- Fsetdta( &olddta );
- return 0; /* keep the compiler happy */
- }
-