Ejemplo n.º 1
0
// this version of AddString adds a string only if it doesn't already exist
// in the list, and in any case, makes sure that the string is the first
// in the list (ie most recent in history)
// also makes sure number of items in the list doesn't exceed the maximum allowed
int CHistoryCombo::AddString(LPCTSTR lpszString)
{
	CString sString(lpszString);

	// if it's not set up as a history combo then call base class
	if (m_sSection.IsEmpty() || m_sKeyPrefix.IsEmpty())
		return CComboBox::AddString(lpszString);

	int nRet = -1;

	// don't add if already there
	sString.TrimLeft();
	sString.TrimRight();

	if (sString.IsEmpty())
	{
		TRACE(_T("ERROR  string is empty\n"));
		return CB_ERR;
	}

	nRet = CComboBox::InsertString(0, sString);
	int nIndex = FindStringExact(0, sString);
	if (nIndex != -1 && nIndex != 0)
		DeleteString(nIndex);

	// if we've got too many items then delete the last one
	// truncate list to m_nMaxHistoryItems
	int nNumItems = GetCount();
	for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
		DeleteString(m_nMaxHistoryItems);

	SetCurSel(nRet);
	return nRet;
}
Ejemplo n.º 2
0
/*
 * FiniProfile - free the profile path strings
 */
void FiniProfile( void )
{
    DeleteString( &cfgFile );
    DeleteString( &iniFile );
    DeleteString( &iniPath );

} /* FiniProfile */
Ejemplo n.º 3
0
BOOL CSplitPointList::OnCommand(WPARAM wParam, LPARAM lParam)
{
    // TODO: Speziellen Code hier einfügen und/oder Basisklasse aufrufen
    AddSplitPointDlg*	aspd;
    DWORD				dwSplitPos;
    int					iIndex;
    char				Buffer[200];

    switch (LOWORD(wParam))
    {
    case IDM_ADDSPLITPOINT:
        aspd=new AddSplitPointDlg;
        aspd->SetSplitPos(0);
        if (aspd->DoModal())
        {
            dwSplitPos=aspd->GetSplitPos();
            if (CheckSplitPoint(dwSplitPos)) AddSplitPoint(dwSplitPos);
        }
        delete aspd;
        break;
    case IDM_REMOVESPLITPOINT:
        iIndex=GetCurSel();
        if (iIndex!=LB_ERR)
        {
            DeleteString(iIndex);
        }
        break;
    case IDM_CHANGESPLITPOINT:
        iIndex=GetCurSel();
        if (iIndex!=LB_ERR)
        {
            GetText(iIndex,Buffer);
            aspd=new AddSplitPointDlg;
            aspd->SetSplitPos(atoi(Buffer));
            if (aspd->DoModal())
            {
                dwSplitPos=aspd->GetSplitPos();
                if (CheckSplitPoint(dwSplitPos))
                {
                    DeleteString(iIndex);
                    AddSplitPoint(dwSplitPos);
                }
            }
            delete aspd;
        }
        break;
    }

    return CListBox::OnCommand(wParam, lParam);
}
Ejemplo n.º 4
0
int CSmartComboBox::AddString(LPCTSTR str)
{
	if( _tcslen(str) == 0 )
		return -1;

	int oldIndex = FindStringExact(-1, str);
	if( oldIndex >= 0 )
		DeleteString(oldIndex);

	if( GetCount() == m_nMaxStrings )
		DeleteString(m_nMaxStrings-1);

	return CComboBox::InsertString(0, str);
}
Ejemplo n.º 5
0
void DeleteChannel(channel *Channel) {

   if (Channel == NULL) {
      Error("DeleteChannel(): Channel = NULL");
      return;
   } else if (Channel->Type != CHANNEL) {
      Error("DeleteChannel(): \"%s\" is not a channel",Channel->Id);
      return;
   }

   DeleteString(&Channel->Id);
   DeleteString(&Channel->Topic);

   free(Channel);
}
Ejemplo n.º 6
0
void CGuiEdit::AjustaCadena(int nStartPos,int  nEndPos )
{
	
	int numCharMove=0;
	int LastChar=FindLasCharR(); //el ultimo caracter valido de la cadena
	int LastCharDel=LastChar;
	int init =nStartPos;
	for (int i=nStartPos; i <= LastChar; i++)
	{
			int nNext = GetNextPos(nStartPos);
			if (IsValidChar(m_szShowMask.GetAt(i),nNext) || m_szShowMask.GetAt(i)==m_cadResult.GetAt(i))//el caracter se puede mover a esa posicion			
			{
				//se mueve el caracter
				m_szShowMask.SetAt(nStartPos,m_szShowMask.GetAt(nNext));			
				//se reemplaza la ultima posicion despues del ultimo caracter con el
				//equivalente en la mascara
				//obtenemos la proxima posicion donde se moveria el proximo caracter
				nStartPos = GetNextPos(nStartPos);
				numCharMove++;
			}
		
	}
	DeleteString(LastCharDel,LastCharDel);
	SetSel(init,init);	
	m_KeySpecial=0;

}
BOOL COXHistoryCombo::DeleteItem(int nItemIndex /* = -1 */)
{
	ASSERT_VALID(this);

	if (nItemIndex == -1)
		// ... No index was specified, get the current selection
		nItemIndex = GetCurSel();

	BOOL bSuccess = (DeleteString(nItemIndex) != CB_ERR);

	if (bSuccess)
	{
		// Select the next item if it exists
		if (nItemIndex < GetCount())
		{
			// ... Items have shifted up, select the same index
			SetCurSel(nItemIndex);

			CWnd* pParentWnd=GetParent();
			if(pParentWnd!=NULL)
			{
				pParentWnd->SendMessage(WM_COMMAND,
					MAKEWPARAM(GetDlgCtrlID(),CBN_SELCHANGE),(LPARAM)GetSafeHwnd());
			}
		}
		else
			// ... Last item was deleted, select the current last one (may not exist if the list is empty)
			SetCurSel(nItemIndex - 1);
	}
	return bSuccess;
}
Ejemplo n.º 8
0
BOOL CUrlBox::PreTranslateMessage(MSG* pMsg)
{
	if ((pMsg->message != WM_KEYDOWN))
		return CComboBox::PreTranslateMessage(pMsg);

    if (pMsg->wParam != VK_RETURN)
       return CComboBox::PreTranslateMessage(pMsg);

	// when the enter key is hit in the ComboBox we want to add the string
	// to the top of the list and hilight it.  We also want to limit the
	// list to the last 15 entries.
	if ((pMsg->lParam & 0x40000000) == 0)   // Not a repeat.
	{
		CString strText;
		GetWindowText(strText);

		InsertString(0, strText);
		SetCurSel(0);
      
      m_curSel = 0;

		if (GetCount() > 150)
			DeleteString(GetCount()-1);


      CMyglView* pView = ((CMyglApp *) AfxGetApp())->GetActiveView();
      if (pView) { pView->ReadUrl( strText); }

	}
	return TRUE;
}
/*
 * Elimina un nodo del árbol.
 */
