tabs->spaces
[AROS.git] / compiler / arossupport / readword.c
blob849776a4b6f47eefe8322b66a425c0312e2c5e3c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Read a big endian word (16bit) from a streamhook
6 Lang: english
7 */
9 #include <proto/dos.h>
10 #include <stdio.h>
11 #include <assert.h>
13 /******************************************************************************
15 NAME */
16 #include <aros/bigendianio.h>
17 #include <proto/alib.h>
19 BOOL ReadWord (
21 /* SYNOPSIS */
22 struct Hook * hook,
23 UWORD * dataptr,
24 void * stream)
26 /* FUNCTION
27 Reads one big endian 16bit value from a streamhook.
29 INPUTS
30 hook - Streamhook
31 dataptr - Put the data here
32 stream - Read from this stream
34 RESULT
35 The function returns TRUE on success. On success, the value
36 read is written into dataptr. On failure, FALSE is returned and the
37 contents of dataptr are not changed.
39 NOTES
40 This function reads big endian values from a streamhook even on
41 little endian machines.
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 ReadByte(), ReadWord(), ReadLong(), ReadFloat(), ReadDouble(),
49 ReadString(), ReadStruct(), WriteByte(), WriteWord(), WriteLong(),
50 WriteFloat(), WriteDouble(), WriteString(), WriteStruct()
52 HISTORY
54 ******************************************************************************/
56 LONG value, c;
58 struct BEIOM_Read rd = {BEIO_READ};
60 /* High byte */
61 c = CallHookA (hook, stream, &rd);
63 if (c == EOF)
64 return FALSE;
66 /* Low byte */
67 value = CallHookA (hook, stream, &rd);
69 if (value == EOF)
70 return FALSE;
72 *dataptr = (c << 8) + value;
74 return TRUE;
75 } /* ReadWord */