DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦925a20f3d⟧ TextFile

    Length: 8258 (0x2042)
    Types: TextFile
    Names: »schema.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/quipu/schema.c« 

TextFile

/* schema.c - */

#ifndef lint
static char *rcsid = "$Header: /f/osi/quipu/RCS/schema.c,v 6.0 89/03/18 23:41:52 mrose Rel $";
#endif

/*
 * $Header: /f/osi/quipu/RCS/schema.c,v 6.0 89/03/18 23:41:52 mrose Rel $
 *
 *
 * $Log:	schema.c,v $
 * Revision 6.0  89/03/18  23:41:52  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.
 *
 */


#include "quipu/util.h"
#include "quipu/entry.h"
#include "quipu/ds_error.h"

extern int oidformat;
extern LLog * log_dsap;

extern AttributeType at_objectclass;

check_schema (eptr,as,error,decode)
Entry eptr;
Attr_Sequence as;
struct DSError * error;
char decode;
{
register Attr_Sequence at;
AV_Sequence avs;
table_seq optr;
int status = OK;
AV_Sequence tavs;

	DLOG (log_dsap,LLOG_TRACE,("check schema")) ;

	if (decode)
		as_decode (as);

	if (eptr->e_parent == NULLENTRY)
		return (OK);    /* no schema for root */

	if ((tavs = eptr->e_parent->e_struct) != NULLAV) {
		/* what should default be !!! */

		/* make sure object class is allowed */
		if (test_schema (tavs,eptr->e_oc_avseq) != OK) {
			LLOG (log_dsap,LLOG_EXCEPTIONS,("Specified object class is not in the tree structure (schema) list"));
			error->dse_type = DSE_ATTRIBUTEERROR;
			error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr);
			error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what =  DSE_AT_CONSTRAINTVIOLATION;
			error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = AttrT_cpy (at_objectclass);
			error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV;
			error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM;
			return (NOTOK);
		}
	}

	/* now check 'must contain' attributes */
	for (avs = eptr->e_oc_avseq; avs != NULLAV; avs = avs->avseq_next)
	    for (optr=avs->avseq_av->av_un.av_objectclass->oc_must; optr!=NULLTABLE_SEQ;  optr=optr->ts_next) {
		at = (as == NULLATTR) ? eptr->e_attributes : as;
		for (; at!=NULLATTR; at=at->attr_link)
			if (at->attr_type->at_table == optr->ts_oa)
				break;

		if (at == NULLATTR) {
			LLOG (log_dsap,LLOG_EXCEPTIONS,("'Must' attribute missing '%s'",attr2name(optr->ts_oa,OIDPART)));

			if (status != OK) {
				/* error in past, append new error */
				struct DSE_at_problem *newerr;
				for (newerr= &(error->ERR_ATTRIBUTE.DSE_at_plist); newerr->dse_at_next != DSE_AT_NOPROBLEM; newerr=newerr->dse_at_next)
					; /* NO-OP */
				newerr->dse_at_next = (struct DSE_at_problem *) smalloc (sizeof(struct DSE_at_problem));
				newerr = newerr->dse_at_next;
				newerr->DSE_at_what = DSE_AT_NOSUCHATTRIBUTE;
				newerr->DSE_at_type = AttrT_new(optr->ts_oa->oa_ot.ot_name);
				newerr->DSE_at_value = NULLAttrV;
				newerr->dse_at_next = DSE_AT_NOPROBLEM;

			} else {
				error->dse_type = DSE_ATTRIBUTEERROR;
				error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr);
				error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what =  DSE_AT_NOSUCHATTRIBUTE;
				error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type =AttrT_new(optr->ts_oa->oa_ot.ot_name);
				error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV;
				error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM;
				status = NOTOK;
			}
		}
	   }

	/* Now try the 'may' contain bits */
	at = (as == NULLATTR) ? eptr->e_attributes : as;
	for (; at!=NULLATTR; at=at->attr_link) {
		optr = NULLTABLE_SEQ;
		for (avs = eptr->e_oc_avseq; avs != NULLAV; avs = avs->avseq_next) {
		    for (optr=avs->avseq_av->av_un.av_objectclass->oc_must; optr!=NULLTABLE_SEQ;  optr=optr->ts_next) 
			if (at->attr_type->at_table == optr->ts_oa)
					break;
		    if (optr != NULLTABLE_SEQ)
		    	break;
			
		    for (optr=avs->avseq_av->av_un.av_objectclass->oc_may; optr!=NULLTABLE_SEQ;  optr=optr->ts_next) 
			if (at->attr_type->at_table == optr->ts_oa)
				break;
		    if (optr != NULLTABLE_SEQ)
		    	break;
		}
		if (optr == NULLTABLE_SEQ) {
			LLOG (log_dsap,LLOG_EXCEPTIONS,("attribute '%s' not allowed in the specified objectclass",attr2name(at->attr_type->at_table,OIDPART)));

			if (status != OK) {
				/* error in past, append new error */
				struct DSE_at_problem *newerr;
				for (newerr= &(error->ERR_ATTRIBUTE.DSE_at_plist); newerr->dse_at_next != DSE_AT_NOPROBLEM; newerr=newerr->dse_at_next)
					; /* NO-OP */
				newerr->dse_at_next = (struct DSE_at_problem *) smalloc (sizeof(struct DSE_at_problem));
				newerr = newerr->dse_at_next;
				newerr->DSE_at_what = DSE_AT_CONSTRAINTVIOLATION;
				newerr->DSE_at_type = AttrT_cpy (at->attr_type);
				newerr->DSE_at_value = NULLAttrV;
				newerr->dse_at_next = DSE_AT_NOPROBLEM;

			} else {
				error->dse_type = DSE_ATTRIBUTEERROR;
				error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr);
				error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what =  DSE_AT_CONSTRAINTVIOLATION;
				error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = AttrT_cpy (at->attr_type);
				error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV;
				error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM;
				status = NOTOK;
			}
		}
	}
	return (status);

}

