Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.

87  {
88  va_list args; //variable args
89  char msg[1000];
90  STRING str = STRING ("DEBUG PAUSE:\n");
91 
92  va_start(args, format); //variable list
93  vsprintf(msg, format, args); //Format into msg
94  va_end(args);
95 
96  #ifdef GRAPHICS_DISABLED
97  // No interaction allowed -> simply go on
98  return true;
99  #else
100 
101  #ifdef __UNIX__
102  printf ("%s\n", msg);
103  printf ("Type \"c\" to cancel, anything else to continue: ");
104  char c = getchar ();
105  return (c != 'c');
106  #endif
107 
108  #ifdef _WIN32
109  str +=
110  STRING (msg) + STRING ("\nUse OK to continue, CANCEL to stop pausing");
111  // return AfxMessageBox( str.string(), MB_OKCANCEL ) == IDOK;
112  return::MessageBox (NULL, msg, "IMGAPP",
113  MB_APPLMODAL | MB_OKCANCEL) == IDOK;
114  #endif
115 
116  #endif
117 }
#define NULL
Definition: host.h:144
Definition: strngs.h:40
TESS_API void tprintf ( const char *  format,
  ... 
)

Definition at line 41 of file tprintf.cpp.

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

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"