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 File Reference
#include <stdlib.h>
Include dependency graph for buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BLOCK_SIZE   2048
 

Typedefs

typedef struct iso_ring_buffer IsoRingBuffer
 

Functions

int iso_ring_buffer_new (size_t size, IsoRingBuffer **rbuf)
 
void iso_ring_buffer_free (IsoRingBuffer *buf)
 
int iso_ring_buffer_write (IsoRingBuffer *buf, uint8_t *data, size_t count)
 
int iso_ring_buffer_read (IsoRingBuffer *buf, uint8_t *dest, size_t count)
 
int iso_ring_buffer_get_buf_status (IsoRingBuffer *buf, size_t *size, size_t *free_bytes)
 
void iso_ring_buffer_writer_close (IsoRingBuffer *buf, int error)
 
void iso_ring_buffer_reader_close (IsoRingBuffer *buf, int error)
 
unsigned int iso_ring_buffer_get_times_full (IsoRingBuffer *buf)
 
unsigned int iso_ring_buffer_get_times_empty (IsoRingBuffer *buf)
 

Macro Definition Documentation

◆ BLOCK_SIZE

#define BLOCK_SIZE   2048

Definition at line 23 of file buffer.h.

Typedef Documentation

◆ IsoRingBuffer

Definition at line 1 of file buffer.h.

Function Documentation

◆ iso_ring_buffer_free()

void iso_ring_buffer_free ( IsoRingBuffer buf)

Free a given buffer

Definition at line 124 of file buffer.c.

References iso_ring_buffer::buf, iso_ring_buffer::empty, iso_ring_buffer::full, and iso_ring_buffer::mutex.

Referenced by ecma119_image_free().

◆ iso_ring_buffer_get_buf_status()

int iso_ring_buffer_get_buf_status ( IsoRingBuffer buf,
size_t *  size,
size_t *  free_bytes 
)

Backend of API call iso_ring_buffer_get_status()

Get the status of a ring buffer.

Parameters
bufThe ring buffer object to inquire
sizeWill be filled with the total size of the buffer, in bytes
free_bytesWill be filled with the bytes currently available in buffer
Returns
< 0 error, > 0 state: 1="active" : input and consumption are active 2="ending" : input has ended without error 3="failing" : input had error and ended, 5="abandoned" : consumption has ended prematurely 6="ended" : consumption has ended without input error 7="aborted" : consumption has ended after input error

Internal via buffer.h

Get the status of a ring buffer.

Parameters
bufThe ring buffer object to inquire
sizeWill be filled with the total size of the buffer, in bytes
free_bytesWill be filled with the bytes currently available in buffer
Returns
< 0 error, > 0 state: 1="active" : input and consumption are active 2="ending" : input has ended without error 3="failing" : input had error and ended, 5="abandoned" : consumption has ended prematurely 6="ended" : consumption has ended without input error 7="aborted" : consumption has ended after input error

Definition at line 315 of file buffer.c.

References iso_ring_buffer::cap, ISO_NULL_POINTER, iso_ring_buffer::mutex, iso_ring_buffer::rend, iso_ring_buffer::size, and iso_ring_buffer::wend.

Referenced by iso_ring_buffer_get_status(), and write_head_part1().

◆ iso_ring_buffer_get_times_empty()

unsigned int iso_ring_buffer_get_times_empty ( IsoRingBuffer buf)

Get the times the buffer was empty.

Definition at line 290 of file buffer.c.

References iso_ring_buffer::times_empty.

Referenced by bs_free_data().

◆ iso_ring_buffer_get_times_full()

unsigned int iso_ring_buffer_get_times_full ( IsoRingBuffer buf)

Get the times the buffer was full.

Definition at line 282 of file buffer.c.

References iso_ring_buffer::times_full.

Referenced by bs_free_data().

◆ iso_ring_buffer_new()

int iso_ring_buffer_new ( size_t  size,
IsoRingBuffer **  rbuf 
)

Create a new buffer.

The created buffer should be freed with iso_ring_buffer_free()

Parameters
sizeNumber of blocks in buffer. You should supply a number >= 32, otherwise size will be ignored and 32 will be used by default, which leads to a 64 KiB buffer.
Returns
1 success, < 0 error

Definition at line 86 of file buffer.c.

References BLOCK_SIZE, ISO_NULL_POINTER, ISO_OUT_OF_MEM, and ISO_SUCCESS.

Referenced by ecma119_image_new().

◆ iso_ring_buffer_read()

int iso_ring_buffer_read ( IsoRingBuffer buf,
uint8_t *  dest,
size_t  count 
)

Read count bytes from the buffer into dest. It blocks until the desired bytes has been read. If the writer finishes before outputting enough bytes, 0 (EOF) is returned, the number of bytes already read remains unknown.

Returns
1 success, 0 EOF, < 0 error

Definition at line 206 of file buffer.c.

References iso_ring_buffer::buf, iso_ring_buffer::cap, iso_ring_buffer::empty, iso_ring_buffer::full, ISO_NULL_POINTER, ISO_SUCCESS, MIN, iso_ring_buffer::mutex, iso_ring_buffer::rpos, iso_ring_buffer::size, iso_ring_buffer::times_empty, and iso_ring_buffer::wend.

Referenced by bs_read(), and ecma119_image_new().

◆ iso_ring_buffer_reader_close()

void iso_ring_buffer_reader_close ( IsoRingBuffer buf,
int  error 
)

Close the buffer (to be called by the reader). If for any reason you don't want to read more data, you need to call this to let the writer thread finish.

Parameters
errorReader has finished prematurely due to an error

Definition at line 262 of file buffer.c.

References iso_ring_buffer::full, iso_ring_buffer::mutex, and iso_ring_buffer::rend.

Referenced by bs_cancel(), and bs_free_data().

◆ iso_ring_buffer_write()

int iso_ring_buffer_write ( IsoRingBuffer buf,
uint8_t *  data,
size_t  count 
)

Write count bytes into buffer. It blocks until all bytes where written or reader close the buffer.

Parameters
bufthe buffer
datapointer to a memory region of at least coun bytes, from which data will be read.
Numberof bytes to write
Returns
1 success, 0 read finished, < 0 error

Definition at line 150 of file buffer.c.

References iso_ring_buffer::buf, iso_ring_buffer::cap, iso_ring_buffer::empty, iso_ring_buffer::full, ISO_NULL_POINTER, ISO_SUCCESS, MIN, iso_ring_buffer::mutex, iso_ring_buffer::rend, iso_ring_buffer::size, iso_ring_buffer::times_full, and iso_ring_buffer::wpos.

Referenced by iso_write().

◆ iso_ring_buffer_writer_close()

void iso_ring_buffer_writer_close ( IsoRingBuffer buf,
int  error 
)

Close the buffer (to be called by the writer). You have to explicitly close the buffer when you don't have more data to write, otherwise reader will be waiting forever.

Parameters
errorWriter has finished prematurely due to an error

Definition at line 252 of file buffer.c.

References iso_ring_buffer::empty, iso_ring_buffer::mutex, and iso_ring_buffer::wend.

Referenced by write_function().