Beispiel #1
0
void CAtkisSatz::LoeschSatz(LPCSTR pcDaten)
{
// Objektnummer des zu löschenden Objektes herausfischen
CxString strBuffer(pcDaten);
CxString strObjektnummer, strAktualitaet;
int pos = strBuffer.Find("DLOB2005EQ");

	if (pos >= 0) {
		strObjektnummer = strBuffer.Mid(pos + 10, 7);
		pos = strBuffer.Find("DLOB2003EQ");
		if (pos >= 0)
			strAktualitaet = strBuffer.Mid(pos + 10, 2);
	}

// dieses Objekt in TRiAS löschen
INT_PTR lMCode = DEX_GetMCodeFromFeatureNameCIEx(DEX_GetDataSourceHandle(), "ALK-Objektnummer");

	_ASSERTE(0 != lMCode);
	if (0 != lMCode) {
	ENUMRECHTEXTMERKMAL ERTM;

		INITSTRUCT(ERTM, ENUMRECHTEXTMERKMAL);
		ERTM.pView = NULL;
		ERTM.lMCode = lMCode;
		ERTM.pMWert = (LPSTR)(LPCSTR)strObjektnummer;
		ERTM.iMode = SMExactMatch;
		ERTM.eFcn = DeleteUpdatedObject;
		ERTM.pData = NULL;
		DEX_EnumRechTextMerkmal(ERTM);
	} 
}
    bool ExportSettingsManager::LoadSettings( const CHAR* strFileName )
    {
        FILE* fp = nullptr;
        fopen_s( &fp, strFileName, "r" );
        if( !fp )
        {
            return false;
        }

        const size_t dwBufferSize = 32 * 1024;
        std::unique_ptr<CHAR[]> strBuffer( new CHAR[dwBufferSize] );
        ZeroMemory( strBuffer.get(), dwBufferSize * sizeof( CHAR ) );

        size_t dwReadBytes = fread( strBuffer.get(), sizeof(CHAR), dwBufferSize, fp );
        fclose( fp );

        if( dwReadBytes == 0 )
        {
            return false;
        }
        else
        {
            assert( dwReadBytes < dwBufferSize );
            strBuffer[dwReadBytes] = '\0';
            bool bSuccess = UnMarshalAllSettings( strBuffer.get() );
            return bSuccess;
        }
    }
    bool ExportSettingsManager::SaveSettings( const CHAR* strFileName )
    {
        const size_t dwBufferSize = 32 * 1024;
        std::unique_ptr<CHAR[]> strBuffer( new CHAR[dwBufferSize] );
        ZeroMemory( strBuffer.get(), dwBufferSize * sizeof( CHAR ) );

        bool bSuccess = MarshalAllSettings( strBuffer.get(), dwBufferSize, true, nullptr );
        if( !bSuccess )
        {
            return false;
        }

        FILE* fp = nullptr;
        fopen_s( &fp, strFileName, "w" );
        if( fp )
        {
            fputs( strBuffer.get(), fp );
            fclose( fp );
            return true;
        }
        else
        {
            return false;
        }
    }
Beispiel #4
0
		ResourceDotHFile(const char * file)
		{          
			assert(file != NULL);        
			CCFileData data(GameResourceManager::sharedManager()->storedFullPathFromRelativePath(file), "rb");
			const char* buffer = (const char*)data.getBuffer();
			std::string strBuffer(buffer);
			std::stringstream ss(stringstream::in | stringstream::out);
			ss << strBuffer<<"\r\n";

			do 
			{
				// read the file from hardware
				char strTemp[1024];
				std::string strVal;   

				while(!ss.eof())
				{
					strTemp[0] = '\0';
					ss.getline(strTemp, 1024);
					//CCLog("line : %s", strTemp);
					strVal = strTemp;
					string_replace(strVal, "\r\n", "");
					string_replace(strVal, "\t" ," ");
					string_tripleft(strVal);

					std::string split = " ";

					int i0 = strVal.find_first_of(split);
					if (-1 == i0)
						continue;

					std::string def = strVal.substr(0, i0);

					strVal = strVal.substr(i0, strVal.length() - i0);
					string_tripleft(strVal);                    
					int i1 = strVal.find_first_of(split);
					if (-1 == i1)
						continue;                    
					std::string macro = strVal.substr(0, i1);

					std::string val = strVal.substr(i1, strVal.length() - i1);    
					string_tripleft(val);

					if (def.empty() == false && 
						val.empty() == false &&
						def.compare("#define") == 0 && 
						val.length() > 0)
					{
						string_replace(macro, " ", "");
						string_replace(val, " ", "");

						m_mapMacro2Value[macro] = atoi(val.c_str());
					}

					//CCLog("key : %s = Value %s\n", macro.c_str(), val.c_str());
				}

			} while (0);                                                
		}
