libpcp  0.2.1
pcpstream.h
1 /*
2  This file is part of Pretty Curved Privacy (pcp1).
3 
4  Copyright (C) 2013-2014 T.v.Dein.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19  You can contact me by mail: <tom AT vondein DOT org>.
20 */
21 
22 #ifndef HAVE_PCP_PCPSTEAM_H
23 #define HAVE_PCP_PCPSTEAM_H
24 
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include "mem.h"
28 #include "util.h"
29 #include "defines.h"
30 #include "buffer.h"
31 
54 struct _pcp_stream_t {
55  FILE *fd;
56  Buffer *b;
57  uint8_t is_buffer;
58  uint8_t eof;
59  uint8_t err;
60 };
61 
63 typedef struct _pcp_stream_t Pcpstream;
64 
65 /* initialize a new empty stream */
66 Pcpstream *ps_init(void);
67 
76 Pcpstream *ps_new_file(FILE *backendfd);
77 
87 
96 
97 
118 size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes);
119 
135 size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes);
136 
152 size_t ps_print(Pcpstream *stream, const char * fmt, ...);
153 
163 size_t ps_tell(Pcpstream *stream);
164 
176 Buffer *ps_buffer(Pcpstream *stream);
177 
187 void ps_close(Pcpstream *stream);
188 
200 int ps_end(Pcpstream *stream);
201 
208 int ps_err(Pcpstream *stream);
209 
210 
211 #endif // HAVE_PCP_PCPSTEAM_H
212 
213