michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_STRING_UTIL_WIN_H_ michael@0: #define BASE_STRING_UTIL_WIN_H_ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "base/logging.h" michael@0: michael@0: namespace base { michael@0: michael@0: // Chromium code style is to not use malloc'd strings; this is only for use michael@0: // for interaction with APIs that require it. michael@0: inline char* strdup(const char* str) { michael@0: return _strdup(str); michael@0: } michael@0: michael@0: inline int strcasecmp(const char* s1, const char* s2) { michael@0: return _stricmp(s1, s2); michael@0: } michael@0: michael@0: inline int strncasecmp(const char* s1, const char* s2, size_t count) { michael@0: return _strnicmp(s1, s2, count); michael@0: } michael@0: michael@0: inline int vsnprintf(char* buffer, size_t size, michael@0: const char* format, va_list arguments) { michael@0: int length = vsnprintf_s(buffer, size, size - 1, format, arguments); michael@0: if (length < 0) michael@0: return _vscprintf(format, arguments); michael@0: return length; michael@0: } michael@0: michael@0: inline int vswprintf(wchar_t* buffer, size_t size, michael@0: const wchar_t* format, va_list arguments) { michael@0: DCHECK(IsWprintfFormatPortable(format)); michael@0: michael@0: int length = _vsnwprintf_s(buffer, size, size - 1, format, arguments); michael@0: if (length < 0) michael@0: return _vscwprintf(format, arguments); michael@0: return length; michael@0: } michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_STRING_UTIL_WIN_H_