-/* $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
#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 */
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
+# include <time.h>
# include <unistd.h>
# include "strfile.h"
int main __P((int, char *[]));
void randomize __P((void));
char *unctrl __P((char));
-void usage __P((void));
+void usage __P((void)) __attribute__((__noreturn__));
/*
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
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);
off_t net;
if (!STORING_PTRS) {
- net = htonl(off);
+ net = htobe64(off);
fwrite(&net, 1, sizeof net, fp);
} else {
ALLOC(Seekpts, Num_pts + 1);
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)
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;