ccutil/tprintf.cpp File Reference

#include "mfcpch.h"
#include <stdio.h>
#include <stdarg.h>
#include "strngs.h"
#include "varable.h"
#include "debugwin.h"
#include "tprintf.h"

Go to the source code of this file.

Defines

Functions


Define Documentation

#define EXTERN

Definition at line 30 of file tprintf.cpp.

#define MAX_MSG_LEN   1024

Note:
File: tprintf.cpp
Trace version of printf, portable between UX and NT
Author:
Phil Cheatle
Date:
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.

Definition at line 28 of file tprintf.cpp.

Referenced by tprintf().


Function Documentation

DLLSYM BOOL8 pause_continue ( const char *  format,
  ... 
)

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.

Definition at line 112 of file tprintf.cpp.

References NULL.

00113   {
00114   va_list args;                  //variable args
00115   char msg[1000];
00116   STRING str = STRING ("DEBUG PAUSE:\n");
00117 
00118   va_start(args, format);  //variable list
00119   vsprintf(msg, format, args);  //Format into msg
00120   va_end(args);
00121 
00122   #ifdef GRAPHICS_DISABLED
00123   // No interaction allowed -> simply go on
00124   return true;
00125   #else // GRAPHICS_DISABLED
00126 
00127   #ifdef __UNIX__
00128   printf ("%s\n", msg);
00129   printf ("Type \"c\" to cancel, anything else to continue: ");
00130   char c = getchar ();
00131   return (c != 'c');
00132   #endif
00133 
00134   #ifdef __MSW32__
00135   str +=
00136     STRING (msg) + STRING ("\nUse OK to continue, CANCEL to stop pausing");
00137   //   return AfxMessageBox( str.string(), MB_OKCANCEL ) == IDOK;
00138   return::MessageBox (NULL, msg, "IMGAPP",
00139     MB_APPLMODAL | MB_OKCANCEL) == IDOK;
00140   #endif
00141 
00142   #endif // GRAPHICS_DISABLED
00143 }

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

Trace version of printf - portable between UX and NT.

Definition at line 47 of file tprintf.cpp.

References DEBUG_WIN_XPOS, DEBUG_WIN_XSIZE, DEBUG_WIN_YPOS, DEBUG_WIN_YSIZE, debugfp, DEBUG_WIN::dprintf(), MAX_MSG_LEN, and NULL.

Referenced by adapt_to_good_ems(), adapt_to_good_samples(), alloc_string(), alloc_struct(), apply_box_testing(), apply_box_training(), apply_boxes(), assign_blobs_to_rows(), PIXROW::bad_box(), block_space_stat(), MEM_ALLOCATOR::check(), check_block_occ(), check_debug_pt(), check_pitch_sync(), check_pitch_sync2(), check_pitch_sync3(), check_struct(), check_wait_list(), choose_partition(), classify_word_pass1(), classify_word_pass2(), clean_noise_from_row(), cleanup_rows(), clip_sample(), cluster_sample(), collect_characters_for_adaption(), collect_ems_for_adaption(), compare_blob_pairs(), complete_clustering(), compute_block_pitch(), compute_fixed_pitch(), compute_pitch_sd(), compute_pitch_sd2(), compute_row_stats(), compute_row_xheight(), cprintf(), cutline(), display_cluster_prototypes(), MEM_ALLOCATOR::display_counts(), doc_and_block_rejection(), dump_words(), ERRCODE::error(), find_best_dropout_row(), CHAR_SAMPLES::find_best_sample(), find_repeated_chars(), find_row_pitch(), find_textlines(), fix_row_pitch(), fix_sp_fp_word(), fixed_pitch_row(), fixspace_dbg(), free_string(), free_struct(), GAPMAP::GAPMAP(), garbage_word(), improve_row_threshold(), isolated_row_stats(), linear_spline_baseline(), main(), make_epaper_choice(), make_first_xheight(), make_old_baselines(), make_prop_words(), mark_gap(), CHAR_PROTO::match(), match1(), match_word_pass2(), merge_oldbl_parts(), most_overlapping_row(), MEM_ALLOCATOR::new_block(), ocr_get_first_image_strip(), open_tif_image(), STRING::operator+(), STRING::operator+=(), STRING::operator=(), partition_line(), pgeditor_msg(), pgeditor_read_file(), IMAGE::pixel(), plot_to_row(), poly2(), potential_word_crunch(), double_VARIABLE::print(), STRING_VARIABLE::print(), BOOL_VARIABLE::print(), INT_VARIABLE::print(), WERD::print(), STATS::print(), BOX::print(), ROW::print(), print_block_counts(), print_em_stats(), print_pitch_sd(), print_ratings_list(), re_estimate_x_ht(), read_hpd_file(), read_next_box(), read_pd_file(), read_tif_image(), read_variables_file(), read_vec_file(), recog_all_words(), recog_interactive(), recog_word(), recog_word_recursive(), reduce_sub_image(), report_failed_box(), resegment_box(), row_pitch_stats(), row_space_stat(), row_spacing_stats(), row_words(), row_words2(), scale_image(), segment_baseline(), segment_spline(), separate_underlines(), set_row_spaces(), set_word_fonts(), STATS::short_print(), signal_exit(), signal_termination_handler(), split_stepped_spline(), terrible_word_crunch(), test_underline(), tidy_up(), tilde_crunch(), tilde_delete(), to_spacing(), try_doc_fixed(), try_rows_fixed(), tune_row_pitch(), tune_row_pitch2(), uniformly_spaced(), word_dumper(), worst_noise_blob(), write_cooked_text(), and write_results().

00049   {
00050   va_list args;                  //variable args
00051   static FILE *debugfp = NULL;   //debug file
00052                                  //debug window
00053   static DEBUG_WIN *debugwin = NULL;
00054   INT32 offset = 0;              //into message
00055   static char msg[MAX_MSG_LEN + 1];
00056 
00057   va_start(args, format);  //variable list
00058   #ifdef __MSW32__
00059                                  //Format into msg
00060   offset += _vsnprintf (msg + offset, MAX_MSG_LEN - offset, format, args);
00061   #else
00062                                  //Format into msg
00063   offset += vsprintf (msg + offset, format, args);
00064   #endif
00065   va_end(args);
00066 
00067   if (debugfp == NULL && strlen (debug_file.string ()) > 0)
00068     debugfp = fopen (debug_file.string (), "w");
00069   else if (debugfp != NULL && strlen (debug_file.string ()) == 0) {
00070     fclose(debugfp);
00071     debugfp = NULL;
00072   }
00073   if (debugfp != NULL)
00074     fprintf (debugfp, "%s", msg);
00075   else {
00076 
00077     if (debug_window_on) {
00078       if (debugwin == NULL)
00079                                  //in pixels
00080         debugwin = new DEBUG_WIN ("Debug Window", DEBUG_WIN_XPOS, DEBUG_WIN_YPOS,
00081                                  //in pixels
00082           DEBUG_WIN_XSIZE, DEBUG_WIN_YSIZE,
00083           debug_lines);
00084       debugwin->dprintf (msg);
00085     }
00086     else {
00087       #ifdef __UNIX__
00088                                  // output to stderr - like it used to
00089       fprintf (stderr, "%s", msg);
00090       #endif
00091 
00092       #ifdef __MSW32__
00093       TRACE ("%s", msg);         //Visual C++2.0 macro
00094       #endif
00095       #ifdef __MAC__
00096       printf ("%s", msg);        //Visual C++2.0 macro
00097       #endif
00098     }
00099   }
00100 }


Generated on Wed Feb 28 19:49:17 2007 for Tesseract by  doxygen 1.5.1