Example #1
0
AnsiString __fastcall TFTPFile::GetFilePath(AnsiString ServerString)
{
  int pos = ServerString.LowerCase().Pos("ftp://");
  if(pos < 1)
    return "";
  ServerString = ServerString.SubString(pos + 6,ServerString.Length() - pos);
  pos = StrLScan(ServerString.c_str(),"/");
  if(pos < 0)
    return "";
  ServerString = ServerString.SubString(pos + 2,ServerString.Length() - pos - 1);
  pos = StrRScan(ServerString.c_str(),"/");
  if(pos < 0)
    return "/";
  ServerString = ServerString.SubString(1,pos);
  if(ServerString.SubString(1,1) != "/")
    ServerString = "/" + ServerString;
  if(ServerString.SubString(ServerString.Length(),1) != "/")
    ServerString = ServerString + "/";
  return ServerString;
}
Example #2
0
void __fastcall TDB_packer::ExtBtn3Click(TObject *Sender)
{
	TElShellTreeItem* itm = shellTree->ItemFocused;
    if(!itm->IsFolder)
    {
        AnsiString str				= itm->FullName;
        int root_len 				= xr_strlen(m_root_folder);
        int len						= str.Length();
    	lbIncludeFiles->Items->Add( str.SubString(root_len+1,len-root_len) );
    }
}
Example #3
0
AnsiString __fastcall TFTPFile::GetUserName(AnsiString ServerString)
{
  int pos = ServerString.LowerCase().Pos("ftp://");
  if(pos < 1)
    return "";
  ServerString = ServerString.SubString(pos + 6,ServerString.Length() - pos);
  pos = StrLScan(ServerString.c_str(),":");
  if(pos < 0)
    return "";
  return DecryFTPPassword(ServerString.SubString(1,pos));
}
//---------------------------------------------------------------------------
void TfrmMainFormServer::AddANewModule(){
    AnsiString name = InputBox("New Virtual Directory",
        "Enter an alias WITHOUT spaces",
        "ANewName");

    if(name.Length() > 0){
        adapter.AddANewModule(name);
        LoadModuleNames();
    }


}
//---------------------------------------------------------------------------
AnsiString __fastcall TBolBradesco::GeraCampoLivre(void)
{
    AnsiString CampoLivre = Agencia.SubString(1,4) +
    Carteira + GetNumeroDocumento() +
    CodigoCedente.SubString(1,7) +
    "0";
    if(CampoLivre.Length() != 25)
     {
      throw Exception("Campo livre deve conter 25 caracteres para o Banco Bradesco.");
     }
    return(CampoLivre);
}
Example #6
0
//----------------------------------------------------------------------------
//class TMemIniFile : public TCustomIniFile
//----------------------------------------------------------------------------
// TIniFileのバグ回避版らしい・・・が、TIniFileと同じことをやる。ドン
TMemIniFile::TMemIniFile(const AnsiString& str) : m_pStream(NULL), m_pConfig(NULL)
{
	if ( str.AnsiPos("\\\\?\\") )
		m_strIniFile = str.SubString( 4, str.Length() - 4).c_str();
	else
		m_strIniFile = str.c_str();
//	m_pStream = new wxFileInputStream( m_strIniFile );
//	m_pConfig = new wxFileConfig(*m_pStream);

//	m_pConfig = new wxFileConfig(wxEmptyString, wxEmptyString, m_strIniFile, wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
	m_pConfig = new wxFileConfig(wxT("krkr"), wxT("ym"), m_strIniFile, wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
}
Example #7
0
//---------------------------------------------------------------------------
void MyPlaySound(AnsiString file)
{
  if( file.Length() == 0 )
    return;
  if( ! FileExists(file) )
  {
    WriteToLogError("WARNING\tPlay sound: file \"%s\" not found !", file.c_str());
    return;
  }
  if( ::PlaySound(file.c_str(), NULL, SND_FILENAME | SND_NODEFAULT | SND_NOWAIT | SND_SYNC) == FALSE )
    WriteToLogError("ERROR\tPlay sound: \"%s\"", FormatLastError2(GetLastError()).c_str());
}
Example #8
0
//---------------------------------------------------------------------------
bool TUtilities::CheckFileBool(std::ifstream &InFile)
//no need to worry about leading '\n' characters as the skipws (skip white space) flag is
//set automatically
{
AnsiString BoolString;
if(!CheckAndReadFileString(InFile, BoolString)) return false;
if(InFile.fail()) return false;
if(BoolString == "") return false;
if((BoolString.Length() > 1) || (BoolString == "")) return false;
if((BoolString != "0") && (BoolString != "1")) return false;
return true;
}
Example #9
0
//---------------------------------------------------------------------------
void StringToTokiensA( AnsiString Words, AnsiString Dlmtr, TStrings *Making )
{
  AnsiString Work = Words.Trim();
  int spos;
  while ((spos = Work.AnsiPos(Dlmtr)) != 0) {
    Making->Add(Work.SubString( 1, spos-1));
    Work = Work.SubString( spos+1, Work.Length() - spos);
    Work = Work.Trim();
  } // while
  if (Work != "")
    Making->Add(Work);
}
Example #10
0
//---------------------------------------------------------------------------
void __fastcall PuttyInitialize()
{
  SaveRandomSeed = true;

  InitializeCriticalSection(&putty_section);

  // make sure random generator is initialised, so random_save_seed()
  // in destructor can proceed
  random_ref();

  flags = FLAG_VERBOSE | FLAG_SYNCAGENT; // verbose log

  sk_init();

  AnsiString VersionString = SshVersionString();
  assert(!VersionString.IsEmpty() && (static_cast<size_t>(VersionString.Length()) < LENOF(sshver)));
  strcpy(sshver, VersionString.c_str());
  AnsiString AppName = AppNameString();
  assert(!AppName.IsEmpty() && (static_cast<size_t>(AppName.Length()) < LENOF(appname_)));
  strcpy(appname_, AppName.c_str());
}
Example #11
0
//---------------------------------------------------------------------------
bool __fastcall TRelDirSearchForm::GetFileList(AnsiString folder)
{
	try
	{
		GetFileList(folder, folder.Length());
	}
	catch(...)
	{
		return false;
	}
	return true;
}
Example #12
0
bool __fastcall TEntryForm::InValidDouble(AnsiString label, TEditPlus *edit)
{
  AnsiString ud = edit->Text;
  if (ud[1] == '-')
    ud.Delete(1,1);
  if (strspn(ud.c_str(), "0123456789.") == (unsigned)ud.Length())
    return false;
  AnsiString msg = "The field "+label+" contains the value '"+edit->Text+"'."
                  +" This is invalid for a non null double field";
  Application->MessageBox(msg.c_str(), "Invalid Double", ID_OK);
  return true;
}
Example #13
0
//---------------------------------------------------------------------------
/// Metoda odpowiedzialna za dostosowanie znaków specjalnych w tekœcie (apostrofy itp.),
/// poprzez dodanie dodanie "\"
void __fastcall ParsujDane::DostosujZnakiSpecjalne(AnsiString &AText)
{
	AnsiString str;
	int pozycjaZnacznik = 0;

	while(pozycjaZnacznik != AText.Length())
	{
		str = AText[pozycjaZnacznik];
		if (str == "\'" || str == "\"") AText.Insert("\\", pozycjaZnacznik - 1);
		pozycjaZnacznik++;
	}
}
Example #14
0
AnsiString Global::Bezogonkow(AnsiString str, bool _)
{ // wyciêcie liter z ogonkami, bo OpenGL nie umie wyœwietliæ
    for (int i = 1; i <= str.Length(); ++i)
        if (str[i] & 0x80)
            str[i] = bezogonkowo[str[i] & 0x7F];
        else if (str[i] < ' ') // znaki steruj¹ce nie s¹ obs³ugiwane
            str[i] = ' ';
        else if (_)
            if (str[i] == '_') // nazwy stacji nie mog¹ zawieraæ spacji
                str[i] = ' '; // wiêc trzeba wyœwietlaæ inaczej
    return str;
}
Example #15
0
//---------------------------------------------------------------------------
void __fastcall TFormReportUchebKartStud::StringToAudHours(AnsiString  h[12], AnsiString &str_hours)
{
    int cur_sem = 0;
    int begin = 1;
    for(int pos = 1; pos <= str_hours.Length(); pos++)
    {
        if (str_hours[pos] == ';')
        {
            h[cur_sem++] = str_hours.SubString(begin, pos - begin);
            begin = pos + 1;
        }
    }
}
Example #16
0
//---------------------------------------------------------------------------
void __fastcall TFormDisciplines::StringToAudHours(AudHours* h, AnsiString &str_hours)
{
    int cur_sem = 0;
    int begin = 1;
    for(int pos = 1; pos <= str_hours.Length(); pos++)
    {
        if (str_hours[pos] == ';')
        {
            h->hours[cur_sem++] = str_hours.SubString(begin, pos - begin);
            begin = pos + 1;
        }
    }
}
Example #17
0
void CFolder::mf_CFolder_0010(AnsiString arg_0)
{
	char local_00[1024];
	char local_01[16];
	m__unknown_003=arg_0;
	if (arg_0.Length()==0) {
		m__unknown_002="";
		return;
	}
	strcpy(local_00,arg_0.c_str());
	ny_htmlproc_5(local_00,local_01);
	m__unknown_002=local_01;
}
Example #18
0
//const int max_count_line = 17; // кол-во строк в одном семестре
//const int max_len_title = 35;
//---------------------------------------------------------------------------
AnsiString TFormReportUchebKartStud::GetDateAsString(const AnsiString& str, bool isYear)
{
    AnsiString res = "";
    res += str.SubString(9,2);
    if (res.Length() == 1)
        res = "0" + res;
    res += " ";
    res += MounthNames[(str.SubString(6, 2).ToInt() - 1) % 12] + " ";
    res += str.SubString(1, 4);
    if (isYear)
        res += " г.";
    return res;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TBolBesc::CalculaDV2Chave25(AnsiString AChave)
{
  int Digito;
  Digito = 0;
  int Soma = 0;
  int Multiplicador = 2;
  for (int i = AChave.Length(); i > 0; i--)
   {
    Soma = Soma + StrToInt(AChave[i]) * Multiplicador;
    Multiplicador++;
    if (Multiplicador > 7)
     Multiplicador = 2;
   }
  int Resto = (Soma % 11);
  if(Resto==0)
   Digito=0;
  else
   if (Resto == 1)
    {
     int Pos24 = StrToInt( AChave[AChave.Length()] );
     if(Pos24 == 9)
      Pos24 = 0;
     else
      Pos24 = Pos24 + 1;
     AChave = AChave.SubString(1, 23) + IntToStr(Pos24);
     return CalculaDV2Chave25(AChave);
    }
   else// (Resto > 1)
    {
     Digito = 11 - Resto;
    }

  Digito = Digito + 2;
  if(Digito == 10)
   Digito = 0;
  if(Digito == 11)
   Digito = 1;
  return IntToStr(Digito);
}
Example #20
0
String			TSearchFilesFrm::GetSearchData()
{
	AnsiString data;
	AnsiString content_text = edtSearchContent->Text;

	if(cbSearchMode->ItemIndex == 0)
	{
		data = content_text;
	}
	else if(cbSearchMode->ItemIndex == 1)
	{
		data = BinToStr(content_text.c_str(), content_text.Length());
	}
	else if(cbSearchMode->ItemIndex == 2)
	{
		DWORD num = content_text.ToInt();
		data.SetLength(4);
		int pos = 0;
		WriteDWORD(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	else if(cbSearchMode->ItemIndex == 3)
	{
		WORD num = content_text.ToInt();
		data.SetLength(2);
		int pos = 0;
		WriteWORD(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	else if(cbSearchMode->ItemIndex == 4)
	{
		BYTE num = content_text.ToInt();
		data.SetLength(1);
		int pos = 0;
		WriteBYTE(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	return	data;
}
DLL_EXPORT int UDPFriend(void *client, char *host_data, char *buf, int buf_size) {
    CConceptClient *CC = (CConceptClient *)client;
    if ((CC) && (buf_size > 0) && (buf)) {
        AnsiString temp = InitUDP3(CC, host_data);
        int size = temp.Length();
        if (size >= buf_size)
            size = buf_size - 1;
        memcpy(buf, temp.c_str(), size);
        buf[size] = 0;
        return size;
    }
    return 0;
}
Example #22
0
//===========================================================================
AnsiString GetShortFileName(AnsiString FileName)
{
   int        SlashCount = 0;
   int        Pos1       = 1111111111;
   int        Pos2       = 0;
   AnsiString Result     = "";

  // --- Считаю количесто слешев -----
   for (int i = 1; i <= FileName.Length(); i++)
       if (FileName[i] == '\\'){
          SlashCount ++;
          if (SlashCount == 2) Pos1 = i;
       }
  // ---- Проверяю количество слешев -------
  if (SlashCount > 3) {
      // ---- Ищу вторую позицию слеша ------
      SlashCount = 0;
      for (int i = FileName.Length(); i > 0; i--){
         if (FileName[i] == '\\'){
            SlashCount ++;
            if (SlashCount == 2 ) {
              Pos2 = i;
              break;
            }
         }
      }

      for (int i = 1; i <= FileName.Length(); i++) {
         if (i <= Pos1) {
               Result = Result + FileName[i];
               if (i + 1 > Pos1) Result = Result + "...";
         }
         if (i >= Pos2) Result = Result + FileName[i];
      }
  } else Result = FileName;

  return Result;
}
Example #23
0
/***************************************************************************
 Function:	StrHexCmp 16进制字符串比较
 Param:     str1 str2 要比对的字符串 ,格式:01030001 16进制字符串
 bFull true 严格一致
 false 遇到** 二个星 认为与任何字符都相同
 Returns:	true 一致 false不一致
 ***************************************************************************/
bool TDataSwitch::StrHexCmp(AnsiString str1, AnsiString str2, bool bFull) {
	if (str1.Length() != str2.Length())
		return false;

	for (int i = 0; i < str1.Length() / 2; i++) {

		if (bFull) {
			if (str1.SubString(i * 2 + 1, 2) != str2.SubString(i * 2 + 1, 2))
				return false;

		}
		else if (str1.SubString(i * 2 + 1, 2) != "**" && str2.SubString
			(i * 2 + 1, 2) != "**") {

			AnsiString tmp1 = str1.SubString(i * 2 + 1, 2);
			AnsiString tmp2 = str2.SubString(i * 2 + 1, 2);
			if (str1.SubString(i * 2 + 1, 2) != str2.SubString(i * 2 + 1, 2))
				return false;
		}
	}

	return true;
}
Example #24
0
//---------------------------------------------------------------------------
void __fastcall TCDirectoryOutline::CreateWnd()
{
    AnsiString CurrentPath;
    
    TCustomOutline::CreateWnd();
    
    if (FDrive == 0) {
        AnsiString CurrentPath = ForceCase(CurDir());
        if (CurrentPath.Length() != 0) {
            FDrive = CurrentPath[1];
            FDirectory = CurrentPath;
        }
    }
}
Example #25
0
//用空格或者'-'分割字符串,取后部分。
AnsiString GetStrName(AnsiString AStr)
{
    AnsiString IName;
    int IPos;
    IPos = AStr.Pos("-");
    if(IPos == 0)
    {
    	IPos = AStr.Pos(" ");
    	if(IPos == 0)
    	{
    		IName = "";
    	}
    	else
    	{
    		IName = AStr.SubString(IPos + 1, AStr.Length());
    	}	
    }
    else
    {
    	IName = AStr.SubString(IPos + 1,AStr.Length());
    }
    return IName;
}
Example #26
0
AnsiString searchleftright(AnsiString t)
{
        int i,left=0,right=0;
        for(i=1;i<=t.Length();i++)
        {
                if(t[i]=='(' || t[i]=='[' || t[i]=='{')
                        left++;
                if(t[i]==')' || t[i]==']' || t[i]=='}')
                        right++;
                if(right==left)
                        break;
        }
        return t.SubString(2,i);
}
Example #27
0
//---------------------------------------------------------------------------
int PosEnd(AnsiString asSt,AnsiString asT)
{
        int t=0,n=asSt.Length();
        for(int i=n;i>=1;i--)
        {
                if(asSt[i]=='(')
                        t++;
                if(asSt[i]==')')
                        t--;
                if(asSt.operator [](i)==asT.operator [](1) && !t)
                        return i;
        }
        return 0;
}
Example #28
0
//----------------------------------------------------------------------------
void CLogSupport::WriteLog(AnsiString content){
	DWORD dwFileLenHigh;
	DWORD dwFileLen = GetFileSize(handleFile , &dwFileLenHigh);
	if (dwFileLen > (DWORD)logSize * 1024){    //文件过大 清空文件
		SetFilePointer(handleFile , 0 , NULL , FILE_BEGIN);    //移动文件指针
		SetEndOfFile(handleFile);//清空文件
	}
	AnsiString strContent =content +"\r\n";
	::EnterCriticalSection(&m_cs);
	SetFilePointer(handleFile , 0 , NULL , FILE_END);    //移动到文件末尾
	DWORD dwWriteLen;
	WriteFile(handleFile, strContent.c_str(), (DWORD)strContent.Length(), &dwWriteLen, NULL);
	::LeaveCriticalSection(&m_cs);	//释放临界区
}
Example #29
0
void __fastcall TCDirectoryOutline::WalkTree(const AnsiString& Dest)
{
    AnsiString Path = ForceCase(Dest);
    long Item = RootIndex;  // start at root


    // remove drive component of Path

    int Colon = Path.Pos(":");
    if (Colon > 0) {
        int Offset = (Path[Colon + 1] == '\\') ? 2 : 1;
        if ((Colon + Offset) >= Path.Length())
           Path = "";
        else
           Path = Path.SubString(Colon + Offset, Path.Length() - (Colon + Offset) +1);
    }

    // do the walk
    for (int SlashPos = GetPos(Path, "\\"); Path.Length() > 0;
            SlashPos = GetPos(Path, "\\")) {
        AnsiString Dir = Path;

        if (SlashPos > 0) {
            // splice out the first directory
            Dir = Path.SubString(1, SlashPos - 1);
            Path = Path.SubString(SlashPos + 1, Path.Length() - (SlashPos + 1) + 1);
        }
        else {
            Dir = Path;
            Path = "";
        }

        Item = GetChildNamed(Dir, Item);
    }

    SelectedItem = Item;
}
Example #30
0
//---------------------------------------------------------------------------
// This event handler is called by the FTP component once it has built the   
// directory listing. We can use this handler to alter the listing, adding
// or removing some info. This sample add the 'virtual' directory.
void __fastcall TFtpServerForm::FtpServer1AlterDirectory(TObject *Sender,
      TFtpCtrlSocket *Client, TFtpString &Directory, bool Detailed)
{
    AnsiString Buf;

    if (UpperCase(Client->Directory) != "C:\\")
        return;
    // Add our 'virtual' directory to the list
    if (Detailed) {
        // We need to format directory lines according to the Unix standard
        Buf =
        "drwxrwxrwx   1 ftp      ftp            0 Apr 30 19:00 VIRTUAL\r\n";
        Client->DataStream->Write(&Buf[1], Buf.Length());
    }
}