Tesseract  3.02
tesseract-ocr/ccutil/tprintf.h File Reference
#include "params.h"

Go to the source code of this file.

Functions

TESS_API void tprintf (const char *format,...)
DLLSYM BOOL8 pause_continue (const char *format,...)

Variables

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

Function Documentation

DLLSYM BOOL8 pause_continue ( const char *  format,
  ... 
)

Definition at line 86 of file tprintf.cpp.

  {
  va_list args;                  //variable args
  char msg[1000];
  STRING str = STRING ("DEBUG PAUSE:\n");

  va_start(args, format);  //variable list
  vsprintf(msg, format, args);  //Format into msg
  va_end(args);

  #ifdef GRAPHICS_DISABLED
  // No interaction allowed -> simply go on
  return true;
  #else

  #ifdef __UNIX__
  printf ("%s\n", msg);
  printf ("Type \"c\" to cancel, anything else to continue: ");
  char c = getchar ();
  return (c != 'c');
  #endif

  #ifdef _WIN32
  str +=
    STRING (msg) + STRING ("\nUse OK to continue, CANCEL to stop pausing");
  //   return AfxMessageBox( str.string(), MB_OKCANCEL ) == IDOK;
  return::MessageBox (NULL, msg, "IMGAPP",
    MB_APPLMODAL | MB_OKCANCEL) == IDOK;
  #endif

  #endif
}
TESS_API void tprintf ( const char *  format,
  ... 
)

Definition at line 41 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
  #ifdef _WIN32
                                 //Format into msg
  offset += _vsnprintf (msg + offset, MAX_MSG_LEN - offset, format, args);
  if (strcmp(debug_file.string(), "/dev/null") == 0)
          debug_file.set_value("nul");
  #else
                                 //Format into msg
  offset += vsprintf (msg + 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 38 of file tprintf.cpp.

DLLSYM bool debug_window_on = 1

"Send tprintf to window unless file set"