1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/string_util_win.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +// Copyright (c) 2006-2008 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_STRING_UTIL_WIN_H_ 1.9 +#define BASE_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 vsnprintf(char* buffer, size_t size, 1.35 + const char* format, va_list arguments) { 1.36 + int length = vsnprintf_s(buffer, size, size - 1, format, arguments); 1.37 + if (length < 0) 1.38 + return _vscprintf(format, arguments); 1.39 + return length; 1.40 +} 1.41 + 1.42 +inline int vswprintf(wchar_t* buffer, size_t size, 1.43 + const wchar_t* format, va_list arguments) { 1.44 + DCHECK(IsWprintfFormatPortable(format)); 1.45 + 1.46 + int length = _vsnwprintf_s(buffer, size, size - 1, format, arguments); 1.47 + if (length < 0) 1.48 + return _vscwprintf(format, arguments); 1.49 + return length; 1.50 +} 1.51 + 1.52 +} // namespace base 1.53 + 1.54 +#endif // BASE_STRING_UTIL_WIN_H_