/usr/include/snacc/c/exp-buf.h is in libsnacc-dev 1.3.1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | /*
* exp_buf.h - read/write/alloc/free routines for a simple buffer structure
*
* MACROS are gross but execution speed is important
*
* NOTE: replacing the malloc and free with a allocs/frees
* from/to buffer pools or similar tuned/fixed size
* mem mgmt will improve performance.
*
* You should tune the buffer management to your environment
* for best results
*
* MS 91
* Copyright (C) 1992 Michael Sample and the University of British Columbia
*
* This library is free software; you can redistribute it and/or
* modify it provided that this copyright/license information is retained
* in original form.
*
* If you modify this file, you must clearly indicate your changes.
*
* This source code is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Header: /usr/app/odstb/CVS/snacc/c-lib/inc/exp-buf.h,v 1.2 1995/07/27 08:54:45 rj Exp $
* $Log: exp-buf.h,v $
* Revision 1.2 1995/07/27 08:54:45 rj
* functions used by gen-bufs or type tables merged.
*
* changed `_' to `-' in file names.
*
* Revision 1.1 1994/08/28 09:21:40 rj
* first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
*
*/
#ifndef _exp_buf_h_
#define _exp_buf_h_
typedef struct ExpBuf
{
char *dataStart; /* points to first valid data byte */
/* when empty, 1 byte past blk end (rvs write)*/
char *dataEnd; /* pts to first byte AFTER last valid data byte*/
char *curr; /* current location to read form */
/* points to next byte to read */
struct ExpBuf *next; /* next buf (NULL if no next buffer)*/
struct ExpBuf *prev; /* prev buf (NULL if no prev buffer)*/
char *blkStart; /* points to first byte of the blk */
char *blkEnd; /* points the first byte AFTER blks last byte */
int readError; /* non-zero is attempt to read past end of data*/
int writeError;/* non-zero is attempt write fails (no mor bufs)*/
} ExpBuf;
/* init, alloc and free routines */
#if defined (DEBUG) /* use fcns when debugging/macros later */ || defined (USE_GEN_BUF)
#ifdef USE_GEN_BUF
void PutExpBufInGenBuf PROTO ((ExpBuf *eb,GenBuf *gb));
#endif
void ExpBufInit PROTO ((unsigned long dataBlkSize));
ExpBuf *ExpBufAllocBuf();
void ExpBufFreeBuf PROTO ((ExpBuf *ptr));
char *ExpBufAllocData();
void ExpBufFreeData PROTO ((char *ptr));
void ExpBufFreeBufAndData PROTO (( ExpBuf *b));
ExpBuf *ExpBufNext PROTO ((ExpBuf *b));
ExpBuf *ExpBufPrev PROTO ((ExpBuf *b));
void ExpBufResetInReadMode PROTO ((ExpBuf *b));
void ExpBufResetInWriteRvsMode PROTO ((ExpBuf *b));
int ExpBufAtEod PROTO ((ExpBuf *b));
int ExpBufFull PROTO ((ExpBuf *b));
int ExpBufHasNoData PROTO ((ExpBuf *b));
unsigned long ExpBufDataSize PROTO ((ExpBuf *b));
unsigned long ExpBufDataBlkSize PROTO ((ExpBuf *b));
char *ExpBufDataPtr PROTO ((ExpBuf *b));
#else
extern unsigned long expBufDataBlkSizeG;
#define ExpBufInit( size) expBufDataBlkSizeG = size;
#define ExpBufAllocBuf() ((ExpBuf *)malloc (sizeof (ExpBuf)))
#define ExpBufFreeBuf( ptr) free (ptr)
#define ExpBufAllocData() ((void *)malloc (expBufDataBlkSizeG))
#define ExpBufFreeData( ptr) free (ptr)
#define ExpBufFreeBufAndData( b) { ExpBufFreeData ((b)->blkStart); ExpBufFreeBuf (b); }
#define ExpBufNext( b) ((b)->next)
#define ExpBufPrev( b) ((b)->prev)
#define ExpBufResetInReadMode( b) { (b)->curr = (b)->dataStart; (b)->readError = 0; (b)->writeError = 1; }
#define ExpBufResetInWriteRvsMode( b) { (b)->dataStart = (b)->dataEnd = (b)->blkEnd; (b)->writeError = 0; (b)->readError = 1; }
/* ExpBufAtEod only valid during reads (fwd) */
#define ExpBufAtEod( b) ((b)->curr == (b)->dataEnd)
/* ExpBufFull only valid during write (reverse) */
#define ExpBufFull( b) ((b)->dataStart == (b)->blkStart)
#define ExpBufHasNoData( b) ((b)->dataStart == (b)->dataEnd)
#define ExpBufDataSize( b) ((b)->dataEnd - (b)->dataStart)
#define ExpBufDataBlkSize( b) ((b)->blkEnd - (b)->blkStart)
#define ExpBufDataPtr( b) (ExpBufHasNoData (b)? NULL: (b)->dataStart)
#endif /* DEBUG || USE_GEN_BUF */
#ifdef USE_GEN_BUF
int ExpBufReadError PROTO ((ExpBuf **b));
int ExpBufWriteError PROTO ((ExpBuf **b));
#else
#define ExpBufReadError( b) ((*b)->readError)
#define ExpBufWriteError( b) ((*b)->writeError)
#endif
ExpBuf *ExpBufAllocBufAndData PROTO ((void));
void ExpBufInstallDataInBuf PROTO ((ExpBuf *b, char *data, unsigned long int len));
void ExpBufFreeBufAndDataList PROTO (( ExpBuf *b));
ExpBuf *ExpBufListLastBuf PROTO ((ExpBuf *b));
ExpBuf *ExpBufListFirstBuf PROTO ((ExpBuf *b));
void ExpBufCopyToFile PROTO ((ExpBuf *b, FILE *f));
/* reading and writing routines */
void ExpBufSkip PROTO (( ExpBuf**, unsigned long len));
int ExpBufCopy PROTO (( char *dst, ExpBuf **b, unsigned long len));
unsigned char ExpBufPeekByte PROTO (( ExpBuf **b));
#if TTBL
int ExpBufPeekCopy PROTO ((char *dst, ExpBuf **b, unsigned long len));
char *ExpBufPeekSeg PROTO ((ExpBuf **b, unsigned long *len));
#endif
char *ExpBufGetSeg PROTO ((ExpBuf **b, unsigned long *len));
void ExpBufPutSegRvs PROTO ((ExpBuf **b, char *data, unsigned long len));
unsigned char ExpBufGetByte PROTO ((ExpBuf **b));
void ExpBufPutByteRvs PROTO ((ExpBuf **b, unsigned char byte));
#endif /* conditional include */
|