/* pathalias -- by steve bellovin, as told to peter honeyman */
static char *sccsid
= "@(#)printit.c 8.2 (down!honey) 86/01/29";
/* use lots of char bufs -- profiling indicates this costs about 5 kbytes */
/* in practice, even the longest paths are < 100 bytes */
printf("%ld\t", (long) Home
->n_cost
);
printf("%s\t%%s\n", Home
->n_name
);
for (l
= Home
->n_link
; l
; l
= l
->l_next
) {
/* preorder traversal of shortest path tree */
setpath(l
, ppath
, npath
);
if ((n
->n_flag
& NNET
) || ISADOMAIN(n
))
printnet(n
, npath
, n
->n_cost
);
printhost(n
, npath
, n
->n_cost
);
for (l
= n
->n_link
; l
; l
= l
->l_next
)
register char *ppath
, *npath
;
* for magic @-% conversion.
* assume that gateways to domains want no @'s
if (next
->n_parent
->n_flag
& ATSIGN
|| ISADOMAIN(next
))
/* special handling for aliases , domains, and nets */
if ((l
->l_flag
& LALIAS
) || (next
->n_flag
& NNET
) || ISADOMAIN(next
)) {
if (next
->n_flag
& ATSIGN
)
netchar
= '%'; /* shazam? shaman? */
/* remainder should be a sprintf -- foo on '%' as an operator */
for ( ; *npath
= *ppath
; ppath
++) {
npath
= hostpath(npath
, l
, netchar
);
fprintf(stderr
, "%s: %%%c found in setpath\n",
hostpath(path
, l
, netchar
)
prev
= l
->l_to
->n_parent
;
if (NETDIR(l
) == LLEFT
) {
strcpy(path
, l
->l_to
->n_name
);
while (ISADOMAIN(prev
)) {
strcpy(path
, prev
->n_name
);
strcpy(path
, l
->l_to
->n_name
);
while (ISADOMAIN(prev
)) {
strcpy(path
, prev
->n_name
);
if ((n
->n_flag
& ISPRIVATE
) == 0) {
printf("%ld\t", (long) cost
);
fputs(n
->n_name
, stdout
);
/* print top-level domain */
if (!ISADOMAIN(n
->n_parent
)) {
if (n
->n_flag
& ISPRIVATE
)
fprintf(stderr
, "%s: warning: private top-level domain %s ignored\n", ProgName
, n
->n_name
);
printdomain(n
, path
, cost
);
/* remainder is for subdomains */
/* don't print if it has a non-private ancestor */
for (parent
= n
->n_parent
; parent
; parent
= parent
->n_parent
)
if (ISADOMAIN(parent
) && (parent
->n_flag
& ISPRIVATE
) == 0)
/* don't print if this domain is also private */
if (n
->n_flag
& ISPRIVATE
)
/* ancestors all private, this domain not private */
printdomain(n
, path
, cost
);
printdomain(n
, path
, cost
)
/* skip subdomains, since the gateway to the parent suffices */
if (ISADOMAIN(n
->n_parent
))
printf("%ld\t", (long) cost
);
fputs(n
->n_name
, stdout
);