tesseract  5.0.0-alpha-619-ge9db
tprintf.h File Reference

Go to the source code of this file.

Functions

TESS_API void tprintf (const char *format,...)
 

Function Documentation

◆ tprintf()

TESS_API void tprintf ( const char *  format,
  ... 
)

Definition at line 34 of file tprintf.cpp.

36 {
37  const char* debug_file_name = debug_file.c_str();
38  static FILE *debugfp = nullptr; // debug file
39 
40  if (debug_file_name == nullptr) {
41  // This should not happen.
42  return;
43  }
44 
45 #ifdef _WIN32
46  // Replace /dev/null by nul for Windows.
47  if (strcmp(debug_file_name, "/dev/null") == 0) {
48  debug_file_name = "nul";
49  debug_file.set_value(debug_file_name);
50  }
51 #endif
52 
53  if (debugfp == nullptr && debug_file_name[0] != '\0') {
54  debugfp = fopen(debug_file_name, "wb");
55  } else if (debugfp != nullptr && debug_file_name[0] == '\0') {
56  fclose(debugfp);
57  debugfp = nullptr;
58  }
59 
60  va_list args; // variable args
61  va_start(args, format); // variable list
62  if (debugfp != nullptr) {
63  vfprintf(debugfp, format, args);
64  } else {
65  vfprintf(stderr, format, args);
66  }
67  va_end(args);