DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦b42147cf4⟧ TextFile

    Length: 3310 (0xcee)
    Types: TextFile
    Names: »stream.h«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« 
        └─⟦a24a58cd3⟧ 
            └─⟦this⟧ »stream.h« 

TextFile

/* 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));