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 - download
Index: ┃ T b

⟦ca60fb711⟧ TextFile

    Length: 2632 (0xa48)
    Types: TextFile
    Names: »bitio.h++«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/image/varc++/bitio.h++« 

TextFile

/* file:  bitio.h							*/

/* BFILE: include file for bit stream I/O.				*/
/* Bitio provides the capabilities to access unix files as arbitrary	*/
/*  bit streams. I/O is buffered on both reading and writing.		*/
/* Read, write, and read/write access is defined.			*/
/* Bit streams of upto the width in bits of a long integer may be read	*/
/*  and written with each access.					*/
/* CPU word and character boundaries are otherwise ignored.		*/
/* These routines are compatible with normal unix file access.		*/

/* Copyright (c) 1982,
   W. S. Havens,
   Laboratory for Computational Vision,
   University of British Columbia
*/

/* Modifications:
    original:						WSH 82/5/20
    added delayed filling of cache:			WSH 82/5/27
    change block size:					SJK 84/5/4
*/

#define		BBLKSZE	4096		/* # of bytes in bit cache	*/
#define		R	0		/* mode = read			*/
#define		W	1		/* mode = write			*/
#define		RW	2		/* mode = read/write		*/
#define		UBXBYTE	8		/* # of bits per byte		*/
#define		WRDSZE	UBXBYTE*sizeof(long)/* # of bits per long word	*/
#define		BEOF	001
#define		BRDERR	002
#define		BWRERR	004
#define		BSKERR	010
#define		NULL	0

/* flags:
  Bit	Indication
  ---	----------
   1	EOF during last read.
   2	read error occurred.
   3	write error occurred.
   4	seek error occurred.
*/

struct iff_bfile
 {int		file;			/* unix file descriptor		*/
  short		wpos;			/* location of bword in cache	*/
  short		bpos;			/* current low-order bit	*/
  short		nwrd;			/* # of bytes in cache		*/
  short		bmode;			/* access mode of file		*/
  short		flags;			/* EOF and ERROR flags		*/
  char		cache[BBLKSZE];		/* byte cache for stream        */	
  };

unsigned long	bseek(...);
struct iff_bfile		*bopen(...), *bdopen(...);
	       

/* Notes:
   ------
1) Beware of the odd bits !!

*/

/* Macros */

#define beof(bfp)	((bfp)->flags & BEOF)
#define berror(bfp)	((bfp)->flags & (BRDERR | BWRERR | BSKERR))
#define bget(bfp,n,signed)						\
  ((n)!=8 || (bfp)->bpos || (bfp)->wpos>=(bfp)->nwrd || (bfp)->bmode==W ?\
    fbget(bfp,n,signed) : 						\
      (signed) ?							\
	*(char *)((bfp)->cache+((bfp)->wpos++)) :			\
	*(unsigned char *)((bfp)->cache+((bfp)->wpos++)) )

#define bput(bfp,bits,n)						\
  ((n)!=8 || (bfp)->bpos || (bfp)->wpos>=BBLKSZE || (bfp)->bmode!=W ?	\
	fbput(bfp,bits,n) :						\
	(*(char *)(bfp->cache+bfp->wpos++) = bits))


/* end of file:  bitio.h */
/*
Copyright (C) 1986, David Sher in the University of Rochester
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as it is not sold for profit, provided
this copyright notice is retained.
*/