sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Name : loadeddlls.cpp
|
sl@0
|
15 |
// Part of : libdl library
|
sl@0
|
16 |
// Implements and maintains the list of opened dll.
|
sl@0
|
17 |
//
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
// INCLUDE FILES
|
sl@0
|
21 |
#include "loadeddlls.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
//-----------------------------------------------------------------------------
|
sl@0
|
24 |
//Function Name : CLoadedDlls::CLoadedDlls()
|
sl@0
|
25 |
//Description : Constructor
|
sl@0
|
26 |
//-----------------------------------------------------------------------------
|
sl@0
|
27 |
CLoadedDlls::CLoadedDlls()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
const TInt error = CreateLock();
|
sl@0
|
30 |
//if error creating lock, panic.
|
sl@0
|
31 |
if ( KErrNone != error )
|
sl@0
|
32 |
{
|
sl@0
|
33 |
User::Panic(_L(""), error);
|
sl@0
|
34 |
}
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
//-----------------------------------------------------------------------------
|
sl@0
|
38 |
//Function Name : CLoadedDlls::~CLoadedDlls()
|
sl@0
|
39 |
//Description : Destructor
|
sl@0
|
40 |
//-----------------------------------------------------------------------------
|
sl@0
|
41 |
CLoadedDlls::~CLoadedDlls()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
iLock.Close();
|
sl@0
|
44 |
iHandleList.Close();
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
//-----------------------------------------------------------------------------
|
sl@0
|
48 |
//Function Name : TInt CLoadedDlls::Add(const TDllEntry& aDllEntry)
|
sl@0
|
49 |
//Description : To add the dll to the list.
|
sl@0
|
50 |
//Return Value : KErrNone if added successfully else system wide error
|
sl@0
|
51 |
//-----------------------------------------------------------------------------
|
sl@0
|
52 |
TInt CLoadedDlls::Add(const TDllEntry& aDllEntry)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
return iHandleList.Append(aDllEntry);
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
//-----------------------------------------------------------------------------
|
sl@0
|
58 |
//Function Name : void CLoadedDlls::Remove(const TInt aIndex)
|
sl@0
|
59 |
//Description : To remove the dll from the list.
|
sl@0
|
60 |
//-----------------------------------------------------------------------------
|
sl@0
|
61 |
void CLoadedDlls::Remove(const TInt aIndex)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
iHandleList.Remove(aIndex);
|
sl@0
|
64 |
iHandleList.GranularCompress();
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
//-----------------------------------------------------------------------------
|
sl@0
|
68 |
//Function Name : TDllEntry& CLoadedDlls::At(const TInt aIndex)
|
sl@0
|
69 |
//Description : Get DllEntry& at particular index. This function assumes that
|
sl@0
|
70 |
// index is valid.
|
sl@0
|
71 |
//Return Value : TDllEntry& DllEntry corresponding to aIndex
|
sl@0
|
72 |
//-----------------------------------------------------------------------------
|
sl@0
|
73 |
TDllEntry& CLoadedDlls::At(const TInt aIndex)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
return iHandleList[aIndex];
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
//-----------------------------------------------------------------------------
|
sl@0
|
79 |
//Function Name : TInt CLoadedDlls::Find(const void* aHandle) const
|
sl@0
|
80 |
//Description : Finds if dll with this handle exist or not
|
sl@0
|
81 |
//Return Value : Index in list if found else KErrNotFound
|
sl@0
|
82 |
//-----------------------------------------------------------------------------
|
sl@0
|
83 |
TInt CLoadedDlls::Find(const void* aHandle) const
|
sl@0
|
84 |
{
|
sl@0
|
85 |
TDllEntry tempDllEntry((TInt) aHandle);
|
sl@0
|
86 |
return iHandleList.Find(tempDllEntry, TIdentityRelation<TDllEntry>(TDllEntry::CompareByHandle));
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
//-----------------------------------------------------------------------------
|
sl@0
|
90 |
//Function Name : TInt CLoadedDlls::Find(const RLibrary& aLibrary) const
|
sl@0
|
91 |
//Description : Finds if dll with this library i.e. same path exist or not
|
sl@0
|
92 |
//Return Value : Index in list if found else KErrNotFound
|
sl@0
|
93 |
//-----------------------------------------------------------------------------
|
sl@0
|
94 |
TInt CLoadedDlls::Find(const RLibrary& aLibrary) const
|
sl@0
|
95 |
{
|
sl@0
|
96 |
TDllEntry tempDllEntry(aLibrary);
|
sl@0
|
97 |
return iHandleList.Find(tempDllEntry,TIdentityRelation<TDllEntry>(TDllEntry::CompareByPath));
|
sl@0
|
98 |
}
|
sl@0
|
99 |
|
sl@0
|
100 |
//-----------------------------------------------------------------------------
|
sl@0
|
101 |
//Function Name : TBool TDllEntry::CompareByHandle(const TDllEntry& aEntry)
|
sl@0
|
102 |
//Description : Comparator function, compares iLibrary.Handle() of two
|
sl@0
|
103 |
// TDllEntry.
|
sl@0
|
104 |
//Return Value : ETrue if Handle of both TDllEntry's RLibrary's matches
|
sl@0
|
105 |
// else EFalse.
|
sl@0
|
106 |
//-----------------------------------------------------------------------------
|
sl@0
|
107 |
TBool TDllEntry::CompareByHandle(const TDllEntry& aEntry1, const TDllEntry& aEntry2)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
if (aEntry1.iLibrary.Handle() == aEntry2.iLibrary.Handle())
|
sl@0
|
110 |
{
|
sl@0
|
111 |
return ETrue;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
return EFalse;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
//-----------------------------------------------------------------------------
|
sl@0
|
117 |
//Function Name : TBool TDllEntry::CompareByPath(const TDllEntry& aEntry)
|
sl@0
|
118 |
//Description : Comparator function, compares path corresponding to two
|
sl@0
|
119 |
// TDllEntry.
|
sl@0
|
120 |
//Return Value : ETrue if file name of both TDllEntry's RLibrary's matches
|
sl@0
|
121 |
// else EFalse.
|
sl@0
|
122 |
//-----------------------------------------------------------------------------
|
sl@0
|
123 |
TBool TDllEntry::CompareByPath(const TDllEntry& aEntry1, const TDllEntry& aEntry2)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
if (aEntry1.iLibrary.FileName().Compare(aEntry2.iLibrary.FileName()))
|
sl@0
|
126 |
{
|
sl@0
|
127 |
return EFalse;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
return ETrue;
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
//-----------------------------------------------------------------------------
|
sl@0
|
133 |
//Function Name : TDllEntry::TDllEntry(const RLibrary aLibrary, const TInt aFlag)
|
sl@0
|
134 |
//Description : constructor. to initialise library by RLibrary object
|
sl@0
|
135 |
//-----------------------------------------------------------------------------
|
sl@0
|
136 |
TDllEntry::TDllEntry(const RLibrary& aLibrary, const TInt aFlag) : iLibrary(aLibrary), iFlags(aFlag), iRefCount(1)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
}
|