2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 * gen_buf.h - flexible (runtime configurable) buffer mgmt stuff.
22 * These are somewhat slower than the direct approach used in
23 * the compiled stuff. Since tables are around 4x slower,
24 * the flexibility of the GenBufs can be justified. This
25 * also allows one enc/dec library to support all buffer types.
29 * Copyright (C) 1993 Michael Sample
30 * and the University of British Columbia
32 * This library is free software; you can redistribute it and/or
33 * modify it provided that this copyright/license information is retained
36 * If you modify this file, you must clearly indicate your changes.
38 * This source code is distributed in the hope that it will be
39 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
40 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
49 * These are the standard buffer routines that the lib
50 * routines need. Note that the Peek routines have be
51 * added to the standard list - they are necessary
52 * to nicely support the table oriented decoder.
53 * The "void *b" param's real type will be the buffer
54 * type that is used inside the GenBuf
55 * (ie SBuf * or ExpBuf ** have been defined).
57 * Note that macros can not be used for these standard functions
58 * because the GenBuf keeps a pointer to these routines.
59 * Thus the exp_buf.[ch] and sbuf.[ch] files are somewhat
60 * differnt than those in snacc/c_lib and snacc/c_include
64 typedef unsigned char (*BufGetByteFcn
) PROTO ((void *b
));
65 typedef unsigned char *(*BufGetSegFcn
) PROTO ((void *b
, unsigned long int *lenPtr
));
66 typedef long int (*BufCopyFcn
) PROTO ((char *dst
, void *b
, unsigned long int len
));
67 typedef void (*BufSkipFcn
) PROTO ((void *b
, unsigned long int len
));
68 typedef unsigned char (*BufPeekByteFcn
) PROTO ((void *b
));
69 typedef unsigned char *(*BufPeekSegFcn
) PROTO ((void *b
, unsigned long int lenPtr
));
70 typedef long int (*BufPeekCopyFcn
) PROTO ((char *dst
, void *b
, unsigned long int len
));
71 typedef void (*BufPutByteRvsFcn
) PROTO ((void *b
, unsigned char byte
));
72 typedef void (*BufPutSegRvsFcn
) PROTO ((void *b
, char *data
, unsigned long int len
));
73 typedef int (*BufReadErrorFcn
) PROTO ((void *b
));
74 typedef int (*BufWriteErrorFcn
) PROTO ((void *b
));
79 BufGetByteFcn getByte
;
83 BufPeekByteFcn peekByte
;
84 BufPeekSegFcn peekSeg
;
85 BufPeekCopyFcn peekCopy
;
86 BufPutByteRvsFcn putByteRvs
;
87 BufPutSegRvsFcn putSegRvs
;
88 BufReadErrorFcn readError
;
89 BufWriteErrorFcn writeError
;
91 void *spare
; /* hack to save space for ExpBuf ** type */
95 #define GenBufGetByte( b) ((b)->getByte (b->bufInfo))
96 #define GenBufGetSeg( b, lenPtr) ((b)->getSeg (b->bufInfo, lenPtr))
97 #define GenBufCopy( dst, b, len) ((b)->copy (dst, b->bufInfo, len))
98 #define GenBufSkip( b, len) ((b)->skip (b->bufInfo,len))
99 #define GenBufPeekByte( b) ((b)->peekByte (b->bufInfo))
100 #define GenBufPeekSeg( b, lenPtr) ((b)->peekSeg (b->bufInfo, lenPtr))
101 #define GenBufPeekCopy( dst, b, len) ((b)->peekCopy (dst, b->bufInfo, len))
102 #define GenBufPutByteRvs( b, byte) ((b)->putByteRvs (b->bufInfo, byte))
103 #define GenBufPutSegRvs( b, data, len) ((b)->putSegRvs (b->bufInfo, data, len))
104 #define GenBufReadError( b) ((b)->readError (b->bufInfo))
105 #define GenBufWriteError( b) ((b)->writeError (b->bufInfo))
108 #endif /* _gen_buf_h_ conditional include */
110 #endif /* USE_GEN_BUF */