Commit cef7e04f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Added ObtainUserAgentString implementation.

parent 3700d279
......@@ -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);
......
......@@ -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.@)
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment