urlmon: Added ObtainUserAgentString implementation.

This commit is contained in:
Jacek Caban 2009-06-27 00:37:52 +02:00 committed by Alexandre Julliard
parent 3700d27960
commit cef7e04f18
2 changed files with 33 additions and 25 deletions

View file

@ -631,6 +631,39 @@ HRESULT WINAPI UrlMkSetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBuf
return S_OK;
}
/**************************************************************************
* ObtainUserAgentString (URLMON.@)
*/
HRESULT WINAPI ObtainUserAgentString(DWORD dwOption, LPSTR pcszUAOut, DWORD *cbSize)
{
DWORD size;
HRESULT hres = E_FAIL;
TRACE("(%d %p %p)\n", dwOption, pcszUAOut, cbSize);
if(!pcszUAOut || !cbSize)
return E_INVALIDARG;
EnterCriticalSection(&session_cs);
ensure_useragent();
if(user_agent) {
size = WideCharToMultiByte(CP_ACP, 0, user_agent, -1, NULL, 0, NULL, NULL);
if(size <= *cbSize) {
WideCharToMultiByte(CP_ACP, 0, user_agent, -1, pcszUAOut, *cbSize, NULL, NULL);
hres = S_OK;
}else {
hres = E_OUTOFMEMORY;
}
*cbSize = size;
}
LeaveCriticalSection(&session_cs);
return hres;
}
void free_session(void)
{
heap_free(user_agent);

View file

@ -362,31 +362,6 @@ HRESULT WINAPI DllRegisterServerEx(void)
return E_FAIL;
}
static const CHAR Agent[] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
/**************************************************************************
* ObtainUserAgentString (URLMON.@)
*/
HRESULT WINAPI ObtainUserAgentString(DWORD dwOption, LPSTR pcszUAOut, DWORD *cbSize)
{
FIXME("(%d, %p, %p): stub\n", dwOption, pcszUAOut, cbSize);
if (pcszUAOut == NULL || cbSize == NULL)
return E_INVALIDARG;
if (*cbSize < sizeof(Agent))
{
*cbSize = sizeof(Agent);
return E_OUTOFMEMORY;
}
if (sizeof(Agent) < *cbSize)
*cbSize = sizeof(Agent);
lstrcpynA(pcszUAOut, Agent, *cbSize);
return S_OK;
}
/**************************************************************************
* IsValidURL (URLMON.@)
*