stream.h
2.75 KB
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
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009-2012, 2014-2016 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _MAILUTILS_SYS_STREAM_H
#define _MAILUTILS_SYS_STREAM_H
#define _MU_STR_OPEN 0x01000000 /* Stream open */
#define _MU_STR_DIRTY 0x02000000 /* Buffer dirty */
#define _MU_STR_WRT 0x04000000 /* Unflushed write pending */
#define _MU_STR_ERR 0x08000000 /* Permanent error state */
#define _MU_STR_EOF 0x10000000 /* EOF encountered */
#define _MU_STR_INTERN_MASK 0xff000000
#define _MU_STR_EVENT_SETFLAG 0
#define _MU_STR_EVENT_CLRFLAG 1
#define _MU_STR_EVENT_FILLBUF 2
#define _MU_STR_EVENT_FLUSHBUF 3
#define _MU_STR_EVENT_CLOSE 4
#define _MU_STR_EVENT_BOOTSTRAP 5
#define _MU_STR_EVMASK(n) (1<<(n))
struct _mu_stream
{
int ref_count;
enum mu_buffer_type buftype;
size_t bufsize;
char *buffer;
size_t level;
size_t pos;
int flags;
mu_off_t offset;
int statmask;
mu_off_t *statbuf;
int last_err;
int (*read) (struct _mu_stream *, char *, size_t, size_t *);
int (*readdelim) (struct _mu_stream *, char *, size_t, int, size_t *);
int (*write) (struct _mu_stream *, const char *, size_t, size_t *);
int (*flush) (struct _mu_stream *);
int (*open) (struct _mu_stream *);
int (*close) (struct _mu_stream *);
void (*done) (struct _mu_stream *);
void (*destroy) (struct _mu_stream *);
int (*seek) (struct _mu_stream *, mu_off_t, mu_off_t *);
int (*size) (struct _mu_stream *, mu_off_t *);
int (*ctl) (struct _mu_stream *, int, int, void *);
int (*wait) (struct _mu_stream *, int *, struct timeval *);
int (*truncate) (struct _mu_stream *, mu_off_t);
int (*shutdown) (struct _mu_stream *, int);
void (*event_cb) (struct _mu_stream *, int code, unsigned long, void *);
int event_mask;
void *event_cb_data;
int (*setbuf_hook) (mu_stream_t, enum mu_buffer_type, size_t);
const char *(*error_string) (struct _mu_stream *, int);
};
mu_stream_t _mu_stream_create (size_t size, int flags);
void _mu_stream_cleareof (mu_stream_t str);
void _mu_stream_seteof (mu_stream_t str);
#endif