tesseract  4.00.00dev
tprintf.h File Reference
#include "params.h"

Go to the source code of this file.

Macros

#define tprintf(...)   tprintf_internal(__VA_ARGS__)
 

Functions

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

Variables

DLLSYM char * debug_file = ""
 
DLLSYM bool debug_window_on = 1
 

Macro Definition Documentation

◆ tprintf

#define tprintf (   ...)    tprintf_internal(__VA_ARGS__)

Definition at line 31 of file tprintf.h.

Function Documentation

◆ tprintf_internal()

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

Definition at line 39 of file tprintf.cpp.

41  {
43  va_list args; // variable args
44  static FILE *debugfp = NULL; // debug file
45  // debug window
46  inT32 offset = 0; // into message
47  static char msg[MAX_MSG_LEN + 1];
48 
49  va_start(args, format); // variable list
50  // Format into msg
51  #ifdef _WIN32
52  offset += _vsnprintf(msg + offset, MAX_MSG_LEN - offset, format, args);
53  if (strcmp(debug_file.string(), "/dev/null") == 0)
54  debug_file.set_value("nul");
55  #else
56  offset += vsnprintf(msg + offset, MAX_MSG_LEN - offset, format, args);
57  #endif
58  va_end(args);
59 
60  if (debugfp == NULL && strlen(debug_file.string()) > 0) {
61  debugfp = fopen(debug_file.string(), "wb");
62  } else if (debugfp != NULL && strlen(debug_file.string()) == 0) {
63  fclose(debugfp);
64  debugfp = NULL;
65  }
66  if (debugfp != NULL)
67  fprintf(debugfp, "%s", msg);
68  else
69  fprintf(stderr, "%s", msg);
71 }
int32_t inT32
Definition: host.h:38
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:60
voidpf uLong offset
Definition: ioapi.h:42
#define MAX_MSG_LEN
Definition: tprintf.cpp:32
DLLSYM char * debug_file
Definition: tprintf.cpp:36

Variable Documentation

◆ debug_file

DLLSYM char* debug_file = ""

"File to send tprintf output to"

Definition at line 36 of file tprintf.cpp.

◆ debug_window_on

DLLSYM bool debug_window_on = 1

"Send tprintf to window unless file set"