diff options
Diffstat (limited to 'lib/x1000-installer/include/xf_stream.h')
-rw-r--r-- | lib/x1000-installer/include/xf_stream.h | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/x1000-installer/include/xf_stream.h b/lib/x1000-installer/include/xf_stream.h deleted file mode 100644 index adbde1c6db..0000000000 --- a/lib/x1000-installer/include/xf_stream.h +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2021 Aidan MacDonald | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _XF_STREAM_H_ | ||
23 | #define _XF_STREAM_H_ | ||
24 | |||
25 | #include <stddef.h> | ||
26 | #include <stdint.h> | ||
27 | #include <sys/types.h> /* ssize_t */ | ||
28 | #include "microtar.h" | ||
29 | |||
30 | struct xf_stream; | ||
31 | |||
32 | struct xf_stream_ops { | ||
33 | off_t(*xget_size)(struct xf_stream* s); | ||
34 | ssize_t(*xread)(struct xf_stream* s, void* buf, size_t len); | ||
35 | ssize_t(*xwrite)(struct xf_stream* s, const void* buf, size_t len); | ||
36 | int(*xclose)(struct xf_stream* s); | ||
37 | }; | ||
38 | |||
39 | struct xf_stream { | ||
40 | intptr_t data; | ||
41 | const struct xf_stream_ops* ops; | ||
42 | }; | ||
43 | |||
44 | inline size_t xf_stream_get_size(struct xf_stream* s) | ||
45 | { return s->ops->xget_size(s); } | ||
46 | |||
47 | inline ssize_t xf_stream_read(struct xf_stream* s, void* buf, size_t len) | ||
48 | { return s->ops->xread(s, buf, len); } | ||
49 | |||
50 | inline ssize_t xf_stream_write(struct xf_stream* s, const void* buf, size_t len) | ||
51 | { return s->ops->xwrite(s, buf, len); } | ||
52 | |||
53 | inline int xf_stream_close(struct xf_stream* s) | ||
54 | { return s->ops->xclose(s); } | ||
55 | |||
56 | int xf_open_file(const char* file, int flags, struct xf_stream* s); | ||
57 | int xf_open_tar(mtar_t* mtar, const char* file, struct xf_stream* s); | ||
58 | int xf_create_tar(mtar_t* mtar, const char* file, size_t size, struct xf_stream* s); | ||
59 | |||
60 | /* Utility function needed for a few things */ | ||
61 | int xf_stream_read_lines(struct xf_stream* s, char* buf, size_t bufsz, | ||
62 | int(*callback)(int n, char* buf, void* arg), void* arg); | ||
63 | |||
64 | #endif /* _XF_STREAM_H_ */ | ||