|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T a
Length: 3955 (0xf73) Types: TextFile Names: »ap_t2p.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Lib/addr/ap_t2p.c«
/* ap_t2p.c: split tree into major address parts */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/addr/RCS/ap_t2p.c,v 5.0 90/09/20 16:04:12 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Lib/addr/RCS/ap_t2p.c,v 5.0 90/09/20 16:04:12 pp Exp Locker: pp $ * * $Log: ap_t2p.c,v $ * Revision 5.0 90/09/20 16:04:12 pp * rcsforce : 5.0 public release * */ /* Record beginnings of major sections of an address Returns: pointer to next node, after address 0 if end of tree -1 if error if both rroute and nroute are requested, and the tree has routing in reverse-path form, then these will point to the same node. */ #include "util.h" #include "ap.h" static int person_level, group_level; /* --------------------- Begin Routines -------------------------------- */ AP_ptr ap_t2p (tree, group, name, local, domain, route) register AP_ptr tree; /* -- the parse tree -- */ AP_ptr *group, /* -- start of group name -- */ *name, /* -- start of person name -- */ *local, /* -- start of local-part -- */ *domain, /* -- basic domain reference -- */ *route; /* -- start of 822 reverse route -- */ { AP_ptr return_ptr, start_ptr = tree; int got_local, got_first; PP_DBG (("Lib/addr/ap_t2p()")); group_level = 0; person_level = 0; if (group != (AP_ptr *) 0) *group = NULLAP; if (name != (AP_ptr *) 0) *name = NULLAP; if (local != (AP_ptr *) 0) *local = NULLAP; if (domain != (AP_ptr *) 0) *domain = NULLAP; if (route != (AP_ptr *) 0) *route = NULLAP; /* -- ignore null stuff -- */ if (tree == NULLAP || tree -> ap_obtype == AP_NIL) return ((AP_ptr) OK); got_first = FALSE; for (got_local = FALSE; ; tree = tree -> ap_next) { /* -- print munged addr -- */ switch (tree -> ap_obtype) { case AP_NIL: return_ptr = NULLAP; goto endit; case AP_PERSON_NAME: person_level++; if (name != (AP_ptr *) 0 && *name == NULLAP) { *name = start_ptr; got_first = TRUE; } start_ptr = tree -> ap_next; break; case AP_PERSON_START: start_ptr = tree -> ap_next; break; case AP_PERSON_END: person_level--; start_ptr = tree -> ap_next; break; case AP_GROUP_NAME: group_level++; if (group != (AP_ptr *) 0 && *group == NULLAP) { *group = start_ptr; got_first = TRUE; } start_ptr = tree -> ap_next; break; case AP_GROUP_START: start_ptr = tree -> ap_next; break; case AP_GROUP_END: group_level--; start_ptr = tree -> ap_next; break; case AP_GENERIC_WORD: case AP_MAILBOX: if (local != (AP_ptr *) 0 && *local == NULLAP) { *local = start_ptr; got_first = TRUE; } got_local = TRUE; start_ptr = tree -> ap_next; break; case AP_DOMAIN_LITERAL: case AP_DOMAIN: if (got_local) { /* -- reference after local -- */ if (domain != (AP_ptr *) 0 && *domain == NULLAP) { *domain = start_ptr; got_first = TRUE; } } else { /* -- must be 822 route -- */ /* -- domain precedes local-part -- */ if (route != (AP_ptr *) 0 && *route == NULLAP) { *route = start_ptr; got_first = TRUE; } } start_ptr = tree -> ap_next; break; case AP_COMMENT: /* -- output value as comment -- */ if (got_first == FALSE) /* cannot lose preceding comments */ break; default: start_ptr = tree -> ap_next; break; } switch (tree -> ap_ptrtype) { case AP_PTR_NXT: if (tree -> ap_next -> ap_obtype != AP_NIL) { return_ptr = (AP_ptr) tree -> ap_next; goto endit; } /* -- else drop on through -- */ case AP_PTR_NIL: return_ptr = (AP_ptr) OK; goto endit; } } endit: return (return_ptr); }