|
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: 6034 (0x1792) Types: TextFile Names: »avs.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« └─⟦d3ac74d73⟧ └─⟦this⟧ »isode-5.0/dsap/common/avs.c«
/* avs.c - General Attribute Value Sequence routines */ #ifndef lint static char *rcsid = "$Header: /f/osi/dsap/common/RCS/avs.c,v 6.0 89/03/18 23:27:25 mrose Rel $"; #endif /* * $Header: /f/osi/dsap/common/RCS/avs.c,v 6.0 89/03/18 23:27:25 mrose Rel $ * * * $Log: avs.c,v $ * Revision 6.0 89/03/18 23:27:25 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/attrvalue.h" #include "quipu/dsp.h" /* for ds_error.h */ #include "quipu/ds_error.h" extern LLog * log_dsap; static AV_Sequence eptr; #define foreach(a) for(eptr = a; eptr != NULLAV; eptr = eptr->avseq_next) avs_comp_free (avs) AV_Sequence avs; { AttrV_free (avs->avseq_av); free ((char *) avs); } avs_free (avs) AV_Sequence avs; { foreach (avs) avs_comp_free (eptr); } AV_Sequence avs_comp_new (pe) AttributeValue pe; { AV_Sequence ptr; ptr = avs_comp_alloc (); avs_comp_fill (ptr,pe); ptr->avseq_soundex[0][0] = 0; ptr->avseq_next = NULLAV; return (ptr); } avs_decode (x,y) AttributeType x; AV_Sequence y; { foreach (y) AttrV_decode (x,eptr->avseq_av); } AV_Sequence avs_merge (a,b) AV_Sequence a,b; { register AV_Sequence aptr, bptr, result, trail; struct DSError error; AV_Sequence acl_merge(); if ( a == NULLAV ) return (b); if ( b == NULLAV ) return (a); if (a->avseq_av->av_syntax == AV_ACL) return (acl_merge (a,b)); /* start sequence off, make sure 'a' is the first */ switch (avs_cmp_comp (a,b,&error)) { case 0: /* equal */ result = a; aptr = a->avseq_next; avs_comp_free (b); bptr = b->avseq_next; break; case -1: result = b; aptr = a; bptr = b->avseq_next; break; case 1: result = a; aptr = a->avseq_next; bptr = b; break; default: LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid syntax")) ; ds_error_free (&error); /* continue as if equal */ result = a; aptr = a->avseq_next; avs_comp_free (b); bptr = b->avseq_next; break; } trail = result; while ( (aptr != NULLAV) && (bptr != NULLAV) ) { switch (avs_cmp_comp (aptr,bptr,&error)) { case 0: /* equal */ trail->avseq_next = aptr; trail = aptr; avs_comp_free (bptr); aptr = aptr->avseq_next; bptr = bptr->avseq_next; break; case -1: trail->avseq_next = bptr; trail = bptr; bptr = bptr->avseq_next; break; case 1: trail->avseq_next = aptr; trail = aptr; aptr = aptr->avseq_next; break; case -2: LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid syntax")) ; ds_error_free (&error); /* continue as if equal */ result = a; aptr = a->avseq_next; avs_comp_free (b); bptr = b->avseq_next; break; } } if (aptr == NULLAV) trail->avseq_next = bptr; else trail->avseq_next = aptr; return (result); } avs_delnext (avs) AV_Sequence avs; { AV_Sequence ptr; if (avs == NULLAV) DLOG (log_dsap,LLOG_DEBUG,("delnext of null avs!")); else { ptr = avs->avseq_next; if (ptr == NULLAV) DLOG (log_dsap,LLOG_DEBUG,("no new avs to delete!")); else { avs->avseq_next = ptr->avseq_next; avs_comp_free (ptr); } } } AV_Sequence avs_comp_cpy (avs) AV_Sequence avs; { AV_Sequence ptr; register int i; if (avs==NULLAV) { DLOG (log_dsap,LLOG_DEBUG,("copy of null avs")); return (NULLAV); } ptr = (AV_Sequence) smalloc (sizeof(avseqcomp)); ptr->avseq_av = AttrV_cpy (avs->avseq_av); for (i=0 ; i< MAXSOUNDEXKEYS; i++) bcopy (avs->avseq_soundex[i], ptr->avseq_soundex[i], SOUNDEXKEYSIZE); ptr->avseq_next = NULLAV; return (ptr); } AV_Sequence avs_cpy (avs) AV_Sequence avs; { AV_Sequence start; AV_Sequence ptr,ptr2; if (avs == NULLAV ) { DLOG (log_dsap,LLOG_DEBUG,("avs_cpy of null avs")); return (NULLAV); } start = avs_comp_cpy (avs); ptr2 = start; foreach (avs->avseq_next) { ptr = avs_comp_cpy (eptr); ptr2->avseq_next = ptr; ptr2 = ptr; } return (start); } avs_cmp (a,b) AV_Sequence a,b; { int i; struct DSError error; /* should this compare the soundex - I think not */ for (; (a != NULLAV) && (b != NULLAV) ; a = a->avseq_next, b = b->avseq_next) if ( (i = avs_cmp_comp (a,b,&error)) != 0) { if ( i==-2 ) ds_error_free (&error); return (i); } if ( (a == NULLAV) && (b == NULLAV) ) { return 0; } else { return (a ? 1 : -1); } } avs_comp_print (ps,avs,format) AV_Sequence avs; PS ps; int format; { /* don't print soundex info */ AttrV_print (ps,avs->avseq_av,format); } avs_print (ps,avs,format) AV_Sequence avs; PS ps; int format; { if (avs == NULLAV) { ps_print (ps,"\n"); return; } if ((format == READOUT) && (avs->avseq_av->av_syntax == AV_OBJECTCLASS)) { oc_print (ps,avs,format); ps_print (ps,"\n"); return; } avs_comp_print (ps,avs,format); if (avs->avseq_next != NULLAV) foreach (avs->avseq_next) { switch (format) { case EDBOUT: ps_print(ps," & "); break; case READOUT: ps_print(ps,"\n\t\t"); break; } avs_comp_print (ps,eptr,format); } ps_print (ps,"\n"); } AV_Sequence str2avs (str,at) char * str; AttributeType at; { char * ptr; char * save,val; AV_Sequence avs = NULLAV; AV_Sequence newavs; AttributeValue av; if (str == NULLCP) return (NULLAV); while ((ptr = index (str,'&')) != 0) { save = ptr++; save--; if (! isspace (*save)) save++; val = *save; *save = 0; if ((av = str_at2AttrV (str,at)) == NULLAttrV) return (NULLAV); newavs = avs_comp_new (av); if (av->av_syntax == AV_OBJECTCLASS) make_oc_hierarchy (&newavs); *save = val; str = ptr; avs = avs_merge (avs,newavs); } if ((av = str_at2AttrV (str,at)) == NULLAttrV) return (NULLAV); newavs = avs_comp_new (av); if (av->av_syntax == AV_OBJECTCLASS) make_oc_hierarchy (&newavs); return (avs_merge (avs,newavs)); }