Branch libreoffice-5-0-4
[LibreOffice.git] / include / systools / win32 / snprintf.h
blob92e571f91ee89a843f064f3d9ecc4653180eda6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SYSTOOLS_WIN32_SNPRINTF_H
21 #define INCLUDED_SYSTOOLS_WIN32_SNPRINTF_H
23 #if !defined(_WIN32)
24 #error ERROR: Only Win32 target supported!
25 #endif
27 /* Macros for Unicode/ANSI support like in TCHAR.H */
29 #ifdef _UNICODE
30 #define sntprintf snwprintf
31 #define vsntprintf vsnwprintf
32 #else
33 #define sntprintf snprintf
34 #define vsntprintf vsnprintf
35 #endif
37 /* Define needed types if they are not yet defined */
40 # ifndef _VA_LIST_DEFINED
41 typedef char * va_list;
42 # define _VA_LIST_DEFINED
43 # endif
46 # ifndef _WCHAR_T_DEFINED
47 typedef unsigned short wchar_t;
48 # define _WCHAR_T_DEFINED
49 # endif
52 #ifndef _SNPRINTF_DLLIMPORT
53 #define _SNPRINTF_DLLIMPORT __declspec( dllimport )
54 #endif
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
61 /* Implementations of snprintf following the ISO/IEC 9899:1999 (ISO C99)
62 standard.
63 The difference compared to _snprintf is that the buffer always is zero
64 terminated (unless count is zero) and the return value is the number of
65 characters (not including terminating zero) that would have been written
66 even if the buffer wasn't large
67 enough to hold the string. */
70 #if !defined(__MINGW32__) || defined (__NO_ISOCEXT)
72 /* UNICODE version */
73 _SNPRINTF_DLLIMPORT int __cdecl snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
75 /* SBCS and MBCS version */
76 _SNPRINTF_DLLIMPORT int __cdecl snprintf( char *buffer, size_t count, const char *format, ... );
78 #endif
80 /* Conflict with STL_port inline implementation */
82 #ifdef __cplusplus
84 #endif
86 #endif // INCLUDED_SYSTOOLS_WIN32_SNPRINTF_H
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */