libisofs
1.5.4
About: libisofs is a library to create an ISO 9660 filesystem, supports extensions like RockRidge or Joliet, makes bootable ISO 9660, and records file attributes which are of interest for data backups.
![]() ![]() |
#include "libisofs.h"
#include "buffer.h"
#include "ecma119.h"
#include <pthread.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | iso_ring_buffer |
Macros | |
#define | LIBISOFS_WITHOUT_LIBBURN yes |
Functions | |
int | iso_ring_buffer_new (size_t size, IsoRingBuffer **rbuf) |
Create a new buffer. More... | |
void | iso_ring_buffer_free (IsoRingBuffer *buf) |
Free a given buffer. More... | |
int | iso_ring_buffer_write (IsoRingBuffer *buf, uint8_t *data, size_t count) |
Write count bytes into buffer. More... | |
int | iso_ring_buffer_read (IsoRingBuffer *buf, uint8_t *dest, size_t count) |
Read count bytes from the buffer into dest. More... | |
void | iso_ring_buffer_writer_close (IsoRingBuffer *buf, int error) |
Close the buffer (to be called by the writer). More... | |
void | iso_ring_buffer_reader_close (IsoRingBuffer *buf, int error) |
Close the buffer (to be called by the reader). More... | |
unsigned int | iso_ring_buffer_get_times_full (IsoRingBuffer *buf) |
Get the times the buffer was full. More... | |
unsigned int | iso_ring_buffer_get_times_empty (IsoRingBuffer *buf) |
Get the times the buffer was empty. More... | |
int | iso_ring_buffer_get_buf_status (IsoRingBuffer *buf, size_t *size, size_t *free_bytes) |
Internal via buffer.h. More... | |
int | iso_ring_buffer_get_status (struct burn_source *b, size_t *size, size_t *free_bytes) |
API via libisofs.h. More... | |
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().
int iso_ring_buffer_get_buf_status | ( | IsoRingBuffer * | buf, |
size_t * | size, | ||
size_t * | free_bytes | ||
) |
Internal via buffer.h.
Backend of API call iso_ring_buffer_get_status()
Get the status of a ring buffer.
buf | The ring buffer object to inquire |
size | Will be filled with the total size of the buffer, in bytes |
free_bytes | Will be filled with the bytes currently available in buffer |
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().
int iso_ring_buffer_get_status | ( | struct burn_source * | b, |
size_t * | size, | ||
size_t * | free_bytes | ||
) |
API via libisofs.h.
Get the status of the buffer used by a burn_source.
Get the status of the buffer used by a burn_source.
b | A burn_source previously obtained with iso_image_create_burn_source(). |
size | Will be filled with the total size of the buffer, in bytes |
free_bytes | Will be filled with the bytes currently available in buffer |
Definition at line 359 of file buffer.c.
References ISO_NULL_POINTER, and iso_ring_buffer_get_buf_status().
Referenced by bs_cancel(), and bs_free_data().
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().
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().
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()
size | Number 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. |
Definition at line 86 of file buffer.c.
References BLOCK_SIZE, iso_ring_buffer::buf, iso_ring_buffer::cap, iso_ring_buffer::empty, iso_ring_buffer::full, ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, iso_ring_buffer::mutex, iso_ring_buffer::rend, iso_ring_buffer::rpos, iso_ring_buffer::size, iso_ring_buffer::times_empty, iso_ring_buffer::times_full, iso_ring_buffer::wend, and iso_ring_buffer::wpos.
Referenced by ecma119_image_new().
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.
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().
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.
error | Reader 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().
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.
buf | the buffer |
data | pointer to a memory region of at least coun bytes, from which data will be read. |
Number | of bytes to write |
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().
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.
error | Writer 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().