1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/strings/string_util_win.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +// Copyright 2013 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_STRINGS_STRING_UTIL_WIN_H_ 1.9 +#define BASE_STRINGS_STRING_UTIL_WIN_H_ 1.10 + 1.11 +#include <stdarg.h> 1.12 +#include <stdio.h> 1.13 +#include <string.h> 1.14 +#include <wchar.h> 1.15 + 1.16 +#include "base/logging.h" 1.17 + 1.18 +namespace base { 1.19 + 1.20 +// Chromium code style is to not use malloc'd strings; this is only for use 1.21 +// for interaction with APIs that require it. 1.22 +inline char* strdup(const char* str) { 1.23 + return _strdup(str); 1.24 +} 1.25 + 1.26 +inline int strcasecmp(const char* s1, const char* s2) { 1.27 + return _stricmp(s1, s2); 1.28 +} 1.29 + 1.30 +inline int strncasecmp(const char* s1, const char* s2, size_t count) { 1.31 + return _strnicmp(s1, s2, count); 1.32 +} 1.33 + 1.34 +inline int strncmp16(const char16* s1, const char16* s2, size_t count) { 1.35 + return ::wcsncmp(s1, s2, count); 1.36 +} 1.37 + 1.38 +inline int vsnprintf(char* buffer, size_t size, 1.39 + const char* format, va_list arguments) { 1.40 + int length = _vsprintf_p(buffer, size, format, arguments); 1.41 + if (length < 0) { 1.42 + if (size > 0) 1.43 + buffer[0] = 0; 1.44 + return _vscprintf_p(format, arguments); 1.45 + } 1.46 + return length; 1.47 +} 1.48 + 1.49 +inline int vswprintf(wchar_t* buffer, size_t size, 1.50 + const wchar_t* format, va_list arguments) { 1.51 + DCHECK(IsWprintfFormatPortable(format)); 1.52 + 1.53 + int length = _vswprintf_p(buffer, size, format, arguments); 1.54 + if (length < 0) { 1.55 + if (size > 0) 1.56 + buffer[0] = 0; 1.57 + return _vscwprintf_p(format, arguments); 1.58 + } 1.59 + return length; 1.60 +} 1.61 + 1.62 +} // namespace base 1.63 + 1.64 +#endif // BASE_STRINGS_STRING_UTIL_WIN_H_