BOOL COptionTreeSpinnerButton::IsStringNumeric(CString strString)
{
    // See if string is numeric or not
    if (strString.FindOneOf("1234567890") == -1 || strString.FindOneOf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~[]{}-_=+\\|'/?>,<") != -1)
    {
        return FALSE;
    }

    return TRUE;
}
Example #2
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;
}
// Get a attribute value from an attribute name
bool CNetList::get_attr( int file_name_index, int sheet, CNetListSymbol &symbol, CString attr, CString &r )
{
	CDrawMethod* pMethod = symbol.m_pMethod;
	if (attr.CompareNoCase( _T("refnum") ) == 0)
	{
		// Use the reference number (minus the reference character)
		CString s = pMethod->GetRefSheet(m_prefix_references,m_prefix_import,file_name_index,sheet+1);
		int b = s.FindOneOf(_T("0123456789"));
		if (b != 1)
		{
			r = s;
			return true;
		}
		else
		{
			r = s.Mid(b);
			return true;
		}
	}
	else
	{
		for (int j = 0; j < pMethod->GetFieldCount(); j++)
		{
			if (pMethod->GetFieldName(j).CompareNoCase(attr) == 0)
			{
				r = pMethod->GetField(j);
				return true;
			}
		}
	}

	return false;
}
Example #4
0
void CMCAModParam::OnChangeModparamsSaveloc() 
{
	CString Text;
	GetDlgItemText(IDC_MODPARAMS_SAVELOC,Text);
	if (!Text.IsEmpty())
	{
		int posStart, posEnd;
		((CEdit*)GetDlgItem(IDC_MODPARAMS_SAVELOC))->GetSel(posStart,posEnd);
		if (Text.FindOneOf(INVALIDCHARSSUB) != -1)
		{
			((CEdit*)GetDlgItem(IDC_MODPARAMS_SAVELOC))->Undo();
			posStart--;
			posEnd--;
		}
		((CEdit*)GetDlgItem(IDC_MODPARAMS_SAVELOC))->SetModify(FALSE);
		((CEdit*)GetDlgItem(IDC_MODPARAMS_SAVELOC))->EmptyUndoBuffer();
		((CEdit*)GetDlgItem(IDC_MODPARAMS_SAVELOC))->SetSel(posStart,posEnd);
	}

	if (m_pPS) m_pPS->SetToClose(0);
	if (!m_bCollectingParametersForNewISO)
	{
		m_bChange = true;
		m_pApplyButton->EnableWindow(TRUE);
	}
}
Example #5
0
bool CCommonAppUtils::AddClipboardUrlToWindow( HWND hWnd )
{
    if (IsClipboardFormatAvailable(CF_UNICODETEXT))
    {
        CClipboardHelper clipboard;
        clipboard.Open(hWnd);
        HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
        if (hglb)
        {
            LPCWSTR lpstr = (LPCWSTR)GlobalLock(hglb);
            CString sUrl = lpstr;
            GlobalUnlock(hglb);

            sUrl.Trim();
            CString sLowerCaseUrl = sUrl;
            sLowerCaseUrl.MakeLower();
            // check for illegal chars: they might be allowed in a regular url, e.g. '?',
            // but not in an url to an svn repository!
            if (sLowerCaseUrl.FindOneOf(L"\n\r?;=+$,<>#") >= 0)
                return false;

            if ((sLowerCaseUrl.Find(L"http://")==0) ||
                (sLowerCaseUrl.Find(L"https://")==0) ||
                (sLowerCaseUrl.Find(L"svn://")==0) ||
                (sLowerCaseUrl.Find(L"svn+ssh://")==0) ||
                (sLowerCaseUrl.Find(L"file://")==0))
            {
                ::SetWindowText(hWnd, (LPCTSTR)sUrl);
                return true;
            }
        }
    }
    return false;
}
Example #6
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 #7
0
void COXUNC::Trim(CString& sText)
	// --- In  :
	// --- Out : 
	// --- Returns :
	// --- Effect : Removes invalid characters and leading and trailing spaces
	{
	// ... Remove invalid chars	<>|"
	int nInvalidCharPos = sText.FindOneOf(m_pszInvalidChars);
	while (0 <= nInvalidCharPos)
		{
		sText = sText.Left(nInvalidCharPos) + sText.Mid(nInvalidCharPos + 1);
		nInvalidCharPos = sText.FindOneOf(m_pszInvalidChars);
		}

	// ... Remove leading and trailng spaces
	sText.TrimLeft();
	sText.TrimRight();
	}
