void CFilteringTable::LoadScript()
{
	CMHFile file;
	file.Init(
		_T("system\\resource\\filterWord.bin"),
		_T("rb"));

	Type type = TypeNone;

	while(FALSE == file.IsEOF())
	{
		TCHAR buffer[MAX_PATH] = {0};
		file.GetLine(
			buffer,
			sizeof(buffer) / sizeof(*buffer));
		
		if(0 == _tcslen(buffer))
		{
			continue;
		}

		LPCTSTR commentMark = _T("@");

		if(0 == _tcsnicmp(buffer, commentMark, _tcslen(commentMark)))
		{
			continue;
		}
		else if(0 == _tcsicmp(buffer, _T("#GM")))
		{
			type = TypePartiallyBlockedName;
			continue;
		}
		else if(0 == _tcsicmp(buffer, _T("#SLANG")))
		{
			type = TypePartiallyBlockedKeyword;
			continue;
		}
		else if(0 == _tcsicmp(buffer, _T("#SYSTEM")))
		{
			type = TypeEntirelyBlockedName;
			continue;
		}

		TCHAR text[MAX_PATH] = {0};
		RemoveSpace(
			buffer,
			text,
			sizeof(text) / sizeof(*text));
		_tcsupr(
			text);

		KeywordContainer& keywordContainer = mFilterContainer[type];
		keywordContainer.insert(
			text);
	}
}
bool ProcessIso2DB::Execute(char *send){
	char bit[LEN_MAX_BIT];
	char msgClass[4+1], procCode[6+1];

	Iso8583 *iso = new Iso8583(ISO_IPIRANGA);
	iso->Extract( m_read.c_str()+HEADER_LEN);

	GatewayInProcessConfig* proc = GatewayInProperties::getInstance()->ProcessConfig();

	memset(msgClass,0,sizeof(msgClass));
	memset(procCode,0,sizeof(procCode));
	strncpy(msgClass, m_read.c_str()+HEADER_LEN  , 4 );
	iso->Get(3,procCode );

	ProcessConfig* process = proc->FindProcessConfig(msgClass , procCode );
	if( process ) {
		MssqlDB *db = new MssqlDB(GatewayInProperties::getInstance()->StrConnectionDB());
		if( db->IsConnect() ) {
			db->StoreProcedure(process->StoredProcedure().c_str());		

			list<BitRow*>::iterator it;
			for ( it=process->LstBitRow().begin() ; it != process->LstBitRow().end(); it++ ){
				memset(bit , 0 , sizeof(bit));
				iso->Get(atoi((*it)->Bit().c_str()),bit );
				db->InsertParameter((*it)->SqlRow().c_str() , bit, (ParameterDirectionEnum)atoi((*it)->SqlType().c_str()));			
			}

			db->Execute();
			{
				char codProc[4+1];
				memset(codProc,0,sizeof(codProc));
				strncpy(codProc , m_read.c_str()+HEADER_LEN , 4 );
				codProc[2]='1';
				iso->CreateSend( send, codProc);
			}
			for ( it=process->LstBitRow().begin() ; it != process->LstBitRow().end(); it++ ){
				string value = Variant2String(db->GetParameter((*it)->SqlRow().c_str()) );
				RemoveSpace( value );
				iso->Set( atoi( (*it)->Bit().c_str() ), value.c_str() );
			}	
			delete db;
			delete iso;
			return true;
		} 
		delete db;
	}
	delete iso;
	return false;

}
Beispiel #3
0
/* =======================================================================
 *  Callback function processing each field of comma-delimited arg string
 * ======================================================================= */
