tabs->spaces
[AROS.git] / compiler / arossupport / writedouble.c
blobe33888a847750e447566b30ea016f9ff6270f9fc
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Write a big endian floating point (64bit) from a streamhook
6 Lang: english
7 */
9 #include <proto/dos.h>
11 /******************************************************************************
13 NAME */
14 #include <stdio.h>
15 #include <aros/bigendianio.h>
16 #include <proto/alib.h>
18 BOOL WriteDouble (
20 /* SYNOPSIS */
21 struct Hook * hook,
22 DOUBLE data,
23 void * stream)
25 /* FUNCTION
26 Writes one big endian 64bit double precision floating point value
27 to a streamhook.
29 INPUTS
30 hook - Write to this streamhook
31 data - Data to be written
32 stream - Stream passed to streamhook
34 RESULT
35 The function returns TRUE on success and FALSE otherwise.
36 See IoErr() for the reason in case of an error.
38 NOTES
39 This function writes big endian values to a file even on little
40 endian machines.
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 ReadByte(), ReadWord(), ReadLong(), ReadFloat(), ReadDouble(),
48 ReadString(), ReadStruct(), WriteByte(), WriteWord(), WriteLong(),
49 WriteFloat(), WriteDouble(), WriteString(), WriteStruct()
51 HISTORY
53 ******************************************************************************/
55 UBYTE * ptr;
56 struct BEIOM_Write wr = {BEIO_WRITE,};
58 #if AROS_BIG_ENDIAN
59 ptr = (UBYTE *)&data;
60 # define NEXT ++
61 #else
62 ptr = ((UBYTE *)&data) + 7;
63 # define NEXT --
64 #endif
66 #define WRITE_ONE_BYTE \
67 wr.Data = *ptr NEXT; \
68 if (CallHookA (hook, stream, &wr) == EOF) \
69 return FALSE
71 WRITE_ONE_BYTE;
72 WRITE_ONE_BYTE;
73 WRITE_ONE_BYTE;
74 WRITE_ONE_BYTE;
75 WRITE_ONE_BYTE;
76 WRITE_ONE_BYTE;
77 WRITE_ONE_BYTE;
78 WRITE_ONE_BYTE;
80 return TRUE;
81 } /* WriteDouble */