lintian doesn't like orphan packages with uploaders...
[debian/amanda] / server-src / infofile.c
index b7db7a89472eea3f835281c00c305fd9027906de..8df21b93acf6500f742e877a45cc132c0e566fb7 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
  * Copyright (c) 1991-1998 University of Maryland at College Park
+ * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
  * All Rights Reserved.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
 #include "amanda.h"
 #include "conffile.h"
 #include "infofile.h"
-#include "token.h"
+#include "util.h"
 
 static void zero_info(info_t *);
 
-  static char *infodir = (char *)0;
-  static char *infofile = (char *)0;
+  static char *infodir = NULL;
+  static char *infofile = NULL;
   static char *newinfofile;
   static int writing;
 
@@ -221,7 +222,6 @@ read_txinfofile(
        stats_t onestat;        /* one stat record */
        int level = 0;
        long long off_t_tmp;
-       intmax_t time_t_tmp;
 
        if (line[0] == '\0')
            continue;
@@ -241,62 +241,64 @@ read_txinfofile(
        s = line;
        ch = *s++;
 
+       /* from here on, we had better be parsing a 'stats' line */
        if(strncmp_const_skip(line, "stats:", s, ch) != 0) {
-           break;
+           return -1;
        }
 
        skip_whitespace(s, ch);
        if(ch == '\0' || sscanf((s - 1), "%d", &level) != 1) {
-           break;
+           return -1;
        }
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
        if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
-           break;
+           return -1;
        }
        onestat.size = (off_t)off_t_tmp;
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
        if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
-           break;
+           return -1;
        }
        onestat.csize = (off_t)off_t_tmp;
        skip_integer(s, ch);
 
+       /* assume that the time fits in a long long */
        skip_whitespace(s, ch);
-       if(ch == '\0' || sscanf((s - 1), "%jd", &time_t_tmp) != 1) {
-           break;
+       if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
+           return -1;
        }
-        onestat.secs = (time_t)time_t_tmp;
+        onestat.secs = (time_t)off_t_tmp;
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
-       if(ch == '\0' || sscanf((s - 1), "%jd", &time_t_tmp) != 1) {
-           break;
+       if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
+           return -1;
        }
-       onestat.date = (time_t)time_t_tmp;
+       onestat.date = (time_t)off_t_tmp;
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
        if(ch != '\0') {
            if(sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
-               break;
+               return -1;
            }
            onestat.filenum = (off_t)off_t_tmp;
            skip_integer(s, ch);
 
            skip_whitespace(s, ch);
            if(ch == '\0') {
-               break;
+               return -1;
            }
            strncpy(onestat.label, s-1, SIZEOF(onestat.label)-1);
            onestat.label[SIZEOF(onestat.label)-1] = '\0';
        }
 
        if(level < 0 || level > DUMP_LEVELS-1)
-           break;
+           return -1;
 
        info->inf[level] = onestat;
     }
@@ -318,7 +320,6 @@ read_txinfofile(
     for(rc = -2; (line = agets(infof)) != NULL; free(line)) {
        history_t onehistory;   /* one history record */
        long long off_t_tmp;
-       intmax_t time_t_tmp;
 
        if (line[0] == '\0')
            continue;
@@ -363,21 +364,21 @@ read_txinfofile(
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);
-       if(ch == '\0' || sscanf((s - 1), "%jd", &time_t_tmp) != 1) {
+       if(ch == '\0' || sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
            amfree(line);
            break;
        }
-       onehistory.date = (time_t)time_t_tmp;
+       onehistory.date = (time_t)off_t_tmp;
        skip_integer(s, ch);
 
        onehistory.secs = (unsigned long)-1;
        skip_whitespace(s, ch);
        if(ch != '\0') {
-           if(sscanf((s - 1), "%jd", &time_t_tmp) != 1) {
+           if(sscanf((s - 1), "%lld", &off_t_tmp) != 1) {
                amfree(line);
                break;
            }
-           onehistory.secs = (time_t)time_t_tmp;
+           onehistory.secs = (time_t)off_t_tmp;
            skip_integer(s, ch);
        }
 
@@ -501,7 +502,7 @@ int
 open_infofile(
     char *     filename)
 {
-    assert(infodir == (char *)0);
+    assert(infodir == NULL);
 
     infodir = stralloc(filename);
 
@@ -511,7 +512,7 @@ open_infofile(
 void
 close_infofile(void)
 {
-    assert(infodir != (char *)0);
+    assert(infodir != NULL);
 
     amfree(infodir);
 }
@@ -741,6 +742,7 @@ main(
     close_infofile();
   }
 
+  dbclose();
   return 0;
 }