Example #1
0
bool COleDBConnectionProp::ReadProps(const CString strConnectionString)
{
	CString strConnection = strConnectionString;

	CString strToken;
	while( !(strToken = GetNextToken(strConnection,";")).IsEmpty())
	{
		CString strTok	 = GetNextToken(strToken,"=");
		strTok.TrimLeft(); strTok.TrimRight();
		CString strValue = GetNextToken(strToken,"");
		strValue.TrimLeft(); strValue.TrimRight();

		if(strTok.CompareNoCase(m_szDSNEntry) == 0)
			m_strDSN = strValue;
		else
		if(strTok.CompareNoCase(m_szServerNameEntry) == 0)
			m_strServerName = strValue;
		else
		if(strTok.CompareNoCase(m_szLoginNameEntry) == 0)
			m_strLoginName = strValue;
		else
		if(strTok.CompareNoCase(m_szDatabaseNameEntry) == 0)
			m_strDatabaseName = strValue;
		else
		if(strTok.CompareNoCase(m_szPasswordEntry) == 0)
			m_strPassword = strValue;
		else
		if(strTok.CompareNoCase(m_szTableEntry) == 0)
			m_strTableName = strValue;
	}

	return true;
}
CConfigurationDBI *CProjectDBI::LookupConfigurationByAddress (const CString &strAddress)
{
    HRESULT hr;
    int iIndex;
    CString str = strAddress;

    hr = Load ();
    if (FAILED (hr))
    {
        throw hr;
    };

    //it is possible that the address passed here contains {} encapsulation.
    str.TrimLeft();
    str.TrimRight();
    str.TrimLeft(_T('{'));
    str.TrimRight(_T('}'));

    for (iIndex = 0; iIndex < m_Configurations.GetSize (); ++iIndex)
    {
        CConfigurationDBI *pConfigurationDBI;

        pConfigurationDBI = m_Configurations[iIndex];
        ASSERT (pConfigurationDBI != NULL);
        if (pConfigurationDBI == NULL)
            continue;

        if (str.CompareNoCase (pConfigurationDBI->GetMachineAddress ()) == 0)
        {
            return (pConfigurationDBI);
        };
    };

    return (NULL);
}
Example #3
0
/**
 * @brief Writes options values from UI to storage.
 */