void cbProcessListElement (void *s, size_t len, void *data)
{
        char buf[1024] = "";
        char mddname[1024] = "";
	LIST_DATA *ldata = (LIST_DATA*)data;

	bool Not = false; // negation flag - set to true if ! preceeds the id

        if (s)
        {

                strncpy(buf, (char*)s, len);
                RemoveSpace(buf);


		if (buf[0] == '!') // negation detected
		{
			sprintf(mddname, "ra%s%s", buf + 1, conf.suffix);
			Not = true;
			GetSignalInfo(ldata->nLn, buf + 1 , mddname);
		}
		else
		{
			sprintf(mddname, "ra%s%s", buf, conf.suffix);
			GetSignalInfo(ldata->nLn, buf , mddname);
		}

		fprintf(stderr, "inputsLst(%d) = %s\n", InpCnt, buf);
		strcpy(inputsLst[InpCnt], buf);
		InpCnt++;


		if ((signals + nSig - 1)->found)
			fprintf(ldata->flp, "\t// Internal ID: %s    External ID: %s\n", (signals + nSig - 1)->radiyname, 
					(signals + nSig - 1)->extID);
		if (Not)
			fprintf(ldata->flp, "\t%s.%s[%d] = !%s;\n", ldata->dataName, ldata->lp,  ldata->cnt, mddname);
		else
			fprintf(ldata->flp, "\t%s.%s[%d] = %s;\n", ldata->dataName, ldata->lp,  ldata->cnt, mddname);

		
		
		ldata->cnt++;
        }

}
BOOL CFilteringTable::IsInvalidText(Type type, LPCTSTR text) const
{
	const FilterContainer::const_iterator filterIterator = mFilterContainer.find(
		type);

	if(mFilterContainer.end() == filterIterator)
	{
		return FALSE;
	}

	const KeywordContainer& keywordContainer = filterIterator->second;

	TCHAR buffer[MAX_PATH] = {0};
	RemoveSpace(
		text,
		buffer,
		sizeof(buffer) / sizeof(*buffer));
	_tcsupr(
		buffer);

	if(TypeEntirelyBlockedName == type)
	{
		return keywordContainer.end() != keywordContainer.find(
			buffer);
	}

	const Text checkedText(buffer);
	
	for(KeywordContainer::const_iterator iterator = keywordContainer.begin();
		keywordContainer.end() != iterator;
		++iterator)
	{
		if(FindPartially(checkedText, *iterator))
		{
			return TRUE;
		}
	}

	return FALSE;
}
Beispiel #5
0
/* ========================================================================
 * This function will analyze expression and fill in EXPRESSION structure
 * holding:
 * left part (lp)
 * right part (rp)
 * If right part isn't a signal name signal flag = false, number = true
 * otherwise flags are assigned other way round
 * If signal name is in MDD then set inMDD = true;
 * If anything goes wrong set error = TRUE and give up
 * IMPORTATNT: function assumes all blanks are stripped from expr arg
 * UPD: however we call  RemoveSpace again to sleep better
 * ======================================================================== */
