Correct behaviour for some error conditions.

Documentation updates.
This commit is contained in:
Jon Griffiths 2003-03-15 19:40:11 +00:00 committed by Alexandre Julliard
parent 7cf70d79c3
commit 7bac7e8ed7
2 changed files with 47 additions and 18 deletions

View File

@ -57,27 +57,33 @@ inline static LPSHLWAPI_CLIST NextItem(LPCSHLWAPI_CLIST lpList)
/************************************************************************* /*************************************************************************
* @ [SHLWAPI.17] * @ [SHLWAPI.17]
* *
* Write a compact list to a stream. * Write a compact list to an IStream object.
* *
* PARAMS * PARAMS
* lpStream [I] Stream to write the list to * lpStream [I] IStream object to write the list to
* lpList [I] List of items to write * lpList [I] List of items to write
* *
* RETURNS * RETURNS
* Success: S_OK * Success: S_OK. The object is written to the stream.
* Failure: An HRESULT error code * Failure: An HRESULT error code
* *
* NOTES * NOTES
* Ordinals 17,18,19,20,21 and 22 are related and together provide a compact * Ordinals 17,18,19,20,21 and 22 are related and together provide a compact
* list structure which may be stored and retrieved from a stream. * list structure which may be stored and retrieved from an IStream object.
* *
* The exposed API consists of: * The exposed API consists of:
* @17 Write a compact list to a stream *
* @18 Read and create a list from a stream * SHLWAPI_17() Write a compact list to a stream,
* @19 Free a list *
* @20 Insert a new item into a list * SHLWAPI_18() Read and create a list from a stream,
* @21 Remove an item from a list *
* @22 Find an item in a list * SHLWAPI_19() Free a list,
*
* SHLWAPI_20() Insert a new item into a list,
*
* SHLWAPI_21() Remove an item from a list,
*
* SHLWAPI_22() Find an item in a list.
* *
* The compact list is stored packed into a memory array. Each element has a * The compact list is stored packed into a memory array. Each element has a
* size and an associated ID. Elements must be less than 64k if the list is * size and an associated ID. Elements must be less than 64k if the list is
@ -131,7 +137,7 @@ HRESULT WINAPI SHLWAPI_17(IStream* lpStream, LPSHLWAPI_CLIST lpList)
/************************************************************************* /*************************************************************************
* @ [SHLWAPI.18] * @ [SHLWAPI.18]
* *
* Read and create a compact list from a stream * Read and create a compact list from an IStream object.
* *
* PARAMS * PARAMS
* lpStream [I] Stream to read the list from * lpStream [I] Stream to read the list from
@ -143,6 +149,7 @@ HRESULT WINAPI SHLWAPI_17(IStream* lpStream, LPSHLWAPI_CLIST lpList)
* *
* NOTES * NOTES
* When read from a file, list objects are limited in size to 64k. * When read from a file, list objects are limited in size to 64k.
* See SHLWAPI_17.
*/ */
HRESULT WINAPI SHLWAPI_18(IStream* lpStream, LPSHLWAPI_CLIST* lppList) HRESULT WINAPI SHLWAPI_18(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
{ {
@ -237,6 +244,9 @@ HRESULT WINAPI SHLWAPI_18(IStream* lpStream, LPSHLWAPI_CLIST* lppList)
* *
* RETURNS * RETURNS
* Nothing. * Nothing.
*
* NOTES
* See SHLWAPI_17.
*/ */
VOID WINAPI SHLWAPI_19(LPSHLWAPI_CLIST lpList) VOID WINAPI SHLWAPI_19(LPSHLWAPI_CLIST lpList)
{ {
@ -256,8 +266,14 @@ VOID WINAPI SHLWAPI_19(LPSHLWAPI_CLIST lpList)
* lpNewItem [I] The new item to add to the list * lpNewItem [I] The new item to add to the list
* *
* RETURNS * RETURNS
* Success: The size of the inserted item. * Success: S_OK. The item is added to the list.
* Failure: An HRESULT error code. * Failure: An HRESULT error code.
*
* 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,
* the call returns S_OK but does not actually add the element.
* See SHLWAPI_17.
*/ */
HRESULT WINAPI SHLWAPI_20(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewItem) HRESULT WINAPI SHLWAPI_20(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewItem)
{ {
@ -266,11 +282,13 @@ HRESULT WINAPI SHLWAPI_20(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewItem)
TRACE("(%p,%p)\n", lppList, lpNewItem); TRACE("(%p,%p)\n", lppList, lpNewItem);
if(!lppList || !lpNewItem || if(!lppList || !lpNewItem )
lpNewItem->ulId == CLIST_ID_CONTAINER ||
lpNewItem->ulSize < sizeof(SHLWAPI_CLIST))
return E_INVALIDARG; return E_INVALIDARG;
if (lpNewItem->ulSize < sizeof(SHLWAPI_CLIST) ||
lpNewItem->ulId == CLIST_ID_CONTAINER)
return S_OK;
ulSize = lpNewItem->ulSize; ulSize = lpNewItem->ulSize;
if(ulSize & 0x3) if(ulSize & 0x3)
@ -345,6 +363,9 @@ HRESULT WINAPI SHLWAPI_20(LPSHLWAPI_CLIST* lppList, LPCSHLWAPI_CLIST lpNewItem)
* RETURNS * RETURNS
* Success: TRUE. * Success: TRUE.
* Failure: FALSE, If any parameters are invalid, or the item was not found. * Failure: FALSE, If any parameters are invalid, or the item was not found.
*
* NOTES
* See SHLWAPI_17.
*/ */
BOOL WINAPI SHLWAPI_21(LPSHLWAPI_CLIST* lppList, ULONG ulId) BOOL WINAPI SHLWAPI_21(LPSHLWAPI_CLIST* lppList, ULONG ulId)
{ {
@ -407,11 +428,14 @@ BOOL WINAPI SHLWAPI_21(LPSHLWAPI_CLIST* lppList, ULONG ulId)
* *
* PARAMS * PARAMS
* lpList [I] List to search * lpList [I] List to search
* ulId [I] ID of item to find * ulId [I] Id of item to find
* *
* RETURNS * RETURNS
* Success: A pointer to the list item found * Success: A pointer to the list item found
* Failure: NULL * Failure: NULL
*
* NOTES
* See SHLWAPI_17.
*/ */
LPSHLWAPI_CLIST WINAPI SHLWAPI_22(LPSHLWAPI_CLIST lpList, ULONG ulId) LPSHLWAPI_CLIST WINAPI SHLWAPI_22(LPSHLWAPI_CLIST lpList, ULONG ulId)
{ {

View File

@ -364,12 +364,17 @@ static void test_CList(void)
inserted->ulSize = sizeof(SHLWAPI_CLIST) -1; inserted->ulSize = sizeof(SHLWAPI_CLIST) -1;
inserted->ulId = 33; inserted->ulId = 33;
hRet = pSHLWAPI_20(&list, inserted); hRet = pSHLWAPI_20(&list, inserted);
ok(hRet == E_INVALIDARG, "allowed bad element size"); /* The call succeeds but the item is not inserted */
ok(hRet == S_OK, "failed bad element size");
inserted = pSHLWAPI_22(list, 33);
ok(inserted == NULL, "inserted bad element size");
inserted = (LPSHLWAPI_CLIST)buff;
inserted->ulSize = 44; inserted->ulSize = 44;
inserted->ulId = -1; inserted->ulId = -1;
hRet = pSHLWAPI_20(&list, inserted); hRet = pSHLWAPI_20(&list, inserted);
ok(hRet == E_INVALIDARG, "allowed adding a container"); /* The call succeeds but the item is not inserted */
ok(hRet == S_OK, "failed adding a container");
item = SHLWAPI_CLIST_items; item = SHLWAPI_CLIST_items;