Adjusted paths for GRUB2 2.00.
[AROS.git] / compiler / arossupport / readlong.c
blobb36cb58e628e160c0cef5b32fb0a97e1e3693f00
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Read a big endian long (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 ReadLong (
20 /* SYNOPSIS */
21 struct Hook * hook,
22 ULONG * dataptr,
23 void * stream)
25 /* FUNCTION
26 Reads one big endian 32bit 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 ULONG value;
57 LONG c;
58 UBYTE * ptr;
60 struct BEIOM_Read rd = {BEIO_READ};
62 #if AROS_BIG_ENDIAN
63 ptr = (UBYTE *)&value;
64 # define NEXT ++
65 #else
66 ptr = ((UBYTE *)&value) + 3;
67 # define NEXT --
68 #endif
70 #define READ_ONE_BYTE \
71 if ((c = CallHookA (hook, stream, &rd)) == EOF) \
72 return FALSE; \
74 *ptr NEXT = c
76 READ_ONE_BYTE;
77 READ_ONE_BYTE;
78 READ_ONE_BYTE;
79 READ_ONE_BYTE;
81 *dataptr = value;
83 return TRUE;
84 } /* ReadLong */