Updated include-file define name to match file name.
[AROS.git] / compiler / arossupport / readfloat.c
blobffc3387a1e4b6b5f1b2fc22955f4225640a85af0
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Read a big endian floating point (32bit) 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 ReadFloat (
20 /* SYNOPSIS */
21 struct Hook * hook,
22 FLOAT * dataptr,
23 void * stream)
25 /* FUNCTION
26 Reads one big endian 32bit floating point value from a streamhook.
28 INPUTS
29 hook - Streamhook
30 dataptr - Put the data here
31 stream - Read from this stream
33 RESULT
34 The function returns TRUE on success. On success, the value
35 read is written into dataptr. On failure, FALSE is returned and the
36 contents of dataptr are not changed.
38 NOTES
39 This function reads big endian values from a streamhook even on
40 little 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
52 14.09.93 ada created
54 ******************************************************************************/
56 union
58 ULONG ulong_val;
59 float float_val;
60 } value;
61 LONG c;
62 UBYTE * ptr;
64 struct BEIOM_Read rd = {BEIO_READ};
66 #if AROS_BIG_ENDIAN
67 ptr = (UBYTE *)&value;
68 # define NEXT ++
69 #else
70 ptr = ((UBYTE *)&value) + 3;
71 # define NEXT --
72 #endif
74 #define READ_ONE_BYTE \
75 if ((c = CallHookA (hook, stream, &rd)) == EOF) \
76 return FALSE; \
78 *ptr NEXT = c
80 READ_ONE_BYTE;
81 READ_ONE_BYTE;
82 READ_ONE_BYTE;
83 READ_ONE_BYTE;
85 *dataptr = value.float_val;
87 return TRUE;
88 } /* ReadFloat */