astyle --recursive --indent=spaces=2 --style=kr --indent-col1-comments --break-blocks --convert-tabs --max-code-length=200

This is done for better merging branch/LG_PRE_RELEASE_0.3 into trunk (same process is applied on this branch)

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7073 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Lionel Gauthier
2015-04-09 09:29:12 +00:00
parent f0a8a0b3b5
commit 059a0a3fdc
2044 changed files with 1182666 additions and 1145123 deletions
+214 -229
View File
@@ -33,7 +33,7 @@
* \date 2011
* \version 0.1
* \company Eurecom
* \email:
* \email:
* \note
* \warning
*/
@@ -119,15 +119,14 @@ add_entry (node_struct * node, node_list * node_vector_end)
node_list *entry = malloc (sizeof (struct node_list_struct));
entry->node = node;
entry->next = NULL;
if (node_vector_end == NULL)
{
return entry;
}
else
{
node_list *tmp = node_vector_end;
tmp->next = entry;
}
if (node_vector_end == NULL) {
return entry;
} else {
node_list *tmp = node_vector_end;
tmp->next = entry;
}
return entry;
}
@@ -137,45 +136,39 @@ remove_node_entry (node_struct * node, node_list * node_vector)
{
node_list *list = node_vector;
node_list *tmp, *toremove;
if (list == NULL)
{
if (list == NULL) {
return NULL;
}
if (list->node->id == node->id) {
// TODO delete the entry
toremove = list;
LOG_D (OMG, "removed entry for node %d \n", list->node->id);
if (list->next == NULL) {
node_vector = NULL;
return NULL;
} else {
node_vector = list->next;
}
if (list->node->id == node->id)
{
// TODO delete the entry
toremove = list;
LOG_D (OMG, "removed entry for node %d \n", list->node->id);
if (list->next == NULL)
{
node_vector = NULL;
return NULL;
}
else
{
node_vector = list->next;
}
}
else
{
while (list->next != NULL)
{
tmp = list;
if (list->next->node->id == node->id)
{
toremove = tmp; // TODO delete the entry
tmp = list->next->next;
if (tmp != NULL)
{
list->next = tmp;
}
else
{
list->next = NULL;
}
}
}
} else {
while (list->next != NULL) {
tmp = list;
if (list->next->node->id == node->id) {
toremove = tmp; // TODO delete the entry
tmp = list->next->next;
if (tmp != NULL) {
list->next = tmp;
} else {
list->next = NULL;
}
}
}
}
return node_vector;
}
@@ -185,53 +178,53 @@ void
display_node_list (node_list * node_vector)
{
node_list *tmp = node_vector;
if (tmp == NULL)
{
#ifdef STANDALONE
printf ("Empty Node_list\n");
#else
LOG_I (OMG, "Empty Node_list\n");
#endif
}
while (tmp != NULL)
{
/*LOG_I(OMG,"[%s][%s] Node of ID %d is %s. Now, it is at location (%.3f, %.3f)\n",
map_int_to_str(mob_type, tmp->node->generator),
map_int_to_str(nodes_type, tmp->node->type),
tmp->node->ID,
map_int_to_str(nodes_status, tmp->node->mobile),
tmp->node->X_pos,
tmp->node->Y_pos ); */
LOG_I (OMG, "[%s %d][%s] \t at (%.3f, %.3f)\n",
map_int_to_str(nodes_type, tmp->node->type),
tmp->node->id,
map_int_to_str(mob_type, tmp->node->generator),
tmp->node->x_pos, tmp->node->y_pos);
// two options: view node mobility of one node during the entire simulation or just a snapshot of all nodes for different timestamps
// note:gnu plot requiredifferent files for each timestamp
//use a python script to postprocess the positions, check the
// support: view node mobility of one node during the entire simulation OR only one snapshot
LOG_F(OMG,"%d; %.3f; %.3f; %.3f\n",
tmp->node->id,
tmp->node->x_pos, tmp->node->y_pos);
//LOG_I(OMG, "node number %d\tstatus(fix/mobile) %d\tX_pos %.2f\tY_pos %.2f\tnode_type(eNB, UE)%d\t", tmp->node->ID,tmp->node->mobile, tmp->node->X_pos,tmp->node->Y_pos, tmp->node->type);
//LOG_D(OMG, "mob->X_from %.3f\tmob->Y_from %.3f\tmob->X_to %.3f\tmob->Y_to %.3f\t", tmp->node->mob->X_from,tmp->node->mob->Y_from, tmp->node->mob->X_to, tmp->node->mob->Y_to );
tmp = tmp->next;
}
if (tmp == NULL) {
#ifdef STANDALONE
printf ("Empty Node_list\n");
#else
LOG_I (OMG, "Empty Node_list\n");
#endif
}
while (tmp != NULL) {
/*LOG_I(OMG,"[%s][%s] Node of ID %d is %s. Now, it is at location (%.3f, %.3f)\n",
map_int_to_str(mob_type, tmp->node->generator),
map_int_to_str(nodes_type, tmp->node->type),
tmp->node->ID,
map_int_to_str(nodes_status, tmp->node->mobile),
tmp->node->X_pos,
tmp->node->Y_pos ); */
LOG_I (OMG, "[%s %d][%s] \t at (%.3f, %.3f)\n",
map_int_to_str(nodes_type, tmp->node->type),
tmp->node->id,
map_int_to_str(mob_type, tmp->node->generator),
tmp->node->x_pos, tmp->node->y_pos);
// two options: view node mobility of one node during the entire simulation or just a snapshot of all nodes for different timestamps
// note:gnu plot requiredifferent files for each timestamp
//use a python script to postprocess the positions, check the
// support: view node mobility of one node during the entire simulation OR only one snapshot
LOG_F(OMG,"%d; %.3f; %.3f; %.3f\n",
tmp->node->id,
tmp->node->x_pos, tmp->node->y_pos);
//LOG_I(OMG, "node number %d\tstatus(fix/mobile) %d\tX_pos %.2f\tY_pos %.2f\tnode_type(eNB, UE)%d\t", tmp->node->ID,tmp->node->mobile, tmp->node->X_pos,tmp->node->Y_pos, tmp->node->type);
//LOG_D(OMG, "mob->X_from %.3f\tmob->Y_from %.3f\tmob->X_to %.3f\tmob->Y_to %.3f\t", tmp->node->mob->X_from,tmp->node->mob->Y_from, tmp->node->mob->X_to, tmp->node->mob->Y_to );
tmp = tmp->next;
}
}
void
display_node_position (int id, int generator, int type, int mobile, double x,
double y)
double y)
{
LOG_I (OMG,
"[%s][%s] Node of ID %d is %s. Now, it is at location (%.2f, %.2f) \n",
map_int_to_str (mob_type, generator), map_int_to_str (nodes_type,
type), id,
map_int_to_str (nodes_status, mobile), x, y);
"[%s][%s] Node of ID %d is %s. Now, it is at location (%.2f, %.2f) \n",
map_int_to_str (mob_type, generator), map_int_to_str (nodes_type,
type), id,
map_int_to_str (nodes_status, mobile), x, y);
}
node_list *
@@ -240,14 +233,15 @@ filter (node_list * vector, int node_type)
node_list *tmp1, *tmp2;
tmp1 = vector;
tmp2 = NULL;
while (tmp1 != NULL)
{
if (tmp1->node->type == node_type)
{
tmp2 = add_entry (tmp1->node, tmp2);
}
tmp1 = tmp1->next;
while (tmp1 != NULL) {
if (tmp1->node->type == node_type) {
tmp2 = add_entry (tmp1->node, tmp2);
}
tmp1 = tmp1->next;
}
return tmp2;
}
@@ -267,60 +261,60 @@ remove_node (node_list * list, int nid, int node_type)
int found;
node_list *current, *previous;
//int cond=0;
//int i=0;
if (list == NULL)
{
found = 1; //false
if (list == NULL) {
found = 1; //false
return NULL;
} else {
//start search
current = list;
while ((current != NULL)
&& ((current->node->id != nid)
|| (current->node->type != node_type))) {
previous = current; // previous hobbles after
current = current->next;
}
//holds: current = NULL or type != node_type or.., but not both
if (current == NULL) {
found = 1;
LOG_E (OMG, " Element to remove is not found\n ");
return NULL;
} //value not found
else {
found = 0; // true value found
if (current == list) {
list = current->next;
LOG_D (OMG, "Element to remove is found at beginning\n");
}
else {
previous->next = current->next;
}
delete_node_entry (current); // freeing memory
current = NULL;
}
else
{ //start search
current = list;
while ((current != NULL)
&& ((current->node->id != nid)
|| (current->node->type != node_type)))
{
previous = current; // previous hobbles after
current = current->next;
}
//holds: current = NULL or type != node_type or.., but not both
if (current == NULL)
{
found = 1;
LOG_E (OMG, " Element to remove is not found\n ");
return NULL;
} //value not found
else
{
found = 0; // true value found
if (current == list)
{
list = current->next;
LOG_D (OMG, "Element to remove is found at beginning\n");
}
else
{
previous->next = current->next;
}
delete_node_entry (current); // freeing memory
current = NULL;
}
return list;
}
return list;
}
}
int
length (char *s)
{
int count = 0;
while (s[count] != '\0')
{
++count;
}
while (s[count] != '\0') {
++count;
}
return count;
}
@@ -331,36 +325,34 @@ find_node (node_list * list, int nid, int node_type)
int found;
node_list *current;
if (list == NULL)
{
printf (" Node_LIST for nodeID %d is NULL \n ", nid);
return NULL;
if (list == NULL) {
printf (" Node_LIST for nodeID %d is NULL \n ", nid);
return NULL;
} else {
//start search
current = list;
while ((current != NULL)
&& ((current->node->id != nid)
|| (current->node->type != node_type))) {
current = current->next;
}
else
{ //start search
current = list;
while ((current != NULL)
&& ((current->node->id != nid)
|| (current->node->type != node_type)))
{
current = current->next;
}
//holds: current = NULL or type != node_type or.., but not both
if (current == NULL)
{
found = 1;
LOG_D (OMG,
" Element to find in Node_Vector with ID: %d could not be found\n ",
nid);
return NULL;
} //value not found
else
{
//printf(" found a node for nodeID %d \n ",nID);
return current->node;
}
//holds: current = NULL or type != node_type or.., but not both
if (current == NULL) {
found = 1;
LOG_D (OMG,
" Element to find in Node_Vector with ID: %d could not be found\n ",
nid);
return NULL;
} //value not found
else {
//printf(" found a node for nodeID %d \n ",nID);
return current->node;
}
return NULL;
}
}
node_list *
@@ -368,20 +360,18 @@ clear_node_list (node_list * list)
{
node_list *tmp;
if (list == NULL)
{
return NULL;
}
else
{
while (list->next != NULL)
{
tmp = list;
list = list->next;
delete_node_entry (tmp);
}
delete_node_entry (list); // clearing the last one
if (list == NULL) {
return NULL;
} else {
while (list->next != NULL) {
tmp = list;
list = list->next;
delete_node_entry (tmp);
}
delete_node_entry (list); // clearing the last one
}
return NULL;
}
@@ -391,23 +381,22 @@ reset_node_list (node_list * list)
{
node_list *tmp;
node_list *last = list;
if (list == NULL)
{
//printf("Node_list is NULL\n");
return NULL;
}
else
{
while (list->next != NULL)
{
tmp = list;
list = list->next;
tmp->node = NULL;
//free(tmp);
}
list->node = NULL; // clearing the last one | JHNOTE: dangerous here: the pointer is not NULL, but node is...that leads to segfault...
//free(last);
if (list == NULL) {
//printf("Node_list is NULL\n");
return NULL;
} else {
while (list->next != NULL) {
tmp = list;
list = list->next;
tmp->node = NULL;
//free(tmp);
}
list->node = NULL; // clearing the last one | JHNOTE: dangerous here: the pointer is not NULL, but node is...that leads to segfault...
//free(last);
}
return list;
}
@@ -417,22 +406,20 @@ clear_string_list (string_list * list)
{
string_list *tmp;
if (list == NULL)
{
return NULL;
}
else
{
while (list->next != NULL)
{
tmp = list;
list = list->next;
free (tmp->string);
tmp->string = NULL;
free (tmp);
}
list->string = NULL; // clearing the last one | JHNOTE: dangerous here: the pointer is not NULL, but node is...that leads to segfault...
if (list == NULL) {
return NULL;
} else {
while (list->next != NULL) {
tmp = list;
list = list->next;
free (tmp->string);
tmp->string = NULL;
free (tmp);
}
list->string = NULL; // clearing the last one | JHNOTE: dangerous here: the pointer is not NULL, but node is...that leads to segfault...
}
return list;
}
@@ -445,36 +432,34 @@ clear_string_list (string_list * list)
int
map_str_to_int (mapping * map, const char *str)
{
while (1)
{
if (map->name == NULL)
{
return (-1);
}
if (!strcmp (map->name, str))
{
return (map->value);
}
map++;
while (1) {
if (map->name == NULL) {
return (-1);
}
if (!strcmp (map->name, str)) {
return (map->value);
}
map++;
}
}
/* map an int to a string. Takes a mapping array and a value */
char *
map_int_to_str (mapping * map, int val)
{
while (1)
{
if (map->name == NULL)
{
return NULL;
}
if (map->value == val)
{
return map->name;
}
map++;
while (1) {
if (map->name == NULL) {
return NULL;
}
if (map->value == val) {
return map->name;
}
map++;
}
}