BOOL CHMProject::HitTestSectionID(LPCSTR str)
{
    CString s;
    ASSERT(str!=NULL);
    s=str;
    s.TrimLeft();
    if (s.IsEmpty()) return FALSE;
    if ((s[0]=='[')&&(s.FindOneOf("]")>0))
        return TRUE;
    return FALSE;
}
Example #9
0
/** 
 * @brief Convert user-given extension list to valid regular expression.
 * @param [in] Extension list/mask to convert to regular expression.
 * @return Regular expression that matches extension list.
 */
CString FileFilterHelper::ParseExtensions(CString extensions) const
{
	CString strParsed;
	CString strPattern;
	BOOL bFilterAdded = FALSE;
	static const TCHAR pszSeps[] = _T(" ;|,:");

	extensions += _T(";"); // Add one separator char to end
	int pos = extensions.FindOneOf(pszSeps);
	
	while (pos >= 0)
	{
		CString token = extensions.Left(pos); // Get first extension
		extensions.Delete(0, pos + 1); // Remove extension + separator
		
		// Only "*." or "*.something" allowed, other ignored
		if (token.GetLength() >= 2 && token[0] == '*' && token[1] == '.')
		{
			bFilterAdded = TRUE;
			strPattern += _T(".*\\.");
			strPattern += token.Mid(2);
			strPattern += _T("$");
		}
		else
			bFilterAdded = FALSE;

		pos = extensions.FindOneOf(pszSeps); 
		if (bFilterAdded && pos >= 0)
			strPattern += _T("|");
	}

	if (strPattern.IsEmpty())
		strParsed = _T(".*"); // Match everything
	else
	{
		strParsed = _T("^");
		strPattern.MakeLower();
		strParsed = strPattern; //+ _T("$");
	}
	return strParsed;
}
Example #10
0
static CString GetNextToken(CString& strSrc, const CString strDelim)
{
	CString token;
	int idx = strSrc.FindOneOf(strDelim);
	if(idx != -1)
	{
		token  = strSrc.Left(idx);
		strSrc = strSrc.Right(strSrc.GetLength() - (idx + 1) );
	}
	else
	{
		token = strSrc;
		strSrc.Empty();
	}
	return token;
}
Example #11
0
void FixURL(CString *pstrURL)
{
	CString strTemp;
	BOOL bPre = FALSE;

	ASSERT(pstrURL != NULL);

	// Load string and make lower
	strTemp = *pstrURL;
	strTemp = strTemp.MakeLower();

	// If the string begins with one of the following prefixes it is an URL
	if(strTemp.Left(5) == _T("http:")) bPre = TRUE;
	else if(strTemp.Left(6) == _T("https:")) bPre = TRUE;
	else if(strTemp.Left(4) == _T("cmd:")) bPre = TRUE;
	else if(strTemp.Left(4) == _T("ftp:")) bPre = TRUE;
	else if(strTemp.Left(5) == _T("file:")) bPre = TRUE;
	else if(strTemp.Left(7) == _T("gopher:")) bPre = TRUE;
	else if(strTemp.Left(7) == _T("mailto:")) bPre = TRUE;
	else if(strTemp.Left(5) == _T("news:")) bPre = TRUE;
	else if(strTemp.Left(5) == _T("nntp:")) bPre = TRUE;
	else if(strTemp.Left(9) == _T("prospero:")) bPre = TRUE;
	else if(strTemp.Left(7) == _T("telnet:")) bPre = TRUE;
	else if(strTemp.Left(5) == _T("wais:")) bPre = TRUE;
	else if(strTemp.Left(4) == _T("irc:")) bPre = TRUE;
	else
	{
		int nIndex = strTemp.Find(_T("://"));
		int nNoIndex = strTemp.FindOneOf(_T("/@;: \t\\"));

		if((nIndex != -1) && ((nNoIndex == -1) || (nNoIndex >= nIndex))) bPre = TRUE;
	}

	if(bPre == FALSE) // The string isn't a valid URL, so assume it's a HTTP
	{
		strTemp = _T("http:");
		if(pstrURL->Left(1) != _T("/")) strTemp += _T("//");
		strTemp += *pstrURL;

		*pstrURL = strTemp;
	}
}
Example #12
0
CString GetNextToken(CString& strSrc, const CString strDelim,bool bTrim, bool bFindOneOf)
{
    CString strToken;
    int idx = bFindOneOf? strSrc.FindOneOf(strDelim) : strSrc.Find(strDelim);
    if(idx != -1)
    {
        strToken  = strSrc.Left(idx);
        strSrc = strSrc.Right(strSrc.GetLength() - (idx + 1));
    }
    else
    {
        strToken = strSrc;
        strSrc.Empty();
    }
    if(bTrim)
    {
        strToken.TrimLeft();
        strToken.TrimRight();
    }
    return strToken;
}
Example #13
0
void CMainFrame::ReloadTree(CString strLabel, long nCodice)
{
  if(strLabel == TREELABEL_OPERATORI
	   || strLabel == TREELABEL_PAGAMENTI
		 || strLabel == TREELABEL_MATERIALI
		 || strLabel == TREELABEL_MARCHI)
    m_wndTreeStrumenti.Populate(strLabel, nCodice);
	if(strLabel == TREELABEL_SCADUTI
	   || strLabel == TREELABEL_INVIGORE
		 || strLabel == TREELABEL_INELABORAZIONE)
		m_wndTreeListini.Populate(strLabel, nCodice);
  if(strLabel == TREELABEL_AZIENDERECENTI
     || strLabel == TREELABEL_AZIENDEIMPORTANTI
     || strLabel == TREELABEL_AZIENDEALFABETICA)
     m_wndTreeAziende.Populate(strLabel, nCodice);
  if(strLabel == TREELABEL_VERBALIULTIMOMESE
     || strLabel == TREELABEL_VERBALIPRECEDENTI
     || strLabel == TREELABEL_VERBALIFATTPROFORMA)
     m_wndTreeVerbali.Populate(strLabel, nCodice);
  if(strLabel == TREELABEL_FATTUREDAEMETTERE || strLabel.FindOneOf("0123456789") >= 0)
    m_wndTreeFatture.Populate(strLabel, nCodice);
}
Example #14
0
//NBNB: KGA: I am overiding this undocumented function; 
//      3 May 1996 from doccore.cpp; check with future versions of MFC
//      Last checked Feb 1997 with MSVC++/MFC version 4.2
BOOL DocRoot::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
#ifndef _MAC
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
#else
			int iBad = newName.FindOneOf(_T(":"));
