⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tprintf.cpp

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 CPP
字号:
/********************************************************************** * File:        tprintf.c * Description: Trace version of printf - portable between UX and NT * Author:      Phil Cheatle * Created:     Wed Jun 28 15:01:15 BST 1995 * * (C) Copyright 1995, Hewlett-Packard Ltd. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. * **********************************************************************/#include          "mfcpch.h"     //precompiled headers#include          <stdio.h>#include          <stdarg.h>#include          "strngs.h"#include          "varable.h"#include              "debugwin.h"//#include                                      "ipeerr.h"#include          "tprintf.h"#define MAX_MSG_LEN     1024#define EXTERN#ifdef __MSW32__DLLSYM STRING_VAR (debug_file, "tesseract.log", "File to send tprintf output to");#elseDLLSYM STRING_VAR (debug_file, "", "File to send tprintf output to");#endifDLLSYM BOOL_VAR (debug_window_on, FALSE,"Send tprintf to window unless file set");DLLSYM voidtprintf (                        //Trace printfconst char *format, ...          //special message) {  va_list args;                  //variable args  static FILE *debugfp = NULL;   //debug file                                 //debug window  static DEBUG_WIN *debugwin = NULL;  INT32 offset = 0;              //into message  static char msg[MAX_MSG_LEN + 1];  va_start(args, format);  //variable list  #ifdef __MSW32__                                 //Format into msg  offset += _vsnprintf (msg + offset, MAX_MSG_LEN - offset, format, args);  #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 (), "w");  else if (debugfp != NULL && strlen (debug_file.string ()) == 0) {    fclose(debugfp);    debugfp = NULL;  }  if (debugfp != NULL)    fprintf (debugfp, "%s", msg);  else {    if (debug_window_on) {      if (debugwin == NULL)                                 //in pixels        debugwin = new DEBUG_WIN ("Debug Window", DEBUG_WIN_XPOS, DEBUG_WIN_YPOS,                                 //in pixels          DEBUG_WIN_XSIZE, DEBUG_WIN_YSIZE,          debug_lines);      debugwin->dprintf (msg);    }    else {      #ifdef __UNIX__                                 // output to stderr - like it used to      fprintf (stderr, "%s", msg);      #endif      #ifdef __MSW32__      TRACE ("%s", msg);         //Visual C++2.0 macro      #endif      #ifdef __MAC__      printf ("%s", msg);        //Visual C++2.0 macro      #endif    }  }}/************************************************************************* * pause_continue() * UI for a debugging pause - to see an intermediate state * Returns TRUE to continue as normal to the next pause in the current mode; * FALSE to quit the current pausing mode. *************************************************************************/DLLSYM BOOL8                                 //special messagepause_continue (const char *format, ...) {  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 __MSW32__  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}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -