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 o

⟦476449683⟧ TextFile

    Length: 6229 (0x1855)
    Types: TextFile
    Names: »oc.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/dsap/common/oc.c« 

TextFile

/* oc.c - Object Class routines */

#ifndef lint
static char *rcsid = "$Header: /f/osi/dsap/common/RCS/oc.c,v 7.1 90/01/11 23:49:43 mrose Exp $";
#endif

/*
 * $Header: /f/osi/dsap/common/RCS/oc.c,v 7.1 90/01/11 23:49:43 mrose Exp $
 *
 *
 * $Log:	oc.c,v $
 * Revision 7.1  90/01/11  23:49:43  mrose
 * lint
 * 
 * Revision 7.0  89/11/23  21:42:31  mrose
 * Release 6.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"
#include "tailor.h"

extern LLog * log_dsap;
extern short oc_sntx; 
extern IFP oc_hier;

objectclass * oc_add (oid)
OID oid;
{
oid_table * Current;
extern objectclass ocOIDTable[];
extern int ocNumEntries;

	Current = &ocOIDTable[ocNumEntries].oc_ot;
	if (oid == NULLOID)
		Current->ot_oid = NULLOID;
	else
		Current->ot_oid = oid_cpy (oid);
	(void) strcpy (Current->ot_name, oid2ode(oid));
	(void) strcpy (Current->ot_stroid, sprintoid(oid));
	add_entry_aux (Current->ot_name,(caddr_t)&ocOIDTable[ocNumEntries],3,NULLCP);
	ocOIDTable[ocNumEntries].oc_hierachy = NULLOIDSEQ;
	ocOIDTable[ocNumEntries].oc_may  = NULLTABLE_SEQ;
	ocOIDTable[ocNumEntries].oc_must = NULLTABLE_SEQ;
	return (&ocOIDTable[ocNumEntries++]);
}

static objectclass * str2oc (str)
char * str;
{
char * ptr;
char * get_oid ();
objectclass *oc;

	if ((oc = name2oc (str)) != NULLOBJECTCLASS) 
		return (oc);

	/* unknown object class -- need to add to table */
	if ((ptr = get_oid (str)) == NULLCP) {
		parse_error ("Object class %s unknown",str);
		return (NULLOBJECTCLASS);
	}

	return (oc_add (str2oid(ptr)));
}

static AV_Sequence new_oc_avs (oc)
objectclass * oc;
{
AV_Sequence avs;

	avs = avs_comp_alloc();
	avs->avseq_next = NULLAV;
	avs->avseq_av.av_syntax = oc_sntx;
	avs->avseq_av.av_struct = (caddr_t) oc;
	return (avs);
}

static AV_Sequence str2oc_hier (str)
char * str;
{
AV_Sequence avs = NULLAV;
objectclass * oc;
char * ptr, *save, val;

	str = SkipSpace (str);

	while ((ptr = index (str,'&')) != 0) {
		save = ptr++;
		save--;
		if (! isspace (*save))
			save++;
		val = *save;
		*save = 0;

		if ((oc = str2oc (str)) == NULLOBJECTCLASS)
			return (NULLAV);
		if (avs == NULLAV)
			avs = new_oc_avs (oc);
		else
			add_oc_avs (oc,&avs);
		add_hierarchy (oc,&avs);

		*save = val;
		str = SkipSpace(ptr);
	}

	if ((oc = str2oc (str)) == NULLOBJECTCLASS)
		return (NULLAV);
	if (avs == NULLAV)
		avs = new_oc_avs (oc);
	else
		add_oc_avs (oc,&avs);
	add_hierarchy (oc,&avs);

	return (avs);
}

add_oc_avs (oc,avsp)
objectclass * oc;
AV_Sequence *avsp;
{
AV_Sequence loop;
objectclass *ocp;

	/* see if we already have oc in heirarchy ... */

	for (loop = *avsp; loop != NULLAV; loop = loop->avseq_next) {
		ocp = (objectclass *)loop->avseq_av.av_struct;
		if (oc == ocp)
			return;
	}
	*avsp = avs_merge (*avsp,new_oc_avs(oc));
}

static add_hierarchy (oc,avsp)
objectclass * oc;
AV_Sequence *avsp;
{
struct oid_seq * oidseq;
objectclass *ocp;

	for (oidseq = oc->oc_hierachy; 
			oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) {
		ocp = oid2oc(oidseq->oid_oid);
		add_oc_avs (ocp,avsp);
		add_hierarchy (ocp,avsp);
	}
}


