]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - fortune/strfile/strfile.c
Include <time.h> in various places in the games where time() or time_t
[bsdgames-darwin.git] / fortune / strfile / strfile.c
index 0e35ba242c68109b0bc20251a63b1278087e1be2..0d74f4e24d4cb926084cdbdaf41dcf04197d9b16 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: strfile.c,v 1.7 1997/10/11 07:48:58 lukem Exp $        */
+/*     $NetBSD: strfile.c,v 1.12 1999/09/09 17:30:19 jsm Exp $ */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
 #if 0
 static char sccsid[] = "@(#)strfile.c  8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.7 1997/10/11 07:48:58 lukem Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.12 1999/09/09 17:30:19 jsm Exp $");
 #endif
 #endif /* not lint */
 
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: strfile.c,v 1.7 1997/10/11 07:48:58 lukem Exp $");
 # include      <stdio.h>
 # include      <stdlib.h>
 # include      <string.h>
+# include      <time.h>
 # include      <unistd.h>
 # include      "strfile.h"
 
@@ -142,7 +143,7 @@ void        getargs __P((int, char *[]));
 int    main __P((int, char *[]));
 void   randomize __P((void));
 char   *unctrl __P((char));
-void   usage __P((void));
+void   usage __P((void)) __attribute__((__noreturn__));
 
 
 /*
@@ -175,7 +176,7 @@ main(ac, av)
        if ((outf = fopen(Outfile, "w")) == NULL)
                err(1, "open `%s'", Outfile);
        if (!STORING_PTRS)
-               (void) fseek(outf, sizeof Tbl, 0);
+               (void) fseek(outf, sizeof Tbl, SEEK_SET);
 
        /*
         * Write the strings onto the file
@@ -243,16 +244,16 @@ main(ac, av)
                       Tbl.str_shortlen == 1 ? "" : "s");
        }
 
-       (void) fseek(outf, (off_t) 0, 0);
-       Tbl.str_version = htonl(Tbl.str_version);
-       Tbl.str_numstr = htonl(Num_pts - 1);
-       Tbl.str_longlen = htonl(Tbl.str_longlen);
-       Tbl.str_shortlen = htonl(Tbl.str_shortlen);
-       Tbl.str_flags = htonl(Tbl.str_flags);
+       (void) fseek(outf, (off_t) 0, SEEK_SET);
+       HTOBE32(Tbl.str_version);
+       Tbl.str_numstr = htobe32(Num_pts - 1);
+       HTOBE32(Tbl.str_longlen);
+       HTOBE32(Tbl.str_shortlen);
+       HTOBE32(Tbl.str_flags);
        (void) fwrite((char *) &Tbl, sizeof Tbl, 1, outf);
        if (STORING_PTRS) {
                for (p = Seekpts, cnt = Num_pts; cnt--; ++p)
-                       *p = htonl(*p);
+                       HTOBE64(*p);
                (void) fwrite((char *) Seekpts, sizeof *Seekpts, (int) Num_pts, outf);
        }
        (void) fclose(outf);
@@ -334,7 +335,7 @@ add_offset(fp, off)
        off_t net;
 
        if (!STORING_PTRS) {
-               net = htonl(off);
+               net = htobe64(off);
                fwrite(&net, 1, sizeof net, fp);
        } else {
                ALLOC(Seekpts, Num_pts + 1);
@@ -396,12 +397,12 @@ int
 cmp_str(vp1, vp2)
        const void *vp1, *vp2;
 {
-       STR     *p1, *p2;
+       const STR       *p1, *p2;
        int     c1, c2;
        int     n1, n2;
 
-       p1 = (STR *)vp1;
-       p2 = (STR *)vp2;
+       p1 = (const STR *)vp1;
+       p2 = (const STR *)vp2;
 
 # define       SET_N(nf,ch)    (nf = (ch == '\n'))
 # define       IS_END(ch,nf)   (ch == Delimch && nf)
@@ -411,8 +412,8 @@ cmp_str(vp1, vp2)
        if (c1 != c2)
                return c1 - c2;
 
-       (void) fseek(Sort_1, p1->pos, 0);
-       (void) fseek(Sort_2, p2->pos, 0);
+       (void) fseek(Sort_1, p1->pos, SEEK_SET);
+       (void) fseek(Sort_2, p2->pos, SEEK_SET);
 
        n1 = FALSE;
        n2 = FALSE;