[2/3] setupapi: Implement StringTableAddStringEx.
Hans Leidekker
hans at codeweavers.com
Mon Dec 8 05:35:06 CST 2008
diff --git a/dlls/setupapi/stringtable.c b/dlls/setupapi/stringtable.c
index 59ad6ce..b789964 100644
--- a/dlls/setupapi/stringtable.c
+++ b/dlls/setupapi/stringtable.c
@@ -190,19 +190,21 @@ StringTableDestroy(HSTRING_TABLE hStringTable)
/**************************************************************************
- * StringTableAddString [SETUPAPI.@]
+ * StringTableAddStringEx [SETUPAPI.@]
*
- * Adds a new string to the string table.
+ * Adds a new string plus extra data to the string table.
*
* PARAMS
- * hStringTable [I] Handle to the string table
- * lpString [I] String to be added to the string table
- * dwFlags [I] Flags
- * 1: case sensitive compare
+ * hStringTable [I] Handle to the string table
+ * lpString [I] String to be added to the string table
+ * dwFlags [I] Flags
+ * 1: case sensitive compare
+ * lpExtraData [I] Pointer to the extra data
+ * dwExtraDataSize [I] Size of the extra data
*
* RETURNS
* Success: String ID
- * Failure: -1
+ * Failure: ~0UL
*
* NOTES
* If the given string already exists in the string table it will not
@@ -210,40 +212,36 @@ StringTableDestroy(HSTRING_TABLE hStringTable)
* this case.
*/
DWORD WINAPI
-StringTableAddString(HSTRING_TABLE hStringTable,
- LPWSTR lpString,
- DWORD dwFlags)
+StringTableAddStringEx(HSTRING_TABLE hStringTable, LPWSTR lpString,
+ DWORD dwFlags, LPVOID lpExtraData, DWORD dwExtraDataSize)
{
PSTRING_TABLE pStringTable;
DWORD i;
- TRACE("%p %s %x\n", hStringTable, debugstr_w(lpString), dwFlags);
+ TRACE("%p %s %x %p, %u\n", hStringTable, debugstr_w(lpString), dwFlags,
+ lpExtraData, dwExtraDataSize);
pStringTable = (PSTRING_TABLE)hStringTable;
- if (pStringTable == NULL)
+ if (!pStringTable)
{
ERR("Invalid hStringTable!\n");
- return (DWORD)-1;
+ return ~0UL;
}
/* Search for existing string in the string table */
for (i = 0; i < pStringTable->dwMaxSlots; i++)
{
- if (pStringTable->pSlots[i].pString != NULL)
+ if (pStringTable->pSlots[i].pString)
{
if (dwFlags & 1)
{
if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString))
- {
return i + 1;
- }
}
else
{
if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString))
- {
return i + 1;
- }
}
}
}
@@ -252,51 +250,51 @@ StringTableAddString(HSTRING_TABLE hStringTable,
if (pStringTable->dwUsedSlots == pStringTable->dwMaxSlots)
{
FIXME("Resize the string table!\n");
- return (DWORD)-1;
+ return ~0UL;
}
/* Search for an empty slot */
for (i = 0; i < pStringTable->dwMaxSlots; i++)
{
- if (pStringTable->pSlots[i].pString == NULL)
+ if (!pStringTable->pSlots[i].pString)
{
pStringTable->pSlots[i].pString = MyMalloc((lstrlenW(lpString) + 1) * sizeof(WCHAR));
- if (pStringTable->pSlots[i].pString == NULL)
+ if (!pStringTable->pSlots[i].pString)
{
- TRACE("Couldn't allocate memory for a new string!\n");
- return (DWORD)-1;
+ WARN("Couldn't allocate memory for a new string!\n");
+ return ~0UL;
}
-
lstrcpyW(pStringTable->pSlots[i].pString, lpString);
+ pStringTable->pSlots[i].pData = MyMalloc(dwExtraDataSize);
+ if (!pStringTable->pSlots[i].pData)
+ {
+ TRACE("Couldn't allocate memory for data!\n");
+ return ~0UL;
+ }
+ memcpy(pStringTable->pSlots[i].pData, lpExtraData, dwExtraDataSize);
pStringTable->dwUsedSlots++;
-
return i + 1;
}
}
-
TRACE("Couldn't find an empty slot!\n");
-
- return (DWORD)-1;
+ return ~0UL;
}
-
/**************************************************************************
- * StringTableAddStringEx [SETUPAPI.@]
+ * StringTableAddString [SETUPAPI.@]
*
- * Adds a new string plus extra data to the string table.
+ * Adds a new string to the string table.
*
* PARAMS
- * hStringTable [I] Handle to the string table
- * lpString [I] String to be added to the string table
- * dwFlags [I] Flags
- * 1: case sensitive compare
- * lpExtraData [I] Pointer to the extra data
- * dwExtraDataSize [I] Size of the extra data
+ * hStringTable [I] Handle to the string table
+ * lpString [I] String to be added to the string table
+ * dwFlags [I] Flags
+ * 1: case sensitive compare
*
* RETURNS
* Success: String ID
- * Failure: -1
+ * Failure: ~0UL
*
* NOTES
* If the given string already exists in the string table it will not
@@ -304,14 +302,9 @@ StringTableAddString(HSTRING_TABLE hStringTable,
* this case.
*/
DWORD WINAPI
-StringTableAddStringEx(HSTRING_TABLE hStringTable,
- LPWSTR lpString,
- DWORD dwFlags,
- LPVOID lpExtraData,
- DWORD dwExtraDataSize)
+StringTableAddString(HSTRING_TABLE hStringTable, LPWSTR lpString, DWORD dwFlags)
{
- FIXME("\n");
- return (DWORD)-1;
+ return StringTableAddStringEx(hStringTable, lpString, dwFlags, NULL, 0);
}
More information about the wine-patches
mailing list