Beispiel #1
0
inline bool format::isNumeric(wxString kw) {
    if(kw.Len()==0)
        return false;
    if(kw.GetChar(0)=='&') {
        switch(kw.MakeLower().GetChar(1)) {
            case 'b':
            kw=kw.Mid(2);
            break;
            case 'o':
            kw=kw.Mid(2);
            break;
            case 'h':
            kw=kw.Mid(2);
            break;
        }
    }
    char ch;
    for(int i=0;i<(int)kw.Len();i++) {
        ch = kw.GetChar(i);
        if( ch >= 46 && ch <= 57 ) {
            if (ch==47)
                return false;
        }
        else {
            return false;
        }
    }
    return true;
}
Beispiel #2
0
wxFileName DirManager::MakeBlockFilePath(wxString value){
   
   wxFileName dir;
   dir.AssignDir(GetDataFilesDir());
   
   if(value.GetChar(0)==wxT('d')){
      // this file is located in a subdiretory tree 
      int location=value.Find(wxT('b'));
      wxString subdir=value.Mid(0,location);
      dir.AppendDir(subdir);
      
      if(!dir.DirExists())dir.Mkdir();
   }
   
   if(value.GetChar(0)==wxT('e')){
      // this file is located in a new style two-deep subdirectory tree 
      wxString topdir=value.Mid(0,3);
      wxString middir=wxT("d");
      middir.Append(value.Mid(3,2));
      
      dir.AppendDir(topdir);
      dir.AppendDir(middir);
      if(!dir.DirExists())dir.Mkdir(0777,wxPATH_MKDIR_FULL);
   }
   return dir;
}
bool CDExtraGatewayRepeaterProtocolHandler::writeText(const wxString& text, LINK_STATUS status, const wxString& reflector)
{
	unsigned char data[40U];

	data[0] = 'D';
	data[1] = 'S';
	data[2] = 'R';
	data[3] = 'P';

	data[4] = 0x00;

	::memset(data + 5U, ' ', 20U);

	for (unsigned int i = 0U; i < text.Length() && i < 20U; i++)
		data[i + 5U] = text.GetChar(i);

	data[25U] = (unsigned char)status;

	::memset(data + 26U, ' ', 8U);

	if (status != LS_NONE) {
		for (unsigned int i = 0U; i < reflector.Length() && i < 8U; i++)
			data[i + 26U] = reflector.GetChar(i);
	}

#if defined(DUMP_TX)
	CUtils::dump(wxT("Sending Text"), data, 34U);
	return true;
#else
	return m_socket.write(data, 34U);
#endif
}
bool CDPlusAuthenticator::poll(const wxString& callsign, const wxString& hostname, unsigned int port, unsigned char id)
{
	CUDPReaderWriter socket(m_address, 0U);
	bool ret = socket.open();
	if (!ret)
		return false;

	unsigned char buffer[56U];
	::memset(buffer, ' ', 56U);

	buffer[0U] = 0x38U;
	buffer[1U] = 0x20U;
	buffer[2U] = 0x01U;
	buffer[3U] = 0x01U;

	for (unsigned int i = 0U; i < callsign.Len(); i++)
		buffer[i + 4U] = callsign.GetChar(i);

	buffer[12U] = 'D';
	buffer[13U] = 'V';
	buffer[14U] = '0';
	buffer[15U] = '1';
	buffer[16U] = '9';
	buffer[17U] = '9';
	buffer[18U] = '9';
	buffer[19U] = '9';

	for (unsigned int i = 0U; i < callsign.Len(); i++)
		buffer[i + 20U] = callsign.GetChar(i);

	buffer[28U] = 'W';
	buffer[29U] = 'X';
	buffer[30U] = 'I';
	buffer[31U] = 'B';
	buffer[32U] = id;

	buffer[40U] = 'D';
	buffer[41U] = 'H';
	buffer[42U] = 'S';
	buffer[43U] = '0';
	buffer[44U] = '2';
	buffer[45U] = '5';
	buffer[46U] = '7';

	in_addr address = socket.lookup(hostname);
	if (address.s_addr == INADDR_NONE) {
		socket.close();
		return false;
	}

	ret = socket.write(buffer, 56U, address, port);

	socket.close();

	return ret;
}
usi interprete::ObtenerNumDeOperacion(wxString parentesis)
{
    usi i=0,resul=0;
    for(i=0;i<parentesis.length();i++)
    {
        if(parentesis.GetChar(i)=='+'||parentesis.GetChar(i)=='-'||parentesis.GetChar(i)=='*')
            resul++;
    }
    return resul+1;
}
Beispiel #6
0
bool wxExEx::Move(
  const wxString& begin_address, 
  const wxString& end_address, 
  const wxString& destination)
{
  if (m_STC->GetReadOnly())
  {
    return false;
  }

  const int dest_line = ToLineNumber(destination);

  if (dest_line == 0)
  {
    return false;
  }

  if (!SetSelection(begin_address, end_address))
  {
    return false;
  }

  if (begin_address.StartsWith("'"))
  {
    if (begin_address.size() > 1)
    {
      MarkerDelete(begin_address.GetChar(1));
    }
  }

  if (end_address.StartsWith("'"))
  {
    if (end_address.size() > 1)
    {
      MarkerDelete(end_address.GetChar(1));
    }
  }

  m_STC->BeginUndoAction();

  m_STC->Cut();
  m_STC->GotoLine(dest_line - 1);
  m_STC->Paste();

  m_STC->EndUndoAction();
  
  const int lines = wxExGetNumberOfLines(m_STC->GetSelectedText());
  if (lines >= 2)
  {
    m_Frame->ShowExMessage(wxString::Format(_("%d lines moved"), lines));
  }

  return true;
}
void CSplitRepeaterHeaderData::setRepeaters(const wxString& rpt1, const wxString& rpt2)
{
	::memset(m_rptCall1, ' ', LONG_CALLSIGN_LENGTH);
	::memset(m_rptCall2, ' ', LONG_CALLSIGN_LENGTH);

	for (unsigned int i = 0U; i < rpt1.Len(); i++)
		m_rptCall1[i] = rpt1.GetChar(i);

	for (unsigned int i = 0U; i < rpt2.Len(); i++)
		m_rptCall2[i] = rpt2.GetChar(i);
}
usi interprete::ObtenerNumCharsOperacion(wxString parentesis)
{
    usi i=0,resul=0;
    for(i=0;i<parentesis.length();i++)
    {
        if(parentesis.GetChar(i)=='+'||parentesis.GetChar(i)=='-'||parentesis.GetChar(i)=='*')
            break;
    }
    resul=i-1;
    return resul;
}
usi interprete::ObtenerNumCharsOperacion(wxString parentesis, usi longitudMa)
{
    int i=0,resul=0;
    while(parentesis.GetChar(i)!='+'||parentesis.GetChar(i)!='-'||parentesis.GetChar(i)=='*')
    {
        resul++;
        i++;
        if(i==longitudMa)
            break;
    }
    return resul;
}
int ToDoListView::CalculateLineNumber(const wxString& buffer, int upTo, int &oldline, int &oldlinepos )
{
    for (; oldlinepos < upTo; ++oldlinepos)
    {
        if (buffer.GetChar(oldlinepos) == _T('\r') && buffer.GetChar(oldlinepos + 1) == _T('\n')) // CR+LF
            continue; // we 'll count on \n (next loop)
        else if (buffer.GetChar(oldlinepos) == _T('\r') || // CR only
                buffer.GetChar(oldlinepos) == _T('\n')) // lf only
            ++oldline;
    }
    return oldline;
}
Beispiel #11
0
static size_t FirstSpecialChar(const wxString& str)
{
	for (size_t pos = 0; pos < str.Len(); pos++) {
		if (!str.GetChar(pos).IsAscii()) {
			continue;
		}
		const unsigned char uc = str.GetChar(pos);
		if (uc == 0x1f || uc == 0x1d || uc == 0x03 || uc == 0x02 || uc == 0x016 || uc == 0x0F) { //get all text until first irc color is found
			return pos;
		}
	}
	return -1;
}
Beispiel #12
0
wxString IniParser::ReadLineFromBuffer(wxString& buffer)
{
    int len = buffer.Length();
    int i = 0;
    while (i < len && buffer.GetChar(i) != _T('\n'))
        ++i;
    wxString str = buffer.Left(i);
    while (i < len && (buffer.GetChar(i) == _T('\n') || buffer.GetChar(i) == _T('\r')))
        ++i;
    buffer.Remove(0, i);
    buffer.Trim();
    return str;
}
void FindSequenceDialog::aaSubSearch ( const wxString &s , int start , int dir , wxString rf )
	{
	int a ;
	wxChar codon[4] ;
	codon[3] = 0 ;
	wxString res ;
	wxArrayInt ai ;
    TVector *v = c->vec ;
    wxString sub = getQuery() ;
    int ostart = start < 0 ? 2 : 0 ;
    
    res.Alloc ( s.length() / 3 + 10 ) ;
    ai.Alloc ( s.length() / 3 + 10 ) ;
    
    if ( start < 0 )
    	{
	    for ( start = -start ; start + 3 < s.length() ; start += 3 ) ;
    	}
   	
	for ( a = start ; a + dir * 2 >= 0 && a + dir * 2 < s.length() ; a += dir * 3 )
		{
 		codon[0] = s.GetChar ( a ) ;
 		codon[1] = s.GetChar ( a + dir ) ;
 		codon[2] = s.GetChar ( a + dir * 2 ) ;

        wxChar c2 = codonhash[codon] ;
        if ( c2 < 'A' ) c2 = codonhash[codon] = v->dna2aa ( codon ) . GetChar ( 0 ) ;
        res += c2 ;

		ai.Add ( a ) ;
		}    
		
	a = subsearch ( res , sub , 0 ) ;
	//a = res.Find ( sub ) ;
	while ( a != -1 )
		{
  		if ( lb->GetCount() > FIND_MAX ) return ;
		int from = ai[a] + 1 - ostart ;
		int to = ai[a+sub.length()-1] + dir * 2 + 1 - ostart ;
		if ( from > to ) { int z = from ; from = to ; to = z ; }
		wxString msg = rf.BeforeFirst ( '\t' ) ;
      lb->Append ( wxString::Format ( _T("%s: %s (%d-%d)") ,
                          txt("amino_acid").c_str() ,
                          msg.c_str() ,
                          from , to ) ) ;
      vi.Add ( -1 ) ;
		res.SetChar ( a , '_' ) ; // Invalidating
		a = subsearch ( res , sub , a+1 ) ;
//		a = res.Find ( sub ) ;
		}    
	}    
usi interprete::ParenNumCarac(wxString parentesis)
{
    usi i=0;
    char a=parentesis.GetChar(0);
    if(a=='('||a=='{')
    {
        for(i=0;i<parentesis.length();i++)
        {
            if(parentesis.GetChar(i)==',')
                break;
        }
    }
    return i;
}
bool TextFileSearcherText::MatchLine(wxString line)
{
	bool match = false;
	if ( m_MatchCase == false )
	{
		line.LowerCase();
	}
	int pos = line.Find(m_SearchText.c_str());
	int nextPos;
	while ( (match == false) && (pos >= 0) )
	{
		char c = ' '; // c is either the preceeding char or a virtual char
		              // that matches systematically the required conditions
		match = true; // pos > 0 => expr found => Matches. Let's test start word
		              // and whole words conditions.
		if ( (m_MatchWordBegin == true) || (m_MatchWord == true) )
		{
			if ( pos > 0 )
			{
				c = line.GetChar(pos - 1);
			}
			//match = (__iscsym(c) == 0);
			match = !(isalnum(c) || ( c == '_' ));
		}

		if ( (match == true) && (m_MatchWord == true) )
		{
			c = ' ';
			if ( (pos + m_SearchText.Length()) < line.Length() )
			{
				c = line.GetChar(pos + m_SearchText.Length());
			}
			match = !(isalnum(c) || ( c == '_' ));
		}

		nextPos = line.Mid(pos+1).Find(m_SearchText.c_str());
		if ( nextPos >= 0 )
		{
			pos += nextPos + 1;
		}
		else
		{
			pos = -1;
		}
	}

	return match;
}
void CSplitRepeaterHeaderData::setMyCall1(const wxString& my1)
{
	::memset(m_myCall1, ' ', LONG_CALLSIGN_LENGTH);

	for (unsigned int i = 0U; i < my1.Len(); i++)
		m_myCall1[i] = my1.GetChar(i);
}
Beispiel #17
0
bool ExpressionNode::IsBinaryOperator(wxString first, wxString second)
{
    switch ((wxChar)first.GetChar(0))
    {
        case _T('&'):
        case _T('|'):
        case _T('='):
        case _T('!'):
        case _T('>'):
        case _T('<'):
        {
            wxString newOperator(first + second);
            if (newOperator == ExpressionConsts::And ||
            newOperator == ExpressionConsts::Or ||
            newOperator == ExpressionConsts::Equal ||
            newOperator == ExpressionConsts::Unequal ||
            newOperator == ExpressionConsts::GTOrEqual ||
            newOperator == ExpressionConsts::LTOrEqual ||
            newOperator == ExpressionConsts::LShift ||
            newOperator == ExpressionConsts::RShift)
                return true;
            else
                return false;
        }
        default:
            return false;
    }
}
Beispiel #18
0
wxString RemoveWhiteSpace(wxString str)
{
    int index = 0;
    while(index < str.Len())
    {
        if(str.GetChar(index) == ' ' || str.GetChar(index) == '\t' || str.GetChar(index) == '\n')
        {
            str.Remove(index, 1);
        }
        else
        {
            index++;
        }
    }
    return str;
}
Beispiel #19
0
CDPlusHandler::CDPlusHandler(IReflectorCallback* handler, const wxString& repeater, const wxString& reflector, CDPlusProtocolHandler* protoHandler, const in_addr& address, unsigned int port) :
m_repeater(repeater),
m_callsign(m_dplusLogin),
m_reflector(reflector),
m_handler(protoHandler),
m_yourAddress(address),
m_yourPort(port),
m_myPort(0U),
m_direction(DIR_OUTGOING),
m_linkState(DPLUS_LINKING),
m_destination(handler),
m_time(),
m_pollTimer(1000U, 1U),			// 1s
m_pollInactivityTimer(1000U, 30U),
m_tryTimer(1000U, 1U),
m_tryCount(0U),
m_dPlusId(0x00U),
m_dPlusSeq(0x00U),
m_inactivityTimer(1000U, 2U),
m_header(NULL)
{
	wxASSERT(protoHandler != NULL);
	wxASSERT(handler != NULL);
	wxASSERT(port > 0U);

	m_myPort = protoHandler->getPort();

	m_pollInactivityTimer.start();
	m_tryTimer.start();

	m_time = ::time(NULL);

	wxChar band = repeater.GetChar(LONG_CALLSIGN_LENGTH - 1U);
	m_callsign.SetChar(LONG_CALLSIGN_LENGTH - 1U, band);
}
Beispiel #20
0
bool wxTerminal::CheckForCD( const wxString &command, wxString &path )
{
	if ( command.IsEmpty() )               return false; // Returning true tells caller there's nothing else to do
	if ( command.Left(2) != wxT("cd") )    return false; // Not a cd attempt so return false so that RunCommand takes over
	if ( wxIsalpha( command.GetChar(2) ) ) return false; // This must be a real command beginning with cd???

	if ( command == wxT("cd.") || command == wxT("cd .") )  {
		path = wxGetCwd();
		return true;
	}

	if ( command == wxT("cd") || command == wxT("cd~") || command == wxT("cd ~") ) {
		path = wxGetHomeDir();
		return true;

	} else if ( command.Find(wxT("&&")) != wxNOT_FOUND ) {
		// a complex command: cd <somewhere> && ...
		return false;

	} else {
		// Otherwise it should be a real dir. Remove the initial cd, plus any white-space
		path = command.Mid( 2 );
		path << wxFileName::GetPathSeparator();
		path.Trim(false);
		wxFileName fn(path);
		fn.MakeAbsolute(m_workingDir);
		fn.Normalize();
		if( fn.DirExists() ) {
			path = fn.GetFullPath();
			return true;
		}
		return false;
	}
}
Beispiel #21
0
// Convert 2-digit hex number to decimal
int wxHexToDec(const wxString& str)
{
    char buf[2];
    buf[0] = str.GetChar(0);
    buf[1] = str.GetChar(1);
    return wxHexToDec((const char*) buf);
}
wxString KeynameConverter::discardModifier( const wxString& keystring )
{
	wxString result;
	if ( keystring.EndsWith(wxT("+")) )	//handle stuff like numpad+ or ctrl++
	{
		wxString tmp = keystring;
		result = tmp.RemoveLast().AfterLast(wxT('+')) + wxT('+');
	}
	else if ( keystring.StartsWith(wxT("+")) )	//handle stuff like "+ (numpad)"
	{
		result = keystring;
	}
	else 
	{
		size_t lastAdd = keystring.find_last_of(wxT('+'));
		if ( ( lastAdd != keystring.npos ) && ( keystring.GetChar(lastAdd - 1) == wxT('+') ) )
		{
			assert( (lastAdd > 0) && "character '+' found in unexcepted location!" );
			result = keystring.substr( lastAdd );
		}
		else
		{
			result = keystring.AfterLast(wxT('+'));
		}
	}
	return result;
}
Beispiel #23
0
void ReplaceWord(wxString& str, const wxString& replaceFrom, const wxString& replaceTo, bool numbers = false)
{
	unsigned int i = 0;
	unsigned int l = replaceFrom.Length();
	while (i < str.Length()) {
		if (str.Mid(i, l) == replaceFrom) {
			if ((i == 0 || IsWordSeparator(str.GetChar(i-1))) &&
				((i == str.Length() - l || IsWordSeparator(str.GetChar(i+l))) ||
					(numbers && IsDigit(str.GetChar(i+l))))) {
				str.replace(i, l, replaceTo);
			}
			i += replaceTo.Length() - 1;
		}
		i++;
	}
}
bool CRemoteProtocolHandler::readHash(const wxString& password, wxUint32 random)
{
	if (m_type != RPHT_HASH)
		return false;

	unsigned char* hash = m_inBuffer + 3U;

	unsigned int len = password.Len() + sizeof(wxUint32);
	unsigned char*  in = new unsigned char[len];
	unsigned char* out = new unsigned char[32U];

	::memcpy(in, &random, sizeof(wxUint32));
	for (unsigned int i = 0U; i < password.Len(); i++)
		in[i + sizeof(unsigned int)] = password.GetChar(i);

	CSHA256 sha256;
	sha256.buffer(in, len, out);

	bool res = ::memcmp(out, hash, 32U) == 0;

	delete[] in;
	delete[] out;

	return res;
}
void CSplitRepeaterHeaderData::setYourCall(const wxString& your)
{
	::memset(m_yourCall, ' ', LONG_CALLSIGN_LENGTH);

	for (unsigned int i = 0U; i < your.Len(); i++)
		m_yourCall[i] = your.GetChar(i);
}
Beispiel #26
0
void QuoteStringIfNeeded(wxString& str)
{
    bool hasSpace = str.Find(_T(' ')) != -1;
    bool hasParen = !platform::windows && (str.Find(_T('(')) != -1 || str.Find(_T(')')) != -1);
    if (!str.IsEmpty() && str.GetChar(0) != _T('"') && (hasSpace || hasParen))
        str = wxString(_T("\"")) + str + _T("\"");
}
Beispiel #27
0
void nwxString::SetFileExtension(wxString *ps, const wxString &sExt)
{
  // STOP HERE
  wxChar dot('.');
  int nFs = ps->Find(wxChar('/'),true);
#ifdef __WXMSW__
  int nFb = ps->Find(wxChar('\\'),true);
#endif
  int nP  = ps->Find(dot,true);
  bool bUseDot =
    ( (nP != wxNOT_FOUND) // dot found
      && ((nFs == wxNOT_FOUND) || (nFs < nP)) // dot after '/'
#ifdef __WXMSW__
      && ((nFb == wxNOT_FOUND) || (nFb < nP)) // dot after '\'
#endif
    );
  if(bUseDot)
  {
    ps->Truncate(nP);
  }
  if( sExt.Len() && (sExt.GetChar(0) != dot) )
  {
    ps->Append(dot);
  }
  ps->Append(sExt);
}
bool CRepeaterProtocolHandler::writePoll(const wxString& text)
{
	unsigned char buffer[40U];

	buffer[0] = 'D';
	buffer[1] = 'S';
	buffer[2] = 'R';
	buffer[3] = 'P';

	buffer[4] = 0x0A;				// Poll with text

	unsigned int length = text.Length();

	for (unsigned int i = 0U; i < length; i++)
		buffer[5U + i] = text.GetChar(i);

	buffer[5U + length] = 0x00;

#if defined(DUMP_TX)
	CUtils::dump(wxT("Sending Poll"), buffer, 6U + length);
	return true;
#else
	return m_socket.write(buffer, 6U + length);
#endif
}
void CDExtraGatewayAudioUnit::spellReflector(const wxString &reflector)
{
	unsigned int length = reflector.Len();

	for (unsigned int i = 0U; i < (length - 1U); i++) {
		wxString c = reflector.Mid(i, 1U);

		if (!c.IsSameAs(wxT(" ")))
			lookup(c);
	}

	wxChar c = reflector.GetChar(length - 1U);

	switch (c) {
		case wxT('A'):
			lookup(wxT("alpha"));
			break;
		case wxT('B'):
			lookup(wxT("bravo"));
			break;
		case wxT('C'):
			lookup(wxT("charlie"));
			break;
		case wxT('D'):
			lookup(wxT("delta"));
			break;
		default:
			lookup(wxString(c));
			break;
	}
}
void CSplitRepeaterHeaderData::setMyCall2(const wxString& my2)
{
	::memset(m_myCall2, ' ', SHORT_CALLSIGN_LENGTH);

	for (unsigned int i = 0U; i < my2.Len(); i++)
		m_myCall2[i] = my2.GetChar(i);
}