void TGridModeDemoMainForm::SortPattern(TcxGridDBDataController *ADataController)
{
    TcxGridDBTableView *AView = (TcxGridDBTableView*)ADataController->GridView;
    TStrings *ASortList = new TStringList();
    try{
      AView->BeginUpdate();
      String AOrder, AFieldName;
      int AIndex;
      for (int I = 0; I < AView->SortedItemCount; I++){
        AIndex = ADataController->GetSortingItemIndex(I);
        AFieldName = AView->Columns[AIndex]->DataBinding->FieldName;
        if (AView->Columns[AIndex]->SortOrder == soAscending)
          AOrder = " ASC, ";
        else
          AOrder = " DESC, ";
        ASortList->Add(AFieldName + AOrder);
      }
      GridModeDemoDataDM->
        ApplySortToQuery((TQuery*)ADataController->DataSet, ASortList);
    }
    __finally{
      delete ASortList;
      AView->EndUpdate();
    }
}
示例#2
0
void __fastcall TEditTiffForm::SetupPageComboBox(int count, int start) {
//-------------------------------------------------------------------------------
//                          Заполняет PageComboBox                              |
// Если start == -1, то не меняет ItemIndex                                     |
//-------------------------------------------------------------------------------
    TStrings *items = PageComboBox->Items;
    int i;
    char buf[50];

    items->Clear();
    for (i = 1; i <= count; i++) {
        sprintf(buf, "%d / %d", i, count);
        items->Add(buf);
    }

    InsideChange = true;
    ScrollBar1->Max = count;
    if (start >= 0) {
        PageComboBox->ItemIndex = start;
        ScrollBar1->Position = start;
    } else if (PageComboBox->ItemIndex == -1) {
        PageComboBox->ItemIndex = 0;
        ScrollBar1->Position = 0;
    }

    EnumTiffPages();
    InsideChange = false;
}
示例#3
0
void ecmd_commands(TStrings &rc) {
   MTLOCK_THIS_FUNC _lk;
   if (!ecmd) ecmd = new_ini(ecmd_name());
   ecmd->ReadSectionKeys("COMMANDS",rc);
   // trim spaces and empty lines
   rc.TrimEmptyLines();
   rc.TrimAllLines();
   for (int ii=0; ii<rc.Count(); ii++) rc[ii].upper();
}
示例#4
0
str_list* _std str_copylines(str_list*list, u32t first, u32t last) {
   TStrings lst;
   if (first<=last) {
      str_getstrs(list,lst);
      if (lst.Count())
         if (first>=lst.Count()) lst.Clear(); else {
            if (last>=lst.Count()) last=lst.Max();
            if (++last!=lst.Count()) lst.Delete(last,lst.Count()-last);
            if (first) lst.Delete(0,first);
         }
   }   
   return str_getlist_local(lst.Str);
}
示例#5
0
//---------------------------------------------------------------------------
void __fastcall TAddressBook::AssignTo(TPersistent* Dest)
{
	TStrings *DestStrings = dynamic_cast<TStrings *>(Dest);

	if (DestStrings) {
		DestStrings->BeginUpdate();
		try {
			DestStrings->Clear();
			DestStrings->AddStrings(FNames);
		}
		__finally {
			DestStrings->EndUpdate();
		}
	}
}
示例#6
0
void splittext(const char *text, u32t width, TStrings &lst, u32t flags) {
   lst.Clear();
   if (!text || width<8) return;
   const char *ps = text, *pps;
   char    softcr = flags&SplitText_HelpMode?'&':0;
   int         ln = 0;
   spstr linehead;
   lst.Add(spstr());
   do {
      while (*ps && (strchr(AllowSet,*ps) || *ps==softcr)) {
         register char cr=*ps++;
         if (cr!=' ') {
            if (cr==softcr) {
               pps = ps;
               if (*pps) pps++;
               while (*pps==' ' || *pps=='\t') pps++;
               /* get 1 char after eol and all spaces after it and use result
                  as a header for all next lines until real cr */
               linehead = spstr(ps, pps-ps).expandtabs(4);
               ps = pps;
            } else {
               lst.Add(spstr());
               if (cr=='\r' && *ps=='\n') ps++;
               linehead.clear();
               if (lst[ln].lastchar()==' ') lst[ln].dellast();
               ln++;
            }
         }
      }
      if (*ps==0) break;
      pps = strpbrk(ps, softcr ? CarrySet AllowSet "&" : CarrySet AllowSet);
      int carry = pps&&strchr(CarrySet,*pps)?1:0;
      spstr curr(ps,pps?pps-ps+carry:0), sum;
      sum = lst[ln]+curr;
      sum.expandtabs(4);

      if ((flags&SplitText_NoAnsi?strlen:str_length)(sum())<width-2)
         lst[ln]=sum;
      else {
         lst.Add(linehead+curr);
         if (lst[ln].lastchar()==' ') lst[ln].dellast();
         ln++;
      }
      if (!carry||pps&&pps[1]==' ') lst[ln]+=' ';
      ps=pps;
      if (carry) ps++;
   } while (pps);
}
示例#7
0
TStrings * ExceptionToMoreMessages(Exception * E)
{
  TStrings * Result = nullptr;
  UnicodeString Message;
  if (ExceptionMessage(E, Message))
  {
    Result = new TStringList();
    Result->Add(Message);
    ExtException * ExtE = dyn_cast<ExtException>(E);
    if ((ExtE != nullptr) && (ExtE->GetMoreMessages() != nullptr))
    {
      Result->AddStrings(ExtE->GetMoreMessages());
    }
  }
  return Result;
}
示例#8
0
TStrings * ExceptionToMoreMessages(Exception * E)
{
  TStrings * Result = nullptr;
  UnicodeString Message;
  if (ExceptionMessage(E, Message))
  {
    Result = new TStringList();
    Result->Add(Message);
    ExtException * ExtE = NB_STATIC_DOWNCAST(ExtException, E);
    if ((ExtE != nullptr) && (ExtE->GetMoreMessages() != nullptr))
    {
      Result->AddStrings(ExtE->GetMoreMessages());
    }
  }
  return Result;
}
示例#9
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeChecklistDialog::CustomCommandsButtonClick(
  TObject * /*Sender*/)
{
  TStrings * LocalFileList = new TStringList();
  TStrings * RemoteFileList = new TStringList();
  try
  {
    TListItem * Item = ListView->Selected;
    assert(Item != NULL);

    while (Item != NULL)
    {
      const TSynchronizeChecklist::TItem * ChecklistItem =
        static_cast<const TSynchronizeChecklist::TItem *>(Item->Data);

      assert((ChecklistItem->Action == TSynchronizeChecklist::saUploadUpdate) ||
             (ChecklistItem->Action == TSynchronizeChecklist::saDownloadUpdate));
      assert(ChecklistItem->RemoteFile != NULL);

      UnicodeString LocalPath =
        IncludeTrailingBackslash(ChecklistItem->Local.Directory) +
        ChecklistItem->Local.FileName;

      LocalFileList->Add(LocalPath);

      UnicodeString RemotePath =
        UnixIncludeTrailingBackslash(ChecklistItem->Remote.Directory) +
        ChecklistItem->Remote.FileName;

      RemoteFileList->AddObject(RemotePath, ChecklistItem->RemoteFile);

      Item = ListView->GetNextItem(Item, sdAll, TItemStates() << isSelected);
    }
  }
  catch(...)
  {
    delete LocalFileList;
    delete RemoteFileList;
    throw;
  }

  assert(FOnCustomCommandMenu != NULL);
  FOnCustomCommandMenu(CustomCommandsButton,
    CalculatePopupRect(CustomCommandsButton), LocalFileList, RemoteFileList);
}
示例#10
0
//---------------------------------------------------------------------------
int get_userpass_input(prompts_t * p, unsigned char * /*in*/, int /*inlen*/)
{
  assert(p != NULL);
  TSecureShell * SecureShell = reinterpret_cast<TSecureShell *>(p->frontend);
  assert(SecureShell != NULL);

  int Result;
  TStrings * Prompts = new TStringList();
  TStrings * Results = new TStringList();
  try
  {
    for (int Index = 0; Index < int(p->n_prompts); Index++)
    {
      prompt_t * Prompt = p->prompts[Index];
      Prompts->AddObject(Prompt->prompt, (TObject *)(FLAGMASK(Prompt->echo, pupEcho)));
      // this fails, when new passwords do not match on change password prompt,
      // and putty retries the prompt
      assert(Prompt->resultsize == 0);
      Results->Add(L"");
    }

    if (SecureShell->PromptUser(p->to_server, p->name, p->name_reqd,
          p->instruction, p->instr_reqd, Prompts, Results))
    {
      for (int Index = 0; Index < int(p->n_prompts); Index++)
      {
        prompt_t * Prompt = p->prompts[Index];
        prompt_set_result(Prompt, AnsiString(Results->Strings[Index]).c_str());
      }
      Result = 1;
    }
    else
    {
      Result = 0;
    }
  }
  __finally
  {
    delete Prompts;
    delete Results;
  }

  return Result;
}
示例#11
0
文件: License.cpp 项目: elazzi/winscp
//---------------------------------------------------------------------------
__fastcall TLicenseDialog::TLicenseDialog(TComponent * Owner, TLicense License)
  : TForm(Owner)
{
  UseSystemSettings(this);

  TStrings * LicenseList = new TStringList();
  try
  {
    LicenseList->Text = ReadResource(LicenseStr[License]);
    assert(LicenseList->Count > 0);
    Caption = FMTLOAD(LICENSE_CAPTION, (LicenseList->Strings[0]));
    LicenseList->Delete(0);
    LicenseMemo->Lines->Text = LicenseList->Text;
  }
  __finally
  {
    delete LicenseList;
  }
}
示例#12
0
static void init_msg_ini(void) {
   if (!msg) {
      TStrings     ht;
      spstr   secname("help");
      msg = new_ini(msg_name());

      msg->ReadSection(secname, ht);
      /* merge strings, ended by backslash. ugly, but allows more friendly
         editing of msg.ini */
      l ii=0, lp;
      while (ii<ht.Count()) {
         if (ht[ii].trim().lastchar()=='\\') {
            ht[ii].dellast()+=ht.MergeBackSlash(ii+1,&lp);
            ht.Delete(ii+1, lp-ii-1);
         }
         ii++;
      }
      msg->WriteSection(secname, ht, true);
   }
}
示例#13
0
//---------------------------------------------------------------------------
void __fastcall TPropertiesDialog::LoadRemoteTokens(TComboBox * ComboBox,
  const TRemoteTokenList * List)
{
  TStrings * Items = ComboBox->Items;
  Items->BeginUpdate();
  try
  {
    Items->Clear();
    if (List != NULL)
    {
      int Count = List->Count();
      for (int Index = 0; Index < Count; Index++)
      {
        Items->Add(LoadRemoteToken(*List->Token(Index)));
      }
    }
  }
  __finally
  {
    Items->EndUpdate();
  }
}
示例#14
0
//---------------------------------------------------------------------------
int __fastcall TThdSend::GetScheme(TScheme *Scheme,String SchemeName)
{
  String      NodeName  = "自动派发";
  String      FileName  = String(TRjlSysVar()()->TradePath) + "\\TradeScheme.xml";
  TStringList *attr     = new TStringList();
  TStringList *cond     = new TStringList();

  if(SchemeName==""){
    TStrings *Header    = new TStringList();

    Header->Clear();
    TRjlXML::GetHead(FileName,Header);
    SchemeName = Header->Values["DftSend"];  //方案名为空的话取默认方案

    delete Header;
  }

  cond->Add("Name="+SchemeName);
  if(TRjlXML::GetNode(FileName,NodeName,cond,attr)<=0) {delete cond;delete attr;return -1;}
  if(attr->Count>0){
    Scheme->Name          = SchemeName;
    Scheme->ConsignPrice  = StrToInt(attr->Values["ConsignPrice"]);
    Scheme->FloatMny      = TRjlFunc::StrToDouble(attr->Values["FloatMny"]);
    Scheme->VolPercent    = TRjlFunc::StrToDouble(attr->Values["VolPercent"]);
    Scheme->VolScheme     = StrToInt(attr->Values["VolScheme"]);
    Scheme->Vol1          = StrToInt(attr->Values["Vol1"]);
    Scheme->Vol2          = StrToInt(attr->Values["Vol2"]);
    Scheme->TrdSec        = StrToInt(attr->Values["TrdSec"]);
    Scheme->Sec1          = StrToInt(attr->Values["Sec1"]);
    Scheme->Sec2          = StrToInt(attr->Values["Sec2"]);
    Scheme->TrdCancelTime = StrToInt(attr->Values["TrdCancelTime"]);
    Scheme->TrdCancelPrc  = TRjlFunc::StrToDouble(attr->Values["TrdCancelPrc"]);
  }

  delete cond;
  delete attr;
  return 0;
}
示例#15
0
//---------------------------------------------------------------------------
void __fastcall Download(TTerminal * Terminal, const UnicodeString FileName,
                         bool UseDefaults)
{
    UnicodeString TargetDirectory;
    TGUICopyParamType CopyParam = GUIConfiguration->DefaultCopyParam;
    TStrings * FileList = NULL;

    try
    {
        FileList = new TStringList();
        TRemoteFile * File = Terminal->Files->FindFile(FileName);
        if (File == NULL)
        {
            throw Exception(FMTLOAD(FILE_NOT_EXISTS, (FileName)));
        }
        FileList->AddObject(FileName, File);
        UnicodeString LocalDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
        if (LocalDirectory.IsEmpty())
        {
            LocalDirectory = GetPersonalFolder();
        }
        TargetDirectory = IncludeTrailingBackslash(LocalDirectory);

        int Options = coDisableQueue;
        int CopyParamAttrs = Terminal->UsableCopyParamAttrs(0).Download;
        if (UseDefaults ||
                DoCopyDialog(false, false, FileList, TargetDirectory, &CopyParam,
                             Options, CopyParamAttrs, NULL))
        {
            Terminal->CopyToLocal(FileList, TargetDirectory, &CopyParam, 0);
        }
    }
    __finally
    {
        delete FileList;
    }
}
示例#16
0
	bool SearchFiles(const TString& directory, TStrings & files, bool subFolders, const TString & mask)
	{
		if(!IsDirectoryExists(directory.c_str()))
			return false;

		TString path;
		HANDLE hFind;
		WIN32_FIND_DATA findData;
		TString searchPath;

		if(subFolders)
		{
			searchPath = CreatePath(directory, TEXT("*"));
			hFind = ::FindFirstFile(searchPath.c_str(), &findData);
			if(hFind != INVALID_HANDLE_VALUE) 
			{
				do 
				{
					TString name = findData.cFileName;
					if(name == TEXT(".") || name == TEXT(".."))
						continue;
					if((findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
						SearchFiles(CreatePath(directory, name), files, subFolders, mask);
				} while(::FindNextFile(hFind, &findData)); 
				::FindClose(hFind);
			}
		}

		searchPath = CreatePath(directory, mask);
		hFind = ::FindFirstFile(searchPath.c_str(), &findData);
		if(hFind != INVALID_HANDLE_VALUE) 
		{
			do 
			{
				TString name = findData.cFileName;
				if(name == TEXT(".") || name == TEXT(".."))
					continue;
				if((findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) == 0)
					files.push_back(CreatePath(directory, name));
			} while(::FindNextFile(hFind, &findData)); 
			::FindClose(hFind);
		}

		return true;
	}
示例#17
0
/** return FS detection list.
    Function returns parsed [fsdetect] section contents, in the single module
    owned heap block. Last entry in this list is zero-filled */
fs_detect_list* ecmd_readfsdetect() {
   TStrings lst;
   if (!ecmd_readsec("fsdetect",lst)) return 0;

   u32t ii, blen = 0, nlen = 0, ecnt = 0;
   for (ii=0; ii<lst.Count(); ii++) {
      // filter out commented lines
      if (lst[ii][0]!=';') {
         spstr val = lst.Value(ii);
         if (val.words(",")==2) {
            blen += val.word(2,",").words();
            nlen += lst.Name(ii).trim().length()+1;
            ecnt++;
            continue;
         }
      }
      lst[ii].clear();
   }
   if (!blen || !nlen) return 0;
   // alloc/calc block pointers
   u32t        listlen = sizeof(fs_detect_list)*(ecnt+1), idx;
   fs_detect_list *res = (fs_detect_list*)malloc(listlen+blen+nlen);
   char          *nptr = (char*)res + listlen;
   u8t           *dptr = (u8t*)nptr + nlen;
   // zero last entry
   memset(res+ecnt, 0, sizeof(fs_detect_list));
   // build return information in the single memory block
   for (ii=0, idx=0; ii<lst.Count(); ii++)
      if (lst[ii].length()) {
         spstr  val = lst.Value(ii),
                key = lst.Name(ii).trim();
         spstr bstr = val.word(2,",");

         res[idx].fsname  = nptr;
         res[idx].offset  = val.word_Dword(1,",");
         res[idx].size    = bstr.words();
         res[idx].cmpdata = dptr;
         // fa name
         memcpy(nptr, key(), key.length()+1);
         nptr += key.length()+1;
         // binary data to cmp
         for (u32t ll=0; ll<res[idx].size; ll++)
            *dptr++ = strtoul(bstr() + bstr.wordpos(ll+1), 0, 16);
         idx++;
      }
   return res;
}
示例#18
0
//---------------------------------------------------------------------------
void __fastcall TSup1011::addItensExecute(TObject *Sender)
{
	TStrings *SQL = new TStringList();
	SQL->Add("SELECT p.cod_produto, p.den_produto, p.cod_unid_medida, 0 val_produto");
	SQL->Add("FROM tbl_produto p");
	SQL->Add("WHERE p.cod_familia = :cod_familia");
	SQL->Add("AND p.ies_ativo = 'S'");
	SQL->Add("ORDER BY p.cod_produto");
	TSup1004 *Sup1004 = new TSup1004(Application);
	Sup1004->OnConfirmList = &addItensConfirm;
	Sup1004->QyCnsProduto->SQL->Assign(SQL);
   Sup1004->edtQtd->Text = '1';
   Sup1004->edtQtd->Visible = false;
   Sup1004->lbQtde->Visible = false;
	Sup1004->ShowModal();
   delete Sup1004;
	delete SQL;
}
示例#19
0
str_list* get_keylist(TINIFile  *ini, const char *Section, str_list**values) {
   TStrings lst;
   ini->ReadSectionKeys(Section,lst);
   if (!values) {
      lst.TrimEmptyLines();
   } else {
      TStrings vlst;
      ini->ReadSectionValues(Section,vlst);
      int ii;
      while (ii<=lst.Max()) {
         spstr sk(lst[ii]), sv(vlst[ii]);
         if (!sk.trim().length() && !sv.trim().length())
            { lst.Delete(ii); vlst.Delete(ii); } else ii++;
      }
      *values = str_getlist_local(vlst.Str);
   }
   return str_getlist_local(lst.Str);
}
示例#20
0
char* _std str_mergeargs(str_list*list) {
   TStrings lst;
   str_getstrs(list,lst);
   return strdup(lst.MergeCmdLine()());
}
示例#21
0
//---------------------------------------------------------------------------
void __fastcall TConfiguration::CopyData(THierarchicalStorage * Source,
  THierarchicalStorage * Target)
{
  TStrings * Names = new TStringList();
  try
  {
    if (Source->OpenSubKey(ConfigurationSubKey, false))
    {
      if (Target->OpenSubKey(ConfigurationSubKey, true))
      {
        if (Source->OpenSubKey(L"CDCache", false))
        {
          if (Target->OpenSubKey(L"CDCache", true))
          {
            Names->Clear();
            Source->GetValueNames(Names);

            for (int Index = 0; Index < Names->Count; Index++)
            {
              Target->WriteBinaryData(Names->Strings[Index],
                Source->ReadBinaryData(Names->Strings[Index]));
            }

            Target->CloseSubKey();
          }
          Source->CloseSubKey();
        }

        if (Source->OpenSubKey(L"Banners", false))
        {
          if (Target->OpenSubKey(L"Banners", true))
          {
            Names->Clear();
            Source->GetValueNames(Names);

            for (int Index = 0; Index < Names->Count; Index++)
            {
              Target->WriteString(Names->Strings[Index],
                Source->ReadString(Names->Strings[Index], L""));
            }

            Target->CloseSubKey();
          }
          Source->CloseSubKey();
        }

        Target->CloseSubKey();
      }
      Source->CloseSubKey();
    }

    if (Source->OpenSubKey(SshHostKeysSubKey, false))
    {
      if (Target->OpenSubKey(SshHostKeysSubKey, true))
      {
        Names->Clear();
        Source->GetValueNames(Names);

        for (int Index = 0; Index < Names->Count; Index++)
        {
          Target->WriteStringRaw(Names->Strings[Index],
            Source->ReadStringRaw(Names->Strings[Index], L""));
        }

        Target->CloseSubKey();
      }
      Source->CloseSubKey();
    }
  }
  __finally
  {
    delete Names;
  }
}
示例#22
0
//---------------------------------------------------------------------------
bool __fastcall TLocationProfilesDialog::AddAsBookmark(TObject * Sender, bool Initial)
{
  TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  TTreeView * ProfilesView = GetProfilesView(Sender);

  assert(!LocalDirectory.IsEmpty() || !RemoteDirectory.IsEmpty());

  bool Result;
  UnicodeString BookmarkName;
  if ((OperationSide == osLocal && !LocalDirectory.IsEmpty()) ||
      RemoteDirectory.IsEmpty())
  {
    BookmarkName = LocalDirectory;
  }
  else
  {
    BookmarkName = RemoteDirectory;
  }

  TTreeNode * Selected = ProfilesView->Selected;
  TBookmark * SelectedBookmark = NULL;
  UnicodeString SelectedNode;
  if (Selected != NULL)
  {
    assert(!Initial);
    SelectedBookmark = (TBookmark *)Selected->Data;
    if (SelectedBookmark != NULL)
    {
      SelectedNode = SelectedBookmark->Node;
    }
    else
    {
      SelectedNode = Selected->Text;
    }
  }

  TStrings * PeerBookmarks = new TStringList();
  try
  {
    for (int Index = 0; Index < BookmarkList->Count; Index++)
    {
      TBookmark * Bookmark = BookmarkList->Bookmarks[Index];
      if (Bookmark->Node == SelectedNode)
      {
        PeerBookmarks->Add(Bookmark->Name);
      }
    }

    TBookmarkNameDialog * Dialog = new TBookmarkNameDialog(PeerBookmarks, Initial);
    try
    {
      bool Shared = WinConfiguration->UseSharedBookmarks;
      Result = Dialog->Execute(BookmarkName, Shared);
      if (Result)
      {
        if (Initial)
        {
          WinConfiguration->UseSharedBookmarks = Shared;
          BookmarkList = GetBookmarkList(GetProfilesSheet());
          ProfilesView = GetProfilesView(GetProfilesSheet());
        }

        TBookmark * Bookmark = BookmarkList->FindByName(SelectedNode, BookmarkName);
        if (Bookmark != NULL)
        {
          Bookmark->Local = LocalDirectory;
          Bookmark->Remote = RemoteDirectory;

          for (int Index = 0; Index < ProfilesView->Items->Count; Index++)
          {
            TTreeNode * Node = ProfilesView->Items->Item[Index];
            if (Node->Data == Bookmark)
            {
              Selected = Node;
              break;
            }
          }
        }
        else
        {
          Bookmark = new TBookmark();
          Bookmark->Name = BookmarkName;
          Bookmark->Local = LocalDirectory;
          Bookmark->Remote = RemoteDirectory;
          if (SelectedBookmark != NULL)
          {
            Bookmark->Node = SelectedBookmark->Node;
            BookmarkList->InsertBefore(SelectedBookmark, Bookmark);
            Selected = ProfilesView->Items->InsertObject(Selected, BookmarkText(Bookmark), Bookmark);
          }
          else if ((Selected != NULL) && (SelectedBookmark == NULL))
          {
            // must be a folder
            assert(!Selected->Parent); // more than one level of folders is not supported
            Bookmark->Node = Selected->Text;
            BookmarkList->Add(Bookmark);
            Selected = ProfilesView->Items->AddChildObject(Selected, BookmarkText(Bookmark), Bookmark);
          }
          else
          {
            BookmarkList->Add(Bookmark);
            Selected = ProfilesView->Items->AddObject(NULL, BookmarkText(Bookmark), Bookmark);
          }
        }
        ProfilesView->Selected = Selected;
      }
    }
    __finally
    {
      delete Dialog;
    }
  }
  __finally
  {
    delete PeerBookmarks;
  }

  UpdateControls();
  return Result;
}
// ---------------------------------------------------------------------------
void __fastcall TFrPrintProductCatalog::LoadPicList(TStrings *NameUser,
	TStrings *Status, TStrings *Activities_KC, TStrings *ComboBox9)
{ // Загрузка нового листа выбора
	TStrings *S;
	AnsiString Sl;
	TField *F, *Fi;
	TADOQuery *Qi;
	Qi = Qw;

	if (Status != NULL) {
		S = Status;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select 0,' Не распределен' union select idn,iText from spl_LbText256 where iLvl=1156 and datedel is null Order by 2 "
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}
	if (Activities_KC != NULL) {
		S = Activities_KC;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select Idn,iText from spl_LbText256 where iLvl=1199 and DateDel is null"
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}
	if (ComboBox9 != NULL) {
		S = ComboBox9;
		Qi->Close();
		Qi->SQL->Clear();
		Qi->SQL->Add
			("select -1,' ВСЕ' union select 0,' Нет менеджера' union SELECT idManager,u.auFamIO FROM cch_CallManager LEFT JOIN aa_Users u on u.auId=idManager WHERE TypeM=0 ORDER BY 2 "
			);
		Qi->Open();
		Fi = Qi->Fields->Fields[0];
		F = Qi->Fields->Fields[1];
		S->Clear();
		while (Qi->Eof == false) {
			S->AddObject(F->AsString, (TObject*)Fi->AsInteger);
			Qi->Next();
		}
		Qi->Close();
	}

}
示例#24
0
// split string to items. result must be freed by single free() call
str_list* __stdcall str_split(const char *str,const char *separators) {
   TStrings lst;
   lst.SplitString(str,separators);
   for (int ii=0;ii<=lst.Max();ii++) lst[ii].trim();
   return str_getlist_local(lst.Str);
}
示例#25
0
str_list* _std str_settext(const char *text, u32t len) {
   TStrings lst;
   lst.SetText(text,len);
   for (int ii=0;ii<=lst.Max();ii++) lst[ii].trimright();
   return str_getlist_local(lst.Str);
}
示例#26
0
str_list* __stdcall str_splitargs(const char *str) {
   TStrings lst;
   lst.ParseCmdLine(str);
   return str_getlist_local(lst.Str);
}
示例#27
0
int get_ini_parms(void) {
   char *mainini = (char*)sto_data(STOKEY_INIDATA);
   u32t     size = sto_size(STOKEY_INIDATA);
   u32t  pciscan = 0;
   int        rc = 0;
   spstr  dbcard;
   // init was saved by pointer, not as data copy
   sto_del(STOKEY_INIDATA);

   /* we have root environment here, so just storing keys for any other
      feature apps */
   u32t htype = hlp_hosttype();
   if (htype>=QSHT_BIOS && htype<=QSHT_EFI) {
      // scan all PCI buses on EFI by default
      if (htype==QSHT_EFI) pciscan = 1;
      setenv("HOSTTYPE", hoststrs[htype], 1);
   }

   u32t btype = hlp_boottype();
   if (btype>QSBT_NONE && btype<=QSBT_SINGLE) {
      setenv("BOOTTYPE", bootstrs[btype-1], 1);
      log_printf("boot type: %s!\n", bootstrs[btype-1]);
   }

   if (mainini) {
      log_printf("ini: %d bytes!\n",size);
      TStrings  ifl;
      ifl.SetText(mainini,size);
      hlp_memfree(mainini);
      if (!ifl.SaveToFile(ini_name)) log_printf("failed to copy ini!\n");

      TINIFile  ini(&ifl);
      dbcard    = ini.ReadStr(cfg_section,"DBCARD");
      pciscan   = ini.ReadInt(cfg_section, "PCISCAN_ALL", pciscan);
      no_tgates = ini.ReadInt(cfg_section,"NOTASK");
      msg_name  = ini.ReadStr(shell_section, "MESSAGES");
      ecmd_name = ini.ReadStr(shell_section, "EXTCOMMANDS");
      mod_delay = ini.ReadInt(cfg_section, "UNZALL", 0) ? 0 : 1;
      ctrln_d0  = ini.ReadInt(cfg_section,"CTRLN");
      rc        = ini.ReadInt(cfg_section,"REIPL");
      if (rc>0) reipltime = rc;
      // disable clock in menu
      rc        = ini.ReadInt(cfg_section,"NOCLOCK");
      if (rc>0 || hlp_insafemode()) setenv("MENU_NO_CLOCK", "YES", 1); else
         if (rc<0) env_setvar("MENU_NO_CLOCK", -1);

      u32t heapflags = ini.ReadInt(cfg_section,"HEAPFLAGS");
      mem_setopts(heapflags&0xF);

      rc = 1;
   } else
      log_printf("no file!\n");
   // save value
   sto_savedword(STOKEY_PCISCAN, pciscan);
   // set default names if no ini file or key in it
   if (!msg_name)  msg_name  = msg_path;
   if (!ecmd_name) ecmd_name = ECMD_PATH;
   // call DBCARD processing (only after pciscan was saved!)
   if (dbcard.length()) {
      rc = shl_dbcard(dbcard, log_printf);
      if (rc) log_printf("DBCARD setup err %d!\n", rc);
   }
   return rc;
}
示例#28
0
static void _std getlog(log_header *log, void *extptr) {
   getloginfo *pli = (getloginfo*)extptr;
   int    puretext = (pli->flags&(LOGTF_DATE|LOGTF_TIME|LOGTF_LEVEL))==0;

   if (puretext) {
      spstr ltext;
      while (log->offset) {
         if ((log->flags&LOGIF_USED)!=0 && ((pli->flags&LOGTF_LEVEL)==0 ||
           (pli->flags&LOGTF_LEVELMASK)>=(log->flags&LOGIF_LEVELMASK)))
         {
            ltext+=(char*)(log+1);
         }
         log+=log->offset;
      }
      if (pli->flags&LOGTF_DOSTEXT) ltext.replace("\n","\r\n");
      // make copy a bit faster
      pli->rc = (char*)malloc(ltext.length()+1);
      memcpy(pli->rc, ltext(), ltext.length());
      pli->rc[ltext.length()] = 0;
   } else {
      TStrings    lst;
      struct tm    dt;
      u32t      pdtme = 0;
      time_t     ptme;

      while (log->offset) {
         if ((log->flags&LOGIF_USED)!=0 && ((pli->flags&LOGTF_LEVEL)==0 ||
           (pli->flags&LOGTF_LEVELMASK)>=(log->flags&LOGIF_LEVELMASK)))
         {
            if (pdtme!=log->dostime) {
               dostimetotm(pdtme=log->dostime,&dt);
               ptme = mktime(&dt);
            }
            spstr estr, astr;

            if (pli->flags&LOGTF_DATE)
               estr.sprintf("%02d.%02d.%02d ",dt.tm_mday,dt.tm_mon+1,dt.tm_year-100);
            if (pli->flags&LOGTF_TIME) {
               int sec = dt.tm_sec;
               if (log->flags&LOGIF_SECOND) sec++;
               astr.sprintf("%02d:%02d:%02d ",dt.tm_hour, dt.tm_min, sec);
               estr+=astr;
            }
            if (pli->flags&LOGTF_LEVEL) {
               if (pli->flags&LOGTF_FLAGS)
                  astr.sprintf("[%c%d%c] ",log->flags&LOGIF_REALMODE?'r':' ',
                     log->flags&LOGIF_LEVELMASK,log->flags&LOGIF_DELAY?'d':' ');
               else
                  astr.sprintf("[%d] ",log->flags&LOGIF_LEVELMASK);
               estr+=astr;
            }
            estr+=(char*)(log+1);
            if (estr.lastchar()=='\n') estr.dellast();
            lst.AddObject(estr,ptme);
         }
         log+=log->offset;
      }
      int ii,jj;
      const char *eol = pli->flags&LOGTF_DOSTEXT?"\r\n":"\n";

      log_it(2, "%d lines of log queried\n", lst.Count());

      for (ii=1;ii<lst.Count();ii++)
         // we`re can`t fill entire log for 3 seconds
         if (lst.Objects(ii-1)-lst.Objects(ii)>3) break;
      // re-order cyclic added lines
      if (ii<lst.Count()) {
         spstr t1 = lst.GetTextToStr(eol,ii),
               t2 = lst.GetTextToStr(eol,0,ii);
         pli->rc = (char*)malloc(t1.length()+t2.length()+1);
         memcpy(pli->rc, t1(), t1.length());
         memcpy(pli->rc+t1.length(), t2(), t2.length()+1);
      } else
         pli->rc = lst.GetText(eol);
   }
}
示例#29
0
/// create list from array of char*
str_list* _std str_fromptr(char **list, int size) {
   TStrings lst;
   if (list&&size>0)
      while (size--) lst.Add(*list++);
   return str_getlist_local(lst.Str);
}
示例#30
0
char* _std str_gettostr(str_list*list, char *separator) {
   TStrings lst;
   str_getstrs(list,lst);
   return lst.GetText(separator?separator:"");
}