check_schema_type (eptr,attr,error)
Entry eptr;
AttributeType attr;
struct DSError * error;
{
register table_seq optr;
AV_Sequence avs;
AV_Sequence tavs;

	DLOG (log_dsap,LLOG_TRACE,("check schema type"));

	if (eptr->e_parent == NULLENTRY)
		return (OK);    /* no schema for root */

	if ((tavs = eptr->e_parent->e_struct) != NULLAV) {

		if (test_schema (tavs,eptr->e_oc_avseq) != OK) {
			LLOG (log_dsap,LLOG_EXCEPTIONS,("given objectclass not in schema (tree structure) list"));
			error->dse_type = DSE_ATTRIBUTEERROR;
			error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr);
			error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what =  DSE_AT_CONSTRAINTVIOLATION;
			error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = AttrT_cpy (at_objectclass);
			error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV;
			error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM;
			return (NOTOK);
		}
	}

	for (avs = eptr->e_oc_avseq; avs != NULLAV; avs = avs->avseq_next) {
	    for (optr=avs->avseq_av->av_un.av_objectclass->oc_must; optr!=NULLTABLE_SEQ;  optr=optr->ts_next) 
		if (attr->at_table == optr->ts_oa)
			break;
	    if (optr != NULLTABLE_SEQ)
	    	break;
		
	    for (optr=avs->avseq_av->av_un.av_objectclass->oc_may; optr!=NULLTABLE_SEQ;  optr=optr->ts_next) 
		if (attr->at_table == optr->ts_oa)
			break;
	    if (optr != NULLTABLE_SEQ)
	    	break;
	}

	if (optr == NULLTABLE_SEQ) {
		LLOG (log_dsap,LLOG_EXCEPTIONS,("Attribute '%s' not allowed for specified objectclass",attr2name(attr->at_table,OIDPART)));

		error->dse_type = DSE_ATTRIBUTEERROR;
		error->ERR_ATTRIBUTE.DSE_at_name = get_copy_dn (eptr);
		error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_what =  DSE_AT_CONSTRAINTVIOLATION;
		error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_type = AttrT_cpy(attr);
		error->ERR_ATTRIBUTE.DSE_at_plist.DSE_at_value = NULLAttrV;
		error->ERR_ATTRIBUTE.DSE_at_plist.dse_at_next = DSE_AT_NOPROBLEM;
		return (NOTOK);
	}
	return (OK);

}


test_schema (tree,oc)
AV_Sequence tree;
AV_Sequence oc;
{
AV_Sequence aptr, tavs;
struct tree_struct *tptr;
char found;

	if (oc == NULLAV)
		return (NOTOK);

	for (aptr=oc; aptr!= NULLAV; aptr=aptr->avseq_next) {
		found = FALSE;
		for (tavs=tree; tavs!=NULLAV ;tavs=tavs->avseq_next) {
			tptr = tavs->avseq_av->av_un.av_tree;
			if (tptr->tree_object == NULLOBJECTCLASS) {
				/* is this correct behaviour ? */
				found = TRUE;
				break;
			}
			if (test_hierarchy (tptr->tree_object->oc_ot.ot_oid, aptr->avseq_av->av_un.av_objectclass->oc_ot.ot_oid) == 0) {
				found = TRUE;
				break;
			}
		}
		if (found == FALSE)
			return (NOTOK);
	}
	return (OK);
}

test_hierarchy (a,b)
OID a,b;
{
struct oid_seq * oidseq;
objectclass *oc;

	if (quipu_oid_cmp (a,b) == 0)
		return (OK);

	if ((oc = oid2oc(a)) == NULLOBJECTCLASS) {
		LLOG (log_dsap,LLOG_EXCEPTIONS,("got an illeagl object class!!!"));
		return (NOTOK);
	}
	
	for (oidseq = oc->oc_hierachy; oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) 
		if (test_hierarchy (oidseq->oid_oid,b) == OK)
			return (OK);

	if (oc->oc_hierachy == NULLOIDSEQ)
		return (NOTOK);
		
	return (NOTOK);
}