license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 4 | |
[email protected] | 44cd16f | 2008-08-14 01:25:32 | [diff] [blame] | 5 | #ifndef BASE_STRING_UTIL_WIN_H_ |
| 6 | #define BASE_STRING_UTIL_WIN_H_ |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 7 | |
| 8 | #include <stdarg.h> |
| 9 | #include <stdio.h> |
| 10 | #include <string.h> |
| 11 | #include <wchar.h> |
| 12 | |
[email protected] | 44cd16f | 2008-08-14 01:25:32 | [diff] [blame] | 13 | #include "base/logging.h" |
| 14 | |
[email protected] | a191e01 | 2008-08-07 19:26:37 | [diff] [blame] | 15 | namespace base { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 16 | |
[email protected] | e614262 | 2008-09-24 00:11:25 | [diff] [blame] | 17 | inline int strcasecmp(const char* s1, const char* s2) { |
| 18 | return _stricmp(s1, s2); |
| 19 | } |
| 20 | |
[email protected] | a191e01 | 2008-08-07 19:26:37 | [diff] [blame] | 21 | inline int strncasecmp(const char* s1, const char* s2, size_t count) { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 22 | return _strnicmp(s1, s2, count); |
| 23 | } |
| 24 | |
[email protected] | a191e01 | 2008-08-07 19:26:37 | [diff] [blame] | 25 | inline int vsnprintf(char* buffer, size_t size, |
| 26 | const char* format, va_list arguments) { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 27 | int length = vsnprintf_s(buffer, size, size - 1, format, arguments); |
| 28 | if (length < 0) |
| 29 | return _vscprintf(format, arguments); |
| 30 | return length; |
| 31 | } |
| 32 | |
[email protected] | a191e01 | 2008-08-07 19:26:37 | [diff] [blame] | 33 | inline int vswprintf(wchar_t* buffer, size_t size, |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 34 | const wchar_t* format, va_list arguments) { |
[email protected] | 44cd16f | 2008-08-14 01:25:32 | [diff] [blame] | 35 | DCHECK(IsWprintfFormatPortable(format)); |
| 36 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 37 | int length = _vsnwprintf_s(buffer, size, size - 1, format, arguments); |
| 38 | if (length < 0) |
| 39 | return _vscwprintf(format, arguments); |
| 40 | return length; |
| 41 | } |
| 42 | |
[email protected] | a191e01 | 2008-08-07 19:26:37 | [diff] [blame] | 43 | } // namespace base |
| 44 | |
[email protected] | 44cd16f | 2008-08-14 01:25:32 | [diff] [blame] | 45 | #endif // BASE_STRING_UTIL_WIN_H_ |