Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 47 lines (41 sloc) 1.773 kB
69d4044 @mbsmith Added modelines to source files.
mbsmith authored
1 /* vim: set expandtab ts=4 sw=4: */
9aa22fe Offered permission to copy under gplv3 license.
cjdelisle authored
2 /*
3 * You may redistribute this program and/or modify it under the terms of
4 * the GNU General Public License as published by the Free Software Foundation,
5 * either version 3 of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
547f4a3 Cleaned up a bunch of files, added a codestyle validator and some inf…
cjdelisle authored
15 #ifndef Writer_H
16 #define Writer_H
d475c9c First commit for cjdns.
cjdelisle authored
17
18 /* size_t */
19 #include <stdlib.h>
20 /* uint64_t */
21 #include <stdint.h>
22
23 /**
24 * Writer interface which writes data to a destination and fails safe rather than overflowing.
25 */
26 struct Writer {
27 /** The internal state of the Writer. */
28 void* const context;
29
30 /**
31 * Write some content from a buffer or other source.
32 *
33 * @param toWrite a pointer to a memory location where content will be sourced from.
34 * @param length the number of bytes to write.
35 * @param this the Writer which is being called. Use: writer->write(X, Y, writer);
36 * @return 0 if write went well, -1 if there is no more space to write.
37 * if a write fails then all subsequent writes will fail with the same error
38 * so writing a large piece of content then a small footer does not require
39 * checking if the content wrote correctly before writing the footer.
40 */
92142dd Random stuff needed to get tinystore working.
cjdelisle authored
41 int (* const write)(const void* toWrite, size_t length, const struct Writer* this);
d475c9c First commit for cjdns.
cjdelisle authored
42
92142dd Random stuff needed to get tinystore working.
cjdelisle authored
43 uint64_t (* const bytesWritten)(const struct Writer* writer);
d475c9c First commit for cjdns.
cjdelisle authored
44 };
45
46 #endif
Something went wrong with that request. Please try again.