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

⟦5d85f9ad9⟧ TextFile

    Length: 20181 (0x4ed5)
    Types: TextFile
    Names: »oid.c«

Derivation

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

TextFile

/* oid.c - Object Identifier routines */

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

/*
 * $Header: /f/osi/dsap/common/RCS/oid.c,v 6.0 89/03/18 23:27:41 mrose Rel $
 *
 *
 * $Log:	oid.c,v $
 * Revision 6.0  89/03/18  23:27:41  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"
#include "cmd_srch.h"
#include "tailor.h"

extern char chrcnv [];

extern LLog * log_dsap;

static CMD_TABLE cmd_syntax [] = {
	"CaseIgnoreString",     AV_CASEIGNORESTRING,
	"objectclass",          AV_OBJECTCLASS,
	"acl",                  AV_ACL,
	"PresentationAddress",  AV_PRESENTATIONADDRESS,
	"DN",			AV_DN,
	"schema",               AV_SCHEMA,
	"EDBInfo",              AV_UPDATE,
	"asn",                  AV_ASN,
	"CaseExactString",      AV_CASEEXACTSTRING,
	"NumericString",        AV_NUMERICSTRING,
	"boolean",              AV_BOOLEAN,
	"integer",              AV_INTEGER,
	"time",                 AV_TIME,
	"oid",                  AV_OID,
	"photo",		AV_PHOTO,
	"undefined",            AV_UNKNOWN,
	0,              -1,
	};

FILE * f_table;

static char * get_entry ();
static add_entry ();
static char * get_oid ();
static char * name2gen ();
static get_oc_bits ();
static add_entry_aux ();
static table_seq table_seq_new ();

oid_table       OIDTable [TABLESIZE];
oid_table_attr  attrOIDTable [TABLESIZE];
objectclass     ocOIDTable [TABLESIZE];

struct mac_buf {                        /* for handling macros */
	char name [BUFSIZE];
	char value [LINESIZE];
} macro [BUFSIZE];

int NumEntries          = 0;
int attrNumEntries      = 0;
int ocNumEntries        = 0;
int NumMacro            = 0;

#define GEN  1
#define ATTR 2
#define OC   3


#define	PBUCKETS	128
#define	PHASH(nm) \
    (((nm)[1]) ? (((chrcnv[((nm)[0])] - chrcnv[((nm)[1])]) & 0x1f) + ((chrcnv[(nm)[2]]) & 0x5f)) \
	       : (chrcnv[(nm)[0]]) & 0x7f)

struct pair {
    char   *p_name;
    caddr_t p_value;
    int     p_type;
    struct pair *p_chain;
};

struct aliases {
	char * a_full;
	char * a_alias;
};

static struct aliases Palias[LOTS];
static int Palias_next = 0;
static struct pair *Pbuckets[PBUCKETS];


load_oid_table (table)
char * table;
{
register char * name;
char filename [FILNSIZE];
register char * extension;
char *isodetable;

	if (NumEntries != 0)
		return;    /* already loaded */

	isodetable = isodefile(table);

	(void) strcpy (filename,isodetable);
	extension = &filename[strlen(isodetable)];

	(void) strcpy (extension,".gen");
	if (( f_table = fopen (filename,"r")) == (FILE *) NULL) {
		LLOG (log_dsap,LLOG_FATAL,("file %s",filename));
		fatal (-91,"Can't open oidtable.gen");
	}

	while (1) {     /* break out */
		if ( (name = get_entry ()) == NULLCP)
			break;
		add_entry (name,GEN);
	}
	(void) fclose (f_table);

	(void) strcpy (extension,".at");
	if (( f_table = fopen (filename,"r")) == (FILE *) NULL) {
		LLOG (log_dsap,LLOG_FATAL,("file %s",filename));
		fatal (-92,"Can't open oidtable.at");
	}

	while (1) {     /* break out */
		if ( (name = get_entry ()) == NULLCP)
			break;
		add_entry (name,ATTR);
	}
	(void) fclose (f_table);

	(void) strcpy (extension,".oc");
	if (( f_table = fopen (filename,"r")) == (FILE *) NULL) {
		LLOG (log_dsap,LLOG_FATAL,("file %s",filename));
		fatal (-93,"Can't open oidtable.oc");
	}

	while (1) {     /* break out */
		if ( (name = get_entry ()) == NULLCP)
			break;
		add_entry (name,OC);
	}
	(void) fclose (f_table);

}

