blob: f2adae69ba9ffe87a644bf905c12b669e10f224e [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commitd7cae122008-07-26 21:49:384
[email protected]44cd16f2008-08-14 01:25:325#ifndef BASE_STRING_UTIL_WIN_H_
6#define BASE_STRING_UTIL_WIN_H_
initial.commitd7cae122008-07-26 21:49:387
8#include <stdarg.h>
9#include <stdio.h>
10#include <string.h>
11#include <wchar.h>
12
[email protected]44cd16f2008-08-14 01:25:3213#include "base/logging.h"
14
[email protected]a191e012008-08-07 19:26:3715namespace base {
initial.commitd7cae122008-07-26 21:49:3816
[email protected]e6142622008-09-24 00:11:2517inline int strcasecmp(const char* s1, const char* s2) {
18 return _stricmp(s1, s2);
19}
20
[email protected]a191e012008-08-07 19:26:3721inline int strncasecmp(const char* s1, const char* s2, size_t count) {
initial.commitd7cae122008-07-26 21:49:3822 return _strnicmp(s1, s2, count);
23}
24
[email protected]a191e012008-08-07 19:26:3725inline int vsnprintf(char* buffer, size_t size,
26 const char* format, va_list arguments) {
initial.commitd7cae122008-07-26 21:49:3827 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]a191e012008-08-07 19:26:3733inline int vswprintf(wchar_t* buffer, size_t size,
initial.commitd7cae122008-07-26 21:49:3834 const wchar_t* format, va_list arguments) {
[email protected]44cd16f2008-08-14 01:25:3235 DCHECK(IsWprintfFormatPortable(format));
36
initial.commitd7cae122008-07-26 21:49:3837 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]a191e012008-08-07 19:26:3743} // namespace base
44
[email protected]44cd16f2008-08-14 01:25:3245#endif // BASE_STRING_UTIL_WIN_H_