#endif
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

#ifndef _MAC
			// append the default suffix if there is one
			CString strExt;
			if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
			  !strExt.IsEmpty())
			{
				ASSERT(strExt[0] == '.');
				newName += strExt;
			}
#endif
		}

		if (!ScdApp()->DoPromptFileName(newName,
		  bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
		  OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate, false))
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
    /* KGA, DO NOT DELETE !!!
		if (0 lpszPathName == NULL)
		{
			// be sure to delete the file
			TRY
			{
				CFile::Remove(newName);
			}
			CATCH_ALL(e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}*/
		return FALSE;
	}

	// reset the title and change the document name
	if (bReplace)
		SetPathName(newName);

	return TRUE;        // success
}
BOOL COptionsSslPage::IsDataValid()
{
	USES_CONVERSION;

	UpdateData();

	std::set<int> portSet;
	bool valid = true;

	CString ports = m_sslports;
	ports.TrimLeft(_T(" ,"));

	int pos = ports.FindOneOf(_T(" ,"));
	while (pos != -1 && valid) {
		int port = _ttoi(ports.Left(pos));
		if (port < 1 || port > 65535) {
			valid = false;
			break;
		}
		else
			portSet.insert(port);
		ports = ports.Mid(pos + 1);
		ports.TrimLeft(_T(" ,"));
		pos = ports.FindOneOf(_T(" ,"));
	}
	if (valid && ports != _T("")) {
		int port = _ttoi(ports);
		if (port < 1 || port > 65535)
			valid = false;
		else
			portSet.insert(port);
	}

	if (!valid && m_enabled) {
		m_pOptionsDlg->ShowPage(this);
		m_cSslports.SetFocus();
		AfxMessageBox(_T("Invalid port found, please only enter ports in the range from 1 to 65535."));
		return FALSE;
	}

	m_sslports = _T("");
	for (auto port : portSet) {
		CString tmp;
		tmp.Format(_T("%d "), port);
		m_sslports += tmp;
	}
	m_sslports.TrimRight(' ');
	UpdateData(false);

	if (m_enabled) {

		if (m_key.IsEmpty()) {
			m_pOptionsDlg->ShowPage(this);
			m_cKey.SetFocus();
			AfxMessageBox(_T("You need to enter a key file."));
			return FALSE;
		}

		if (m_certificate.IsEmpty()) {
			m_pOptionsDlg->ShowPage(this);
			m_cCertificate.SetFocus();
			AfxMessageBox(_T("You need to enter a certificate file."));
			return FALSE;
		}

		if (m_pOptionsDlg->IsLocalConnection()) {
			CAsyncSslSocketLayer layer(0);
			CString error;
			int res = layer.SetCertKeyFile(m_certificate, m_key, m_pass, &error);
			if (res == SSL_FAILURE_LOADDLLS) {
				m_pOptionsDlg->ShowPage(this);
				AfxMessageBox(_T("Failed to load TLS libraries"));
				return FALSE;
			}
			else if (res == SSL_FAILURE_INITSSL) {
				m_pOptionsDlg->ShowPage(this);
				AfxMessageBox(_T("Failed to initialize TLS libraries"));
				return FALSE;
			}
			else if (res == SSL_FAILURE_VERIFYCERT) {
				m_pOptionsDlg->ShowPage(this);
				if (error != _T(""))
					AfxMessageBox(error);
				else
					AfxMessageBox(_T("Failed to set certificate and private key"));
				return FALSE;
			}
			else if (res) {
				m_pOptionsDlg->ShowPage(this);
				return FALSE;
			}
		}
	}

	return true;
}
void CGroupSelectDlg::OnOK() 
{
	// TODO: Add extra validation here
	int oldCount=0;
	BOOL r = TRUE;
	CString filename;
	m_name.GetWindowText(filename);
	int pos = filename.FindOneOf(STR_ERR_PATH_CHAR);
	if (pos>=0)
	{
		MSGBOX(IDS_GROUPNAME_ERROR);
		return;
	}
	//
	char state[10]="state",name[9]="name",url[8]="url",download[13]="download"; // x+5
	char num[15];
	filename = theApp.m_strGroupPath + filename+".cgp";
	//get old count 
	char tmp[INTERNET_MAX_PATH_LENGTH];
	while(r)
	{
		itoa(oldCount, name+4, 10);
		itoa(oldCount, url+3, 10);
		r = ::GetPrivateProfileString("Group", name, NULL, tmp, INTERNET_MAX_PATH_LENGTH, filename);
		if (!r)
			break;
		oldCount++;
	}
	//
	if (oldCount<1)
	{
		r = WritePrivateProfileSection("Group", NULL, filename);
		if (!r)
		{
			if (!_FileIsExist(theApp.m_strGroupPath))
				MSGBOX(IDS_GROUP_NOT_EXIST);
			else
				MSGBOX(IDS_GROUPNAME_ERROR);
			return;
		}
	}
	//write new item
	int i,count = m_list.GetItemCount();
	int index=0;
	for (i=0;i<count;i++)
	{
		if (m_list.GetCheck(i))
		{
			itoa(index+oldCount, state+5, 10);
			itoa(index+oldCount, name+4, 10);
			itoa(index+oldCount, url+3, 10);
			itoa(index+oldCount, download+8, 10);
			//::WritePrivateProfileString("Group", state, "1", filename);
			::WritePrivateProfileString("Group", name, m_list.GetItemText(i,0), filename);
			::WritePrivateProfileString("Group", url, m_list.GetItemText(i,1), filename);
			if (m_list.GetItemData(i) != DEFAULT_PROPERTY)
			{
				ultoa( m_list.GetItemData(i), num, 10);
				::WritePrivateProfileString("Group", download, num, filename);
			}
			//
			index++;
		}
	}

	CDialog::OnOK();
}
Example #17
0
BOOL CMUSHclientDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

  SetDefaults (false);        // set up numeric/boolean defaults
  SetAlphaDefaults (false);   // set up alpha defaults

   // if defaults are wanted, overwrite what we loaded with them :)
             
  if (m_bLoaded)
    OnFileReloaddefaults ();
  else
    {

    if (!App.m_strDefaultColoursFile.IsEmpty ())
      {
      m_bUseDefaultColours = true;
      Load_Set (COLOUR, App.m_strDefaultColoursFile, &Frame);
      }

    if (!App.m_strDefaultTriggersFile.IsEmpty ())
      {
      m_bUseDefaultTriggers = true;
      Load_Set (TRIGGER, App.m_strDefaultTriggersFile, &Frame);
      }

    if (!App.m_strDefaultAliasesFile.IsEmpty ())
      {
      m_bUseDefaultAliases = true;
      Load_Set (ALIAS, App.m_strDefaultAliasesFile, &Frame);
      }

    if (!App.m_strDefaultTimersFile.IsEmpty ())
      {
      m_bUseDefaultTimers = true;
      Load_Set (TIMER, App.m_strDefaultTimersFile, &Frame);
      }

    if (!App.m_strDefaultMacrosFile.IsEmpty ())
      {
      m_bUseDefaultMacros = true;
      Load_Set (MACRO, App.m_strDefaultMacrosFile, &Frame);
      }

    if (!App.m_strDefaultInputFont.IsEmpty ())
      {
      m_bUseDefaultInputFont = true;
      m_input_font_height = App.m_iDefaultInputFontHeight; 
      m_input_font_name = App.m_strDefaultInputFont;   
      m_input_font_italic = App.m_iDefaultInputFontItalic; 
      m_input_font_weight = App.m_iDefaultInputFontWeight;
      m_input_font_charset = App.m_iDefaultInputFontCharset;
      }   // end of input font override

    if (!App.m_strDefaultOutputFont.IsEmpty ())
      {
      m_bUseDefaultOutputFont = true;
      m_font_height = App.m_iDefaultOutputFontHeight; 
      m_font_name = App.m_strDefaultOutputFont;   
      m_font_weight = FW_NORMAL;
      m_font_charset = App.m_iDefaultOutputFontCharset;
    }   // end of output font override
    } // end of not loading an existing world

  m_bLoaded = false;    // not really loaded - effectively a new world

