[IPCONFIG] Indentation and coding style fixes. No code changes!

This commit is contained in:
Eric Kohl 2019-06-13 02:35:16 +02:00
parent cc25a266f2
commit cd579382b5

View file

@ -30,23 +30,23 @@ HINSTANCE hInstance;
HANDLE ProcessHeap; HANDLE ProcessHeap;
int LoadStringAndOem(HINSTANCE hInst, int LoadStringAndOem(HINSTANCE hInst,
UINT uID, UINT uID,
LPTSTR szNode, LPTSTR szNode,
int byteSize int byteSize)
)
{ {
TCHAR *szTmp; TCHAR *szTmp;
int res; int res;
szTmp = (LPTSTR)HeapAlloc(ProcessHeap, 0, byteSize); szTmp = (LPTSTR)HeapAlloc(ProcessHeap, 0, byteSize);
if (szTmp == NULL) if (szTmp == NULL)
{ {
return 0; return 0;
} }
res = LoadString(hInst, uID, szTmp, byteSize);
CharToOem(szTmp, szNode); res = LoadString(hInst, uID, szTmp, byteSize);
HeapFree(ProcessHeap, 0, szTmp); CharToOem(szTmp, szNode);
return res; HeapFree(ProcessHeap, 0, szTmp);
return res;
} }
LPTSTR GetNodeTypeName(UINT NodeType) LPTSTR GetNodeTypeName(UINT NodeType)
@ -197,16 +197,16 @@ LPTSTR GetConnectionType(LPTSTR lpClass)
KEY_READ, KEY_READ,
&hKey) == ERROR_SUCCESS) &hKey) == ERROR_SUCCESS)
{ {
if(RegQueryValueEx(hKey, if (RegQueryValueEx(hKey,
_T("Name"), _T("Name"),
NULL, NULL,
&dwType, &dwType,
NULL, NULL,
&dwDataSize) == ERROR_SUCCESS) &dwDataSize) == ERROR_SUCCESS)
{ {
ConTypeTmp = (LPTSTR)HeapAlloc(ProcessHeap, ConTypeTmp = (LPTSTR)HeapAlloc(ProcessHeap,
0, 0,
dwDataSize); dwDataSize);
if (ConTypeTmp == NULL) if (ConTypeTmp == NULL)
return NULL; return NULL;
@ -220,13 +220,13 @@ LPTSTR GetConnectionType(LPTSTR lpClass)
HeapFree(ProcessHeap, 0, ConTypeTmp); HeapFree(ProcessHeap, 0, ConTypeTmp);
return NULL; return NULL;
} }
if(RegQueryValueEx(hKey, if (RegQueryValueEx(hKey,
_T("Name"), _T("Name"),
NULL, NULL,
&dwType, &dwType,
(PBYTE)ConTypeTmp, (PBYTE)ConTypeTmp,
&dwDataSize) != ERROR_SUCCESS) &dwDataSize) != ERROR_SUCCESS)
{ {
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
@ -235,7 +235,8 @@ LPTSTR GetConnectionType(LPTSTR lpClass)
ConType = NULL; ConType = NULL;
} }
if (ConType) CharToOem(ConTypeTmp, ConType); if (ConType)
CharToOem(ConTypeTmp, ConType);
HeapFree(ProcessHeap, 0, ConTypeTmp); HeapFree(ProcessHeap, 0, ConTypeTmp);
} }
} }
@ -268,7 +269,7 @@ LPTSTR GetConnectionDescription(LPTSTR lpClass)
return NULL; return NULL;
} }
for (i=0; ; i++) for (i = 0; ; i++)
{ {
DWORD PathSize; DWORD PathSize;
LONG Status; LONG Status;
@ -317,12 +318,12 @@ LPTSTR GetConnectionDescription(LPTSTR lpClass)
HeapFree(ProcessHeap, 0, lpPath); HeapFree(ProcessHeap, 0, lpPath);
lpPath = NULL; lpPath = NULL;
if(RegQueryValueEx(hClassKey, if (RegQueryValueEx(hClassKey,
_T("NetCfgInstanceId"), _T("NetCfgInstanceId"),
NULL, NULL,
&dwType, &dwType,
NULL, NULL,
&dwDataSize) == ERROR_SUCCESS) &dwDataSize) == ERROR_SUCCESS)
{ {
lpKeyClass = (LPTSTR)HeapAlloc(ProcessHeap, lpKeyClass = (LPTSTR)HeapAlloc(ProcessHeap,
0, 0,
@ -330,12 +331,12 @@ LPTSTR GetConnectionDescription(LPTSTR lpClass)
if (lpKeyClass == NULL) if (lpKeyClass == NULL)
goto CLEANUP; goto CLEANUP;
if(RegQueryValueEx(hClassKey, if (RegQueryValueEx(hClassKey,
_T("NetCfgInstanceId"), _T("NetCfgInstanceId"),
NULL, NULL,
&dwType, &dwType,
(PBYTE)lpKeyClass, (PBYTE)lpKeyClass,
&dwDataSize) != ERROR_SUCCESS) &dwDataSize) != ERROR_SUCCESS)
{ {
HeapFree(ProcessHeap, 0, lpKeyClass); HeapFree(ProcessHeap, 0, lpKeyClass);
lpKeyClass = NULL; lpKeyClass = NULL;
@ -350,12 +351,12 @@ LPTSTR GetConnectionDescription(LPTSTR lpClass)
HeapFree(ProcessHeap, 0, lpKeyClass); HeapFree(ProcessHeap, 0, lpKeyClass);
lpKeyClass = NULL; lpKeyClass = NULL;
if(RegQueryValueEx(hClassKey, if (RegQueryValueEx(hClassKey,
_T("DriverDesc"), _T("DriverDesc"),
NULL, NULL,
&dwType, &dwType,
NULL, NULL,
&dwDataSize) == ERROR_SUCCESS) &dwDataSize) == ERROR_SUCCESS)
{ {
lpConDesc = (LPTSTR)HeapAlloc(ProcessHeap, lpConDesc = (LPTSTR)HeapAlloc(ProcessHeap,
0, 0,
@ -363,12 +364,12 @@ LPTSTR GetConnectionDescription(LPTSTR lpClass)
if (lpConDesc == NULL) if (lpConDesc == NULL)
goto CLEANUP; goto CLEANUP;
if(RegQueryValueEx(hClassKey, if (RegQueryValueEx(hClassKey,
_T("DriverDesc"), _T("DriverDesc"),
NULL, NULL,
&dwType, &dwType,
(PBYTE)lpConDesc, (PBYTE)lpConDesc,
&dwDataSize) != ERROR_SUCCESS) &dwDataSize) != ERROR_SUCCESS)
{ {
HeapFree(ProcessHeap, 0, lpConDesc); HeapFree(ProcessHeap, 0, lpConDesc);
lpConDesc = NULL; lpConDesc = NULL;
@ -376,7 +377,9 @@ LPTSTR GetConnectionDescription(LPTSTR lpClass)
} }
} }
else else
{
lpConDesc = NULL; lpConDesc = NULL;
}
break; break;
} }
@ -424,7 +427,7 @@ VOID ShowInfo(BOOL bAll)
} }
else else
{ {
if( ERROR_NO_DATA != ret ) if (ret != ERROR_NO_DATA)
{ {
DoFormatMessage(0); DoFormatMessage(0);
return; return;
@ -432,7 +435,7 @@ VOID ShowInfo(BOOL bAll)
} }
/* call GetNetworkParams to obtain the network info */ /* call GetNetworkParams to obtain the network info */
if(GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW) if (GetNetworkParams(pFixedInfo, &netOutBufLen) == ERROR_BUFFER_OVERFLOW)
{ {
pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen); pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
if (pFixedInfo == NULL) if (pFixedInfo == NULL)
@ -593,15 +596,15 @@ VOID Release(LPTSTR Index)
{ {
for (i = 0; i < pInfo->NumAdapters; i++) for (i = 0; i < pInfo->NumAdapters; i++)
{ {
CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP)); CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
_tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name); _tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
/* Call IpReleaseAddress to release the IP address on the specified adapter. */ /* Call IpReleaseAddress to release the IP address on the specified adapter. */
if ((ret = IpReleaseAddress(&AdapterInfo)) != NO_ERROR) if ((ret = IpReleaseAddress(&AdapterInfo)) != NO_ERROR)
{ {
_tprintf(_T("\nAn error occured while releasing interface %ls : \n"), AdapterInfo.Name); _tprintf(_T("\nAn error occured while releasing interface %ls : \n"), AdapterInfo.Name);
DoFormatMessage(ret); DoFormatMessage(ret);
} }
} }
HeapFree(ProcessHeap, 0, pInfo); HeapFree(ProcessHeap, 0, pInfo);
@ -653,7 +656,7 @@ VOID Renew(LPTSTR Index)
/* Make an initial call to GetInterfaceInfo to get /* Make an initial call to GetInterfaceInfo to get
* the necessary size into the ulOutBufLen variable */ * the necessary size into the ulOutBufLen variable */
if ( GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER) if (GetInterfaceInfo(pInfo, &ulOutBufLen) == ERROR_INSUFFICIENT_BUFFER)
{ {
HeapFree(ProcessHeap, 0, pInfo); HeapFree(ProcessHeap, 0, pInfo);
pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen); pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, ulOutBufLen);
@ -665,14 +668,13 @@ VOID Renew(LPTSTR Index)
} }
/* Make a second call to GetInterfaceInfo to get the actual data we want */ /* Make a second call to GetInterfaceInfo to get the actual data we want */
if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR ) if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR)
{ {
for (i = 0; i < pInfo->NumAdapters; i++) for (i = 0; i < pInfo->NumAdapters; i++)
{ {
CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP)); CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
_tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name); _tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
/* Call IpRenewAddress to renew the IP address on the specified adapter. */ /* Call IpRenewAddress to renew the IP address on the specified adapter. */
if (IpRenewAddress(&AdapterInfo) != NO_ERROR) if (IpRenewAddress(&AdapterInfo) != NO_ERROR)
{ {
@ -755,41 +757,41 @@ int main(int argc, char *argv[])
ProcessHeap = GetProcessHeap(); ProcessHeap = GetProcessHeap();
/* Parse command line for options we have been given. */ /* Parse command line for options we have been given. */
if ( (argc > 1)&&(argv[1][0]=='/' || argv[1][0]=='-') ) if ((argc > 1) && (argv[1][0]=='/' || argv[1][0]=='-'))
{ {
if( !_tcsicmp( &argv[1][1], _T("?") )) if (!_tcsicmp(&argv[1][1], _T("?")))
{ {
DoUsage = TRUE; DoUsage = TRUE;
} }
else if( !_tcsnicmp( &argv[1][1], _T("ALL"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("ALL"), _tcslen(&argv[1][1])))
{ {
DoAll = TRUE; DoAll = TRUE;
} }
else if( !_tcsnicmp( &argv[1][1], _T("RELEASE"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("RELEASE"), _tcslen(&argv[1][1])))
{ {
DoRelease = TRUE; DoRelease = TRUE;
} }
else if( ! _tcsnicmp( &argv[1][1], _T("RENEW"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("RENEW"), _tcslen(&argv[1][1])))
{ {
DoRenew = TRUE; DoRenew = TRUE;
} }
else if( ! _tcsnicmp( &argv[1][1], _T("FLUSHDNS"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("FLUSHDNS"), _tcslen(&argv[1][1])))
{ {
DoFlushdns = TRUE; DoFlushdns = TRUE;
} }
else if( ! _tcsnicmp( &argv[1][1], _T("FLUSHREGISTERDNS"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("FLUSHREGISTERDNS"), _tcslen(&argv[1][1])))
{ {
DoRegisterdns = TRUE; DoRegisterdns = TRUE;
} }
else if( ! _tcsnicmp( &argv[1][1], _T("DISPLAYDNS"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("DISPLAYDNS"), _tcslen(&argv[1][1])))
{ {
DoDisplaydns = TRUE; DoDisplaydns = TRUE;
} }
else if( ! _tcsnicmp( &argv[1][1], _T("SHOWCLASSID"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("SHOWCLASSID"), _tcslen(&argv[1][1])))
{ {
DoShowclassid = TRUE; DoShowclassid = TRUE;
} }
else if( ! _tcsnicmp( &argv[1][1], _T("SETCLASSID"), _tcslen(&argv[1][1]) )) else if (!_tcsnicmp(&argv[1][1], _T("SETCLASSID"), _tcslen(&argv[1][1])))
{ {
DoSetclassid = TRUE; DoSetclassid = TRUE;
} }