|
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 t
Length: 5145 (0x1419) Types: TextFile Names: »tree_struct.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/dsap/common/tree_struct.c«
/* tree_struct.c - Tree Structure and OID Sequence utility routines */ #ifndef lint static char *rcsid = "$Header: /f/osi/dsap/common/RCS/tree_struct.c,v 6.0 89/03/18 23:27:54 mrose Rel $"; #endif /* * $Header: /f/osi/dsap/common/RCS/tree_struct.c,v 6.0 89/03/18 23:27:54 mrose Rel $ * * * $Log: tree_struct.c,v $ * Revision 6.0 89/03/18 23:27:54 mrose * Release 5.0 * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ /* LINTLIBRARY */ #include "quipu/util.h" #include "quipu/entry.h" extern int oidformat; /* oid_seq and tree_struct in same file for historic reasons */ /* would be sensible to split now tho' */ /* ARGSUSED */ tree_struct_free (ptr) struct tree_struct * ptr; { /* don't free objectclass - in static table */ ; } oid_seq_free (ptr) struct oid_seq * ptr; { register struct oid_seq * loop; for (loop=ptr; loop!=NULLOIDSEQ; loop=loop->oid_next) { oid_free (loop->oid_oid); free ((char *) loop); } } struct oid_seq *oid_seq_merge (a,b) struct oid_seq *a; struct oid_seq *b; { register struct oid_seq *aptr, *bptr, *result, *trail; if ( a == NULLOIDSEQ ) return (b); if ( b == NULLOIDSEQ ) return (a); /* start sequence off, make sure 'a' is the first */ switch (quipu_oid_cmp (a->oid_oid,b->oid_oid)) { case 0: /* equal */ result = a; oid_free (b->oid_oid); free ((char *) b); aptr = a->oid_next; bptr = b->oid_next; break; case -1: result = b; aptr = a; bptr = b->oid_next; break; case 1: result = a; aptr = a->oid_next; bptr = b; break; } trail = result; while ( (aptr != NULLOIDSEQ) && (bptr != NULLOIDSEQ) ) { switch (quipu_oid_cmp (aptr->oid_oid,bptr->oid_oid)) { case 0: /* equal */ trail->oid_next = aptr; trail = aptr; oid_free (bptr->oid_oid); free ((char *) bptr); aptr = aptr->oid_next; bptr = bptr->oid_next; break; case -1: trail->oid_next = bptr; trail = bptr; bptr = bptr->oid_next; break; case 1: trail->oid_next = aptr; trail = aptr; aptr = aptr->oid_next; break; } } if (aptr == NULLOIDSEQ) trail->oid_next = bptr; else trail->oid_next = aptr; return (result); } oid_seq_cmp (a,b) struct oid_seq *a, *b; { register int i; for (; (a != NULLOIDSEQ) && (b != NULLOIDSEQ) ; a = a->oid_next, b = b->oid_next) { if ( (i=quipu_oid_cmp (a->oid_oid,b->oid_oid)) != 0) { return (i); } } if ( (a == NULLOIDSEQ) && (b == NULLOIDSEQ) ) { return 0; } else { return ( a ? 1 : -1); } } struct oid_seq * oid_seq_cpy (a) struct oid_seq * a; { register struct oid_seq * b; register struct oid_seq * c; register struct oid_seq * d; struct oid_seq * result; result = oid_seq_alloc (); result -> oid_oid = oid_cpy (a->oid_oid); result -> oid_next = NULLOIDSEQ; b = result; for (c=a->oid_next; c!=NULLOIDSEQ; c=c->oid_next) { d = oid_seq_alloc (); d-> oid_oid = oid_cpy (c->oid_oid); d-> oid_next = NULLOIDSEQ; b-> oid_next = d; b = d; } return (result); } struct tree_struct * tree_struct_cpy (a) struct tree_struct * a; { struct tree_struct * result; result = tree_struct_alloc (); result->tree_object = a->tree_object; return (result); } /* ARGSUSED */ tree_struct_print (ps,tree,format) register PS ps; struct tree_struct * tree; int format; { ps_printf (ps,"%s",oc2name(tree->tree_object,oidformat)); } oid_seq_print (ps,ptr,format) PS ps; register struct oid_seq * ptr; int format; { ps_printf (ps,"%s",oid2name (ptr->oid_oid,oidformat)); for ( ptr=ptr->oid_next; ptr!= NULLOIDSEQ; ptr=ptr->oid_next) if ( format == READOUT ) ps_printf (ps," $ %s",oid2name (ptr->oid_oid,oidformat)); else ps_printf (ps,"$%s",oid2name (ptr->oid_oid,oidformat)); } struct oid_seq * str2oidseq (str) char * str; { register char *ptr; register char *save,val; struct oid_seq * ois = NULLOIDSEQ; struct oid_seq * newois; OID oid; char * SkipSpace(); while ( (ptr = index (str,'$')) != 0) { save = ptr++; save--; if (! isspace (*save)) save++; val = *save; *save = 0; newois = oid_seq_alloc(); if ((oid = name2oid (SkipSpace(str))) == NULLOID) { parse_error ("invaild name in sequence %s",str); oid_seq_free (ois); free ((char *) newois); return (NULLOIDSEQ); } newois->oid_oid = oid_cpy(oid); newois->oid_next = ois; ois = newois; *save = val; str = ptr; } newois = oid_seq_alloc(); if ((oid = name2oid (SkipSpace(str))) == NULLOID) { parse_error ("invaild name in sequence %s",str); oid_seq_free (ois); free ((char *) newois); return (NULLOIDSEQ); } newois->oid_oid = oid_cpy(oid); newois->oid_next = ois; ois = newois; return (ois); } struct tree_struct * str2schema (str) char * str; { struct tree_struct * ts; ts = tree_struct_alloc (); if ((ts->tree_object = name2oc(str)) == NULLOBJECTCLASS) { parse_error ("invalid oid in schema '%s'",str); free ((char *) ts); return (NULLTREE); } return (ts); }