tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/tprintf.h File Reference
#include "params.h"

Go to the source code of this file.

Defines

#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

Define Documentation

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

Definition at line 31 of file tprintf.h.


Function Documentation

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

Definition at line 39 of file tprintf.cpp.

  {
  tesseract::tprintfMutex.Lock();
  va_list args;                  // variable args
  static FILE *debugfp = NULL;   // debug file
                                 // debug window
  inT32 offset = 0;              // into message
  static char msg[MAX_MSG_LEN + 1];

  va_start(args, format);  // variable list
  // Format into msg
  #ifdef _WIN32
  offset += _vsnprintf(msg + offset, MAX_MSG_LEN - offset, format, args);
  if (strcmp(debug_file.string(), "/dev/null") == 0)
    debug_file.set_value("nul");
  #else
  offset += vsnprintf(msg + offset, MAX_MSG_LEN - offset, format, args);
  #endif
  va_end(args);

  if (debugfp == NULL && strlen(debug_file.string()) > 0) {
    debugfp = fopen(debug_file.string(), "wb");
  } else if (debugfp != NULL && strlen(debug_file.string()) == 0) {
    fclose(debugfp);
    debugfp = NULL;
  }
  if (debugfp != NULL)
    fprintf(debugfp, "%s", msg);
  else
    fprintf(stderr, "%s", msg);
  tesseract::tprintfMutex.Unlock();
}

Variable Documentation

DLLSYM char* debug_file = ""

"File to send tprintf output to"

Definition at line 36 of file tprintf.cpp.

"Send tprintf to window unless file set"

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines