|
|
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 d
Length: 4578 (0x11e2)
Types: TextFile
Names: »dn.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/dsap/common/dn.c«
/* dn.c - General Directory Name routines */
#ifndef lint
static char *rcsid = "$Header: /f/osi/dsap/common/RCS/dn.c,v 6.0 89/03/18 23:27:28 mrose Rel $";
#endif
/*
* $Header: /f/osi/dsap/common/RCS/dn.c,v 6.0 89/03/18 23:27:28 mrose Rel $
*
*
* $Log: dn.c,v $
* Revision 6.0 89/03/18 23:27:28 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/name.h"
extern LLog * log_dsap;
static char dn_alias;
dn_comp_free (dn)
DN dn;
{
rdn_free (dn->dn_rdn);
free ((char *) dn);
}
dn_free (dn)
DN dn;
{
register DN eptr;
for (eptr = dn; eptr != NULLDN; eptr = eptr->dn_parent)
dn_comp_free (eptr);
}
DN dn_comp_new (rdn)
RDN rdn;
{
DN ptr;
ptr = dn_comp_alloc ();
dn_comp_fill (ptr,rdn);
ptr->dn_parent = NULLDN;
return (ptr);
}
dn_decode (x)
DN x;
{
register DN eptr;
for (eptr = x; eptr != NULLDN; eptr = eptr->dn_parent)
rdn_decode (eptr->dn_rdn);
}
dn_append (a,b)
DN a,b;
{
register DN ptr;
register DN eptr;
if (a == NULLDN)
DLOG (log_dsap,LLOG_DEBUG,("appending to null dn!"));
else {
for (eptr = a; eptr != NULLDN; eptr = eptr->dn_parent)
ptr = eptr;
ptr->dn_parent = b;
}
}
DN dn_comp_cpy (dn)
register DN dn;
{
register DN ptr;
if (dn==NULLDN) {
DLOG (log_dsap,LLOG_DEBUG,("copy of null dn"));
return (NULLDN);
}
ptr = (DN) smalloc (sizeof(dncomp));
ptr->dn_rdn = rdn_cpy (dn->dn_rdn);
ptr->dn_parent = NULLDN;
return (ptr);
}
DN dn_cpy (dn)
register DN dn;
{
DN start;
register DN eptr,ptr,ptr2;
if (dn == NULLDN) {
DLOG (log_dsap,LLOG_DEBUG,("dn_cpy of null dn"));
return (NULLDN);
}
start = dn_comp_cpy (dn);
ptr2 = start;
for (eptr = dn->dn_parent; eptr != NULLDN; eptr = eptr->dn_parent) {
ptr = dn_comp_cpy (eptr);
ptr2->dn_parent = ptr;
ptr2 = ptr;
}
return (start);
}
dn_cmp (a,b)
register DN a,b;
{
for (; (a != NULLDN) && (b != NULLDN) ; a = a->dn_parent, b = b->dn_parent)
if ( dn_comp_cmp (a,b) == NOTOK) {
return NOTOK;
}
if (( a == NULLDN) && (b == NULLDN)) {
return OK;
} else {
return NOTOK;
}
}
dn_cmp_prefix (a,b)
register DN a,b;
{
for (; a != NULLDN && b != NULLDN ; a = a->dn_parent, b = b->dn_parent)
if ( dn_comp_cmp (a,b) == NOTOK) {
return NOTOK;
}
if ( a == NULLDN) {
return OK;
} else {
return NOTOK;
}
}
dn_print (ps,dn,format)
DN dn;
PS ps;
int format;
{
register DN eptr;
if (dn == NULLDN) {
if (format == READOUT)
ps_print (ps,"NULL DN");
return ;
}
dn_comp_print (ps,dn,format);
if (dn->dn_parent != NULLDN)
for (eptr = dn->dn_parent; eptr != NULLDN; eptr = eptr->dn_parent) {
switch (format) {
case DIROUT: ps_print (ps,"/"); break;
case EDBOUT: ps_print (ps,"@"); break;
case READOUT: ps_print (ps," @ "); break;
}
dn_comp_print (ps,eptr,format);
}
}
DN str2dn (str)
register char * str;
{
register char *ptr;
char *save,val;
char * aliasptr;
DN dn = NULLDN, newdn;
RDN rdn;
char * alias2name ();
char * SkipSpace ();
if (str == NULLCP)
return (NULLDN);
while ( (ptr = index (str,'@')) != 0) {
save = ptr++;
save--;
if (! isspace (*save))
save++;
val = *save;
*save = 0;
if (dn == NULLDN)
/* try str as an alias */
if ((aliasptr = alias2name (SkipSpace(str))) != NULLCP) {
dn_alias = TRUE;
if ((newdn = str2dn(aliasptr)) == NULLDN) {
parse_error ("Invalid alias '%s'",aliasptr);
dn_free (dn);
return (NULLDN);
}
dn = newdn;
*save = val;
str = ptr;
continue;
}
if ((rdn = str2rdn (str)) == NULLRDN) {
dn_free (dn);
return (NULLDN);
}
if (dn == NULLDN)
dn = dn_comp_new (rdn);
else
dn_append (dn,dn_comp_new (rdn));
*save = val;
str = ptr;
}
/* try str as an alias */
if (dn == NULLDN)
if ((aliasptr = alias2name (SkipSpace(str))) != NULLCP) {
dn_alias = TRUE;
if ((newdn = str2dn(aliasptr)) == NULLDN) {
parse_error ("Invalid alias '%s'",aliasptr);
dn_free (dn);
return (NULLDN);
}
return (newdn);
}
if ((rdn = str2rdn (str)) == NULLRDN) {
dn_free (dn);
return (NULLDN);
}
if (dn == NULLDN)
dn = dn_comp_new (rdn);
else
dn_append (dn,dn_comp_new (rdn));
return (dn);
}
DN str2dn_aux (str,alias)
char * str;
char *alias;
{
DN dn;
dn_alias = FALSE;
dn = str2dn (str);
*alias = dn_alias;
return (dn);
}