portableio.h

Go to the documentation of this file.
00001 #ifndef LAME_PORTABLEIO_H
00002 #define LAME_PORTABLEIO_H
00003 /* Copyright (C) 1988-1991 Apple Computer, Inc.
00004  * All Rights Reserved.
00005  *
00006  * Warranty Information
00007  * Even though Apple has reviewed this software, Apple makes no warranty
00008  * or representation, either express or implied, with respect to this
00009  * software, its quality, accuracy, merchantability, or fitness for a 
00010  * particular purpose.  As a result, this software is provided "as is,"
00011  * and you, its user, are assuming the entire risk as to its quality
00012  * and accuracy.
00013  *
00014  * This code may be used and freely distributed as long as it includes
00015  * this copyright notice and the warranty information.
00016  *
00017  * Machine-independent I/O routines for 8-, 16-, 24-, and 32-bit integers.
00018  *
00019  * Motorola processors (Macintosh, Sun, Sparc, MIPS, etc)
00020  * pack bytes from high to low (they are big-endian).
00021  * Use the HighLow routines to match the native format
00022  * of these machines.
00023  *
00024  * Intel-like machines (PCs, Sequent)
00025  * pack bytes from low to high (the are little-endian).
00026  * Use the LowHigh routines to match the native format
00027  * of these machines.
00028  *
00029  * These routines have been tested on the following machines:
00030  *      Apple Macintosh, MPW 3.1 C compiler
00031  *      Apple Macintosh, THINK C compiler
00032  *      Silicon Graphics IRIS, MIPS compiler
00033  *      Cray X/MP and Y/MP
00034  *      Digital Equipment VAX
00035  *
00036  *
00037  * Implemented by Malcolm Slaney and Ken Turkowski.
00038  *
00039  * Malcolm Slaney contributions during 1988-1990 include big- and little-
00040  * endian file I/O, conversion to and from Motorola's extended 80-bit
00041  * floating-point format, and conversions to and from IEEE single-
00042  * precision floating-point format.
00043  *
00044  * In 1991, Ken Turkowski implemented the conversions to and from
00045  * IEEE double-precision format, added more precision to the extended
00046  * conversions, and accommodated conversions involving +/- infinity,
00047  * NaN's, and denormalized numbers.
00048  *
00049  * $Id: portableio.h,v 1.4 2005/11/01 13:01:57 robert Exp $
00050  */
00051 
00052 #include        <stdio.h>
00053 
00054 #ifndef __cplusplus
00055 # define        CLINK
00056 #else
00057 # define        CLINK "C"
00058 #endif
00059 
00060 extern CLINK int ReadByte(FILE * fp);
00061 extern CLINK int Read16BitsLowHigh(FILE * fp);
00062 extern CLINK int Read16BitsHighLow(FILE * fp);
00063 extern CLINK void Write8Bits(FILE * fp, int i);
00064 extern CLINK void Write16BitsLowHigh(FILE * fp, int i);
00065 extern CLINK void Write16BitsHighLow(FILE * fp, int i);
00066 extern CLINK int Read24BitsHighLow(FILE * fp);
00067 extern CLINK int Read32Bits(FILE * fp);
00068 extern CLINK int Read32BitsHighLow(FILE * fp);
00069 extern CLINK void Write32Bits(FILE * fp, int i);
00070 extern CLINK void Write32BitsLowHigh(FILE * fp, int i);
00071 extern CLINK void Write32BitsHighLow(FILE * fp, int i);
00072 extern CLINK void ReadBytes(FILE * fp, char *p, int n);
00073 extern CLINK void ReadBytesSwapped(FILE * fp, char *p, int n);
00074 extern CLINK void WriteBytes(FILE * fp, char *p, int n);
00075 extern CLINK void WriteBytesSwapped(FILE * fp, char *p, int n);
00076 extern CLINK double ReadIeeeFloatHighLow(FILE * fp);
00077 extern CLINK double ReadIeeeFloatLowHigh(FILE * fp);
00078 extern CLINK double ReadIeeeDoubleHighLow(FILE * fp);
00079 extern CLINK double ReadIeeeDoubleLowHigh(FILE * fp);
00080 extern CLINK double ReadIeeeExtendedHighLow(FILE * fp);
00081 extern CLINK double ReadIeeeExtendedLowHigh(FILE * fp);
00082 extern CLINK void WriteIeeeFloatLowHigh(FILE * fp, double num);
00083 extern CLINK void WriteIeeeFloatHighLow(FILE * fp, double num);
00084 extern CLINK void WriteIeeeDoubleLowHigh(FILE * fp, double num);
00085 extern CLINK void WriteIeeeDoubleHighLow(FILE * fp, double num);
00086 extern CLINK void WriteIeeeExtendedLowHigh(FILE * fp, double num);
00087 extern CLINK void WriteIeeeExtendedHighLow(FILE * fp, double num);
00088 
00089 #define Read32BitsLowHigh(f)    Read32Bits(f)
00090 #define WriteString(f,s)        fwrite(s,strlen(s),sizeof(char),f)
00091 #endif

Generated on Sun Dec 2 11:34:18 2007 for LAME by  doxygen 1.5.2