cutil/debug.h File Reference

#include "variables.h"
#include "callcpp.h"
#include <stdio.h>

Go to the source code of this file.

Classes

Defines

Functions

Variables


Define Documentation

#define float_value ( proc,
string,
variable,
default   ) 

Value:

\
float variable = default;                          \
                                       \
int proc ()                                        \
{                                                  \
   return (set_float_value (string, &variable));   \
}                                                  \
Template procedures to set a floating point value of a variable.

Definition at line 60 of file debug.h.

#define handle_menu ( menu,
handle_menu_x   ) 

Value:

\
int handle_menu_x ()                            \
{                                               \
   int x;                                      \
   cprintf ("\t 0. Continue\n");               \
   for (x = 0; x < NUM_MENU_ITEMS; x++) {      \
      if (menu_table[menu][x].menu_string)                           \
      cprintf ("\t%2d. %s\n", x, menu_table[menu][x].menu_string);  \
   }                                                                 \
                                    \
   scanf ("%d", &x);                           \
                                    \
   if (x == 0) return (0);                     \
   if ((0 < x && x < NUM_MENU_ITEMS) &&        \
      (menu_table[menu][x].menu_function)) {  \
      (*menu_table[menu][x].menu_function) ();\
      return (1);                             \
   }                                           \
   else {                                      \
      cprintf ("Bad menu selection");         \
      return (0);                             \
   }                                           \
}                                               \
Create a procedure to handle menu items.

Definition at line 71 of file debug.h.

#define int_value ( proc,
string,
variable,
default   ) 

Value:

\
int variable = default;                         \
                                    \
int proc ()                                     \
{                                               \
   return (set_int_value (string, &variable)); \
}                                               \
Template procedures to set a floating point value of a variable.

Definition at line 98 of file debug.h.

#define make_float_const ( name,
default,
installer   ) 

Value:

\
float name = default;                        \
                                       \
void installer ()                                   \
{                                                   \
float_variable (name, #name, default);              \
}                                                   \
Create a constant with a config file reader

Definition at line 147 of file debug.h.

#define make_float_var ( name,
default,
installer,
menu,
menuitem,
menufunct,
menustring   ) 

Value:

\
float_value (menufunct, menustring, name, default); \
                                       \
void installer ()                                   \
{                                                   \
float_variable (name, #name, default);              \
make_menu_item (menu, menuitem, menustring, menufunct); \
}                                                   \
Create a variable with a config file reader and a menu handler.

Definition at line 214 of file debug.h.

#define make_int_const ( name,
default,
installer   ) 

Value:

\
int name = default;                          \
                                       \
void installer ()                                   \
{                                                   \
int_variable (name, #name, default);                \
}                                                   \
Create a constant with a config file reader

Definition at line 158 of file debug.h.

#define make_int_var ( name,
default,
installer,
menu,
menuitem,
menufunct,
menustring   ) 

Value:

\
int_value (menufunct, menustring, name, default);   \
                                       \
void installer ()                                   \
{                                                   \
int_variable (name, #name, default);                \
make_menu_item (menu, menuitem, menustring, menufunct); \
}                                                   \
Create a variable with a config file reader and a menu handler.

Definition at line 228 of file debug.h.

#define make_toggle_const ( name,
default,
installer   ) 

Value:

\
int name = default;                          \
                                       \
void installer ()                                   \
{                                                   \
int_variable (name, #name, default);                \
}                                                   \
Create a constant with a config file reader

Definition at line 169 of file debug.h.

#define make_toggle_var ( name,
default,
installer,
menu,
menuitem,
menufunct,
menustring   ) 

Value:

\
toggle_value (menufunct, menustring, name, default);\
                                       \
void installer ()                                   \
{                                                   \
int_variable (name, #name, default);                \
make_menu_item (menu, menuitem, menustring, menufunct); \
}                                                   \
Create a variable with a config file reader and a menu handler.

Definition at line 242 of file debug.h.

#define NUM_MENU_ITEMS   30

Definition at line 52 of file debug.h.

#define NUM_MENUS   30

Definition at line 51 of file debug.h.

#define toggle_value ( proc,
string,
variable,
default   ) 

Value:

\
int variable = default;                            \
                                    \
int proc ()                                        \
{                                                  \
   if (variable) {                                \
      cprintf( "%s is OFF\n", string);   \
      variable = 0;                              \
   }                                              \
   else {                                         \
      cprintf( "%s is ON\n", string);    \
      variable = 1;                              \
   }                                              \
   return (1);                                    \
}                                                  \

Definition at line 127 of file debug.h.


Function Documentation

void make_menu_item ( int  menu,
int  menu_item,
const char *  menu_string,
int_void  menu_funct 
)

Create an entry in the menu handler table that will create a menu entry; which, when selected, will invoke the requested function.

Definition at line 79 of file debug.cpp.

References MENU_ITEM::menu_function, MENU_ITEM::menu_string, and menu_table.

00082                                          {
00083   menu_table[menu][menu_item].menu_string = menu_string;
00084   menu_table[menu][menu_item].menu_function = (void_proc) menu_funct;
00085 }

int set_float_value ( const char *  message,
float *  variable 
)

Set the value of a floating point variable from the break handler.

Definition at line 38 of file debug.cpp.

References CHARS_PER_LINE, cprintf(), and NULL.

00038                                                           { 
00039   char this_string[CHARS_PER_LINE];
00040 
00041   cprintf ("%s (%7.5f) ? ", message, *variable);
00042   fflush(stdout); 
00043 
00044   if (fgets (this_string, CHARS_PER_LINE, stdin) == NULL)
00045     return (1);
00046 
00047   if (fgets (this_string, CHARS_PER_LINE, stdin) != NULL) {
00048     sscanf (this_string, "%f", variable);
00049     cprintf ("%s = %7.5f\n", message, *variable);
00050   }
00051   return (1);
00052 }

int set_int_value ( const char *  message,
int *  variable 
)

Set the value of a floating point variable from the break handler.

Definition at line 58 of file debug.cpp.

References CHARS_PER_LINE, cprintf(), and NULL.

00058                                                       { 
00059   char this_string[CHARS_PER_LINE];
00060 
00061   cprintf ("%s (%d) ? ", message, *variable);
00062   fflush(stdout); 
00063 
00064   if (fgets (this_string, CHARS_PER_LINE, stdin) == NULL)
00065     return (1);
00066 
00067   if (fgets (this_string, CHARS_PER_LINE, stdin) != NULL) {
00068     sscanf (this_string, "%d", variable);
00069     cprintf ("%s = %d\n", message, *variable);
00070   }
00071   return (1);
00072 }


Variable Documentation

MENU_ITEM menu_table[NUM_MENUS][NUM_MENU_ITEMS]

Note:
File: debug.cpp (Formerly debug.c)
Combinatorial Splitter
Author:
Mark Seaman, OCR Technology
Date:
Thu Jul 27 08:59:01 1989 Tue Feb 19 10:34:36 1991 (Mark Seaman) marks
 * (c) Copyright 1989, Hewlett-Packard Company.
 ** 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 30 of file debug.cpp.

Referenced by make_menu_item().


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