示例#1
0
void check_ontology(list * output) {
	int i;
	char * dir = getenv("PANINI");
	char * fn = malloc(strlen(dir) + strlen("ontology.csv")+1);
	strcpy(fn,dir);
	strcat(fn, "ontology.csv");
	list * ontology = csvloader(fn);
	free(fn);
	
	for(i = 1; i<= output->length; i++) {
		int j;
		list * definitions = list_get_list(output, i);
		if(!definitions) continue;
		
		for(j = 2; j <= definitions->length; j++) {
			list * def = list_get_list(definitions, j);
			if(def)
				checkrule(def, ontology);
		}
	}
}
示例#2
0
int Rule(char *oriCalledNum, PtrRule pDialTab, char *objCalledNum)
{	
	
	char *p = NULL;
	char plustemp[50] = {0};
	char minuttemp[50] = {0};
	char preAndMidd[100] = {0};
	char TempCalledNum[64] = {0};
	//char convertStr[256] = {0};

	int i = 0;

	if (pDialTab == NULL)
		return NULL;

	if (oriCalledNum == NULL || strcmp(oriCalledNum, "\0") == 0)
		return NULL;

	if (objCalledNum == NULL)
		return NULL;	
	
	sprintf(TempCalledNum, "0%s", oriCalledNum);
	while(!IsLast(pDialTab))
	{
		pDialTab = pDialTab->Next;
		TRACE("DialPlan=%s\n", pDialTab->CodeRule);
		
		if (checkrule(pDialTab->CodeRule) != 1)
			continue;
		
		for (i = 0; pDialTab->CodeRule[i] != '+';  i++)
		{
			if (pDialTab->CodeRule[i] == '+')
				break;
			plustemp[i] = pDialTab->CodeRule[i];
		}

		strncat(preAndMidd, plustemp, sizeof(preAndMidd));
		
		i++;
		
		for(int j = 0; pDialTab->CodeRule[i] != '|';  i++, j++)
		{
			if (pDialTab->CodeRule[j] == '|')
				break;
			
			minuttemp[j] = pDialTab->CodeRule[i];		
		}	

		if((sizeof(preAndMidd)-strlen(preAndMidd)-1) >= strlen(minuttemp))
			strncat(preAndMidd, minuttemp, sizeof(preAndMidd)-strlen(preAndMidd)-1);
		else
			continue;
		
		if (strlen(preAndMidd) > 0 && strncmp(preAndMidd, TempCalledNum, strlen(preAndMidd)) == 0)
		{
			strncat(objCalledNum, plustemp, strlen(plustemp));
			strncat(objCalledNum, TempCalledNum+strlen(preAndMidd), strlen(TempCalledNum) - strlen(preAndMidd));
			return strlen(objCalledNum);
		}
		
		memset(preAndMidd, 0, sizeof(preAndMidd));
	}			

	return  (0);
}