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 
58 struct _pcp_stream_t {
59  FILE *fd;
60  Buffer *b;
61  uint8_t is_buffer;
62  uint8_t eof;
63  uint8_t err;
64 };
65 
67 typedef struct _pcp_stream_t Pcpstream;
68 
69 /* initialize a new empty stream */
70 Pcpstream *ps_init(void);
71 
80 Pcpstream *ps_new_file(FILE *backendfd);
81 
91 
100 
101 
122 size_t ps_read(Pcpstream *stream, void *buf, size_t readbytes);
123 
139 size_t ps_write(Pcpstream *stream, void *buf, size_t writebytes);
140 
156 size_t ps_print(Pcpstream *stream, const char * fmt, ...);
157 
167 size_t ps_tell(Pcpstream *stream);
168 
180 Buffer *ps_buffer(Pcpstream *stream);
181 
191 void ps_close(Pcpstream *stream);
192 
204 int ps_end(Pcpstream *stream);
205 
212 int ps_err(Pcpstream *stream);
213 
214 
215 #endif // HAVE_PCP_PCPSTEAM_H
216 
217