tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/tprintf.cpp File Reference
#include <stdio.h>
#include <stdarg.h>
#include "ccutil.h"
#include "params.h"
#include "strngs.h"
#include "tprintf.h"

Go to the source code of this file.

Defines

#define MAX_MSG_LEN   65536
#define EXTERN

Functions

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

Variables

DLLSYM char * debug_file = ""

Define Documentation

#define EXTERN

Definition at line 34 of file tprintf.cpp.

#define MAX_MSG_LEN   65536

Definition at line 32 of file tprintf.cpp.


Function Documentation

DLLSYM 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.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines