home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Sound / LAME / Source / portableio.h < prev    next >
C/C++ Source or Header  |  1997-01-22  |  4KB  |  96 lines

  1. #ifndef PORTABLEIO_H__
  2. #define PORTABLEIO_H__
  3. /* Copyright (C) 1988-1991 Apple Computer, Inc.
  4.  * All Rights Reserved.
  5.  *
  6.  * Warranty Information
  7.  * Even though Apple has reviewed this software, Apple makes no warranty
  8.  * or representation, either express or implied, with respect to this
  9.  * software, its quality, accuracy, merchantability, or fitness for a 
  10.  * particular purpose.  As a result, this software is provided "as is,"
  11.  * and you, its user, are assuming the entire risk as to its quality
  12.  * and accuracy.
  13.  *
  14.  * This code may be used and freely distributed as long as it includes
  15.  * this copyright notice and the warranty information.
  16.  *
  17.  * Machine-independent I/O routines for 8-, 16-, 24-, and 32-bit integers.
  18.  *
  19.  * Motorola processors (Macintosh, Sun, Sparc, MIPS, etc)
  20.  * pack bytes from high to low (they are big-endian).
  21.  * Use the HighLow routines to match the native format
  22.  * of these machines.
  23.  *
  24.  * Intel-like machines (PCs, Sequent)
  25.  * pack bytes from low to high (the are little-endian).
  26.  * Use the LowHigh routines to match the native format
  27.  * of these machines.
  28.  *
  29.  * These routines have been tested on the following machines:
  30.  *    Apple Macintosh, MPW 3.1 C compiler
  31.  *    Apple Macintosh, THINK C compiler
  32.  *    Silicon Graphics IRIS, MIPS compiler
  33.  *    Cray X/MP and Y/MP
  34.  *    Digital Equipment VAX
  35.  *
  36.  *
  37.  * Implemented by Malcolm Slaney and Ken Turkowski.
  38.  *
  39.  * Malcolm Slaney contributions during 1988-1990 include big- and little-
  40.  * endian file I/O, conversion to and from Motorola's extended 80-bit
  41.  * floating-point format, and conversions to and from IEEE single-
  42.  * precision floating-point format.
  43.  *
  44.  * In 1991, Ken Turkowski implemented the conversions to and from
  45.  * IEEE double-precision format, added more precision to the extended
  46.  * conversions, and accommodated conversions involving +/- infinity,
  47.  * NaN's, and denormalized numbers.
  48.  *
  49.  * $Id: portableio.h,v 2.6 1991/04/30 17:06:02 malcolm Exp $
  50.  *
  51.  * $Log: portableio.h,v $
  52.  * Revision 2.6  91/04/30  17:06:02  malcolm
  53.  */
  54.  
  55. #include    <stdio.h>
  56. #include    "ieeefloat.h"
  57.  
  58. #ifndef    __cplusplus
  59. # define    CLINK    
  60. #else
  61. # define    CLINK "C"
  62. #endif
  63.  
  64. extern CLINK int ReadByte(FILE *fp);
  65. extern CLINK int Read16BitsLowHigh(FILE *fp);
  66. extern CLINK int Read16BitsHighLow(FILE *fp);
  67. extern CLINK void Write8Bits(FILE *fp, int i);
  68. extern CLINK void Write16BitsLowHigh(FILE *fp, int i);
  69. extern CLINK void Write16BitsHighLow(FILE *fp, int i);
  70. extern CLINK int Read24BitsHighLow(FILE *fp);
  71. extern CLINK int Read32Bits(FILE *fp);
  72. extern CLINK int Read32BitsHighLow(FILE *fp);
  73. extern CLINK void Write32Bits(FILE *fp, int i);
  74. extern CLINK void Write32BitsLowHigh(FILE *fp, int i);
  75. extern CLINK void Write32BitsHighLow(FILE *fp, int i);
  76. extern CLINK void ReadBytes(FILE *fp, char *p, int n);
  77. extern CLINK void ReadBytesSwapped(FILE *fp, char *p, int n);
  78. extern CLINK void WriteBytes(FILE *fp, char *p, int n);
  79. extern CLINK void WriteBytesSwapped(FILE *fp, char *p, int n);
  80. extern CLINK defdouble ReadIeeeFloatHighLow(FILE *fp);
  81. extern CLINK defdouble ReadIeeeFloatLowHigh(FILE *fp);
  82. extern CLINK defdouble ReadIeeeDoubleHighLow(FILE *fp);
  83. extern CLINK defdouble ReadIeeeDoubleLowHigh(FILE *fp);
  84. extern CLINK defdouble ReadIeeeExtendedHighLow(FILE *fp);
  85. extern CLINK defdouble ReadIeeeExtendedLowHigh(FILE *fp);
  86. extern CLINK void WriteIeeeFloatLowHigh(FILE *fp, defdouble num);
  87. extern CLINK void WriteIeeeFloatHighLow(FILE *fp, defdouble num);
  88. extern CLINK void WriteIeeeDoubleLowHigh(FILE *fp, defdouble num);
  89. extern CLINK void WriteIeeeDoubleHighLow(FILE *fp, defdouble num);
  90. extern CLINK void WriteIeeeExtendedLowHigh(FILE *fp, defdouble num);
  91. extern CLINK void WriteIeeeExtendedHighLow(FILE *fp, defdouble num);
  92.  
  93. #define    Read32BitsLowHigh(f)    Read32Bits(f)
  94. #define WriteString(f,s)    fwrite(s,strlen(s),sizeof(char),f)
  95. #endif
  96.