Annotation of src/usr.bin/make/buf.h, Revision 1.3
1.3 ! millert 1: /* $OpenBSD: buf.h,v 1.2 1996/06/26 05:36:26 deraadt Exp $ */
! 2: /* $NetBSD: buf.h,v 1.6 1996/11/06 17:59:00 christos Exp $ */
1.1 deraadt 3:
4: /*
5: * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
6: * Copyright (c) 1988, 1989 by Adam de Boor
7: * Copyright (c) 1989 by Berkeley Softworks
8: * All rights reserved.
9: *
10: * This code is derived from software contributed to Berkeley by
11: * Adam de Boor.
12: *
13: * Redistribution and use in source and binary forms, with or without
14: * modification, are permitted provided that the following conditions
15: * are met:
16: * 1. Redistributions of source code must retain the above copyright
17: * notice, this list of conditions and the following disclaimer.
18: * 2. Redistributions in binary form must reproduce the above copyright
19: * notice, this list of conditions and the following disclaimer in the
20: * documentation and/or other materials provided with the distribution.
21: * 3. All advertising materials mentioning features or use of this software
22: * must display the following acknowledgement:
23: * This product includes software developed by the University of
24: * California, Berkeley and its contributors.
25: * 4. Neither the name of the University nor the names of its contributors
26: * may be used to endorse or promote products derived from this software
27: * without specific prior written permission.
28: *
29: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39: * SUCH DAMAGE.
40: *
1.3 ! millert 41: * from: @(#)buf.h 8.1 (Berkeley) 6/6/93
1.1 deraadt 42: */
43:
44: /*-
45: * buf.h --
46: * Header for users of the buf library.
47: */
48:
49: #ifndef _BUF_H
50: #define _BUF_H
51:
52: #include "sprite.h"
53:
54: typedef char Byte;
55:
56: typedef struct Buffer {
57: int size; /* Current size of the buffer */
58: int left; /* Space left (== size - (inPtr - buffer)) */
59: Byte *buffer; /* The buffer itself */
60: Byte *inPtr; /* Place to write to */
61: Byte *outPtr; /* Place to read from */
62: } *Buffer;
63:
64: /* Buf_AddByte adds a single byte to a buffer. */
65: #define Buf_AddByte(bp, byte) \
66: (void) (--(bp)->left <= 0 ? Buf_OvAddByte(bp, byte), 1 : \
67: (*(bp)->inPtr++ = (byte), *(bp)->inPtr = 0), 1)
68:
69: #define BUF_ERROR 256
70:
71: void Buf_OvAddByte __P((Buffer, int));
1.3 ! millert 72: void Buf_AddBytes __P((Buffer, int, const Byte *));
1.1 deraadt 73: void Buf_UngetByte __P((Buffer, int));
74: void Buf_UngetBytes __P((Buffer, int, Byte *));
75: int Buf_GetByte __P((Buffer));
76: int Buf_GetBytes __P((Buffer, int, Byte *));
77: Byte *Buf_GetAll __P((Buffer, int *));
78: void Buf_Discard __P((Buffer, int));
79: int Buf_Size __P((Buffer));
80: Buffer Buf_Init __P((int));
81: void Buf_Destroy __P((Buffer, Boolean));
1.3 ! millert 82: void Buf_ReplaceLastByte __P((Buffer, Byte));
1.1 deraadt 83:
84: #endif /* _BUF_H */