r1003: BlueDot theme is usable again thanks to Miha Kitic who finished off
[cinelerra_cv/mob.git] / toolame-02l / portableio.c
blob0310d8bcb081d0254cc0f2f71c038b2692b99270
1 /* Copyright (C) 1988-1991 Apple Computer, Inc.
2 * All Rights Reserved.
4 * Warranty Information
5 * Even though Apple has reviewed this software, Apple makes no warranty
6 * or representation, either express or implied, with respect to this
7 * software, its quality, accuracy, merchantability, or fitness for a
8 * particular purpose. As a result, this software is provided "as is,"
9 * and you, its user, are assuming the entire risk as to its quality
10 * and accuracy.
12 * This code may be used and freely distributed as long as it includes
13 * this copyright notice and the warranty information.
16 * Motorola processors (Macintosh, Sun, Sparc, MIPS, etc)
17 * pack bytes from high to low (they are big-endian).
18 * Use the HighLow routines to match the native format
19 * of these machines.
21 * Intel-like machines (PCs, Sequent)
22 * pack bytes from low to high (the are little-endian).
23 * Use the LowHigh routines to match the native format
24 * of these machines.
26 * These routines have been tested on the following machines:
27 * Apple Macintosh, MPW 3.1 C compiler
28 * Apple Macintosh, THINK C compiler
29 * Silicon Graphics IRIS, MIPS compiler
30 * Cray X/MP and Y/MP
31 * Digital Equipment VAX
34 * Implemented by Malcolm Slaney and Ken Turkowski.
36 * Malcolm Slaney contributions during 1988-1990 include big- and little-
37 * endian file I/O, conversion to and from Motorola's extended 80-bit
38 * FLOATing-point format, and conversions to and from IEEE single-
39 * precision FLOATing-point format.
41 * In 1991, Ken Turkowski implemented the conversions to and from
42 * IEEE double-precision format, added more precision to the extended
43 * conversions, and accommodated conversions involving +/- infinity,
44 * NaN's, and denormalized numbers.
46 * $Id: portableio.c,v 1.1 2003/10/04 00:11:19 herman Exp $
48 * $Log: portableio.c,v $
49 * Revision 1.1 2003/10/04 00:11:19 herman
50 * New file from 1.1.7 (not in 1.1.6) added from Rich's automakified src tree.
52 * Revision 1.1 2003/07/29 04:17:52 heroine
53 * *** empty log message ***
55 * Revision 2.6 91/04/30 17:06:02 malcolm
56 * Apr 2000
57 * MFC - hacked out everything we don't need for layer II
60 #include <stdio.h>
61 #include <math.h>
62 #include "portableio.h"
63 #include "common.h"
65 /****************************************************************
66 * Big/little-endian independent I/O routines.
67 ****************************************************************/
68 int Read16BitsHighLow (fp)
69 FILE *fp;
71 int first, second, result;
73 first = 0xff & getc (fp);
74 second = 0xff & getc (fp);
76 result = (first << 8) + second;
77 #ifndef THINK_C42
78 if (result & 0x8000)
79 result = result - 0x10000;
80 #endif /* THINK_C */
81 return (result);
84 double ReadIeeeExtendedHighLow (fp)
85 FILE *fp;
87 char bits[kExtendedLength];
89 ReadBytes (fp, bits, kExtendedLength);
90 return ConvertFromIeeeExtended (bits);
93 int Read32BitsHighLow (fp)
94 FILE *fp;
96 int first, second, result;
98 first = 0xffff & Read16BitsHighLow (fp);
99 second = 0xffff & Read16BitsHighLow (fp);
101 result = (first << 16) + second;
102 #ifdef CRAY
103 if (result & 0x80000000)
104 result = result - 0x100000000;
105 #endif
106 return (result);
109 void ReadBytes (fp, p, n)
110 FILE *fp;
111 char *p;
112 int n;
114 while (!feof (fp) & (n-- > 0))
115 *p++ = getc (fp);