Author: hpoussin Date: Fri Dec 21 13:09:46 2007 New Revision: 31367
URL: http://svn.reactos.org/svn/reactos?rev=31367&view=rev Log: Use TRACE/WARN/ERR/FIXME macros for debugging, so they can be enabled at runtime
Modified: trunk/reactos/dll/cpl/ncpa/ncpa.c trunk/reactos/dll/cpl/ncpa/ncpa.h trunk/reactos/dll/cpl/ncpa/ncpa.rbuild trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
Modified: trunk/reactos/dll/cpl/ncpa/ncpa.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/ncpa/ncpa.c?rev=313... ============================================================================== --- trunk/reactos/dll/cpl/ncpa/ncpa.c (original) +++ trunk/reactos/dll/cpl/ncpa/ncpa.c Fri Dec 21 13:09:46 2007 @@ -40,7 +40,7 @@ * the new network support in Reactos. * * If you intend to extend this code by more, please contact me to avoid duplicate work. - * There are already resources and code for TCP/IP configuration that are not + * There are already resources and code for TCP/IP configuration that are not * mature enough for committing them to CVS yet. */
@@ -53,7 +53,13 @@ #include <commctrl.h> #include <cpl.h>
-#include <debug.h> +#include <wine/debug.h> +WINE_DEFAULT_DEBUG_CHANNEL(ncpa); +#ifndef _UNICODE +#define debugstr_aw debugstr_a +#else +#define debugstr_aw debugstr_w +#endif
#include "resource.h" #include "ncpa.h" @@ -96,7 +102,7 @@
if(RegOpenKeyEx(hBaseKey,tpszRegPath,0,KEY_ENUMERATE_SUB_KEYS,&hKey)!=ERROR_SUCCESS) { - DPRINT("EnumRegKeys failed (key not found): %S\n", tpszRegPath); + WARN("EnumRegKeys failed (key not found): %S\n", tpszRegPath); return; }
@@ -106,12 +112,12 @@ ret = RegEnumKeyEx(hKey,i,tpszName,&dwNameLen,NULL,NULL,NULL,NULL); if(ret != ERROR_SUCCESS) { - DPRINT("EnumRegKeys: RegEnumKeyEx failed for %S (rc 0x%lx)\n", tpszName, ret); + WARN("EnumRegKeys: RegEnumKeyEx failed for %S (rc 0x%lx)\n", tpszName, ret); break; }
_stprintf(pszNewPath,_T("%s\%s"),tpszRegPath,tpszName); - DPRINT("EnumRegKeys: Calling user supplied enum function\n"); + TRACE("EnumRegKeys: Calling user supplied enum function\n"); pCallback(pCookie,hBaseKey,pszNewPath);
dwNameLen = sizeof(tpszName); @@ -262,6 +268,7 @@
if(!FindNICClassKeyForCfgInstance(pGlobalData->CurrentAdapterName, tpszSubKey)) { + WARN("NIC Entry not found for '%s'\n", debugstr_w(pGlobalData->CurrentAdapterName)); MessageBox(hwndDlg,_T("NIC Entry not found"),_T("Registry error"),MB_ICONSTOP); MessageBox(hwndDlg,pGlobalData->CurrentAdapterName,tpszSubKey,MB_ICONSTOP); } @@ -309,7 +316,6 @@ RegCloseKey(hNDIKey);
SetDlgItemText(hwndDlg,IDC_DESCRIPTION,tpszHelpText); - } if(HIWORD(wParam)!=LBN_DBLCLK) break; @@ -322,8 +328,9 @@ } else { + FIXME("If you see this, then the IPHLPAPI.DLL probably needs more work because GetAdaptersInfo did not return the expected data.\n"); MessageBox(NULL,_T("If you see this, then the IPHLPAPI.DLL probably needs more work because GetAdaptersInfo did not return the expected data."),_T("Error"),MB_ICONSTOP); - } + } } break; } @@ -360,8 +367,7 @@ else _tcscat(tpszName,_T(" Properties")); RegCloseKey(hKey); - - + ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; @@ -373,7 +379,6 @@ psh.nStartPage = 0; psh.ppsp = psp; psh.pfnCallback = NULL; -
InitPropSheetPage(&psp[0], IDD_NETPROPERTIES, NICPropertyPageProc, (LPARAM)pGlobalData); PropertySheet(&psh); @@ -388,17 +393,18 @@ if (pGlobalData->pFirstAdapterInfo) HeapFree(GetProcessHeap(), 0, pGlobalData->pFirstAdapterInfo);
- BufferSize = sizeof(IP_ADAPTER_INFO); + BufferSize = sizeof(IP_ADAPTER_INFO); pGlobalData->pFirstAdapterInfo = (PIP_ADAPTER_INFO) HeapAlloc(GetProcessHeap(), 0, BufferSize); - - if (GetAdaptersInfo(pGlobalData->pFirstAdapterInfo, &BufferSize) == ERROR_BUFFER_OVERFLOW) - { - HeapFree(GetProcessHeap(), 0, pGlobalData->pFirstAdapterInfo); - pGlobalData->pFirstAdapterInfo = (PIP_ADAPTER_INFO) HeapAlloc(GetProcessHeap(), 0, BufferSize); + + if (GetAdaptersInfo(pGlobalData->pFirstAdapterInfo, &BufferSize) == ERROR_BUFFER_OVERFLOW) + { + HeapFree(GetProcessHeap(), 0, pGlobalData->pFirstAdapterInfo); + pGlobalData->pFirstAdapterInfo = (PIP_ADAPTER_INFO) HeapAlloc(GetProcessHeap(), 0, BufferSize); }
if ((ErrRet = GetAdaptersInfo(pGlobalData->pFirstAdapterInfo, &BufferSize)) != NO_ERROR) { + ERR("error adapterinfo\n"); MessageBox(hwndDlg, _T("error adapterinfo") ,_T("ncpa.cpl"),MB_ICONSTOP);
if (pGlobalData->pFirstAdapterInfo) @@ -449,9 +455,9 @@ } } else if (ERROR_NO_DATA == dwRetVal) - DPRINT("There are no network adapters with IPv4 enabled on the local system\n"); + WARN("There are no network adapters with IPv4 enabled on the local system\n"); else - DPRINT1("GetInterfaceInfo failed.\n"); + ERR("GetInterfaceInfo failed.\n"); }
static VOID @@ -471,7 +477,7 @@ if (firstError) { firstError = FALSE; - DPRINT1("Out of memory - could not allocate MIB_IFTABLE(1)"); + WARN("Out of memory - could not allocate MIB_IFTABLE(1)"); return; } } @@ -490,7 +496,7 @@ if (firstError) { firstError = FALSE; - DPRINT1("Out of memory - could not allocate MIB_IFTABLE(2)"); + WARN("Out of memory - could not allocate MIB_IFTABLE(2)"); }
pGlobalData->IfTableSize = 0; @@ -518,7 +524,7 @@ PMIB_IFROW pIfRow = NULL; TCHAR Buffer[256], LocBuffer[256]; SYSTEMTIME TimeConnected; - + memset(&TimeConnected, 0, sizeof(TimeConnected));
if (pGlobalData->pCurrentAdapterInfo) @@ -593,7 +599,7 @@ break;
default: - DPRINT1("Unknown operation status: %d\n", OperStatus); + WARN("Unknown operation status: %d\n", OperStatus); OperStatus = IDS_STATUS_OPERATIONAL; break; } @@ -630,7 +636,7 @@ if (firstError) { firstError = FALSE; - DPRINT1("GetIfTable failed with error code: %d\n", dwRet); + ERR("GetIfTable failed with error code: %d\n", dwRet); return; } } @@ -698,7 +704,7 @@ switch(uMsg) { case WM_INITDIALOG: - { + { pGlobalData = (PGLOBAL_NCPA_DATA)((LPPROPSHEETPAGE)lParam)->lParam; if (pGlobalData == NULL) return FALSE; @@ -706,14 +712,14 @@ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
if (pGlobalData->pCurrentAdapterInfo) - { + { TCHAR Buffer[64];
if (pGlobalData->pCurrentAdapterInfo->DhcpEnabled) LoadString(hApplet, IDS_ASSIGNED_DHCP, Buffer, sizeof(Buffer) / sizeof(TCHAR)); else LoadString(hApplet, IDS_ASSIGNED_MANUAL, Buffer, sizeof(Buffer) / sizeof(TCHAR)); - + SendDlgItemMessage(hwndDlg, IDC_DETAILSTYPE, WM_SETTEXT, 0, (LPARAM)Buffer); _stprintf(Buffer, _T("%S"), pGlobalData->pCurrentAdapterInfo->IpAddressList.IpAddress.String); SendDlgItemMessage(hwndDlg, IDC_DETAILSIP, WM_SETTEXT, 0, (LPARAM)Buffer); @@ -721,7 +727,7 @@ SendDlgItemMessage(hwndDlg, IDC_DETAILSSUBNET, WM_SETTEXT, 0, (LPARAM)Buffer); _stprintf(Buffer, _T("%S"), pGlobalData->pCurrentAdapterInfo->GatewayList.IpAddress.String); SendDlgItemMessage(hwndDlg, IDC_DETAILSGATEWAY, WM_SETTEXT, 0, (LPARAM)Buffer); - } + } } break; case WM_COMMAND: @@ -733,10 +739,10 @@ break; case IDC_DETAILS: { + FIXME("Not implemented: show detail window\n"); MessageBox(hwndDlg,_T("not implemented: show detail window"),_T("ncpa.cpl"),MB_ICONSTOP); } break; - } break; } @@ -808,7 +814,7 @@
InitPropSheetPage(&psp[0], IDD_CARDPROPERTIES, NICStatusPageProc, (LPARAM)pGlobalData); InitPropSheetPage(&psp[1], IDD_CARDSUPPORT, NICSupportPageProc, (LPARAM)pGlobalData); - + PropertySheet(&psh); return; } @@ -828,6 +834,7 @@ size=sizeof(Info); if(GetAdaptersInfo(Info,&size)!=ERROR_SUCCESS) { + WARN("IPHLPAPI.DLL failed to provide Adapter information\n"); MessageBox(hwndDlg,L"IPHLPAPI.DLL failed to provide Adapter information",L"Error",MB_ICONSTOP); return; } @@ -859,33 +866,33 @@ HWND hwndDlg = (HWND)pCookie; DWORD dwCharacteristics;
- DPRINT("NetAdapterCallback: %S\n", tpszSubKey); + TRACE("NetAdapterCallback: %s\n", debugstr_aw(tpszSubKey));
if(RegOpenKeyEx(hBaseKey,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS) return;
- DPRINT("NetAdapterCallback: Reading Characteristics\n"); + TRACE("NetAdapterCallback: Reading Characteristics\n"); dwType = REG_DWORD; dwSize = sizeof(dwCharacteristics); if(RegQueryValueEx(hKey,_T("Characteristics"),NULL,&dwType,(BYTE*)&dwCharacteristics,&dwSize)!=ERROR_SUCCESS) dwCharacteristics = 0; - if (dwCharacteristics & NCF_HIDDEN) return; - if (!(dwCharacteristics & NCF_VIRTUAL) && !(dwCharacteristics & NCF_PHYSICAL)) return; - - DPRINT("NetAdapterCallback: Reading DriverDesc\n"); + + TRACE("NetAdapterCallback: Reading DriverDesc\n"); dwType = REG_SZ; dwSize = sizeof(tpszDisplayName); if (RegQueryValueEx(hKey,_T("DriverDesc"),NULL,&dwType,(BYTE*)tpszDisplayName,&dwSize)!= ERROR_SUCCESS) _tcscpy(tpszDisplayName,_T("Unnamed Adapter")); + TRACE("Network card: '%s'\n", debugstr_aw(tpszDisplayName));
// get the link to the Enum Subkey (currently unused) //dwType = REG_SZ; //dwSize = sizeof(tpszDeviceID); //if(RegQueryValueEx(hKey,_T("MatchingDeviceId"),NULL,&dwType,(BYTE*)tpszDeviceID,&dwSize) != ERROR_SUCCESS) { + // WARN("Missing MatchingDeviceId Entry\n"); // MessageBox(hwndDlg,_T("Missing MatchingDeviceId Entry"),_T("Registry Problem"),MB_ICONSTOP); // return; //} @@ -893,7 +900,9 @@ // get the card configuration GUID dwType = REG_SZ; dwSize = sizeof(tpszCfgInstanceID); - if(RegQueryValueEx(hKey,_T("NetCfgInstanceId"),NULL,&dwType,(BYTE*)tpszCfgInstanceID,&dwSize) != ERROR_SUCCESS) { + if(RegQueryValueEx(hKey,_T("NetCfgInstanceId"),NULL,&dwType,(BYTE*)tpszCfgInstanceID,&dwSize) != ERROR_SUCCESS) + { + ERR("Missing NetCfgInstanceId Entry\n"); MessageBox(hwndDlg,_T("Missing NetCfgInstanceId Entry"),_T("Registry Problem"),MB_ICONSTOP); return; } @@ -905,7 +914,6 @@ // really represents a device that is currently connected to the system // // How is this done properly ? -
nIndex = (int) SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_ADDSTRING,0,(LPARAM)tpszDisplayName); SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETITEMDATA,nIndex,(LPARAM)ptpszCfgInstanceID); @@ -940,7 +948,7 @@
EnableWindow(GetDlgItem(hwndDlg,IDC_ADD),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVE),FALSE); - + EnumAdapters(hwndDlg); SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETCURSEL,0,0); } @@ -1078,6 +1086,3 @@
return TRUE; } - - -
Modified: trunk/reactos/dll/cpl/ncpa/ncpa.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/ncpa/ncpa.h?rev=313... ============================================================================== --- trunk/reactos/dll/cpl/ncpa/ncpa.h (original) +++ trunk/reactos/dll/cpl/ncpa/ncpa.h Fri Dec 21 13:09:46 2007 @@ -23,8 +23,6 @@
extern HINSTANCE hApplet;
-extern ULONG DbgPrint(PCCH Fmt, ...); - #endif // __NCPA_H
/* EOF */
Modified: trunk/reactos/dll/cpl/ncpa/ncpa.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/ncpa/ncpa.rbuild?re... ============================================================================== --- trunk/reactos/dll/cpl/ncpa/ncpa.rbuild (original) +++ trunk/reactos/dll/cpl/ncpa/ncpa.rbuild Fri Dec 21 13:09:46 2007 @@ -5,6 +5,7 @@ <include base="ncpa">.</include> <define name="_WIN32_IE">0x600</define> <define name="_WIN32_WINNT">0x501</define> + <library>wine</library> <library>kernel32</library> <library>advapi32</library> <library>user32</library> @@ -12,8 +13,6 @@ <library>iphlpapi</library> <library>ws2_32</library> <library>dhcpcsvc</library> - <library>ntdll</library> - <library>msvcrt</library> <file>ncpa.c</file> <file>tcpip_properties.c</file> <file>ncpa.rc</file>
Modified: trunk/reactos/dll/cpl/ncpa/tcpip_properties.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/ncpa/tcpip_properti... ============================================================================== --- trunk/reactos/dll/cpl/ncpa/tcpip_properties.c (original) +++ trunk/reactos/dll/cpl/ncpa/tcpip_properties.c Fri Dec 21 13:09:46 2007 @@ -7,6 +7,7 @@ * Copyright 2006 Ge van Geldorp gvg@reactos.org */
+#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h> @@ -21,20 +22,13 @@
#ifdef _MSC_VER #include <cpl.h> -#else - -// this is missing on reactos... -#ifndef IPM_SETADDRESS -#define IPM_SETADDRESS (WM_USER+101) -#endif - #endif
#include "resource.h" #include "ncpa.h"
-#define NDEBUG -#include <debug.h> +#include <wine/debug.h> +WINE_DEFAULT_DEBUG_CHANNEL(ncpa);
typedef struct _TCPIP_PROPERTIES_DATA { DWORD AdapterIndex; @@ -135,6 +129,7 @@ MsgId, Msg, sizeof(Msg) / sizeof(Msg[0]))) { wcscpy(Msg, L"Unknown error"); } + ERR("%s\n", debugstr_w(Msg)); MessageBoxW(Parent, Msg, Error, MB_OK | MB_ICONSTOP); }
@@ -204,7 +199,7 @@ RowToAdd.dwForwardNextHop = DlgData->Gateway;
CreateIpForwardEntry( &RowToAdd ); - ASSERT(BST_CHECKED == IsDlgButtonChecked(Dlg, IDC_FIXEDDNS)); + assert(BST_CHECKED == IsDlgButtonChecked(Dlg, IDC_FIXEDDNS)); } else { DlgData->IpAddress = INADDR_NONE; DlgData->SubnetMask = INADDR_NONE; @@ -250,7 +245,7 @@
if (! ValidateAndStore(Dlg, DlgData)) { /* Should never happen, we should have validated at PSN_KILLACTIVE */ - ASSERT(FALSE); + assert(FALSE); return FALSE; }
@@ -300,8 +295,6 @@ goto cleanup; }
- // arty ... Not needed anymore ... We update the address live now - //MessageBox(NULL, TEXT("You need to reboot before the new parameters take effect."), TEXT("Reboot required"), MB_OK | MB_ICONWARNING); ret = TRUE;
cleanup: