Category : C Source Code
Archive   : GHSTSCPT.ZIP
Filename : STREAM.H

 
Output of file : STREAM.H contained in archive : GHSTSCPT.ZIP
/* Copyright (C) 1989 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.

This file is part of Ghostscript.

Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.

Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
copies. */

/* stream.h */
/* Definitions for standard stream package for GhostScript */
/* Any place that uses stream.h must also include stdio.h. */

/* Note that the stream package works with bytes, not chars. */
/* This is to ensure unsigned representation on all systems. */
/* A stream can only be read or written, not both. */
/* Note also that the read procedure returns an int, */
/* not a char or a byte, because EOFC is -1. */
typedef struct stream_s stream;
struct stream_s {
byte *ptr; /* current pointer */
uint cnt; /* byte count for reading */
byte *buf; /* base of buffer */
uint bsize; /* size of buffer */
char writing; /* 0 if reading, 1 if writing */
char eof; /* non-zero if at EOF when buffer */
/* becomes empty */
long position; /* file position of beginning of */
/* buffer, -1 means not seekable */
FILE *file; /* file handle for C library */
int (*rproc)(P1(stream *)); /* read procedure */
int (*wproc)(P2(byte, stream *)); /* write procedure */
int (*sproc)(P2(stream *, long)); /* seek procedure */
int (*flproc)(P1(stream *)); /* flush procedure */
int (*clproc)(P1(stream *)); /* close procedure */
};

/* Stream functions. Some of these are macros -- beware. */
/* Note that there is no eof test -- instead, do a sgetc, */
/* compare against EOFC, and then do sputback if not at eof. */

/* Following are valid for all streams. */
#define sseekable(s) ((s)->position >= 0)

/* Following are only valid for read streams. */
#define sgetc(s)\
((s)->cnt-->0 ? *(s)->ptr++ : (*(s)->rproc)(s))
extern uint sgets(P3(byte *, uint, stream *));
#define sputback(s) ((s)->cnt++, (s)->ptr--)

/* Following are only valid for write streams. */
#define sputc(c,s)\
((s)->cnt-->0 ? ((int)(*(s)->ptr++=(c))) : (*(s)->wproc)((c),(s)))
extern uint sputs(P3(byte *, uint, stream *));

/* Following are only valid for positionable streams. */
#define stell(s) ((s)->ptr - (s)->buf + (s)->position)
#define sseek(s,pos) (*(s)->sproc)(s,(long)(pos))

/* Following are only valid for file streams (read or write). */
#define sflush(s) (*(s)->flproc)(s)
#define sclose(s) (*(s)->clproc)(s)

#define EOFC (-1)

/* Stream creation procedures */
extern void sread_string(P3(stream *, byte *, uint)),
swrite_string(P3(stream *, byte *, uint)),
sread_file(P4(stream *, FILE *, byte *, uint)),
swrite_file(P4(stream *, FILE *, byte *, uint));


  3 Responses to “Category : C Source Code
Archive   : GHSTSCPT.ZIP
Filename : STREAM.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/