home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1996 September
/
Simtel-MSDOS-Sep1996-CD2.iso
/
disc2
/
c
/
backlog.c
< prev
next >
Wrap
Internet Message Format
|
1988-08-14
|
4KB
Date: Tue, 12 Jul 88 17:16:17 cdt
From: wucs1!wubios!david@uunet.UU.NET (David Camp)
Subject: BACKLOG.C
Greg,
Here is a little something I cooked up.
-David-
*-------------------------------------------------------------------------*
| (314) 362-3635 Mr. David J. Camp |
| Room 1108D ^ Box 8067, Biostatistics |
| 706 South Euclid < * > Washington University Medical School |
| v 660 South Euclid |
| Bitnet: david%wubios@wucfua.wustl Saint Louis, MO 63110 |
| Internet: david%wubios@wucfua.wustl.edu |
*-------------------------------------------------------------------------*
/* BACKLOG.C -- program to copy latest portion of BACKUP.LOG */
/* Written by David J. Camp of the Washington University
Division of Biostatistics */
/*
I have sent you BACKLOG.C and BACKLOG.EXE, which does something
useful. Whenever I use the MS-Dos 3.3 BACKUP command, I like to specify
/L to get information appended to C:\BACKUP.LOG indicating each file
backed up. I have routinely edited this file, placing the latest portion
on the last disk of my backup. Now there is BACKLOG, which takes two
arguments, the source drive and the target drive, e.g.:
BACKLOG c: a:
It will copy just the part pertaining to your latest backup into a file
named \BACKUP.LOG on the target drive.
*-------------------------------------------------------------------------*
| (314) 362-3635 Mr. David J. Camp |
| Room 1108D ^ Box 8067, Biostatistics |
| 706 South Euclid < * > Washington University Medical School |
| v 660 South Euclid |
| Bitnet: david%wubios@wucfua.wustl Saint Louis, MO 63110 |
| Internet: david%wubios@wucfua.wustl.edu |
*-------------------------------------------------------------------------*
*/
#include <readable.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
main (argc, argv)
int argc;
char * argv [];
begin
char infile [64], outfile [64];
FILE * inf;
FILE * otf;
char buffer [1024];
long holdpos, position;
long i;
if (argc != 3 or strlen (argv [1]) != 2 or strlen (argv [2]) != 2 or
not isalpha (argv [1] [0]) or argv [1] [1] != ':' or
not isalpha (argv [2] [0]) or argv [2] [1] != ':')
begin
fprintf (stderr,"usage: backlog c: a: (or other drive names)\n");
fprintf (stderr,"Copies latest portion of \\BACKUP.LOG");
exit (1);
end
strcpy (infile, argv [1]);
strcat (infile, "\\BACKUP.LOG");
strcpy (outfile, argv [2]);
strcat (outfile, "\\BACKUP.LOG");
inf = fopen (infile, "r");
holdpos = ftell (inf);
position = holdpos;
fgets (buffer, 1024, inf);
while (not feof (inf))
begin
/* Find the last date field. */
if (isdigit (buffer [0]) and not isspace (buffer [3]))
begin
position = holdpos;
buffer [strlen (buffer) - 1] = '\0';
fprintf (stdout, "%s \r", buffer);
end
holdpos = ftell (inf);
fgets (buffer, 1024, inf);
end
rewind (inf);
if (0 != fseek (inf, position, SEEK_SET))
begin
fprintf (stderr, "Error seeking into %s\n", infile);
exit (2);
end
fgets (buffer, 1024, inf);
fprintf (stdout, "\nWriting %s\n", outfile);
otf = fopen (outfile, "w");
while (not feof (inf))
begin
fputs (buffer, otf);
fgets (buffer, 1024, inf);
end
fputs (buffer, otf);
fclose (inf);
fclose (otf);
end
/* readable.h follows
#define begin {
#define end }
#define and &&
#define or ||
#define not !
#define eq ==
*/