ccstruct/callcpp.cpp

Go to the documentation of this file.
00001 
00020 #include "mfcpch.h"
00021 #include          "errcode.h"
00022 #ifdef __UNIX__
00023 #include          <assert.h>
00024 #include <stdarg.h>
00025 #endif
00026 #include          <time.h>
00027 #include          "memry.h"
00028 #include          "grphics.h"
00029 #include          "evnts.h"
00030 #include          "varable.h"
00031 #include          "callcpp.h"
00032 #include          "tprintf.h"
00033 //#include                                      "strace.h"
00034 #include          "host.h"
00035 
00036 //extern "C" {
00037 
00040 INT_VAR (tess_cp_mapping0, 0, "Mappings for class pruner distance");
00041 INT_VAR (tess_cp_mapping1, 1, "Mappings for class pruner distance");
00042 INT_VAR (tess_cp_mapping2, 2, "Mappings for class pruner distance");
00043 INT_VAR (tess_cp_mapping3, 3, "Mappings for class pruner distance");
00044 INT_VAR (stopper_numbers_on, 0, "Allow numbers to be acceptable choices");
00045 INT_VAR (config_pruner_enabled, 0, "Turn on config pruner");
00046 INT_VAR (feature_prune_percentile, 0, "Percent of features to use");
00047 INT_VAR (newcp_ratings_on, 0, "Use new class pruner normalisation");
00048 INT_VAR (record_matcher_output, 0, "Record detailed matcher info");
00049 INT_VAR (il1_adaption_test, 0, "Dont adapt to i/I at beginning of word");
00050 double_VAR (permuter_pending_threshold, 0.0,
00051 "Worst conf for using pending dictionary");
00052 double_VAR (newcp_duff_rating, 0.30, "Worst rating for calling real matcher");
00053 double_VAR (newcp_prune_threshold, 1.2, "Ratio of best to prune");
00054 double_VAR (tessedit_cp_ratio, 0.0, "Ratio from best to prune");
00057 //Global matcher info from the class pruner.
00058 INT32 cp_classes;
00059 INT32 cp_bestindex;
00060 INT32 cp_bestrating;
00061 INT32 cp_bestconf;
00062 char cp_chars[2];
00063 INT32 cp_ratings[2];
00064 INT32 cp_confs[2];
00065 INT32 cp_maps[4];
00066 //Global info to control writes of matcher info
00067 INT32 blob_type;                 //write control
00068 char blob_answer;                //correct char
00069 char *word_answer;               //correct word
00070 INT32 matcher_pass;              //pass in chopper.c
00071 INT32 bits_in_states;            //no of bits in states
00072 
00073 #ifndef __UNIX__
00074 
00077 void assert(             //recog one owrd
00078             int testing  //assert fail if false
00079            ) {
00080   ASSERT_HOST(testing); 
00081 }
00082 #endif
00083 
00084 void setup_cp_maps() { 
00085   cp_maps[0] = tess_cp_mapping0;
00086   cp_maps[1] = tess_cp_mapping1;
00087   cp_maps[2] = tess_cp_mapping2;
00088   cp_maps[3] = tess_cp_mapping3;
00089 }
00090 
00091 
00092 void trace_stack() {  //Trace current stack
00093 }
00094 
00095 
00096 void
00097 cprintf (                        //Trace printf
00098 const char *format, ...          //special message
00099 ) {
00100   va_list args;                  //variable args
00101   char msg[1000];
00102 
00103   va_start(args, format);  //variable list
00104   vsprintf(msg, format, args);  //Format into msg
00105   va_end(args); 
00106 
00107   tprintf ("%s", msg);
00108 }
00109 
00110 
00111 char *c_alloc_string(             //allocate string
00112                      INT32 count  //no of chars required
00113                     ) {
00114   return alloc_string (count);
00115 }
00116 
00117 
00118 void c_free_string(              //free a string
00119                    char *string  //string to free
00120                   ) {
00121   free_string(string); 
00122 }
00123 
00124 
00125 void *c_alloc_struct(                  //allocate memory
00126                      INT32 count,      //no of chars required
00127                      const char *name  //class name
00128                     ) {
00129   return alloc_struct (count, name);
00130 }
00131 
00132 
00133 void c_free_struct(                   //free a structure
00134                    void *deadstruct,  //structure to free
00135                    INT32 count,       //no of bytes
00136                    const char *name   //class name
00137                   ) {
00138   free_struct(deadstruct, count, name); 
00139 }
00140 
00141 
00142 void *c_alloc_mem_p(             //allocate permanent space
00143                     INT32 count  //block size to allocate
00144                    ) {
00145   return alloc_mem_p (count);
00146 }
00147 
00148 
00149 void *c_alloc_mem(             //get some memory
00150                   INT32 count  //no of bytes to get
00151                  ) {
00152   return alloc_mem (count);
00153 }
00154 
00155 
00156 void c_free_mem(                //free mem from alloc_mem
00157                 void *oldchunk  //chunk to free
00158                ) {
00159   free_mem(oldchunk); 
00160 }
00161 
00162 
00163 void c_check_mem(                     //check consistency
00164                  const char *string,  //context message
00165                  INT8 level           //level of check
00166                 ) {
00167   check_mem(string, level); 
00168 }
00169 
00170 #ifndef GRAPHICS_DISABLED
00171 void *c_create_window(                   /*create a window */
00172                       const char *name,  /*name/title of window */
00173                       INT16 xpos,        /*coords of window */
00174                       INT16 ypos,        /*coords of window */
00175                       INT16 xsize,       /*size of window */
00176                       INT16 ysize,       /*size of window */
00177                       double xmin,       /*scrolling limits */
00178                       double xmax,       /*to stop users */
00179                       double ymin,       /*getting lost in */
00180                       double ymax        /*empty space */
00181                      ) {
00182   return create_window (name, SCROLLINGWIN, xpos, ypos, xsize, ysize,
00183     xmin, xmax, ymin, ymax, TRUE, FALSE, FALSE, TRUE);
00184 }
00185 
00186 
00187 void c_line_color_index(  /*set color */
00188                         void *win,
00189                         C_COL index) {
00190   WINDOW window = (WINDOW) win;
00191 
00192   //      ASSERT_HOST(index>=0 && index<=48);
00193   if (index < 0 || index > 48)
00194     index = (C_COL) 1;
00195   window->Line_color_index ((COLOUR) index);
00196 }
00197 
00198 
00199 void c_move(  /*move pen */
00200             void *win,
00201             double x,
00202             double y) {
00203   WINDOW window = (WINDOW) win;
00204 
00205   window->Move2d (x, y);
00206 }
00207 
00208 
00209 void c_draw(  /*move pen */
00210             void *win,
00211             double x,
00212             double y) {
00213   WINDOW window = (WINDOW) win;
00214 
00215   window->Draw2d (x, y);
00216 }
00217 
00218 
00219 void c_make_current(  /*move pen */
00220                     void *win) {
00221   WINDOW window = (WINDOW) win;
00222 
00223   window->Make_picture_current ();
00224 }
00225 
00226 
00227 void c_clear_window(  /*move pen */
00228                     void *win) {
00229   WINDOW window = (WINDOW) win;
00230 
00231   window->Clear_view_surface ();
00232 }
00233 
00234 
00235 char window_wait(  /*move pen */
00236                  void *win) {
00237   WINDOW window = (WINDOW) win;
00238   GRAPHICS_EVENT event;
00239 
00240   await_event(window, TRUE, ANY_EVENT, &event); 
00241   if (event.type == KEYPRESS_EVENT)
00242     return event.key;
00243   else
00244     return '\0';
00245 }
00246 #endif
00247 
00248 void reverse32(void *ptr) { 
00249   char tmp;
00250   char *cptr = (char *) ptr;
00251 
00252   tmp = *cptr;
00253   *cptr = *(cptr + 3);
00254   *(cptr + 3) = tmp;
00255   tmp = *(cptr + 1);
00256   *(cptr + 1) = *(cptr + 2);
00257   *(cptr + 2) = tmp;
00258 }
00259 
00260 
00261 void reverse16(void *ptr) { 
00262   char tmp;
00263   char *cptr = (char *) ptr;
00264 
00265   tmp = *cptr;
00266   *cptr = *(cptr + 1);
00267   *(cptr + 1) = tmp;
00268 }
00269 
00270 
00271 //};

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