|
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 o
Length: 5267 (0x1493) Types: TextFile Names: »or_check.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Lib/or/or_check.c«
/* or_check.c: check and normalise or names */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/or/RCS/or_check.c,v 5.0 90/09/20 16:07:57 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Lib/or/RCS/or_check.c,v 5.0 90/09/20 16:07:57 pp Exp Locker: pp $ * * $Log: or_check.c,v $ * Revision 5.0 90/09/20 16:07:57 pp * rcsforce : 5.0 public release * */ #include "util.h" #include "or.h" #include "table.h" extern char *or_tbl; static Table *tb_or; char or_error[BUFSIZ]; /* --------------------- Begin Routines -------------------------------- */ /* --- *** --- or_check (or, buf, buf_type, locname) where: or - what is being checked buf - what is returned buf_type - Channel or local lsubdom - local perferred table --- *** --- */ int or_check (or, buf, buf_type, lsubdom) OR_ptr *or; char *buf; int *buf_type; char **lsubdom; { OR_ptr tptr, sptr, current_ptr; char current_val[LINESIZE], tbuf[LINESIZE], tracebuf[LINESIZE], *oargv[10]; int oargc; PP_DBG (("Lib/or_chk()")); *lsubdom = NULLCP; if ((tptr = loc_ortree) == NULLOR) { PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_chk: loc_ortree missing")); return NOTOK; } if ((current_ptr = *or ) == NULLOR) { sprintf (or_error, "No OR specified for checking"); PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_chk: No OR specified for checking")); return NOTOK; } if (tb_or == NULLTBL) { if ((tb_or = tb_nm2struct (or_tbl)) == NULLTBL) { sprintf(or_error, "No or table!!!"); PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_init: or table NULL!")); return NOTOK; } } or_or2std (*or, tracebuf, FALSE); PP_TRACE (("Lib/or_chk's tracebuf: '%s'", tracebuf)); buf[0] = '\0'; for (;;) { or_or2dmn (NULLOR, current_ptr, current_val); PP_DBG (("Lib/or_chk: Checking part: '%s'", current_val)); if (tb_k2val (tb_or, current_val, tbuf) != OK) { if (buf[0] == '\0') { int oargc; char *oargv[10]; char *dollar; PP_DBG (("Lib/or_chk: Check failed '%s' '%s'", current_val, tracebuf)); if (sstr2arg (current_val, 9, oargv, ".")) { if (dollar = index (oargv[0], '$')) *dollar = ' '; sprintf (or_error, "Unknown '%s' in '%s'", oargv[0], tracebuf); } else sprintf (or_error, "Unknown '%s' in '%s'", current_val, tracebuf); return NOTOK; } else return OK; } PP_DBG (("Lib/or_chk: Hit: '%s'", tbuf)); /* --- Have found a pointer --- */ oargc = sstr2arg (tbuf, 9, oargv, " \t\n,"); if (lexequ (oargv[0], "valid") == 0) { buf[0] = '\0'; current_ptr = current_ptr -> or_next; continue; } if (lexequ (oargv[0], "local") == 0) { /* --- This is local - map rest to buf --- */ if (current_ptr -> or_next == NULLOR) { sprintf (or_error, "No local bits left: '%s'", tracebuf); PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_chk: No local bits left: '%s'", tracebuf)); return NOTOK; } tptr = current_ptr; current_ptr = current_ptr -> or_next; current_ptr -> or_prev = NULLOR; if (or_getpn (current_ptr, buf) == FALSE) or_or2std (current_ptr, buf, TRUE); current_ptr -> or_prev = tptr; *buf_type = OR_ISLOCAL; PP_TRACE (("Lib/or_chk: Returning local: '%s' '%s' ", buf, tracebuf)); if (oargc > 1) *lsubdom = strdup (oargv[1]); return OK; } /* --- end of if local --- */ if (oargc < 2) { sprintf (or_error, "Not enough args on RHS '%s' '%s'", current_val, tracebuf); PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_chk: Not enough args on RHS '%s' '%s'", current_val, tracebuf)); return NOTOK; } if (lexequ (oargv[0], "mta") == 0) { (void) strcpy (buf, oargv[1]); *buf_type = OR_ISMTA; current_ptr = current_ptr -> or_next; continue; } if (lexequ (oargv[0], "alias") == 0) { /* --- invalidate previous hits --- */ buf[0] = '\0'; if ((tptr = or_dmn2or (oargv[1])) == NULLOR) { sprintf(or_error, "Invalid syntax alias", oargv[1], tracebuf); PP_LOG (LLOG_EXCEPTIONS, ("%s '%s' '%s'", "Lib/or_check: Invlaid syntax alias", oargv[1], tracebuf)); return NOTOK; } /* --- free off old head --- */ sptr = current_ptr -> or_next; sptr -> or_prev = NULLOR; current_ptr -> or_next = NULLOR; or_free (*or); /* --- add in the new stuff --- */ *or = tptr; current_ptr = or_lastpart (tptr); if (sptr -> or_type < current_ptr -> or_type) { PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_chk: Alias out of order '%s' '%s'", oargv[1], tracebuf)); sprintf (or_error, "Alias out of order '%s' '%s'", oargv[1], tracebuf); return NOTOK; } current_ptr -> or_next = sptr; sptr -> or_prev = current_ptr; continue; } /* --- end of if alias --- */ PP_LOG (LLOG_EXCEPTIONS, ("Lib/or_check: Unknown alias type '%s' '%s'", oargv[0], tracebuf)); sprintf (or_error, "Unknown alias type '%s' '%s'", oargv[1], tracebuf); return NOTOK; } /* end of for */ }