/******************************************************************************
*  This program will tell you how long it will take to send a file to a remote*
*     computer.  All you do is give it the name of the file and the baud rate *
*     that you will be sending the file at.                                   *
******************************************************************************/
/******************************************************************************
*         ____                                                                *
*        / / /  Amiga 1000  | Thomas "Maverick" Schwarz  -  Sirius Software   *
*       / / /  The  Machine |     Box 349 Caromar Dr.  Mars, PA  16046        *
*____  / / /   That Made It |                (412) 443-8916                   *
*\ \ \/ / /      Possible!  |                                                 *
* \ \/ / /          --      |UUCP: {allegra,cadre}!pitt!darth!floopy!maverick *
*  \/_/_/         First!    |  or: ...uunet!nfsun!eklektik!thomas             *
******************************************************************************/

/**** COPYRIGHT 1990 Thomas "Maverick" Schwarz - Sirius Software ****/

#include <libraries/dos.h>
#include <intuition/intuition.h>
#include <exec/memory.h>
#include <stdio.h>

struct FileLock *mylock  = NULL;
struct FileInfoBlock *fib = NULL;

main(argc,argv)
int argc;
char *argv[];
{
int success, baud;
long tsecs, hours, mins, secs;

    if (argv[1] == "?")
	    {
        printf("\nUsage: TTime <filename> <baud rate>\n\n");
		exit(0);
	    }
    if (argc < 2)
	    {
        printf("\nUsage: TTime <filename> <baud rate>\n\n");
		exit(0);
	    }
    baud = atoi(argv[2]);
    if (baud == 0)
        {
        printf("\nUseage: TTime <filename> <baud rate>\n\n");
        exit(0);
        }
    if((fib = (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC|MEMF_CLEAR))==NULL)
        exit(0);
    mylock = (struct FileLock *)Lock(argv[1],ACCESS_READ);
    if(!(success = Examine(mylock,fib)))
        {
            printf("\n\n\nFile Not Locked!\n\n");
            FreeMem(fib,sizeof(struct FileInfoBlock));
            exit(0);
        }
    tsecs = ((((fib->fib_Size) *10) / baud) + (fib->fib_Size / 1920)); 
	hours = (tsecs / 3600);
    mins = ((tsecs - 60 * hours) / 60);
    secs = (tsecs - (mins * 60) - (hours * 3600));
    printf("\nTransfer time will be: %02d:%02d:%02d\n\n",hours,mins,secs);
    FreeMem(fib,sizeof(struct FileInfoBlock));
    UnLock(mylock);
}