void DeleteString(int p) {
  int  replacement;
  /* Si el nodo a borrar no está en el árbol, no hacemos nada. */
  if ( tree[ p ].parent == UNUSED )
    return;
  /* Si el nodo a borrar sólo tiene un hijo, hacemos una contracción
     del árbol. */
  if ( tree[ p ].larger_child == UNUSED )
    ContractNode( p, tree[ p ].smaller_child );
  else if ( tree[ p ].smaller_child == UNUSED )
    ContractNode( p, tree[ p ].larger_child );
  /* Si el nodo a borrar tiene ambos descendientes. */
  else {
    /* Localizamos el siguiente nodo más pequeño que el nodo que
       intentamos borrar. */
    replacement = FindNextNode( p );
    /* Eliminaos el siguiente nodo más pequeño del árbol. Nótese que
       el nodo "replacemente" nunca va a tener los dos descendientes,
       lo que evita entrar en más de un nivel de recursión. */
    DeleteString( replacement );
    /* Sustituimos el nodo que estamos intentanbo borrar por el que
       acabamos de localizar y eliminar el árbol. */
    ReplaceNode( p, replacement );
  }
}
Ejemplo n.º 10
0
void CProgressListBox::UpdateItems(int nLimit, bool bUpdateSize)
{
	// delete items from array
	if(m_vItems.size() > nLimit)
	{
		std::vector<_PROGRESSITEM_*>::iterator iterStart = m_vItems.begin() + nLimit;
		for(std::vector<_PROGRESSITEM_*>::iterator iterPos = iterStart; iterPos != m_vItems.end(); ++iterPos)
		{
			delete *iterPos;
		}
		m_vItems.erase(iterStart, m_vItems.end());
	}
	// change count of elements in a listbox
	if (GetCount() != m_vItems.size())
	{
		while (GetCount() < m_vItems.size())
			AddString(_T(""));

		while (GetCount() > m_vItems.size())
			DeleteString(m_vItems.size());
	}

	if (bUpdateSize)
	{
		Invalidate();
		RecalcHeight();
	}
}
Ejemplo n.º 11
0
void CBetPoolListBox::DeleteIndex(int iIndex)
{
	PoolBox_AppendData * pData = (PoolBox_AppendData *)GetItemDataPtr(iIndex);

	if ( NULL != pData ) {
		delete pData->pSta0;
		pData->pSta0 = NULL ;

		delete pData->pBut2;
		pData->pBut2 = NULL ;

		delete pData->pSta1;
		pData->pSta1 = NULL ;

		delete pData->pSta3;
		pData->pSta3 = NULL;

		delete pData->pSta2;
		pData->pSta2 = NULL ;

		delete pData;
		pData = NULL;
	}

	DeleteString(iIndex);
	button_betmap::iterator iter = m_mButton.find(iIndex);
	if (iter != m_mButton.end())
	{
		m_mButton.erase(iter);
	}

}
Ejemplo n.º 12
0
int CListBoxST::Move(int nOldIndex, int nNewIndex, BOOL bSetCurSel)
{
	int				nInsertedIndex = LB_ERR;
	CString			sText;
	STRUCT_LBDATA*	lpLBData = NULL;
	STRUCT_LBDATA 	csLBData;

	// If index is out of range
	if ((UINT)nOldIndex >= (UINT)GetCount())	return LB_ERR;

	// Get item text
	GetText(nOldIndex, sText);
	// Get associated data
	::ZeroMemory(&csLBData, sizeof(csLBData));
	lpLBData = (STRUCT_LBDATA*)CListBox::GetItemData(nOldIndex);
	if (lpLBData != (LPVOID)-1L)
	{
		::CopyMemory(&csLBData, lpLBData, sizeof(csLBData));
	} // if
	// Delete string
	DeleteString(nOldIndex);
	// Insert string at new position
	nInsertedIndex = InsertString(nNewIndex, sText);
	// Restore associated data
	ReplaceItemData(nInsertedIndex, csLBData.dwItemData, csLBData.pData, csLBData.nImage, csLBData.dwFlags, MASK_ALL);

	// Select item
	if (bSetCurSel && nInsertedIndex != LB_ERR && nInsertedIndex != LB_ERRSPACE)
		SetCurSel(nInsertedIndex);

	return nInsertedIndex;
} // End of Move
Ejemplo n.º 13
0
Archivo: lzss.cpp Proyecto: kilitary/ss
void CompressFile ( FILE *input, BFILE *output)
{
	int i;
	int c;
	int look_ahead_bytes;
	int current_pos;
	int replace_count;
	int match_len;
	int match_pos;
	
	current_pos = 1;
	
	for ( i = 0; i < LOOK_AHEAD_SIZE; i++)
	{
		if ( (c = getc (input)) == EOF )
			break;
		window [current_pos + i] = (uchar) c;
	}
	
	look_ahead_bytes = i;
	InitTree (current_pos);
	match_len = 0;
	match_pos = 0;
	
	while (look_ahead_bytes > 0)
	{
		if (match_len > look_ahead_bytes)
			match_len = look_ahead_bytes;
		if (match_len <= BREAK_EVEN)
		{
			replace_count = 1;
			WriteBit ( output, 1);
			WriteBits ( output, (ulong) window [current_pos], 8);
		}
		else
		{
			WriteBit  ( output, 0);
			WriteBits ( output, (ulong) match_pos, INDEX_BITS);
			WriteBits ( output, (ulong) ( match_len - (BREAK_EVEN + 1)),
				LENGTH_BITS);
			replace_count = match_len;
		}
		
		for ( i = 0; i < replace_count; i++)
		{
			DeleteString ( MODULO (current_pos + LOOK_AHEAD_SIZE));
			if ( (c = getc (input)) == EOF )
				look_ahead_bytes--;
			else
				window [MODULO (current_pos + LOOK_AHEAD_SIZE)] = (uchar) c;
			current_pos = MODULO (current_pos + 1);
			if (look_ahead_bytes)
				match_len = AddString ( current_pos, &match_pos);
		}
	}
	
	WriteBit  ( output, 0);
	WriteBits ( output, (ulong) END_OF_STREAM, INDEX_BITS);
}
Ejemplo n.º 14
0
//@doc SECEdit
//@mfunc Internal function.  Cuts the column of text from pStartPos to pEndPos, 
//              from column pStartPos->iOffset to pEndPos->iOffset.
//@rdesc int 
//@parm PTEXTPOS pStartPos
//@parm  PTEXTPOS pEndPos
//@parm  BOOL bSaveUndoRecord
int SECEdit::ColumnCut(PTEXTPOS pStartPos, PTEXTPOS pEndPos, BOOL bSaveUndoRecord)
   {
   int iRval;
   UNDORECORD UndoRecord;
   LPSTR lpText;
   PLINEDESC pLine;
   TEXTPOS TextPos;
   TEXTPOS StartPos,EndPos;

   if (m_bReadOnly)
      return IDS_OE_READONLY;

   // column blocks may not be in order...
   if (!InOrder(pStartPos,pEndPos))
      {
      StartPos = *pEndPos;
      EndPos = *pStartPos;
      }
   else
      {
      StartPos = *pStartPos;
      EndPos = *pEndPos;
      }

   iRval = 0;

	UndoRecord.iCol    = StartPos.iOffset;
	UndoRecord.iEndCol = EndPos.iOffset;

	if (bSaveUndoRecord)
		{
		UndoRecord.iRow    = GetLineNo(StartPos.pLine);
		UndoRecord.iEndRow = GetLineNo(EndPos.pLine);
		UndoRecord.iUndoType = OE_UNDO_COLUMNCUT;
		lpText = ColumnCopy(&StartPos, &EndPos, FALSE);
		}

	int iTabbedOffset = GetTabbedOffset(StartPos.pLine,StartPos.iOffset);
	int iCount = UndoRecord.iEndCol - UndoRecord.iCol;
   pLine = StartPos.pLine;
   while (pLine)
      {
      TextPos.pLine = pLine;
		TextPos.iOffset = GetRealOffset(TextPos.pLine,iTabbedOffset);
      iRval = DeleteString(&TextPos, iCount, FALSE);
		if (pLine == EndPos.pLine)
			break;
		pLine = pLine->pNext;
      }

   if (!iRval && bSaveUndoRecord)
		{
      SaveUndoRecord(&UndoRecord, lpText);
		free(lpText);
		}

   return iRval;
   }
