Imported Upstream version 2.5.1
[debian/amanda] / server-src / amindex.c
index 2e763dc44b88225ae38bb16cce821af42cd149d8..b775c43d2a5b551ad4f943bbcaffcca5cc352f75 100644 (file)
  *                        University of Maryland at College Park
  */
 /*
- * $Id: amindex.c,v 1.13 2001/09/01 03:36:24 jrjackson Exp $
+ * $Id: amindex.c,v 1.15 2006/05/25 01:47:19 johnfranks Exp $
  *
  * index control
  */
 
+#include "amanda.h"
 #include "conffile.h"
 #include "amindex.h"
 
-char *getindexfname(host, disk, date, level)
-char *host, *disk, *date;
-int level;
+char *
+getindexfname(
+    char *     host,
+    char *     disk,
+    char *     date,
+    int                level)
 {
   char *conf_indexdir;
   char *buf;
   char level_str[NUM_STR_SIZE];
-  char datebuf[8 + 1];
+  char datebuf[14 + 1];
   char *dc = NULL;
   char *pc;
   int ch;
@@ -48,17 +52,19 @@ int level;
   if (date != NULL) {
     dc = date;
     pc = datebuf;
-    while (pc < datebuf + sizeof (datebuf)) {
-      if ((*pc++ = ch = *dc++) == '\0') {
+    while (pc < datebuf + SIZEOF(datebuf)) {
+      ch = *dc++;
+      *pc++ = (char)ch;
+      if (ch == '\0') {
         break;
       } else if (! isdigit (ch)) {
         pc--;
       }
     }
-    datebuf[sizeof(datebuf)-1] = '\0';
+    datebuf[SIZEOF(datebuf)-1] = '\0';
     dc = datebuf;
 
-    snprintf(level_str, sizeof(level_str), "%d", level);
+    snprintf(level_str, SIZEOF(level_str), "%d", level);
   }
 
   host = sanitise_filename(host);