BSD 4_4 release
[unix-history] / usr / src / sbin / dump / itime.c
index 901596e..94656ac 100644 (file)
@@ -1,39 +1,63 @@
 /*-
 /*-
- * Copyright (c) 1980 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)itime.c    5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)itime.c    8.1 (Berkeley) 6/5/93";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#ifdef sunos
-#include <stdio.h>
-#include <ctype.h>
 #include <sys/param.h>
 #include <sys/param.h>
-#include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/time.h>
-#include <sys/dir.h>
+#ifdef sunos
 #include <sys/vnode.h>
 #include <sys/vnode.h>
+
+#include <ufs/fsdir.h>
 #include <ufs/inode.h>
 #include <ufs/fs.h>
 #else
 #include <ufs/inode.h>
 #include <ufs/fs.h>
 #else
-#include <sys/param.h>
-#include <sys/time.h>
 #include <ufs/ufs/dinode.h>
 #endif
 #include <ufs/ufs/dinode.h>
 #endif
-#include <fcntl.h>
+
 #include <protocols/dumprestore.h>
 #include <protocols/dumprestore.h>
+
 #include <errno.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #ifdef __STDC__
 #include <stdio.h>
 #ifdef __STDC__
-#include <time.h>
-#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #endif
 #endif
+
 #include "dump.h"
 
 struct dumpdates **ddatev = 0;
 #include "dump.h"
 
 struct dumpdates **ddatev = 0;
@@ -41,11 +65,10 @@ int nddates = 0;
 int    ddates_in = 0;
 struct dumptime *dthead = 0;
 
 int    ddates_in = 0;
 struct dumptime *dthead = 0;
 
-void   readdumptimes();
-int    getrecord();
-int    makedumpdate();
-
-static void dumprecout();
+static void dumprecout __P((FILE *, struct dumpdates *));
+static int getrecord __P((FILE *, struct dumpdates *));
+static int makedumpdate __P((struct dumpdates *, char *));
+static void readdumptimes __P((FILE *));
 
 void
 initdumptimes()
 
 void
 initdumptimes()
@@ -76,10 +99,10 @@ initdumptimes()
        }
        (void) flock(fileno(df), LOCK_SH);
        readdumptimes(df);
        }
        (void) flock(fileno(df), LOCK_SH);
        readdumptimes(df);
-       fclose(df);
+       (void) fclose(df);
 }
 
 }
 
-void
+static void
 readdumptimes(df)
        FILE *df;
 {
 readdumptimes(df)
        FILE *df;
 {
@@ -101,7 +124,7 @@ readdumptimes(df)
         *      record that we may have to add to the ddate structure
         */
        ddatev = (struct dumpdates **)
         *      record that we may have to add to the ddate structure
         */
        ddatev = (struct dumpdates **)
-               calloc(nddates + 1, sizeof (struct dumpdates *));
+               calloc((unsigned) (nddates + 1), sizeof (struct dumpdates *));
        dtwalk = dthead;
        for (i = nddates - 1; i >= 0; i--, dtwalk = dtwalk->dt_next)
                ddatev[i] = &dtwalk->dt_value;
        dtwalk = dthead;
        for (i = nddates - 1; i >= 0; i--, dtwalk = dtwalk->dt_next)
                ddatev[i] = &dtwalk->dt_value;
@@ -155,7 +178,7 @@ putdumptime()
        fd = fileno(df);
        (void) flock(fd, LOCK_EX);
        fname = disk;
        fd = fileno(df);
        (void) flock(fd, LOCK_EX);
        fname = disk;
-       free(ddatev);
+       free((char *)ddatev);
        ddatev = 0;
        nddates = 0;
        dthead = 0;
        ddatev = 0;
        nddates = 0;
        dthead = 0;
@@ -210,7 +233,8 @@ dumprecout(file, what)
 }
 
 int    recno;
 }
 
 int    recno;
-int
+
+static int
 getrecord(df, ddatep)
        FILE *df;
        struct dumpdates *ddatep;
 getrecord(df, ddatep)
        FILE *df;
        struct dumpdates *ddatep;
@@ -232,16 +256,14 @@ getrecord(df, ddatep)
        return(0);
 }
 
        return(0);
 }
 
-time_t unctime();
-
-int
+static int
 makedumpdate(ddp, tbuf)
        struct dumpdates *ddp;
        char *tbuf;
 {
        char un_buf[128];
 
 makedumpdate(ddp, tbuf)
        struct dumpdates *ddp;
        char *tbuf;
 {
        char un_buf[128];
 
-       sscanf(tbuf, DUMPINFMT, ddp->dd_name, &ddp->dd_level, un_buf);
+       (void) sscanf(tbuf, DUMPINFMT, ddp->dd_name, &ddp->dd_level, un_buf);
        ddp->dd_ddate = unctime(un_buf);
        if (ddp->dd_ddate < 0)
                return(-1);
        ddp->dd_ddate = unctime(un_buf);
        if (ddp->dd_ddate < 0)
                return(-1);