Mobile API Reference  MicroStrategy 2019
PDCstdio.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : PDCstdio.h
3 // AUTHOR : Perl Script
4 // CREATION : 6/13/02
5 // Copyright (C) MicroStrategy, Inc. 2002
6 //==============================================================================================
7 #ifndef PDCstdio_h
8 #define PDCstdio_h
9 
10 // this must be the *first* file included
11 #include "ProtectedSource/Prolog.h"
12 
13 #include <stdio.h>
14 #include <string.h>
15 
16 #include "PDCwchar.h"
17 #include "PDCstdarg.h"
18 
19 #if !defined(WIN32) && defined(WIN64)
20 // 2003-11-04 vovechkin
22 // Implemented swprintf() with additional count parameter,
23 // just like on UNIX.
24 //
25 inline int swprintf(wchar_t* buffer, size_t count, const wchar_t* format, ...)
26 {
27  va_list argptr;
28 
29  // variable arguments start with last defined argument - format
30  va_start(argptr, format);
31 
32  // build message based on format, and remaining arguments
33  const int lResult = ::_vsnwprintf(buffer, count, format, argptr);
34 
35  va_end(argptr);
36 
37  return lResult;
38 }
39 #endif // WIN32
40 
41 // this is a version of sprintf with extra count parameter
42 inline int sprintf(char* buffer, size_t count, const char* format, ...)
43 {
44  va_list argptr;
45 
46  // variable arguments start with last defined argument - format
47  va_start(argptr, format);
48 
49  // build message based on format, and remaining arguments
50 #ifdef WIN32
51  const int lResult = ::_vsnprintf_s(buffer, count, count, format, argptr);
52 #else
53  const int lResult = ::vsnprintf(buffer, count, format, argptr);
54 #endif
55 
56  va_end(argptr);
57 
58  return lResult;
59 }
60 
61 #if !defined(WIN32) && defined(WIN64)
62 
84 inline int sprintf_s(char *buffer, size_t sizeOfBuffer, const char* format, ...)
85 {
86  va_list argptr;
87  va_start(argptr, format); // variable arguments start with last defined argument - format
88  const int lResult = ::vsnprintf(buffer, sizeOfBuffer, format, argptr);
89  va_end(argptr);
90 
91  return lResult;
92 }
93 
106 inline int swprintf_s(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t* format, ...)
107 {
108  va_list argptr;
109  va_start(argptr, format); // variable arguments start with last defined argument - format
110  const int lResult = ::_vsnwprintf(buffer, sizeOfBuffer, format, argptr);
111  va_end(argptr);
112 
113  return lResult;
114 }
115 
116 #endif
117 
118 // this must be the *last* file included
119 #include "ProtectedSource/Epilog.h"
120 
121 #endif // PDCstdio_h
int sprintf(char *buffer, size_t count, const char *format,...)
Definition: PDCstdio.h:42