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"
33 * lib_ring_buffer_get_next_record advances the buffer read position to the next
34 * record. It returns either the size of the next record, -EAGAIN if there is
35 * currently no data available, or -ENODATA if no data is available and buffer
38 extern ssize_t
lib_ring_buffer_get_next_record(struct channel
*chan
,
39 struct lib_ring_buffer
*buf
);
42 * channel_get_next_record advances the buffer read position to the next record.
43 * It returns either the size of the next record, -EAGAIN if there is currently
44 * no data available, or -ENODATA if no data is available and buffer is
46 * Returns the current buffer in ret_buf.
48 extern ssize_t
channel_get_next_record(struct channel
*chan
,
49 struct lib_ring_buffer
**ret_buf
);
52 * read_current_record - copy the buffer current record into dest.
54 * @dest: destination where the record should be copied
56 * dest should be large enough to contain the record. Returns the number of
59 static inline size_t read_current_record(struct lib_ring_buffer
*buf
, void *dest
)
61 return lib_ring_buffer_read(&buf
->backend
, buf
->iter
.read_offset
,
62 dest
, buf
->iter
.payload_len
);
65 extern int lib_ring_buffer_iterator_open(struct lib_ring_buffer
*buf
);
66 extern void lib_ring_buffer_iterator_release(struct lib_ring_buffer
*buf
);
67 extern int channel_iterator_open(struct channel
*chan
);
68 extern void channel_iterator_release(struct channel
*chan
);
70 extern const struct file_operations channel_payload_file_operations
;
71 extern const struct file_operations lib_ring_buffer_payload_file_operations
;
76 int channel_iterator_init(struct channel
*chan
);
77 void channel_iterator_unregister_notifiers(struct channel
*chan
);
78 void channel_iterator_free(struct channel
*chan
);
79 void channel_iterator_reset(struct channel
*chan
);
80 void lib_ring_buffer_iterator_reset(struct lib_ring_buffer
*buf
);
82 #endif /* _LIB_RING_BUFFER_ITERATOR_H */