Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c15245d9
Commit
c15245d9
authored
Jul 11, 2007
by
Thomas Weidenmueller
Committed by
Alexandre Julliard
Jul 12, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shlwapi: Use publicly defined structure DATABLOCK_HEADER instead of redefining it locally.
parent
d0e06874
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
73 deletions
+65
-73
clist.c
dlls/shlwapi/clist.c
+65
-73
No files found.
dlls/shlwapi/clist.c
View file @
c15245d9
...
...
@@ -24,36 +24,28 @@
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "objbase.h"
#include "shlobj.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
shell
);
/* DataBlock list element (ordinals 17-22) */
typedef
struct
tagSHLWAPI_CLIST
{
ULONG
ulSize
;
/* Size of this list element and its data */
ULONG
ulId
;
/* If 0xFFFFFFFF, The real element follows */
/* Item data (or a contained SHLWAPI_CLIST) follows... */
}
SHLWAPI_CLIST
,
*
LPSHLWAPI_CLIST
;
typedef
const
SHLWAPI_CLIST
*
LPCSHLWAPI_CLIST
;
/* ulId for contained SHLWAPI_CLIST items */
/* dwSignature for contained DATABLOCK_HEADER items */
#define CLIST_ID_CONTAINER (~0U)
HRESULT
WINAPI
SHAddDataBlock
(
LP
SHLWAPI_CLIST
*
,
LPCSHLWAPI_CLIST
);
HRESULT
WINAPI
SHAddDataBlock
(
LP
DBLIST
*
,
const
DATABLOCK_HEADER
*
);
/*************************************************************************
* NextItem
*
* Internal helper: move a DataBlock pointer to the next item.
*/
static
inline
LP
SHLWAPI_CLIST
NextItem
(
LPSHLWAPI_C
LIST
lpList
)
static
inline
LP
DATABLOCK_HEADER
NextItem
(
LPDB
LIST
lpList
)
{
char
*
address
=
(
char
*
)
lpList
;
address
+=
lpList
->
ul
Size
;
return
(
LP
SHLWAPI_CLIST
)
address
;
address
+=
lpList
->
cb
Size
;
return
(
LP
DATABLOCK_HEADER
)
address
;
}
/*************************************************************************
...
...
@@ -93,27 +85,27 @@ static inline LPSHLWAPI_CLIST NextItem(LPSHLWAPI_CLIST lpList)
*
* These functions are slow for large objects and long lists.
*/
HRESULT
WINAPI
SHWriteDataBlockList
(
IStream
*
lpStream
,
LP
SHLWAPI_C
LIST
lpList
)
HRESULT
WINAPI
SHWriteDataBlockList
(
IStream
*
lpStream
,
LP
DB
LIST
lpList
)
{
ULONG
ulSize
;
HRESULT
hRet
=
E_FAIL
;
HRESULT
hRet
=
S_OK
;
TRACE
(
"(%p,%p)
\n
"
,
lpStream
,
lpList
);
if
(
lpList
)
{
while
(
lpList
->
ul
Size
)
while
(
lpList
->
cb
Size
)
{
LP
SHLWAPI_CLIST
lpItem
=
lpList
;
LP
DATABLOCK_HEADER
lpItem
=
lpList
;
if
(
lpList
->
ulId
==
CLIST_ID_CONTAINER
)
if
(
lpList
->
dwSignature
==
CLIST_ID_CONTAINER
)
lpItem
++
;
hRet
=
IStream_Write
(
lpStream
,
lpItem
,
lpItem
->
ul
Size
,
&
ulSize
);
hRet
=
IStream_Write
(
lpStream
,
lpItem
,
lpItem
->
cb
Size
,
&
ulSize
);
if
(
FAILED
(
hRet
))
return
hRet
;
if
(
lpItem
->
ul
Size
!=
ulSize
)
if
(
lpItem
->
cb
Size
!=
ulSize
)
return
STG_E_MEDIUMFULL
;
lpList
=
NextItem
(
lpList
);
...
...
@@ -149,11 +141,11 @@ HRESULT WINAPI SHWriteDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST lpList)
* When read from a file, list objects are limited in size to 64k.
* See SHWriteDataBlockList.
*/
HRESULT
WINAPI
SHReadDataBlockList
(
IStream
*
lpStream
,
LP
SHLWAPI_C
LIST
*
lppList
)
HRESULT
WINAPI
SHReadDataBlockList
(
IStream
*
lpStream
,
LP
DB
LIST
*
lppList
)
{
SHLWAPI_CLIST
bBuff
[
128
];
/* Temporary storage for new list item */
DATABLOCK_HEADER
bBuff
[
128
];
/* Temporary storage for new list item */
ULONG
ulBuffSize
=
sizeof
(
bBuff
);
LP
SHLWAPI_CLIST
pItem
=
bBuff
;
LP
DATABLOCK_HEADER
pItem
=
bBuff
;
ULONG
ulRead
,
ulSize
;
HRESULT
hRet
=
S_OK
;
...
...
@@ -189,18 +181,18 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
}
break
;
}
else
if
(
ulSize
>=
sizeof
(
SHLWAPI_CLIST
))
else
if
(
ulSize
>=
sizeof
(
DATABLOCK_HEADER
))
{
/* Add this new item to the list */
if
(
ulSize
>
ulBuffSize
)
{
/* We need more buffer space, allocate it */
LP
SHLWAPI_CLIST
lpTemp
;
LP
DATABLOCK_HEADER
lpTemp
;
if
(
pItem
==
bBuff
)
lpTemp
=
(
LP
SHLWAPI_CLIST
)
LocalAlloc
(
LMEM_ZEROINIT
,
ulSize
);
lpTemp
=
(
LP
DATABLOCK_HEADER
)
LocalAlloc
(
LMEM_ZEROINIT
,
ulSize
);
else
lpTemp
=
(
LP
SHLWAPI_CLIST
)
LocalReAlloc
((
HLOCAL
)
pItem
,
ulSize
,
lpTemp
=
(
LP
DATABLOCK_HEADER
)
LocalReAlloc
((
HLOCAL
)
pItem
,
ulSize
,
LMEM_ZEROINIT
|
LMEM_MOVEABLE
);
if
(
!
lpTemp
)
...
...
@@ -212,11 +204,11 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
pItem
=
lpTemp
;
}
pItem
->
ul
Size
=
ulSize
;
ulSize
-=
sizeof
(
pItem
->
ul
Size
);
/* already read this member */
pItem
->
cb
Size
=
ulSize
;
ulSize
-=
sizeof
(
pItem
->
cb
Size
);
/* already read this member */
/* Read the item Id and data */
hRet
=
IStream_Read
(
lpStream
,
&
pItem
->
ulId
,
ulSize
,
&
ulRead
);
hRet
=
IStream_Read
(
lpStream
,
&
pItem
->
dwSignature
,
ulSize
,
&
ulRead
);
if
(
FAILED
(
hRet
)
||
ulRead
!=
ulSize
)
break
;
...
...
@@ -246,7 +238,7 @@ HRESULT WINAPI SHReadDataBlockList(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
* NOTES
* See SHWriteDataBlockList.
*/
VOID
WINAPI
SHFreeDataBlockList
(
LP
SHLWAPI_C
LIST
lpList
)
VOID
WINAPI
SHFreeDataBlockList
(
LP
DB
LIST
lpList
)
{
TRACE
(
"(%p)
\n
"
,
lpList
);
...
...
@@ -269,13 +261,13 @@ VOID WINAPI SHFreeDataBlockList(LPSHLWAPI_CLIST lpList)
*
* NOTES
* If the size of the element to be inserted is less than the size of a
*
SHLWAPI_CLIST
node, or the Id for the item is CLIST_ID_CONTAINER,
*
DATABLOCK_HEADER
node, or the Id for the item is CLIST_ID_CONTAINER,
* the call returns S_OK but does not actually add the element.
* See SHWriteDataBlockList.
*/
HRESULT
WINAPI
SHAddDataBlock
(
LP
SHLWAPI_CLIST
*
lppList
,
LPCSHLWAPI_CLIST
lpNewItem
)
HRESULT
WINAPI
SHAddDataBlock
(
LP
DBLIST
*
lppList
,
const
DATABLOCK_HEADER
*
lpNewItem
)
{
LP
SHLWAPI_CLIST
lpInsertAt
=
NULL
;
LP
DATABLOCK_HEADER
lpInsertAt
=
NULL
;
ULONG
ulSize
;
TRACE
(
"(%p,%p)
\n
"
,
lppList
,
lpNewItem
);
...
...
@@ -283,23 +275,23 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
if
(
!
lppList
||
!
lpNewItem
)
return
E_INVALIDARG
;
if
(
lpNewItem
->
ulSize
<
sizeof
(
SHLWAPI_CLIST
)
||
lpNewItem
->
ulId
==
CLIST_ID_CONTAINER
)
if
(
lpNewItem
->
cbSize
<
sizeof
(
DATABLOCK_HEADER
)
||
lpNewItem
->
dwSignature
==
CLIST_ID_CONTAINER
)
return
S_OK
;
ulSize
=
lpNewItem
->
ul
Size
;
ulSize
=
lpNewItem
->
cb
Size
;
if
(
ulSize
&
0x3
)
{
/* Tune size to a ULONG boundary, add space for container element */
ulSize
=
((
ulSize
+
0x3
)
&
0xFFFFFFFC
)
+
sizeof
(
SHLWAPI_CLIST
);
ulSize
=
((
ulSize
+
0x3
)
&
0xFFFFFFFC
)
+
sizeof
(
DATABLOCK_HEADER
);
TRACE
(
"Creating container item, new size = %d
\n
"
,
ulSize
);
}
if
(
!*
lppList
)
{
/* An empty list. Allocate space for terminal ulSize also */
*
lppList
=
(
LP
SHLWAPI_CLIST
)
LocalAlloc
(
LMEM_ZEROINIT
,
*
lppList
=
(
LP
DATABLOCK_HEADER
)
LocalAlloc
(
LMEM_ZEROINIT
,
ulSize
+
sizeof
(
ULONG
));
lpInsertAt
=
*
lppList
;
}
...
...
@@ -307,44 +299,44 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
{
/* Append to the end of the list */
ULONG
ulTotalSize
=
0
;
LP
SHLWAPI_CLIST
lpIter
=
*
lppList
;
LP
DATABLOCK_HEADER
lpIter
=
*
lppList
;
/* Iterate to the end of the list, calculating the total size */
while
(
lpIter
->
ul
Size
)
while
(
lpIter
->
cb
Size
)
{
ulTotalSize
+=
lpIter
->
ul
Size
;
ulTotalSize
+=
lpIter
->
cb
Size
;
lpIter
=
NextItem
(
lpIter
);
}
/* Increase the size of the list */
lpIter
=
(
LP
SHLWAPI_CLIST
)
LocalReAlloc
((
HLOCAL
)
*
lppList
,
lpIter
=
(
LP
DATABLOCK_HEADER
)
LocalReAlloc
((
HLOCAL
)
*
lppList
,
ulTotalSize
+
ulSize
+
sizeof
(
ULONG
),
LMEM_ZEROINIT
|
LMEM_MOVEABLE
);
if
(
lpIter
)
{
*
lppList
=
lpIter
;
lpInsertAt
=
(
LP
SHLWAPI_CLIST
)((
char
*
)
lpIter
+
ulTotalSize
);
/* At end */
lpInsertAt
=
(
LP
DATABLOCK_HEADER
)((
char
*
)
lpIter
+
ulTotalSize
);
/* At end */
}
}
if
(
lpInsertAt
)
{
/* Copy in the new item */
LP
SHLWAPI_CLIST
lpDest
=
lpInsertAt
;
LP
DATABLOCK_HEADER
lpDest
=
lpInsertAt
;
if
(
ulSize
!=
lpNewItem
->
ul
Size
)
if
(
ulSize
!=
lpNewItem
->
cb
Size
)
{
lpInsertAt
->
ul
Size
=
ulSize
;
lpInsertAt
->
ulId
=
CLIST_ID_CONTAINER
;
lpInsertAt
->
cb
Size
=
ulSize
;
lpInsertAt
->
dwSignature
=
CLIST_ID_CONTAINER
;
lpDest
++
;
}
memcpy
(
lpDest
,
lpNewItem
,
lpNewItem
->
ul
Size
);
memcpy
(
lpDest
,
lpNewItem
,
lpNewItem
->
cb
Size
);
/* Terminate the list */
lpInsertAt
=
NextItem
(
lpInsertAt
);
lpInsertAt
->
ul
Size
=
0
;
lpInsertAt
->
cb
Size
=
0
;
return
lpNewItem
->
ul
Size
;
return
lpNewItem
->
cb
Size
;
}
return
S_OK
;
}
...
...
@@ -355,8 +347,8 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
* Remove an item from a DataBlock list.
*
* PARAMS
* lppList [O] List to remove the item from
*
ulId
[I] Id of item to remove
* lppList
[O] List to remove the item from
*
dwSignature
[I] Id of item to remove
*
* RETURNS
* Success: TRUE.
...
...
@@ -365,22 +357,22 @@ HRESULT WINAPI SHAddDataBlock(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewIt
* NOTES
* See SHWriteDataBlockList.
*/
BOOL
WINAPI
SHRemoveDataBlock
(
LP
SHLWAPI_CLIST
*
lppList
,
ULONG
ulId
)
BOOL
WINAPI
SHRemoveDataBlock
(
LP
DBLIST
*
lppList
,
DWORD
dwSignature
)
{
LP
SHLWAPI_CLIST
lpList
=
0
;
LP
SHLWAPI_CLIST
lpItem
=
NULL
;
LP
SHLWAPI_CLIST
lpNext
;
LP
DATABLOCK_HEADER
lpList
=
0
;
LP
DATABLOCK_HEADER
lpItem
=
NULL
;
LP
DATABLOCK_HEADER
lpNext
;
ULONG
ulNewSize
;
TRACE
(
"(%p,%d)
\n
"
,
lppList
,
ulId
);
TRACE
(
"(%p,%d)
\n
"
,
lppList
,
dwSignature
);
if
(
lppList
&&
(
lpList
=
*
lppList
))
{
/* Search for item in list */
while
(
lpList
->
ul
Size
)
while
(
lpList
->
cb
Size
)
{
if
(
lpList
->
ulId
==
ulId
||
(
lpList
->
ulId
==
CLIST_ID_CONTAINER
&&
lpList
[
1
].
ulId
==
ulId
))
if
(
lpList
->
dwSignature
==
dwSignature
||
(
lpList
->
dwSignature
==
CLIST_ID_CONTAINER
&&
lpList
[
1
].
dwSignature
==
dwSignature
))
{
lpItem
=
lpList
;
/* Found */
break
;
...
...
@@ -395,11 +387,11 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
lpList
=
lpNext
=
NextItem
(
lpItem
);
/* Locate the end of the list */
while
(
lpList
->
ul
Size
)
while
(
lpList
->
cb
Size
)
lpList
=
NextItem
(
lpList
);
/* Resize the list */
ulNewSize
=
LocalSize
((
HLOCAL
)
*
lppList
)
-
lpItem
->
ul
Size
;
ulNewSize
=
LocalSize
((
HLOCAL
)
*
lppList
)
-
lpItem
->
cb
Size
;
/* Copy following elements over lpItem */
memmove
(
lpItem
,
lpNext
,
(
char
*
)
lpList
-
(
char
*
)
lpNext
+
sizeof
(
ULONG
));
...
...
@@ -411,7 +403,7 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
}
else
{
lpList
=
(
LP
SHLWAPI_CLIST
)
LocalReAlloc
((
HLOCAL
)
*
lppList
,
ulNewSize
,
lpList
=
(
LP
DATABLOCK_HEADER
)
LocalReAlloc
((
HLOCAL
)
*
lppList
,
ulNewSize
,
LMEM_ZEROINIT
|
LMEM_MOVEABLE
);
if
(
lpList
)
*
lppList
=
lpList
;
...
...
@@ -425,8 +417,8 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
* Find an item in a DataBlock list.
*
* PARAMS
* lpList [I] List to search
*
ulId
[I] Id of item to find
* lpList
[I] List to search
*
dwSignature
[I] Id of item to find
*
* RETURNS
* Success: A pointer to the list item found
...
...
@@ -435,17 +427,17 @@ BOOL WINAPI SHRemoveDataBlock(LPSHLWAPI_CLIST* lppList, ULONG ulId)
* NOTES
* See SHWriteDataBlockList.
*/
LP
SHLWAPI_CLIST
WINAPI
SHFindDataBlock
(
LPSHLWAPI_CLIST
lpList
,
ULONG
ulId
)
LP
DATABLOCK_HEADER
WINAPI
SHFindDataBlock
(
LPDBLIST
lpList
,
DWORD
dwSignature
)
{
TRACE
(
"(%p,%d)
\n
"
,
lpList
,
ulId
);
TRACE
(
"(%p,%d)
\n
"
,
lpList
,
dwSignature
);
if
(
lpList
)
{
while
(
lpList
->
ul
Size
)
while
(
lpList
->
cb
Size
)
{
if
(
lpList
->
ulId
==
ulId
)
if
(
lpList
->
dwSignature
==
dwSignature
)
return
lpList
;
/* Matched */
else
if
(
lpList
->
ulId
==
CLIST_ID_CONTAINER
&&
lpList
[
1
].
ulId
==
ulId
)
else
if
(
lpList
->
dwSignature
==
CLIST_ID_CONTAINER
&&
lpList
[
1
].
dwSignature
==
dwSignature
)
return
lpList
+
1
;
/* Contained item matches */
lpList
=
NextItem
(
lpList
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment