44 " -V log level: LOG_INFO, LOG_NOTICE, LOG_ERR, LOG_DEBUG\n"
57 while ((
getoptret = getopt(argc, argv,
"hvV:")) != EOF) {
60 fprintf(stderr,
"Date de compilation : %s a %s.\n", __DATE__, __TIME__);
63 if (!strcmp(
"LOG_NULL", optarg))
65 else if (!strcmp(
"LOG_NOTICE", optarg))
67 else if (!strcmp(
"LOG_INFO", optarg))
69 else if (!strcmp(
"LOG_ERR", optarg))
71 else if (!strcmp(
"LOG_DEBUG", optarg))
74 fprintf(stderr,
"%s n'est pas un niveau de log valide.\n", optarg);
81 fprintf(stderr,
"\n Missing log level\n");
82 }
else if (optopt ==
'p') {
83 fprintf(stderr,
"\n Missing port\n");
84 }
else if (optopt !=
's') {
85 fprintf(stderr,
"\n Unknow missing option %c\n", optopt);
99int main(
int argc,
char** argv) {
114 child1_data.
type = 0;
120 child2_data.
type = 0;
126 grandchild_data.
type = 0;
167 printf(
"Found node at (");
171 printf(
") with data: %d\n", *(
int*)result->
data_ptr);
173 printf(
"Node not found or has no data.\n");
void process_args(int argc, char **argv)
#define __n_assert(__ptr, __ret)
macro to assert things
#define Free(__ptr)
Free Handler to get errors.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_NULL
no log output
#define LOG_INFO
informational
print_func print
pointer to print function
TREE_NODE * root
pointer to first node
size_t nb_nodes
number of nodes in the tree
COORD_VALUE z
z coordinate
COORD_VALUE y
Y coordinate.
QUADTREE_NODE * root
tree list first node
union NODE_DATA_TYPES value
node value
NODE_DATA data
structure holding values for node
COORD_VALUE x
x coordinate
void * data_ptr
Pointer to data, can be NULL.
POINT3D point
Point represented by this node.
COORD_VALUE y
y coordinate
COORD_VALUE x
X coordinate.
void free_octree_node(OCTREE_NODE *node)
recursive function to free an OCTREE node and its children
void insert_octree(OCTREE *octree, POINT3D point, void *data_ptr)
Insert a point into the OCTREE.
int tree_insert_child(TREE_NODE *parent, TREE_NODE *child)
insert a child node into the parent node
void free_quadtree(QUADTREE_NODE *root)
Function to free the quad tree.
TREE * new_tree()
create a new TREE
TREE_NODE * tree_create_node(NODE_DATA value, void(*destroy_func)(void *ptr))
create a TREE node
QUADTREE_NODE * search(QUADTREE *qt, QUADTREE_NODE *root, COORD_VALUE x, COORD_VALUE y)
Function to search for a point in the quad tree.
void free_octree(OCTREE *octree)
free the OCTREE
void tree_destroy(TREE **tree)
destroy a TREE
OCTREE_NODE * create_octree_node(POINT3D point, void *data_ptr)
create and OCTREE node
OCTREE * create_octree(int type)
Create a new OCTREE with a specified coordinate type.
int tree_delete_node(TREE *tree, TREE_NODE *node)
delete a TREE node
void insert(QUADTREE *qt, QUADTREE_NODE **root, COORD_VALUE x, COORD_VALUE y, void *data_ptr)
Function to insert a point into the quad tree.
QUADTREE * create_quadtree(int coord_type)
Function to create a new quad tree.
QUADTREE_NODE * create_node(COORD_VALUE x, COORD_VALUE y, void *data_ptr)
function to create a new quad tree node
structure of a TREE node data
structure of an OCTREE node
Structure for a POINT3D in the 3D space.
structure of a quad tree node
structure of a n-ary TREE node
Union to store the coordinate values.
Common headers and low-level functions & define.
N_STR and string function declaration.