Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions MrMapi/MMAccounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void LogProp(LPOLKACCOUNT lpAccount, ULONG ulPropTag)
const auto name = proptags::PropTagToPropName(ulPropTag, false).bestGuess;
const auto tag = proptype::TypeToString(PROP_TYPE(ulPropTag));

wprintf(
wprintf_s(
L"Prop = %ws, Type = %ws, ",
name.empty() ? strings::format(L"0x%08X", ulPropTag).c_str() : name.c_str(),
tag.c_str());
Expand All @@ -25,28 +25,28 @@ void LogProp(LPOLKACCOUNT lpAccount, ULONG ulPropTag)
case PT_UNICODE:
if (pProp.Val.pwsz)
{
wprintf(L"\"%ws\"", pProp.Val.pwsz);
wprintf_s(L"\"%ws\"", pProp.Val.pwsz);
WC_H_S(lpAccount->FreeMemory(reinterpret_cast<LPBYTE>(pProp.Val.pwsz)));
}
break;
case PT_LONG:
wprintf(L"0x%08lX", pProp.Val.dw);
wprintf_s(L"0x%08lX", pProp.Val.dw);
break;
case PT_BINARY:
wprintf(L"%ws", strings::BinToHexString(pProp.Val.bin.pb, pProp.Val.bin.cb, true).c_str());
wprintf_s(L"%ws", strings::BinToHexString(pProp.Val.bin.pb, pProp.Val.bin.cb, true).c_str());
WC_H_S(lpAccount->FreeMemory(pProp.Val.bin.pb));
break;
}

wprintf(L"\n");
wprintf_s(L"\n");
}
}

void IterateAllProps(LPOLKACCOUNT lpAccount)
{
if (!lpAccount) return;

wprintf(L"Iterating all properties\n");
wprintf_s(L"Iterating all properties\n");

for (auto i = 0; i < 0x8000; i++)
{
Expand All @@ -55,7 +55,7 @@ void IterateAllProps(LPOLKACCOUNT lpAccount)
LogProp(lpAccount, PROP_TAG(PT_BINARY, i));
}

wprintf(L"Done iterating all properties\n");
wprintf_s(L"Done iterating all properties\n");
}

