Exemplo n.º 1
0
bool
BNetworkAddress::operator<(const BNetworkAddress& other) const
{
	if (Family() < other.Family())
		return true;
	if (Family() > other.Family())
		return false;

	int compare;

	switch (fAddress.ss_family) {
		default:
		case AF_INET:
		{
			sockaddr_in& address = (sockaddr_in&)fAddress;
			sockaddr_in& otherAddress = (sockaddr_in&)other.fAddress;
			compare = memcmp(&address.sin_addr, &otherAddress.sin_addr,
				sizeof(address.sin_addr));
			break;
		}

		case AF_INET6:
		{
			sockaddr_in6& address = (sockaddr_in6&)fAddress;
			sockaddr_in6& otherAddress = (sockaddr_in6&)other.fAddress;
			compare = memcmp(&address.sin6_addr, &otherAddress.sin6_addr,
				sizeof(address.sin6_addr));
			break;
		}

		case AF_LINK:
			if (LinkLevelAddressLength() < other.LinkLevelAddressLength())
				return true;
			if (LinkLevelAddressLength() > other.LinkLevelAddressLength())
				return true;

			// TODO: could compare index, and name, too
			compare = memcmp(LinkLevelAddress(), other.LinkLevelAddress(),
				LinkLevelAddressLength());
			break;
	}

	if (compare < 0)
		return true;
	if (compare > 0)
		return false;

	return Port() < other.Port();
}
Exemplo n.º 2
0
TInt CCmdSetPrompt::ProcessL( const TDesC& aCommand )
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();

TPtrC param;
TRAPD( error, param.Set( ParamsL( aCommand )) );
if ( error != KErrNone )
	return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() );

TLex parse( param );
if ( !parse.Eos() && !parse.Peek().IsSpace() )
	return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() );

// ParseOnly => not executed.
if ( Family()->Switch(CCmdFamily::EParseOnly) )
	return error;

// Alter prompt, back to the default one if no new one.
param.Set( TfrLex::TrimAndPeel( param ) );
if ( param.Length() == 0 ) 
	param.Set(THA_CommandPrompt);

if ( error = Machine()->SetPrompt( param ), error != KErrNone )
	// ### Failure
	Log( TFR_KFmtErrFailed, &Keyphrase(), error );

return error;
}
Exemplo n.º 3
0
TInt CCmdPause::ProcessL(const TDesC& aCommand)
{
TPtrC param;
TRAPD(error, param.Set(ParamsL(aCommand)));
if (error != KErrNone)
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());
	}

TLex parse( param );
if (!parse.Eos() && !parse.Peek().IsSpace())
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());
	}

// ParseOnly => not executed.
if (Family()->Switch(CCmdFamily::EParseOnly))
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return error;
	}

// Ask any key, prompt is either param or a default.
param.Set( TfrLex::TrimAndPeel(param));
if (param.Length() == 0) 
	param.Set(TFR_KTxtMsgPressAnyKey);

Machine()->Pause(param);
return error;
}
Exemplo n.º 4
0
TInt CCmdPrint::ProcessL(const TDesC& aCommand)
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();

TPtrC param;
TRAPD(error, param.Set(ParamsL(aCommand)));
if (error != KErrNone)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

TLex parse(param);
if ( !parse.Eos() && !parse.Peek().IsSpace() )
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

// ParseOnly => not executed.
if (Family()->Switch(CCmdFamily::EParseOnly))
	return error;

iCurEchoMode = Machine()->EchoMode();
Machine()->SetEchoMode(EFalse);

// Print out the param text.
param.Set(TfrLex::TrimAndPeel(param));
//Print(param, EFalse);
Print(param, ETrue);
//Print(param.Mid(6), EFalse);

//	reset the echo mode to that of before this command!
Machine()->SetEchoMode(iCurEchoMode);

