xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

buffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Vreixo Formoso
3  *
4  * This file is part of the libisofs project; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License version 2
6  * or later as published by the Free Software Foundation.
7  * See COPYING file for details.
8  */
9 
10 #ifndef LIBISO_BUFFER_H_
11 #define LIBISO_BUFFER_H_
12 
13 #include <stdlib.h>
14 
15 #ifdef HAVE_STDINT_H
16 #include <stdint.h>
17 #else
18 #ifdef HAVE_INTTYPES_H
19 #include <inttypes.h>
20 #endif
21 #endif
22 
23 #define BLOCK_SIZE 2048
24 
25 typedef struct iso_ring_buffer IsoRingBuffer;
26 
27 /**
28  * Create a new buffer.
29  *
30  * The created buffer should be freed with iso_ring_buffer_free()
31  *
32  * @param size
33  * Number of blocks in buffer. You should supply a number >= 32, otherwise
34  * size will be ignored and 32 will be used by default, which leads to a
35  * 64 KiB buffer.
36  * @return
37  * 1 success, < 0 error
38  */
39 int iso_ring_buffer_new(size_t size, IsoRingBuffer **rbuf);
40 
41 /**
42  * Free a given buffer
43  */
45 
46 /**
47  * Write count bytes into buffer. It blocks until all bytes where written or
48  * reader close the buffer.
49  *
50  * @param buf
51  * the buffer
52  * @param data
53  * pointer to a memory region of at least coun bytes, from which data
54  * will be read.
55  * @param
56  * Number of bytes to write
57  * @return
58  * 1 success, 0 read finished, < 0 error
59  */
60 int iso_ring_buffer_write(IsoRingBuffer *buf, uint8_t *data, size_t count);
61 
62 /**
63  * Read count bytes from the buffer into dest. It blocks until the desired
64  * bytes has been read. If the writer finishes before outputting enough
65  * bytes, 0 (EOF) is returned, the number of bytes already read remains
66  * unknown.
67  *
68  * @return
69  * 1 success, 0 EOF, < 0 error
70  */
71 int iso_ring_buffer_read(IsoRingBuffer *buf, uint8_t *dest, size_t count);
72 
73 /** Backend of API call iso_ring_buffer_get_status()
74  *
75  * Get the status of a ring buffer.
76  *
77  * @param buf
78  * The ring buffer object to inquire
79  * @param size
80  * Will be filled with the total size of the buffer, in bytes
81  * @param free_bytes
82  * Will be filled with the bytes currently available in buffer
83  * @return
84  * < 0 error, > 0 state:
85  * 1="active" : input and consumption are active
86  * 2="ending" : input has ended without error
87  * 3="failing" : input had error and ended,
88  * 5="abandoned" : consumption has ended prematurely
89  * 6="ended" : consumption has ended without input error
90  * 7="aborted" : consumption has ended after input error
91  */
93  size_t *free_bytes);
94 
95 /**
96  * Close the buffer (to be called by the writer).
97  * You have to explicitly close the buffer when you don't have more data to
98  * write, otherwise reader will be waiting forever.
99  *
100  * @param error
101  * Writer has finished prematurely due to an error
102  */
104 
105 /**
106  * Close the buffer (to be called by the reader).
107  * If for any reason you don't want to read more data, you need to call this
108  * to let the writer thread finish.
109  *
110  * @param error
111  * Reader has finished prematurely due to an error
112  */
114 
115 /**
116  * Get the times the buffer was full.
117  */
119 
120 /**
121  * Get the times the buffer was empty.
122  */
124 
125 #endif /*LIBISO_BUFFER_H_*/
int iso_ring_buffer_get_buf_status(IsoRingBuffer *buf, size_t *size, size_t *free_bytes)
Definition: buffer.c:315
int iso_ring_buffer_read(IsoRingBuffer *buf, uint8_t *dest, size_t count)
Definition: buffer.c:206
void iso_ring_buffer_free(IsoRingBuffer *buf)
Definition: buffer.c:124
unsigned int iso_ring_buffer_get_times_full(IsoRingBuffer *buf)
Definition: buffer.c:282
unsigned int iso_ring_buffer_get_times_empty(IsoRingBuffer *buf)
Definition: buffer.c:290
void iso_ring_buffer_reader_close(IsoRingBuffer *buf, int error)
Definition: buffer.c:262
int iso_ring_buffer_write(IsoRingBuffer *buf, uint8_t *data, size_t count)
Definition: buffer.c:150
void iso_ring_buffer_writer_close(IsoRingBuffer *buf, int error)
Definition: buffer.c:252
int iso_ring_buffer_new(size_t size, IsoRingBuffer **rbuf)
Definition: buffer.c:86
size_t size
Definition: buffer.c:52
uint8_t * buf
Definition: buffer.c:42