Commit 1d5e6b67 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

Better TRACEing in some functions.

parent 453d0903
......@@ -725,13 +725,121 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
BOOL bSuccess = FALSE;
LPWININETHTTPREQA lpwhr;
TRACE("(0x%08lx)--> %ld\n", dwInfoLevel, dwInfoLevel);
if (TRACE_ON(wininet)) {
#define FE(x) { x, #x }
static const wininet_flag_info query_flags[] = {
FE(HTTP_QUERY_MIME_VERSION),
FE(HTTP_QUERY_CONTENT_TYPE),
FE(HTTP_QUERY_CONTENT_TRANSFER_ENCODING),
FE(HTTP_QUERY_CONTENT_ID),
FE(HTTP_QUERY_CONTENT_DESCRIPTION),
FE(HTTP_QUERY_CONTENT_LENGTH),
FE(HTTP_QUERY_CONTENT_LANGUAGE),
FE(HTTP_QUERY_ALLOW),
FE(HTTP_QUERY_PUBLIC),
FE(HTTP_QUERY_DATE),
FE(HTTP_QUERY_EXPIRES),
FE(HTTP_QUERY_LAST_MODIFIED),
FE(HTTP_QUERY_MESSAGE_ID),
FE(HTTP_QUERY_URI),
FE(HTTP_QUERY_DERIVED_FROM),
FE(HTTP_QUERY_COST),
FE(HTTP_QUERY_LINK),
FE(HTTP_QUERY_PRAGMA),
FE(HTTP_QUERY_VERSION),
FE(HTTP_QUERY_STATUS_CODE),
FE(HTTP_QUERY_STATUS_TEXT),
FE(HTTP_QUERY_RAW_HEADERS),
FE(HTTP_QUERY_RAW_HEADERS_CRLF),
FE(HTTP_QUERY_CONNECTION),
FE(HTTP_QUERY_ACCEPT),
FE(HTTP_QUERY_ACCEPT_CHARSET),
FE(HTTP_QUERY_ACCEPT_ENCODING),
FE(HTTP_QUERY_ACCEPT_LANGUAGE),
FE(HTTP_QUERY_AUTHORIZATION),
FE(HTTP_QUERY_CONTENT_ENCODING),
FE(HTTP_QUERY_FORWARDED),
FE(HTTP_QUERY_FROM),
FE(HTTP_QUERY_IF_MODIFIED_SINCE),
FE(HTTP_QUERY_LOCATION),
FE(HTTP_QUERY_ORIG_URI),
FE(HTTP_QUERY_REFERER),
FE(HTTP_QUERY_RETRY_AFTER),
FE(HTTP_QUERY_SERVER),
FE(HTTP_QUERY_TITLE),
FE(HTTP_QUERY_USER_AGENT),
FE(HTTP_QUERY_WWW_AUTHENTICATE),
FE(HTTP_QUERY_PROXY_AUTHENTICATE),
FE(HTTP_QUERY_ACCEPT_RANGES),
FE(HTTP_QUERY_SET_COOKIE),
FE(HTTP_QUERY_COOKIE),
FE(HTTP_QUERY_REQUEST_METHOD),
FE(HTTP_QUERY_REFRESH),
FE(HTTP_QUERY_CONTENT_DISPOSITION),
FE(HTTP_QUERY_AGE),
FE(HTTP_QUERY_CACHE_CONTROL),
FE(HTTP_QUERY_CONTENT_BASE),
FE(HTTP_QUERY_CONTENT_LOCATION),
FE(HTTP_QUERY_CONTENT_MD5),
FE(HTTP_QUERY_CONTENT_RANGE),
FE(HTTP_QUERY_ETAG),
FE(HTTP_QUERY_HOST),
FE(HTTP_QUERY_IF_MATCH),
FE(HTTP_QUERY_IF_NONE_MATCH),
FE(HTTP_QUERY_IF_RANGE),
FE(HTTP_QUERY_IF_UNMODIFIED_SINCE),
FE(HTTP_QUERY_MAX_FORWARDS),
FE(HTTP_QUERY_PROXY_AUTHORIZATION),
FE(HTTP_QUERY_RANGE),
FE(HTTP_QUERY_TRANSFER_ENCODING),
FE(HTTP_QUERY_UPGRADE),
FE(HTTP_QUERY_VARY),
FE(HTTP_QUERY_VIA),
FE(HTTP_QUERY_WARNING),
FE(HTTP_QUERY_CUSTOM)
};
static const wininet_flag_info modifier_flags[] = {
FE(HTTP_QUERY_FLAG_REQUEST_HEADERS),
FE(HTTP_QUERY_FLAG_SYSTEMTIME),
FE(HTTP_QUERY_FLAG_NUMBER),
FE(HTTP_QUERY_FLAG_COALESCE)
};
#undef FE
DWORD info_mod = dwInfoLevel & HTTP_QUERY_MODIFIER_FLAGS_MASK;
DWORD info = dwInfoLevel & HTTP_QUERY_HEADER_MASK;
int i;
TRACE("(%p, 0x%08lx)--> %ld\n", hHttpRequest, dwInfoLevel, dwInfoLevel);
TRACE(" Attribute:");
for (i = 0; i < (sizeof(query_flags) / sizeof(query_flags[0])); i++) {
if (query_flags[i].val == info) {
DPRINTF(" %s", query_flags[i].name);
break;
}
}
if (i == (sizeof(query_flags) / sizeof(query_flags[0]))) {
DPRINTF(" Unknown (%08lx)", info);
}
DPRINTF(" Modifier:");
for (i = 0; i < (sizeof(modifier_flags) / sizeof(modifier_flags[0])); i++) {
if (modifier_flags[i].val & info_mod) {
DPRINTF(" %s", modifier_flags[i].name);
info_mod &= ~ modifier_flags[i].val;
}
}
if (info_mod) {
DPRINTF(" Unknown (%08lx)", info_mod);
}
DPRINTF("\n");
}
lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
goto lend;
}
/* Find requested header structure */
......@@ -831,8 +939,10 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
/* coalesce value to reuqested type */
if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER)
{
*(int *)lpBuffer = atoi(lphttpHdr->lpszValue);
bSuccess = TRUE;
*(int *)lpBuffer = atoi(lphttpHdr->lpszValue);
bSuccess = TRUE;
TRACE(" returning number : %d\n", *(int *)lpBuffer);
}
else if (dwInfoLevel & HTTP_QUERY_FLAG_SYSTEMTIME)
{
......@@ -847,16 +957,20 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
if(STHook==NULL)
goto lend;
STHook->wDay = tmpTM.tm_mday;
STHook->wHour = tmpTM.tm_hour;
STHook->wMilliseconds = 0;
STHook->wMinute = tmpTM.tm_min;
STHook->wDayOfWeek = tmpTM.tm_wday;
STHook->wMonth = tmpTM.tm_mon + 1;
STHook->wSecond = tmpTM.tm_sec;
STHook->wYear = tmpTM.tm_year;
bSuccess = TRUE;
STHook->wDay = tmpTM.tm_mday;
STHook->wHour = tmpTM.tm_hour;
STHook->wMilliseconds = 0;
STHook->wMinute = tmpTM.tm_min;
STHook->wDayOfWeek = tmpTM.tm_wday;
STHook->wMonth = tmpTM.tm_mon + 1;
STHook->wSecond = tmpTM.tm_sec;
STHook->wYear = tmpTM.tm_year;
bSuccess = TRUE;
TRACE(" returning time : %04d/%02d/%02d - %d - %02d:%02d:%02d.%02d\n",
STHook->wYear, STHook->wMonth, STHook->wDay, STHook->wDayOfWeek,
STHook->wHour, STHook->wMinute, STHook->wSecond, STHook->wMilliseconds);
}
else if (dwInfoLevel & HTTP_QUERY_FLAG_COALESCE)
{
......@@ -885,6 +999,8 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
((char*)lpBuffer)[len]=0;
*lpdwBufferLength = len;
bSuccess = TRUE;
TRACE(" returning string : '%s'\n", debugstr_a(lpBuffer));
}
lend:
......
......@@ -405,10 +405,45 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
{
LPWININETAPPINFOA lpwai = NULL;
HINTERNET handle;
TRACE("(%s, %li, %s, %s, %li)\n", debugstr_a(lpszAgent), dwAccessType,
debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
HINTERNET handle = NULL;
if (TRACE_ON(wininet)) {
#define FE(x) { x, #x }
static const wininet_flag_info access_type[] = {
FE(INTERNET_OPEN_TYPE_PRECONFIG),
FE(INTERNET_OPEN_TYPE_DIRECT),
FE(INTERNET_OPEN_TYPE_PROXY),
FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY)
};
static const wininet_flag_info flag[] = {
FE(INTERNET_FLAG_ASYNC),
FE(INTERNET_FLAG_FROM_CACHE),
FE(INTERNET_FLAG_OFFLINE)
};
#undef FE
int i;
const char *access_type_str = "Unknown";
DWORD flag_val = dwFlags;
TRACE("(%s, %li, %s, %s, %li)\n", debugstr_a(lpszAgent), dwAccessType,
debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
for (i = 0; i < (sizeof(access_type) / sizeof(access_type[0])); i++) {
if (access_type[i].val == dwAccessType) {
access_type_str = access_type[i].name;
break;
}
}
TRACE(" access type : %s\n", access_type_str);
TRACE(" flags :");
for (i = 0; i < (sizeof(flag) / sizeof(flag[0])); i++) {
if (flag[i].val & flag_val) {
DPRINTF(" %s", flag[i].name);
flag_val &= ~flag[i].val;
}
}
if (flag_val) DPRINTF(" Unknown flags (%08lx)", flag_val);
DPRINTF("\n");
}
/* Clear any error information */
INTERNET_SetLastError(0);
......@@ -417,7 +452,7 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
if (NULL == lpwai)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return NULL;
goto lend;
}
memset(lpwai, 0, sizeof(WININETAPPINFOA));
......@@ -433,7 +468,7 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
{
HeapFree( GetProcessHeap(), 0, lpwai );
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return NULL;
goto lend;
}
if (NULL != lpszAgent)
......@@ -461,6 +496,7 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
strcpy( lpwai->lpszProxyBypass, lpszProxyBypass );
}
lend:
TRACE("returning %p\n", (HINTERNET)lpwai);
return handle;
......@@ -2382,7 +2418,39 @@ VOID INTERNET_ExecuteWork()
if (!INTERNET_GetWorkRequest(&workRequest))
return;
TRACE("Got work %d\n", workRequest.asyncall);
if (TRACE_ON(wininet)) {
static const wininet_flag_info work_request_types[] = {
#define FE(x) { x, #x }
FE(FTPPUTFILEA),
FE(FTPSETCURRENTDIRECTORYA),
FE(FTPCREATEDIRECTORYA),
FE(FTPFINDFIRSTFILEA),
FE(FTPGETCURRENTDIRECTORYA),
FE(FTPOPENFILEA),
FE(FTPGETFILEA),
FE(FTPDELETEFILEA),
FE(FTPREMOVEDIRECTORYA),
FE(FTPRENAMEFILEA),
FE(INTERNETFINDNEXTA),
FE(HTTPSENDREQUESTA),
FE(HTTPOPENREQUESTA),
FE(SENDCALLBACK),
FE(INTERNETOPENURLA)
#undef FE
};
int i;
const char *val = "Unknown";
for (i = 0; i < (sizeof(work_request_types) / sizeof(work_request_types[0])); i++) {
if (work_request_types[i].val == workRequest.asyncall) {
val = work_request_types[i].name;
break;
}
}
TRACE("Got work %d (%s)\n", workRequest.asyncall, val);
}
switch (workRequest.asyncall)
{
case FTPPUTFILEA:
......
......@@ -408,5 +408,11 @@ BOOL NETCON_getNextLine(WININET_NETCONNECTION *connection, LPSTR lpszBuffer, LPD
#define MAX_REPLY_LEN 0x5B4
/* Used for debugging - maybe need to be shared in the Wine debugging code ? */
typedef struct
{
DWORD val;
const char* name;
} wininet_flag_info;
#endif /* _WINE_INTERNET_H_ */
......@@ -169,6 +169,49 @@ BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
* Helper function for sending async Callbacks
*/
static const char *get_callback_name(DWORD dwInternetStatus) {
static const wininet_flag_info internet_status[] = {
#define FE(x) { x, #x }
FE(INTERNET_STATUS_RESOLVING_NAME),
FE(INTERNET_STATUS_NAME_RESOLVED),
FE(INTERNET_STATUS_CONNECTING_TO_SERVER),
FE(INTERNET_STATUS_CONNECTED_TO_SERVER),
FE(INTERNET_STATUS_SENDING_REQUEST),
FE(INTERNET_STATUS_REQUEST_SENT),
FE(INTERNET_STATUS_RECEIVING_RESPONSE),
FE(INTERNET_STATUS_RESPONSE_RECEIVED),
FE(INTERNET_STATUS_CTL_RESPONSE_RECEIVED),
FE(INTERNET_STATUS_PREFETCH),
FE(INTERNET_STATUS_CLOSING_CONNECTION),
FE(INTERNET_STATUS_CONNECTION_CLOSED),
FE(INTERNET_STATUS_HANDLE_CREATED),
FE(INTERNET_STATUS_HANDLE_CLOSING),
FE(INTERNET_STATUS_REQUEST_COMPLETE),
FE(INTERNET_STATUS_REDIRECT),
FE(INTERNET_STATUS_INTERMEDIATE_RESPONSE),
FE(INTERNET_STATUS_USER_INPUT_REQUIRED),
FE(INTERNET_STATUS_STATE_CHANGE),
FE(INTERNET_STATUS_COOKIE_SENT),
FE(INTERNET_STATUS_COOKIE_RECEIVED),
FE(INTERNET_STATUS_PRIVACY_IMPACTED),
FE(INTERNET_STATUS_P3P_HEADER),
FE(INTERNET_STATUS_P3P_POLICYREF),
FE(INTERNET_STATUS_COOKIE_HISTORY),
FE(INTERNET_STATE_CONNECTED),
FE(INTERNET_STATE_DISCONNECTED),
FE(INTERNET_STATE_DISCONNECTED_BY_USER),
FE(INTERNET_STATE_IDLE),
FE(INTERNET_STATE_BUSY)
#undef FE
};
int i;
for (i = 0; i < (sizeof(internet_status) / sizeof(internet_status[0])); i++) {
if (internet_status[i].val == dwInternetStatus) return internet_status[i].name;
}
return "Unknown";
}
VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo, DWORD dwStatusInfoLength)
......@@ -181,12 +224,12 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
if( !dwContext )
return;
TRACE("--> Callback %ld\n",dwInternetStatus);
TRACE("--> Callback %ld (%s)\n",dwInternetStatus, get_callback_name(dwInternetStatus));
hIC->lpfnStatusCB(hHttpSession, dwContext, dwInternetStatus,
lpvStatusInfo, dwStatusInfoLength);
TRACE("<-- Callback %ld\n",dwInternetStatus);
TRACE("<-- Callback %ld (%s)\n",dwInternetStatus, get_callback_name(dwInternetStatus));
}
......@@ -195,7 +238,7 @@ VOID SendAsyncCallback(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo, DWORD dwStatusInfoLength)
{
TRACE("Send Callback %ld\n",dwInternetStatus);
TRACE("Send Callback %ld (%s)\n",dwInternetStatus, get_callback_name(dwInternetStatus));
if (! (hIC->lpfnStatusCB))
return;
......
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