]> git.proxmox.com Git - mirror_qemu.git/blame - include/io/channel-buffer.h
iotests/image-fleecing: switch to qemu_io()
[mirror_qemu.git] / include / io / channel-buffer.h
CommitLineData
d98e4eb7
DB
1/*
2 * QEMU I/O channels memory buffer driver
3 *
4 * Copyright (c) 2015 Red Hat, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
c8198bd5 9 * version 2.1 of the License, or (at your option) any later version.
d98e4eb7
DB
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
2a6a4076
MA
21#ifndef QIO_CHANNEL_BUFFER_H
22#define QIO_CHANNEL_BUFFER_H
d98e4eb7
DB
23
24#include "io/channel.h"
db1015e9 25#include "qom/object.h"
d98e4eb7
DB
26
27#define TYPE_QIO_CHANNEL_BUFFER "qio-channel-buffer"
8063396b 28OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelBuffer, QIO_CHANNEL_BUFFER)
d98e4eb7 29
d98e4eb7
DB
30
31/**
32 * QIOChannelBuffer:
33 *
34 * The QIOChannelBuffer object provides a channel implementation
35 * that is able to perform I/O to/from a memory buffer.
36 *
37 */
38
39struct QIOChannelBuffer {
40 QIOChannel parent;
41 size_t capacity; /* Total allocated memory */
42 size_t usage; /* Current size of data */
43 size_t offset; /* Offset for future I/O ops */
e8f117f3 44 uint8_t *data;
d98e4eb7
DB
45};
46
47
48/**
49 * qio_channel_buffer_new:
50 * @capacity: the initial buffer capacity to allocate
51 *
52 * Allocate a new buffer which is initially empty
53 *
54 * Returns: the new channel object
55 */
56QIOChannelBuffer *
57qio_channel_buffer_new(size_t capacity);
58
2a6a4076 59#endif /* QIO_CHANNEL_BUFFER_H */