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

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