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 d

⟦ed1867511⟧ TextFile

    Length: 5475 (0x1563)
    Types: TextFile
    Names: »ds_init.c«

Derivation

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

TextFile

/* ds_init.c - initialise the DSA */

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

/*
 * $Header: /f/osi/quipu/RCS/ds_init.c,v 6.0 89/03/18 23:41:17 mrose Rel $
 *
 *
 * $Log:	ds_init.c,v $
 * Revision 6.0  89/03/18  23:41:17  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/read.h"
#include "quipu/dua.h"
#include "quipu/connection.h"
#include "quipu/entry.h"

DN super_user;
extern Entry database_root;
Entry subtree_load ();
Entry make_path ();
extern LLog * log_dsap;
extern DN mydsadn;
static Entry load_dsa_cache_entry(), load_dsa_remote_entry();

dsa_init (name)
char * name;
{
Attr_Sequence as;
AttributeType manager;
extern char * mydsaname;
DN str2dn();
extern char * treedir;
struct edb_info * dsainfo;
AV_Sequence avs;
Entry newentry;
extern char * new_version();
extern char * quipuversion;
extern int parse_status;
Entry my_entry, rem_entry;

	check_known_oids ();

	if (( manager = AttrT_new (MANAGER_OID)) == NULLAttrT)
		fatal (-1,"Manager - unknown attribute - check oid tables");

	LLOG (log_dsap,LLOG_NOTICE,("dsa name %s",mydsaname));

	if ((mydsadn = str2dn (mydsaname)) == NULLDN) {
		fatal (-2,"Invalid dsa name");
	}

	/* Try to load root of tree */
	database_root = directory_load (name,'w',TRUE);
	if (parse_status != 0)
		fatal (-3,"DSA Halted");

	if ((my_entry = local_find_entry (mydsadn,TRUE)) == NULLENTRY) 
		my_entry = load_dsa_cache_entry (mydsadn) ;

	if (my_entry == NULLENTRY) {
		LLOG (log_dsap,LLOG_NOTICE,("Can't find my own entry - trying another DSA"));
		if ((my_entry = load_dsa_remote_entry (mydsadn)) == NULLENTRY)
			fatal (-4,"can't get my own entry!");
		else
			(void) journal (my_entry);
	} else if (my_entry->e_data == E_TYPE_CACHE_FROM_MASTER)
		if ((rem_entry = load_dsa_remote_entry (mydsadn)) != NULLENTRY) {
			if (rem_entry->e_parent != NULLENTRY)
				rem_entry->e_parent->e_edbversion = new_version();
			(void) journal (rem_entry);
			my_entry = rem_entry;
		}

	if (my_entry->e_passwd == NULLCP) 
		/* This is not a fatal error, but some remote operations may fail */
		LLOG(log_dsap,LLOG_EXCEPTIONS,("Can't find my own PASSWORD"));

	if (my_entry->e_dsainfo != NULLDSA) {
		/* get manager attribute */
		if ((as = as_find_type(my_entry->e_attributes,manager)) == NULLATTR )
			fatal (-5,"Manager attribute missing in my own entry");
		AttrT_free (manager);
		super_user = dn_cpy (as->attr_value->avseq_av->av_un.av_dn);
		if (strcmp(my_entry->e_dsainfo->dsa_version,quipuversion) != 0)
			LLOG(log_dsap,LLOG_EXCEPTIONS,("WARNING: version number wrong (expecting '%s', got '%s') !!",quipuversion,my_entry->e_dsainfo->dsa_version));
	} else 
		fatal (-6,"No edbinfo attribute in my own entry");

	for (avs = my_entry->e_dsainfo->dsa_attr ; avs != NULLAV; avs=avs->avseq_next) {
		if (avs->avseq_av == NULLAttrV)
			continue;
		dsainfo = avs->avseq_av->av_un.av_update;
		if (dsainfo->edb_name != NULLDN) {
			newentry = make_path (dsainfo->edb_name);
			(void) subtree_load (newentry,dsainfo->edb_name);
			if (parse_status != 0)
				fatal (-7,"DSA Halted (2)");
		}
	}

	return (OK);

}

static Entry load_dsa_cache_entry(dn)
DN dn;
{
DN ptr,trail = NULLDN;
Entry newentry;

	for (ptr=dn; ptr->dn_parent != NULLDN; ptr=ptr->dn_parent)
		trail = ptr;

	if (trail == NULLDN)
		return (NULLENTRY);

	trail->dn_parent = NULLDN;
	newentry = make_path (dn);
	(void) subtree_load (newentry,dn);
	trail->dn_parent = ptr;
	
	return (local_find_entry (mydsadn,TRUE)); 
}

static Entry load_dsa_remote_entry(dn)
DN dn;
{
static struct ds_read_arg read_arg =
	{
		default_common_args,
		NULLDN,
		{       /* entry info selection */
			TRUE,
			NULLATTR,
			EIS_ATTRIBUTESANDVALUES
		}
	};
struct ds_read_result result;
struct DSError error;
extern Entry current_entry;
static struct ds_bind_arg bindarg;
static struct ds_bind_arg bindresult;
static struct ds_bind_error binderr;
int ad;
extern struct PSAPaddr *parent_psap();
struct PSAPaddr * addr;

#ifndef NO_STATS
extern LLog * log_stat;
extern dn_print ();

	dn_decode (dn);
	pslog (log_stat,LLOG_NOTICE,"remote dsa entry lookup",dn_print,(caddr_t)dn);
#endif

	/* read from of remote DSA */
	/* Do synchronus read for now */
	/* Async read eventually */

	make_dsa_bind_arg (&bindarg);

	if ((addr = parent_psap ()) == NULLPA) {
		LLOG (log_dsap,LLOG_EXCEPTIONS,("No parent or quipu-db defined - check quiputailor"));
		return (NULLENTRY);
	}
	
	if (dap_bind (&ad, &bindarg, &binderr, &bindresult,addr) != OK) {
		LLOG (log_dsap,LLOG_EXCEPTIONS,("Can't bind to remote DSA thus can't read my own entry"));
		return (NULLENTRY);
	}

	read_arg.rda_object = dn;

	if (dap_read (ad, 1,&read_arg, &error, &result) != DS_OK) {
		log_ds_error (&error);
		LLOG (log_dsap,LLOG_EXCEPTIONS,("Remote DSA failed on lookup of my address"));
		(void) dap_unbind (ad);
		return (NULLENTRY);
	}

	cache_entry (&(result.rdr_entry), TRUE, EIS_ATTRIBUTESANDVALUES);

	if (unravel_attribute (current_entry,&error,TRUE) != OK) {
		log_ds_error (&error);
		LLOG (log_dsap, LLOG_EXCEPTIONS, ("Remote copy of my entry is wrong!"));
		return (NULLENTRY);
	}

	(void) dap_unbind (ad);

	return (current_entry);
}