// get name and IP address, give up if cancelled

  if (App.m_TypeOfNewDocument == App.eQuickConnect) // pop up nice simple dialog box
    {
    CQuickConnectDlg dlg;
    dlg.m_iPort = 4000;
    dlg.m_strWorldName = "Untitled world";
    dlg.m_strAddress = "";
    if (dlg.DoModal () != IDOK)
      return FALSE;
    m_server = dlg.m_strAddress;
    m_port = dlg.m_iPort;
    m_mush_name = dlg.m_strWorldName;

    // save auto connect flag, then set to true, to make sure we connect
    unsigned int savebAutoConnectWorlds = App.m_bAutoConnectWorlds;
    App.m_bAutoConnectWorlds = TRUE;
    SetUpOutputWindow ();
    OpenSession ();
    App.m_bAutoConnectWorlds = savebAutoConnectWorlds;
    SetModifiedFlag ();
    return TRUE;
        
    } // end of quick connect

  if (App.m_TypeOfNewDocument == App.eTelnetFromNetscape) // just do it
    {
    // get rid of telnet stuff
    CString strCommandLine = ::Replace (App.m_lpCmdLine, "telnet://", "");
    int iSpace = strCommandLine.FindOneOf (" :");
    if (iSpace == -1)
      {
      m_server = strCommandLine;
      m_mush_name = strCommandLine;
      m_port = 23;
      }
    else
      {
      m_server = strCommandLine.Left (iSpace);
      m_mush_name = m_server;
      m_port = atoi (strCommandLine.Mid (iSpace + 1));
      }

    // save auto connect flag, then set to true, to make sure we connect
    unsigned int savebAutoConnectWorlds = App.m_bAutoConnectWorlds;
    App.m_bAutoConnectWorlds = TRUE;
    SetUpOutputWindow ();
    OpenSession ();
    App.m_bAutoConnectWorlds = savebAutoConnectWorlds;
    SetModifiedFlag ();
    return TRUE;
        
    } // end of telnet called from netscape navigator

  // we have to do this *before* getting the preferences
  SetUpOutputWindow ();

  if (!GamePreferences (ePageGeneral))
    return FALSE;

  if(m_mush_name.IsEmpty ())
    {
    ::TMessageBox("Your world name cannot be blank.", MB_ICONEXCLAMATION);
    return FALSE;
    }

  if(m_server.IsEmpty ())
    {
    ::TMessageBox("The world TCP/IP address cannot be blank.", MB_ICONEXCLAMATION);
    return FALSE;
    }


  OpenSession ();

  return TRUE;

  }