static add_entry_aux (a,b,c,d)
char * a;
caddr_t b;
int c;
char * d;
{
    int	    i;
    register struct pair *p;

    if ((p = (struct pair *) calloc (1, sizeof *p)) == NULL) {
	SLOG (log_dsap, LLOG_EXCEPTIONS, NULLCP,
	      ("calloc of alias structure failed"));
	return;
    }

    p -> p_name = a;
    p -> p_value = b;
    p -> p_type = c;
    p -> p_chain = Pbuckets[i = PHASH (p -> p_name)];
    Pbuckets[i] = p;

    if (d != NULLCP) {
	if ((p = (struct pair *) calloc (1, sizeof *p)) == NULL) {
		SLOG (log_dsap, LLOG_EXCEPTIONS, NULLCP,
	      	   	   ("calloc of alias (2) structure failed"));
		return;
    	}

	Palias[Palias_next].a_full = a;
	Palias[Palias_next++].a_alias = d;

    	p -> p_name = d;
    	p -> p_value = b;
    	p -> p_type = c;
    	p -> p_chain = Pbuckets[i = PHASH (p -> p_name)];
    	Pbuckets[i] = p;
    }

}


static add_entry (newname,towho)
char * newname;
int towho;
{
register char *nptr, *ptr, *sep;
OID oid;
oid_table * Current;
char * alias = NULLCP;

	if ((nptr = index (newname,SEPERATOR)) == 0) {
		LLOG (log_dsap,LLOG_FATAL,("oid missing in %s",newname));
		return;
	}
	*nptr = 0;
	if ((sep = index (newname,COMMA)) != 0) {
		*sep++ = 0;
		alias = strdup(newname);
		newname = sep;
	} 

	switch (towho) {
		case GEN:
			Current = &OIDTable[NumEntries];
			(void) strcpy (Current->ot_name, newname);
			add_entry_aux (Current->ot_name,(caddr_t)&OIDTable[NumEntries],GEN,alias);
			break;
		case ATTR:
			Current = &attrOIDTable[attrNumEntries].oa_ot;
			(void) strcpy (Current->ot_name, newname);
			add_entry_aux (Current->ot_name,(caddr_t)&attrOIDTable[attrNumEntries],ATTR,alias);
			break;
		case OC:
			Current = &ocOIDTable[ocNumEntries].oc_ot;
			(void) strcpy (Current->ot_name, newname);
			add_entry_aux (Current->ot_name,(caddr_t)&ocOIDTable[ocNumEntries],OC,alias);
			break;
		}
	*nptr = SEPERATOR;
	nptr++;

	if ((sep = index (nptr,SEPERATOR)) != 0)
		*sep++ = 0;

	ptr = get_oid (nptr);
	if (ptr == NULLCP) {
		LLOG (log_dsap,LLOG_FATAL,("invalid oid '%s'",nptr));
		return;
	}
	(void) strcpy (Current->ot_stroid,ptr);

	oid = str2oid (Current->ot_stroid);
	if (oid == NULLOID)
		Current->ot_oid = NULLOID;
		/* only reason for failure is generic oid of length 1 */
	else
		Current->ot_oid = oid_cpy (oid);

	/* now do special work for at and oc types */
	switch (towho) {
		case GEN:
			NumEntries++;   /* nothing else to do */
			break;
		case ATTR:
			if (sep == 0)
				LLOG (log_dsap,LLOG_FATAL,("syntax missing in %s",newname));
			else {
				if (( ptr = index (sep,SEPERATOR)) != NULLCP) {
					*ptr++ = 0;
					if (lexequ (ptr,"FILE") != 0)
						LLOG (log_dsap,LLOG_FATAL,("FILE syntax expected, '%s' found",ptr));
					else {
						if ((attrOIDTable[attrNumEntries].oa_syntax = cmd_srch (sep, cmd_syntax)) == -1)
							LLOG (log_dsap,LLOG_FATAL,("Unknown syntax %s",sep));
						else {
							attrOIDTable[attrNumEntries].oa_syntax += AV_WRITE_FILE;
							attrNumEntries++;
						}
					}
				} else {
					if ((attrOIDTable[attrNumEntries].oa_syntax = cmd_srch (sep, cmd_syntax)) == -1)
						LLOG (log_dsap,LLOG_FATAL,("Unknown syntax %s",sep));
					else
						attrNumEntries++;
				}
			}
			break;
		case OC:
			if (sep == 0)
				LLOG (log_dsap,LLOG_FATAL,("hierarchy missing %s",newname));
			if (get_oc_bits (sep) == OK)
				ocNumEntries++;
			else
				LLOG (log_dsap,LLOG_FATAL,("(%s)",newname));
			break;
		}

	return;
}

