home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / jove-4.16-src.tgz / tar.out / bsd / jove / fp.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  94 lines

  1. /************************************************************************
  2.  * This program is Copyright (C) 1986-1996 by Jonathan Payne.  JOVE is  *
  3.  * provided to you without charge, and with no warranty.  You may give  *
  4.  * away copies of JOVE, including sources, provided that this notice is *
  5.  * included in all the files.                                           *
  6.  ************************************************************************/
  7.  
  8. #ifdef NO_JSTDOUT
  9. extern void    scr_putchar proto((char c));    /* defined in win32.c */
  10. # ifdef IBMPCDOS
  11. #  define flushscreen()    { }
  12. # else /* !IBMPCDOS */
  13. extern void flushscreen proto((void));
  14. # endif /* !IBMPCDOS */
  15. #else /* !NO_JSTDOUT */
  16. extern File    *jstdout;
  17. # define scr_putchar(c)    f_putc((c), jstdout)
  18. extern void        flushscreen proto((void));
  19. # ifndef SMALL
  20. #  define MAXTTYBUF    2048
  21. # else
  22. #  define MAXTTYBUF    512
  23. # endif
  24. #endif /* !NO_JSTDOUT */
  25.  
  26.  
  27. #define f_putc(c, fp)    { while (--(fp)->f_cnt < 0) flushout(fp); *(fp)->f_ptr++ = (c); }
  28. #define f_getc(fp)    \
  29.     ((--(fp)->f_cnt < 0) ? f_filbuf(fp) : ZXRC(*(fp)->f_ptr++))
  30. #define f_eof(fp)    (((fp)->f_flags & F_EOF) != 0)
  31.  
  32. /* typedef struct FileStruct File in jove.h */
  33.  
  34. struct FileStruct {
  35.     int    f_cnt,        /* number of characters left in buffer */
  36.         f_bufsize,    /* size of what f_base points to */
  37.         f_fd,        /* fildes */
  38.         f_flags;    /* various flags */
  39.     char    *f_ptr,        /* current offset */
  40.         *f_base;    /* pointer to base */
  41.     char    *f_name;    /* name of open file */
  42. };
  43.  
  44. #define F_READ        01
  45. #define F_WRITE        02
  46. #define F_APPEND    04
  47. #define F_MODE(x)    ((x)&07)
  48. #define F_EOF        010
  49. #define F_STRING    020
  50. #define F_ERR        040
  51. #define F_LOCKED    0100    /* don't close this file upon error */
  52. #define F_MYBUF        0200    /* f_alloc allocated the buffer, so
  53.                    f_close knows to free it up */
  54. #define F_TELLALL    0400    /* whether to display info upon close */
  55. #define F_READONLY    01000    /* file is read only */
  56.  
  57. /* ScrBufSize is the size of the buffer for jstdout.  It is also the
  58.  * number of characters to be output between checks for input, so
  59.  * it is meaningful even if jstdout isn't used.  Its value is set by
  60.  * settout based on the baud rate of output (on systems with baud rates).
  61.  */
  62. extern int    ScrBufSize;
  63.  
  64. extern File
  65.     *f_open proto((char *name,int flags,char *buffer,int buf_size)),
  66.     *fd_open proto((char *name,int flags,int fd,char *buffer,int bsize));
  67.  
  68. extern int
  69.     f_filbuf proto((File *fp));
  70.  
  71. #ifdef PIPEPROCS
  72. extern size_t
  73.     f_readn proto((File *fp,char *addr,size_t n));
  74. #endif
  75.  
  76. #if defined(ZTCDOS) || defined(__BORLANDC__)
  77. /* POSIX <sys/types.h> defines this as some signed arithmetic type
  78.  * suitable for holding file sizes.
  79.  */
  80. typedef long    off_t;
  81. #endif
  82.  
  83. extern void
  84.     f_close proto((File *fp)),
  85.     f_seek proto((File *fp, off_t offset)),
  86.     f_toNL proto((File *fp)),
  87.     flushout proto((File *fp)),
  88.     fputnchar proto((char *s,int n,File *fp)),
  89.     gc_openfiles proto((void)),
  90.     putstr proto((const char *s));
  91.  
  92. extern bool
  93.     f_gets proto((File *fp,char *buf,size_t max));
  94.