int ParseExpression(char *expr, EXPRESSION *exprData)
{

        char *ch = NULL;
        char buf[1024] = "";

        if (!expr)
                return -1;

	// Do cleanup
	memset(exprData, '\x0', sizeof(EXPRESSION));
        strcpy(buf, expr);
	
	// Strip spaces if any 
	RemoveSpace(buf);

        ch = strstr(buf, "=");

        if (ch) // There's equal sign, treat expr as an Y = X style expression 
        {
		// Get right part, then terminate at '='
                strcpy(exprData->rp, ch + 1);
                *ch = '\x0';
		
		// Get left part
                strcpy(exprData->lp, buf);

		// Check if the right part is a list (for OR, AND etc)
		// If it is not: 
		// 1. Check if the right part is numeric
		// 2. If it is not then treat it as a signal name

		if ((isList(exprData->rp)) == RP_LIST) // right part is comma-sep list
		{
			exprData->list = true;
			exprData->signal = false;
			exprData->number = false;
			// That's it for the list - we already have it in rp member, no further processing needed
		}
		else // right part is an individual signal or number
		{
			if ((isNumeric(exprData->rp)) == RP_SIGNAL) // signal - we'll make MDD name of it
			{
	
				// make MDD point name and store it to mddname, separately from rp
				memset(buf, '\x0', sizeof(buf));

				// set flag if negation needed that is '!' stands in front of signal name
				if (exprData->rp[0] == '!')	
				{
					exprData->Not = true;
					sprintf(buf, "ra%s%s", (exprData->rp) + 1, conf.suffix);
					fprintf(stderr, "ParseExpression: negation found: rp = %s buf = %s\n", exprData->rp, buf);
				}
				else 
				{
					exprData->Not = false;
					sprintf(buf, "ra%s%s", exprData->rp, conf.suffix);
				}

				strcpy(exprData->mddname, buf);
				
				exprData->list = false;
				exprData->signal = true;
				exprData->number = false;
			}	// number on the right part - set flags and that's it
			else
			{
				exprData->signal = false;
				exprData->list = false;
				exprData->number = true;
			}
		}
		

                return IAM_EXPRESSION;
        }

	// expr isn't an expression in fact
	exprData->error = true;
	return IAMNOT_EXPRESSION;
}
Beispiel #6
0
void main(void)
{
	int i;
	const int TC_MAX = 26;
	char buf[BUF_MAX] = { 0, };
	char exp[TC_MAX][BUF_MAX] =
	{
		"1+2+3",
		"(1+2)+3",
		"1+(2+3)",
		"-(1+2)+3",
		"-(-1+2)+3",
		"(-2)*3",
		"-3*(-3)",
		"((1+2)*3)-2",
		"(((1+2)*(2-3))/3)",
		"-(-(2+3))",
		"2+(-4*2-(2+3))",
		"-((1+(-2)+(3+(4+(-5)+6+(-7))+8)+9)+(-10))",
		"(((1+2)*(2-3))/3) % 7 + (-34*7-98/2*(-2))",
		"-( 28 * (( -23 - 7 % 9 )-( 22 / 3 - 9 * 4 -( -8 + 6 * 3 )))) ",
		"(-(28*((-44 -7%5) - (22/3645-977*4 -(8+654*3)))) -(28*((-23 -7%9) - (22/3-9*4 -(-8+6*3))))) * 6-45",
		"-123456789 + 123456789 + 4 * 596 % 10 -87 /14",		
		"1*2*3*4*5*6*7*8*9",
		"-(1*((-2)*(3*(-4)*5*(-6)*7)))*(-8*9)",
		"1234567890/24444/21/2",
		"1234567890/((-24444)/21)/(-2)",
		"1*+3",
		"11231*-324",
		"1+(+1)",
		"1-(-1)",
		"-5*-4-5*4+5*4+5*-4",
//		"1+-+1",
//		"1-+-1",
//		"1+-+-1",
//		"1-+-+1",
//		"1*+-+-1",
//		"1*+-+1",
//		"-+-+1-+1",		// +/- 의 배치에 따라 안되는 경우 잔존함
//		"+-+1-+1",
//		"-341*-(+-+-+-+1)",
//		"-341+(-(+-+-+-+12))",
//		"-+-+-+(-+-34)*-+-(32/-+-+-5)"
//		"(-(28*((-44*1*1 -7%5 -341*-(+1)) - (22/3645-977*4 -(8+1-1+654*3)))) -(28*((-23 -7%9) - (22/3-9*4 -(-8+6*3))))) * 6-45 +1-+1"
		"(-(28*((-44*1*-1 -7%5 -341*-(+1)) - (22/3645-977*4 -(8+1+1+654*3)))) -(28*((-23 -7%9) - (22/3-9*4 -(-8+6*3))))) * 6-45 -1-+1"
	};

	// Expresion Test
	i = -((1+(-2)+(3+(4+(-5)+6+(-7))+8)+9)+(-10));
	i = -(1*((-2)*(3*(-4)*5*(-6)*7)))*(-8*9);
	i = 1*+-+-1;
	i = 1+-+1;
	i = 1+-+-+1;
	i = 1-+-+-+1;
	i = 1-+-+-+-+1;
	i = 1-+-+-+-+-1;

	for (i = 0; i < TC_MAX; i++)
	{
		RemoveSpace(buf, exp[i]);
		while (HasBrase(buf))
		{
			ParseBrace(buf);
		}
		CalcExpresion(buf);		
		PutS(buf);
		PutS(" \t");
		PutS(exp[i]);
		PutS("\n");
	}
	return;
}