return error;
}
Exemplo n.º 5
0
bool
BNetworkAddress::Equals(const BNetworkAddress& other, bool includePort) const
{
	if (IsEmpty() && other.IsEmpty())
		return true;

	if (Family() != other.Family()
			|| (includePort && Port() != other.Port())) {
		return false;
	}

	switch (fAddress.ss_family) {
		case AF_INET:
		{
			sockaddr_in& address = (sockaddr_in&)fAddress;
			sockaddr_in& otherAddress = (sockaddr_in&)other.fAddress;
			return memcmp(&address.sin_addr, &otherAddress.sin_addr,
				sizeof(address.sin_addr)) == 0;
		}

		case AF_INET6:
		{
			sockaddr_in6& address = (sockaddr_in6&)fAddress;
			sockaddr_in6& otherAddress = (sockaddr_in6&)other.fAddress;
			return memcmp(&address.sin6_addr, &otherAddress.sin6_addr,
				sizeof(address.sin6_addr)) == 0;
		}

		default:
			if (fAddress.ss_len != other.fAddress.ss_len)
				return false;

			return memcmp(&fAddress, &other.fAddress, fAddress.ss_len);
	}
}
Exemplo n.º 6
0
TInt TInetAddr6Only::Input(const TDesC &aBuf)
{
    const TInt ret = TInetAddr::Input(aBuf);
    if (ret == KErrNone && Family() == KAfInet)
        ConvertToV4Mapped();
    return ret;
}
Exemplo n.º 7
0
std::string QSIModelInfo::GetBaseModelNumber(std::string defaultNumber)	// Marketing model number, sans the features.  Just "604" or "RS0.4".
{
	std::string sb;
    bool researchSpec = false;

    switch( Family() )
    {
		case FAM_Series500:
			sb.append( "5" );
			break;
		case FAM_Series600:
			sb.append( "6" );
			break;
		case FAM_ResearchSpec600:
			sb.append( "RS" );
			researchSpec = true;
			break;
		default:
			return defaultNumber;
    }

    switch( CcdSensorType() )
    {
		case CST_KAF_0402:
			sb.append( researchSpec ? "0.4" : "04" );
			break;
		case CST_KAF_1603:
			sb.append( researchSpec ? "1.6" : "16" );
			break;
		case CST_KAF_3200:
			sb.append( researchSpec ? "3.2" : "32" );
			break;
		case CST_KAF_8300:
			sb.append( researchSpec ? "8.3" : "83" );
			break;
		case CST_KAI_2020:
			sb.append( researchSpec ? "2.0" : "20" );
			break;
		case CST_KAI_04022:
			sb.append( researchSpec ? "4.0" : "40" );
			break;
		case CST_ICX674:
			sb.append( researchSpec ? "2.8" : "28" );
			break;
		case CST_ICX694:
			sb.append( researchSpec ? "6.0" : "60" );
			break;
		case CST_ICX814:
			sb.append( researchSpec ? "9.0" : "90" );
			break;			
		default:
			return defaultNumber;
    }

	return sb;
}
Exemplo n.º 8
0
status_t
BNetworkAddress::SetAddress(in_addr_t inetAddress)
{
	if (Family() != AF_INET)
		return B_BAD_VALUE;

	sockaddr_in& address = (sockaddr_in&)fAddress;
	address.sin_addr.s_addr = inetAddress;
	return B_OK;
}
Exemplo n.º 9
0
TBool CCmdRemark::Recognize( const TDesC& aCommand  )
{
// Obey the command family's step over mode.
SetStepOver(Family()->StepOver());

// Check if is empty or begins with # character.
TPtrC cmd = TfrLex::Trim(aCommand);

//	look for empty, # or //
return ((cmd.Length() == 0) || (cmd.Match( _L("#*")) == 0) || (cmd.Match(_L("//*")) == 0 ));
}
Exemplo n.º 10
0
TInt CCmdDisconnect::ProcessL(const TDesC& aCommand)
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();

	TInt error;
	TPtrC conname;
	if (( error = ParseCmdArgs( aCommand, conname )) != KErrNone)
		return error;

	//	Check if the connection already is defined. 
	//	If it is return error, if not create a session and ptr!
	CAnyObject *obj = (CAnyObject *) Machine()->Domains()->Name(conname);

	// at this point we can find the session that the disconnect refers to
	// in the Session, save disconnects eventhandler.
		
	if (obj != NULL)	//	connection (name) exists
		{
		//	get reference to list in CmdConnect from Family and retrieve the reference to the session
		CCmdConnect *iConnect = (CCmdConnect *)Family()->Command(THA_KHTTP_Connect);

		iConnect->DisconnectL(conname);
	
		TBool frmwrk = ((CFrmwrkSession *) obj->Ptr())->UseWSPProtocol() ;

		if (!frmwrk)		// HTTP Session so complete request
			{
			//	check that there are no existing transactions (live) for this session
			//	and that the session is not already closed (i.e. in error)

			//XXXXXXX

			iConnect->Delete(conname); 
			Machine()->Domains()->Delete(conname);

			//	what about the iSessionIndex - this is going to be problematic since we need to track the 
			//	index into the session when it changes...
			WriteDateStamp();
			Log(_L("\tConnection '%S' has been disconnected!"), &conname);
			}
		else
			{
			Log(_L("Issued DisconnectL"));
			}
		}
	else
		return Error(KErrNotFound, THA_KErrConnectionErr, &conname);
	
	if ( error != KErrNone )
		Log(TFR_KFmtErrFailed, &Keyphrase(), error);

	return error;
}
Exemplo n.º 11
0
status_t
BNetworkAddress::SetAddress(const in6_addr& inet6Address)
{
	if (Family() != AF_INET6)
		return B_BAD_VALUE;

	sockaddr_in6& address = (sockaddr_in6&)fAddress;
	memcpy(address.sin6_addr.s6_addr, &inet6Address,
		sizeof(address.sin6_addr.s6_addr));
	return B_OK;
}
Exemplo n.º 12
0
TInt CCmdListAll::ProcessL(const TDesC& aCommand)
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();