Example #18
0
BOOL static getField(ifstream& fin, CString& marker, CString& contents)
{
	static BOOL bNextLineIsBlank=FALSE;
	if(bNextLineIsBlank)
	{
		bNextLineIsBlank=FALSE;
		marker = "BLANKLINE";
		contents ="";
		return TRUE;
	}

	ASSERTX(fin.is_open());

	const int kBuffSize = 5000;	// CURRENTLY MAX FIELD SIZE TOO!

	CString sField;
	LPTSTR buff = sField.GetBuffer(kBuffSize+2);
	LPTSTR start_buff = buff;

	fin.eatwhite();
	char* b = buff;
	BOOL bFoundBlank = FALSE;
	do
	{
		fin.getline(b, kBuffSize - (b-buff), '\n');
		b += fin.gcount();
		if(fin.gcount())
		{
			*(b-1) = '\n'; // put a carriage return in place of the null terminator
			*b = '\0';		// null terminate in case the next getline fails
		}
		while(fin.peek() == '\n') // keep swallowing blank lines until we see what's at the end of them
		{
			fin.get(); // swallow the \n;
			if(fin.peek() == '\\')	 // if the blanks are followed by a record, then this constitutes a true blank line
			{
				bFoundBlank=TRUE;
				break;
			}
		}
	} while (!bFoundBlank && fin.good() && fin.gcount() && fin.peek() != '\\');

	bNextLineIsBlank = bFoundBlank; // will be used on the next call

	if( (kBuffSize-1) <= (b-buff))	// to long (and thus fin.gcount() == 0)
	{
		CString s;
		s.Format("The interlinear file appears to have a line which is longer than the maximum of %d characters which csCleanITX can handle.\n",
					kBuffSize);
		throw(s);

	}

	if(!buff[0])	// end of file
	{	sField.ReleaseBuffer(-1);
		return FALSE;
	}

	// eat white space before the SFM Code (will always be there after a \dis)
	while(*buff && _ismbcspace(*buff))
	{
		*buff='~'; // a hack so that iSpaceLoc, below, isn't set to the space between the "\dis" and marker
		++buff;
	}


	int iSpaceLoc ;
	// figure out where the marker ends and field contents begin
	iSpaceLoc = sField.FindOneOf(" \t\n");
	if(iSpaceLoc <= 1)// [0] should be the slash, [1] at least one char
	{	sField.ReleaseBuffer(-1);
		return FALSE;
	}


	start_buff[iSpaceLoc] = '\0';
	marker = buff + 1; // +1 to skip the slash
	marker.TrimRight();

	contents = start_buff + iSpaceLoc+1;
	contents.TrimLeft();
	contents.TrimRight();

	sField.ReleaseBuffer(-1);
	return TRUE;
}