File: stream.h

package info (click to toggle)
penguin 19-3
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 2,468 kB
  • ctags: 2,393
  • sloc: ansic: 13,993; makefile: 134
file content (70 lines) | stat: -rw-r--r-- 2,169 bytes parent folder | download
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
/*
 * stream.h -- Stream definitions
 *
 * Copyright (c) 1997 by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file COPYING in the main directory of this archive
 * for more details.
 */

#ifndef _stream_h
#define _stream_h

typedef struct _module {
    /* data supplied by the module */
    char *name;							/* name of this module */
    long maxbuf;						/* max. bytes a fillbuf() call
										 * can return */
    /* methods */
    int (*open)( const char *name );	/* open the module */
    long (*fillbuf)( char *buf );		/* fill a buffer, max. maxbuf bytes
										 * returned */
    int (*skip)( long cnt );			/* skip data (for seek), optional,
										 * returns amount  skipped */
    int (*close)( void );				/* close the module */
    /* data maintained by general streams layer */
    char *buf;							/* current buffer */
    char *bufp;							/* pointer into buffer */
    long buf_cnt;						/* #chars left in buffer */
    long fpos;							/* position in stream */
    int eof;							/* EOF indicator */
	long last_shown;					/* last call of show_progress */
    /* links to neighbour modules */
    struct _module *down, *up;
} MODULE;

/* initializer for fields in MODULE not supplied by module */
#define MOD_REST_INIT								\
	NULL, NULL, 0, 0, 0, 0,	/* buffer data */		\
	NULL, NULL				/* down, up pointers */


/***************************** Prototypes *****************************/

void		stream_init( void );
void		stream_push( MODULE *mod );
int			sopen( const char *name );
long		sread( char *buf, long cnt );
int			sseek( long offset, int whence );
int			sclose( void );

/************************* End of Prototypes **************************/
    
/***************************** Modules ********************************/

/* file_mod.c */
extern MODULE	file_mod;

/* gunzip_mod.c */
extern MODULE	gunzip_mod;

/* bunzip2_mod.c */
extern MODULE	bunzip2_mod;

/*********************** End of Modules *******************************/
#endif  /* _stream_h */

/* Local Variables: */
/* tab-width: 4     */
/* End:             */