if (!Recognize(aCommand))
	return Error(KErrArgument, TFR_KFmtErrBadCmd, &Keyphrase());

// List commands out
Family()->ListAll(Console());
return KErrNone;
}
Exemplo n.º 13
0
TInt CCmdHold::ProcessL( const TDesC& aCommand )
{
TPtrC param;
TRAPD( error, param.Set( ParamsL( aCommand )) );
if ( error != KErrNone )
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase() );
	}

TLex parse( param );
if ( !parse.Eos() && !parse.Peek().IsSpace() )
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() );
	}

// Param must be integer. If no param then default is 1 second.
param.Set( TfrLex::TrimAndPeel(param) );
parse = param;

TInt n;
if ( parse.Eos() )
	n = 1;

else if (parse.Val(n) != KErrNone || !parse.Eos())
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());
	}

// ParseOnly => not executed!
if (Family()->Switch(CCmdFamily::EParseOnly) )
	{
	// Complete the test machine - will then get the next cmd
	Machine()->CompleteRequest();
	return error;
	}

// Hold processing for n seconds.
TTimeIntervalMicroSeconds32 microseconds;
microseconds = 1000000 * n;
Machine()->Hold(microseconds);
return error;
}
Exemplo n.º 14
0
void CompositeFind::readInFamilies(std::string eleFilePath) {
	std::ifstream fin(eleFilePath.c_str());    
	std::string eleLine("");
	getline(fin,eleLine);

	std::vector<std::string> eleStrs;
	Family curFam;
	int preFamilyId = -1;
	int curFamilyId;
	int startPos;
	int endPos;

	while(getline(fin,eleLine)) {
		splitEleLine(eleLine, eleStrs);
		curFamilyId = atoi(eleStrs[0].c_str());
		startPos = atoi(eleStrs[4].c_str());
		if (curFamilyId != preFamilyId ) {
			if (preFamilyId != -1)
				families.push_back(curFam);
			curFam = Family();
			curFam.setID(curFamilyId);
			endPos = atoi(eleStrs[5].c_str());
			curFam.setMinL(endPos - startPos + 1);
			preFamilyId = curFamilyId;
		}
		curFam.increaseCount();
		curFam.addStartPosition(startPos);
	}
	families.push_back(curFam);
	fin.close();

	sort(families.begin(), families.end(), compareFam);
	std::cout<< "families sorted finished, families size:"<< families.size() <<std::endl;

	for (int j=0; j<(int)families.size(); j++) {
		int cnt = families[j].getCount();
		for (int i =0; i< cnt; i++)
			familyMap[families[j].startPositions[i]] = &families[j];
	}

}
Exemplo n.º 15
0
TInt CCmdCheckMode::ProcessL( const TDesC& aCommand )
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();

TPtrC param;
TRAPD( error, param.Set( ParamsL( aCommand )) );
if ( error != KErrNone )
	return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() );

TLex parse( param );
if ( !parse.Peek().IsSpace() )
	return Error( error, TFR_KFmtErrBadCmd, &Keyphrase() );

// Param shall On or Off?
param.Set( TfrLex::TrimAndPeel( param ) );
TBool value = (param.CompareF(TFR_KTxtTermOn) == 0);
if ( !value && param.CompareF(TFR_KTxtTermOff) != 0 )
	return Error( KErrArgument, TFR_KFmtErrBadCmd, &Keyphrase() );