#ifdef	notyet
static in_hierarchy (a,b)
AV_Sequence a, b;
{
struct oid_seq * oidseq;
objectclass *oca, *ocb;

	if ((a == NULLAV) || (a->avseq_av.av_syntax != oc_sntx) || (a->avseq_av.av_struct == NULL))
		return (FALSE);

	if ((b == NULLAV) || (b->avseq_av.av_syntax != oc_sntx) || (b->avseq_av.av_struct == NULL))
		return (FALSE);

	oca = (objectclass *) a->avseq_av.av_struct;
	ocb = (objectclass *) b->avseq_av.av_struct;

	for (oidseq = ocb->oc_hierachy; 
			oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) 
		if (oid_cmp(oca->oc_ot.ot_oid,oidseq->oid_oid) == 0)
			return (TRUE);

	return (FALSE);
}

static oc_print_avs (ps,avs,format)  /* need to use this somehow !!! */
PS ps;
AV_Sequence avs;
int format;
{
AV_Sequence newavs;
char found;
char printed = FALSE;

	if (avs == NULLAV)
		return;

	if (format != READOUT)
		DLOG (log_dsap,LLOG_EXCEPTIONS,("invalid call to oc_print"));

	for ( ; avs->avseq_next != NULLAV ; avs=avs->avseq_next) {
		found = FALSE;
		for (newavs = avs->avseq_next; newavs != NULLAV; newavs=newavs->avseq_next)
			if (in_hierarchy(avs,newavs) == TRUE) {
				found = TRUE;
				break;
			}

		if (found == FALSE) {
			if (printed == TRUE)
				ps_print (ps," & ");
			AttrV_print (ps,&avs->avseq_av,format);
			printed = TRUE;
		}
	}

	if (printed == TRUE)
		ps_print (ps," & ");
	AttrV_print (ps,&avs->avseq_av,format);
}
#endif

objclass_cmp (a,b)
objectclass *a, *b;
{
	if (a == NULLOBJECTCLASS)
		return ( b ? -1 : 0 );

	if (b == NULLOBJECTCLASS)
		return (1);

	return (oid_cmp(a->oc_ot.ot_oid,b->oc_ot.ot_oid));
}

static objectclass * oc_cpy (oc)
objectclass * oc;
{
	return (oc);	/* static table !!! */
}

check_in_oc (oid,avs)
OID oid;
AV_Sequence avs;
{
objectclass * oc;

	for (; avs != NULLAV; avs = avs->avseq_next) {
		oc = (objectclass *) avs->avseq_av.av_struct;
		if (oc == NULLOBJECTCLASS)
			continue;
		if (oid_cmp(oid,oc->oc_ot.ot_oid) == 0)
			return (TRUE);
	}

	return (FALSE);
}

/* ARGSUSED */
static oc_free (oc)
objectclass * oc;
{
	;	/* static table !!! */
}

static PE oc_enc (oc)
objectclass *oc;
{
	return (oid2prim(oc->oc_ot.ot_oid));
}


static objectclass * oc_dec (pe)
PE pe;
{
OID oid;
objectclass *oc;

        if (! test_prim_pe (pe,PE_CLASS_UNIV,PE_PRIM_OID))
		return NULLOBJECTCLASS;

	if ((oid = prim2oid (pe)) == NULLOID)
		return NULLOBJECTCLASS;

	if ((oc = oid2oc (oid)) != NULLOBJECTCLASS)
		return (oc);

	return (oc_add(oid));
}



oc_print (ps,oc,format)
PS ps;
objectclass * oc;
int format;
{
extern int oidformat;

	if ( format != READOUT)
		ps_printf (ps,"%s",oc2name (oc,OIDPART));
	else
		ps_printf (ps,"%s",oc2name (oc,oidformat));
}

objectclass_syntax ()
{

	oc_sntx = add_attribute_syntax ("objectclass",
		(IFP) oc_enc,	(IFP) oc_dec,
		(IFP) str2oc,	oc_print,
		(IFP) oc_cpy,	objclass_cmp,
		oc_free,	NULLCP,
		NULLIFP,	FALSE );

	oc_hier = (IFP) str2oc_hier;
	want_oc_hierarchy ();

}