/* pathalias -- by steve bellovin, as told to peter honeyman */
static char *sccsid
= "@(#)mapaux.c 8.2 (down!honey) 86/01/26";
for (hole
= Tabsize
- 1; hole
>= 0 && Table
[hole
] != 0; --hole
)
/* repeatedly move next filled entry into last hole */
for (next
= hole
- 1; next
>= 0; --next
) {
Table
[hole
] = Table
[next
];
Table
[hole
]->n_tloc
= hole
;
while (Table
[--hole
] != 0) /* find next hole */
if ((Gstream
= fopen(Graphout
, "w")) == NULL
) {
fprintf(stderr
, "%s: ", ProgName
);
untangle(); /* untangle net cycles for proper output */
for (i
= Hashpart
; i
< Tabsize
; i
++) {
continue; /* impossible, but ... */
/* a minor optimization ... */
/* pathparse doesn't need these */
char netbuf
[BUFSIZ
], *nptr
= netbuf
;
for (l
= from
->n_link
; l
; l
= l
->l_next
) {
continue; /* oops -- it's me! */
if ((to
->n_flag
& NNET
) == 0) {
/* host -> host -- print host>host */
continue; /* phoney link */
fputs(from
->n_name
, Gstream
);
fputs(to
->n_name
, Gstream
);
/* host -> net -- just cache it for now */
while (to
->n_root
&& to
!= to
->n_root
)
strcpy(nptr
, to
->n_name
);
/* nets -- print host@\tnet,net, ... */
fputs(from
->n_name
, Gstream
);
*netbuf
= '\t'; /* insert tab by killing initial ',' */
fputs(netbuf
, Gstream
); /* skip initial ',' */
* remove cycles in net definitions.
* for each net, run dfs on its neighbors (nets only). if we return to
* a visited node, that's a net cycle. mark the cycle with a pointer
* in the n_root field (which gets us closer to the root of this
* portion of the dfs tree).
for (i
= Hashpart
; i
< Tabsize
; i
++) {
if (n
== 0 || (n
->n_flag
& NNET
) == 0 || n
->n_root
)
for (l
= n
->n_link
; l
; l
= l
->l_next
) {
if ((next
->n_flag
& NNET
) == 0)
if ((next
->n_flag
& INDFS
) == 0) {
if (next
->n_root
!= next
)
n
->n_root
= next
->n_root
;
n
->n_root
= next
->n_root
;
if ((estream
= fopen(Linkout
, "w")) == 0)
for (i
= Hashpart
; i
< Tabsize
; i
++) {
if (n
== 0) /* impossible, but ... */
fprintf(estream
, "%s\t%s(%d)", n
->n_name
,
l
->l_cost
? l
->l_cost
: DEFCOST
);
for (l
= l
->l_next
; l
; l
= l
->l_next
)
fprintf(estream
, ",\n\t%s(%d)", l
->l_to
->n_name
,
l
->l_cost
? l
->l_cost
: DEFCOST
);
* n is node in heap, newp is candidate for new parent.
* choose between newp and n->n_parent for parent.
* return 0 to use newp, non-zero o.w.
register char *opname
, *npname
, *name
;
* given the choice, avoid gatewayed nets,
* thereby placating the FCC or some such.
if (GATEWAYED(newp
) && !GATEWAYED(oldp
))
if (!GATEWAYED(newp
) && GATEWAYED(oldp
))
/* look at real parents, not nets */
while (oldp
->n_flag
& NNET
)
while (newp
->n_flag
& NNET
)
/* use fewer hops, if possible */
metric
= height(oldp
) - height(newp
);
/* find point of departure */
while (*opname
== *npname
&& *npname
== *name
) {
fprintf(stderr
, "%s: error in tie breaker\n", ProgName
);
/* use longest match, if appl. */
if (*opname
== *name
|| *opname
== 0)
if (*npname
== *name
|| *npname
== 0)
/* use shorter host name, if appl. */
metric
= strlen(opname
) - strlen(npname
);
/* use larger lexicographically (no reason) */
metric
= strcmp(opname
, npname
);
while ((n
= n
->n_parent
) != 0)
if ((n
->n_flag
& NNET
) == 0)
i
++; /* should count domains too ... */