1 #ifndef _LIB_RING_BUFFER_ITERATOR_H
2 #define _LIB_RING_BUFFER_ITERATOR_H
5 * lib/ringbuffer/iterator.h
7 * Ring buffer and channel iterators.
9 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
29 #include "../../wrapper/ringbuffer/backend.h"
30 #include "../../wrapper/ringbuffer/frontend.h"
31 #include "../../wrapper/ringbuffer/vfs.h"
34 * lib_ring_buffer_get_next_record advances the buffer read position to the next
35 * record. It returns either the size of the next record, -EAGAIN if there is
36 * currently no data available, or -ENODATA if no data is available and buffer
39 extern ssize_t
lib_ring_buffer_get_next_record(struct channel
*chan
,
40 struct lib_ring_buffer
*buf
);
43 * channel_get_next_record advances the buffer read position to the next record.
44 * It returns either the size of the next record, -EAGAIN if there is currently
45 * no data available, or -ENODATA if no data is available and buffer is
47 * Returns the current buffer in ret_buf.
49 extern ssize_t
channel_get_next_record(struct channel
*chan
,
50 struct lib_ring_buffer
**ret_buf
);
53 * read_current_record - copy the buffer current record into dest.
55 * @dest: destination where the record should be copied
57 * dest should be large enough to contain the record. Returns the number of
60 static inline size_t read_current_record(struct lib_ring_buffer
*buf
, void *dest
)
62 return lib_ring_buffer_read(&buf
->backend
, buf
->iter
.read_offset
,
63 dest
, buf
->iter
.payload_len
);
66 extern int lib_ring_buffer_iterator_open(struct lib_ring_buffer
*buf
);
67 extern void lib_ring_buffer_iterator_release(struct lib_ring_buffer
*buf
);
68 extern int channel_iterator_open(struct channel
*chan
);
69 extern void channel_iterator_release(struct channel
*chan
);
71 extern const struct file_operations channel_payload_file_operations
;
72 extern const struct file_operations lib_ring_buffer_payload_file_operations
;
77 int channel_iterator_init(struct channel
*chan
);
78 void channel_iterator_unregister_notifiers(struct channel
*chan
);
79 void channel_iterator_free(struct channel
*chan
);
80 void channel_iterator_reset(struct channel
*chan
);
81 void lib_ring_buffer_iterator_reset(struct lib_ring_buffer
*buf
);
83 #endif /* _LIB_RING_BUFFER_ITERATOR_H */