static get_oc_bits (str)
register char * str;
{
register char * ptr;
register char * ptr2;
struct oid_seq * oidseq = NULLOIDSEQ, *oidseqptr = oidseq;
objectclass * oc;

	if ((ptr = index (str,SEPERATOR)) == 0) {
		LLOG (log_dsap,LLOG_FATAL,("must missing"));
		return (NOTOK);
	}
	*ptr++ = 0;

	while (( ptr2 = index (str,COMMA)) != 0) {
		*ptr2++ = 0;
		oidseqptr = (struct oid_seq *) smalloc (sizeof (struct oid_seq));
		if ((oc = name2oc(str)) == NULLOBJECTCLASS) {
			LLOG (log_dsap,LLOG_FATAL,("unknown objectclass in hierachy %s",str));
			return (NOTOK);
		}
		oidseqptr->oid_oid = oc->oc_ot.ot_oid;
		oidseqptr->oid_next = NULLOIDSEQ;
		oidseq = oid_seq_merge (oidseq,oidseqptr);
		str = ptr2;
	}
	if (*str != 0) {
		oidseqptr = (struct oid_seq *) smalloc (sizeof (struct oid_seq));
					/* no logging -> never freed */
		if ((oc = name2oc(str)) == NULLOBJECTCLASS) {
			LLOG (log_dsap,LLOG_FATAL,("unknown objectclass in hierachy %s",str));
			return (NOTOK);
		}
		oidseqptr->oid_oid = oc->oc_ot.ot_oid;
		oidseqptr->oid_next = NULLOIDSEQ;
		oidseq = oid_seq_merge (oidseq,oidseqptr);
		ocOIDTable[ocNumEntries].oc_hierachy = oidseq;
	} else
		ocOIDTable[ocNumEntries].oc_hierachy = NULLOIDSEQ;

	str = ptr;
	if ((ptr = index (str,SEPERATOR)) == 0) {
		LLOG (log_dsap,LLOG_FATAL,("may element missing"));
		return (NOTOK);
	}
	*ptr++ = 0;

	ocOIDTable[ocNumEntries].oc_may  = table_seq_new (ptr);
	ocOIDTable[ocNumEntries].oc_must = table_seq_new (str);

	return (OK);
}

static table_seq undo_macro (top,ptr)
table_seq top;
register char * ptr;
{
register int i;
table_seq tab;
table_seq tab_top;
table_seq trail = NULLTABLE_SEQ;

	if (*ptr == 0)
		return (top);

	for (i=0; i<NumMacro; i++)
		if (lexequ (macro[i].name,ptr) == 0) {
			tab_top= table_seq_new (macro[i].value);
			for (tab=tab_top; tab!=NULLTABLE_SEQ; tab=tab->ts_next)
				trail = tab;
			if (trail != NULLTABLE_SEQ) {
				trail->ts_next = top;
				return (tab_top);
			} else
				return (top);
		}

	LLOG (log_dsap,LLOG_FATAL,("can't interpret %s in must/may field",ptr));
	return (top);
}

static table_seq table_seq_new (str)
register char * str;
{
register char * ptr;
table_seq tptr;
table_seq top = NULLTABLE_SEQ;
oid_table_attr * at;

	if (*str == 0)
		return (NULLTABLE_SEQ);

	while ((ptr = index (str,COMMA)) != 0) {
		*ptr = 0;
		if ((at = name2attr (str)) == NULLTABLE_ATTR)
			top = undo_macro (top,str);
		else {
			tptr = (table_seq) smalloc (sizeof (*tptr));
					/* no logging -> never freed */
			tptr->ts_oa = at;
			tptr->ts_next = top;
			top = tptr;
		}
		*ptr = COMMA;
		str = ptr + 1;
	}

	if (str != 0) {
		if ((at = name2attr (str)) == NULLTABLE_ATTR)
			return (undo_macro (top,str));
		else {
			tptr = (table_seq) smalloc (sizeof (*tptr));
					/* no logging -> never freed */
			tptr->ts_oa = at;
			tptr->ts_next = top;
			return (tptr);
		}
	} else
		return (NULLTABLE_SEQ);

}

