setupapi: Implement StringTableAddStringEx.
This commit is contained in:
parent
1058561e3b
commit
c2f99f3014
|
@ -189,98 +189,6 @@ StringTableDestroy(HSTRING_TABLE hStringTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* StringTableAddString [SETUPAPI.@]
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* Success: String ID
|
|
||||||
* Failure: -1
|
|
||||||
*
|
|
||||||
* NOTES
|
|
||||||
* If the given string already exists in the string table it will not
|
|
||||||
* be added again. The ID of the existing string will be returned in
|
|
||||||
* this case.
|
|
||||||
*/
|
|
||||||
DWORD WINAPI
|
|
||||||
StringTableAddString(HSTRING_TABLE hStringTable,
|
|
||||||
LPWSTR lpString,
|
|
||||||
DWORD dwFlags)
|
|
||||||
{
|
|
||||||
PSTRING_TABLE pStringTable;
|
|
||||||
DWORD i;
|
|
||||||
|
|
||||||
TRACE("%p %s %x\n", hStringTable, debugstr_w(lpString), dwFlags);
|
|
||||||
|
|
||||||
pStringTable = (PSTRING_TABLE)hStringTable;
|
|
||||||
if (pStringTable == NULL)
|
|
||||||
{
|
|
||||||
ERR("Invalid hStringTable!\n");
|
|
||||||
return (DWORD)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Search for existing string in the string table */
|
|
||||||
for (i = 0; i < pStringTable->dwMaxSlots; i++)
|
|
||||||
{
|
|
||||||
if (pStringTable->pSlots[i].pString != NULL)
|
|
||||||
{
|
|
||||||
if (dwFlags & 1)
|
|
||||||
{
|
|
||||||
if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString))
|
|
||||||
{
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString))
|
|
||||||
{
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for filled slot table */
|
|
||||||
if (pStringTable->dwUsedSlots == pStringTable->dwMaxSlots)
|
|
||||||
{
|
|
||||||
FIXME("Resize the string table!\n");
|
|
||||||
return (DWORD)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Search for an empty slot */
|
|
||||||
for (i = 0; i < pStringTable->dwMaxSlots; i++)
|
|
||||||
{
|
|
||||||
if (pStringTable->pSlots[i].pString == NULL)
|
|
||||||
{
|
|
||||||
pStringTable->pSlots[i].pString = MyMalloc((lstrlenW(lpString) + 1) * sizeof(WCHAR));
|
|
||||||
if (pStringTable->pSlots[i].pString == NULL)
|
|
||||||
{
|
|
||||||
TRACE("Couldn't allocate memory for a new string!\n");
|
|
||||||
return (DWORD)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
lstrcpyW(pStringTable->pSlots[i].pString, lpString);
|
|
||||||
|
|
||||||
pStringTable->dwUsedSlots++;
|
|
||||||
|
|
||||||
return i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("Couldn't find an empty slot!\n");
|
|
||||||
|
|
||||||
return (DWORD)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* StringTableAddStringEx [SETUPAPI.@]
|
* StringTableAddStringEx [SETUPAPI.@]
|
||||||
*
|
*
|
||||||
|
@ -296,7 +204,7 @@ StringTableAddString(HSTRING_TABLE hStringTable,
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: String ID
|
* Success: String ID
|
||||||
* Failure: -1
|
* Failure: ~0u
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* If the given string already exists in the string table it will not
|
* If the given string already exists in the string table it will not
|
||||||
|
@ -304,14 +212,99 @@ StringTableAddString(HSTRING_TABLE hStringTable,
|
||||||
* this case.
|
* this case.
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
StringTableAddStringEx(HSTRING_TABLE hStringTable,
|
StringTableAddStringEx(HSTRING_TABLE hStringTable, LPWSTR lpString,
|
||||||
LPWSTR lpString,
|
DWORD dwFlags, LPVOID lpExtraData, DWORD dwExtraDataSize)
|
||||||
DWORD dwFlags,
|
|
||||||
LPVOID lpExtraData,
|
|
||||||
DWORD dwExtraDataSize)
|
|
||||||
{
|
{
|
||||||
FIXME("\n");
|
PSTRING_TABLE pStringTable;
|
||||||
return (DWORD)-1;
|
DWORD i;
|
||||||
|
|
||||||
|
TRACE("%p %s %x %p, %u\n", hStringTable, debugstr_w(lpString), dwFlags,
|
||||||
|
lpExtraData, dwExtraDataSize);
|
||||||
|
|
||||||
|
pStringTable = (PSTRING_TABLE)hStringTable;
|
||||||
|
if (!pStringTable)
|
||||||
|
{
|
||||||
|
ERR("Invalid hStringTable!\n");
|
||||||
|
return ~0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search for existing string in the string table */
|
||||||
|
for (i = 0; i < pStringTable->dwMaxSlots; i++)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for filled slot table */
|
||||||
|
if (pStringTable->dwUsedSlots == pStringTable->dwMaxSlots)
|
||||||
|
{
|
||||||
|
FIXME("Resize the string table!\n");
|
||||||
|
return ~0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search for an empty slot */
|
||||||
|
for (i = 0; i < pStringTable->dwMaxSlots; i++)
|
||||||
|
{
|
||||||
|
if (!pStringTable->pSlots[i].pString)
|
||||||
|
{
|
||||||
|
pStringTable->pSlots[i].pString = MyMalloc((lstrlenW(lpString) + 1) * sizeof(WCHAR));
|
||||||
|
if (!pStringTable->pSlots[i].pString)
|
||||||
|
{
|
||||||
|
WARN("Couldn't allocate memory for a new string!\n");
|
||||||
|
return ~0u;
|
||||||
|
}
|
||||||
|
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 ~0u;
|
||||||
|
}
|
||||||
|
memcpy(pStringTable->pSlots[i].pData, lpExtraData, dwExtraDataSize);
|
||||||
|
pStringTable->dwUsedSlots++;
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TRACE("Couldn't find an empty slot!\n");
|
||||||
|
return ~0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* StringTableAddString [SETUPAPI.@]
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Success: String ID
|
||||||
|
* Failure: ~0u
|
||||||
|
*
|
||||||
|
* NOTES
|
||||||
|
* If the given string already exists in the string table it will not
|
||||||
|
* be added again. The ID of the existing string will be returned in
|
||||||
|
* this case.
|
||||||
|
*/
|
||||||
|
DWORD WINAPI
|
||||||
|
StringTableAddString(HSTRING_TABLE hStringTable, LPWSTR lpString, DWORD dwFlags)
|
||||||
|
{
|
||||||
|
return StringTableAddStringEx(hStringTable, lpString, dwFlags, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue