home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume26 / mytinfo / part01 / fake_stdio.h < prev    next >
C/C++ Source or Header  |  1992-12-26  |  1KB  |  66 lines

  1. /*
  2.  * fake_stdio.h
  3.  *
  4.  * By Ross Ridge
  5.  * Public Domain
  6.  * 92/02/01 07:29:53
  7.  *
  8.  * A fake stdio.h for a fake stdio (read only)
  9.  *
  10.  * @(#) mytinfo fake_stdio.h 3.2 92/02/01 public domain, By Ross Ridge
  11.  */
  12.  
  13. #ifndef _FAKE_STDIO_H_
  14.  
  15. #define _FAKE_STDIO_H_
  16.  
  17. #if 1
  18. #define getc _fake_getc
  19. #define fgetc _fake_fgetc
  20. #define fgets _fake_fgets
  21. #define fclose _fake_fclose
  22. #define _fillbuf _fake_fillbuf
  23. #define ungetc _fake_ungetc
  24. #define fopen _fake_fopen
  25. #define fdopen _fake_fdopen
  26. #endif
  27.  
  28. #define FILES    5
  29. #define FAKE_BUF_SIZE    512
  30.  
  31. struct _fake_file {
  32.     char *pos;
  33.     char *end;
  34.     int fd;
  35.     char buf[FAKE_BUF_SIZE];
  36. };
  37.  
  38. #undef FILE
  39. #define FILE struct _fake_file
  40. #undef EOF
  41. #define EOF (-1)
  42.  
  43. #define _fake_getc(f) ((f)->pos >= (f)->end ? _fillbuf(f) : *((f)->pos)++)
  44. #define _fake_fclose(f) (close((f)->fd) == -1 ? EOF : ((f)->fd = -1, 0))
  45. #define _fake_ungetc(c, f) ((f)->pos > (f)->buf ? (*--((f)->pos) = c) : EOF)
  46.  
  47. #ifdef USE_PROTOYPES
  48. int fgetc(FILE *);
  49. int _fillbuf(FILE *);
  50. char *fgets(char *, int, FILE *);
  51. FILE *fopen(char *, char *);
  52. FILE *fdopen(int, char *);
  53. #else
  54. int fgetc();
  55. int _fillbuf();
  56. char *fgets();
  57. FILE *fopen();
  58. FILE *fdopen();
  59. #endif
  60.  
  61. #if !defined(NULL) && !defined(USE_STRINGS)
  62. #define NULL ((anyptr) 0)
  63. #endif
  64.  
  65. #endif /* !_FAKE_STDIO_H_ */
  66.