Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions | Variables
tprintf.cpp File Reference
`#include "mfcpch.h"`
`#include <stdio.h>`
`#include <stdarg.h>`
`#include "strngs.h"`
`#include "params.h"`
`#include "tprintf.h"`
`#include "ccutil.h"`

Go to the source code of this file.

## Macros
#define | MAX_MSG_LEN 65536
#define | EXTERN

## Functions
DLLSYM void | tprintf (const char *format,...)
DLLSYM BOOL8 | pause_continue (const char *format,...)

## Variables
DLLSYM char * | debug_file = ""

## Macro Definition Documentation

#define EXTERN

Definition at line 36 of file tprintf.cpp.

#define MAX_MSG_LEN 65536

Definition at line 34 of file tprintf.cpp.

## 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
}

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