// Set Check Mode (ParseOnly) On/Off.
Family()->SetSwitch(CCmdFamily::EParseOnly, value);
return error;
}
Exemplo n.º 16
0
bool
EDFBFont::IsValid() const
{
	return(fEngine != NULL && fDFBFont != NULL && Family() != NULL && Style() != NULL);
}
Exemplo n.º 17
0
bool
EFontFT2::IsValid() const
{
	return(fFilename != NULL && fFaceIndex >= 0 && nFaces > 0 && Family() != NULL && Style() != NULL);
}
Exemplo n.º 18
0
TInt CCmdIf::ProcessL(const TDesC &aCommand)
{
// Complete the test machine - will then get the next cmd
Machine()->CompleteRequest();

//	this converts the first parameter (if found) into something useful!
TPtrC param;
TRAPD(error, param.Set(ParamsL(aCommand)));
if (error != KErrNone)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

TLex parse(param);
if (!parse.Eos() && !parse.Peek().IsSpace())
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

parse.SkipSpace();
if (parse.Eos())
	//	no parameters so invalid command
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

//	convert into our LValue
TPtrC lvalue;
TRAP(error, lvalue.Set(TfrLex::GetL(parse)));
if (error != KErrNone)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

lvalue.Set(TfrLex::Peel(lvalue));
if (lvalue.Length() > 32)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

//	now check that the second 'param' is one of our comparison tokens...
TPtrC opr;
TRAP(error, opr.Set(TfrLex::GetL(parse)));
if (error != KErrNone) 
	return Error(KErrArgument, TFR_KFmtErrBadCmd, &opr);

//	check is valid length
opr.Set(TfrLex::Peel(opr));
if (opr.Length() > 16) 
	return Error(KErrArgument, THA_KErrParameterLong, &opr);

//	check operator is one of our known list
//	Param shall be HTTP or WSP
opr.Set(TfrLex::TrimAndPeel(opr));
TBool eValue;
if (opr.CompareF(KTxtEquals) == 0)
	eValue = TCO_Equals;

else if (opr.CompareF(KTxtNotEqual) == 0)
	eValue = TCO_NotEqual;

else if (opr.CompareF(KTxtGreaterThan) == 0)
	eValue = TCO_GreaterThan;

else if (opr.CompareF(KTxtLessThan) == 0)
	eValue = TCO_LessThan;

else if (opr.CompareF(KTxtGreaterThanEq) == 0)
	eValue = TCO_GreaterThanEq;

else if (opr.CompareF(KTxtLessThanEq) == 0)
	eValue = TCO_LessThanEq;

else	//	not recognized the comp.operator so error
	return Error(KErrArgument, THA_KErrInvalidOptr, &opr);

//	now look at the final parameter and convert into our LValue
//	assuming that there is anything more.
TPtrC rvalue = TfrLex::Trim(parse.Remainder());
if (rvalue.Length() == 0) 
	return Error(KErrArgument, TFR_KFmtErrBadCmd, &aCommand);

rvalue.Set(TfrLex::TrimAndPeel(rvalue));
if (rvalue.Length() > 16)
	return Error(error, TFR_KFmtErrBadCmd, &Keyphrase());

// ParseOnly => not executed.
if (Family()->Switch(CCmdFamily::EParseOnly))
	return error;

//	determine if we're comparing numeric or data (or both!)
TBool iNumeric = ETrue;
TInt ilval;
TInt irval;
if (InetProtTextUtils::ConvertDescriptorToInt(lvalue,ilval) < 0)
	iNumeric = EFalse;

//	check we're not comparing apples with oranges...
iNumeric = ((InetProtTextUtils::ConvertDescriptorToInt(rvalue,irval) < 0) && iNumeric) ? EFalse : ETrue;

//	now determine the comparison result (also 
//	-1 => error or failure (i.e. < 0) 0 = false, 1 = true
TInt iResult = -2;
switch (eValue)
	{
	case TCO_Equals : 
		iResult = (iNumeric) ? ((TInt) (ilval == irval)) : ((lvalue.Match(rvalue) == 0) ? 1 : 0); break;
	case TCO_NotEqual : 
		iResult = (iNumeric) ? ((TInt) (ilval != irval)) : ((lvalue.Match(rvalue) != 0) ? 1 : 0); break;
	case TCO_GreaterThan : 
		iResult = (iNumeric) ? ((TInt) (ilval > irval)) : ((lvalue.Match(rvalue) == 1) ? 1 : 0); break;
	case TCO_LessThan : 
		iResult = (iNumeric) ? ((TInt) (ilval < irval)) : ((lvalue.Match(rvalue) == -1) ? 1 : 0); break;
	case TCO_GreaterThanEq : 
		iResult = (iNumeric) ? ((TInt) (ilval >= irval)) : ((lvalue.Match(rvalue) >= 0) ? 1 : 0); break;
	case TCO_LessThanEq : 
		iResult = (iNumeric) ? ((TInt) (ilval <= irval)) : ((lvalue.Match(rvalue) < 1) ? 1 : 0); break;
	}

//	the result now determines if we continue processing (and ignore any following ELSE)
//	before we meet the ENDIF or we skip and perform the ELSE clause...
//	NOTE: now we can nest IF's etc, we MUST count those that are met when we
//				'ignore' lines as these MAY be incorrectly nested...
TBool iSuccess = (TBool) iResult;
if (iSuccess)
	Machine()->IfL(CIFControl::EIFTrue, iSuccess, CIFControl::EInIF);
else
	//	failed test so skip the true block
	Machine()->IfL(CIFControl::EELSETrue, iSuccess, CIFControl::EInIF);

//	whilst we would be better off returning the actual result, it bears little consequence
//	- in fact if we get here we're ok anyway...
return KErrNone;
}
Exemplo n.º 19
0
Particle::Particle(exroot::LHEFParticle const& particle, int id) :
    PseudoJet(LorentzVector<Momentum>(particle))
{
    SetInfo(Family(id, Relative::particle));
}