예제 #1
0
static void	handle_role_start(LoadMibState *state, const char **atts)
{
	int	rolenbr = 0;
	char	*rolename = NULL;
	char	*pubkeyname = NULL;
	char	*privkeyname = NULL;
	char	**att;
	char	*name;
	char	*value;
	AppRole	*role;

	if (noMibYet(state)) return;
	if (state->venture == NULL)
	{
		return noteLoadError(state, "Venture not specified.");
	}

	for (att = (char **) atts; *att; att++)
	{
		name = *att;
		att++;
		value = *att;
		if (strcmp(name, "nbr") == 0)
		{
			rolenbr = atoi(value);
		}
		else if (strcmp(name, "name") == 0)
		{
			rolename = value;
		}
		else if (strcmp(name, "pubkey") == 0)
		{
			pubkeyname = value;
		}
		else if (strcmp(name, "privkey") == 0)
		{
			privkeyname = value;
		}
		else return noteLoadError(state, "Unknown attribute.");
	}

	if (rolename == NULL)
	{
		return noteLoadError(state, "Need name of role.");
	}

	role = lookUpRole(state->venture, rolename);
	switch (state->currentOperation)
	{
	case LoadAdding:
		if (role == NULL)
		{
			role = createRole(state->venture, rolenbr, rolename,
					pubkeyname, privkeyname);
			if (role == NULL)
			{
				return putErrmsg("Couldn't add role.",
						rolename);
			}
		}
		else
		{
			return noteLoadError(state, "Role already in MIB.");
		}

		break;

	case LoadChanging:
		return noteLoadError(state, "'Change' not yet implemented.");

	case LoadDeleting:
		if (role == NULL)
		{
			return noteLoadError(state, "No such role.");
		}

		state->target = role;	/*	May be deletion target.	*/
		break;

	default:
		return noteLoadError(state, "Not in an operation.");
	}
}
예제 #2
0
void TBox :: buildDAG ( void )
{
	nNominalReferences = 0;

	// init concept indexing
	nC = 1;	// start with 1 to make index 0 an indicator of "not processed"
	ConceptMap.push_back(NULL);

	// make fresh concept and datatype
	concept2dag(pTemp);
	DLTree* freshDT = DTCenter.getFreshDataType();
	addDataExprToHeap ( static_cast<TDataEntry*>(freshDT->Element().getNE()) );
	deleteTree(freshDT);

	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		concept2dag(*pc);
	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		concept2dag(*pi);

	// init heads of simple rules
	for ( TSimpleRules::iterator q = SimpleRules.begin(), q_end = SimpleRules.end(); q < q_end; ++q )
		(*q)->bpHead = tree2dag((*q)->tHead);

	// builds Roles range and domain
	initRangeDomain(ORM);
	initRangeDomain(DRM);

	// build all splits
	for ( TSplitVars::iterator s = getSplits()->begin(), s_end = getSplits()->end(); s != s_end; ++s )
		split2dag(*s);

	RoleMaster::iterator p, p_end;

	// build all GCIs
	DLTree* GCI = Axioms.getGCI();

	// add special domains to the GCIs
	if ( likely(useSpecialDomains) )
		for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
			if ( !(*p)->isSynonym() && (*p)->hasSpecialDomain() )
				GCI = createSNFAnd ( GCI, clone((*p)->getTSpecialDomain()) );

	// take chains that lead to Bot role into account
	if ( !ORM.getBotRole()->isSimple() )
		GCI = createSNFAnd ( GCI,
				new DLTree ( TLexeme(FORALL), createRole(ORM.getBotRole()), createBottom() ) );

	T_G = tree2dag(GCI);
	deleteTree(GCI);

	// mark GCI flags
	GCIs.setGCI(T_G != bpTOP);
	GCIs.setReflexive(ORM.hasReflexiveRoles());

	// builds functional labels for roles
	for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );
	for ( p = DRM.begin(), p_end = DRM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );

	// check the type of the ontology
	if ( nNominalReferences > 0 )
	{
		unsigned int nInd = i_end() - i_begin();
		if ( nInd > 100 && nNominalReferences > nInd )
			isLikeWINE = true;
	}

	// here DAG is complete; set its final size
	DLHeap.setFinalSize();
}
예제 #3
0
static int	loadTestMib()
{
	AmsMibParameters	parms = { 1, "dgr", NULL, NULL };
	AmsMib			*mib;
	char			ownHostName[MAXHOSTNAMELEN + 1];
	char			eps[MAXHOSTNAMELEN + 5 + 1];
	LystElt			elt;
	Venture			*venture;
	AppRole			*role;
	Subject			*subject;

	mib = _mib(&parms);
	if (mib == NULL)
	{
		return crash();
	}

	getNameOfHost(ownHostName, sizeof ownHostName);
	isprintf(eps, sizeof eps, "%s:2357", ownHostName);
	elt = createCsEndpoint(eps, NULL);
       	if (elt == NULL)
	{
		return crash();
	}

	elt = createApp("amsdemo", NULL, NULL);
       	if (elt == NULL)
	{
		return crash();
	}

	venture = createVenture(1, "amsdemo", "test", NULL, 0, 0);
	if (venture == NULL)
	{
		return crash();
	}

	role = createRole(venture, 2, "shell", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	role = createRole(venture, 3, "log", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	role = createRole(venture, 4, "pitch", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	role = createRole(venture, 5, "catch", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	role = createRole(venture, 96, "amsd", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	role = createRole(venture, 97, "amsstop", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	role = createRole(venture, 98, "amsmib", NULL, NULL);
	if (role == NULL)
	{
		return crash();
	}

	subject = createSubject(venture, 1, "text",
			"Arbitrary variable-length text.", NULL, NULL, NULL);
	if (subject == NULL)
	{
		return crash();
	}

	subject = createSubject(venture, 97, "amsstop",
			"Message space shutdown command.", NULL, NULL, NULL);
	if (subject == NULL)
	{
		return crash();
	}

	subject = createSubject(venture, 98, "amsmib",
			"Runtime MIB updates.", NULL, NULL, NULL);
	if (subject == NULL)
	{
		return crash();
	}

	return 0;
}