File: compactlog.c

package info (click to toggle)
e2undel 0.82-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 316 kB
  • ctags: 300
  • sloc: ansic: 4,112; makefile: 109
file content (41 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* compactlog.c: compacts libundel log file */
/* not specifically tested yet, but seems to work */

/* (C) Oliver Diedrich */
/* this file may be redistributed under the terms of the */
/* GNU Public License (GPL), see www.gnu.org */


#include <stdio.h>
#include "e2undel.h"

int flag_redir = 1;   /* avoids printing progress points when reading */

int main(int argc, char **argv)
{
  int n_log;
  struct e2undel_log *log;    /* list of log file entries */

  if (argc > 1)
  {
    printf("compacts libundel log file %s to stdout\n", LOGNAME);
    printf("usage: %s [> TMP]\n", argv[0]);
    printf("[cp TMP %s]\n", LOGNAME);
    return 1;
  }
  
  fprintf(stderr, "reading log file: ");
  fflush(stderr);
  if (NULL == (log = read_log(0, &n_log)))
  {
    printf("no entries in log file\n");
    return 1;
  }
  fprintf(stderr, "%d entries\n", n_log);
  fprintf(stderr, "compacting log file: ");
  fflush(stderr);
  log = compact_log(log, &n_log);
  fprintf(stderr, "%d entries remaining\n", n_log);
  print_log(log);
  return 0;
}