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 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_nl(char **strp, const char *fmt, ...)
AVL tree.
typedef struct _nacore_avl_tree * nacore_avl_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
Destroys a tree element.
_NACORE_DEF void nacore_avl_tree_elem_free( nacore_avl_tree_elem 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 )
Inserts a tree element into a tree.
_NACORE_DEF void nacore_avl_tree_elem_insert( nacore_avl_tree tree, nacore_avl_tree_elem elem, void * cmp_opaque )
Creates a new tree element without adding it to a tree.
_NACORE_DEF nacore_avl_tree_elem nacore_avl_tree_elem_new( void * value )
Removes an element from a tree without destroying it.
_NACORE_DEF void nacore_avl_tree_elem_pop( 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 )
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 )
Destroys 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 )
Creates a new tree element and inserts it 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, destroys it 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-16 character.
_NACORE_DEF size_t nacore_char_utf16_decode( const uint16_t * utf16c, uint32_t * cp )
Encodes a Unicode code point into an UTF-16 character.
_NACORE_DEF size_t nacore_char_utf16_encode( uint16_t * utf16c, 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 extern 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
Creates a new list element and appends it to a list.
_NACORE_DEF nacore_list_elem nacore_list_append( nacore_list list, void * gs_opaque, void * value )
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
Appends a list element to a list.
_NACORE_DEF void nacore_list_elem_append( nacore_list list, nacore_list_elem elem )
Destroys a list element.
_NACORE_DEF void nacore_list_elem_free( nacore_list_elem 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 )
Inserts a list element after another element in a list.
_NACORE_DEF void nacore_list_elem_insert_after( nacore_list list, nacore_list_elem elem, nacore_list_elem after )
Inserts a list element before another element in a list.
_NACORE_DEF void nacore_list_elem_insert_before( nacore_list list, nacore_list_elem elem, nacore_list_elem before )
Creates a new list element without adding it to a list.
_NACORE_DEF nacore_list_elem nacore_list_elem_new( void * value )
Removes an element from a list without destroying it.
_NACORE_DEF void nacore_list_elem_pop( nacore_list list, nacore_list_elem elem )
Prepends a list element to a list.
_NACORE_DEF void nacore_list_elem_prepend( 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 )
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 )
Destroys 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 )
Creates a new list element and inserts it after another 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 )
Creates a new list element and inserts it before another 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, destroys it and returns the value it contains.
_NACORE_DEF void * nacore_list_pop( nacore_list list, nacore_list_elem elem )
Creates a new list element and prepends it to a list.
_NACORE_DEF nacore_list_elem nacore_list_prepend( nacore_list list, void * gs_opaque, void * value )
Duplicates a locale object.
_NACORE_DEF nacore_locale nacore_locale_dup( nacore_locale locale )
Releases the resources allocated for a locale object.
_NACORE_DEF void nacore_locale_free( nacore_locale locale )
Creates a new locale object or modifies an existing one.
_NACORE_DEF nacore_locale nacore_locale_new( int category_mask, const char * locale, nacore_locale base )
Sets or gets the current locale of the calling thread.
_NACORE_DEF nacore_locale nacore_locale_use( nacore_locale locale )
Destroys 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 destroys 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
Destroys 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 mutex.
_NACORE_DEF int nacore_mutex_trylock( nacore_mutex mutex )
Releases the lock on a 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)
Pointer comparison function.
_NACORE_DEF int nacore_ptr_cmp( const void * v1, const void * v2, void * opaque )
Semaphore.
typedef struct _nacore_sem *nacore_sem
Destroys a semaphore.
_NACORE_DEF void nacore_sem_free( nacore_sem sem )
Creates a new semaphore.
_NACORE_DEF nacore_sem nacore_sem_new( unsigned int value )
Unlocks a semaphore.
_NACORE_DEF int nacore_sem_post( nacore_sem sem )
Attempts to lock a semaphore.
_NACORE_DEF int nacore_sem_trywait( nacore_sem sem )
Locks a semaphore.
_NACORE_DEF int nacore_sem_wait( nacore_sem sem )
Analog of strcpy() that allocates a string large enough to hold the output including the terminating null character.
_NACORE_DEF char * nacore_strdup( const char * s, void * unused )
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-16 encoded string to UTF-8 into a previously allocated buffer, including the terminating null character.
_NACORE_DEF void nacore_string_utf16_to_utf8( char * buf, const uint16_t * str_utf16 )
Converts a UTF-16 encoded string to UTF-8, allocating the output string.
_NACORE_DEF char * nacore_string_utf16_to_utf8_a( const uint16_t * str_utf16 )
Calculates the number of bytes needed to store the UTF-8 representation of a UTF-16 encoded string, excluding the terminating null character.
_NACORE_DEF size_t nacore_string_utf16_to_utf8_len( const uint16_t * str_utf16 )
Converts a UTF-8 encoded string to UTF-16 into a previously allocated buffer, including the terminating null character.
_NACORE_DEF void nacore_string_utf8_to_utf16( uint16_t * buf, const char * str_utf8 )
Converts a UTF-8 encoded string to UTF-16, allocating the output string.
_NACORE_DEF uint16_t * nacore_string_utf8_to_utf16_a( const char * str_utf8 )
Calculates the number of bytes needed to store the UTF-16 representation of a UTF-8 encoded string, excluding the terminating null character.
_NACORE_DEF size_t nacore_string_utf8_to_utf16_len( const char * str_utf8 )
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 )
Creates a new thread.
_NACORE_DEF int nacore_thread_create( nacore_thread * thread, size_t stack_size, void (*start_routine)(void *arg), void * arg )
Compares two thread identifiers.
_NACORE_DEF char nacore_thread_equal( nacore_thread t1, nacore_thread t2 )
Terminates the calling thread.
_NACORE_DEF void nacore_thread_exit()
Waits for termination of the specified thread.
_NACORE_DEF int nacore_thread_join( nacore_thread thread )
Gets an identifier for the calling thread.
_NACORE_DEF nacore_thread nacore_thread_self()
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)
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_nl(char **strp, const char *fmt, va_list ap)