DWORD CShellFileOp::GetRequiredBufferSize ( const CStringList& list ) { DWORD dwRetVal = 0; POSITION pos; CString cstr; // If this assert fires, the passed-in list was empty. This ought to // never fire, actually, since Go() won't even call this function if // either list is empty. ASSERT ( !list.IsEmpty() ); pos = list.GetHeadPosition(); while ( NULL != pos ) { cstr = list.GetNext ( pos ); // **NOTE** The MFC docs for CString::GetLength() say that it returns // the number of bytes in the string, but that's wrong!! In Unicode, // it returns the number of characters (which is half the number of // bytes). Thus the multiplication by sizeof(TCHAR). dwRetVal += sizeof(TCHAR) * ( cstr.GetLength() + 1 ); } return dwRetVal + sizeof(TCHAR); // add one more for the final null }
void CShellFileOp::FillSzzBuffer ( TCHAR* pBuffer, const CStringList& list ) { TCHAR* pCurrPos; POSITION pos; CString cstr; // If this assert fires, the passed-in list was empty. This ought to // never fire, actually, since Go() won't even call this function if // either list is empty when it shouldn't be. ASSERT ( !list.IsEmpty() ); ASSERT ( pBuffer != NULL ); pCurrPos = pBuffer; pos = list.GetHeadPosition(); while ( NULL != pos ) { cstr = list.GetNext ( pos ); _tcscpy ( pCurrPos, (LPCTSTR) cstr ); pCurrPos = _tcsinc ( _tcschr ( pCurrPos, '\0' ) ); } // Tack on the final null *pCurrPos = '\0'; }
void CDownloads::PurgeDeletes() { CStringList pRemove; HKEY hKey = NULL; if ( ERROR_SUCCESS != RegOpenKeyEx( HKEY_CURRENT_USER, _T("Software\\Shareaza\\Shareaza\\Delete"), 0, KEY_ALL_ACCESS, &hKey ) ) return; for ( DWORD nIndex = 0 ; nIndex < 1000 ; nIndex ++ ) { DWORD nPath = MAX_PATH*2; TCHAR szPath[MAX_PATH*2]; if ( ERROR_SUCCESS != RegEnumValue( hKey, nIndex, szPath, &nPath, NULL, NULL, NULL, NULL ) ) break; if ( GetFileAttributes( szPath ) == 0xFFFFFFFF || DeleteFile( szPath ) ) { pRemove.AddTail( szPath ); } } while ( ! pRemove.IsEmpty() ) { RegDeleteValue( hKey, pRemove.RemoveHead() ); } RegCloseKey( hKey ); }
BOOL IsPick(CString itemName){ if(dlxiaoDllDlg->IsDlgButtonChecked(IDC_CHECK_QJ)){ return TRUE; } if ( pickItemNameList.IsEmpty()){ return false; }else if(pickItemNameList.Find(itemName)){ return true; } return false; }
void CWizDlg::load_menub(POSITION ps) { CStringList bList; bookm.DestroyMenu(); bookm.CreatePopupMenu(); Recents.GetHead()->load_menu_bm(bList); UINT itm=150; POSITION p=bList.GetHeadPosition(); while (p) bookm.AppendMenu(MF_STRING,itm++,bList.GetNext(p)); bookm.AppendMenu(MF_SEPARATOR,itm++); bookm.AppendMenu(MF_STRING,itm++,"Store bookmarks list in memo"); bookm.EnableMenuItem(itm-1, ( bList.IsEmpty() )? MF_GRAYED:0); }
// takes a list of strings and converts it to a string like "apples,peaches,pears" void ListToString (const CStringList & thelist, const char delim, CString & str) { int iCount = 0; str.Empty (); if (thelist.IsEmpty ()) return; for (POSITION pos = thelist.GetHeadPosition (); pos; ) { str += thelist.GetNext (pos); if (++iCount < thelist.GetCount ()) str += delim; } // end of getting each one } // end of ListToString
bool ExtractParams(CString data, CStringList ¶ms) { CString param; params.RemoveAll(); for(int i = 0; ; i++) { if(ExtractParam(data, param, i)) { params.AddTail(param); } else { break; } } return !params.IsEmpty(); }
bool CRegistryKey::getValues(CStringList& values) { values.RemoveAll(); if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) { for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; ++i) { TCHAR value[255] = { 0 }; DWORD size = _countof(value); rc = RegEnumValue(m_hKey, i, value, &size, nullptr, nullptr, nullptr, nullptr); if (rc == ERROR_SUCCESS) values.AddTail(value); } } return !values.IsEmpty(); }
bool CRegistryKey::getSubKeys(CStringList& subkeys) { subkeys.RemoveAll(); if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) { for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; ++i) { TCHAR value[1024] = { 0 }; DWORD size = _countof(value); FILETIME last_write_time; rc = RegEnumKeyEx(m_hKey, i, value, &size, nullptr, nullptr, nullptr, &last_write_time); if (rc == ERROR_SUCCESS) subkeys.AddTail(value); } } return !subkeys.IsEmpty(); }
BOOL CPackagePage::OnSetActive() { SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT ); if ( ! theApp.m_sCommandLineSourceFile.IsEmpty() ) { CStringList oDirs; oDirs.AddTail( theApp.m_sCommandLineSourceFile ); theApp.m_sCommandLineSourceFile.Empty(); while ( ! oDirs.IsEmpty() ) { CString strFolder = oDirs.RemoveHead() + _T("\\"); CFileFind finder; BOOL bWorking = finder.FindFile( strFolder + _T("*.*") ); while ( bWorking ) { bWorking = finder.FindNextFile(); if ( ! finder.IsDots() && ! finder.IsHidden() ) { CString sFilename = strFolder + finder.GetFileName(); if ( finder.IsDirectory() ) oDirs.AddTail( sFilename ); else AddFile( sFilename ); } } } if ( m_wndList.GetItemCount() > 0 ) Next(); } m_wndRemove.EnableWindow( m_wndList.GetSelectedCount() > 0 ); UpdateData( FALSE ); return CWizardPage::OnSetActive(); }
void CCmd_ListOpStat::PreProcess(BOOL& done) { int i; POSITION pos; CCmd_ListOp cmd1(m_pClient); // Set up and run ListOp synchronously cmd1.Init(NULL, RUN_SYNC); cmd1.SetChkForSyncs(m_ChkForSyncs); cmd1.SetWarnIfLocked(m_WarnIfLocked); if(cmd1.Run(m_pFileSpecs, m_Command, m_ChangeNumber, m_NewType)) { m_FatalError= cmd1.GetError(); done=TRUE; if (m_ChkForSyncs) { CStringList * pSyncList = cmd1.GetSyncList(); if (!pSyncList->IsEmpty()) { for( pos= pSyncList->GetHeadPosition(); pos!= NULL; ) m_Unsynced.AddHead( pSyncList->GetNext(pos) ); CStringList * pEditList = cmd1.GetList(); for( pos= pEditList->GetHeadPosition(); pos!= NULL; ) { CString txt = pEditList->GetNext(pos); if ((i = txt.Find(_T('#'))) != -1) txt = txt.Left(i); m_RevertIfCancel.AddHead( txt ); } } else m_ChkForSyncs = FALSE; } } else { m_ErrorTxt= _T("Unable to Run ListOp"); m_FatalError=TRUE; } // Extract the CStringList from ListOp, which has filtered // results for the command. Note that Errors, warnings and // gee-whiz info have been thrown to the status window and // are not in the list CStringList *strList= cmd1.GetList(); // Check for huge file sets, where incremental screen update can take // a very looong time to complete. We are more tolerant for repoens, // because they involve updates in only one pane if(!m_FatalError && m_Command== P4REOPEN && strList->GetCount() > (3 * MAX_FILESEEKS)) { m_HitMaxFileSeeks= TRUE; TheApp()->StatusAdd(_T("CCmd_ListOpStat/P4REOPEN hit MAX_FILESEEKS - blowing off incremental update"), SV_DEBUG); } else if(!m_FatalError && m_Command!= P4REOPEN && strList->GetCount() > MAX_FILESEEKS) { m_HitMaxFileSeeks= TRUE; TheApp()->StatusAdd(_T("CCmd_ListOpStat hit MAX_FILESEEKS - blowing off incremental update"), SV_DEBUG); } // In the usual case of zero to a few hundred files, gather ostat-like info // for each file so that screen updates can be completed else if(!m_FatalError && strList->GetCount() > 0) { // Save a copy of the stringlist. for( pos= strList->GetHeadPosition(); pos!= NULL; ) m_StrListOut.AddHead( strList->GetNext(pos) ); // See if we need to run Ostat if(m_Command==P4EDIT || m_Command==P4DELETE) { // Set up and run ostat synchronously CCmd_Ostat cmd2(m_pClient); cmd2.Init(NULL, RUN_SYNC); if(cmd2.Run(FALSE, m_ChangeNumber)) m_FatalError= cmd2.GetError(); else { m_ErrorTxt= _T("Unable to Run Ostat"); m_FatalError=TRUE; } CObArray const *array= cmd2.GetArray(); if(!m_FatalError && array->GetSize() > 0) { // Save a copy of the oblist. for( int i=0; i < array->GetSize(); i++ ) m_StatList.AddHead( array->GetAt(i) ); } } else PrepareStatInfo(); } // Post the completion message if(!m_FatalError) { CString message; int already = 0; int reopened = 0; switch(m_Command) { case P4EDIT: for( pos= strList->GetHeadPosition(); pos!= NULL; ) { CString str = strList->GetNext(pos); if (str.Find(_T(" - currently opened ")) != -1) already++; else if (str.Find(_T(" - reopened ")) != -1) reopened++; } message.FormatMessage(IDS_OPENED_n_FILES_FOR_EDIT, strList->GetCount() - already - reopened); if (reopened) message.FormatMessage(IDS_s_n_FILES_REOPENED, message, reopened); if (already) message.FormatMessage(IDS_s_n_FILES_ALREADY_OPENED, message, already); break; case P4REOPEN: message.FormatMessage(IDS_REOPENED_n_FILES, strList->GetCount()); break; case P4REVERT: case P4VIRTREVERT: m_OutputError = cmd1.GetOutputErrFlag(); message.FormatMessage(m_OutputError ? IDS_ERROR_REVERTING_n_FILES : IDS_REVERTED_n_FILES, strList->GetCount()); break; case P4REVERTUNCHG: m_OutputError = cmd1.GetOutputErrFlag(); if (m_OutputError) message.FormatMessage(IDS_ERROR_REVERTING_n_FILES, strList->GetCount()); else if (m_NbrChgedFilesReverted) message.FormatMessage(IDS_REVERTED_n_FILES_n_CHG_n_UNCHG, m_NbrChgedFilesReverted + strList->GetCount(), m_NbrChgedFilesReverted, strList->GetCount()); else message.FormatMessage(IDS_REVERTED_n_FILES, strList->GetCount()); break; case P4LOCK: message.FormatMessage(IDS_LOCKED_n_FILES, strList->GetCount()); break; case P4UNLOCK: message.FormatMessage(IDS_UNLOCKED_n_FILES, strList->GetCount()); break; case P4DELETE: for( pos= strList->GetHeadPosition(); pos!= NULL; ) { CString str = strList->GetNext(pos); if (str.Find(_T(" - currently opened ")) != -1) already++; else if (str.Find(_T(" - reopened ")) != -1) reopened++; } message.FormatMessage(IDS_OPENED_n_FILES_FOR_DELETE, strList->GetCount() - already - reopened); if (reopened) message.FormatMessage(IDS_s_n_FILES_REOPENED, message, reopened); if (already) message.FormatMessage(IDS_s_n_FILES_ALREADY_OPENED, message, already); break; case P4ADD: message.FormatMessage(IDS_OPENED_n_FILES_FOR_ADD, strList->GetCount()); break; default: ASSERT(0); } if(!message.IsEmpty()) TheApp()->StatusAdd( message, SV_COMPLETION ); } done=TRUE; }
// do the action required to open a single atomic tag (iAction) void CMUSHclientDoc::MXP_OpenAtomicTag (const CString strTag, int iAction, CStyle * pStyle, CString & strAction, // new action CString & strHint, // new hint CString & strVariable, // new variable CArgumentList & ArgumentList) { CString strArgument; CString strArgumentName; bool bIgnoreUnusedArgs = false; // cut down on some spam by setting this COLORREF colour1, colour2; unsigned short iFlags = pStyle->iFlags; COLORREF iForeColour = pStyle->iForeColour; COLORREF iBackColour = pStyle->iBackColour; // call script if required if (m_dispidOnMXP_OpenTag != DISPID_UNKNOWN || m_bPluginProcessesOpenTag) { // dummy-up an argument list CString strArgument; CArgument * pArgument; POSITION pos; // put the arguments into the array for (pos = ArgumentList.GetHeadPosition (); pos; ) { pArgument = ArgumentList.GetNext (pos); // empty ones we will put there by position if (pArgument->strName.IsEmpty ()) strArgument += CFormat ("'%s'", (LPCTSTR) pArgument->strValue); else strArgument += CFormat ("%s='%s'", (LPCTSTR) pArgument->strName, (LPCTSTR) pArgument->strValue); if (pos) strArgument += " "; } // end of looping through each argument bool bNotWanted = MXP_StartTagScript (strTag, strArgument, ArgumentList); // re-get current style in case the script did a world.note pStyle = m_pCurrentLine->styleList.GetTail (); // put things backt to how they were pStyle->iFlags = iFlags; pStyle->iForeColour = iForeColour; pStyle->iBackColour = iBackColour; if (bNotWanted) return; // they didn't want to go ahead with this tag } // find current foreground and background RGB values GetStyleRGB (pStyle, colour1, colour2); // special processing for Pueblo // a tag like this: <A XCH_CMD="examine #1"> // will convert to a SEND tag if (iAction == MXP_ACTION_HYPERLINK && PUEBLO_ACTIVE) { strArgument = GetArgument (ArgumentList, "xch_cmd", 0, true); if (!strArgument.IsEmpty ()) { m_bPuebloActive = true; // for correct newline processing iAction = MXP_ACTION_SEND; } } // now take the action switch (iAction) { // temporarily make headlines the same as bold case MXP_ACTION_H1: case MXP_ACTION_H2: case MXP_ACTION_H3: case MXP_ACTION_H4: case MXP_ACTION_H5: case MXP_ACTION_H6: case MXP_ACTION_BOLD: pStyle->iFlags |= HILITE; break; case MXP_ACTION_UNDERLINE: pStyle->iFlags |= UNDERLINE; break; case MXP_ACTION_ITALIC: pStyle->iFlags |= BLINK; break; case MXP_ACTION_COLOR: { pStyle->iForeColour = colour1; pStyle->iBackColour = colour2; // convert to RGB colour to start with in case only FORE or BACK supplied pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; // foreground colour strArgument = GetArgument (ArgumentList, "fore", 1, true); // get foreground colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strArgument, pStyle->iForeColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strArgument)); // background colour strArgument = GetArgument (ArgumentList, "back", 2, true); // get background colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strArgument, pStyle->iBackColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strArgument)); } break; // end of COLOR case MXP_ACTION_HIGH: { CColor clr; pStyle->iForeColour = colour1; pStyle->iBackColour = colour2; // convert to RGB colour to start with pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; clr.SetColor (colour1); float lum = clr.GetLuminance (); lum += 0.15f; if (lum > 1.0f) lum = 1.0f; clr.SetLuminance (lum); pStyle->iForeColour = clr; } break; // end of COLOR case MXP_ACTION_SEND: // send to mud hyperlink pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions if (GetKeyword (ArgumentList, "prompt")) pStyle->iFlags |= ACTION_PROMPT; // prompt action else pStyle->iFlags |= ACTION_SEND; // send-to action if (m_bUnderlineHyperlinks) pStyle->iFlags |= UNDERLINE; // underline it if (m_bUseCustomLinkColour) { // find current background RGB value pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour pStyle->iBackColour = colour2; pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; } strArgument = GetArgument (ArgumentList,"href", 1, false); // get link if (strArgument.IsEmpty ()) strArgument = GetArgument (ArgumentList,"xch_cmd", 1, false); // get link strAction = strArgument; // hyperlink strArgument = GetArgument (ArgumentList, "hint", 2, false); // get hints if (strArgument.IsEmpty ()) strArgument = GetArgument (ArgumentList,"xch_hint", 2, false); // get hint strHint = strArgument; // hints break; // end of MXP_ACTION_SEND case MXP_ACTION_HYPERLINK: // hyperlink strArgument = GetArgument (ArgumentList,"href", 1, false); // get link strAction = strArgument; // hyperlink pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions pStyle->iFlags |= ACTION_HYPERLINK | UNDERLINE; // send-to action if (m_bUseCustomLinkColour) { pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour pStyle->iBackColour = colour2; pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; } break; // end of MXP_ACTION_HYPERLINK case MXP_ACTION_FONT: { pStyle->iForeColour = colour1; pStyle->iBackColour = colour2; // convert to RGB colour to start with in case only FORE or BACK supplied pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; // eg. <FONT COLOR=Red,Blink> CStringList list; strArgument = GetArgument (ArgumentList,"color", 1, true); // get color etc. if (strArgument.IsEmpty () && PUEBLO_ACTIVE) strArgument = GetArgument (ArgumentList,"fgcolor", 1, true); // get color StringToList (strArgument, ",", list); // break into components for (POSITION pos = list.GetHeadPosition (); pos; ) { CString strItem = list.GetNext (pos); // get action item if (strItem == "blink") pStyle->iFlags |= BLINK; else if (strItem == "italic") pStyle->iFlags |= BLINK; else if (strItem == "underline") pStyle->iFlags |= UNDERLINE; else if (strItem == "bold") pStyle->iFlags |= HILITE; else if (strItem == "inverse") pStyle->iFlags |= INVERSE; else { // must be colour name, yes? // foreground colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strItem, pStyle->iForeColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strItem)); } // end of colour } // end of handling each item in the list strArgument = GetArgument (ArgumentList,"back", 2, true); // get back color if (strArgument.IsEmpty () && PUEBLO_ACTIVE) strArgument = GetArgument (ArgumentList,"bgcolor", 2, true); // get back color // background colour if (!m_bIgnoreMXPcolourChanges) if (SetColour (strArgument, pStyle->iBackColour)) MXP_error (DBG_ERROR, errMXP_UnknownColour, TFormat ("Unknown colour: \"%s\"" , (LPCTSTR) strArgument)); // get font size argument to avoid warnings about unused arguments strArgument = GetArgument (ArgumentList,"size", 0, true); // get font size } break; // end of FONT case MXP_ACTION_VERSION: { CString strVersion = CFormat ("\x1B[1z<VERSION MXP=\"%s\" CLIENT=MUSHclient " "VERSION=\"%s\" REGISTERED=YES>%s", MXP_VERSION, MUSHCLIENT_VERSION, ENDLINE ); SendPacket (strVersion, strVersion.GetLength ()); // send version info back MXP_error (DBG_INFO, infoMXP_VersionSent, TFormat ("Sent version response: %s" , (LPCTSTR) strVersion.Mid (4))); } break; // end of VERSION case MXP_ACTION_AFK: if (m_bSendMXP_AFK_Response) // if player wants us to { strArgument = GetArgument (ArgumentList,"challenge", 1, false); // get challenge // find time since last player input CTimeSpan ts = CTime::GetCurrentTime() - m_tLastPlayerInput; CString strAFK = CFormat ("\x1B[1z<AFK %ld %s>%s", ts.GetTotalSeconds (), (LPCTSTR) strArgument, ENDLINE ); SendPacket (strAFK, strAFK.GetLength ()); // send AFK info back MXP_error (DBG_INFO, infoMXP_AFKSent, TFormat ("Sent AFK response: %s" , (LPCTSTR) strAFK.Mid (4))); } // end of AFK break; case MXP_ACTION_SUPPORT: { CString strSupports; CAtomicElement * pElement; CStringList list; CString strName; if (ArgumentList.IsEmpty ()) { for (POSITION pos = App.m_ElementMap.GetStartPosition(); pos; ) { App.m_ElementMap.GetNextAssoc (pos, strName, pElement); if ((pElement->iFlags & TAG_NOT_IMP) == 0) { strSupports += "+"; strSupports += pElement->strName; strSupports += " "; // now list the sub-items it supports StringToList (pElement->strArgs, ",", list); // break into components for (POSITION argpos = list.GetHeadPosition (); argpos; ) { CString strItem = list.GetNext (argpos); // get argument item strSupports += "+"; strSupports += pElement->strName; strSupports += "."; strSupports += strItem; strSupports += " "; } // end of doing each sub-item } // end of being implemented } // end of looping through all atomic elements } // end of wanting complete list else { for (POSITION pos = ArgumentList.GetHeadPosition (); pos; ) { CArgument * pArgument = ArgumentList.GetNext (pos); CStringList questionlist; StringToList (pArgument->strValue, ".", questionlist); // break into components // should be one or two words, eg. send.prompt or color if (questionlist.GetCount () > 2) { MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument, TFormat ("Invalid <support> argument: %s" , (LPCTSTR) pArgument->strValue)); return; } CString strTag = questionlist.RemoveHead (); strTag.MakeLower (); // check valid name requested if (!IsValidName (strTag)) { MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument, TFormat ("Invalid <support> argument: %s" , (LPCTSTR) strTag)); return; } // look up main element name if (!App.m_ElementMap.Lookup (strTag, pElement) || (pElement->iFlags & TAG_NOT_IMP) != 0) { // not supported strSupports += "-"; strSupports += strTag; strSupports += " "; continue; // all done for this argument } // only one word - they aren't looking for a suboption if (questionlist.IsEmpty ()) { // supported strSupports += "+"; strSupports += strTag; strSupports += " "; continue; // all done for this argument } CString strSubtag = questionlist.RemoveHead (); strSubtag.MakeLower (); if (strSubtag == "*") { // they want list of options for this tag // now list the sub-items it supports StringToList (pElement->strArgs, ",", list); // break into components for (POSITION argpos = list.GetHeadPosition (); argpos; ) { CString strItem = list.GetNext (argpos); // get argument item strSupports += "+"; strSupports += pElement->strName; strSupports += "."; strSupports += strItem; strSupports += " "; } // end of doing each sub-item } // end of wildcard else { // not wildcard - must be name // check valid name requested if (!IsValidName (strSubtag)) { MXP_error (DBG_ERROR, errMXP_InvalidSupportArgument, TFormat ("Invalid <support> argument: %s" , (LPCTSTR) strSubtag)); return; } // so, see if that word is in our arguments list StringToList (pElement->strArgs, ",", list); // break into components if (list.Find (strSubtag)) { strSupports += "+"; strSupports += pArgument->strValue; strSupports += " "; } else { strSupports += "-"; strSupports += pArgument->strValue; strSupports += " "; } } // end of not looking for wildcard } // end of doing each argument } // find individual items CString strMessage = CFormat ("\x1B[1z<SUPPORTS %s>%s", (LPCTSTR) strSupports, ENDLINE); SendPacket (strMessage, strMessage.GetLength ()); // send version info back MXP_error (DBG_INFO, infoMXP_SupportsSent, TFormat ("Sent supports response: %s" , (LPCTSTR) strMessage.Mid (4))); } bIgnoreUnusedArgs = true; break; // end of MXP_ACTION_SUPPORT case MXP_ACTION_OPTION: { CString strOptions; CStringList list; CString strName; if (ArgumentList.IsEmpty ()) { for (long i = 0; OptionsTable [i].pName; i++) { char * pName = OptionsTable [i].pName; strOptions += CFormat ("%s=%ld ", pName, (LPCTSTR) GetOptionItem (i)); } } // end of wanting complete list else { for (POSITION pos = ArgumentList.GetHeadPosition (); pos; ) { CArgument * pArgument = ArgumentList.GetNext (pos); strOptions += CFormat ("%s=%ld", (LPCTSTR) pArgument->strValue, (LPCTSTR) GetOption (pArgument->strValue)); } // end of doing each argument } // find individual items CString strMessage = CFormat ("\x1B[1z<OPTIONS %s>%s", (LPCTSTR) strOptions, ENDLINE); SendPacket (strMessage, strMessage.GetLength ()); // send version info back MXP_error (DBG_INFO, infoMXP_OptionsSent, TFormat ("Sent options response: %s" , (LPCTSTR) strMessage.Mid (4))); } bIgnoreUnusedArgs = true; break; // end of MXP_ACTION_OPTION case MXP_ACTION_RECOMMEND_OPTION: if (m_bMudCanChangeOptions) { CString strOptions; CStringList list; CString strName; for (POSITION pos = ArgumentList.GetHeadPosition (); pos; ) { CArgument * pArgument = ArgumentList.GetNext (pos); int iItem; int iResult = FindBaseOption (pArgument->strName, OptionsTable, iItem); if (iResult != eOK) MXP_error (DBG_ERROR, errMXP_InvalidOptionArgument, TFormat ("Option named '%s' not known.", (LPCTSTR) pArgument->strName)); else if (!(OptionsTable [iItem].iFlags & OPT_SERVER_CAN_WRITE)) MXP_error (DBG_ERROR, errMXP_CannotChangeOption, TFormat ("Option named '%s' cannot be changed.", (LPCTSTR) pArgument->strName)); else { iResult = SetOptionItem (iItem, atol (pArgument->strValue), true, false); if (iResult == eOK) MXP_error (DBG_INFO, infoMXP_OptionChanged, TFormat ("Option named '%s' changed to '%s'.", (LPCTSTR) pArgument->strName, (LPCTSTR) pArgument->strValue)); else MXP_error (DBG_ERROR, errMXP_OptionOutOfRange, TFormat ("Option named '%s' could not be changed to '%s' (out of range).", (LPCTSTR) pArgument->strName, (LPCTSTR) pArgument->strValue)); } } // end of doing each argument } bIgnoreUnusedArgs = true; break; // end of MXP_ACTION_RECOMMEND_OPTION case MXP_ACTION_USER: if (!m_name.IsEmpty () && m_connect_now == eConnectMXP) { CString strPacket = m_name + ENDLINE; SendPacket (strPacket, strPacket.GetLength ()); // send name to MUD MXP_error (DBG_INFO, infoMXP_CharacterNameSent, TFormat ("Sent character name: %s" , (LPCTSTR) m_name)); } else if (m_connect_now != eConnectMXP) MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined, Translate ("Character name requested but auto-connect not set to MXP.")); else MXP_error (DBG_WARNING, wrnMXP_CharacterNameRequestedButNotDefined, Translate ("Character name requested but none defined.")); break; // end of USER case MXP_ACTION_PASSWORD: if (m_nTotalLinesSent > 10) // security check MXP_error (DBG_WARNING, wrnMXP_PasswordNotSent, "Too many lines sent to MUD - password not sent."); else if (!m_password.IsEmpty () && m_connect_now == eConnectMXP) { CString strPacket = m_password + ENDLINE; SendPacket (strPacket, strPacket.GetLength ()); // send password to MUD MXP_error (DBG_INFO, infoMXP_PasswordSent, "Sent password to world."); } else if (m_connect_now != eConnectMXP) MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined, "Password requested but auto-connect not set to MXP."); else MXP_error (DBG_WARNING, wrnMXP_PasswordRequestedButNotDefined, "Password requested but none defined."); break; // end of PASSWORD // new para case MXP_ACTION_P: // experimental m_cLastChar = 0; m_bInParagraph = true; break; // end of MXP_ACTION_P // new line case MXP_ACTION_BR: bIgnoreUnusedArgs = true; // don't worry about args for now :) StartNewLine (true, 0); SetNewLineColour (0); break; // end of MXP_ACTION_BR // reset case MXP_ACTION_RESET: MXP_Off (); break; // end of MXP_ACTION_RESET // MXP options (MXP OFF, MXP DEFAULT_OPEN, MXP DEFAULT_SECURE etc. case MXP_ACTION_MXP: if (GetKeyword (ArgumentList, "off")) MXP_Off (true); /* if (GetKeyword (ArgumentList, "default_open")) { MXP_error (DBG_INFO, "MXP default mode now OPEN."); m_iMXP_defaultMode = eMXP_open; } // end of DEFAULT_OPEN if (GetKeyword (ArgumentList, "default_secure")) { MXP_error (DBG_INFO, "MXP default mode now SECURE."); m_iMXP_defaultMode = eMXP_secure; } // end of DEFAULT_SECURE if (GetKeyword (ArgumentList, "default_locked")) { MXP_error (DBG_INFO, "MXP default mode now LOCKED."); m_iMXP_defaultMode = eMXP_locked; } // end of DEFAULT_LOCKED if (GetKeyword (ArgumentList, "use_newlines")) { MXP_error (DBG_INFO, "Now interpreting newlines as normal."); m_bInParagraph = false; } // end of USE_NEWLINES if (GetKeyword (ArgumentList, "ignore_newlines")) { MXP_error (DBG_INFO, "Now ignoring newlines."); m_bInParagraph = true; } // end of IGNORE_NEWLINES */ break; // end of MXP_ACTION_MXP case MXP_ACTION_SCRIPT: MXP_error (DBG_INFO, infoMXP_ScriptCollectionStarted, "Script collection mode entered (discarding script)."); m_bMXP_script = true; break; // end of MXP_ACTION_SCRIPT case MXP_ACTION_HR: { // wrap up previous line if necessary if (m_pCurrentLine->len > 0) StartNewLine (true, 0); /* CString strLine; char * p = strLine.GetBuffer (m_nWrapColumn); memset (p, 175, m_nWrapColumn); strLine.ReleaseBuffer (m_nWrapColumn); AddToLine (strLine, 0); */ // mark line as HR line m_pCurrentLine->flags = HORIZ_RULE; StartNewLine (true, 0); // now finish this line } break; // end of MXP_ACTION_HR case MXP_ACTION_PRE: m_bPreMode = true; break; // end of MXP_ACTION_PRE case MXP_ACTION_UL: m_iListMode = eUnorderedList; m_iListCount = 0; break; // end of MXP_ACTION_UL case MXP_ACTION_OL: m_iListMode = eOrderedList; m_iListCount = 0; break; // end of MXP_ACTION_OL case MXP_ACTION_LI: { // wrap up previous line if necessary if (m_pCurrentLine->len > 0) StartNewLine (true, 0); CString strListItem = " * "; if (m_iListMode == eOrderedList) strListItem.Format (" %i. ", ++m_iListCount); AddToLine (strListItem, 0); } break; // end of MXP_ACTION_LI // pueblo tags we put here so we don't get warnings case MXP_ACTION_BODY : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_HEAD : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_HTML : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_TITLE: bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_SAMP : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_CENTER : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_XCH_PANE : bIgnoreUnusedArgs = true; break; // just ignore it case MXP_ACTION_IMG : case MXP_ACTION_IMAGE: { GetKeyword (ArgumentList, "ismap"); // make sure we realise it is a keyword // detect newline treatment strArgument = GetArgument (ArgumentList,"xch_mode", 0, false); // get mode if (!strArgument.IsEmpty ()) { m_bPuebloActive = true; // for correct newline processing if (strArgument.CompareNoCase ("purehtml") == 0) m_bSuppressNewline = true; else if (strArgument.CompareNoCase ("html") == 0) m_bSuppressNewline = false; } // end of some sort of Pueblo strArgument = GetArgument (ArgumentList,"url", 0, false); // get link if (strArgument.IsEmpty () && PUEBLO_ACTIVE) strArgument = GetArgument (ArgumentList,"src", 0, false); // get link CString strFilename = GetArgument (ArgumentList,"fname", 0, false); // and file name if (!strArgument.IsEmpty ()) { CString strOldAction = strAction; int iFlags = pStyle->iFlags; COLORREF iForeColour = pStyle->iForeColour; COLORREF iBackColour = pStyle->iBackColour; // ensure on new line if (m_pCurrentLine->len > 0) StartNewLine (true, 0); // starting a new line may have deleted pStyle pStyle = m_pCurrentLine->styleList.GetTail (); if (m_bUseCustomLinkColour) { pStyle->iForeColour = m_iHyperlinkColour; // use hyperlink colour pStyle->iBackColour = colour2; pStyle->iFlags &= ~COLOURTYPE; // clear bits, eg. custom pStyle->iFlags |= COLOUR_RGB; } strArgument += strFilename; // append filename to URL strAction = strArgument; // hyperlink pStyle->iFlags &= ~ACTIONTYPE; // cancel old actions pStyle->iFlags |= ACTION_HYPERLINK; // send-to action if (m_bUnderlineHyperlinks) pStyle->iFlags |= UNDERLINE; // send-to action AddToLine ("[", 0); AddToLine (strArgument, 0); AddToLine ("]", 0); // have to add the action now, before we start a new line pStyle->pAction = GetAction (strAction, strHint, strVariable); strAction.Empty (); StartNewLine (true, 0); // new line after image tag // go back to old style (ie. lose the underlining) AddStyle (iFlags, iForeColour, iBackColour, 0, strOldAction); } } break; // end of MXP_ACTION_IMG case MXP_ACTION_XCH_PAGE: bIgnoreUnusedArgs = true; m_bPuebloActive = true; // for correct newline processing MXP_Off (); // same as <reset>? break; // end of MXP_ACTION_XCH_PAGE case MXP_ACTION_VAR: // set variable strVariable = GetArgument (ArgumentList,"", 1, false); // get name // case insensitive strVariable.MakeLower (); if (!IsValidName (strVariable)) { MXP_error (DBG_ERROR, errMXP_InvalidDefinition, TFormat ("Invalid MXP entity name: <!%s>", (LPCTSTR) strVariable)); strVariable.Empty (); return; } { // protect local variable CString strEntityContents; if (App.m_EntityMap.Lookup (strVariable, strEntityContents)) { MXP_error (DBG_ERROR, errMXP_CannotRedefineEntity, TFormat ("Cannot redefine entity: &%s;", (LPCTSTR) strVariable)); strVariable.Empty (); return; } } break; // end of MXP_ACTION_VAR default: { // warn them it is not implemented MXP_error (DBG_WARNING, wrnMXP_TagNotImplemented, TFormat ("MXP tag <%s> is not implemented" , (LPCTSTR) strTag)); } // end of default } // end of switch on iAction if (!bIgnoreUnusedArgs) CheckArgumentsUsed (strTag, ArgumentList); } // end of CMUSHclientDoc::MXP_OpenAtomicTag
bool Get_XML_date (CXMLelement & node, const char * sName, CTime & tValue, const bool bUseDefault) { CString strValue; if (!Get_XML_string (node, sName, strValue, true, true)) if (bUseDefault) return false; else { tValue = 0; // default is no time return false; } if (strValue.IsEmpty ()) ThrowErrorException ("No time supplied for attribute named '%s'" , sName); // break up date into date portion / time portion CStringList strDateTime; StringToList (strValue, " ", strDateTime); if (strDateTime.GetCount () < 1 || strDateTime.GetCount () > 2) ThrowErrorException ("Date/time must consist of YYYY-MM-DD [ HH:MM:SS ]"); CString strDate = strDateTime.RemoveHead (); CString strTime; if (!strDateTime.IsEmpty ()) strTime = strDateTime.RemoveHead (); CString strYear, strMonth, strDay; CStringList strDateList; StringToList (strDate, "-", strDateList); if (strDateList.GetCount () != 3) ThrowErrorException ("Date must consist of YYYY-MM-DD"); strYear = strDateList.RemoveHead (); strMonth = strDateList.RemoveHead (); strDay = strDateList.RemoveHead (); if (!IsNumber (strYear)) ThrowErrorException ("Year is not numeric"); if (!IsNumber (strMonth)) ThrowErrorException ("Month is not numeric"); if (!IsNumber (strDay)) ThrowErrorException ("Day is not numeric"); int iYear, iMonth, iDay; iYear = atoi (strYear); iMonth = atoi (strMonth); iDay = atoi (strDay); if (iYear < 1900 || iYear > 2100) ThrowErrorException ("Year must be in range 1900 to 2100"); if (iMonth < 1 || iMonth > 12) ThrowErrorException ("Month must be in range 1 to 12"); if (iDay < 1 || iDay > 31) ThrowErrorException ("Month must be in range 1 to 31"); int iHour = 0, iMinute = 0, iSecond = 0; if (!strTime.IsEmpty ()) { CString strHour, strMinute, strSecond; CStringList strTimeList; StringToList (strTime, ":", strTimeList); if (strTimeList.GetCount () > 3) ThrowErrorException ("Time must consist of HH, HH:MM, or HH:MM:SS"); strHour = strTimeList.RemoveHead (); strMinute = "0"; strSecond = "0"; if (!strTimeList.IsEmpty ()) { strMinute = strTimeList.RemoveHead (); if (!strTimeList.IsEmpty ()) strSecond = strTimeList.RemoveHead (); } if (!IsNumber (strHour)) ThrowErrorException ("Hour is not numeric"); if (!IsNumber (strMinute)) ThrowErrorException ("Minute is not numeric"); if (!IsNumber (strSecond)) ThrowErrorException ("Second is not numeric"); iHour = atoi (strHour); iMinute = atoi (strMinute); iSecond = atoi (strSecond); if (iHour < 0 || iHour > 23) ThrowErrorException ("Hour must be in range 0 to 23"); if (iMinute < 0 || iMinute > 59) ThrowErrorException ("Minute must be in range 0 to 59"); if (iSecond < 0 || iSecond > 59) ThrowErrorException ("Minute must be in range 0 to 59"); } // end of having a time tValue = CTime (iYear, iMonth, iDay, iHour, iMinute, iSecond, 0); return true; } // end of Get_XML_date
BOOL CFileSharingPage::OnInitDialog() { CFilePropertiesPage::OnInitDialog(); m_wndTags.AddString( _T("") ); if ( UploadQueues.m_pSection.Lock() ) { CStringList pAdded; for ( POSITION pos = UploadQueues.GetIterator() ; pos ; ) { CUploadQueue* pQueue = UploadQueues.GetNext( pos ); if ( pQueue->m_sShareTag.GetLength() ) { if ( pAdded.Find( pQueue->m_sShareTag ) == NULL ) { pAdded.AddTail( pQueue->m_sShareTag ); m_wndTags.AddString( pQueue->m_sShareTag ); } } } UploadQueues.m_pSection.Unlock(); if ( pAdded.IsEmpty() ) { m_wndTags.AddString( _T("Release") ); m_wndTags.AddString( _T("Popular") ); } } { CQuickLock oLock( Library.m_pSection ); if ( CLibraryFile* pFile = GetFile() ) { m_bOverride = pFile->m_bShared != TS_UNKNOWN; m_bShare = pFile->IsShared(); m_sTags = pFile->m_sShareTags; } else if ( CLibraryList* pList = GetList() ) { for ( POSITION pos = pList->GetIterator() ; pos ; ) { if ( CLibraryFile* pFile = pList->GetNextFile( pos ) ) { m_bOverride = pFile->m_bShared != TS_UNKNOWN; m_bShare = pFile->IsShared(); m_sTags = pFile->m_sShareTags; } } } } UpdateData( FALSE ); m_wndShare.EnableWindow( m_bOverride ); return TRUE; }
DLL_DECL void DesertFinit_Apply(const char *applyConstraints) { CManager::theInstance->AnalyseConstraints(); CManager::theInstance->GenerateNextHierarchy(); if (CManager::theInstance->HasConstraints()) { if (applyConstraints) { CStringList cNames; bool applyAll = strncmp(applyConstraints, "applyAll", 8) == 0; if (!applyAll) { char *cons = strdup(applyConstraints); char *cName = strtok( cons, ":" ); while(cName) { cNames.AddTail( cName ); cName = strtok( NULL, ":" ); } if(cNames.IsEmpty()) return; } CDynConstraintSet *set = new CDynConstraintSet(0); set->RemoveAll(); CDynConstraintSetList & setlist = CManager::theInstance->GetConstraintSets(); POSITION sl_pos = setlist.GetHeadPosition(); while (sl_pos) { CDynConstraintSet * setlist_i = setlist.GetNext(sl_pos); CDynConstraintList& list = setlist_i->GetConstraints(); POSITION pos1 = list.GetHeadPosition(); while(pos1) { CDynConstraint *cur = list.GetNext(pos1); const CString& nm = cur->GetName(); if (applyAll || cNames.Find(nm)) { Info("DesertFinit", "Applying Constraint: %s", nm); cur->SetApplied(); set->InsertConstraint(cur); } } } // prune & generate next hierarchy double dspSize; long repSize; long clockTime; try{ CManager::theInstance->GetSizeInfo(dspSize, repSize, clockTime, set); }catch(CDesertException *e) { CManager::theInstance->GenerateNextHierarchy(); set->RemoveAll(); delete set; throw e; } // Info("DesertFinit", "Design Space Size Info: %f %d %d", dspSize, repSize, clockTime); CManager::theInstance->GenerateNextHierarchy(); set->RemoveAll(); delete set; } } }
//************************************************************************************************* BOOL CBCGPMousePage::OnInitDialog() { ASSERT (g_pMouseManager != NULL); CPropertyPage::OnInitDialog(); CStringList listOfViewNames; g_pMouseManager->GetViewNames (listOfViewNames); //------------------- // Create image list: //------------------- if (!m_ViewsImages.Create ( globalData.m_sizeSmallIcon.cx, globalData.m_sizeSmallIcon.cy, ILC_COLOR | ILC_MASK, (int) listOfViewNames.GetCount (), 1)) { ASSERT (FALSE); } m_wndListOfViews.SetImageList (&m_ViewsImages, LVSIL_SMALL); POSITION pos; //----------------- // Fill views list: //----------------- CRect rect; m_wndListOfViews.GetClientRect (&rect); m_wndListOfViews.InsertColumn (0, _T(""), LVCFMT_LEFT, rect.Width () - 1); ASSERT (!listOfViewNames.IsEmpty ()); int iMaxWidth = 0; for (pos = listOfViewNames.GetHeadPosition (); pos != NULL;) { CString strViewName = listOfViewNames.GetNext (pos); int iImageIndex = -1; //--------------- // Add view icon: //--------------- UINT uiViewIconId = g_pMouseManager->GetViewIconId ( g_pMouseManager->GetViewIdByName (strViewName)); HICON hViewIcon; if (uiViewIconId != 0 && (hViewIcon = AfxGetApp ()->LoadIcon (uiViewIconId)) != NULL) { iImageIndex = m_ViewsImages.Add (hViewIcon); ::DestroyIcon (hViewIcon); } int iIndex = m_wndListOfViews.GetItemCount (); for (int i = 0; i < m_wndListOfViews.GetItemCount (); i ++) { CString strText = m_wndListOfViews.GetItemText (i, 0); if (strText > strViewName) { iIndex = i; break; } } m_wndListOfViews.InsertItem (iIndex, strViewName, iImageIndex); m_wndListOfViews.SetItemData (iIndex, (DWORD) g_pMouseManager->GetViewIdByName (strViewName)); int iStrWidth = m_wndListOfViews.GetStringWidth (strViewName); iMaxWidth = max (iStrWidth, iMaxWidth); } //---------------------------------- // Add icon width pluse some pixels: //---------------------------------- IMAGEINFO info; m_ViewsImages.GetImageInfo (0, &info); CRect rectImage = info.rcImage; iMaxWidth += rectImage.Width () + 10; m_wndListOfViews.SetColumnWidth (0, iMaxWidth); //-------------------- // Fill commands list: //-------------------- CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ()); ASSERT (pWndParent != NULL); pWndParent->FillAllCommandsList (m_wndListOfCommands); //----------------------- // Select the first view: //----------------------- m_wndListOfViews.SetItemState (0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); m_wndListOfViews.EnsureVisible (0, FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }