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)  

util.h File Reference
#include <time.h>
#include <fcntl.h>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 
#define DIV_UP(n, div)   ((n + div - 1) / div)
 
#define ROUND_UP(n, mul)   (DIV_UP(n, mul) * mul)
 
#define LIBISO_ALLOC_MEM(pt, typ, count)
 
#define LIBISO_ALLOC_MEM_VOID(pt, typ, count)
 
#define LIBISO_FREE_MEM(pt)
 

Typedefs

typedef struct iso_rbtree IsoRBTree
 
typedef struct iso_htable IsoHTable
 
typedef unsigned int(* hash_funtion_t) (const void *key)
 
typedef int(* compare_function_t) (const void *a, const void *b)
 
typedef void(* hfree_data_t) (void *key, void *data)
 

Functions

int int_pow (int base, int power)
 
int iso_init_locale (int flag)
 
int strconv (const char *input, const char *icharset, const char *ocharset, char **output)
 
int strnconv (const char *str, const char *icharset, const char *ocharset, size_t len, char **output)
 
int strnconvl (const char *str, const char *icharset, const char *ocharset, size_t len, char **output, size_t *out_len)
 
int str2ascii (const char *icharset, const char *input, char **output)
 
int str2ucs (const char *icharset, const char *input, uint16_t **output)
 
int str2utf16be (const char *icharset, const char *input, uint16_t **output)
 
char * iso_1_dirid (const char *src, int relaxed)
 
char * iso_2_dirid (const char *src)
 
char * iso_r_dirid (const char *src, int size, int relaxed)
 
char * iso_1_fileid (const char *src, int relaxed, int force_dots)
 
char * iso_2_fileid (const char *src)
 
char * iso_r_fileid (const char *src, size_t len, int relaxed, int forcedot)
 
uint16_t * iso_j_file_id (const uint16_t *src, int flag)
 
uint16_t * iso_j_dir_id (const uint16_t *src, int flag)
 
size_t ucslen (const uint16_t *str)
 
uint16_t * ucsrchr (const uint16_t *str, char c)
 
uint16_t * ucsdup (const uint16_t *str)
 
int ucscmp (const uint16_t *s1, const uint16_t *s2)
 
uint16_t * ucscpy (uint16_t *dest, const uint16_t *src)
 
uint16_t * ucsncpy (uint16_t *dest, const uint16_t *src, size_t n)
 
void iso_handle_split_utf16 (uint16_t *utf_word)
 
int str2d_char (const char *icharset, const char *input, char **output)
 
int str2a_char (const char *icharset, const char *input, char **output)
 
void iso_lsb (uint8_t *buf, uint32_t num, int bytes)
 
void iso_lsb64 (uint8_t *buf, uint64_t num)
 
void iso_msb (uint8_t *buf, uint32_t num, int bytes)
 
void iso_bb (uint8_t *buf, uint32_t num, int bytes)
 
int iso_lsb_to_buf (char **wpt, uint32_t value, int bytes, int flag)
 
uint32_t iso_read_lsb (const uint8_t *buf, int bytes)
 
uint32_t iso_read_msb (const uint8_t *buf, int bytes)
 
uint32_t iso_read_bb (const uint8_t *buf, int bytes, int *error)
 
uint64_t iso_read_lsb64 (const uint8_t *buf)
 
uint64_t iso_read_msb64 (const uint8_t *buf)
 
void iso_datetime_7 (uint8_t *buf, time_t t, int always_gmt)
 
void iso_datetime_17 (uint8_t *buf, time_t t, int always_gmt)
 
time_t iso_datetime_read_7 (const uint8_t *buf)
 
time_t iso_datetime_read_17 (const uint8_t *buf)
 
int iso_eaccess (const char *path)
 
char * iso_util_strcopy (const char *buf, size_t len)
 
char * iso_util_strcopy_untail (const char *buf, size_t len)
 
void strncpy_pad (char *dest, const char *src, size_t max)
 
char * ucs2str (const char *buf, size_t len)
 
int iso_rbtree_new (int(*compare)(const void *, const void *), IsoRBTree **tree)
 
void iso_rbtree_destroy (IsoRBTree *tree, void(*free_data)(void *))
 
int iso_rbtree_insert (IsoRBTree *tree, void *data, void **item)
 
size_t iso_rbtree_get_size (IsoRBTree *tree)
 
void ** iso_rbtree_to_array (IsoRBTree *tree, int(*include_item)(void *), size_t *size)
 
size_t iso_rbtree_count_array (IsoRBTree *tree, size_t initial_count, int(*include_item)(void *))
 
int iso_htable_create (size_t size, hash_funtion_t hash, compare_function_t compare, IsoHTable **table)
 
int iso_htable_add (IsoHTable *table, void *key, void *data)
 
int iso_htable_put (IsoHTable *table, void *key, void *data)
 
int iso_htable_get (IsoHTable *table, void *key, void **data)
 
int iso_htable_remove (IsoHTable *table, void *key, hfree_data_t free_data)
 
int iso_htable_remove_ptr (IsoHTable *table, void *key, hfree_data_t free_data)
 
void iso_htable_destroy (IsoHTable *table, hfree_data_t free_data)
 
unsigned int iso_str_hash (const void *key)
 
int iso_util_encode_len_bytes (uint32_t data, char *buffer, int data_len, int *result_len, int flag)
 
int iso_util_decode_len_bytes (uint32_t *data, char *buffer, int *data_len, int buffer_len, int flag)
 
int iso_util_eval_md5_tag (char *block, int desired, uint32_t lba, void *ctx, uint32_t ctx_start_lba, int *tag_type, uint32_t *next_tag, int flag)
 
int iso_util_tag_magic (int tag_type, char **tag_magic, int *len, int flag)
 
int iso_util_bin_to_hex (char *target, uint8_t *bytes, int num_bytes, int flag)
 
int iso_util_hex_to_bin (char *hex, char *bin, int bin_size, int *bin_count, int flag)
 
int iso_truncate_rr_name (int truncate_mode, int truncate_length, char *name, int flag)
 
int checksum_cx_xinfo_func (void *data, int flag)
 
int checksum_cx_xinfo_cloner (void *old_data, void **new_data, int flag)
 
int checksum_md5_xinfo_func (void *data, int flag)
 
int checksum_md5_xinfo_cloner (void *old_data, void **new_data, int flag)
 
int iso_hfsplus_xinfo_cloner (void *old_data, void **new_data, int flag)
 
void * iso_alloc_mem (size_t size, size_t count, int flag)
 
int iso_clone_mem (char *in, char **out, size_t size)
 
int iso_clone_mgtd_mem (char *in, char **out, size_t size)
 
off_t iso_scanf_io_size (char *text, int flag)
 
uint16_t iso_ntohs (uint16_t v)
 
uint16_t iso_htons (uint16_t v)
 

Macro Definition Documentation

◆ DIV_UP

#define DIV_UP (   n,
  div 
)    ((n + div - 1) / div)

Definition at line 38 of file util.h.

◆ LIBISO_ALLOC_MEM

#define LIBISO_ALLOC_MEM (   pt,
  typ,
  count 
)
Value:
{ \
pt= (typ *) iso_alloc_mem(sizeof(typ), (size_t) (count), 0); \
if(pt == NULL) { \
ret= ISO_OUT_OF_MEM; goto ex; \
} }
void * iso_alloc_mem(size_t size, size_t count, int flag)
Definition: util.c:2297
#define ISO_OUT_OF_MEM
Definition: libisofs.h:8745

Definition at line 615 of file util.h.

◆ LIBISO_ALLOC_MEM_VOID

#define LIBISO_ALLOC_MEM_VOID (   pt,
  typ,
  count 
)
Value:
{ \
pt= (typ *) iso_alloc_mem(sizeof(typ), (size_t) (count), 0); \
if(pt == NULL) { \
goto ex; \
} }

Definition at line 621 of file util.h.

◆ LIBISO_FREE_MEM

#define LIBISO_FREE_MEM (   pt)
Value:
{ \
if(pt != NULL) \
free((char *) pt); \
}

Definition at line 627 of file util.h.

◆ MAX

#define MAX (   a,
 
)    (((a) > (b)) ? (a) : (b))

Definition at line 31 of file util.h.

◆ MIN

#define MIN (   a,
 
)    (((a) < (b)) ? (a) : (b))

Definition at line 35 of file util.h.

◆ ROUND_UP

#define ROUND_UP (   n,
  mul 
)    (DIV_UP(n, mul) * mul)

Definition at line 39 of file util.h.

Typedef Documentation

◆ compare_function_t

typedef int(* compare_function_t) (const void *a, const void *b)

Definition at line 343 of file util.h.

◆ hash_funtion_t

typedef unsigned int(* hash_funtion_t) (const void *key)

Definition at line 342 of file util.h.

◆ hfree_data_t

typedef void(* hfree_data_t) (void *key, void *data)

Definition at line 344 of file util.h.

◆ IsoHTable

typedef struct iso_htable IsoHTable

Definition at line 337 of file util.h.

◆ IsoRBTree

typedef struct iso_rbtree IsoRBTree

Definition at line 337 of file util.h.

Function Documentation

◆ checksum_cx_xinfo_cloner()

int checksum_cx_xinfo_cloner ( void *  old_data,
void **  new_data,
int  flag 
)

Definition at line 431 of file md5.c.

References ISO_XINFO_NO_CLONE.

Referenced by iso_init_with_flag().

◆ checksum_cx_xinfo_func()

int checksum_cx_xinfo_func ( void *  data,
int  flag 
)

◆ checksum_md5_xinfo_cloner()

int checksum_md5_xinfo_cloner ( void *  old_data,
void **  new_data,
int  flag 
)

Definition at line 459 of file md5.c.

References ISO_OUT_OF_MEM, and ISO_XINFO_NO_CLONE.

