home *** CD-ROM | disk | FTP | other *** search
- // TimeCopy V1.01 Copyright (c) 1991 IP Makers
-
- // This program writes four dumps in four files
- // every INTERVAL seconds after INITIAL DELAY time has passed
- // Compile this file in tiny model
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <dos.h>
- #include <io.h>
- #include <fcntl.h>
- #include <sys/stat.h>
- #define TRUE 1
- #define FALSE 0
-
- extern void interrupt Timer(...);
-
- long ini_time,
- interval;
- void interrupt ( *OldTimer )(...);
- char CommandLine[ 256 ];
-
- main( int nargs, char *args[] )
- {
- printf( "TimeCopy Version 1.01 Copyright (c) 1991 IP Makers\n" );
- if( nargs < 4 ||
- !( ini_time = 18 * atoi( args[1] )) ||
- !( interval = 18 * atoi( args[2] ))){
- printf( "Usage: TimeCopy <initial delay(sec)> <interval(sec)> Command line\n" );
- exit( 0 );
- }
- for( int i = 3; i < nargs; i++ ){
- strcat( CommandLine, args[i] );
- strcat( CommandLine, " " );
- }
- OldTimer = getvect( 8 ); // After parameters are successfully
- setvect( 8, Timer ); // transformed we hook timer
- system ( CommandLine ); // and make system call,
- setvect( 8, OldTimer ); // then restore timer
- }
-
- void _write_( unsigned handle, unsigned seg,
- unsigned off, unsigned l )
- {
- asm {
- mov bx, handle // this is replacement
- mov dx, off // for function _write;
- mov cx, l // Borland does not want
- mov ax, seg // to understand that in
- push ds // tiny model we need
- mov ds, ax // features of huge
- mov ah, 40h
- int 21h
- pop ds
- }
- }
-
- void interrupt Timer(...)
- {
- static ini_passed;
- static FileNumber = 0;
- static long ticks = interval;
- static char* FileName[] = { "000", "111", "222", "333" };
-
- OldTimer();
- if( !ini_passed ) // Wait until initial
- if( !ini_time-- ) // delay is passed
- ini_passed = TRUE;
- else
- return;
-
- if( !ticks-- && FileNumber < 4 ){ // Get dump every
- unsigned PSP = getpsp(); // interval ticks
- int handle = open( FileName[ FileNumber++ ],
- O_WRONLY | O_CREAT | O_BINARY, S_IWRITE );
-
- if( handle != -1 ){
- while( PSP < 0xA000 ){
- _write_( handle, PSP, 0, 0xffff );
- _write_( handle, PSP, 0xffff, 1 );
- PSP += 0x1000;
- }
- close( handle );
- ticks = interval;
- }
- }
- }