void process_document_response_headers(HTMLDocumentNode *doc, IBinding *binding) { IWinInetHttpInfo *http_info; char buf[1024]; DWORD size; HRESULT hres; hres = IBinding_QueryInterface(binding, &IID_IWinInetHttpInfo, (void**)&http_info); if(FAILED(hres)) { TRACE("No IWinInetHttpInfo\n"); return; } size = sizeof(buf); strcpy(buf, "X-UA-Compatible"); hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_CUSTOM, buf, &size, NULL, NULL); if(hres == S_OK && size) { compat_mode_t document_mode; WCHAR *header; TRACE("size %u\n", size); header = heap_strdupAtoW(buf); if(header && parse_ua_compatible(header, &document_mode)) { TRACE("setting document mode %d\n", document_mode); set_document_mode(doc, document_mode, FALSE); } heap_free(header); } IWinInetHttpInfo_Release(http_info); }
static LPWSTR get_url(void) { DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR); WCHAR *url, *config_key; HKEY hkey; DWORD res, type; DWORD returned_size; static const WCHAR httpW[] = {'h','t','t','p'}; url = heap_alloc(size); returned_size = size; hkey = open_config_key(); if (hkey) { config_key = heap_strdupAtoW(addon->url_config_key); res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size); heap_free(config_key); RegCloseKey(hkey); if(res == ERROR_SUCCESS && type == REG_SZ) goto found; } MultiByteToWideChar( CP_ACP, 0, addon->url_default, -1, url, size / sizeof(WCHAR) ); found: if (returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) append_url_params( url ); TRACE("Got URL %s\n", debugstr_w(url)); return url; }
/*********************************************************************** * URLDownloadToFileA (URLMON.@) * * Downloads URL szURL to rile szFileName and call lpfnCB callback to * report progress. * * PARAMS * pCaller [I] controlling IUnknown interface. * szURL [I] URL of the file to download * szFileName [I] file name to store the content of the URL * dwReserved [I] reserved - set to 0 * lpfnCB [I] callback for progress report * * RETURNS * S_OK on success */ HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN pCaller, LPCSTR szURL, LPCSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB) { LPWSTR urlW, file_nameW; HRESULT hres; TRACE("(%p %s %s %d %p)\n", pCaller, debugstr_a(szURL), debugstr_a(szFileName), dwReserved, lpfnCB); urlW = heap_strdupAtoW(szURL); file_nameW = heap_strdupAtoW(szFileName); hres = URLDownloadToFileW(pCaller, urlW, file_nameW, dwReserved, lpfnCB); heap_free(urlW); heap_free(file_nameW); return hres; }
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInfo, DWORD dwStatusInfoLength) { LPVOID lpvNewInfo = NULL; if( !hdr->lpfnStatusCB ) return; /* the IE5 version of wininet does not send callbacks if dwContext is zero */ if( !dwContext ) return; lpvNewInfo = lpvStatusInfo; if(hdr->dwInternalFlags & INET_CALLBACKW) { switch(dwInternetStatus) { case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: lpvNewInfo = heap_strdupAtoW(lpvStatusInfo); dwStatusInfoLength *= sizeof(WCHAR); break; case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: lpvNewInfo = heap_strdupW(lpvStatusInfo); break; } }else { switch(dwInternetStatus) { case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER: lpvNewInfo = heap_alloc(strlen(lpvStatusInfo) + 1); if (lpvNewInfo) strcpy(lpvNewInfo, lpvStatusInfo); break; case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT: lpvNewInfo = heap_strdupWtoA(lpvStatusInfo); dwStatusInfoLength /= sizeof(WCHAR); break; } } TRACE(" callback(%p) (%p (%p), %08lx, %d (%s), %p, %d)\n", hdr->lpfnStatusCB, hdr->hInternet, hdr, dwContext, dwInternetStatus, get_callback_name(dwInternetStatus), lpvNewInfo, dwStatusInfoLength); hdr->lpfnStatusCB(hdr->hInternet, dwContext, dwInternetStatus, lpvNewInfo, dwStatusInfoLength); TRACE(" end callback().\n"); if(lpvNewInfo != lpvStatusInfo) HeapFree(GetProcessHeap(), 0, lpvNewInfo); }
BOOL WINAPI SQLWritePrivateProfileString(LPCSTR lpszSection, LPCSTR lpszEntry, LPCSTR lpszString, LPCSTR lpszFilename) { BOOL ret; WCHAR *sect, *entry, *string, *file; clear_errors(); TRACE("%s %s %s %s\n", lpszSection, lpszEntry, lpszString, lpszFilename); sect = heap_strdupAtoW(lpszSection); entry = heap_strdupAtoW(lpszEntry); string = heap_strdupAtoW(lpszString); file = heap_strdupAtoW(lpszFilename); ret = SQLWritePrivateProfileStringW(sect, entry, string, file); heap_free(sect); heap_free(entry); heap_free(string); heap_free(file); return ret; }
static LPWSTR get_url(void) { DWORD size = INTERNET_MAX_URL_LENGTH*sizeof(WCHAR); WCHAR *url, *config_key; HKEY hkey; DWORD res, type; DWORD returned_size; static const WCHAR httpW[] = {'h','t','t','p'}; static const WCHAR arch_formatW[] = {'?','a','r','c','h','='}; static const WCHAR v_formatW[] = {'&','v','='}; hkey = open_config_key(); if(!hkey) return NULL; url = heap_alloc(size); returned_size = size; config_key = heap_strdupAtoW(addon->url_config_key); res = RegQueryValueExW(hkey, config_key, NULL, &type, (LPBYTE)url, &returned_size); heap_free(config_key); RegCloseKey(hkey); if(res != ERROR_SUCCESS || type != REG_SZ) { heap_free(url); return NULL; } if(returned_size > sizeof(httpW) && !memcmp(url, httpW, sizeof(httpW))) { DWORD len; len = strlenW(url); memcpy(url+len, arch_formatW, sizeof(arch_formatW)); len += sizeof(arch_formatW)/sizeof(WCHAR); len += MultiByteToWideChar(CP_ACP, 0, ARCH_STRING, sizeof(ARCH_STRING), url+len, size/sizeof(WCHAR)-len)-1; memcpy(url+len, v_formatW, sizeof(v_formatW)); len += sizeof(v_formatW)/sizeof(WCHAR); MultiByteToWideChar(CP_ACP, 0, addon->version, -1, url+len, size/sizeof(WCHAR)-len); } TRACE("Got URL %s\n", debugstr_w(url)); return url; }
static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR context, DWORD internet_status, LPVOID status_info, DWORD status_info_len) { Protocol *protocol = (Protocol*)context; switch(internet_status) { case INTERNET_STATUS_RESOLVING_NAME: TRACE("%p INTERNET_STATUS_RESOLVING_NAME\n", protocol); report_progress(protocol, BINDSTATUS_FINDINGRESOURCE, (LPWSTR)status_info); break; case INTERNET_STATUS_CONNECTING_TO_SERVER: { WCHAR *info; TRACE("%p INTERNET_STATUS_CONNECTING_TO_SERVER %s\n", protocol, (const char*)status_info); info = heap_strdupAtoW(status_info); if(!info) return; report_progress(protocol, BINDSTATUS_CONNECTING, info); heap_free(info); break; } case INTERNET_STATUS_SENDING_REQUEST: TRACE("%p INTERNET_STATUS_SENDING_REQUEST\n", protocol); report_progress(protocol, BINDSTATUS_SENDINGREQUEST, (LPWSTR)status_info); break; case INTERNET_STATUS_REDIRECT: TRACE("%p INTERNET_STATUS_REDIRECT\n", protocol); report_progress(protocol, BINDSTATUS_REDIRECTING, (LPWSTR)status_info); break; case INTERNET_STATUS_REQUEST_COMPLETE: request_complete(protocol, status_info); break; case INTERNET_STATUS_HANDLE_CREATED: TRACE("%p INTERNET_STATUS_HANDLE_CREATED\n", protocol); IInternetProtocol_AddRef(protocol->protocol); break; case INTERNET_STATUS_HANDLE_CLOSING: TRACE("%p INTERNET_STATUS_HANDLE_CLOSING\n", protocol); if(*(HINTERNET *)status_info == protocol->request) { protocol->request = NULL; if(protocol->protocol_sink) { IInternetProtocolSink_Release(protocol->protocol_sink); protocol->protocol_sink = NULL; } if(protocol->bind_info.cbSize) { ReleaseBindInfo(&protocol->bind_info); memset(&protocol->bind_info, 0, sizeof(protocol->bind_info)); } }else if(*(HINTERNET *)status_info == protocol->connection) { protocol->connection = NULL; } IInternetProtocol_Release(protocol->protocol); break; default: WARN("Unhandled Internet status callback %d\n", internet_status); } }