void PropRegistry::WriteOptions()
{
    CMergeApp *app = static_cast<CMergeApp*>(AfxGetApp());
    CString sDefaultEditor = app->GetDefaultEditor();

    GetOptionsMgr()->SaveOption(OPT_USE_RECYCLE_BIN, m_bUseRecycleBin == TRUE);

    CString sExtEditor = m_strEditorPath;
    sExtEditor.TrimLeft();
    sExtEditor.TrimRight();
    if (sExtEditor.IsEmpty())
        sExtEditor = sDefaultEditor;
    GetOptionsMgr()->SaveOption(OPT_EXT_EDITOR_CMD, sExtEditor);

    CString sFilterPath = m_strUserFilterPath;
    sFilterPath.TrimLeft();
    sFilterPath.TrimRight();
    GetOptionsMgr()->SaveOption(OPT_FILTER_USERPATH, sFilterPath);

    bool useSysTemp = m_tempFolderType == 0;
    GetOptionsMgr()->SaveOption(OPT_USE_SYSTEM_TEMP_PATH, useSysTemp);

    CString tempFolder = m_tempFolder;
    tempFolder.TrimLeft();
    tempFolder.TrimRight();
    GetOptionsMgr()->SaveOption(OPT_CUSTOM_TEMP_PATH, tempFolder);
}
Example #4
0
void CEditableListCtrl::CommitEditCtrl()
{
	if (m_iEditCol != -1 && m_iEditRow != -1)
	{
		if (m_pctrlEdit && m_pctrlEdit->IsWindowVisible())
		{
			CString strItem;
			m_pctrlEdit->GetWindowText(strItem);
			strItem.TrimLeft();
			strItem.TrimRight();
			SetItemText(m_iEditRow, m_iEditCol, strItem);
//			m_iEditRow = -1;
//			m_iEditCol = -1;
		}
		else if (m_pctrlComboBox && m_pctrlComboBox->IsWindowVisible())
		{
			CString strItem;
			m_pctrlComboBox->GetLBText(m_pctrlComboBox->GetCurSel(), strItem);
			strItem.TrimLeft();
			strItem.TrimRight();
			SetItemText(m_iEditRow, m_iEditCol, strItem);
//			m_iEditRow = -1;
//			m_iEditCol = -1;
		}
	}
}
BOOL CHMProject::ReadHuaMianList(CStdioFile *pfile)
{
    CString str;
    BOOL bl1,bl2;
    tagHMID hmid;
    tagHMID* phmid;
    int iret;

    //移动读指针到画面段落
    if (SeekSection(pfile,"HuaMian")==FALSE)
        return FALSE;
    try
    {
        //读取下一行字符串
        bl1=pfile->ReadString(str);
        if (!bl1) return FALSE;

        str.TrimLeft();
        str.TrimRight();
        //判断字符串是否是段落名
        bl2=HitTestSectionID(str);
        if (bl2) return FALSE;
        while ((!bl2)&&(bl1))
        {
            //读入画面名称和画面标志
            iret=sscanf(str,"%x=%[^;]33s",&hmid.dwflag,hmid.strHMName);//%[^=]s
            if (iret==2)
            {
                phmid=new tagHMID;
                if (phmid==NULL) return FALSE;
                ZeroMemory(phmid,sizeof(*phmid));
                strcpy(phmid->strHMName,hmid.strHMName);
                phmid->dwflag=hmid.dwflag;
                m_HMIDList.AddTail(phmid);
            }

            //读取下一行字符串
            bl1=pfile->ReadString(str);
            if (!bl1) break;

            str.TrimLeft();
            str.TrimRight();
            //判断字符串是否是段落名
            bl2=HitTestSectionID(str);
            if (bl2) break;
        }
        return TRUE;
    }
    catch(CFileException* e)
    {
        e->Delete();
        return FALSE;
    }

}
Example #6
0
BOOL CSimpleSAH::SetAttribute(LPCSTR lpAttriName, LPCSTR lpNewVal)
{
	CString tmp;
	CString tag(strCurTagBuf);
	tag.MakeLower();
	CString attri(lpAttriName);
	attri.MakeLower();

	BOOL found = FALSE;
	try{

	CString s;
	int i=0, j=0;
	while(!found)
	{
		i = tag.Find(attri, i);
		if(i<0)
			break;

		j = tag.Find('=', i);
		s = tag.Mid(i+attri.GetLength(), j-i-attri.GetLength());
		s.TrimLeft();
		if(s.IsEmpty())
		{
			found=TRUE;
			tmp = strCurTagBuf.Mid(j+1); tmp.TrimLeft();
			tag = strCurTagBuf.Left(j+1); //XXX=
			tag += "\"";
			tag += lpNewVal;
			tag += "\"";  //XXX="VVV" 

			if(tmp.GetAt(0) == '\"' || tmp.GetAt(0) == '\'') //quated string
			{
				tmp = tmp.Right(tmp.GetLength()-1);
				i = tmp.FindOneOf("\'\"\r\n>");
				if(tmp.GetAt(i) == '\"' || tmp.GetAt(i) == '\'')
					i++;
			}
			else
				i = tmp.FindOneOf(" \r\n>\'\"");
			tag += strCurTagBuf.Right(tmp.GetLength() - i);
			strCurTagBuf = tag;
		}
		i += attri.GetLength();
	}
	}
	catch(...)
	{
	}

	return found;
}
Example #7
0
BOOL CPreStylePag::DeleteTextStyle(CString strTSName)
{
    CMObject obj, tsobj;
    long     i, nCount;
    CString  strtmp;

    //进行参数检查和初始化
    strTSName.TrimLeft();
    strTSName.TrimRight();
    strTSName.MakeUpper();
    if(strTSName.GetLength() <= 0) return FALSE;

    try
    {
        if(FindAcad() == FALSE)
        {
            return FALSE;
        }
        
        //SETUP-1: 获取ACAD文本样式列表
        obj = EDIBAcad::objAcadDoc.GetPropertyByName(
                                      _T("TextStyles"));
        
        //SETUP-2: 获取样式对象
		nCount = (long)obj.GetPropertyByName(_T("Count"));
		for( i = 0; i < nCount; i++)
		{
			tsobj = obj.Invoke(_T("Item"), 1, &_variant_t(i));
			strtmp = vtos(tsobj.GetPropertyByName(_T("Name")));
			strtmp.TrimLeft();
            strtmp.TrimRight();
			strtmp.MakeUpper();
			if(strtmp == strTSName)
			{
                //删除目标样式
                tsobj.Invoke0(_T("Delete"));
                return TRUE;
			}
		}
    }
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}
    catch(...)
    {
    }
    return FALSE;
}
Example #8
0
void CLotteryDlg::_readInit()
{
	TCHAR path[MAX_PATH] = {0};
	CString strPath = _getCurPath() + _T("init.ini");
	GetPrivateProfileString(_T("Titile"), _T("title"), _T(""), path, MAX_PATH, strPath);
	CString str = path;
	m_uiInfo._title = str.GetBuffer();
	str.ReleaseBuffer();
	//读取已经中奖的人
	TCHAR *pBuf = new TCHAR[10240];
	memset(pBuf, 0, sizeof(TCHAR) * 10240);
	GetPrivateProfileString(_T("Procedure"), _T("winner"), _T(""), pBuf, 10240, strPath);
	std::wstring strwinner = pBuf;
	delete pBuf;
	pBuf = NULL;
	_parseWinnerPicPath(strwinner);
	//读取奖项设置
	m_TotalClass = GetPrivateProfileInt(_T("Adwards"), _T("total"), 3, strPath);
	m_NumFinished = GetPrivateProfileInt(_T("Procedure"), _T("finished"), 0, strPath);
	AwardInfo ai;
	CString tmp;
	int pos = 0;
	for (int i = m_TotalClass; i > 0; --i)
	{
		str.Format(_T("%d"), i);
		GetPrivateProfileString(_T("Adwards"), str, _T("0"), path, MAX_PATH, strPath);
		str = path;
		//几等奖品
		pos = str.Find(_T(' '));
		tmp = str.Left(pos);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._class = tmp.GetBuffer();
		tmp.ReleaseBuffer();
		//多少人的
		pos = str.Find(_T(' '));
		tmp = str.Left(pos-1);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._tnum = _wtoi(tmp.GetBuffer());
		tmp.ReleaseBuffer();
		//什么奖品
		str.Trim();
		ai._award = str.GetBuffer();
		str.ReleaseBuffer();

		m_AwardInfo.push_back(ai);
	}
	//读取信息后需要在做一下处理:比如说上次程序运行已经完成到什么阶段,现在应该接着运行
	_checkFinishedNum();
}
Example #9
0
static void outputAccumulated(ostream& fout, CString &sAccumulate)
{
	if(!sAccumulate.IsEmpty())
	{
		// strip extra whitespace

		sAccumulate.TrimLeft();// remove leading whitespace
		const char* b = LPCTSTR(sAccumulate);
		char* buff = new char[sAccumulate.GetLength()+1];
		char* c = buff;
		while(*b)
		{
			if(*b == '_') // inserted by joincomp
				*(c++) = ' ';

			else if(! (::iswspace(*b) && ::iswspace(*(b+1))))
			{
				*c = *b;
				++c;
			}
			++b;
		}
		*c='\0';

		// replace with preceding marker (i.e. \v )
		//fout <<'\\'<<lpszPrecedingMarker<<' '<<buff<<'\n';
		fout <<' '<<buff<<'\n';
	}
	sAccumulate="";
}
Example #10
0
BOOL CListCtrlEx::OnToolTipText(UINT /*uID*/, NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
{
    BOOL bRet = TRUE;
#ifdef _TOOL_TIP_ENABLE
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
    TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
    UINT nID = pNMHDR->idFrom;
    if(!nID)
    	bRet = FALSE;

	if(bRet)
	{
		int nRow = ((nID-1) >> 10) & 0x3fffff ;
		int nCol = (nID-1) & 0x3ff;
		CString strTipText = GetItemText(nRow, nCol);
		strTipText.TrimRight();
		strTipText.TrimLeft();
#ifndef _UNICODE
		if (pNMHDR->code == TTN_NEEDTEXTA)
			lstrcpyn(pTTTA->szText, strTipText, 80);
		else
			_mbstowcsz(pTTTW->szText, strTipText, 80);
#else
		if(pNMHDR->code == TTN_NEEDTEXTA)
			_wcstombsz(pTTTA->szText, strTipText, 80);
		else
			lstrcpyn(pTTTW->szText, strTipText, 80);
#endif
	}
    
	*pResult = 0;
#endif

    return bRet;
}
Example #11
0
void CPreStylePag::QueryAcadTextStyleCombo()
{
    //查询ACAD中已有的可用的文字样式
    CMObject obj, sobj;
    CString  strStyleName;
    CComboBox *lpStyle;
    long i, nCount;
	try
	{
        lpStyle = (CComboBox *)GetDlgItem(IDC_COMBO_STYLE);
        obj = EDIBAcad::objAcadDoc.GetPropertyByName(_T("TextStyles"));
		nCount =(long)obj.GetPropertyByName(_T("Count"));

		for(i = 0; i < nCount; i++)
		{
			sobj = obj.Invoke(_T("Item"), 1, &_variant_t(i));
			strStyleName = vtos(sobj.GetPropertyByName(_T("Name")));
			strStyleName.TrimLeft();
            strStyleName.TrimRight();
            if(strStyleName.GetLength() <= 0) continue;

            lpStyle->AddString(strStyleName);
		}
	}
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}
	catch(...)
	{
	}
}
Example #12
0
void textelite_get(CString& cszText)
{
   std::string str(g_vecPrintfText.begin(), g_vecPrintfText.end());
   cszText = str.c_str();
   cszText.TrimLeft(_T("\r\n"));
   cszText.TrimRight();
}
Example #13
0
	void BootStrap(T *pTarget, const CString& sContent)
	{
		if (!pTarget->GetBuffer().IsEmpty())
			return; // in this case the module was probably reloaded

		VCString vsLines;
		VCString::iterator it;

		sContent.Split("\n", vsLines);

		for (it = vsLines.begin(); it != vsLines.end(); ++it) {
			CString sLine(*it);
			sLine.Trim();
			if (sLine[0] == '@' && it+1 != vsLines.end())
			{
				CString sTimestamp = sLine.Token(0);
				sTimestamp.TrimLeft("@");
				timeval ts;
				ts.tv_sec = sTimestamp.Token(0, false, ",").ToLongLong();
				ts.tv_usec = sTimestamp.Token(1, false, ",").ToLong();

				CString sFormat = sLine.Token(1, true);

				CString sText(*++it);
				sText.Trim();

				pTarget->AddBuffer(sFormat, sText, &ts);
			} else
			{
				// Old format, escape the line and use as is.
				pTarget->AddBuffer(_NAMEDFMT(sLine));
			}
		}
	}
CString CProjectDBI::StripConfiguration (const CString &strPath, CString &strRemainder)
{
    int iPos;

    if (strPath[0] == _T ('{'))
    {
        iPos = strPath.Find (_T ('}'));
        if (iPos == -1)
        {
            strRemainder = strPath;
            return ("");
        };

        strRemainder = strPath.Mid (iPos + 1);
        strRemainder.TrimLeft(_T('.'));
        return (strPath.Left (iPos+1));
    };

    iPos = strPath.Find (_T ('.'));
    if (iPos == -1)
    {
        strRemainder = "";
        return (strPath);
    };

    strRemainder = strPath.Mid (iPos + 1);
    return (strPath.Left (iPos));
}
Example #15
0
int CuDlgMain::GetInstallationParam(int nSchema)
{
	int nInstallation = -1;
	CRect r1, r2, re;
	CComboBoxEx* pComboDatabase = (nSchema == 1)? &m_cComboDatabase1: &m_cComboDatabase2;
	CEdit*       pEditFile  = (nSchema == 1)? &m_cEditFile1: &m_cEditFile2;
	if (pEditFile->IsWindowVisible())
	{
		CString strFile;
		pEditFile->GetWindowText(strFile);
		strFile.TrimLeft();
		strFile.TrimRight();
		if (strFile.IsEmpty())
			return -1;
		if (_taccess(strFile, 0) == -1)
			return -1;
		nInstallation = IsInstallationFile(strFile);
	}
	else
	{
		int nSel = pComboDatabase->GetCurSel();
		if (nSel != CB_ERR)
		{
			CaDatabase* pDatabase = (CaDatabase*)pComboDatabase->GetItemDataPtr(nSel);
			if (pDatabase)
			{
				CString strDb = pDatabase->GetItem();
				nInstallation = strDb.IsEmpty()? 1: 0;
			}
		}
	}
	return nInstallation;
}
Example #16
0
void CuDlgPropertyPageSqlExpressionInParams::OnButton2Param() 
{
	int nAnswer = IDCANCEL;
	CxDlgPropertySheetSqlExpressionWizard* pParent = (CxDlgPropertySheetSqlExpressionWizard*)GetParent();

	try
	{
		//
		// Select only mode:
		CxDlgPropertySheetSqlWizard sqlWizard (TRUE, this);
		sqlWizard.m_queryInfo = pParent->m_queryInfo;
		if (sqlWizard.DoModal() != IDCANCEL)
		{
			CString strStatement;
			sqlWizard.GetStatement (strStatement);
			strStatement.TrimLeft();
			strStatement.TrimRight();
			if (!strStatement.IsEmpty())
				m_cParam1.ReplaceSel(strStatement, TRUE);
		}
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	catch(...)
	{
		// _T("Cannot initialize the SQL assistant.");
		AfxMessageBox (IDS_MSG_SQL_ASSISTANT, MB_ICONEXCLAMATION|MB_OK);
	}
}
void CGroupSelectDlg::OnUpdate() 
{
	// TODO: Add your control notification handler code here
	int item;
	int i = m_list.GetSelectedCount();
	if(i>0)
	{
		POSITION pos = m_list.GetFirstSelectedItemPosition();
		item = m_list.GetNextSelectedItem(pos);
	}
	else
		return;
	
	CGroupUrlDlg dlg;
	dlg.m_strName = m_list.GetItemText(item, 0);
	dlg.m_strUrl = m_list.GetItemText(item,1);
	dlg.m_bState = m_list.GetCheck(item);
	dlg.m_dwProperty = m_list.GetItemData(item);
	if(dlg.DoModal() == IDOK)
	{
		CString str = dlg.m_strName;
		str.TrimLeft();
		str.TrimRight();
		if(str.IsEmpty())
			GetUnqBlankName(str);
		m_list.SetItemText(item, 0, str);
		dlg.m_strUrl.TrimLeft();
		m_list.SetItemText(item, 1, dlg.m_strUrl);
		m_list.SetCheck(item, dlg.m_bState);
		m_list.SetItemData(item,dlg.m_dwProperty);
	}	
}
BOOL CVersionChecker::UndertakeRequest(CString& strPost)
{
	m_pRequest.SetURL( _T("http://update.trillinux.org/version/beta.php?") + strPost );
	//Remember to set the update server for final releases.
	
	if ( ! m_pRequest.Execute( FALSE ) ) return FALSE;
	
	int nStatusCode = m_pRequest.GetStatusCode();
	if ( nStatusCode < 200 || nStatusCode > 299 ) return FALSE;
	
	CString strResponse = m_pRequest.GetResponseString();
	CString strHack = theApp.GetProfileString( _T("VersionCheck"), _T("TestResponse"), _T("") );
	if ( strHack.GetLength() ) strResponse = strHack;
	
	for ( strResponse += '&' ; strResponse.GetLength() ; )
	{
		CString strItem	= strResponse.SpanExcluding( _T("&") );
		strResponse		= strResponse.Mid( strItem.GetLength() + 1 );
		
		CString strKey = strItem.SpanExcluding( _T("=") );
		if ( strKey.GetLength() == strItem.GetLength() ) continue;
		strItem = CTransfer::URLDecode( strItem.Mid( strKey.GetLength() + 1 ) );

		strItem.TrimLeft();
		strItem.TrimRight();
		
		m_pResponse.SetAt( strKey, strItem );
	}
	
	return TRUE;
}
Example #19
0
void CMCAModParam::OnModparamsBrowse() 
{
	if(m_pPS)m_pPS->SetToClose(0);

	CDirDialog DirDialog(this);
	char temp[_MAX_DIR+1];
	GetDlgItem(IDC_MODPARAMS_SAVELOC)->GetWindowText(temp,sizeof(temp)-1);
	DirDialog.m_strTitle = "Select Directory to save files in.";
	if (DirDialog.DoBrowse())
	{
		CString Id;
		GetDlgItemText(IDC_MODPARAMS_FILEID,Id);
		Id.TrimLeft();
		CString Text(DirDialog.m_strPath);
		CString Name("MCA"+Id);
		if (Text.Find(Name,0)==-1)
		{
			if (Text.Right(1) == '\\')
				Text += "MCA";
			else
				Text += "\\MCA";
			Text += Id;
		}
		SetDlgItemText(IDC_MODPARAMS_SAVELOC, Text);
	}
}
Example #20
0
// Reads a field ending with a comma, newline, or at maxlen
// Delimiting character is not appended
// CurPos is incremented to the next field
// Returns FALSE if the current field is blank
int CSVFile::getField (char *str, int maxlen)
{
	int i = 0;

    while (dataLine[curPos] != COMMA && i < maxlen && curPos < lineLength)
        str[i++] = dataLine[curPos++];

    if (dataLine[curPos] != COMMA && i == maxlen)
	{
        str[--i] = NULL;
		skipField (1);
	}
	else
	{
		str[i] = NULL;
		curPos++;
	}

	CString csStr = str;
	csStr.TrimLeft();
	csStr.TrimRight();
	strcpy( str, csStr );

    // returns count of characters in field
    return i;
}
Example #21
0
void CGroupingDlg::OnAdd() 
{
	CString strValue;
	m_wndGroup.GetWindowText( strValue );
	
	strValue.TrimLeft(); strValue.TrimRight();
	if ( strValue.IsEmpty() ) return;
	
	if ( ! m_pXML ) m_pXML = new CXMLElement;
	
	if ( m_wndGroup.FindStringExact( -1, strValue ) == CB_ERR ) CreateGroup( strValue, m_pXML );
	
	int nItem = m_wndList.InsertItem( LVIF_TEXT|LVIF_PARAM,
		m_wndList.GetItemCount(), NULL, 0, 0, 0, NULL );
	
	for ( int nDeselect = m_wndList.GetNextItem( -1, LVNI_SELECTED ) ;
		nDeselect != -1 ; nDeselect = m_wndList.GetNextItem( nDeselect, LVNI_SELECTED ) )
	{
		m_wndList.SetItemState( nDeselect, 0, LVIS_SELECTED );
	}
	
	m_wndList.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED );
	m_wndList.EnsureVisible( nItem, TRUE );
	
	m_pHitInfo.iItem	= nItem;
	m_pHitInfo.iSubItem	= 0;
	
	m_wndList.SetFocus();
	m_wndList.EditLabel( nItem );
}
Example #22
0
	virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage) {
		sTarget.TrimLeft("\244");

		if (sMessage.Left(2) == "``") {
			sMessage.LeftChomp(2);
			return CONTINUE;
		}

		MCString::iterator it = FindNV(sTarget.AsLower());

		if (it != EndNV()) {
			CChan* pChan = m_pUser->FindChan(sTarget);
			if (pChan) {
				if (pChan->KeepBuffer())
					pChan->AddBuffer(":\244" + m_pUser->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage);
				m_pUser->PutUser(":\244" + m_pUser->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage, NULL, m_pClient);
			}

			CString sMsg = MakeIvec() + sMessage;
			sMsg.Encrypt(it->second);
			sMsg.Base64Encode();
			sMsg = "+OK *" + sMsg;

			PutIRC("PRIVMSG " + sTarget + " :" + sMsg);
			return HALTCORE;
		}

		return CONTINUE;
	}
Example #23
0
bool CPatch::Read(CStdioFile& fp)
{
	CString	s;
	int	Version;
	if (!fp.ReadString(s) || _stscanf(s, FILE_ID, &Version) != 1)
		return(FALSE);
	SetDefaults();	// in case some lines are missing
	while (fp.ReadString(s)) {
		s.TrimLeft();
		CString	Name = s.SpanExcluding(_T(" \t"));
		CString	Arg = s.Mid(Name.GetLength());
		int	i;
		for (i = 0; i < ROWS; i++) {
			if (Name == m_RowData[i].Name) {
				ROW	*r = &m_Row[i];
				_stscanf(Arg, _T("%lf %d %lf %lf %lf"),
					&r->Val, &r->Wave, &r->Amp, &r->Freq, &r->PW);
				break;
			}
		}
		if (i >= ROWS) {	// not a parm row, assume it's a state member
			for (i = 0; m_LineInfo[i].Name != NULL; i++) {
				if (Name == m_LineInfo[i].Name) {
					CFormatIO::StrToVal(m_LineInfo[i].Type, Arg,
						((char *)this) + m_LineInfo[i].Offset);
					break;
				}
			}
		}
	}
	return(TRUE);
}
void CBusEventHandlerDlg::OnBnClickedOk()
{
    CButton* pomButton       = NULL;
    CString omStrHandlerName = STR_EMPTY ;
    CString omStrControl     = STR_EMPTY ;
    INT nCheck               = 0;
    BOOL bIsEnable           = TRUE;
    // Get the selected handlers either for deleteting or adding and
    // add the name in the array
    for(int j=0; j<defBUSEV_HANDLER_NUMBER; j++)
    {
        pomButton = (CButton*)GetDlgItem(IDC_CHKB_BUSEV_CONNECT_HANDLER + j);
        if(pomButton != NULL )
        {
            nCheck      = pomButton->GetCheck();
            bIsEnable   = pomButton->IsWindowEnabled();
            pomButton->GetWindowText(omStrControl);
            omStrControl.TrimLeft();
            omStrControl.TrimRight();
            omStrControl.Replace(' ','_');
            omStrControl.Replace('-','_');
            omStrHandlerName = omStrControl;
            if(nCheck == 1 && bIsEnable != 0 )
            {
                m_omStrArrayBusEventHandler.Add(omStrHandlerName);
            }
        }
    }
    OnOK();
}
void CCeWatchDlg::OnPasteItems ()
{
    if (m_bHistoryFocus)
    {
        m_HistoryListCtrl.Paste();
        return;
    }

    HGLOBAL memoryHandle;
    LPCTSTR memoryBlock;
    CString strNames;

    if (!::OpenClipboard (m_hWnd))
        return;

    memoryHandle = ::GetClipboardData (CF_TEXT);
    if (memoryHandle == NULL)
    {
        ::CloseClipboard ();
        return;
    };

    memoryBlock = (LPCTSTR)::GlobalLock (memoryHandle);
    if (memoryBlock == NULL)
    {
        ::CloseClipboard ();
        return;
    };

    strNames = memoryBlock;

    ::GlobalUnlock (memoryHandle);
    ::CloseClipboard ();

    while (!strNames.IsEmpty ())
    {
        int iPos;
        CString strName;
        CCeWatchElement *pInsertedElement=NULL;

        iPos = strNames.Find (_T ('\n'));
        if (iPos == -1)
        {
            strName = strNames;
            strNames = _T ("");
        }
        else
        {
            strName = strNames.Left (iPos);
            strNames = strNames.Mid (iPos + 1);
        };

        strName.TrimLeft ();
        strName.TrimRight ();

        if (!strName.IsEmpty ())
            m_VarList.InsertExpressionWithStructInfo(strName, pInsertedElement);
    };
}
void CCalendarDlg2::SetTextForDay(SYSTEMTIME* sysTime)
{
    static BOOL bFirst=1;
    static CString sDovesok;
    static COleDateTime dtCurrent;
    if(!bFirst && dtCurrent.GetStatus()!=COleDateTime::invalid) {
        CString sThisDayNKey=Format(sKey,dtCurrent.GetDay(),dtCurrent.GetMonth(),dtCurrent.GetYear());
        CString sCurDay;
        m_eText.GetWindowText(sCurDay);
        sCurDay.TrimLeft();
        sCurDay.TrimRight();
        if(sCurDay!="") {
            sCurDay.Replace("\r\n","\n");
            if(sDovesok!="") {
                sCurDay+=Format("[?CDATA{%s}?DATAC:)]",sDovesok);
            }
            if(!bINewLine) {
                sCurDay.Replace("\n","<br>");
            }
            CString sContent=CString("\n")+sCurDay+"\n";
            while(sContent!="") {
                CString sLine=sContent.SpanExcluding("\n");
                if(sLine!="") {
                    aItems.Add(sThisDayNKey+sLine);
                    if(sContent.GetLength()>sLine.GetLength()) {
                        sContent=sContent.Mid(sLine.GetLength()+1);
                    } else {
                        sContent="";
                    }
                }
                sContent.TrimLeft();
            }
        }
        sDovesok="";
    }
    bFirst=0;
    if(sysTime) {
        COleDateTime dtTime=COleDateTime(sysTime->wYear,sysTime->wMonth,sysTime->wDay,0,0,0);
        char szTmp[256]= {0};
        GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,sysTime,0,szTmp,sizeof(szTmp));
        GetDlgItem(IDC_STATIC3)->SetWindowText(Format("%s: %s",_l("Current date"),szTmp));
        CString sThisDayNKey=Format(sKey,dtTime.GetDay(),dtTime.GetMonth(),dtTime.GetYear());
        dtCurrent=dtTime;
        CString sDayNote;
        for(int i=aItems.GetSize()-1; i>=0; i--) {
            if(aItems[i].Find(sThisDayNKey)==0) {
                if(sDayNote!="") {
                    sDayNote+="\r\n";
                }
                sDayNote+=aItems[i].Mid(sThisDayNKey.GetLength());
                aItems.RemoveAt(i);
            }
        }
        sDovesok=CDataXMLSaver::GetInstringPart("[?CDATA{","}?DATAC:)]",sDayNote);
        sDayNote.Replace(Format("[?CDATA{%s}?DATAC:)]",sDovesok),"");
        sDayNote.Replace("<br>","\r\n");
        m_eText.SetWindowText(sDayNote);
    }
}
Example #27
0
CString CSimpleSAH::GetAttribute(LPCSTR lpAttriName)
{
	CString tmp;
	CString tag(strCurTagBuf);
	tag.MakeLower();
	CString attri(lpAttriName);
	attri.MakeLower();

	try{

	CString s;
	int i=0, j=0;
	BOOL found = FALSE;
	while(!found)
	{
		i = tag.Find(attri, i);
		if(i<0)
			break;

		j = tag.Find('=', i);
		s = tag.Mid(i+attri.GetLength(), j-i-attri.GetLength());
		s.TrimLeft();
		if(s.IsEmpty())
		{
			found=TRUE;
			tmp = strCurTagBuf.Mid(j+1);
			if(tmp.GetAt(0) == '\"' || tmp.GetAt(0) == '\'') //quoted string
			{
				tmp = tmp.Right(tmp.GetLength()-1);
				i = tmp.FindOneOf("\'\"\r\n>");
			}
			else
				i = tmp.FindOneOf(" \r\n>\'\"");
			tmp = tmp.Left(i);
			tmp.TrimLeft();
			tmp.TrimRight();
		}
		i += attri.GetLength();
	}
	}
	catch(...)
	{
	}

	return tmp;
}
Example #28
0
void CFilePath::Trim(CString &sString)
{
    if (_istspace(GetFirstChar(sString)))
        sString.TrimLeft();

    if (_istspace(GetLastChar(sString)))
        sString.TrimRight();
}
Example #29
0
void CIRCSock::ParseISupport(const CMessage& Message) {
    const VCString vsParams = Message.GetParams();

    for (size_t i = 1; i < vsParams.size() - 1; ++i) {
        const CString& sParam = vsParams[i];
        CString sName = sParam.Token(0, false, "=");
        CString sValue = sParam.Token(1, true, "=");

        if (0 < sName.length() && ':' == sName[0]) {
            break;
        }

        m_mISupport[sName] = sValue;

        if (sName.Equals("PREFIX")) {
            CString sPrefixes = sValue.Token(1, false, ")");
            CString sPermModes = sValue.Token(0, false, ")");
            sPermModes.TrimLeft("(");

            if (!sPrefixes.empty() && sPermModes.size() == sPrefixes.size()) {
                m_sPerms = sPrefixes;
                m_sPermModes = sPermModes;
            }
        } else if (sName.Equals("CHANTYPES")) {
            m_pNetwork->SetChanPrefixes(sValue);
        } else if (sName.Equals("NICKLEN")) {
            unsigned int uMax = sValue.ToUInt();

            if (uMax) {
                m_uMaxNickLen = uMax;
            }
        } else if (sName.Equals("CHANMODES")) {
            if (!sValue.empty()) {
                m_mueChanModes.clear();

                for (unsigned int a = 0; a < 4; a++) {
                    CString sModes = sValue.Token(a, false, ",");

                    for (unsigned int b = 0; b < sModes.size(); b++) {
                        m_mueChanModes[sModes[b]] = (EChanModeArgs) a;
                    }
                }
            }
        } else if (sName.Equals("NAMESX")) {
            if (m_bNamesx)
                continue;
            m_bNamesx = true;
            PutIRC("PROTOCTL NAMESX");
        } else if (sName.Equals("UHNAMES")) {
            if (m_bUHNames)
                continue;
            m_bUHNames = true;
            PutIRC("PROTOCTL UHNAMES");
        }
    }
}
// returns NULL if CANCEL, else input string
//
LPCSTR GetString( LPCSTR psPrompt ) {
	static CString strReturn;
	CGetString Input( psPrompt, &strReturn );
	if( Input.DoModal() == IDOK ) {
		strReturn.TrimLeft();
		strReturn.TrimRight();
		return ( LPCSTR )strReturn;
	}
	return NULL;
}