home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
592b.lha
/
XTime_v1.0
/
source
/
VMS-UNIX_XTime.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-19
|
2KB
|
67 lines
/* XTime v. 1.00
Copyright 1991 by Kurt R. Krueger and the Sirius Cybernetics Corp.
This program is freely distributable in an unmodified form. */
#define XFER_RATE 232
extern long atol();
extern int atoi();
char *param, k[] = "-k", r[] = "-r", r_string[4];
int n = 1, i = 0, r_len, mins, min_xfer = 5L;
int x_rate = 232;
long secs, byte;
main (argc, argv)
int argc;
char *argv[];
{
if (argc == 1)
{
help();
exit(0);
}
byte = atol(argv[argc-1]);
if (byte == 0)
{
help();
exit(0);
}
param = argv[n];
while (param[0] == '-')
{
if (strcmp(argv[n], k) == 0)
byte *= 1000;
/* Extract the number after -r if -r exists */
if (strncmp(argv[n], r, 2) == 0) /* if <0 then -r was found */
{
r_len = strlen(argv[n]) - 2; /* len of the value after -r */
for (i = 0; i < r_len; i++)
r_string[i] = argv[n][i+2]; /* concatenate a string */
x_rate = atoi(r_string);
if (x_rate == 0)
x_rate = XFER_RATE;
}
param = argv[n++];
}
secs = byte / x_rate;
mins = secs / 60;
secs = secs - (mins * 60);
if (secs <= min_xfer)
secs = min_xfer;
printf ("\nAt a rate of %d cps, the transfer will take:\n", x_rate);
printf ("%d m %ld s\n", mins, secs);
}
help()
{
printf("\nXTime v. 1.00\n");
printf("Copyright 1991 by Kurt R. Krueger\n\n");
printf("Syntax: XTime [-k] [-r<cps>] <file size in bytes>\n\n");
printf("-k: file size is in K\n");
printf("-r: Assumed transfer rate is r characters/sec\n\n");
}