Referenced by iso_init_with_flag().

◆ checksum_md5_xinfo_func()

int checksum_md5_xinfo_func ( void *  data,
int  flag 
)

◆ int_pow()

int int_pow ( int  base,
int  power 
)

Definition at line 159 of file util.c.

Referenced by mangle_single_dir().

◆ iso_1_dirid()

char* iso_1_dirid ( const char *  src,
int  relaxed 
)

Create a level 1 directory identifier.

Parameters
srcThe identifier, in ASCII encoding.
relaxed0 only allow d-characters, 1 allow also lowe case chars, 2 allow all characters

Definition at line 882 of file util.c.

References iso_dirid().

Referenced by iso_get_ecma119_name().

◆ iso_1_fileid()

char* iso_1_fileid ( const char *  src,
int  relaxed,
int  force_dots 
)

Create a level 1 file identifier that consists of a name, in 8.3 format. Note that version number is not added to the file name

Parameters
srcThe identifier, in ASCII encoding.
relaxed0 only allow d-characters, 1 allow also lowe case chars, 2 allow all characters
force_dotsIf 1 then prepend empty extension by SEPARATOR1 = '.'

Definition at line 892 of file util.c.

References map_fileid_char(), and valid_d_char().

Referenced by iso_get_ecma119_name().

◆ iso_2_dirid()

char* iso_2_dirid ( const char *  src)

Create a level 2 directory identifier.

Parameters
srcThe identifier, in ASCII encoding.

Definition at line 887 of file util.c.

References iso_dirid().

Referenced by iso_get_ecma119_name().

◆ iso_2_fileid()

char* iso_2_fileid ( const char *  src)

Create a level 2 file identifier. Note that version number is not added to the file name

Parameters
srcThe identifier, in ASCII encoding.

Definition at line 960 of file util.c.

References valid_d_char().

Referenced by iso_get_ecma119_name().

◆ iso_alloc_mem()

void* iso_alloc_mem ( size_t  size,
size_t  count,
int  flag 
)

Definition at line 2297 of file util.c.

References iso_msg_submit(), and ISO_OUT_OF_MEM.

Referenced by iso_impsysa_report_blockpath().

◆ iso_bb()

◆ iso_clone_mem()

int iso_clone_mem ( char *  in,
char **  out,
size_t  size 
)

Definition at line 2336 of file util.c.

References ISO_OUT_OF_MEM, and ISO_SUCCESS.

Referenced by iso_clone_mgtd_mem(), iso_get_rr_name(), and iso_write_opts_clone().

◆ iso_clone_mgtd_mem()

int iso_clone_mgtd_mem ( char *  in,
char **  out,
size_t  size 
)

Definition at line 2352 of file util.c.

References iso_clone_mem().

Referenced by hppa_palo_set_path(), and iso_image_set_hppa_palo().

◆ iso_datetime_17()

void iso_datetime_17 ( uint8_t *  buf,
time_t  t,
int  always_gmt 
)

Records the date/time into a 17 byte buffer (ECMA-119, 8.4.26.1)

◆ iso_datetime_7()

void iso_datetime_7 ( uint8_t *  buf,
time_t  t,
int  always_gmt 
)

Records the date/time into a 7 byte buffer (ECMA-119, 9.1.5)

Parameters
bufBuffer where the date will be written
tThe time to be written
always_gmtAlways write the date in GMT and not in local time.

◆ iso_datetime_read_17()

time_t iso_datetime_read_17 ( const uint8_t *  buf)

Definition at line 1841 of file util.c.

References timegm().

Referenced by ecma119_determine_now_time(), and read_rr_TF().

◆ iso_datetime_read_7()

time_t iso_datetime_read_7 ( const uint8_t *  buf)

Definition at line 1826 of file util.c.

References timegm().

Referenced by read_rr_TF().

◆ iso_eaccess()

int iso_eaccess ( const char *  path)

Check whether the caller process has read access to the given local file.

Returns
1 on success (i.e, the process has read access), < 0 on error (including ISO_FILE_ACCESS_DENIED on access denied to the specified file or any directory on the path).

Definition at line 1866 of file util.c.

References ISO_FILE_ACCESS_DENIED, ISO_FILE_BAD_PATH, ISO_FILE_DOESNT_EXIST, ISO_FILE_ERROR, ISO_OUT_OF_MEM, and ISO_SUCCESS.

Referenced by iso_data_source_new_from_file(), and lfs_access().

◆ iso_handle_split_utf16()

void iso_handle_split_utf16 ( uint16_t *  utf_word)

Check whether utf_word is the first surrogate word of a pair. If so, change it to UTF-16 character '_'.

Definition at line 2326 of file util.c.

References set_ucsbe().

Referenced by iso_j_dir_id(), iso_j_file_id(), ucsncpy(), and ucsncpy_pad().

◆ iso_hfsplus_xinfo_cloner()

int iso_hfsplus_xinfo_cloner ( void *  old_data,
void **  new_data,
int  flag 
)