static char * get_oid (str)
char * str;
{
static char buffer [BUFSIZE];
register char * ptr = buffer;
register char * dotptr;
register char * soid;
char deref = FALSE;

      if ( ! isdigit(*str))
	      if ((dotptr = index (str,DOT)) == 0)
		      return (name2gen(str));

	while (*str != 0) {
		if ( (! isdigit (*str)) && (*str != DOT) ) {
			if ((dotptr = index (str,DOT)) == 0) {
				*--ptr = 0;
				return (buffer);
			}
			*dotptr = 0;
			*ptr = 0;
			if ((soid = name2gen(str)) == NULLCP) {
				*dotptr = DOT;
				return (NULLCP);
			}
			*dotptr = DOT;
			str = dotptr;
			if (deref) {
				if ((dotptr = rindex (soid,DOT)) == 0)
					return (NULLCP); /* invalid */
				if ((strncmp (soid,buffer,strlen(buffer))) != 0)
					return (NULLCP);  /* inconsistent */
			}
			deref = TRUE;
			(void) strcpy (buffer,soid);
			ptr = buffer + strlen (soid);
			}
		else
			*ptr++ = *str++;
	}

	*ptr = 0;
	return (buffer);
}

static char * name2gen (nodename)
char * nodename;
{
register int i;
register oid_table * tblptr = &OIDTable[0];

	for (i=0;i<NumEntries;i++,tblptr++) {
		if (lexequ (tblptr->ot_name, nodename) == 0)
			return (tblptr->ot_stroid);
	}

	return (NULLCP);
}

static char * soid2gen (soid)
char * soid;
{
register int i;
register oid_table * tblptr = &OIDTable[0];
	for (i=0;i<NumEntries;i++,tblptr++) {
		if (strcmp (tblptr->ot_stroid, soid) == 0)
			return (tblptr->ot_name);
	}

	return (NULLCP);
}

static char * get_line ()
{
static char buffer [LINESIZE];
register char * buf = buffer;
register char * ptr = buffer;
register int done;

	/* read line, ignore comments, join lines in '/' found */

	do {
		done = TRUE;
		if (fgets (buf,LINESIZE,f_table) == NULLCP)
			return (NULLCP);

		StripSpace (buf);
		if (*buf != 0) {
			ptr += strlen(buf) - 1;
			if (*ptr == '\\') {
				buf = ptr;
				done = FALSE;
			}
		} else
			done = FALSE;
	} while (done == FALSE);

	return (buffer);
}

static char * get_entry ()
{
register char * buf;
register char * ptr;

	/* read next line - test for macro defs */
	while (1) { /* return out */
		if ((buf = get_line ()) == NULLCP)
			return (NULLCP);

		if ((ptr = index (buf,'=')) != 0) {
			*ptr++ = 0;
			(void) strcpy(macro[NumMacro].name,buf);
			(void) strcpy(macro[NumMacro++].value,ptr);
		} else
			return (buf);

	}


}

oid_table_attr *name2attr(nodename)
char * nodename;
{
register int i;
register char * ptr;
char * str;
register oid_table_attr * atrptr = &attrOIDTable[0];

	if ((ptr = rindex (nodename,DOT)) == 0) {
		struct pair *p;
		for (p = Pbuckets[PHASH (nodename)];
			p && lexequ (p -> p_name, nodename);
	     		p = p -> p_chain) 
				; /* NO-OP */

		if ((p != NULL) && (p->p_type == ATTR))
			return ( (oid_table_attr *) p->p_value);
		else 
			return (NULLTABLE_ATTR);

	} else {
		str = get_oid (nodename);
		if (isdigit (*++ptr)) {
			for (i=0;i<attrNumEntries;i++,atrptr++)
				if (lexequ (atrptr->oa_ot.ot_stroid, str) == 0)
				return (atrptr);
			return (NULLTABLE_ATTR);
		} else {
			for (i=0;i<attrNumEntries;i++,atrptr++)
				if (lexequ (atrptr->oa_ot.ot_name, ptr) == 0)
					if (strncmp (str,atrptr->oa_ot.ot_stroid,strlen(str)) == 0)
						return (atrptr);
					else
						return (NULLTABLE_ATTR);
		}
	}
	return (NULLTABLE_ATTR);
	
}


oid_table_attr *oid2attr(oid)
OID oid;
{
register int i;
register oid_table_attr * ptr = &attrOIDTable[0];

	DLOG (log_dsap,LLOG_DEBUG,("oid2attr: %s",sprintoid(oid)));

	for (i=0;i<attrNumEntries;i++,ptr++) {
		if (quipu_oid_cmp (ptr->oa_ot.ot_oid, oid) == 0)
			return (ptr);
	}

	return (NULLTABLE_ATTR);
}

objectclass *name2oc(nodename)
register char * nodename;
{
register int i;
register char * ptr;
char * str;
register objectclass * oc = & ocOIDTable[0];

	if ((ptr = rindex (nodename,DOT)) == 0) {
		struct pair *p;
		for (p = Pbuckets[PHASH (nodename)];
			p && lexequ (p -> p_name, nodename);
	     		p = p -> p_chain) 
				; /* NO-OP */

		if ((p != NULL) && (p->p_type == OC))
			return ( (objectclass *) p->p_value);
		else 
			return (NULLOBJECTCLASS);
	} else {
		str = get_oid (nodename);
		if (isdigit (*++ptr)) {
			for (i=0;i<ocNumEntries;i++,oc++)
				if (lexequ (oc->oc_ot.ot_stroid, str) == 0)
				return (oc);
			return (NULLOBJECTCLASS);
		} else {
			for (i=0;i<ocNumEntries;i++,oc++)
				if (lexequ (oc->oc_ot.ot_name, ptr) == 0)
					if (strncmp (str,oc->oc_ot.ot_stroid,strlen(str)) == 0)
						return (oc);
					else
						return (NULLOBJECTCLASS);

		}
	}

	return (NULLOBJECTCLASS);
}


objectclass *oid2oc(oid)
OID oid;
{
register int i;
register objectclass * oc = &ocOIDTable[0];

	for (i=0;i<ocNumEntries;i++,oc++) {
		if (quipu_oid_cmp (oc->oc_ot.ot_oid, oid) == 0)
			return (oc);
	}

	return (NULLOBJECTCLASS);
}


static char * full_gen (ot)
oid_table * ot;
{
static char buffer [BUFSIZ];
register char * ptr = buffer;
register char * soid;
register char * str;

	buffer [0] = '\0';
	str = sprintoid (ot->ot_oid);

	soid   = str;

	while (*str != '\0')
		if ( *str == DOT)  {
			*str = '\0';
			ptr = soid2gen (soid);
			if (ptr == NULLCP) {
				*str++ = DOT;
				continue;
			}
			(void) strcat (buffer,".");
			(void) strcat (buffer,ptr);
			*str++ = DOT;
		} else
			str++;

	(void) strcat (buffer,".");
	return (&buffer[1]);
}

char *attr2name_aux (oa)
register oid_table_attr *oa;
{
	if ( oa != NULLTABLE_ATTR)
		return (oa->oa_ot.ot_name);
	else {
		LLOG (log_dsap,LLOG_EXCEPTIONS,("NULL table entry"));
		return (NULLCP);
	}
}

char *attr2name(oa,format)
register oid_table_attr *oa;
int format;
{
register char * buffer;
int x;

	if ( oa != NULLTABLE_ATTR)
		switch (format) {
		case OIDFULL:
			buffer = full_gen (&oa->oa_ot);
			(void) strcat (buffer,oa->oa_ot.ot_name);
			return (buffer);
		case OIDNUM:
			return (oa->oa_ot.ot_stroid);
		default:
			/* look for long name */
			for (x=0; x<Palias_next; x++)
				if (lexequ (Palias[x].a_full,oa->oa_ot.ot_name) == 0)
					return (Palias[x].a_alias);
			return (oa->oa_ot.ot_name);
		}
	else {
		LLOG (log_dsap,LLOG_EXCEPTIONS,("NULL table entry"));
		return (NULLCP);
	}
}


char *oc2name(oc,format)
register objectclass *oc;
int format;
{
register char * buffer;

	if ( oc != NULLOBJECTCLASS)
		switch (format) {
		case OIDFULL:
			buffer = full_gen (&oc->oc_ot);
			(void) strcat (buffer,oc->oc_ot.ot_name);
			return (buffer);
		case OIDNUM:
			return (oc->oc_ot.ot_stroid);
		default:
			return (oc->oc_ot.ot_name);
		}
	else
		return (NULLCP);
}

char *oid2name(oid,format)
OID oid;
int format;
{
register oid_table_attr * at;
register objectclass * oc;

	/* try attribute first */
	if (( at = oid2attr (oid)) != NULLTABLE_ATTR)
		return (attr2name(at,format)) ;

	/* try objectclass */
	if (( oc = oid2oc (oid)) != NULLOBJECTCLASS)
		return (oc2name(oc,format)) ;

	return (oid2ode (oid));

}

OID name2oid (str)
register char * str;
{
register struct pair *p;
OID ptr;

	for (p = Pbuckets[PHASH (str)];
		p && lexequ (p -> p_name, str);
     		p = p -> p_chain) 
			; /* NO-OP */

	if (p != NULL)
		switch (p -> p_type) {
		    case GEN: {
			oid_table * ot;
			ot = (oid_table *) p->p_value;
			return (ot->ot_oid);
		    }
		    case ATTR: {
			oid_table_attr * at;
			at = (oid_table_attr *) p->p_value;
			return (at->oa_ot.ot_oid) ;
		    }
		    case OC: {
			objectclass * oc;
			oc = (objectclass *) p->p_value;
			return (oc->oc_ot.ot_oid) ;
		    }
		    default:
			if ( (ptr=ode2oid (str)) == NULLOID)
				return (str2oid(str));
			return (ptr);
		}
	else 
		/* try isobjects */
		if ( (ptr=ode2oid (str)) == NULLOID)
			return (str2oid(str));
		return (ptr);

}


make_oc_hierarchy (avs)
AV_Sequence *avs;
{
AV_Sequence newavs;
AttributeValue x;
struct oid_seq * oidseq;

	/* avs contains 1 oid, add the oid's of the hierarchy */

	for (oidseq = (*avs)->avseq_av->av_un.av_objectclass->oc_hierachy; 
			oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) {
		x = AttrV_alloc();
		x->av_pe = NULLPE;
		x->av_syntax = AV_OBJECTCLASS;
		x->av_un.av_objectclass = oid2oc(oidseq->oid_oid);
		newavs = avs_comp_new (x);
		make_oc_hierarchy (&newavs);
		*avs = avs_merge (*avs,newavs);
	}
}

in_hierarchy (a,b)
AV_Sequence a, b;
{
struct oid_seq * oidseq;


	if ((a == NULLAV) || (a->avseq_av == NULLAttrV) || (a->avseq_av->av_syntax == AV_UNKNOWN) || (a->avseq_av->av_un.av_objectclass == NULLOBJECTCLASS))
		return (FALSE);

	if ((b == NULLAV) || (b->avseq_av == NULLAttrV) || (b->avseq_av->av_syntax == AV_UNKNOWN) || (b->avseq_av->av_un.av_objectclass == NULLOBJECTCLASS))
		return (FALSE);

	for (oidseq = b->avseq_av->av_un.av_objectclass->oc_hierachy; 
			oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) 
		if (quipu_oid_cmp(a->avseq_av->av_un.av_objectclass->oc_ot.ot_oid,oidseq->oid_oid) == 0)
			return (TRUE);

	return (FALSE);
}

oc_print (ps,avs,format)
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);
}

void	dumpalloid ()
{
register int i;
register objectclass      * oc = &ocOIDTable[0];
register oid_table_attr   * at = &attrOIDTable[0];
register oid_table        * oi = &OIDTable[0];
 
	for (i=0;i<ocNumEntries;i++,oc++)
		(void) printf("\"%s\"       %s\n", oc->oc_ot.ot_name, oc->oc_ot.ot_stroid);
 
	for (i=0;i<attrNumEntries;i++,at++)
		(void) printf("\"%s\"       %s\n", at->oa_ot.ot_name, at->oa_ot.ot_stroid);
 
	for (i=0;i<NumEntries;i++,oi++)
		(void) printf("\"%s\"       %s\n", oi->ot_name, oi->ot_stroid);
  
  }

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

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

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