home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / aros / writefloat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-28  |  1.5 KB  |  78 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: writefloat.c,v 1.5 1997/01/27 00:16:39 ldp Exp $
  4.  
  5.     Desc: Write a big endian floating point (32bit) from a file
  6.     Lang: english
  7. */
  8. #include <proto/dos.h>
  9.  
  10. /******************************************************************************
  11.  
  12.     NAME */
  13. #include <stdio.h>
  14. #include <proto/alib.h>
  15.  
  16.     BOOL WriteFloat (
  17.  
  18. /*  SYNOPSIS */
  19.     BPTR  fh,
  20.     FLOAT data)
  21.  
  22. /*  FUNCTION
  23.     Writes one big endian 32bit floating point value to a file.
  24.  
  25.     INPUTS
  26.     fh - Write to this file
  27.     data - Data to be written
  28.  
  29.     RESULT
  30.     The function returns TRUE on success and FALSE otherwise.
  31.     See IoErr() for the reason in case of an error.
  32.  
  33.     NOTES
  34.     This function writes big endian values to a file even on little
  35.     endian machines.
  36.  
  37.     EXAMPLE
  38.  
  39.     BUGS
  40.  
  41.     SEE ALSO
  42.     Open(), Close(), ReadByte(), ReadWord(), ReadLong(), ReadDouble(),
  43.     ReadString(), WriteByte(), WriteWord(), WriteLong(), WriteDouble(),
  44.     WriteString()
  45.  
  46.     HISTORY
  47.     14.09.93    ada created
  48.  
  49. ******************************************************************************/
  50. {
  51.     UBYTE * ptr;
  52.     LONG    rc;
  53.  
  54. #if AROS_BIG_ENDIAN
  55.     ptr = (UBYTE *)&data;
  56. #   define NEXT ptr++
  57. #else
  58.     ptr = ((UBYTE *)&data) + 3;
  59. #   define NEXT ptr--
  60. #endif
  61.  
  62. #define WRITE_ONE_BYTE        \
  63.     rc = FPutC (fh, *ptr);  \
  64.                 \
  65.     if (rc == EOF)          \
  66.     return FALSE;        \
  67.                 \
  68.     NEXT
  69.  
  70.     WRITE_ONE_BYTE;
  71.     WRITE_ONE_BYTE;
  72.     WRITE_ONE_BYTE;
  73.     WRITE_ONE_BYTE;
  74.  
  75.     return TRUE;
  76. } /* WriteFloat */
  77.  
  78.