From 73cd14b4af906e77f3d8b019962fb9979ff12620 Mon Sep 17 00:00:00 2001 From: mmentovai Date: Wed, 15 Nov 2006 22:24:42 +0000 Subject: Airbag client libraries should compile under MSVC .NET 2003/7.1 (#64). r=bryner http://groups.google.com/group/airbag-dev/browse_thread/thread/b838faeb50f71818 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@64 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/tools/windows/symupload/symupload.cc | 28 ++++++++++++++++++++-------- src/tools/windows/symupload/symupload.vcproj | 4 ++++ 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src/tools/windows/symupload') diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc index 33f8e51f..602a0568 100644 --- a/src/tools/windows/symupload/symupload.cc +++ b/src/tools/windows/symupload/symupload.cc @@ -46,6 +46,8 @@ #include #include +#include "common/windows/string_utils-inl.h" + #include "common/windows/http_upload.h" #include "common/windows/pdb_source_line_writer.h" @@ -55,6 +57,7 @@ using std::vector; using std::map; using google_airbag::HTTPUpload; using google_airbag::PDBSourceLineWriter; +using google_airbag::WindowsStringUtils; // Extracts the file version information for the given filename, // as a string, for example, "1.2.3.4". Returns true on success. @@ -82,12 +85,13 @@ static bool GetFileVersionString(const wchar_t *filename, wstring *version) { wchar_t ver_string[24]; VS_FIXEDFILEINFO *file_info = reinterpret_cast(file_info_buffer); - _snwprintf_s(ver_string, sizeof(ver_string) / sizeof(wchar_t), _TRUNCATE, - L"%d.%d.%d.%d", - file_info->dwFileVersionMS >> 16, - file_info->dwFileVersionMS & 0xffff, - file_info->dwFileVersionLS >> 16, - file_info->dwFileVersionLS & 0xffff); + WindowsStringUtils::safe_swprintf( + ver_string, sizeof(ver_string) / sizeof(ver_string[0]), + L"%d.%d.%d.%d", + file_info->dwFileVersionMS >> 16, + file_info->dwFileVersionMS & 0xffff, + file_info->dwFileVersionLS >> 16, + file_info->dwFileVersionLS & 0xffff); *version = ver_string; return true; } @@ -116,7 +120,13 @@ static bool DumpSymbolsToTempFile(const wchar_t *file, } FILE *temp_file = NULL; +#if _MSC_VER >= 1400 // MSVC 2005/8 if (_wfopen_s(&temp_file, temp_filename, L"w") != 0) { +#else // _MSC_VER >= 1400 + // _wfopen_s was introduced in MSVC8. Use _wfopen for earlier environments. + // Don't use it with MSVC8 and later, because it's deprecated. + if (!(temp_file = _wfopen(temp_filename, L"w"))) { +#endif // _MSC_VER >= 1400 return false; } @@ -148,8 +158,10 @@ int wmain(int argc, wchar_t *argv[]) { } wchar_t module_age_string[11]; - _snwprintf_s(module_age_string, sizeof(module_age_string) / sizeof(wchar_t), - _TRUNCATE, L"0x%x", module_age); + WindowsStringUtils::safe_swprintf( + module_age_string, + sizeof(module_age_string) / sizeof(module_age_string[0]), + L"0x%x", module_age); map parameters; parameters[L"module"] = module_basename; diff --git a/src/tools/windows/symupload/symupload.vcproj b/src/tools/windows/symupload/symupload.vcproj index ddd63fc1..c1458854 100755 --- a/src/tools/windows/symupload/symupload.vcproj +++ b/src/tools/windows/symupload/symupload.vcproj @@ -188,6 +188,10 @@ RelativePath="..\..\..\common\windows\pdb_source_line_writer.h" > + +