From de725c53912c6c915d30b51beb08ede16e9dbe35 Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Tue, 27 Jun 2017 23:33:15 +0000 Subject: [PATCH] [FORMATTING][RAPPS] available.cpp: Fix braces svn path=/branches/GSoC_2017/rapps/; revision=75220 --- reactos/base/applications/rapps/available.cpp | 137 ++++++++++-------- 1 file changed, 73 insertions(+), 64 deletions(-) diff --git a/reactos/base/applications/rapps/available.cpp b/reactos/base/applications/rapps/available.cpp index cd70bd72bbc..fd26eea79f5 100644 --- a/reactos/base/applications/rapps/available.cpp +++ b/reactos/base/applications/rapps/available.cpp @@ -9,17 +9,19 @@ #include "rapps.h" -inline void _AddText(UINT a, LPCWSTR b, DWORD c, DWORD d) { - if (b[0] != '\0') - { - WCHAR szText[MAX_STR_LEN]; - LoadStringW(hInst, a, szText, _countof(szText)); - InsertRichEditText(szText, c); - InsertRichEditText(b, d); - } +inline void _AddText(UINT a, LPCWSTR b, DWORD c, DWORD d) +{ + if (b[0] != '\0') + { + WCHAR szText[MAX_STR_LEN]; + LoadStringW(hInst, a, szText, _countof(szText)); + InsertRichEditText(szText, c); + InsertRichEditText(b, d); + } } -inline void _AddTextNewl(UINT a, DWORD b) { +inline void _AddTextNewl(UINT a, DWORD b) +{ WCHAR szText[MAX_STR_LEN]; LoadStringW(hInst, a, szText, _countof(szText)); InsertRichEditText(L"\n", 0); @@ -28,15 +30,18 @@ inline void _AddTextNewl(UINT a, DWORD b) { } template -inline BOOL _GetString(LPCWSTR a, T(&b)[N], T (&cFileName)[N2]) { - return ParserGetString(a, b, N, cFileName); +inline BOOL _GetString(LPCWSTR a, T(&b)[N], T(&cFileName)[N2]) +{ + return ParserGetString(a, b, N, cFileName); } template -inline void _GetStringNullFailure(LPCWSTR a, T(&b)[N], T (&cFileName)[N2]) { - if (!_GetString(a, b, cFileName)) { - b[0] = '\0'; - } +inline void _GetStringNullFailure(LPCWSTR a, T(&b)[N], T(&cFileName)[N2]) +{ + if (!_GetString(a, b, cFileName)) + { + b[0] = '\0'; + } } //App is "installed" if the RegName or Name is in the registry @@ -52,9 +57,10 @@ inline BOOL _AppInstallCheckWithKey(PAPPLICATION_INFO Info, REGSAM key) //Check both registry keys in 64bit system //TODO: check system type beforehand to avoid double checks? -inline BOOL _AppInstallCheck(PAPPLICATION_INFO Info) { - return _AppInstallCheckWithKey(Info, KEY_WOW64_32KEY) - || _AppInstallCheckWithKey(Info, KEY_WOW64_64KEY); +inline BOOL _AppInstallCheck(PAPPLICATION_INFO Info) +{ + return _AppInstallCheckWithKey(Info, KEY_WOW64_32KEY) + || _AppInstallCheckWithKey(Info, KEY_WOW64_64KEY); } //App is "installed" if the RegName or Name is in the registry @@ -74,7 +80,7 @@ inline BOOL _GetInstalledVersion(PAPPLICATION_INFO Info, LPWSTR szVersion, UINT || _GetInstalledVersionWithKey(Info, szVersion, iVersionSize, KEY_WOW64_64KEY); } -LIST_ENTRY CachedEntriesHead = { &CachedEntriesHead, &CachedEntriesHead }; +LIST_ENTRY CachedEntriesHead = {&CachedEntriesHead, &CachedEntriesHead}; PLIST_ENTRY pCachedEntry = &CachedEntriesHead; BOOL @@ -89,14 +95,15 @@ ShowAvailableAppInfo(INT Index) NewRichEditText(Info->szName, CFE_BOLD); if (bIsInstalled) { - _AddTextNewl(IDS_STATUS_INSTALLED, CFE_ITALIC); - if (_GetInstalledVersion(Info, szVersion, _countof(szVersion))) - { - _AddText(IDS_AINFO_VERSION, szVersion, CFE_BOLD, 0); - } - } else + _AddTextNewl(IDS_STATUS_INSTALLED, CFE_ITALIC); + if (_GetInstalledVersion(Info, szVersion, _countof(szVersion))) + { + _AddText(IDS_AINFO_VERSION, szVersion, CFE_BOLD, 0); + } + } + else { - _AddTextNewl(IDS_STATUS_NOTINSTALLED, CFE_ITALIC); + _AddTextNewl(IDS_STATUS_NOTINSTALLED, CFE_ITALIC); } _AddText(IDS_AINFO_AVAILABLEVERSION, Info->szVersion, CFE_BOLD, 0); @@ -125,8 +132,8 @@ DeleteCurrentAppsDB(VOID) return FALSE; hr = StringCbPrintfW(szCabPath, sizeof(szCabPath), - L"%ls\\rappmgr.cab", - szPath); + L"%ls\\rappmgr.cab", + szPath); if (FAILED(hr)) return FALSE; @@ -138,8 +145,8 @@ DeleteCurrentAppsDB(VOID) return FALSE; hr = StringCbPrintfW(szSearchPath, sizeof(szSearchPath), - L"%ls*.txt", - szPath); + L"%ls*.txt", + szPath); if (FAILED(hr)) return FALSE; @@ -151,13 +158,14 @@ DeleteCurrentAppsDB(VOID) do { hr = StringCbPrintfW(szTmp, sizeof(szTmp), - L"%ls%ls", - szPath, FindFileData.cFileName); + L"%ls%ls", + szPath, FindFileData.cFileName); if (FAILED(hr)) continue; result = result && DeleteFileW(szTmp); - } while (FindNextFileW(hFind, &FindFileData) != 0); + } + while (FindNextFileW(hFind, &FindFileData) != 0); FindClose(hFind); @@ -181,15 +189,15 @@ UpdateAppsDB(VOID) return FALSE; if (FAILED(StringCbPrintfW(szCabPath, sizeof(szCabPath), - L"%ls\\rappmgr.cab", - szPath))) + L"%ls\\rappmgr.cab", + szPath))) { return FALSE; } if (FAILED(StringCbPrintfW(szAppsPath, sizeof(szAppsPath), - L"%ls\\rapps\\", - szPath))) + L"%ls\\rapps\\", + szPath))) { return FALSE; } @@ -215,8 +223,8 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) return FALSE; hr = StringCbPrintfW(szCabPath, sizeof(szCabPath), - L"%ls\\rappmgr.cab", - szPath); + L"%ls\\rappmgr.cab", + szPath); if (FAILED(hr)) return FALSE; @@ -263,7 +271,7 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) Info = CONTAINING_RECORD(pCachedEntry, APPLICATION_INFO, List); /* do we already have this entry in cache? */ - if(_wcsicmp(FindFileData.cFileName, Info->cFileName) == 0) + if (_wcsicmp(FindFileData.cFileName, Info->cFileName) == 0) { /* is it current enough, or the file has been modified since our last time here? */ if (CompareFileTime(&FindFileData.ftLastWriteTime, &Info->ftCacheStamp) == 1) @@ -283,21 +291,21 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc) } /* create a new entry */ - Info = (PAPPLICATION_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APPLICATION_INFO)); + Info = (PAPPLICATION_INFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(APPLICATION_INFO)); - if(!Info) + if (!Info) break; Info->Category = ParserGetInt(L"Category", FindFileData.cFileName); /* copy the cache-related fields for the next time */ - RtlCopyMemory(&Info->cFileName, &FindFileData.cFileName, MAX_PATH); + RtlCopyMemory(&Info->cFileName, &FindFileData.cFileName, MAX_PATH); RtlCopyMemory(&Info->ftCacheStamp, &FindFileData.ftLastWriteTime, sizeof(FILETIME)); /* add our cached entry to the cached list */ InsertTailList(&CachedEntriesHead, &Info->List); -skip_if_cached: + skip_if_cached: if (Info->Category == FALSE) continue; @@ -310,26 +318,27 @@ skip_if_cached: if (Info->szUrlDownload[0] == 0) { - if (!_GetString(L"Name", Info->szName, FindFileData.cFileName) - || !_GetString(L"URLDownload", Info->szUrlDownload, FindFileData.cFileName)) - { - continue; - } - - _GetStringNullFailure(L"RegName", Info->szRegName, FindFileData.cFileName); - _GetStringNullFailure(L"Version", Info->szVersion, FindFileData.cFileName); - _GetStringNullFailure(L"License", Info->szLicense, FindFileData.cFileName); - _GetStringNullFailure(L"Description", Info->szDesc, FindFileData.cFileName); - _GetStringNullFailure(L"Size", Info->szSize, FindFileData.cFileName); - _GetStringNullFailure(L"URLSite", Info->szUrlSite, FindFileData.cFileName); - _GetStringNullFailure(L"CDPath", Info->szCDPath, FindFileData.cFileName); - _GetStringNullFailure(L"SHA1", Info->szSHA1, FindFileData.cFileName); + if (!_GetString(L"Name", Info->szName, FindFileData.cFileName) + || !_GetString(L"URLDownload", Info->szUrlDownload, FindFileData.cFileName)) + { + continue; + } + + _GetStringNullFailure(L"RegName", Info->szRegName, FindFileData.cFileName); + _GetStringNullFailure(L"Version", Info->szVersion, FindFileData.cFileName); + _GetStringNullFailure(L"License", Info->szLicense, FindFileData.cFileName); + _GetStringNullFailure(L"Description", Info->szDesc, FindFileData.cFileName); + _GetStringNullFailure(L"Size", Info->szSize, FindFileData.cFileName); + _GetStringNullFailure(L"URLSite", Info->szUrlSite, FindFileData.cFileName); + _GetStringNullFailure(L"CDPath", Info->szCDPath, FindFileData.cFileName); + _GetStringNullFailure(L"SHA1", Info->szSHA1, FindFileData.cFileName); } if (!lpEnumProc(Info)) break; - } while (FindNextFileW(hFind, &FindFileData) != 0); + } + while (FindNextFileW(hFind, &FindFileData) != 0); FindClose(hFind); @@ -338,16 +347,16 @@ skip_if_cached: VOID FreeCachedAvailableEntries(VOID) { - PAPPLICATION_INFO Info; - + PAPPLICATION_INFO Info; + /* loop and deallocate all the cached app infos in the list */ for (pCachedEntry = CachedEntriesHead.Flink; pCachedEntry != &CachedEntriesHead;) { - Info = CONTAINING_RECORD(pCachedEntry, APPLICATION_INFO, List); - + Info = CONTAINING_RECORD(pCachedEntry, APPLICATION_INFO, List); + /* grab a reference to the next linked entry before getting rid of the current one */ pCachedEntry = pCachedEntry->Flink; - + /* flush them down the toilet :D */ RemoveEntryList(&Info->List); HeapFree(GetProcessHeap(), 0, Info); -- 2.17.1