Beispiel #5
0
int libxml_streams_IO_write(void* context, const char* buffer, int len) {
  ITRACE(1, "libxml_IO_write({}, {}, {})\n", context, (void*)buffer, len);
  Trace::Indent _i;

  Resource stream(static_cast<ResourceData*>(context));
  String strBuffer(StringData::Make(buffer, len, CopyString));
  Variant ret = HHVM_FN(fwrite)(stream, strBuffer);
  if (ret.isInteger() && ret.asInt64Val() < INT_MAX) {
    return (int)ret.asInt64Val();
  } else {
    return -1;
  }
}
Beispiel #6
0
inline void simpleThrift_10()
{

	thriftPerformance::simpleThrift_10 input = thriftPerformance::simpleThrift_10(), output;
	input.__set_att1(1);
	input.__set_att2(2);
	input.__set_att3(3);
	input.__set_att4(4);
	input.__set_att5(5);
	input.__set_att6(6);
	input.__set_att7(7);
	input.__set_att8(8);
	input.__set_att9(9);
	input.__set_att10(10);

	boost::shared_ptr<TMemoryBuffer> strBuffer(new TMemoryBuffer(100));
	boost::shared_ptr<TBufferedTransport> bt(new TBufferedTransport(strBuffer));
	boost::shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(bt));
	/*boost::shared_ptr<TSocket> socket(new TSocket("localhost", 8585));
	boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
	boost::shared_ptr<TBinaryProtocol> binaryProtcol(new TBinaryProtocol(transport));*/

	apache::thrift::protocol::TProtocol* p = binaryProtcol.get();
	strBuffer->open();

	boost::timer::auto_cpu_timer t;

	boost::chrono::duration<double> program_seconds;

	boost::chrono::system_clock::time_point program_start = boost::chrono::system_clock::now();

	for(int i = 0; i < NUMBER_OF_LOOPS; ++i)
	{
		try{
			input.write(p);
			output.read(p);
			//std::cout << "writes" << std::endl;
		}catch (std::exception &ex){
			//std::cout << ex.what() << ": " << std::endl;
		}
	}

	//transport->close();

	program_seconds = boost::chrono::system_clock::now() - program_start;

	cout << program_seconds.count() << endl;
}
Beispiel #7
0
/*
** return TRUE if event applies to pszAsset
*/
BOOL CEventDef::CheckAsset (LPCSTR pszAsset) const
{
	// no assets specified means ANY
	if (m_strAssets.IsEmpty())
		return TRUE;
	// else parse the list of included assets
	CString strBuffer(m_strAssets);
	CString strThisOne = BreakString(strBuffer, '\t', TRUE);
	while (strThisOne.GetLength())
	{
		if (0 == strThisOne.CompareNoCase(pszAsset))
			return TRUE;
		strThisOne = BreakString(strBuffer, '\t', TRUE);
	}
	return FALSE;
}
bool AttributeManager::setAttributeValue( const std::string &name, const std::string &type, const std::string &value )
{
    bool bRet = false;
    std::stringstream strBuffer( value );

    // the type information is case-insensitve
    std::string citype;    
    for ( size_t i = 0; i < type.size(); ++i ) citype += toupper( type[ i ] );

    if ( ( citype == "BOOLEAN" ) || ( citype == "BOOL" ) ) 
    {
        std::string bVal;
        strBuffer >> bVal;
        bool   bValue = ( bVal == "true" ) ? true : false;
        bRet = setAttributeValue( name, bValue );
    }
Beispiel #9
0
result_t encoding_base::bsonEncode(v8::Local<v8::Object> data,
                                   obj_ptr<Buffer_base> &retVal)
{
    bson bb;
    result_t hr;

    hr = encodeObject(&bb, data);
    if (hr < 0)
        return hr;

    std::string strBuffer(bson_data(&bb), bson_size(&bb));
    retVal = new Buffer(strBuffer);

    bson_destroy(&bb);

    return 0;
}
Beispiel #10
0
tstring CWidgetAddress::GetAddress()
{
TRY_CATCH

	tstring address;

	int szBuffer = GetWindowTextLength() + 1;
	if ( szBuffer > 1 )
	{
		boost::scoped_ptr<TCHAR> strBuffer( new TCHAR[szBuffer] );
		if ( GetWindowText(strBuffer.get(), szBuffer) )
			address = strBuffer.get();
	}

	return address;

CATCH_THROW()
}
Beispiel #11
0
extern NXString GW_remove_sharp_bracket_text(NXString inputString)
{
	std::string	strBuffer(inputString.GetLocaleText());
	NXString returnString;

	while (true)
	{
		std::string::size_type begin = strBuffer.find("<");
		if (-1 == begin)
			break;
		std::string::size_type end = strBuffer.find(">");
		if (-1 == end)
			break;
		strBuffer = strBuffer.erase(begin, end-begin+1);
	}
	returnString = strBuffer.c_str();
	return returnString;
}
Beispiel #12
0
ACLStr ACLStr::StripWord(IN const ACLStr& strToStrip)
{
    ACLStr newString;
    if (strToStrip.Len())
    {
        size_t lenStrToStrip(strToStrip.Len());
        
        LPTSTR strBuffer(_string);
        
        LPTSTR findString(NULL);
        while ((findString = STRSTR(strBuffer, (LPCTSTR)strToStrip)))
        {
            newString.Append(strBuffer, (findString - strBuffer));
            strBuffer = (findString + lenStrToStrip);
        }
        if (strBuffer) newString.Append(strBuffer);
    }
    return newString;
} // StripWord
Beispiel #13
0
/*************************************************
Function:       serverFunction
Description:    The logic codes for serving the client request.
Calls:          read()
				fprintf()
				perror()
				closeCallBack()
				clown::Event::saveData()
				std::string::append()
				write()
				std::string::clear()
				std::string::c_str()
Input:          None.
Output:         None.
Return:         void
Others:         None.
*************************************************/
void clown::Event::serveFunction()
{
	char buffer[MAX_LINE];

	std::string echoMessage;

	int nRead = read(clientFD, buffer, MAX_LINE);

	if(nRead < 0)
	{
		fprintf(stderr, "A client happened exception, close this connection.\n");

		perror("Details: ");

		closeCallBack();
	}
	else if(nRead == 0)
	{
		closeCallBack();
	}
	else
	{
		std::string strBuffer(buffer);

		if(this->saveData(strBuffer))
		{
			echoMessage.append("Error.\n");
		}
		else
		{
			echoMessage.append("Succeeded.\n");
		}

        write(clientFD, echoMessage.c_str(), echoMessage.size());

        echoMessage.clear();
	}

	//auto destructing after the event is finished.
	delete this;
}
void ProcessReceive::receive(char* buffer, int32_t length, int32_t sendPid, CorrespondParam::ProtocolId protocalId)
{
	std::string strBuffer(buffer, length);
	switch (protocalId)
	{
	case CorrespondParam::CLIENT_INIT:
	{
		printf("PROCESS_CLIENT_INIT, length = %d\n", length);
		ProtoMessage message;
		message.from(strBuffer);
		addClientServerLoginName(message, CSystem::processName(sendPid));
		std::string strMessage;
		message.toString(strMessage);
		std::string compressMessage;
		Compress::zlibCompress(compressMessage, strMessage, 9);
		m_netClient->send(compressMessage.c_str(), compressMessage.length(), protocalId);
		return;
	}
	case CorrespondParam::PROTO_MESSAGE:
	{
		//printf("PROTO_MESSAGE, length = %d\n", length);
		break;
	}
	case CorrespondParam::JSON:
	{
		break;
	}
	case CorrespondParam::XML:
	{
		break;
	}
	default:
		break;
	}
	
	std::string compressMessage;
	Compress::zlibCompress(compressMessage, strBuffer, 9);
	m_netClient->send(compressMessage.c_str(), compressMessage.length(), protocalId);
}
BOOL CSynBCGPEditCtrl::SaveFileEx( const CString& strFileName )
{
	CString strBuffer(m_strBuffer);
	strBuffer.Replace(_T("\n"), _T("\r\n"));
	if (m_File.SaveFile(strFileName, strBuffer))
	{
		m_bIsModified = FALSE;
		m_posDocSavedUndoPos = m_posUndoBuffer;
		m_bSavedUndo = !m_bBOL;

		// Update saved flag:
		for (POSITION pos = m_lstUndoActions.GetHeadPosition (); pos != NULL;)
		{
			POSITION posSave = pos;
			BCGP_EDIT_UNDO_ACTION* pUndoAction = m_lstUndoActions.GetNext (pos);
			ASSERT (pUndoAction != NULL);

			if (m_bEOL && posSave == m_lstUndoActions.GetTailPosition () ||
				!m_bEOL && posSave == m_posUndoBuffer)
			{
				// mark as saved
				pUndoAction->m_dwFlags |= g_dwUAFSaved;
			}
			else
			{
				// clear saved flag
				pUndoAction->m_dwFlags &= ~g_dwUAFSaved;
			}
		}
		return TRUE;
	} 
	else
	{
		CFMessageBox(m_File.GetLastErrorMsg(), MB_OK | MB_ICONERROR);
		return FALSE;
	}
}
Beispiel #16
0
void CAtkisSatz::LoeschSatz(LPCSTR pcDaten)
{
// Objektnummer des zu löschenden Objektes herausfischen
CString strBuffer(pcDaten);
CString strObjektnummer, strAktualitaet;
int pos = strBuffer.Find("DLOB2005EQ");

	if (pos >= 0) {
	// DLOB2005
		strObjektnummer = strBuffer.Mid(pos + 10, 7);
		pos = strBuffer.Find("DLOB2003EQ");
		if (pos >= 0)
			strAktualitaet = strBuffer.Mid(pos + 10, 2);
	}

	if (pos < 0) {
	// evtl. DLTA1001
		pos = strBuffer.Find("DLTA0001EQ");
		if (pos >= 0)
			strObjektnummer = strBuffer.Mid(pos + 10, 7);

		strcpy (m_AttrObjNr, strObjektnummer);
		m_AttrObjNr[7] = '\0';

		pos = strBuffer.Find("DLTA0004EQ");
		if (pos >= 0)
			strAktualitaet = strBuffer.Mid(pos + 10, 2);

		pos = strBuffer.Find("DLTA0002EQ");
		m_AttrOTNr[0] = '\0';
		if (pos >= 0) {
		CString strTeilNr = strBuffer.Mid(pos + 10, 3);

			AllTrimm (strTeilNr);	// ggf. ist TeilNr leer
			strcat (m_AttrOTNr, strTeilNr);
		}

		m_fIsFloeDelta = TRUE;

	// hier alle Attribute dieses Objektes löschen
	INT_PTR lMCode = DEX_GetMCodeFromFeatureNameCIEx(DEX_GetDataSourceHandle(), "ATKIS-Objektnummer");

		_ASSERTE(0 != lMCode);
		if (0 != lMCode) {
#if defined(_DEBUG)
		DELINFO DI;

			DI.m_lMCode = lMCode;
			DI.m_pcObjNr = strObjektnummer;
			DI.m_ulLen = strObjektnummer.GetLength();
#endif // defined(_DEBUG)

		ENUMRECHTEXTMERKMAL ERTM;

			INITSTRUCT(ERTM, ENUMRECHTEXTMERKMAL);
			ERTM.pView = NULL;
			ERTM.lMCode = lMCode;
			ERTM.pMWert = (LPSTR)(LPCSTR)strObjektnummer;
			ERTM.iMode = SMSubStringStartMatch;
			ERTM.eFcn = DeleteUpdatedObjectAttributes;
#if defined(_DEBUG)
			ERTM.pData = &DI;
#endif // defined(_DEBUG)
			DEX_EnumRechTextMerkmal(ERTM);
		}
		return;
	}

	if (pos < 0) 
		return;		// nichts für uns

// dieses Objekt in TRiAS löschen
INT_PTR lMCode = DEX_GetMCodeFromFeatureNameCIEx(DEX_GetDataSourceHandle(), "ATKIS-Objektnummer");

	_ASSERTE(0 != lMCode);
	if (0 != lMCode) {
		_ASSERTE(strObjektnummer.GetLength() > 0);

#if defined(_DEBUG)
	DELINFO DI;

		DI.m_lMCode = lMCode;
		DI.m_pcObjNr = strObjektnummer;
		DI.m_ulLen = strObjektnummer.GetLength();
#endif // defined(_DEBUG)

	ENUMRECHTEXTMERKMAL ERTM;

		INITSTRUCT(ERTM, ENUMRECHTEXTMERKMAL);
		ERTM.pView = NULL;
		ERTM.lMCode = lMCode;
		ERTM.pMWert = (LPSTR)(LPCSTR)strObjektnummer;
		ERTM.iMode = SMSubStringStartMatch;
		ERTM.eFcn = DeleteUpdatedObject;
#if defined(_DEBUG)
		ERTM.pData = &DI;
#endif // defined(_DEBUG)
		DEX_EnumRechTextMerkmal(ERTM);
	} 
}
Beispiel #17
0
void z3ResEx::parseMsfMethod2( TMemoryStream &msf )
{
	unsigned short strLen( 0 );
	unsigned short mrfIndexLen( 0 );

	// Folders are now in a table at the top of the file
	msf.Read( &mrfIndexLen, sizeof( unsigned short ) );

  if (mrfIndexLen == 0)
  {
    // There are no folders in the filesystem
    return;
  }

	// List of filenames
  vector<string> vecMsf(mrfIndexLen);

  vector<unsigned char> strBuffer(MAX_STRING_SIZE);

	// MRF filenames are now packed in a list
	for( unsigned short i( 0 ); i != mrfIndexLen; ++i )
	{
		strLen = msf.ReadUShort();
		unpackStringEx( msf, strBuffer, strLen );

		// Required to rename files
		//vecMsf[i].first.assign( (char *)strBuffer );
		// Cached file opening (and a pointer so we can call the constructor)
		//vecMsf[i].second = new TFileStream( strBuffer );

    vecMsf[i] = string(strBuffer.begin(), strBuffer.end());
	}

	// Files are now listed (similar to before)
	FILEINDEX_ENTRY2 fiItem;

	unsigned int items( 0 ), errors( 0 );

	//msf.SaveToFile("debugFilesys.dat");

	bool bMatchesCriteria = true;
	string tmpFilename;

	while( ( msf.Position() < msf.Size() ) && ( errors < MAX_ERRORS ) )
	{
		msf.Read( &fiItem, sizeof( FILEINDEX_ENTRY2 ) );

		strLen = msf.ReadUShort();
		unpackStringEx( msf, strBuffer, strLen );
		
		if( !m_folderCriteria.empty() )
		{
      tmpFilename = string(strBuffer.begin(), strBuffer.end());
			std::transform(tmpFilename.begin(), tmpFilename.end(), tmpFilename.begin(), ::toupper);
			bMatchesCriteria = !( tmpFilename.find( m_folderCriteria ) == string::npos );
		}

		if( bMatchesCriteria )
		{
			if( m_listContents )
			{
				printf( "%s (%u bytes)\n", &strBuffer[0], fiItem.size );
			}
			else
			{
				if( !( extractItem2( fiItem, vecMsf[ fiItem.mrfIndex ], reinterpret_cast<const char*>(&strBuffer[0]) ) ) )
					++errors;
			}
		}

		++items;
	}

	vecMsf.clear();

	printf( "Processed %u items (%u issues)\n\n", items, errors );
}
Beispiel #18
0
// Execute SQL Query for the established connection
// Mostly a SELECT query, Other queries may be executed using Execute()
// Returns TRUE on success
UINT CSmartDBRecordSet::Open(LPCTSTR strQueryString, CSmartDB *ptrConn, LONG nRSType)
{
	if (ptrConn->IsLibLoaded() == FALSE)
		return RSOPEN_NOLIBLOADED;

	if (m_bIsOpen)
		return RSOPEN_ALREADYOPENED;

	if (!ptrConn->IsConnected())
		return RSOPEN_NOCONNECT;
	
	vector<string> *strRSRow;		// Record Set holder
	BOOL bTypesSaved = FALSE;	// Flag used to mark if DataTypes are saved for each column
	char *zErrMsg = 0;

	sqlite3_stmt *stmtByteCode;
	const char *strUnused = 0;
	UINT nCount = 0;
	UINT nRecCount = 0;
	INT nType;

#ifdef UNICODE
	string strBuffer = ws2s(strQueryString);// Temp Buffer
#else
	string strBuffer(strQueryString);// Temp Buffer
#endif

	SmartDBPrepare(ptrConn->db, strBuffer.c_str(), strBuffer.length(), &stmtByteCode, &strUnused);

	nCount = SmartDBColumnCount(stmtByteCode);
	for (UINT i=0; i < nCount; i++)
	{
		strBuffer = SmartDBColumnName (stmtByteCode, i); // column_name
		m_strFieldsList.push_back(strBuffer);
	}
	m_nFieldsCount = m_strFieldsList.size();
	

	// return, If there is no field in the table
	if (m_nFieldsCount == 0)
		return RSOPEN_INVALIDQRY;

	m_bIsOpen = TRUE;

	int nValue;
	double nFValue;
	const char * pszValue = NULL;
	char strTemp[100];

	while (SmartDBStep (stmtByteCode) != SQLITE_DONE)	// step
	{
		strRSRow = new vector<string>();

		for (int i=0; (LONG)i < m_nFieldsCount; i++)
		{
			if (!bTypesSaved)	// Save Field Types in an array
			{
				nType = SmartDBColumnType (stmtByteCode, i);	// column_type
				m_nFieldsType.push_back((UINT)nType);
				if ((LONG)i == m_nFieldsCount-1)
					bTypesSaved = TRUE;
			}
			
			switch (m_nFieldsType[i])
			{
				case SQLITE_INTEGER:
					nValue = SmartDBColumnInt (stmtByteCode, i);
					sprintf(strTemp,"%d", nValue);
					strRSRow->push_back(strTemp);
					break;
				case SQLITE_FLOAT:
					nFValue = SmartDBColumnDouble (stmtByteCode, i);
					sprintf(strTemp,"%f", nFValue);
					strRSRow->push_back(strTemp);
					break;
				case SQLITE_TEXT:
					pszValue = SmartDBColumnText(stmtByteCode, i);
					if (NULL == pszValue)
						strRSRow->push_back("");
					else
						strRSRow->push_back(pszValue);
					break;
				case SQLITE_BLOB:
					pszValue = (const char *)SmartDBColumnBlob (stmtByteCode, i);
					if (NULL == pszValue)
						strRSRow->push_back("");
					else
						strRSRow->push_back(pszValue);
					break;
				case SQLITE_NULL:
					strRSRow->push_back("");
					break;
			}
		}
		orsRows.push_back(strRSRow);
		nRecCount++;
	}

	m_nRecordCount = nRecCount;
	m_nCurrentRecord = 0;

	SmartDBFinalize(stmtByteCode);

	return RSOPEN_SUCCESS;
}
Beispiel #19
0
void CGnuLocal::OnReceive(int nErrorCode) 
{
	byte buffer[1024];

	CString Host, LocalHost, NetworkPing, NetworkPong;
	CString LanName, IRCAddr, InfoURL;

	UINT    Port, LocalPort, Leaves = 0;

	int buffLength = ReceiveFrom(buffer, 1024, Host, Port);

	GetSockName(LocalHost, LocalPort);

	// Handle Errors
	if(!buffLength || buffLength == SOCKET_ERROR)
		return;
	
	CString strBuffer((char*) buffer, 128);

	NetworkPing =  theApp.m_spGD->ModeNetwork;
	NetworkPing += _T(" PING\r\n");

	NetworkPong =  theApp.m_spGD->ModeNetwork;
	NetworkPong += _T(" PONG\r\n");


	// Handle Ping over LAN
	if(strBuffer.Find(NetworkPing) == 0)
	{
		if(Host == LocalHost)
		{
			return;
		}

		// Send back pong only if not a leaf
		if(!m_pComm->m_LeafModeActive)
		{
			NetworkPong += _T("Port: ") + DWrdtoStr(m_pComm->m_CurrentPort) + _T("\r\n");

			if(theApp.m_spGD->m_NetworkModel == NETWORK_PRIVATE)
			{
				// LAN header
				if(theApp.m_spGD->m_Lan)
					NetworkPong += _T("LAN: ") + theApp.m_spGD->m_LanName + _T("\r\n");

				// IRC header
				if(theApp.m_spGD->m_InternalIRC)
					NetworkPong += _T("IRC: ") + theApp.m_spGD->m_InternalIRCAddr + _T("\r\n");
			}

			// Leaves header
			if(m_pComm->m_NodeCapability == CLIENT_ULTRAPEER)
			{
				int Leaves = m_pComm->CountLeafConnects();

				if(Leaves)
					NetworkPong += _T("Leaves: ") + DWrdtoStr(Leaves) + _T("\r\n");
			}


			NetworkPong += _T("\r\n");

			int pos = strBuffer.Find(_T("\r\nPort: "));
			if(pos != -1)
			{
				pos += 2;
				_stscanf((TCHAR*)buffer + pos, _T("Port: %d\r\n"), &Port);
			}
			
			SendTo(NetworkPong, NetworkPong.GetLength(), UDP_PORT, Host);
		}
	}

	// Extract Data from ping/pong
	if(strBuffer.Find(NetworkPing) == 0 || strBuffer.Find(NetworkPong) == 0)
	{
		int pos, backpos;

		pos = strBuffer.Find(_T("\r\nPort: "));
		if(pos != -1)
		{
			pos += 2;
			_stscanf((TCHAR*)buffer + pos, _T("Port: %d\r\n"), &Port);
		}

		pos = strBuffer.Find(_T("\r\nLAN: "));
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find(_T("\r\n"), pos);
			LanName = strBuffer.Mid(pos + 5, backpos - pos - 5);
		}

		pos = strBuffer.Find(_T("\r\nIRC: "));
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find(_T("\r\n"), pos);
			IRCAddr = strBuffer.Mid(pos + 5, backpos - pos - 5);
		}

		pos = strBuffer.Find(_T("\r\nInfoURL: "));
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find(_T("\r\n"), pos);
			InfoURL = strBuffer.Mid(pos + 9, backpos - pos - 9);
		}

		pos = strBuffer.Find(_T("\r\nLeaves: "));
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find(_T("\r\n"), pos);
			Leaves  = _ttoi( strBuffer.Mid(pos + 8, backpos - pos - 8) );
		}
	}

	
	// Handle Pong over LAN
	if(strBuffer.Find(NetworkPong) == 0)
	{
		CString Extra;

		if(Leaves)
			Extra = _T(" with ") + DWrdtoStr(Leaves) + _T(" leaves");
	}

	for(int i = 0; i < m_HostList.size(); i++)
		if( m_HostList[i].Host == Host && m_HostList[i].Port == Port)
			return;


	LanNode LocalNode;
	LocalNode.Host		= Host;
	LocalNode.Port		= Port;
	LocalNode.Name		= LanName;
	LocalNode.IRCserver = IRCAddr;
	LocalNode.InfoPage	= InfoURL;
	LocalNode.Leaves	= Leaves;
	m_HostList.push_back(LocalNode);

	CAsyncSocket::OnReceive(nErrorCode);
}
Beispiel #20
0
BOOL HTTPCLUSTER_MONITOR(char *url, char *uid, char *pwd, char *pserver, int pport,
                         char *puid, char *ppwd, char *ostype, char *clusterlog, char *cpath,
                         char *szReturn)
{
    int		ret = 0;
    BOOL	bResult = TRUE;
    char	*ca = NULL;
    char	iniFile[256] = {0};
    char	cmd[256] = {0};

#if _DEBUG
    sprintf(iniFile, "%s\\templates.os\\%s", FuncGetInstallRootPath(), ostype);
#else
    sprintf(iniFile, "%s\\MonitorManager\\templates.os\\%s", FuncGetInstallRootPath(), ostype);
#endif
    DFN_GetPrivateProfileString("cat", "command", "", cmd, sizeof(cmd), iniFile);
    if(!*cmd)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_14%>"));    //  <%IDS_TelMonitor_14%>
        return FALSE;
    }

    if(ca = strstr(cmd, "<file>"))
    {
        strcpy(ca, clusterlog);
        *(ca + strlen(clusterlog)) = 0;
    }

    char msg[100 * 1024] = {0};
    if(!http_command(url, cmd, READ_TIMEOUT, uid, pwd, pserver, pport, puid, ppwd, msg))
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_15%>"));    //  <%IDS_TelMonitor_15%>
        return FALSE;
    }

    {
        int index = 0;
        CString	strBuffer(msg);
        CString	strLine = _T("");

        // Cluster
        if((index = strBuffer.Find("CLUSTER", 0)) >= 0)
        {
            strBuffer.Delete(0, index);
        }
        else
        {
            sprintf(szReturn, "error=%s", "No Cluster");	// No Cluster
            return FALSE;
        }

        strLine = GetStringFromLineNo(strBuffer, 2);
        sprintf(szReturn, "%sClusterName=%s$ClusterStatus=%s$", szReturn,
                GetColumnFromLine(strLine, 1), GetColumnFromLine(strLine, 2));

        // Node
        if((index = strBuffer.Find("NODE", 0)) >= 0)
        {
            strBuffer.Delete(0, index);
        }
        else
        {
            sprintf(szReturn, "error=%s", "No Node");	// No Node
            return FALSE;
        }

        strLine = GetStringFromLineNo(strBuffer, 2);
        sprintf(szReturn, "%sNodeName=%s$NodeStatus=%s$NodeState=%s$", szReturn,
                GetColumnFromLine(strLine, 1), GetColumnFromLine(strLine, 2),
                GetColumnFromLine(strLine, 3));

        // Package
        if((index = strBuffer.Find("PACKAGE", 0)) >= 0)
        {
            strBuffer.Delete(0, index);
        }
        else
        {
            sprintf(szReturn, "error=%s", "No Package");	// No Package
            return FALSE;
        }

        strLine = GetStringFromLineNo(strBuffer, 2);
        sprintf(szReturn, "%sPackageName=%s$PackageStatus=%s$PackageState=%s$PackageAutorun=%s$",
                szReturn, GetColumnFromLine(strLine, 1), GetColumnFromLine(strLine, 2),
                GetColumnFromLine(strLine, 3), GetColumnFromLine(strLine, 4));
    }

    return TRUE;
}
Beispiel #21
0
EncodedJSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    bool isRealArray = isJSArray(&exec->globalData(), thisValue);
    if (!isRealArray && !thisValue.inherits(&JSArray::info))
        return throwVMTypeError(exec);
    JSArray* thisObj = asArray(thisValue);
    
    HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements;
    if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) {
        if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth)
            return throwVMError(exec, createStackOverflowError(exec));
    }

    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    if (alreadyVisited)
        return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoiding infinite recursion.

//FYWEBKITMOD begin: setting up StringJoiner (while integrating r148721 due to fix of bug 114779). But not using 'ConstructFromLiteral' optimization which we dont have in our webkit.
    unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec);
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

	//WebCore::String separator(",", WebCore::String::ConstructFromLiteral);
	//JSStringJoiner stringJoiner(separator, length);
	JSStringJoiner stringJoiner(",", length);
//FYWEBKITMOD end
    unsigned totalSize = length ? length - 1 : 0;
    Vector<RefPtr<UString::Rep>, 256> strBuffer(length);
    for (unsigned k = 0; k < length; k++) {
        JSValue element;
        if (isRealArray && thisObj->canGetIndex(k))
            element = thisObj->getIndex(k);
        else {
            element = thisObj->get(exec, k);
//FYWEBKITMOD begin: added while integrating r148721 due to fix of bug 114779
			if (exec->hadException()) 
				return JSValue::encode(jsUndefined());
//FYWEBKITMOD end
			}
        
//FYWEBKITMOD begin: removed (USE_FIX 1) old implementation which joined the strings manually and added usage of JSStringJoiner (while integrating r148721 due to fix of bug 114779)
#define USE_FIX 1 //keep this defined!!!
#ifdef USE_FIX
		if (element.isUndefinedOrNull()) 
			stringJoiner.append(WebCore::String()); //FYWEBKITMOD: 
		else
			stringJoiner.append(element.toString(exec).rep()); //FYWEBKITMOD: using toString() instead of new toWTFString(). Only difference is an optimization used in the toWTFString() case.

		if (exec->hadException())
			return JSValue::encode(jsUndefined());
		}

	arrayVisitedElements.remove(thisObj);

	return JSValue::encode(stringJoiner.build(exec));

