Merging of the entire pre5 branch.

This commit is contained in:
Guus Sliepen 2002-02-10 21:57:54 +00:00
parent c2752b961c
commit f0aa9641e8
70 changed files with 2575 additions and 4056 deletions

View file

@ -1,7 +1,7 @@
/*
edge.c -- edge tree management
Copyright (C) 2000,2001 Guus Sliepen <guus@sliepen.warande.net>,
2000,2001 Ivo Timmermans <itimmermans@bigfoot.com>
Copyright (C) 2000-2002 Guus Sliepen <guus@sliepen.warande.net>,
2000-2002 Ivo Timmermans <itimmermans@bigfoot.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: edge.c,v 1.1.2.5 2001/11/16 12:21:49 zarq Exp $
$Id: edge.c,v 1.1.2.6 2002/02/10 21:57:54 guus Exp $
*/
#include "config.h"
@ -30,6 +30,7 @@
#include <list.h>
#include "net.h" /* Don't ask. */
#include "netutl.h"
#include "config.h"
#include "conf.h"
#include <utils.h>
@ -45,12 +46,12 @@ int edge_compare(edge_t *a, edge_t *b)
{
int result;
result = strcmp(a->from->name, b->from->name);
result = strcmp(a->from.node->name, b->from.node->name);
if(result)
return result;
else
return strcmp(a->to->name, b->to->name);
return strcmp(a->to.node->name, b->to.node->name);
}
/* Evil edge_compare() from a parallel universe ;)
@ -59,7 +60,7 @@ int edge_compare(edge_t *a, edge_t *b)
{
int result;
return (result = strcmp(a->from->name, b->from->name)) || (result = strcmp(a->to->name, b->to->name)), result;
return (result = strcmp(a->from.node->name, b->from.node->name)) || (result = strcmp(a->to.node->name, b->to.node->name)), result;
}
*/
@ -69,15 +70,15 @@ int edge_name_compare(edge_t *a, edge_t *b)
int result;
char *name_a1, *name_a2, *name_b1, *name_b2;
if(strcmp(a->from->name, a->to->name) < 0)
name_a1 = a->from->name, name_a2 = a->to->name;
if(strcmp(a->from.node->name, a->to.node->name) < 0)
name_a1 = a->from.node->name, name_a2 = a->to.node->name;
else
name_a1 = a->to->name, name_a2 = a->from->name;
name_a1 = a->to.node->name, name_a2 = a->from.node->name;
if(strcmp(b->from->name, b->to->name) < 0)
name_b1 = b->from->name, name_b2 = b->to->name;
if(strcmp(b->from.node->name, b->to.node->name) < 0)
name_b1 = b->from.node->name, name_b2 = b->to.node->name;
else
name_b1 = b->to->name, name_b2 = b->from->name;
name_b1 = b->to.node->name, name_b2 = b->from.node->name;
result = strcmp(name_a1, name_b1);
@ -151,8 +152,8 @@ void edge_add(edge_t *e)
cp
avl_insert(edge_tree, e);
avl_insert(edge_weight_tree, e);
avl_insert(e->from->edge_tree, e);
avl_insert(e->to->edge_tree, e);
avl_insert(e->from.node->edge_tree, e);
avl_insert(e->to.node->edge_tree, e);
cp
}
@ -161,8 +162,8 @@ void edge_del(edge_t *e)
cp
avl_delete(edge_tree, e);
avl_delete(edge_weight_tree, e);
avl_delete(e->from->edge_tree, e);
avl_delete(e->to->edge_tree, e);
avl_delete(e->from.node->edge_tree, e);
avl_delete(e->to.node->edge_tree, e);
cp
}
@ -170,16 +171,16 @@ edge_t *lookup_edge(node_t *from, node_t *to)
{
edge_t v, *result;
cp
v.from = from;
v.to = to;
v.from.node = from;
v.to.node = to;
result = avl_search(edge_tree, &v);
if(result)
return result;
cp
v.from = to;
v.to = from;
v.from.node = to;
v.to.node = from;
return avl_search(edge_tree, &v);
}
@ -188,14 +189,21 @@ void dump_edges(void)
{
avl_node_t *node;
edge_t *e;
char *from_address, *to_address;
cp
syslog(LOG_DEBUG, _("Edges:"));
for(node = edge_tree->head; node; node = node->next)
{
e = (edge_t *)node->data;
syslog(LOG_DEBUG, _(" %s - %s options %ld weight %d"),
e->from->name, e->to->name, e->options, e->weight);
from_address = address2str(e->from.address);
to_address = address2str(e->to.address);
syslog(LOG_DEBUG, _(" %s at %s port %hd - %s at %s port %hd options %ld weight %d"),
e->from.node->name, from_address, e->from.port,
e->to.node->name, to_address, e->to.port,
e->options, e->weight);
free(from_address);
free(to_address);
}
syslog(LOG_DEBUG, _("End of edges."));