Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
1.8 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1994 - 1999
  3. Module Name:
  4. io.c
  5. Abstract:
  6. Input/Output functions for RPC development performance tests.
  7. Author:
  8. Mario Goertzel (mariogo) 29-Mar-1994
  9. Revision History:
  10. --*/
  11. #include <rpcperf.h>
  12. #include <stdarg.h>
  13. void PauseForUser(char *string)
  14. {
  15. char buffer[80];
  16. printf("%s\n<return to continue>\n", string);
  17. fflush(stdout);
  18. gets(buffer);
  19. return;
  20. }
  21. static FILE *LogFile = 0;
  22. static char buffer[1024];
  23. void DumpCommon(char *Format, va_list Marker)
  24. {
  25. // Are we logging to a file?
  26. if (LogFileName)
  27. {
  28. // Have we opened to log file yet?
  29. if (!LogFile)
  30. {
  31. if (AppendOnly)
  32. LogFile = fopen(LogFileName, "a");
  33. else
  34. LogFile = fopen(LogFileName, "w");
  35. if (!LogFile)
  36. {
  37. fprintf(stderr, "Unable to open log file: %s\n", LogFileName);
  38. exit(-1);
  39. }
  40. }
  41. vfprintf(LogFile, Format, Marker);
  42. fflush(LogFile);
  43. }
  44. #ifndef WIN
  45. vfprintf(stdout, Format, Marker);
  46. #else
  47. {
  48. // Hack for Windows STDIO emulator
  49. char buffer[256];
  50. vsprintf(buffer, Format, Marker);
  51. #undef printf
  52. printf(buffer);
  53. }
  54. #endif
  55. }
  56. void Dump(char *Format, ...)
  57. {
  58. va_list Marker;
  59. va_start(Marker, Format);
  60. DumpCommon(Format, Marker);
  61. va_end(Marker);
  62. }
  63. void Verbose(char *Format, ...)
  64. {
  65. if (OutputLevel > 1)
  66. {
  67. va_list Marker;
  68. va_start(Marker, Format);
  69. DumpCommon(Format, Marker);
  70. va_end(Marker);
  71. }
  72. }
  73. void Trace(char *Format, ...)
  74. {
  75. if (OutputLevel > 2)
  76. {
  77. va_list Marker;
  78. va_start(Marker, Format);
  79. DumpCommon(Format, Marker);
  80. va_end(Marker);
  81. }
  82. }