home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / src / baseline / jove-4.14.6.lha / jove-4.14.6 / fp.h < prev    next >
C/C++ Source or Header  |  1992-01-10  |  2KB  |  75 lines

  1. /***************************************************************************
  2.  * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
  3.  * is 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. extern void    jputchar proto((int c));    /* hidden by macro */
  9.  
  10. #define jputchar(c)    jputc((c), stdout)
  11. #define jputc(c, fp)    { while (--(fp)->f_cnt < 0) flushout(fp); *(fp)->f_ptr++ = (c); }
  12. #define jgetc(fp)    \
  13.     (((--(fp)->f_cnt < 0) ? filbuf(fp) : (unsigned char) *(fp)->f_ptr++))
  14. #define f_eof(fp)    ((fp)->f_flags & F_EOF)
  15.  
  16. typedef struct FileStruct {
  17.     int    f_cnt,        /* number of characters left in buffer */
  18.         f_bufsize,    /* size of what f_base points to */
  19.         f_fd,        /* fildes */
  20.         f_flags;    /* various flags */
  21.     char    *f_ptr,        /* current offset */
  22.         *f_base;    /* pointer to base */
  23.     char    *f_name;    /* name of open file */
  24. } File;
  25.  
  26. #define F_READ        01
  27. #define F_WRITE        02
  28. #define F_APPEND    04
  29. #define F_MODE(x)    ((x)&07)
  30. #define F_EOF        010
  31. #define F_STRING    020
  32. #define F_ERR        040
  33. #define F_LOCKED    0100    /* don't close this file upon error */
  34. #define F_MYBUF        0200    /* f_alloc allocated the buffer, so
  35.                    f_close knows to free it up */
  36. #define F_TELLALL    0400    /* whether to display info upon close */
  37. #define F_READONLY    01000    /* file is read only */
  38.  
  39. extern long    io_chars;
  40. extern int    io_lines;
  41.  
  42. extern File
  43.     *stdout;
  44.  
  45. #ifdef    VMUNIX
  46. # define MAXTTYBUF    2048
  47. #else
  48. # define MAXTTYBUF    512
  49. #endif
  50.  
  51. extern int    BufSize;
  52.  
  53. extern File
  54.     *f_open proto((char *name,int flags,char *buffer,int buf_size)),
  55.     *fd_open proto((char *name,int flags,int fd,char *buffer,int bsize));
  56.  
  57. extern int
  58.     filbuf proto((File *fp));
  59.  
  60. extern size_t
  61.     f_readn proto((File *fp,char *addr,size_t n));
  62.  
  63. extern void
  64.     f_close proto((File *fp)),
  65.     f_seek proto((File *fp, off_t offset)),
  66.     f_toNL proto((File *fp)),
  67.     flushout proto((File *fp)),
  68.     flushscreen proto((void)),
  69.     fputnchar proto((char *s,int n,File *fp)),
  70.     gc_openfiles proto((void)),
  71.     putstr proto((char *s));
  72.  
  73. extern bool
  74.     f_gets proto((File *fp,char *buf,size_t max));
  75.