3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
21 #include <sys/types.h>
29 int filelength(int fd)
33 cur_pos = lseek(fd, 0, SEEK_CUR);
34 lseek(fd, 0, SEEK_END);
35 end_pos = lseek(fd, 0, SEEK_CUR);
36 lseek(fd, cur_pos, SEEK_SET);
40 byte file_read_byte(FILE *fp)
44 if (fread(&b, 1, 1, fp) != 1)
45 Error("Error reading byte in file_read_byte()");
49 short file_read_short(FILE *fp)
53 if (fread(&s, 2, 1, fp) != 1)
54 Error("Error reading short in file_read_short()");
55 return INTEL_SHORT(s);
58 int file_read_int(FILE *fp)
62 if (fread(&i, 4, 1, fp) != 1)
63 Error("Error reading int in file_read_int()");
67 fix file_read_fix(FILE *fp)
71 if (fread(&f, 4, 1, fp) != 1)
72 Error("Error reading fix in file_read_fix()");
76 int file_write_byte(FILE *fp, byte b)
78 return (fwrite(&b, 1, 1, fp));
81 int file_write_short(FILE *fp, short s)
84 return (fwrite(&s, 2, 1, fp));
87 int file_write_int(FILE *fp, int i)
90 return (fwrite(&i, 4, 1, fp));
93 int write_fix_swap(FILE *fp, fix f)
95 f = (fix)INTEL_INT((int)f);
96 return (fwrite(&f, 4, 1, fp));