home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / pdc.lzh / File3 < prev    next >
Text File  |  1991-08-04  |  1KB  |  56 lines

  1. /*
  2.  * stdio.h
  3.  * PDC I/O Library Copyright (C) 1987 by J.A. Lydiatt.
  4.  * Freely Distributable for non-commercial use.
  5.  */
  6. /*
  7.  * I'll try to begin PD System variables with an '_'.
  8.  */
  9.  
  10. #ifndef _STDIO_H
  11. #  define _STDIO_H
  12. #  ifndef  NULL
  13. #    define NULL 0
  14. #  endif
  15. #  define EOF -1
  16.  
  17. #  define BUFSIZ 1024
  18. #  define MAXSTREAM 20
  19.  
  20. #  define _FILEACTIVE    0x01
  21. #  define _FILEISDYNA    0x02
  22. #  define _FILEISDIRTY     0x04
  23. #  define _FILEATEOF    0x08
  24. #  define _FILEBAD        0x10
  25. #  define _FILEISTTY    0x80
  26.  
  27.     typedef struct _fdevice {
  28.     struct _fdevice *next; /* pointer to the next table entry */
  29.     char *_filecpos;    /* Current position in the buffer */
  30.     char *_fileend;        /* one past last char in buffer */
  31.     char *_filebufp;    /* pointer to the buffer */
  32.     short _fileflag;    /* mode flags */
  33.     short _fileunit;    /* value returned by open */
  34.     char  _filebyte;    /* one byte used by unbuffered streams. */
  35.     short _filelen;        /* length of the buffer. */
  36.     }
  37.         FILE;
  38.  
  39.     extern FILE _fdevtab[];
  40.  
  41. #    define stdin        (&_fdevtab[0])
  42. #    define stdout        (&_fdevtab[1])
  43. #    define stderr        (&_fdevtab[2])
  44. #    define getchar()    getc(stdin)
  45. #    define fgetc(fp)    getc(fp)
  46. #    define putchar(c)    putc(c,stdout)
  47. #    define fputc(c,fp)    putc(c,fp)
  48. #    define feof(fp)        (((fp)->_fileflag & _FILEATEOF) != 0)
  49. #    define ferror(fp)    ((fp)->_fileflag & _FILEBAD) != 0)
  50. #    define clearerr(fp)    ((fp)->_fileflag &= ~(_FILEBAD|_FILEATEOF))
  51. #    define fileno(fp)    ((int)(fp)->_fileunit) 
  52. #    define fflush(fp)    _doflush(fp, -1)
  53. #    define rewind        fseek(fp, 0L, 0)
  54.  
  55. #endif
  56.