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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: writelong.c,v 1.5 1997/01/27 00:16:39 ldp Exp $
  4.  
  5.     Desc: Write a big endian long (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 WriteLong (
  17.  
  18. /*  SYNOPSIS */
  19.     BPTR  fh,
  20.     ULONG data)
  21.  
  22. /*  FUNCTION
  23.     Writes one big endian 32bit 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(), WriteDouble(),
  44.     WriteString()
  45.  
  46.     HISTORY
  47.     14.09.93    ada created
  48.  
  49. ******************************************************************************/
  50. {
  51.     UBYTE * ptr;
  52.  
  53. #if AROS_BIG_ENDIAN
  54.     ptr = (UBYTE *)&data;
  55. #   define NEXT ++
  56. #else
  57.     ptr = ((UBYTE *)&data) + 3;
  58. #   define NEXT --
  59. #endif
  60.  
  61. #define WRITE_ONE_CHAR            \
  62.     if (FPutC (fh, *ptr NEXT) == EOF)   \
  63.     return FALSE
  64.  
  65.     WRITE_ONE_CHAR;
  66.     WRITE_ONE_CHAR;
  67.     WRITE_ONE_CHAR;
  68.     WRITE_ONE_CHAR;
  69.  
  70.     return TRUE;
  71. } /* WriteLong */
  72.  
  73.