Nilorea Library tree test.
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#ifndef __windows__
#include <sys/wait.h>
#endif
fprintf(stderr,
" -v version\n"
" -V log level: LOG_INFO, LOG_NOTICE, LOG_ERR, LOG_DEBUG\n"
" -h help\n");
}
while ((
getoptret = getopt(argc, argv,
"hvV:")) != EOF) {
case 'v':
fprintf(stderr, "Date de compilation : %s a %s.\n", __DATE__, __TIME__);
exit(1);
case 'V':
if (!strncmp("LOG_NULL", optarg, 5)) {
} else {
if (!strncmp("LOG_NOTICE", optarg, 6)) {
} else {
if (!strncmp("LOG_INFO", optarg, 7)) {
} else {
if (!strncmp("LOG_ERR", optarg, 5)) {
} else {
if (!strncmp("LOG_DEBUG", optarg, 5)) {
} else {
fprintf(stderr, "%s n'est pas un niveau de log valide.\n", optarg);
exit(-1);
}
}
}
}
}
break;
default:
case '?': {
if (optopt == 'V') {
fprintf(stderr, "\n Missing log level\n");
} else if (optopt == 'p') {
fprintf(stderr, "\n Missing port\n");
} else if (optopt != 's') {
fprintf(stderr, "\n Unknow missing option %c\n", optopt);
}
exit(1);
}
case 'h': {
exit(1);
}
}
}
}
int main(
int argc,
char** argv) {
int data1 = 100;
int data2 = 200;
printf("Found node at (");
printf(", ");
printf(
") with data: %d\n", *(
int*)result->
data_ptr);
} else {
printf("Node not found or has no data.\n");
}
free(qt);
exit(0);
}
void process_args(int argc, char **argv)
#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
COORD_VALUE y
Y coordinate.
QUADTREE_NODE * root
tree list first node
void * data_ptr
Pointer to data, can be NULL.
COORD_VALUE x
X coordinate.
void free_quadtree(QUADTREE_NODE *root)
Function to free the quad tree.
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 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.
structure of a quad tree node
Union to store the coordinate values.
Common headers and low-level functions & define.
N_STR and string function declaration.