Ejemplo n.º 15
0
void CHistoryCombo::SetMaxHistoryItems(int nMaxItems)
{
	m_nMaxHistoryItems = nMaxItems;

	//truncate list to nMaxItems
	int nNumItems = GetCount();
	for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
		DeleteString(m_nMaxHistoryItems);
}
Ejemplo n.º 16
0
void MyListBox::DeleteAllString()
{
	int count = GetCount();
	while (count != 0) 
	{
		DeleteString(0);
		count = GetCount();
	}
}
Ejemplo n.º 17
0
int CDropListBox::DeleteListItem( UINT nIndex )
{
	if(nIndex < 0 || nIndex >= GetCount())
	{
		return LB_ERR;
	}

	int nRemain = DeleteString(nIndex);
	return nRemain;
}
Ejemplo n.º 18
0
int main(int argc, char const *argv[])
{
    char str1[] = "we are students";
    char str2[] ="aeiou";

    DeleteString(str1,str2);
    // DeleteString2(str1,str2);
    printf("%s\n", str1);
    return 0;
}
Ejemplo n.º 19
0
BOOL CDomainComboBox::DeleteCurSel( )
{
	int nSel = GetCurSel();
	if( CB_ERR != nSel )
	{
		DeleteString( nSel );
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 20
0
int CMyListBox::DeleteItemL(lua_State* L)
{
	int nParams = lua_gettop(L);
	if(lua_istable(L, 1))
	{		
		lua_pushnil(L);
		while(lua_next(L, -2) != 0)
		{
			DeleteString(PAI(L, -1));
			lua_pop(L, 1);
		}
		lua_pop(L, 1);
	}
	else
	{
		DeleteString(PAI(L, -1));	
	}
	return 0;
}
Ejemplo n.º 21
0
void GVSearchListBox::AddItem(GVStack::find_message_t & msg)
{
	std::lock_guard<std::recursive_mutex> l(mutex_);

	auto found = false;

	for (auto & i : m_findMessages)
	{
		if (
			i.pairs[L"u"] == msg.pairs[L"u"] &&
			i.pairs[L"m"] == msg.pairs[L"m"]
			)
		{
			found = true;

			break;
		}
	}

	if (found)
	{
		// ...
	}
	else
	{
		m_findMessages.push_back(msg);

		struct cmp
		{
			bool operator ()
				(GVStack::find_message_t & a, GVStack::find_message_t & b
				)
			{
				return a.pairs[L"__t"] > b.pairs[L"__t"];
			}
		};
#if 1 // sort
		std::sort(m_findMessages.begin(), m_findMessages.end(), cmp());

		//ResetContent();

		while (GetCount())
		{
			DeleteString(0);
		}

		for (auto & i : m_findMessages)
		{
			AddString(L"");
		}
#else
		InsertString(m_findMessages.size() - 1, L"");
#endif
	}
}
int CXTPSyntaxEditColorComboBox::SetAutoColor(COLORREF crColor, LPCTSTR lpszAutoText/*=NULL*/)
{
	CString csAuto;
	if (lpszAutoText == NULL)
	{
		XTPResourceManager()->LoadString(
			&csAuto, XTP_IDS_CLR_AUTOMATIC);

		int nTipIndex = csAuto.Find(_T('\n'), 0);
		if (nTipIndex > 0)
			csAuto.ReleaseBuffer(nTipIndex);
	}
	else
	{
		csAuto = lpszAutoText;
	}

	if (crColor == COLORREF_NULL)
	{
		m_crAuto = COLORREF_NULL;

		int iIndex = FindStringExact(-1, csAuto);
		if (iIndex != CB_ERR)
		{
			return DeleteString(iIndex);
		}

		return CB_ERR;
	}

	if (m_crAuto == COLORREF_NULL)
	{
		int iIndex = InsertString(0, csAuto);
		if (iIndex != CB_ERR)
		{
			m_crAuto = crColor;
			SetItemData(iIndex, (DWORD)m_crAuto);
			RedrawWindow();
			return iIndex;
		}
	}
	else
	{
		int iIndex = FindStringExact(-1, csAuto);
		if (iIndex != CB_ERR)
		{
			m_crAuto = crColor;
			SetItemData(iIndex, (DWORD)m_crAuto);
			RedrawWindow();
			return iIndex;
		}
	}

	return CB_ERR;
}
BOOL COXHistoryCombo::AddNewItem(LPCTSTR pszItemText /* = NULL */)
{
	ASSERT_VALID(this);
	CString sNewItem(pszItemText);

	if (sNewItem.IsEmpty())
		// ... No text was specified, get the text from the edit control
		GetWindowText(sNewItem);

	if (sNewItem.IsEmpty())
		// ... Do not add empty string to the list
		return FALSE;

	// Check whether the item is already in the list or not
	BOOL bAlreadyInList = FALSE;
	int nOldPos = FindStringExact(-1, sNewItem);
	if (nOldPos != CB_ERR)
	{
		// ... Already in the list, remove the old item
		DeleteString(nOldPos);
		bAlreadyInList = TRUE;
	}

	// ... Insert the new string at the top of the list and select it
	InsertString(0, sNewItem);
	SetCurSel(0);

	// If the list contains more items than allowed, truncate the list
	// ... Cast to DWORD so that -1 becomes a very large number
	if ((DWORD)m_nMaxHistoryCount < (DWORD)GetCount())
	{
		for (int nItemIndex = GetCount() - 1; m_nMaxHistoryCount <= nItemIndex; nItemIndex--)
		{
			DeleteString(nItemIndex);
		}
	}
	// ... Select the entire string
	SetEditSel(0, -1);

	ASSERT_VALID(this);
	return !bAlreadyInList;
}
int CXTPSyntaxEditColorComboBox::DeleteColor(COLORREF crColor)
{
	int iIndex = FindColor(crColor);

	if (iIndex != CB_ERR)
	{
		return DeleteString(iIndex);
	}

	return CB_ERR;
}
Ejemplo n.º 25
0
int CCrossfaderBar::CMyComboBox::UpdateString(int nIndex, LPCTSTR lpszString)
{
	PVOID	pCurSel = GetItemDataPtr(GetCurSel());
	PVOID	pData = GetItemDataPtr(nIndex);
	if (DeleteString(nIndex) == CB_ERR)
		return(CB_ERR);
	int	pos = AddString(lpszString);
	SetItemDataPtr(pos, pData);
	SetCurSel(FindItemDataPtr(pCurSel));
	return(pos);
}
Ejemplo n.º 26
0
/******************************************************************************
 Function Name  :   OnTraceWndDelete

 Description    :   Handler to remove the selected trace entry in the list box
 Input(s)       :   - 
                    - 
 Output         :   -
 Functionality  :   Deletes the selected item in the Listbox
 Member of      :   CNotificListbox

 Author(s)      :   Ravikumar Patil
 Date Created   :   27-03-2003
 Modification	:   By Pradeep Kadoor on 3/12/2008
******************************************************************************/
void CNotificListbox::OnTraceWndDelete() 
{
	for (int i = 0; i < GetCount(); i++)
	{
		if (GetSel(i))
		{
			DeleteString(i);
			--i;
		}
	}     
}
Ejemplo n.º 27
0
// Replaces a string at a specific location in the list box.
//
// Parameters:
//		[IN]	nIndex
//				Specifies the zero-based index of the position to replace the string.
//		[IN]	lpszItem
//				Pointer to the null-terminated string that is to be replaced.
//		[IN]	nImage
//				Image to be associated with the string.
//				Pass -1L to associate no image.
//
// Return value:
//		The zero-based index of the position at which the string was replaced.
//		The return value is LB_ERR if an error occurs; the return value 
//		is LB_ERRSPACE if insufficient space is available to store the new string.
//
int CListBoxST::ReplaceString(int nIndex, LPCTSTR lpszString, int nImage)
{
	int	nRetValue;

	nRetValue = DeleteString(nIndex);
	if (nRetValue != LB_ERR)
	{
		nRetValue = InsertString(nIndex, lpszString, nImage);
	} // if

	return nRetValue;
} // End of ReplaceString
Ejemplo n.º 28
0
//
/// Deletes the item in the list at the position (starting at 0) supplied in
/// index. DeleteItem returns the adress of the associated TCheckListBoxItem,
/// or ZERO if an error occurs. The item must be deleted by the owner
//
TCheckListItem*
TCheckList::DetachItem(int idx)
{
  TCheckListItem* item = GetItem(idx);
  if(item){
    Items.DetachItem(item);
    if(GetHandle())
      DeleteString(idx);
     return item;
  }
  return 0;
}
Ejemplo n.º 29
0
// This will add the history of data used
LRESULT CToolBarCombo::AddtoHistory(const _bstr_t& bstrURL){
  CRegKey keyAppID;
  if(std::basic_string<TCHAR>(bstrURL).find_first_not_of(_T(" "))!=std::string::npos)  {
    int h = GetCount();
    int pos = FindStringExact(-1,bstrURL);
    if(pos == CB_ERR){
      if(h<50){
        InsertString(0,bstrURL);
      }else{
        DeleteString(h-1);
        InsertString(0,bstrURL);
      }
    }else{
      DeleteString(pos);
      InsertString(0,bstrURL);
    }

    {
      CRegKey keyAppID;
      keyAppID.Attach(Get6BeeAppRegistryKey());
      keyAppID.RecurseDeleteKey(_T("History"));
    }

    {
      CRegKey keyAppID;
      keyAppID.Create(Get6BeeAppRegistryKey(),_T("History"));

      for(int i=0;i < GetCount();i++)
      {
        TCHAR cValue[1024]={};
        GetLBText(i, cValue);
        keyAppID.SetDWORDValue(cValue,1);
      }
    }

    SetCurSel(0);
  }

  return 0;
}
Ejemplo n.º 30
0
void dynLibImplLinux::GetImportAndExportData( 
	const char* dllName )
{
	if( std::string(dllName).empty())
	{
		return;
	}

	Elf* mainElf;
	struct link_map* mainLm;
	std::string csPath_o;
	OpenDynamicLibrary( dllName, mainElf, mainLm, csPath_o );
	if ( mainLm == NULL )
	{
		return;
	}

	Elf_Scn* section = 0;
	ElfW(Shdr) *shdr;
	FindSection( mainElf, SHT_DYNAMIC, section, shdr );

	std::list<std::string> dependencies;
	ExtractDynSymbols( mainElf, section, shdr, STT_NOTYPE, dependencies );

	std::list<std::string>::iterator it;
	for(it = dependencies.begin( ); it != dependencies.end( ) ; it++) {

		AddString( it->c_str() );

		if ( GetDllEntry( it->c_str()  ) == NULL )
		{
			DLL_ENTRY stImpExport;

			std::string csPath_o;
			if ( GetExportData( it->c_str(), stImpExport.ArrayExport, csPath_o ) )
			{
				stImpExport.m_bIsStable = true;
				stImpExport.m_csFullPath = csPath_o;

				// Add data to static internal map
				MakeUpper( *it );
				m_DataEntry[ *it ] = stImpExport;

			}

		}

		DeleteString( it->c_str() );
	}

	dlclose( mainLm );
}