summaryrefslogtreecommitdiffstats
path: root/src/sliding_buffer.h
blob: 34f156bbaf88bc695979aac9e956b85496a05d27 (plain)
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
/* --------------------------------------------------------------------------
 * Copyright 2003-2011 (inclusive) Nathan Angelacos 
 *                   (nangel@users.sourceforge.net)
 * 
 *   This file is part of haserl.
 *
 *   Haserl is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2,
 *   as published by the Free Software Foundation.
 *
 *   Haserl 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.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with haserl.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------------ */

#ifndef _SLIDING_BUF_H
#define _SLIDING_BUF_H	1


/* sliding buffer structure */
typedef struct {
	int		fh;			/* the input filehandle for the buffer */
	unsigned char	*buf;			/* pointer to the buffer  */
	unsigned char	*ptr;			/* start positon (used internally) */
	unsigned char	*segment;		/* the start position of this segment */ 
	size_t		len;			/* length of this segment */
	size_t		maxsize;		/* max size of buffer */
	size_t		bufsize;		/* current size of buffer */
	size_t		maxread;		/* maximum number of bytes to read from fh, ignored if 0 */
	size_t		nrread;			/* number of bytes read from fh */
	int		eof; 			/* true if there is no more to read */
	} sliding_buffer_t;



/* sliding_buffer.c */
int s_buffer_init(sliding_buffer_t *sbuf, int size);
void s_buffer_destroy(sliding_buffer_t *sbuf);
int s_buffer_read(sliding_buffer_t *sbuf, char *matchstr);


#endif /* !_SLIDING_BUF_H */