diff options
author | simonb <simonb@NetBSD.org> | 2000-07-31 11:32:33 +0000 |
---|---|---|
committer | simonb <simonb@NetBSD.org> | 2000-07-31 11:32:33 +0000 |
commit | 082bea3cb121dc354c2dc17781ae2e9622864f8e (patch) | |
tree | 90a99b63bf437eb5fda90859511ec82322d1fa17 /fortune/strfile | |
parent | cdb35d118cef7a4ec366984eee09299364599519 (diff) | |
download | bsdgames-darwin-082bea3cb121dc354c2dc17781ae2e9622864f8e.tar.gz bsdgames-darwin-082bea3cb121dc354c2dc17781ae2e9622864f8e.tar.zst bsdgames-darwin-082bea3cb121dc354c2dc17781ae2e9622864f8e.zip |
Use a local implementation of htonl() called h2nl(). htonl() is not
available in all cross-compile environments.
Patches from Chris Demetriou.
Diffstat (limited to 'fortune/strfile')
-rw-r--r-- | fortune/strfile/strfile.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/fortune/strfile/strfile.c b/fortune/strfile/strfile.c index ba35de82..3fe83d95 100644 --- a/fortune/strfile/strfile.c +++ b/fortune/strfile/strfile.c @@ -1,4 +1,4 @@ -/* $NetBSD: strfile.c,v 1.19 2000/01/13 16:22:10 jsm Exp $ */ +/* $NetBSD: strfile.c,v 1.20 2000/07/31 11:32:33 simonb Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -47,7 +47,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.19 2000/01/13 16:22:10 jsm Exp $"); +__RCSID("$NetBSD: strfile.c,v 1.20 2000/07/31 11:32:33 simonb Exp $"); #endif #endif /* not lint */ #endif /* __NetBSD__ */ @@ -70,6 +70,21 @@ __RCSID("$NetBSD: strfile.c,v 1.19 2000/01/13 16:22:10 jsm Exp $"); # define MAXPATHLEN 1024 # endif /* MAXPATHLEN */ +u_int32_t +h2nl(u_int32_t h) +{ + unsigned char c[4]; + u_int32_t rv; + + c[0] = (h >> 24) & 0xff; + c[1] = (h >> 16) & 0xff; + c[2] = (h >> 8) & 0xff; + c[3] = (h >> 0) & 0xff; + memcpy(&rv, c, sizeof rv); + + return (rv); +} + /* * This program takes a file composed of strings seperated by * lines starting with two consecutive delimiting character (default @@ -253,11 +268,11 @@ main(ac, av) } (void) fseek(outf, (off_t) 0, SEEK_SET); - 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); + Tbl.str_version = h2nl(Tbl.str_version); + Tbl.str_numstr = h2nl(Num_pts - 1); + Tbl.str_longlen = h2nl(Tbl.str_longlen); + Tbl.str_shortlen = h2nl(Tbl.str_shortlen); + Tbl.str_flags = h2nl(Tbl.str_flags); (void) fwrite((char *) &Tbl, sizeof Tbl, 1, outf); if (STORING_PTRS) { for (p = Seekpts, cnt = Num_pts; cnt--; ++p) |