void EnumerateAccounts(
Expand All @@ -66,7 +66,7 @@ void EnumerateAccounts(
{
LPOLKENUM lpAcctEnum = nullptr;

wprintf(L"Category: %ws\n", szCat.c_str());
wprintf_s(L"Category: %ws\n", szCat.c_str());
EC_H_S(lpAcctMgr->EnumerateAccounts(pclsidCategory, nullptr, OLK_ACCOUNT_NO_FLAGS, &lpAcctEnum));
if (lpAcctEnum)
{
Expand All @@ -78,8 +78,8 @@ void EnumerateAccounts(
EC_H_S(lpAcctEnum->Reset());
for (DWORD i = 0; i < cAccounts; i++)
{
if (i > 0) wprintf(L"\n");
wprintf(L"Account #%lu\n", i + 1);
if (i > 0) wprintf_s(L"\n");
wprintf_s(L"Account #%lu\n", i + 1);
LPUNKNOWN lpUnk = nullptr;

EC_H_S(lpAcctEnum->GetNext(&lpUnk));
Expand Down Expand Up @@ -149,7 +149,7 @@ void DoAccounts(_In_opt_ LPMAPISESSION lpMAPISession)
const auto bWizard = cli::switchWizard.isSet();
const auto profileName = mapi::GetProfileName(lpMAPISession);

wprintf(L"Enum Accounts\n");
wprintf_s(L"Enum Accounts\n");

if (!profileName.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions MrMapi/MMEntryID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ HRESULT DoEntryID(_In_opt_ LPMDB lpMDB)
hRes = WC_H_GETPROPS(message->GetProps(&tags, fMapiUnicode, &count, &props));
if (SUCCEEDED(hRes) && props && count == 1)
{
wprintf(L"%ws<messageprops>\n", output::g_szXMLHeader.c_str());
wprintf_s(L"%ws<messageprops>\n", output::g_szXMLHeader.c_str());
output::outputProperties(output::dbgLevel::NoDebug, stdout, count, props, message, true);
wprintf(L"</messageprops>\n");
wprintf_s(L"</messageprops>\n");
if (PROP_TYPE(props[0].ulPropTag) == PT_ERROR) hRes = props[0].Value.err;
}
else if (SUCCEEDED(hRes))
Expand Down
12 changes: 6 additions & 6 deletions MrMapi/MMErr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace error

void PrintErrFromNum(_In_ ULONG ulError)
{
wprintf(L"0x%08lX = %ws\n", ulError, error::ErrorNameFromErrorCode(ulError).c_str());
wprintf_s(L"0x%08lX = %ws\n", ulError, error::ErrorNameFromErrorCode(ulError).c_str());
}

void PrintErrFromName(_In_ const std::wstring& lpszError) noexcept
Expand All @@ -22,30 +22,30 @@ void PrintErrFromName(_In_ const std::wstring& lpszError) noexcept
{
if (0 == lstrcmpiW(szErr, error::g_ErrorArray[i].lpszName))
{
wprintf(L"0x%08lX = %ws\n", error::g_ErrorArray[i].ulErrorName, szErr);
wprintf_s(L"0x%08lX = %ws\n", error::g_ErrorArray[i].ulErrorName, szErr);
}
}
}

void PrintErrFromPartialName(_In_ const std::wstring& lpszError) noexcept
{
if (!lpszError.empty())
wprintf(L"Searching for \"%ws\"\n", lpszError.c_str());
wprintf_s(L"Searching for \"%ws\"\n", lpszError.c_str());
else
wprintf(L"Searching for all errors\n");
wprintf_s(L"Searching for all errors\n");

ULONG ulNumMatches = 0;

for (ULONG ulCur = 0; ulCur < error::g_ulErrorArray; ulCur++)
{
if (lpszError.empty() || nullptr != StrStrIW(error::g_ErrorArray[ulCur].lpszName, lpszError.c_str()))
{
wprintf(L"0x%08lX = %ws\n", error::g_ErrorArray[ulCur].ulErrorName, error::g_ErrorArray[ulCur].lpszName);
wprintf_s(L"0x%08lX = %ws\n", error::g_ErrorArray[ulCur].ulErrorName, error::g_ErrorArray[ulCur].lpszName);
ulNumMatches++;
}
}

wprintf(L"Found %lu matches.\n", ulNumMatches);
wprintf_s(L"Found %lu matches.\n", ulNumMatches);
}

void DoErrorParse()
Expand Down
4 changes: 2 additions & 2 deletions MrMapi/MMFidMid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace mapiprocessor
{
void PrintFolder(const std::wstring& szFid, const std::wstring& szFolder) noexcept
{
wprintf(L"%-15ws %ws\n", szFid.c_str(), szFolder.c_str());
wprintf_s(L"%-15ws %ws\n", szFid.c_str(), szFolder.c_str());
}

void PrintMessage(
Expand All @@ -22,7 +22,7 @@ namespace mapiprocessor
const std::wstring& szSubject,
const std::wstring& szClass) noexcept
{
wprintf(
wprintf_s(
L" %-15ws %wc %ws (%ws)\n", szMid.c_str(), fAssociated ? L'A' : L'R', szSubject.c_str(), szClass.c_str());
}

Expand Down
26 changes: 13 additions & 13 deletions MrMapi/MMFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ void DumpHierarchyTable(
{
for (ULONG iTab = 0; iTab < ulDepth; iTab++)
{
wprintf(L" ");
wprintf_s(L" ");
}
}

if (PR_DISPLAY_NAME_W == lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].ulPropTag)
{
wprintf(L"%ws\n", lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].Value.lpszW);
wprintf_s(L"%ws\n", lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].Value.lpszW);
}

if (PR_ENTRYID == lpRow->aRow[i].lpProps[ePR_ENTRYID].ulPropTag)
Expand Down Expand Up @@ -539,21 +539,21 @@ void DumpSearchState(
const auto hRes = WC_H(lpFolder->GetSearchCriteria(fMapiUnicode, &lpRes, &lpEntryList, &ulSearchState));
if (MAPI_E_NOT_INITIALIZED == hRes)
{
wprintf(L"No search criteria has been set on this folder.\n");
wprintf_s(L"No search criteria has been set on this folder.\n");
}
else if (MAPI_E_NO_SUPPORT == hRes)
{
wprintf(L"This does not appear to be a search folder.\n");
wprintf_s(L"This does not appear to be a search folder.\n");
}
else if (SUCCEEDED(hRes))
{
auto szFlags = flags::InterpretFlags(flagSearchState, ulSearchState);
wprintf(L"Search state %ws == 0x%08X\n", szFlags.c_str(), ulSearchState);
wprintf(L"\n");
wprintf(L"Search Scope:\n");
wprintf_s(L"Search state %ws == 0x%08X\n", szFlags.c_str(), ulSearchState);
wprintf_s(L"\n");
wprintf_s(L"Search Scope:\n");
output::outputEntryList(output::dbgLevel::NoDebug, stdout, lpEntryList);
wprintf(L"\n");
wprintf(L"Search Criteria:\n");
wprintf_s(L"\n");
wprintf_s(L"Search Criteria:\n");
output::outputRestriction(output::dbgLevel::NoDebug, stdout, lpRes, nullptr);
}

Expand All @@ -573,10 +573,10 @@ void DoFolderProps(_In_opt_ LPMAPIFOLDER lpFolder)
void DoFolderSize(_In_opt_ LPMAPIFOLDER lpFolder)
{
const LONGLONG ullSize = ComputeFolderSize(cli::switchProfile[0], lpFolder, cli::switchFolder[0]);
wprintf(L"Folder size (including subfolders)\n");
wprintf(L"Bytes: %I64d\n", ullSize);
wprintf(L"KB: %I64d\n", ullSize / 1024);
wprintf(L"MB: %I64d\n", ullSize / (1024 * 1024));
wprintf_s(L"Folder size (including subfolders)\n");
wprintf_s(L"Bytes: %I64d\n", ullSize);
wprintf_s(L"KB: %I64d\n", ullSize / 1024);
wprintf_s(L"MB: %I64d\n", ullSize / (1024 * 1024));
}

void DoChildFolders(_In_opt_ LPMAPIFOLDER lpFolder)
Expand Down
62 changes: 31 additions & 31 deletions MrMapi/MMMapiMime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,67 @@ void DoMAPIMIME(_In_opt_ LPMAPISESSION lpMAPISession)
const auto cSetType = static_cast<CHARSETTYPE>(cli::switchCharset.atULONG(1));
const auto cSetApplyType = static_cast<CSETAPPLYTYPE>(cli::switchCharset.atULONG(2));

wprintf(L"Message File Converter\n");
wprintf(L"Options specified:\n");
wprintf(L" Input File: %ws\n", input.c_str());
wprintf(L" Output File: %ws\n", output.c_str());
wprintf(L" Conversion Type: ");
wprintf_s(L"Message File Converter\n");
wprintf_s(L"Options specified:\n");
wprintf_s(L" Input File: %ws\n", input.c_str());
wprintf_s(L" Output File: %ws\n", output.c_str());
wprintf_s(L" Conversion Type: ");
if (cli::switchMAPI.isSet())
{
wprintf(L"MAPI -> MIME\n");
wprintf_s(L"MAPI -> MIME\n");

wprintf(L" Save Format: %ws\n", cli::switchRFC822.isSet() ? L"RFC822" : L"RFC1521");
wprintf_s(L" Save Format: %ws\n", cli::switchRFC822.isSet() ? L"RFC822" : L"RFC1521");

if (cli::switchWrap.isSet())
{
wprintf(L" Line Wrap: ");
wprintf_s(L" Line Wrap: ");
if (ulWrapLines == 0)
wprintf(L"OFF\n");
wprintf_s(L"OFF\n");
else
wprintf(L"%lu\n", ulWrapLines);
wprintf_s(L"%lu\n", ulWrapLines);
}
}
else if (cli::switchMAPI.isSet())
{
wprintf(L"MIME -> MAPI\n");
wprintf_s(L"MIME -> MAPI\n");
if (cli::switchUnicode.isSet())
{
wprintf(L" Building Unicode MSG file\n");
wprintf_s(L" Building Unicode MSG file\n");
}

if (cli::switchCharset.isSet())
{
wprintf(L" CodePage: %lu\n", ulCodePage);
wprintf(L" CharSetType: ");
wprintf_s(L" CodePage: %lu\n", ulCodePage);
wprintf_s(L" CharSetType: ");
switch (cSetType)
{
case CHARSET_BODY:
wprintf(L"CHARSET_BODY");
wprintf_s(L"CHARSET_BODY");
break;
case CHARSET_HEADER:
wprintf(L"CHARSET_HEADER");
wprintf_s(L"CHARSET_HEADER");
break;
case CHARSET_WEB:
wprintf(L"CHARSET_WEB");
wprintf_s(L"CHARSET_WEB");
break;
}

wprintf(L"\n");
wprintf(L" CharSetApplyType: ");
wprintf_s(L"\n");
wprintf_s(L" CharSetApplyType: ");
switch (cSetApplyType)
{
case CSET_APPLY_UNTAGGED:
wprintf(L"CSET_APPLY_UNTAGGED");
wprintf_s(L"CSET_APPLY_UNTAGGED");
break;
case CSET_APPLY_ALL:
wprintf(L"CSET_APPLY_ALL");
wprintf_s(L"CSET_APPLY_ALL");
break;
case CSET_APPLY_TAG_ALL:
wprintf(L"CSET_APPLY_TAG_ALL");
wprintf_s(L"CSET_APPLY_TAG_ALL");
break;
}

wprintf(L"\n");
wprintf_s(L"\n");
}
}

Expand All @@ -87,7 +87,7 @@ void DoMAPIMIME(_In_opt_ LPMAPISESSION lpMAPISession)
auto szFlags = flags::InterpretFlags(flagCcsf, convertFlags);
if (!szFlags.empty())
{
wprintf(L" Conversion Flags: %ws\n", szFlags.c_str());
wprintf_s(L" Conversion Flags: %ws\n", szFlags.c_str());
}
}

Expand All @@ -96,13 +96,13 @@ void DoMAPIMIME(_In_opt_ LPMAPISESSION lpMAPISession)
auto szType = flags::InterpretFlags(flagIet, ulEncodingType);
if (!szType.empty())
{
wprintf(L" Encoding Type: %ws\n", szType.c_str());
wprintf_s(L" Encoding Type: %ws\n", szType.c_str());
}
}

if (cli::switchAddressBook.isSet())
{
wprintf(L" Using Address Book\n");
wprintf_s(L" Using Address Book\n");
}

auto hRes = S_OK;
Expand All @@ -111,7 +111,7 @@ void DoMAPIMIME(_In_opt_ LPMAPISESSION lpMAPISession)
if (cli::switchAddressBook.isSet() && lpMAPISession)
{
hRes = WC_MAPI(lpMAPISession->OpenAddressBook(NULL, nullptr, AB_NO_DIALOG, &lpAdrBook));
if (FAILED(hRes)) wprintf(L"OpenAddressBook returned an error: 0x%08lx\n", hRes);
if (FAILED(hRes)) wprintf_s(L"OpenAddressBook returned an error: 0x%08lx\n", hRes);
}

if (cli::switchMIME.isSet())
Expand All @@ -135,7 +135,7 @@ void DoMAPIMIME(_In_opt_ LPMAPISESSION lpMAPISession)
hRes = WC_H(import::MyMimeOleGetCodePageCharset(ulCodePage, cSetType, &hCharSet));
if (FAILED(hRes))
{
wprintf(L"MimeOleGetCodePageCharset returned 0x%08lX\n", hRes);
wprintf_s(L"MimeOleGetCodePageCharset returned 0x%08lX\n", hRes);
}
}

Expand All @@ -155,15 +155,15 @@ void DoMAPIMIME(_In_opt_ LPMAPISESSION lpMAPISession)

if (SUCCEEDED(hRes))
{
wprintf(L"File converted successfully.\n");
wprintf_s(L"File converted successfully.\n");
}
else if (REGDB_E_CLASSNOTREG == hRes)
{
wprintf(L"MAPI <-> MIME converter not found. Perhaps Outlook is not installed.\n");
wprintf_s(L"MAPI <-> MIME converter not found. Perhaps Outlook is not installed.\n");
}
else
{
wprintf(L"Conversion returned an error: 0x%08lx\n", hRes);
wprintf_s(L"Conversion returned an error: 0x%08lx\n", hRes);
}

if (lpAdrBook) lpAdrBook->Release();
Expand Down
Loading
Loading