![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| struct | LIST |
| Structure of a generic LIST container. More... | |
| struct | LIST_NODE |
| Structure of a generic list node. More... | |
Macros | |
| #define | link_node(__NODE_1, __NODE_2) |
| Macro helper for linking two nodes, with NULL safety. | |
| #define | list_foreach(__ITEM_, __LIST_) |
| ForEach macro helper, safe for node removal during iteration. | |
| #define | list_pop(__LIST_, __TYPE_) |
| Pop macro helper for void pointer casting. | |
| #define | list_shift(__LIST_, __TYPE_) |
| Shift macro helper for void pointer casting. | |
| #define | MAX_LIST_ITEMS SIZE_MAX |
| flag to pass to new_generic_list for the maximum possible number of item in a list | |
| #define | remove_list_node(__LIST_, __NODE_, __TYPE_) |
| Remove macro helper for void pointer casting. | |
| #define | UNLIMITED_LIST_ITEMS 0 |
| flag to pass to new_generic_list for an unlimited number of item in the list. | |
Functions | |
| int | list_destroy (LIST **list) |
| free the list | |
| int | list_empty (LIST *list) |
| empty the list | |
| int | list_empty_with_f (LIST *list, void(*free_fnct)(void *ptr)) |
| empty the list with a custom free function | |
| LIST_NODE * | list_node_pop (LIST *list) |
| pop a node from the end of the list | |
| int | list_node_push (LIST *list, LIST_NODE *node) |
| push a node at the end of the list | |
| LIST_NODE * | list_node_shift (LIST *list) |
| shift a node from the beginning of the list | |
| int | list_node_unshift (LIST *list, LIST_NODE *node) |
| unshift a node at the beginning of the list | |
| void * | list_pop_f (LIST *list) |
| get last ptr from list | |
| int | list_push (LIST *list, void *ptr, void(*destructor)(void *ptr)) |
| add a pointer at the end of the list | |
| int | list_push_sorted (LIST *list, void *ptr, int(*comparator)(const void *a, const void *b), void(*destructor)(void *ptr)) |
| add a pointer sorted via comparator from the end of the list | |
| LIST_NODE * | list_search (LIST *list, const void *ptr) |
| search ptr in list | |
| LIST_NODE * | list_search_with_f (LIST *list, int(*checkfunk)(void *ptr)) |
| search for data in list | |
| void * | list_shift_f (LIST *list, char *file, size_t line) |
| get first ptr from list | |
| int | list_unshift (LIST *list, void *ptr, void(*destructor)(void *ptr)) |
| put a pointer at the beginning of list | |
| int | list_unshift_sorted (LIST *list, void *ptr, int(*comparator)(const void *a, const void *b), void(*destructor)(void *ptr)) |
| put a pointer sorted via comparator from the start to the end | |
| LIST * | new_generic_list (size_t max_items) |
| initialize a list | |
| LIST_NODE * | new_list_node (void *ptr, void(*destructor)(void *ptr)) |
| create a new node | |
| void * | remove_list_node_f (LIST *list, LIST_NODE *node) |
| remove a node | |
| struct LIST |
Structure of a generic LIST container.
| Data Fields | ||
|---|---|---|
| LIST_NODE * | end | pointer to the end of the list |
| size_t | nb_items | number of item currently in the list |
| size_t | nb_max_items |
Maximum number of items in the list. 0 means unlimited |
| LIST_NODE * | start | pointer to the start of the list |
| struct LIST_NODE |
Structure of a generic list node.
| Data Fields | ||
|---|---|---|
| void(*)(void *ptr) | destroy_func | pointer to destructor function if any, else NULL |
| struct LIST_NODE * | next | pointer to the next node |
| struct LIST_NODE * | prev | pointer to the previous node |
| void * | ptr | void pointer to store |
| #define link_node | ( | __NODE_1, | |
| __NODE_2 ) |
Macro helper for linking two nodes, with NULL safety.
Definition at line 78 of file n_list.h.
Referenced by list_node_unshift(), list_push_sorted(), list_unshift(), and list_unshift_sorted().
| #define list_foreach | ( | __ITEM_, | |
| __LIST_ ) |
ForEach macro helper, safe for node removal during iteration.
Definition at line 89 of file n_list.h.
Referenced by _button_neighbour(), _compute_gui_bounds(), _datagrid_resize_hover(), _draw_window(), _find_focused_window(), _find_widget_const(), _find_widget_window(), _find_window_node(), _ht_get_node(), _ht_remove(), _n_gui_window_capture_normalized(), _n_html_attr_lookup(), _n_html_push_js_url(), _pointer_over_window(), _sort_windows_by_zorder(), _splitpane_hit(), _tooltip_widget_at(), _topmost_window_at(), _window_update_content_size(), destroy_threaded_pool(), dump_nodup_log(), find_link(), get_config_section_value(), get_nb_config_file_sections(), get_nb_config_file_sections_entries(), handle_request(), ht_get_node_ex(), ht_put_ptr_ex(), ht_remove_ex(), list_count(), list_search(), list_search_with_f(), main(), main(), main(), mp_emit(), n_cookiejar_add_from_header(), n_cookiejar_build_header(), n_cookiejar_remove(), n_diff_to_unified(), n_fluid_simulate_threaded(), n_gui_apply_adaptive_resize(), n_gui_close_window(), n_gui_count_detached(), n_gui_destroy_ctx(), n_gui_draw(), n_gui_draw_detached(), n_gui_focus_window(), n_gui_hovered_widget(), n_gui_load_layout_json(), n_gui_load_theme_json(), n_gui_process_event(), n_gui_reset_all_widget_themes(), n_gui_save_layout_json(), n_gui_set_default_font(), n_gui_set_focus(), n_gui_set_resize_mode(), n_gui_wants_mouse(), n_gui_widget_set_rect(), n_gui_window_apply_autofit(), n_gui_window_attach(), n_gui_window_autosize(), n_gui_window_detach(), n_gui_window_find_button(), n_gui_window_from_display(), n_gui_window_set_rect_axes(), n_html_extract_forms(), n_html_extract_links(), n_kafka_dump_unprocessed(), netw_close(), test_scripts(), update_completion(), update_definitions(), userlist_send_waiting_msgs(), and userlist_user_send_waiting_msgs().
| #define list_pop | ( | __LIST_, | |
| __TYPE_ ) |
Pop macro helper for void pointer casting.
Definition at line 94 of file n_list.h.
Referenced by main().
| #define list_shift | ( | __LIST_, | |
| __TYPE_ ) |
Shift macro helper for void pointer casting.
Definition at line 96 of file n_list.h.
Referenced by get_bytes_from_msg(), get_int_from_msg(), get_nb_from_msg(), get_nstr_from_msg(), get_str_from_msg(), main(), netw_get_msg(), and netw_send_func().
| #define MAX_LIST_ITEMS SIZE_MAX |
flag to pass to new_generic_list for the maximum possible number of item in a list
Definition at line 75 of file n_list.h.
Referenced by _ht_search(), _ht_search_trie(), _n_html_parse_tag(), _n_html_scan_tags(), create_msg(), ht_resize(), load_config_file(), main(), main(), n_diff_lines(), n_html_extract_forms(), n_html_extract_js_urls(), n_html_extract_links(), n_html_extract_scripts(), n_kafka_new(), n_kafka_poll(), n_sitemap_extract_urls(), netw_accept_from(), netw_accept_nonblock_from(), netw_adopt_client_fd(), netw_bind_udp(), netw_connect(), netw_connect_nonblock(), netw_connect_to(), netw_connect_udp(), netw_make_listening(), netw_new(), netw_ssl_connect(), netw_ssl_connect_client_to(), new_ht(), new_thread_pool(), run_server(), tree_create_node(), tree_insert_child(), and userlist_new().
| #define remove_list_node | ( | __LIST_, | |
| __NODE_, | |||
| __TYPE_ ) |
Remove macro helper for void pointer casting.
Definition at line 98 of file n_list.h.
Referenced by _empty_ht(), _ht_remove(), free_emitters(), free_particle_system(), ht_remove_ex(), main(), manage_particle_ex(), n_kafka_get_event(), n_kafka_poll(), netw_pool_remove(), refresh_thread_pool(), and remove_emitter().
| #define UNLIMITED_LIST_ITEMS 0 |
flag to pass to new_generic_list for an unlimited number of item in the list.
Can be dangerous !
Definition at line 73 of file n_list.h.
Referenced by init_particle_system(), main(), n_git_list_branches(), n_git_log(), n_git_status(), n_gui_add_window(), and n_gui_new_ctx().
| int list_destroy | ( | LIST ** | list | ) |
free the list
free the list
Call the destructor each time.
| list | The list to destroy. An already empty or null list will cause an error and a _log message. |
Definition at line 548 of file n_list.c.
References __n_assert, Free, list_empty(), LOG_ERR, and n_log.
Referenced by _destroy_ht(), _destroy_window(), _ht_search(), _ht_search_trie(), _n_html_form_free(), _n_html_tag_free(), _n_mock_request_clean(), create_msg(), delete_msg(), destroy_config_file(), destroy_n_fluid(), destroy_threaded_pool(), free_entry(), free_particle_system(), ht_get_completion_list(), ht_resize(), load_config_file(), main(), main(), main(), n_cookiejar_free(), n_diff_result_free(), n_gui_destroy_ctx(), n_gui_new_ctx(), n_html_extract_forms(), n_html_extract_links(), n_html_forms_free(), n_html_links_free(), n_http_multipart_free(), n_kafka_delete(), n_kafka_event_destroy_ptr(), netw_close(), netw_set(), new_ht(), new_thread_pool(), run_server(), tree_delete_node(), update_completion(), and userlist_destroy().
| int list_empty | ( | LIST * | list | ) |
empty the list
empty the list
| list | The list to empty. An already empty or null list will cause an error and a _log message. |
Definition at line 501 of file n_list.c.
References __n_assert, LIST_NODE::destroy_func, LIST::end, Free, LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::ptr, and LIST::start.
Referenced by empty_msg(), list_destroy(), main(), netw_set(), userlist_del_user(), userlist_send_waiting_msgs(), and userlist_user_send_waiting_msgs().
| int list_empty_with_f | ( | LIST * | list, |
| void(* | free_fnct )(void *ptr) ) |
empty the list with a custom free function
empty the list with a custom free function
| list | The list to empty. An already empty or null list will cause an error and a _log message. |
| free_fnct | a function ptr to a void func( void *ptr ) |
Definition at line 526 of file n_list.c.
References __n_assert, LIST::end, Free, LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::ptr, and LIST::start.
pop a node from the end of the list
pop a node from the end of the list
| list | An initilized list container. A null value will cause an error and a _log message. |
Definition at line 143 of file n_list.c.
References __n_assert, LIST::end, LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::prev, and LIST::start.
Referenced by main().
push a node at the end of the list
push a node at the end of the list
| list | An initilized list container. A null value will cause an error and a _log message. |
| node | The node pointer you want to put in the list. A null value will cause an error and a _log message. |
Definition at line 117 of file n_list.c.
References __n_assert, LIST::end, LOG_ERR, n_log, LIST::nb_items, LIST::nb_max_items, LIST_NODE::next, LIST_NODE::prev, and LIST::start.
Referenced by ht_resize(), main(), and tree_insert_child().
shift a node from the beginning of the list
shift a node from the beginning of the list
| list | An initilized list container. A null value will cause an error and a _log message. |
Definition at line 170 of file n_list.c.
References __n_assert, LIST::end, LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::prev, and LIST::start.
Referenced by ht_resize(), and main().
unshift a node at the beginning of the list
unshift a node at the beginning of the list
| list | An initilized list container. A null value will cause an error and a _log message. |
| node | The node pointer you wan to put in the list. A null value will cause an error and a _log message. |
Definition at line 200 of file n_list.c.
References __n_assert, LIST::end, link_node, LOG_ERR, n_log, LIST::nb_items, LIST::nb_max_items, LIST_NODE::next, LIST_NODE::prev, and LIST::start.
Referenced by main().
| void * list_pop_f | ( | LIST * | list | ) |
get last ptr from list
get last ptr from list
| list | An initilized list container. A null value will cause an error and a _log message. |
Definition at line 403 of file n_list.c.
References __n_assert, LIST::end, Free, LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::prev, LIST_NODE::ptr, and LIST::start.
| int list_push | ( | LIST * | list, |
| void * | ptr, | ||
| void(* | destructor )(void *ptr) ) |
add a pointer at the end of the list
add a pointer at the end of the list
| list | An initilized list container. A null value will cause an error and a _log message. |
| ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 228 of file n_list.c.
References __n_assert, LIST::end, LOG_ERR, n_log, LIST::nb_items, LIST::nb_max_items, new_list_node(), LIST_NODE::next, LIST_NODE::prev, and LIST::start.
Referenced by _ht_depth_first_search(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), _ht_search(), _ht_search_trie_helper(), _n_html_parse_tag(), _n_html_push_link(), _n_mock_parse_request(), _sort_windows_by_zorder(), add_bytes_to_msg(), add_emitter(), add_int_to_msg(), add_nb_to_msg(), add_nstrdup_to_msg(), add_nstrptr_to_msg(), add_particle(), add_particle_at(), add_strdup_to_msg(), add_threaded_process(), ht_get_completion_list(), ht_put_ptr_ex(), list_push_sorted(), list_unshift_sorted(), load_config_file(), main(), main(), n_cookiejar_add_from_header(), n_git_list_branches(), n_git_log(), n_git_status(), n_gui_add_button(), n_gui_add_checkbox(), n_gui_add_combobox(), n_gui_add_custom(), n_gui_add_datagrid(), n_gui_add_dropmenu(), n_gui_add_hexview(), n_gui_add_image(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_markdownview(), n_gui_add_progressbar(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), n_gui_add_splitpane(), n_gui_add_syntaxview(), n_gui_add_textarea(), n_gui_add_window(), n_gui_raise_window(), n_html_extract_forms(), n_html_extract_scripts(), n_http_parse_multipart(), n_kafka_poll(), n_kafka_produce(), n_sitemap_extract_urls(), netw_add_msg(), netw_add_msg_ex(), netw_pool_add(), netw_recv_func(), new_n_fluid(), process_args(), run_server(), scan_dir_ex(), and userlist_user_add_waiting_msg().
| int list_push_sorted | ( | LIST * | list, |
| void * | ptr, | ||
| int(* | comparator )(const void *a, const void *b), | ||
| void(* | destructor )(void *ptr) ) |
add a pointer sorted via comparator from the end of the list
add a pointer sorted via comparator from the end of the list
| list | An initilized list container. A null value will cause an error and a _log message. |
| ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
| comparator | A pointer to a function which take two void * pointers and return an int. |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 261 of file n_list.c.
References __n_assert, LIST::end, link_node, list_push(), list_unshift(), LOG_ERR, n_log, LIST::nb_items, LIST::nb_max_items, new_list_node(), LIST_NODE::next, LIST_NODE::prev, and LIST_NODE::ptr.
Referenced by main(), and n_scan_dir().
search ptr in list
| list | The target list |
| ptr | Searched pointer |
Definition at line 469 of file n_list.c.
References __n_assert, and list_foreach.
Referenced by main(), and netw_pool_remove().
search for data in list
search for data in list
| list | The target list |
| checkfunk | Function pointer who should return 1 if it matches or 0 if it's not |
Definition at line 485 of file n_list.c.
References __n_assert, and list_foreach.
| void * list_shift_f | ( | LIST * | list, |
| char * | file, | ||
| size_t | line ) |
get first ptr from list
get first ptr from list
Helper function for the list_shift macro.
| list | An initilized list container. A null value will cause an error and a _log message. |
| file | holder for FILE |
| line | holder for LINE |
Definition at line 436 of file n_list.c.
References __n_assert, LIST::end, Free, line(), LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::prev, LIST_NODE::ptr, and LIST::start.
| int list_unshift | ( | LIST * | list, |
| void * | ptr, | ||
| void(* | destructor )(void *ptr) ) |
put a pointer at the beginning of list
put a pointer at the beginning of list
| list | An initilized list container. A null value will cause an error and a _log message. |
| ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 317 of file n_list.c.
References __n_assert, LIST::end, link_node, LOG_ERR, n_log, LIST::nb_items, LIST::nb_max_items, new_list_node(), and LIST::start.
Referenced by _emit(), list_push_sorted(), list_unshift_sorted(), main(), and n_gui_lower_window().
| int list_unshift_sorted | ( | LIST * | list, |
| void * | ptr, | ||
| int(* | comparator )(const void *a, const void *b), | ||
| void(* | destructor )(void *ptr) ) |
put a pointer sorted via comparator from the start to the end
put a pointer sorted via comparator from the start to the end
| list | An initilized list container. A null value will cause an error and a _log message. |
| ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
| comparator | A pointer to a function which take two void * pointers and return an int. |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 349 of file n_list.c.
References __n_assert, link_node, list_push(), list_unshift(), LOG_ERR, n_log, LIST::nb_items, LIST::nb_max_items, new_list_node(), LIST_NODE::next, LIST_NODE::prev, and LIST::start.
Referenced by main().
| LIST * new_generic_list | ( | size_t | max_items | ) |
initialize a list
initialize a list
| max_items | Specify a max size for the list container. From UNLIMITED_LIST_ITEMS (0) to MAX_LIST_ITEMS (SIZE_MAX). |
Definition at line 37 of file n_list.c.
References __n_assert, LIST::end, Malloc, LIST::nb_items, LIST::nb_max_items, and LIST::start.
Referenced by _ht_search(), _ht_search_trie(), _n_html_parse_tag(), _n_html_scan_tags(), _n_mock_parse_request(), create_msg(), ht_get_completion_list(), ht_resize(), init_particle_system(), load_config_file(), main(), main(), main(), n_cookiejar_new(), n_diff_lines(), n_git_list_branches(), n_git_log(), n_git_status(), n_gui_add_window(), n_gui_new_ctx(), n_html_extract_forms(), n_html_extract_js_urls(), n_html_extract_links(), n_html_extract_scripts(), n_http_parse_multipart(), n_kafka_new(), n_kafka_poll(), n_sitemap_extract_urls(), netw_new(), new_ht(), new_n_fluid(), new_thread_pool(), run_server(), tree_create_node(), tree_insert_child(), and userlist_new().
| LIST_NODE * new_list_node | ( | void * | ptr, |
| void(* | destructor )(void *ptr) ) |
create a new node
create a new node
| ptr | The pointer you want to put in the node. |
| destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 57 of file n_list.c.
References __n_assert, LIST_NODE::destroy_func, LOG_ERR, Malloc, n_log, LIST_NODE::next, LIST_NODE::prev, and LIST_NODE::ptr.
Referenced by list_push(), list_push_sorted(), list_unshift(), list_unshift_sorted(), main(), and tree_insert_child().
remove a node
remove a node
| list | The list to pick in |
| node | The node to remove in the list |
Definition at line 76 of file n_list.c.
References __n_assert, LIST::end, Free, LOG_ERR, n_log, LIST::nb_items, LIST_NODE::next, LIST_NODE::prev, LIST_NODE::ptr, and LIST::start.
Referenced by _sort_windows_by_zorder(), n_cookiejar_clear(), n_cookiejar_remove(), n_gui_lower_window(), n_gui_raise_window(), run_server(), and tree_delete_node().