home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / programming / stuff / BBCtape / h / patch
Encoding:
Text File  |  1997-01-26  |  1.5 KB  |  67 lines

  1. /* Desperate patch to get things going */
  2.  
  3. #pragma include_only_once
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. /* Hope this is right */
  8. #define M_PI 3.14159267
  9.  
  10.  
  11. /* Also hope this guess is sufficiently educated */
  12. typedef unsigned char u_char;
  13. typedef unsigned short int u_short;
  14. typedef unsigned long int u_long;
  15.  
  16. /* Again hope this works */
  17.  
  18. #define O_RDONLY 1    /* Probably (nay, certainly) the wrong values */
  19. #define O_WRONLY 2
  20. #define O_CREAT  4
  21.  
  22. int next_pfh=0;
  23. FILE * files_used[16];
  24.  
  25. /* Prototype them (for completeness) */
  26. int read(int, void *, int);
  27. int write(int, void *, int);
  28. int open(char *, int, int);
  29. void close(int);
  30. double rint(double);
  31.  
  32. double rint(double num)
  33.        {
  34.     return (double)(int)num;
  35.        }
  36.  
  37. int read(int pfh, void *ptd, int length)
  38.     {
  39.      return (int)fread(ptd,(size_t) 1, (size_t) length, files_used[pfh]); 
  40.     }
  41.  
  42. int write(int pfh, void *ptd, int length)
  43.     {
  44.      return (int)fwrite(ptd,(size_t) 1, (size_t) length, files_used[pfh]); 
  45.     }
  46.  
  47.  
  48. /* Highly brain damaged */
  49. int open(char * filename, int flags, int permission)
  50.     {
  51.      char modestring[5]="";
  52.      /* Ignore file access flags! */ 
  53.      /* Build modestring */
  54.      if (flags == O_WRONLY|O_CREAT)
  55.          strcpy(modestring, "wb+");
  56.      if (flags == O_RDONLY)
  57.          strcpy(modestring, "rb");
  58.       
  59.      files_used[next_pfh] = fopen(filename, modestring);
  60.      return next_pfh++;   /* Finally a use for postfix ++ */
  61.     }    
  62.  
  63. void close(int pfh)
  64.      {
  65.       fclose(files_used[pfh]); 
  66.      }
  67.