home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / backlog.c < prev    next >
Internet Message Format  |  1994-03-04  |  4KB

  1. Date: Tue, 12 Jul 88 17:16:17 cdt
  2. From: wucs1!wubios!david@uunet.UU.NET (David Camp)
  3. Subject: BACKLOG.C
  4.  
  5. Greg,
  6.      Here is a little something I cooked up.
  7. -David-
  8.  
  9. *-------------------------------------------------------------------------*
  10. | (314) 362-3635                     Mr. David J. Camp                    |
  11. | Room 1108D               ^         Box 8067, Biostatistics              |
  12. | 706 South Euclid       < * >       Washington University Medical School |
  13. |                          v         660 South Euclid                     |
  14. | Bitnet: david%wubios@wucfua.wustl  Saint Louis, MO 63110                |
  15. | Internet: david%wubios@wucfua.wustl.edu                                 |
  16. *-------------------------------------------------------------------------*
  17.  
  18. /* BACKLOG.C -- program to copy latest portion of BACKUP.LOG */
  19. /* Written by David J. Camp of the Washington University
  20.                                    Division of Biostatistics */
  21.  
  22. /*
  23.      I have sent you BACKLOG.C and BACKLOG.EXE, which does something
  24. useful.  Whenever I use the MS-Dos 3.3 BACKUP command, I like to specify
  25. /L to get information appended to C:\BACKUP.LOG indicating each file
  26. backed up.  I have routinely edited this file, placing the latest portion
  27. on the last disk of my backup.  Now there is BACKLOG, which takes two
  28. arguments, the source drive and the target drive, e.g.:
  29.  
  30.      BACKLOG c: a:
  31.  
  32. It will copy just the part pertaining to your latest backup into a file
  33. named \BACKUP.LOG on the target drive.
  34.  
  35. *-------------------------------------------------------------------------*
  36. | (314) 362-3635                     Mr. David J. Camp                    |
  37. | Room 1108D               ^         Box 8067, Biostatistics              |
  38. | 706 South Euclid       < * >       Washington University Medical School |
  39. |                          v         660 South Euclid                     |
  40. | Bitnet: david%wubios@wucfua.wustl  Saint Louis, MO 63110                |
  41. | Internet: david%wubios@wucfua.wustl.edu                                 |
  42. *-------------------------------------------------------------------------*
  43.  
  44. */
  45.  
  46. #include <readable.h>
  47. #include <stdio.h>
  48. #include <string.h>
  49. #include <ctype.h>
  50. #include <stdlib.h>
  51.  
  52. main (argc, argv)
  53. int argc;
  54. char * argv [];
  55.  
  56. begin
  57. char infile [64], outfile [64];
  58. FILE * inf;
  59. FILE * otf;
  60. char buffer [1024];
  61. long holdpos, position;
  62. long i;
  63.  
  64. if (argc != 3 or strlen (argv [1]) != 2 or strlen (argv [2]) != 2 or
  65.         not isalpha (argv [1] [0]) or argv [1] [1] != ':' or
  66.         not isalpha (argv [2] [0]) or argv [2] [1] != ':')
  67.     begin
  68.     fprintf (stderr,"usage: backlog c: a: (or other drive names)\n");
  69.     fprintf (stderr,"Copies latest portion of \\BACKUP.LOG");
  70.     exit (1);
  71.     end
  72. strcpy (infile, argv [1]);
  73. strcat (infile, "\\BACKUP.LOG");
  74. strcpy (outfile, argv [2]);
  75. strcat (outfile, "\\BACKUP.LOG");
  76. inf = fopen (infile, "r");
  77. holdpos = ftell (inf);
  78. position = holdpos;
  79. fgets (buffer, 1024, inf);
  80. while (not feof (inf))
  81.     begin
  82.     /* Find the last date field. */
  83.     if (isdigit (buffer [0]) and not isspace (buffer [3]))
  84.         begin
  85.         position = holdpos;
  86.         buffer [strlen (buffer) - 1] = '\0';
  87.         fprintf (stdout, "%s  \r", buffer);
  88.         end
  89.     holdpos = ftell (inf);
  90.     fgets (buffer, 1024, inf);
  91.     end
  92. rewind (inf);
  93. if (0 != fseek (inf, position, SEEK_SET))
  94.     begin
  95.     fprintf (stderr, "Error seeking into %s\n", infile);
  96.     exit (2);
  97.     end
  98. fgets (buffer, 1024, inf);
  99. fprintf (stdout, "\nWriting %s\n", outfile);
  100. otf = fopen (outfile, "w");
  101. while (not feof (inf))
  102.     begin
  103.     fputs (buffer, otf);
  104.     fgets (buffer, 1024, inf);
  105.     end
  106. fputs (buffer, otf);
  107. fclose (inf);
  108. fclose (otf);
  109. end
  110. /* readable.h follows
  111. #define begin {
  112. #define end }
  113. #define and &&
  114. #define or ||
  115. #define not !
  116. #define eq ==
  117. */
  118.