home *** CD-ROM | disk | FTP | other *** search
- /* Desperate patch to get things going */
-
- #pragma include_only_once
- #include <stdio.h>
- #include <string.h>
-
- /* Hope this is right */
- #define M_PI 3.14159267
-
-
- /* Also hope this guess is sufficiently educated */
- typedef unsigned char u_char;
- typedef unsigned short int u_short;
- typedef unsigned long int u_long;
-
- /* Again hope this works */
-
- #define O_RDONLY 1 /* Probably (nay, certainly) the wrong values */
- #define O_WRONLY 2
- #define O_CREAT 4
-
- int next_pfh=0;
- FILE * files_used[16];
-
- /* Prototype them (for completeness) */
- int read(int, void *, int);
- int write(int, void *, int);
- int open(char *, int, int);
- void close(int);
- double rint(double);
-
- double rint(double num)
- {
- return (double)(int)num;
- }
-
- int read(int pfh, void *ptd, int length)
- {
- return (int)fread(ptd,(size_t) 1, (size_t) length, files_used[pfh]);
- }
-
- int write(int pfh, void *ptd, int length)
- {
- return (int)fwrite(ptd,(size_t) 1, (size_t) length, files_used[pfh]);
- }
-
-
- /* Highly brain damaged */
- int open(char * filename, int flags, int permission)
- {
- char modestring[5]="";
- /* Ignore file access flags! */
- /* Build modestring */
- if (flags == O_WRONLY|O_CREAT)
- strcpy(modestring, "wb+");
- if (flags == O_RDONLY)
- strcpy(modestring, "rb");
-
- files_used[next_pfh] = fopen(filename, modestring);
- return next_pfh++; /* Finally a use for postfix ++ */
- }
-
- void close(int pfh)
- {
- fclose(files_used[pfh]);
- }
-