FormatString.cpp 922 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * 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. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #include "FormatString.h"
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdarg.h>
  14. #include "LinuxStrings.h"
  15. char * FormatString(const char *format, ...)
  16. {
  17. static int textIndex=0;
  18. static char text[4][8096];
  19. va_list ap;
  20. va_start(ap, format);
  21. if (++textIndex==4)
  22. textIndex=0;
  23. _vsnprintf(text[textIndex], 8096, format, ap);
  24. va_end(ap);
  25. text[textIndex][8096-1]=0;
  26. return text[textIndex];
  27. }
  28. char * FormatStringTS(char *output, const char *format, ...)
  29. {
  30. va_list ap;
  31. va_start(ap, format);
  32. _vsnprintf(output, 512, format, ap);
  33. va_end(ap);
  34. return output;
  35. }
粤ICP备19079148号