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

📄 debugwin.cpp

📁 一OCR的相关资料。.希望对研究OCR的朋友有所帮助.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    pid);  length += sprintf (command + length, "trap \"exit\" 1 2 3 13 15\n");  length +=    sprintf (command + length,    "while [ ! -s /tmp/debug%d ]\ndo\nsleep 1\ndone\n", pid);  length += sprintf (command + length, "trap \"\" 1 2 3 13 15\n");  length += sprintf (command + length, "ofile=`cat /tmp/debug%d`\n", pid);  length +=    sprintf (command + length, "cat -u - >$ofile; rm /tmp/debug%d\n", pid);  if (remote) {    command[length++] = '\'';    //terminate remsh    command[length] = '\0';  }  fp = popen (command, "w");     /*create window */  if (fp != NULL) {                                 /*set no buffering */    if (setvbuf (fp, NULL, _IONBF, BUFSIZ)) {      pclose(fp);       fp = NULL;    }  }  #endif}/********************************************************************** * DEBUG_WIN::DEBUG_WIN * * Close the file and destroy the window. **********************************************************************/DEBUG_WIN::~DEBUG_WIN (//destructor) {  #ifdef __UNIX__  pclose(fp);   #endif}/********************************************************************** * dprintf * * Print a message to the debug window. * Like printf, this function can cope with messages which do not end * in newline, but nothing is printed until the newline is received. **********************************************************************/voidDEBUG_WIN::dprintf (             //debug printfconst char *format, ...          //special message) {  va_list args;                  //variable args  va_start(args, format);  //variable list  #ifdef __UNIX__  vfprintf(fp, format, args);  //Format into msg  #else                                 //Format into msg  vfprintf(stderr, format, args);   #endif  va_end(args); }/********************************************************************** * await_destruction * * Wait for the user to close the debug window. Then return. **********************************************************************/void DEBUG_WIN::await_destruction() {  //wait for user to close  #ifdef __UNIX__  signal(SIGPIPE, SIG_IGN);   while (!ferror (fp)) {    sleep (1);    fputc (0, fp);               //send nulls until error  }  #endif}#endif                           //UNIX Implmentation#ifdef __MAC__                   //NT implementation#include          <stdio.h>//#include                                                      "textwindow.h"#include          <lwindow.h>#include          "ipcbase.h"    //must be last include// Until I can figure a way to do this without linking in PowerPlant,// the debug window will just have empty functions so compilation can take place./********************************************************************** * DEBUG_WIN::SetCommander * * Mac-specific function to set the commander for the next debug window **********************************************************************/void DEBUG_WIN::SetCommander(LCommander *pNew) {   pCommander = pNew;}/********************************************************************** * DEBUG_WIN::DEBUG_WIN * * Create a debug window with size according to the arguments. * Create an hpterm window with a pipe connected to it. **********************************************************************/DEBUG_WIN::DEBUG_WIN(                    //constructor                     const char *title,  //of window                     INT32 xpos,         //initial position                     INT32 ypos,         //in pixels                     INT32 xsize,        //initial size                     INT32 ysize,        //in pixels                     INT32 buflines      //default scroll size                    ) {  INT32 length;                  /*length of name */  // don't replace this DebugStr() with a call to DEBUG_WIN!  //if (pCommander==NULL) DebugStr("\pDEBUG_WIN::DEBUG_WIN(), Commander not set");  // create the window  //pWindow=LWindow::CreateWindow(2700,pCommander);}/********************************************************************** * DEBUG_WIN::DEBUG_WIN * * Close the file and destroy the window. **********************************************************************/DEBUG_WIN::~DEBUG_WIN (//destructor) {}/********************************************************************** * dprintf * * Print a message to the debug window. * Like printf, this function can cope with messages which do not end * in newline, but nothing is printed until the newline is received. **********************************************************************/voidDEBUG_WIN::dprintf (             //debug printfconst char *format, ...          //special message) {  #if 0  LTextEdit *pTextEdit;  va_list args;                  //variable args  static char msg[1024];  INT32 i;  INT32 OriginalLength;  INT32 NewLength;  TEHandle hTextEdit;  char *pTempBuffer;  CharsHandle hChar;  char *pOriginalText;  INT32 StringLength;  pTextEdit = (LTextEdit *) pWindow->FindPaneByID (text_FLOWED);  if (pTextEdit == NULL)    DebugStr ("\pwhoops");  // get a C String from the format and args passed in  va_start(args, format);  //variable list  vsprintf(msg, format, args);  //Format into msg  va_end(args);   StringLength = strlen (msg);  // get the handle for the text  hTextEdit = pTextEdit->GetMacTEH ();  if (hTextEdit == NULL)    DebugStr ("\pDEBUG_WIN,WriteCharsToConsole()");  // get a pointer to the characters and the length of the character stream  hChar = TEGetText (hTextEdit);  if (hChar == NULL)    DebugStr ("\pDEBUG_WIN,WriteCharsToConsole()");  pOriginalText = *hChar;        // get pointer to existing text                                 // get the length of the original data  OriginalLength = (*hTextEdit)->teLength;  // setup a temporary buffer for the new text  NewLength = OriginalLength + StringLength;  pTempBuffer = NewPtr (NewLength);  if (pTempBuffer == NULL)    DebugStr ("\pDEBUG_WIN,WriteCharsToConsole()");  // copy the original data into the new buffer  for (i = 0; i < OriginalLength; i++)    pTempBuffer[i] = pOriginalText[i];  // append the new data onto the end of the original buffer  for (i = 0; i < StringLength; i++) {    if (msg[i] == '\n')      pTempBuffer[i + OriginalLength] = '\r';    else      pTempBuffer[i + OriginalLength] = msg[i];  }  // put the new text into the text edit item  TESetText(pTempBuffer, NewLength, hTextEdit);   // clean up  DisposePtr(pTempBuffer);   #endif}#endif                           //Mac Implmentation#else                            // Non graphical debuggerDEBUG_WIN::DEBUG_WIN( const char*, INT32, INT32, INT32, INT32, INT32 ) {}DEBUG_WIN::~DEBUG_WIN () {}void DEBUG_WIN::dprintf (const char *format, ...) {  va_list ap;  va_start(ap, format);  vfprintf(stderr, format, ap);  va_end(ap);}void await_destruction() {}#endif

⌨️ 快捷键说明

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