SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FormatString.cpp
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
16 #include "slikenet/FormatString.h"
17 #include <stdio.h>
18 #include <string.h>
19 #include <stdarg.h>
20 #include "slikenet/LinuxStrings.h"
21 #include "slikenet/linux_adapter.h"
22 #include "slikenet/osx_adapter.h"
23
24 char * FormatString(const char *format, ...)
25 {
26 static int textIndex=0;
27 static char text[4][8096];
28 va_list ap;
29 va_start(ap, format);
30
31 if (++textIndex==4)
32 textIndex=0;
33 vsnprintf_s(text[textIndex], 8096, _TRUNCATE, format, ap);
34 va_end(ap);
35
36 return text[textIndex];
37 }
38
39 char * FormatStringTS(char *output, const char *format, ...)
40 {
41 va_list ap;
42 va_start(ap, format);
43 vsnprintf_s(output, 512, _TRUNCATE, format, ap);
44 va_end(ap);
45 return output;
46 }