Analog of sprintf() that allocates a string large enough to hold the output including the terminating null character.
_NACORE_DEF NACORE_FORMAT_PRINTF( 2, 3 ) int nacore_asprintf(char **strp, const char *fmt, ...)
Analog of strcpy() that allocates a string large enough to hold the output including the terminating null character.
_NACORE_DEF char * nacore_astrcpy( const char * s, void * unused )
AVL tree.
typedef struct _nacore_avl_tree * nacore_avl_tree
Starts a section of code in which the tree is guaranteed not to be modified by other threads.
_NACORE_DEF int nacore_avl_tree_begin_op( nacore_avl_tree tree )
Dumps the structure and content of a tree on stderr.
_NACORE_DEF void nacore_avl_tree_dump( nacore_avl_tree tree, nacore_to_string_cb to_string_cb, void * to_string_opaque )
Duplicates a tree.
_NACORE_DEF nacore_avl_tree nacore_avl_tree_dup( nacore_avl_tree tree, void * cmp_opaque, nacore_get_size_cb gs_cb, void * gs_opaque, nacore_filter_cb filter_cb, void * filter_opaque, nacore_op_cb dup_cb, void * dup_opaque )
AVL tree element.
typedef struct _nacore_avl_tree_elem * nacore_avl_tree_elem
Gets the next element on the right with regard to the given element in a tree.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_elem_get_next( nacore_avl_tree tree, nacore_avl_tree_elem elem )
Gets the next element on the left with regard to the given element in a tree.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_elem_get_prev( nacore_avl_tree tree, nacore_avl_tree_elem elem )
Gets the value contained in a tree element.
_NACORE_DEF void * nacore_avl_tree_elem_get_value( nacore_avl_tree tree, nacore_avl_tree_elem elem )
Sets the value contained in a tree element and rearranges the tree to keep the sorting if needed.
_NACORE_DEF int nacore_avl_tree_elem_set_value( nacore_avl_tree tree, nacore_avl_tree_elem elem, nacore_op_cb free_cb, void * free_opaque, void * cmp_opaque, void * gs_opaque, void * value )
Ends a section of code in which the tree is guaranteed not to be modified by other threads.
_NACORE_DEF void nacore_avl_tree_end_op( nacore_avl_tree tree )
Finds a matching element inside a tree by comparing values.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_find( nacore_avl_tree tree, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Finds the leftmost matching element inside a tree by comparing values.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_find_first( nacore_avl_tree tree, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Finds the rightmost matching element inside a tree by comparing values.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_find_last( nacore_avl_tree tree, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Finds the next element on the right in a tree holding a value that compares identical to that of the given element.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_find_next( nacore_avl_tree tree, nacore_avl_tree_elem elem, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque )
Finds the next element on the left in a tree holding a value that compares identical to that of the given element.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_find_prev( nacore_avl_tree tree, nacore_avl_tree_elem elem, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque )
Destroies a tree and all its elements.
_NACORE_DEF void nacore_avl_tree_free( nacore_avl_tree tree, nacore_op_cb free_cb, void * free_opaque )
Gets the leftmost (i.e., the first/smallest by value) element in a tree.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_get_first( nacore_avl_tree tree )
Gets the rightmost (i.e., the last/biggest by value) element in a tree.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_get_last( nacore_avl_tree tree )
Gets the number of elements in a tree.
_NACORE_DEF size_t nacore_avl_tree_get_n_elems( nacore_avl_tree tree )
Inserts a new element into a tree.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_insert( nacore_avl_tree tree, void * cmp_opaque, void * gs_opaque, void * value )
Merges two trees by inserting the elements of one tree into the other.
_NACORE_DEF nacore_avl_tree nacore_avl_tree_merge( nacore_avl_tree dest, nacore_avl_tree src, void * cmp_opaque )
Creates a new tree.
_NACORE_DEF nacore_avl_tree nacore_avl_tree_new( nacore_cmp_cb cmp_cb, nacore_get_size_cb gs_cb )
Removes an element from a tree and returns the value it contains.
_NACORE_DEF void * nacore_avl_tree_pop( nacore_avl_tree tree, nacore_avl_tree_elem elem )
Decodes the Unicode code point associated to an UTF-16LE character.
_NACORE_DEF size_t nacore_char_utf16le_decode( const char * utf16lec, uint32_t * cp )
Encodes a Unicode code point into an UTF-16LE character.
_NACORE_DEF size_t nacore_char_utf16le_encode( char * utf16lec, uint32_t cp )
Decodes the Unicode code point associated to an UTF-8 character.
_NACORE_DEF size_t nacore_char_utf8_decode( const char * utf8c, uint32_t * cp )
Encodes a Unicode code point into an UTF-8 character.
_NACORE_DEF size_t nacore_char_utf8_encode( char * utf8c, uint32_t cp )
A function that compares two values.
typedef int ( * nacore_cmp_cb )(const void *v1, const void *v2, void *opaque)
Decrements the reference count on the dynamically loaded library handle.
_NACORE_DEF int nacore_dl_close( nacore_dl_handle handle, nacore_msg_context msg_context, void * msg_opaque )
Dynamically loaded library handle.
typedef struct _nacore_dl_handle * nacore_dl_handle
Loads a dynamic library.
_NACORE_DEF nacore_dl_handle nacore_dl_open( const char * filename, nacore_msg_context msg_context, void * msg_opaque )
Retrieves the memory address where a symbol from a dynamically loaded library is loaded into memory.
_NACORE_DEF void * nacore_dl_sym( nacore_dl_handle handle, const char * symbol, nacore_msg_context msg_context, void * msg_opaque )
Dismisses a value returned by nacore_env_get().
_NACORE_DEF void nacore_env_free( const char * value )
Gets the value of an environment variable.
_NACORE_DEF const char * nacore_env_get( const char * name )
Splits a string representing a list of path prefixes similarily to nacore_string_split().
_NACORE_DEF nacore_list nacore_env_path_prefixes_split( const char * path )
A function that decides whether a certain value should be filtered out or not.
typedef char ( * nacore_filter_cb )(const void *value, void *opaque)
Directory stream.
typedef struct _nacore_fs_dir * nacore_fs_dir
Closes a directory stream.
_NACORE_DEF int nacore_fs_dir_close( nacore_fs_dir dir )
Directory entry.
typedef struct _nacore_fs_dir_entry * nacore_fs_dir_entry
Dismisses a directory entry returned by nacore_fs_dir_get_next_entry().
_NACORE_DEF void nacore_fs_dir_entry_free( nacore_fs_dir_entry entry )
Gets the filename of the directory entry.
_NACORE_DEF const char * nacore_fs_dir_entry_get_name( nacore_fs_dir_entry entry )
Gets the next entry in the given directory stream.
_NACORE_DEF nacore_fs_dir_entry nacore_fs_dir_get_next_entry( nacore_fs_dir dir )
Opens a directory stream.
_NACORE_DEF nacore_fs_dir nacore_fs_dir_open( const char * name )
Platform-specific directory separator.
_NACORE_DEF const char * const nacore_fs_dir_sep
A function that returns the size of some value.
typedef size_t ( * nacore_get_size_cb )(const void *value, void *opaque)
Doubly-linked list.
typedef struct _nacore_list * nacore_list
Appends a new element to a list.
_NACORE_DEF nacore_list_elem nacore_list_append( nacore_list list, void * gs_opaque, void * value )
Starts a section of code in which the list is guaranteed not to be modified by other threads.
_NACORE_DEF int nacore_list_begin_op( nacore_list list )
Dumps the structure and content of a list on stderr.
_NACORE_DEF void nacore_list_dump( nacore_list list, nacore_to_string_cb to_string_cb, void * to_string_opaque )
Duplicates a list.
_NACORE_DEF nacore_list nacore_list_dup( nacore_list list, nacore_get_size_cb gs_cb, void * gs_opaque, nacore_filter_cb filter_cb, void * filter_opaque, nacore_op_cb dup_cb, void * dup_opaque )
Doubly-linked list element.
typedef struct _nacore_list_elem * nacore_list_elem
Gets the following element with regard to the given element in a list.
_NACORE_DEF nacore_list_elem nacore_list_elem_get_next( nacore_list list, nacore_list_elem elem )
Gets the previous element with regard to the given element in a list.
_NACORE_DEF nacore_list_elem nacore_list_elem_get_prev( nacore_list list, nacore_list_elem elem )
Gets the value contained in a list element.
_NACORE_DEF void * nacore_list_elem_get_value( nacore_list list, nacore_list_elem elem )
Sets the value contained in a list element.
_NACORE_DEF int nacore_list_elem_set_value( nacore_list list, nacore_list_elem elem, nacore_op_cb free_cb, void * free_opaque, void * gs_opaque, void * value )
Ends a section of code in which the list is guaranteed not to be modified by other threads.
_NACORE_DEF void nacore_list_end_op( nacore_list list )
Finds the first matching element inside a list going forwards after another given element.
_NACORE_DEF nacore_list_elem nacore_list_find_after( nacore_list list, nacore_list_elem elem, nacore_cmp_cb cmp_cb, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Finds the first matching element inside a list going backwards before another given element.
_NACORE_DEF nacore_list_elem nacore_list_find_before( nacore_list list, nacore_list_elem elem, nacore_cmp_cb cmp_cb, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Finds the first matching element inside a list.
_NACORE_DEF nacore_list_elem nacore_list_find_first( nacore_list list, nacore_cmp_cb cmp_cb, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Finds the last matching element inside a list.
_NACORE_DEF nacore_list_elem nacore_list_find_last( nacore_list list, nacore_cmp_cb cmp_cb, void * cmp_opaque, nacore_filter_cb filter_cb, void * filter_opaque, void * value )
Destroies a list and all its elements.
_NACORE_DEF void nacore_list_free( nacore_list list, nacore_op_cb free_cb, void * free_opaque )
Returns the head (first element) of a list.
_NACORE_DEF nacore_list_elem nacore_list_get_head( nacore_list list )
Gets the number of elements in a list.
_NACORE_DEF size_t nacore_list_get_n_elems( nacore_list list )
Returns the tail (last element) of a list.
_NACORE_DEF nacore_list_elem nacore_list_get_tail( nacore_list list )
Inserts a new element after another given element in a list.
_NACORE_DEF nacore_list_elem nacore_list_insert_after( nacore_list list, nacore_list_elem elem, void * gs_opaque, void * value )
Inserts a new element before another given element in a list.
_NACORE_DEF nacore_list_elem nacore_list_insert_before( nacore_list list, nacore_list_elem elem, void * gs_opaque, void * value )
Merges two lists by appending the elements of src to dest.
_NACORE_DEF nacore_list nacore_list_merge( nacore_list dest, nacore_list src )
Moves an element after another element in a list.
_NACORE_DEF void nacore_list_move_after( nacore_list list, nacore_list_elem dest, nacore_list_elem src )
Moves an element before another element in a list.
_NACORE_DEF void nacore_list_move_before( nacore_list list, nacore_list_elem dest, nacore_list_elem src )
Creates a new list.
_NACORE_DEF nacore_list nacore_list_new( nacore_get_size_cb gs_cb )
Removes an element from a list and returns the value it contains.
_NACORE_DEF void * nacore_list_pop( nacore_list list, nacore_list_elem elem )
Prepends a new element to a list.
_NACORE_DEF nacore_list_elem nacore_list_prepend( nacore_list list, void * gs_opaque, void * value )
Destroies a message box.
_NACORE_DEF void nacore_msg_box_free( nacore_msg_context msg_box )
Creates a new message box.
_NACORE_DEF nacore_msg_context nacore_msg_box_new( void * opaque )
Associates callbacks to a message box.
_NACORE_DEF void nacore_msg_box_set_callbacks( nacore_msg_context msg_box, nacore_msg_status_begin_cb status_begin_cb, nacore_msg_status_end_cb status_end_cb, nacore_msg_text_cb text_cb )
Message context (message box or status message).
typedef struct _nacore_msg_context * nacore_msg_context
Gets the opaque data associated to a given message context.
_NACORE_DEF void * nacore_msg_context_get_opaque( nacore_msg_context context )
Gets the parent message context of a given message context.
_NACORE_DEF nacore_msg_context nacore_msg_context_get_parent( nacore_msg_context context )
Creates a new status message, possibly notifying it to the status message begin callback.
_NACORE_DEF NACORE_FORMAT_PRINTF( 3, 4 ) nacore_msg_context nacore_msg_status_begin(nacore_msg_context context, void *opaque, const char *fmt, ...)
Status message begin callback.
typedef void ( * nacore_msg_status_begin_cb )(nacore_msg_context status_msg, const char *text, void *opaque)
Possibly reports the result of the operation described by a status message to the status message end callback and destroies such status message.
_NACORE_DEF void nacore_msg_status_end( nacore_msg_context status_msg, nacore_msg_result result )
Status message end callback.
typedef void ( * nacore_msg_status_end_cb )(nacore_msg_context status_msg, nacore_msg_result result, void *opaque)
Possibly reports a new text message to the text message callback.
_NACORE_DEF NACORE_FORMAT_PRINTF( 4, 5 ) void nacore_msg_text(nacore_msg_context context, nacore_msg_severity severity, void *opaque, const char *fmt, ...)
Text message callback.
typedef void ( * nacore_msg_text_cb )(nacore_msg_context context, nacore_msg_severity severity, const char *text, void *opaque)
Mutex.
typedef struct _nacore_mutex *nacore_mutex
Destroies a mutex.
_NACORE_DEF void nacore_mutex_free( nacore_mutex mutex )
Acquires the lock on a mutex.
_NACORE_DEF int nacore_mutex_lock( nacore_mutex mutex )
Creates a new mutex.
_NACORE_DEF nacore_mutex nacore_mutex_new()
Attempts to acquire the lock on a recursive mutex.
_NACORE_DEF int nacore_mutex_trylock( nacore_mutex mutex )
Releases the lock on a recursive mutex.
_NACORE_DEF void nacore_mutex_unlock( nacore_mutex mutex )
A function that performs some operation on a value.
typedef void ( * nacore_op_cb )(void *value, void *opaque)
Like nacore_op_cb but also passes message reporting-related data.
typedef void ( * nacore_op_with_msg_cb )(void *value, nacore_msg_context msg_context, void *msg_opaque, void *opaque)
Pointer comparison function.
_NACORE_DEF int nacore_ptr_cmp( const void * v1, const void * v2, void * opaque )
Calculates the number of graphemes in a string.
_NACORE_DEF size_t nacore_strgraphemes( const char * s )
Returns the number of bytes making up a string including the terminating null character.
_NACORE_DEF size_t nacore_string_get_size( const char * s, void * unused )
Creates an auto-allocating list of strings by splitting the given string on boundaries formed by the given separator string.
_NACORE_DEF nacore_list nacore_string_split( const char * s, const char * sep, nacore_filter_cb filter_cb, void * filter_opaque )
Converts a UTF-16LE encoded string to UTF-8.
_NACORE_DEF char * nacore_string_utf16le_to_utf8( const char * str_utf16le )
Converts a UTF-8 encoded string to UTF-16LE.
_NACORE_DEF char * nacore_string_utf8_to_utf16le( const char * str_utf8 )
Calculates the number of graphemes in a string, up to a certain number.
_NACORE_DEF size_t nacore_strngraphemes( const char * s, size_t max )
Gets the number of bytes in a string, not including the terminating null character, up to a certain length.
_NACORE_DEF size_t nacore_strnlen( const char * s, size_t maxlen )
A function that retuns a textual description of some value.
typedef char * ( * nacore_to_string_cb )(const void *value, void *opaque)
Analog of vsprintf() that allocates a string large enough to hold the output including the terminating null character.
_NACORE_DEF NACORE_FORMAT_VPRINTF( 2 ) int nacore_vasprintf(char **strp, const char *fmt, va_list ap)