#else
        if (element.isUndefinedOrNull())
            continue;
        
        UString str = element.toString(exec);
        strBuffer[k] = str.rep();
        totalSize += str.size();
        
        if (!strBuffer.data()) {
            throwOutOfMemoryError(exec);
        }
        
        if (exec->hadException())
            break;
    }
Beispiel #22
0
BOOL RLOGINCLUSTER_MONITOR(char *server, int port, char *uid, char *pwd, char *pserver,
                           int pport, char *puid, char *ppwd, char *pprompt, char *prompts, char *ostype,
                           char *clusterlog, char *cpath, char *szReturn)
{
    int		ret = 0;
    int		hSocket = 0;
    BOOL	bResult = TRUE;
    char	iniFile[256] = {0};
    char	cmd[256] = {0};

    /*************************************
     * For Reason Of Prompt
     */
    int		c = 0;
    char	*ca = prompts, *cb = NULL;
    char	arprompt[PR_NUM][256];
    memset(arprompt, 0, sizeof(arprompt));

    while(cb = strchr(ca, 0x20))
    {
        if(ca == cb)
        {
            ca ++;
            continue;
        }

        strncpy(arprompt[c++], ca, cb - ca);
        ca = cb + 1;
    }

    strcpy(arprompt[c++], ca);
    /***********************************/

    hSocket = rlogin_init(server, port, pserver, pport, puid, ppwd);
    if(hSocket <= 0)
    {
        if(hSocket == -1)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_1%>"));    //  <%IDS_TelMonitor_1%>
        else if(hSocket == -2)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_2%>"));   //  <%IDS_TelMonitor_2%>
        else if(hSocket == -3)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_3%>"));     //  <%IDS_TelMonitor_3%>
        else if(hSocket == -4)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_4%>"));     //  <%IDS_TelMonitor_4%>
        else if(hSocket == -5)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_5%>"));        //  <%IDS_TelMonitor_5%>
        else
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_6%>"));     //  <%IDS_TelMonitor_6%>

        bResult = FALSE;
        goto err;
    }

    if((ret = rlogin_connect(hSocket, uid, pwd, pprompt, arprompt)) < 0)
    {
        if(ret == -1)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_7%>"));    //  <%IDS_TelMonitor_7%>
        else if(ret == -2)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_8%>"));     //  <%IDS_TelMonitor_8%>
        else if(ret == -3)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_9%>"));     //  <%IDS_TelMonitor_9%>
        else if(ret == -4)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_10%>"));   //  <%IDS_TelMonitor_10%>
        else if(ret == -5)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_11%>"));   //  <%IDS_TelMonitor_11%>
        else if(ret == -6)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_12%>"));   //  <%IDS_TelMonitor_12%>
        else
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_13%>"));     //  <%IDS_TelMonitor_13%>

        bResult = FALSE;
        goto err;

    }

#if _DEBUG
    sprintf(iniFile, "%s\\templates.os\\%s", FuncGetInstallRootPath(), ostype);
#else
    sprintf(iniFile, "%s\\MonitorManager\\templates.os\\%s", FuncGetInstallRootPath(), ostype);
#endif
    DFN_GetPrivateProfileString("cat", "command", "", cmd, sizeof(cmd), iniFile);
    if(!*cmd)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_14%>"));    //  <%IDS_TelMonitor_14%>
        bResult = FALSE;
        goto err;
    }

    if(ca = strstr(cmd, "<file>"))
    {
        strcpy(ca, clusterlog);
        *(ca + strlen(clusterlog)) = 0;
    }

    if((ret = rlogin_command(hSocket, cmd)) < 0)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_TelMonitor_15%>"));    //  <%IDS_TelMonitor_15%>
        bResult = FALSE;
        goto err;
    }

    {
        int index = 0;
        CString	strBuffer(rlogin_databuffer);
        CString	strLine = _T("");

        // Cluster
        if((index = strBuffer.Find("CLUSTER", 0)) >= 0)
        {
            strBuffer.Delete(0, index);
        }
        else
        {
            sprintf(szReturn, "error=%s", "No Cluster");	// No Cluster
            bResult = FALSE;
            goto err;
        }

        strLine = GetStringFromLineNo(strBuffer, 2);
        sprintf(szReturn, "%sClusterName=%s$ClusterStatus=%s$", szReturn,
                GetColumnFromLine(strLine, 1), GetColumnFromLine(strLine, 2));

        // Node
        if((index = strBuffer.Find("NODE", 0)) >= 0)
        {
            strBuffer.Delete(0, index);
        }
        else
        {
            sprintf(szReturn, "error=%s", "No Node");	// No Node
            bResult = FALSE;
            goto err;
        }

        strLine = GetStringFromLineNo(strBuffer, 2);
        sprintf(szReturn, "%sNodeName=%s$NodeStatus=%s$NodeState=%s$", szReturn,
                GetColumnFromLine(strLine, 1), GetColumnFromLine(strLine, 2),
                GetColumnFromLine(strLine, 3));

        // Package
        if((index = strBuffer.Find("PACKAGE", 0)) >= 0)
        {
            strBuffer.Delete(0, index);
        }
        else
        {
            sprintf(szReturn, "error=%s", "No Package");	// No Package
            bResult = FALSE;
            goto err;
        }

        strLine = GetStringFromLineNo(strBuffer, 2);
        sprintf(szReturn, "%sPackageName=%s$PackageStatus=%s$PackageState=%s$PackageAutorun=%s$",
                szReturn, GetColumnFromLine(strLine, 1), GetColumnFromLine(strLine, 2),
                GetColumnFromLine(strLine, 3), GetColumnFromLine(strLine, 4));
    }

err:
    shutdown(hSocket, 0x02);
    closesocket(hSocket);
    return bResult;
}
Beispiel #23
0
int cPasTokenizer::IsKeyword(const char* strLabel)
{
    std::string strBuffer(strLabel);
    std::transform(strBuffer.begin(), strBuffer.end(), strBuffer.begin(), ::tolower);
    return cTokenizer::IsKeyword(strBuffer.c_str());
}
Beispiel #24
0
void CGnuLocal::OnReceive(int nErrorCode) 
{
	byte buffer[1024];

	CString Host, LocalHost, NetworkPing, NetworkPong;
	CString LanName, IRCAddr, InfoURL;

	UINT    Port, LocalPort, Leaves = 0;

	int buffLength = ReceiveFrom(buffer, 1024, Host, Port);

	GetSockName(LocalHost, LocalPort);

	// Handle Errors
	if(!buffLength || buffLength == SOCKET_ERROR)
		return;
	
	CString strBuffer((char*) buffer, 128);

	NetworkPing =  m_pComm->m_NetworkName;
	NetworkPing += " PING\r\n";

	NetworkPong =  m_pComm->m_NetworkName;
	NetworkPong += " PONG\r\n";


	// Handle Ping over LAN
	if(strBuffer.Find(NetworkPing) == 0)
	{
		if(Host == LocalHost)
		{
			m_pCore->LogError("UDP: Ping received from localhost");
			//return;
		}

		// Send back pong only if not a leaf
		NetworkPong += "Port: " + NumtoStr(m_pNet->m_CurrentPort) + "\r\n";

		if(m_pPrefs->m_LanMode)
		{
			NetworkPong += "LAN: " + m_pPrefs->m_LanName + "\r\n";

			CString RandCache = m_pComm->m_pCache->GetRandWebCache(true);
		
			if(!RandCache.IsEmpty())
				NetworkPing += "WebCache: " + RandCache + "\r\n";
		}

		// Leaves header
		if(m_pComm->m_GnuClientMode ==GNU_ULTRAPEER)
		{
			int Leaves = m_pComm->CountLeafConnects();

			if(Leaves)
				NetworkPong += "Leaves: " + NumtoStr(Leaves) + "\r\n";
		}


		NetworkPong += "\r\n";

		int pos = strBuffer.Find("\r\nPort: ");
		if(pos != -1)
		{
			pos += 2;
			sscanf((char*)buffer + pos, "Port: %d\r\n", &Port);
		}
		
		SendTo(NetworkPong, NetworkPong.GetLength(), UDP_PORT, Host);
		m_pCore->LogError("UDP: Pong Sent to " + Host + ":" + NumtoStr(Port));
	
	}

	// Extract Data from ping/pong
	if(strBuffer.Find(NetworkPing) == 0 || strBuffer.Find(NetworkPong) == 0)
	{
		int pos, backpos;

		pos = strBuffer.Find("\r\nPort: ");
		if(pos != -1)
		{
			pos += 2;
			sscanf((char*)buffer + pos, "Port: %d\r\n", &Port);
		}

		pos = strBuffer.Find("\r\nLAN: ");
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find("\r\n", pos);
			LanName = strBuffer.Mid(pos + 5, backpos - pos - 5);
		}

		pos = strBuffer.Find("\r\nWebCache: ");
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find("\r\n", pos);
			CString NewWebCache = strBuffer.Mid(pos + 10, backpos - pos - 10);

			m_pComm->m_pCache->WebCacheAddCache(NewWebCache);
		}

		pos = strBuffer.Find("\r\nIRC: ");
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find("\r\n", pos);
			IRCAddr = strBuffer.Mid(pos + 5, backpos - pos - 5);
		}

		pos = strBuffer.Find("\r\nInfoURL: ");
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find("\r\n", pos);
			InfoURL = strBuffer.Mid(pos + 9, backpos - pos - 9);
		}

		pos = strBuffer.Find("\r\nLeaves: ");
		if(pos != -1)
		{
			pos += 2;
			backpos = strBuffer.Find("\r\n", pos);
			Leaves  = atoi( strBuffer.Mid(pos + 8, backpos - pos - 8) );
		}
	}

	
	// Handle Pong over LAN
	if(strBuffer.Find(NetworkPong) == 0)
	{
		CString Extra;

		if(Leaves)
			Extra = " with " + NumtoStr(Leaves) + " leaves";

		m_pCore->LogError("UDP: Pong Received from " + Host + ":" + NumtoStr(Port) + Extra);
	}


	std::map<int, LanNode>::iterator itNode;
	for(itNode = m_LanNodeIDMap.begin(); itNode != m_LanNodeIDMap.end(); itNode++)
		if( itNode->second.Host == Host && itNode->second.Port == Port)
			return;


	LanNode LocalNode;
	LocalNode.Host		= Host;
	LocalNode.Port		= Port;
	LocalNode.Name		= LanName;
	LocalNode.IRCserver = IRCAddr;
	LocalNode.InfoPage	= InfoURL;
	LocalNode.Leaves	= Leaves;

	int LanNodeID = m_NextLanID++;
	m_LanNodeIDMap[LanNodeID] = LocalNode;


	// If we're not in lan mode, just add to cache
	if(!m_pPrefs->m_LanMode)
	{
		Node PermNode;
		PermNode.Host = Host;
		PermNode.Port = Port;
		
		if(PermNode.Host != LocalHost)
			m_pComm->m_pCache->m_GnuPerm.push_back(PermNode);
	}


	CAsyncSocket::OnReceive(nErrorCode);
}
void LastRecentFileList::updateMenu()
{
	NppParameters *pNppParam = NppParameters::getInstance();

	if (!_hasSeparators && _size > 0) 
	{	
		//add separators
		NativeLangSpeaker *pNativeLangSpeaker = pNppParam->getNativeLangSpeaker();

		generic_string recentFileList = pNativeLangSpeaker->getSpecialMenuEntryName("RecentFiles");
		generic_string openAllFiles = pNativeLangSpeaker->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE);
		generic_string cleanFileList = pNativeLangSpeaker->getNativeLangMenuString(IDM_CLEAN_RECENT_FILE_LIST);

		if (recentFileList == TEXT(""))
			recentFileList = TEXT("&Recent Files");
		if (openAllFiles == TEXT(""))
			openAllFiles = TEXT("Open All Recent Files");
		if (cleanFileList == TEXT(""))
			cleanFileList = TEXT("Empty Recent Files List");

		if (!isSubMenuMode())
			::InsertMenu(_hMenu, _posBase + 0, MF_BYPOSITION, UINT(-1), 0);

		::InsertMenu(_hMenu, _posBase + 1, MF_BYPOSITION, IDM_OPEN_ALL_RECENT_FILE, openAllFiles.c_str());
		::InsertMenu(_hMenu, _posBase + 2, MF_BYPOSITION, IDM_CLEAN_RECENT_FILE_LIST, cleanFileList.c_str());
		::InsertMenu(_hMenu, _posBase + 3, MF_BYPOSITION, UINT(-1), 0);
		_hasSeparators = true;

		if (isSubMenuMode())
		{
			::InsertMenu(_hParentMenu, _posBase + 0, MF_BYPOSITION | MF_POPUP, UINT(_hMenu), (LPCTSTR)recentFileList.c_str());
			::InsertMenu(_hParentMenu, _posBase + 1, MF_BYPOSITION, UINT(-1), 0);
		}
	}
	else if (_hasSeparators && _size == 0) 	//remove separators
	{
		::RemoveMenu(_hMenu, _posBase + 3, MF_BYPOSITION);
		::RemoveMenu(_hMenu, IDM_CLEAN_RECENT_FILE_LIST, MF_BYCOMMAND);
		::RemoveMenu(_hMenu, IDM_OPEN_ALL_RECENT_FILE, MF_BYCOMMAND);
		::RemoveMenu(_hMenu, _posBase + 0, MF_BYPOSITION);
		_hasSeparators = false;

		if (isSubMenuMode())
		{
			// Remove "Recent Files" Entry and the separator from the main menu
			::RemoveMenu(_hParentMenu, _posBase + 1, MF_BYPOSITION);
			::RemoveMenu(_hParentMenu, _posBase + 0, MF_BYPOSITION);

			// Remove the last left separator from the submenu
			::RemoveMenu(_hMenu, 0, MF_BYPOSITION);
		}
	}

	//Remove all menu items
	for(int i = 0; i < _size; ++i) 
	{
		::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND);
	}
	//Then readd them, so everything stays in sync
	for(int j = 0; j < _size; ++j)
	{
		generic_string strBuffer(BuildMenuFileName(pNppParam->getRecentFileCustomLength(), j, _lrfl.at(j)._name));
		::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, strBuffer.c_str());
	}
	
}
Beispiel #26
0
BOOL CISCOCONFIG_MONITOR62(char *server, int port, char *pwd, char *enpwd,
                           char *pwdprompt, char *prompt, char *enpwdprompt,
                           char *enprompt, char *encmd, char *monitorid,
                           char *proxy_server, int proxy_port, char *proxy_uid,
                           char *proxy_pwd, char *custpath, char *szReturn)
{
    int		ret = 0;
    int		hSocket = 0;
    char runcmd[64] = {0};

    printf("Server:%s\nPort:%d\n", server, port);
    hSocket = telnet_init(server, port, proxy_server, proxy_port, proxy_uid, proxy_pwd);
    if(hSocket <= 0)
    {
        if(hSocket == -1)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_1%>"));//<%IDS_CiscoLog_1%>
        else if(hSocket == -2)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_2%>"));//<%IDS_CiscoLog_2%>
        else if(hSocket == -3)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_3%>"));//<%IDS_CiscoLog_3%>
        else if(hSocket == -4)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_4%>"));//<%IDS_CiscoLog_4%>
        else if(hSocket == -5)
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_5%>"));//<%IDS_CiscoLog_5%>
        else
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_6%>"));//<%IDS_CiscoLog_6%>

        return FALSE;
    }

    LPGDATA pgd=new GDATA;
    memset(pgd,0,sizeof(GDATA));

    printf("Connect Cisio network set\n");
    if((ret = cisco_connect(hSocket, pwd, pwdprompt, prompt,pgd)) < 0)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_7%>"));//<%IDS_CiscoLog_7%>
        delete pgd;
        return FALSE;
    }

    strncpy(runcmd, "enable\r\n", 8);
    send(hSocket, runcmd, strlen(runcmd), 0);
    printf("Login Cisio Config\n");
    if((ret = cisco_connect(hSocket, enpwd, enpwdprompt, enprompt,pgd)) < 0)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_8%>"));//<%IDS_CiscoLog_8%>
        delete pgd;
        return FALSE;
    }
    printf("Execute command\n");
    if((ret = cisco_command(hSocket, encmd, enprompt,pgd)) < 0)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_9%>"));//<%IDS_CiscoLog_9%>
        delete pgd;
        return FALSE;
    }

    int index = 0;
    char prebuffer[MAX_READ_SIZE] = {0};
    CString strBuffer(pgd->databuffer);

    index = strBuffer.Find("show running-config\r\n", 0);
    if(index >= 0)
        strBuffer.Delete(0, index + 21);

    if(!strBuffer.Right(strlen(enprompt)).Compare(enprompt))
    {
        index = strBuffer.ReverseFind('\r');
        if(index >= 0)
            strBuffer = strBuffer.Left(index);
    }

    FILE *cisco_fp = NULL;
    char prefile[256] = {0};

    sprintf(prefile, "%s\\cisco_config_%s", custpath, monitorid);
    if((_access(prefile, 0x04)) == -1)
    {
        if((cisco_fp = fopen(prefile, "w")) == NULL)
        {
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_10%>"));//<%IDS_CiscoLog_10%>
            delete pgd;
            return FALSE;
        }

        sprintf(szReturn,"status=%s$", FuncGetStringFromIDS("<%IDS_CiscoLog_11%>"));//<%IDS_CiscoLog_11%>
        int i = fwrite(strBuffer, sizeof(char), strBuffer.GetLength(), cisco_fp);
        fclose(cisco_fp);
        delete pgd;
        return TRUE;
    }

    if((cisco_fp = fopen(prefile, "r")) == NULL)
    {
        sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_12%>"));//<%IDS_CiscoLog_12%>
        delete pgd;
        return FALSE;
    }

    int j = fread(prebuffer, sizeof(char), sizeof(prebuffer), cisco_fp);
    fclose(cisco_fp);
    prebuffer[j] = 0;
    int m = strlen(prebuffer);
    int n = strBuffer.GetLength();
    if(!strBuffer.Compare(prebuffer))
    {
        char buffer [256] = {0};
        char tmp [256] = {0};
#if _DEBUG
        sprintf(buffer, "%s\\temp\\Cisio_logfile_%s.ini", FuncGetInstallRootPath(), server);
#else
        sprintf(buffer, "%s\\MonitorManager\\temp\\logfile.ini", FuncGetInstallRootPath());
#endif
        BOOL bChange = DFN_GetPrivateProfileInt(monitorid, "needconfirm", FALSE, buffer);
        if (!bChange)
        {
            sprintf(szReturn, "status=%s$", FuncGetStringFromIDS("<%IDS_CiscoLog_13%>"));//<%IDS_CiscoLog_13%>
            delete pgd;
            return TRUE;
        }
        else
        {
            sprintf(szReturn, "status=%s$", FuncGetStringFromIDS("<%IDS_CiscoLog_14%>"));//<%IDS_CiscoLog_14%>
            delete pgd;
            return TRUE;
        }
    }
    else
    {
        sprintf(szReturn, "status=%s$", FuncGetStringFromIDS("<%IDS_CiscoLog_14%>"));//<%IDS_CiscoLog_14%>
        if((cisco_fp = fopen(prefile, "w")) == NULL)
        {
            sprintf(szReturn, "error=%s", FuncGetStringFromIDS("<%IDS_CiscoLog_15%>"));//<%IDS_CiscoLog_15%>
            delete pgd;
            return FALSE;
        }

        int k = fwrite(strBuffer, sizeof(char), strBuffer.GetLength(), cisco_fp);
        fclose(cisco_fp);

        char buffer [256] = {0};
        char tmp [256] = {0};
#if _DEBUG
        sprintf(buffer, "%s\\temp\\Cisio_logfile_%s.ini", FuncGetInstallRootPath(), server);
#else
        sprintf(buffer, "%s\\MonitorManager\\temp\\logfile.ini", FuncGetInstallRootPath());
#endif
        DFN_WritePrivateProfileString(monitorid, "needconfirm", _ltoa(TRUE, tmp, 10), buffer);

        delete pgd;
        return TRUE;
    }
}