Definition at line 1864 of file hfsplus.c.

References iso_hfsplus_xinfo_new(), ISO_OUT_OF_MEM, ISO_SUCCESS, and ISO_XINFO_NO_CLONE.

Referenced by iso_init_with_flag().

◆ iso_htable_add()

int iso_htable_add ( IsoHTable table,
void *  key,
void *  data 
)

Put an element in a Hash Table. The element will be identified by the given key, that you should use to retrieve the element again.

This function allow duplicates, i.e., two items with the same key. In those cases, the value returned by iso_htable_get() is undefined. If you don't want to allow duplicates, use iso_htable_put() instead;

Both the key and data pointers will be stored internally, so you should free the objects they point to. Use iso_htable_remove() to delete an element from the table.

Definition at line 70 of file util_htable.c.

References iso_htable::cap, iso_hnode::data, iso_htable::hash, iso_hnode_new(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, iso_hnode::key, iso_htable::size, and iso_htable::table.

Referenced by mangle_single_dir().

◆ iso_htable_create()

int iso_htable_create ( size_t  size,
hash_funtion_t  hash,
compare_function_t  compare,
IsoHTable **  table 
)

Create a new hash table.

Parameters
sizeNumber of slots in table.
hashFunction used to generate

Definition at line 321 of file util_htable.c.

References iso_htable::cap, iso_htable::compare, iso_htable::hash, ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, ISO_WRONG_ARG_VALUE, iso_htable::size, and iso_htable::table.

Referenced by mangle_single_dir().

◆ iso_htable_destroy()

void iso_htable_destroy ( IsoHTable table,
hfree_data_t  free_data 
)

Destroy the given hash table.

Note that you're responsible to actually destroy the elements by providing a valid free_data function. You can pass NULL if you only want to delete the hash structure.

Definition at line 290 of file util_htable.c.

References iso_htable::cap, iso_hnode::data, iso_hnode::key, iso_hnode::next, and iso_htable::table.

Referenced by mangle_single_dir().

◆ iso_htable_get()

int iso_htable_get ( IsoHTable table,
void *  key,
void **  data 
)

Retrieve an element from the given table.

Parameters
tableHash table
keyKey of the element that will be removed
dataWill be filled with the element found. Remains untouched if no element with the given key is found.
Returns
1 if found, 0 if not, < 0 on error

Definition at line 144 of file util_htable.c.

References iso_htable::cap, iso_htable::compare, iso_hnode::data, iso_htable::hash, ISO_NULL_POINTER, iso_hnode::key, iso_hnode::next, and iso_htable::table.

Referenced by mangle_single_dir().

◆ iso_htable_put()

int iso_htable_put ( IsoHTable table,
void *  key,
void *  data 
)

Like iso_htable_add(), but this doesn't allow dulpicates.

Returns
1 success, 0 if an item with the same key already exists, < 0 error

Definition at line 100 of file util_htable.c.

References iso_htable::cap, iso_htable::compare, iso_hnode::data, iso_htable::hash, iso_hnode_new(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, iso_hnode::key, iso_hnode::next, iso_htable::size, and iso_htable::table.

◆ iso_htable_remove()

int iso_htable_remove ( IsoHTable table,
void *  key,
hfree_data_t  free_data 
)

Remove an item with the given key from the table. In tables that allow duplicates, it is undefined the element that will be deleted.

Parameters
tableHash table
keyKey of the element that will be removed
free_dataFunction that will be called passing as parameters both the key and the element that will be deleted. The user can use it to free the element. You can pass NULL if you don't want to delete the item itself.
Returns
1 success, 0 no element exists with the given key, < 0 error

Definition at line 182 of file util_htable.c.

References iso_htable::cap, iso_htable::compare, iso_hnode::data, iso_htable::hash, ISO_NULL_POINTER, iso_hnode::key, iso_hnode::next, iso_htable::size, and iso_htable::table.

◆ iso_htable_remove_ptr()

int iso_htable_remove_ptr ( IsoHTable table,
void *  key,
hfree_data_t  free_data 
)

Like remove, but instead of checking for key equality using the compare function, it just compare the key pointers. If the table allows duplicates, and you provide different keys (i.e. different pointers) to elements with same key (i.e. same content), this function ensure the exact element is removed.

It has the problem that you must provide the same key pointer, and not just a key whose contents are equal. Moreover, if you use the same key (same pointer) to identify several objects, what of those are removed is undefined.

Parameters
tableHash table
keyKey of the element that will be removed
free_dataFunction that will be called passing as parameters both the key and the element that will be deleted. The user can use it to free the element. You can pass NULL if you don't want to delete the item itself.
Returns
1 success, 0 no element exists with the given key, < 0 error

Definition at line 236 of file util_htable.c.

References iso_htable::cap, iso_hnode::data, iso_htable::hash, ISO_NULL_POINTER, iso_hnode::key, iso_hnode::next, iso_htable::size, and iso_htable::table.

Referenced by mangle_single_dir().

◆ iso_htons()

uint16_t iso_htons ( uint16_t  v)

Definition at line 2313 of file util.c.

References iso_msb().

Referenced by iso_get_hfsplus_name().

◆ iso_init_locale()

int iso_init_locale ( int  flag)

Set up locale by LC_* environment variables.

Definition at line 2038 of file util.c.

Referenced by iso_init_with_flag().

◆ iso_j_dir_id()

uint16_t* iso_j_dir_id ( const uint16_t *  src,
int  flag 
)

Create a Joliet directory identifier that consists of name and optionally extension. The combined name and extension length will not exceed 128 bytes, and the name and extension will be separated (.). All characters consist of 2 bytes and the resulting string is NULL-terminated by a 2-byte NULL.

Parameters
flagbit1= allow 103 characters rather than 64
Returns
NULL if the original name and extension both are of length 0.

Definition at line 1298 of file util.c.

References iso_handle_split_utf16(), LIBISO_ALLOC_MEM_VOID, LIBISO_FREE_MEM, LIBISO_JOLIET_NAME_MAX, set_ucsbe(), ucsdup(), ucslen(), and valid_j_char().

Referenced by iso_get_joliet_name().

◆ iso_j_file_id()

uint16_t* iso_j_file_id ( const uint16_t *  src,
int  flag 
)

Create a Joliet file identifier that consists of name and extension. The combined name and extension length will normally not exceed 64 characters (= 128 bytes). The name and the extension will be separated (.). All characters consist of 2 bytes and the resulting string is NULL-terminated by a 2-byte NULL.

Note that version number and (;1) is not appended.

Parameters
flagbit0= no_force_dots bit1= allow 103 characters rather than 64
Returns
NULL if the original name and extension both are of length 0.

Definition at line 1215 of file util.c.

References cmp_ucsbe(), iso_handle_split_utf16(), LIBISO_ALLOC_MEM_VOID, LIBISO_FREE_MEM, LIBISO_JOLIET_NAME_MAX, set_ucsbe(), ucsdup(), ucslen(), ucsrchr(), and valid_j_char().

Referenced by iso_get_joliet_name().

◆ iso_lsb()

◆ iso_lsb64()

void iso_lsb64 ( uint8_t *  buf,
uint64_t  num 
)

Definition at line 1486 of file util.c.

Referenced by ziso_stream_compress(), and zisofs_add_ZF().

◆ iso_lsb_to_buf()

int iso_lsb_to_buf ( char **  wpt,
uint32_t  value,
int  bytes,
int  flag 
)

Definition at line 1510 of file util.c.

Referenced by iso_write_gpt_entry(), and iso_write_gpt_header_block().

◆ iso_msb()

◆ iso_ntohs()

uint16_t iso_ntohs ( uint16_t  v)

Definition at line 2308 of file util.c.

References iso_read_msb().

Referenced by get_class(), and iso_get_hfsplus_name().

◆ iso_r_dirid()

char* iso_r_dirid ( const char *  src,
int  size,
int  relaxed 
)

Create a dir name suitable for an ISO image with relaxed constraints.

Parameters
srcThe identifier, in ASCII encoding.
sizeMax len for the name
relaxed0 only allow d-characters, 1 allow also lowe case chars, 2 allow all characters

Create a dir name suitable for an ISO image with relaxed constraints.

Parameters
sizeMax len for the name
relaxedbit0+1: 0 only allow d-characters, 1 allow also lowe case chars, 2 allow all 8-bit characters, bit2: allow 7-bit characters (but map lowercase to uppercase if not bit0+1 == 2)

Definition at line 1026 of file util.c.

References map_fileid_char(), and valid_d_char().

Referenced by iso_get_ecma119_name().

◆ iso_r_fileid()

char* iso_r_fileid ( const char *  src,
size_t  len,
int  relaxed,
int  forcedot 
)

Create a file name suitable for an ISO image with relaxed constraints.

Parameters
srcThe identifier, in ASCII encoding.
lenMax len for the name, without taken the "." into account.
relaxed0 only allow d-characters, 1 allow also lowe case chars, 2 allow all characters
forcedotWhether to ensure that "." is added

Create a file name suitable for an ISO image with level > 1 and with relaxed constraints.

Parameters
lenMax len for the name, without taken the "." into account.
relaxedbit0+1: 0 only allow d-characters, 1 allow also lowe case chars, 2 allow all 8-bit characters, bit2: allow 7-bit characters (but map lowercase to uppercase if not bit0+1 == 2)
forcedotWhether to ensure that "." is added

Definition at line 1090 of file util.c.

References map_fileid_char(), and valid_d_char().

Referenced by iso_get_ecma119_name().

◆ iso_rbtree_count_array()

size_t iso_rbtree_count_array ( IsoRBTree tree,
size_t  initial_count,
int(*)(void *)  include_item 
)

Predict the size of the array which gets returned by iso_rbtree_to_array().

Definition at line 337 of file util_rbtree.c.

References rbtree_count_array_aux(), and iso_rbtree::root.

Referenced by filesrc_writer_pre_compute().

◆ iso_rbtree_destroy()

void iso_rbtree_destroy ( IsoRBTree tree,
void(*)(void *)  free_data 
)

Destroy a given tree.

Note that only the structure itself is deleted. To delete the elements, you should provide a valid free_data function. It will be called for each element of the tree, so you can use it to free any related data.

Definition at line 84 of file util_rbtree.c.

References rbtree_destroy_aux(), and iso_rbtree::root.

Referenced by ecma119_image_free().

◆ iso_rbtree_get_size()

size_t iso_rbtree_get_size ( IsoRBTree tree)

Get the number of elements in a given tree.

Definition at line 250 of file util_rbtree.c.

References iso_rbtree::size.

◆ iso_rbtree_insert()

int iso_rbtree_insert ( IsoRBTree tree,
void *  data,
void **  item 
)

Inserts a given element in a Red-Black tree.

Parameters
treethe tree where to insert
dataelement to be inserted on the tree. It can't be NULL
itemif not NULL, it will point to a location where the tree element ptr will be stored. If data was inserted, *item == data. If data was already on the tree, *item points to the previously inserted object that is equal to data.
Returns
1 success, 0 element already inserted, < 0 error

Definition at line 149 of file util_rbtree.c.

References iso_rbnode::ch, iso_rbtree::compare, iso_rbnode::data, is_red(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, iso_rbnode_new(), iso_rbtree_double(), iso_rbtree_single(), iso_rbnode::red, iso_rbtree::root, and iso_rbtree::size.

Referenced by iso_file_src_add(), and iso_file_src_create().

◆ iso_rbtree_new()

int iso_rbtree_new ( int(*)(const void *, const void *)  compare,
IsoRBTree **  tree 
)

Create a new binary tree. libisofs binary trees allow you to add any data passing it as a pointer. You must provide a function suitable for compare two elements.

Parameters
compareA function to compare two keys. It takes a pointer to both keys and return 0, -1 or 1 if the first key is equal, less or greater than the second one.
treeLocation where the tree structure will be stored.

Create a new binary tree. libisofs binary trees allow you to add any data passing it as a pointer. You must provide a function suitable for compare two elements.

Parameters
compareA function to compare two elements. It takes a pointer to both elements and return 0, -1 or 1 if the first element is equal, less or greater than the second one.
treeLocation where the tree structure will be stored.

Definition at line 50 of file util_rbtree.c.

References ISO_NULL_POINTER, ISO_OUT_OF_MEM, and ISO_SUCCESS.

Referenced by ecma119_image_new().

◆ iso_rbtree_to_array()

void** iso_rbtree_to_array ( IsoRBTree tree,
int(*)(void *)  include_item,
size_t *  size 
)

Get an array view of the elements of the tree.

Parameters
include_itemFunction to select which elements to include in the array. It that takes a pointer to an element and returns 1 if the element should be included, 0 if not. If you want to add all elements to the array, you can pass a NULL pointer.
sizeIf not null, will be filled with the number of elements in the array, without counting the final NULL item.
Returns
A sorted array with the contents of the tree, or NULL if there is not enough memory to allocate the array. You should free(3) the array when no more needed. Note that the array is NULL-terminated, and thus it has size + 1 length.

Get an array view of the elements of the tree.

Parameters
include_itemFunction to select which elements to include in the array. It that takes a pointer to an element and returns 1 if the element should be included, 0 if not. If you want to add all elements to the array, you can pass a NULL pointer.
Returns
A sorted array with the contents of the tree, or NULL if there is not enough memory to allocate the array. You should free(3) the array when no more needed. Note that the array is NULL-terminated, and thus it has size + 1 length.

Definition at line 284 of file util_rbtree.c.

References rbtree_to_array_aux(), iso_rbtree::root, and iso_rbtree::size.

Referenced by filesrc_writer_pre_compute().

◆ iso_read_bb()

uint32_t iso_read_bb ( const uint8_t *  buf,
int  bytes,
int *  error 
)

if error != NULL it will be set to 1 if LSB and MSB integers don't match.

Definition at line 1542 of file util.c.

References iso_read_lsb(), and iso_read_msb().

Referenced by iso_file_source_new_ifs(), iso_image_filesystem_new(), read_dir(), read_pvd_block(), read_pvm(), read_rr_PN(), read_rr_PX(), read_zisofs_ZF(), and susp_iter_next().

◆ iso_read_lsb()

uint32_t iso_read_lsb ( const uint8_t *  buf,
int  bytes 
)

Definition at line 1520 of file util.c.

Referenced by iso_read_bb().

◆ iso_read_lsb64()

◆ iso_read_msb()

uint32_t iso_read_msb ( const uint8_t *  buf,
int  bytes 
)

◆ iso_read_msb64()

uint64_t iso_read_msb64 ( const uint8_t *  buf)

Definition at line 1564 of file util.c.

Referenced by iso_analyze_sun().

◆ iso_scanf_io_size()

off_t iso_scanf_io_size ( char *  text,
int  flag 
)

Convert a text into a number of type double and multiply it by unit code [kmgt] (2^10 to 2^40) or [s] (2048) or [d] (512). (Also accepts capital letters.)

Parameters
textInput like "42", "223062s", "3m" or "-1g"
flagBitfield for control purposes: bit0= return -1 rather than 0 on failure bit1= if scaled then compute the last byte of the last unit
Returns
The derived value

Definition at line 2369 of file util.c.

Referenced by iso_ivr_read_number().

◆ iso_str_hash()

unsigned int iso_str_hash ( const void *  key)

Hash function suitable for keys that are char strings.

Definition at line 270 of file util_htable.c.

References iso_hnode::key.

Referenced by mangle_single_dir().

◆ iso_truncate_rr_name()

◆ iso_util_bin_to_hex()

int iso_util_bin_to_hex ( char *  target,
uint8_t *  bytes,
int  num_bytes,
int  flag 
)

Definition at line 2096 of file util.c.

Referenced by iso_analyze_gpt_backup(), iso_eltorito_report(), and iso_impsysa_report().

◆ iso_util_decode_len_bytes()

int iso_util_decode_len_bytes ( uint32_t *  data,
char *  buffer,
int *  data_len,
int  buffer_len,
int  flag 
)

Decode an integer as LEN,BYTES for being a component in certain AAIP attribute values.

Parameters
datareturns the decoded value
buffercontains the encoded value
data_lenreturns the number of value bytes (without len byte)
buffer_lentells the number of valid buffer bytes

Definition at line 2069 of file util.c.

References ISO_SUCCESS.

Referenced by iso_root_get_isofsca(), and iso_root_get_isofsnt().

◆ iso_util_encode_len_bytes()

int iso_util_encode_len_bytes ( uint32_t  data,
char *  buffer,
int  data_len,
int *  result_len,
int  flag 
)

Encode an integer as LEN,BYTES for being a component in certain AAIP attribute values.

Definition at line 2045 of file util.c.

References ISO_SUCCESS.

Referenced by iso_root_set_isofsca(), and iso_root_set_isofsnt().

◆ iso_util_eval_md5_tag()

int iso_util_eval_md5_tag ( char *  block,
int  desired,
uint32_t  lba,
void *  ctx,
uint32_t  ctx_start_lba,
int *  tag_type,
uint32_t *  next_tag,
int  flag 
)

◆ iso_util_hex_to_bin()

int iso_util_hex_to_bin ( char *  hex,
char *  bin,
int  bin_size,
int *  bin_count,
int  flag 
)

Definition at line 2107 of file util.c.

Referenced by iso_util_decode_md5_tag().

◆ iso_util_strcopy()

char* iso_util_strcopy ( const char *  buf,
size_t  len 
)

Copy up to len chars from buf and return this newly allocated string. The new string is null-terminated.

Definition at line 1912 of file util.c.

Referenced by iso_util_strcopy_untail(), read_rr_NM(), and read_rr_SL().

◆ iso_util_strcopy_untail()

char* iso_util_strcopy_untail ( const char *  buf,
size_t  len 
)

Copy up to len chars from buf and return this newly allocated string. The new string is null-terminated. Any trailing blanks will be removed.

Definition at line 1925 of file util.c.

References iso_util_strcopy().

Referenced by read_pvm().

◆ iso_util_tag_magic()

int iso_util_tag_magic ( int  tag_type,
char **  tag_magic,
int *  len,
int  flag 
)

Definition at line 2130 of file util.c.

References ISO_WRONG_ARG_VALUE.

Referenced by iso_md5_write_tag(), and iso_util_decode_md5_tag().

◆ str2a_char()

int str2a_char ( const char *  icharset,
const char *  input,
char **  output 
)

allow NULL input

Definition at line 1444 of file util.c.

References ISO_OUT_OF_MEM, ISO_SUCCESS, str2ascii(), and valid_a_char().

Referenced by ecma119_writer_write_vol_desc(), and iso1999_writer_write_vol_desc().

◆ str2ascii()

int str2ascii ( const char *  icharset,
const char *  input,
char **  output 
)

Convert a given string from any input charset to ASCII

Parameters
icharsetInput charset. Must be supported by iconv
inputInput string
outputLocation where the pointer to the output string will be stored
Returns
1 on success, < 0 on error

Definition at line 392 of file util.c.

References ISO_CHARSET_CONV_ERROR, iso_iconv(), iso_iconv_close(), iso_iconv_open(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, and str2wchar().

Referenced by iso_get_ecma119_name(), str2a_char(), and str2d_char().

◆ str2d_char()

int str2d_char ( const char *  icharset,
const char *  input,
char **  output 
)

Convert a given input string to d-chars.

Returns
1 on success, < 0 error, 0 if input was null (output is set to null)

allow NULL input

Definition at line 1410 of file util.c.

References ISO_OUT_OF_MEM, ISO_SUCCESS, str2ascii(), and valid_d_char().

Referenced by ecma119_writer_write_vol_desc().

◆ str2ucs()

int str2ucs ( const char *  icharset,
const char *  input,
uint16_t **  output 
)

Convert a given string from any input charset to UCS-2BE charset, used for Joliet file identifiers.

Parameters
icharsetInput charset. Must be supported by iconv
inputInput string
outputLocation where the pointer to the output string will be stored
Returns
1 on success, < 0 on error

Definition at line 558 of file util.c.

References ISO_CHARSET_CONV_ERROR, iso_iconv(), iso_iconv_close(), iso_iconv_open(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, set_ucsbe(), and str2wchar().

Referenced by iso_get_joliet_name(), joliet_create_mangled_name(), and joliet_writer_write_vol_desc().

◆ str2utf16be()

int str2utf16be ( const char *  icharset,
const char *  input,
uint16_t **  output 
)

Convert a given string from any input charset to UTF-16BE charset, used for HFS+ file identifiers. (UTF-16 differs from older UCS-2 by having multi word characters.)

Parameters
icharsetInput charset. Must be supported by iconv
inputInput string
outputLocation where the pointer to the output string will be stored
Returns
1 on success, < 0 on error

Definition at line 687 of file util.c.

References ISO_CHARSET_CONV_ERROR, iso_iconv(), iso_iconv_close(), iso_iconv_open(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, set_ucsbe(), and str2wchar().

Referenced by iso_get_hfsplus_name(), and iso_get_joliet_name().

◆ strconv()

int strconv ( const char *  input,
const char *  icharset,
const char *  ocharset,
char **  output 
)

Convert the charset encoding of a given string.

Parameters
inputInput string
icharsetInput charset. Must be supported by iconv
ocharsetOutput charset. Must be supported by iconv
outputLocation where the pointer to the output string will be stored
Returns
1 on success, < 0 on error

Definition at line 192 of file util.c.

References ISO_CHARSET_CONV_ERROR, iso_iconv(), iso_iconv_close(), iso_iconv_open(), ISO_OUT_OF_MEM, and ISO_SUCCESS.

Referenced by get_iso1999_name(), get_relaxed_vol_id(), and iso_get_rr_name().

◆ strnconv()

int strnconv ( const char *  str,
const char *  icharset,
const char *  ocharset,
size_t  len,
char **  output 
)

Definition at line 295 of file util.c.

References strnconvl().

Referenced by get_name().

◆ strnconvl()

int strnconvl ( const char *  str,
const char *  icharset,
const char *  ocharset,
size_t  len,
char **  output,
size_t *  out_len 
)

◆ strncpy_pad()

void strncpy_pad ( char *  dest,
const char *  src,
size_t  max 
)

Copy up to max characters from src to dest. If src has less than max characters, we pad dest with " " characters.

Definition at line 1947 of file util.c.

References MIN.

Referenced by ecma119_writer_write_vol_desc(), and iso1999_writer_write_vol_desc().

◆ ucs2str()

char* ucs2str ( const char *  buf,
size_t  len 
)

Convert a Joliet string with a length of len bytes to a new string in local charset.

Definition at line 1963 of file util.c.

References iso_get_local_charset(), iso_iconv(), iso_iconv_close(), and iso_iconv_open().

◆ ucscmp()

int ucscmp ( const uint16_t *  s1,
const uint16_t *  s2 
)

Like strcmp, but for Joliet strings.

Although each character is 2 bytes, we actually compare byte-by-byte because the words are big-endian. Comparing possibly swapped words would make the sorting order depend on the machine byte order.

Definition at line 1371 of file util.c.

References MIN, and ucslen().

Referenced by cmp_node(), cmp_node_name(), iso_get_joliet_name(), and mangle_single_dir().

◆ ucscpy()

uint16_t* ucscpy ( uint16_t *  dest,
const uint16_t *  src 
)

Like strcpy, but for Joliet strings.

Definition at line 1394 of file util.c.

References ucslen().

Referenced by mangle_single_dir().

◆ ucsdup()

uint16_t* ucsdup ( const uint16_t *  str)

Like strdup, but for Joliet strings.

Definition at line 1352 of file util.c.

References ucslen().

Referenced by iso_j_dir_id(), iso_j_file_id(), and mangle_single_dir().

◆ ucslen()

◆ ucsncpy()

uint16_t* ucsncpy ( uint16_t *  dest,
const uint16_t *  src,
size_t  n 
)

Like strncpy, but for Joliet strings.

Parameters
nMaximum number of characters to copy (2 bytes per char).

Definition at line 1401 of file util.c.

References iso_handle_split_utf16(), MIN, and ucslen().

Referenced by joliet_create_mangled_name().

◆ ucsrchr()

uint16_t* ucsrchr ( const uint16_t *  str,
char  c 
)

Like strrchr, but for Joliet strings.

Definition at line 1340 of file util.c.

References cmp_ucsbe(), and ucslen().

Referenced by iso_j_file_id(), and mangle_single_dir().