cutil/variables.h

Go to the documentation of this file.
00001 
00020 #ifndef VARIABLES_H
00021 #define VARIABLES_H
00022 
00023 #include "cutil.h"
00024 #include "oldlist.h"
00025 
00026 /*----------------------------------------------------------------------
00027               T y p e s
00028 ----------------------------------------------------------------------*/
00033 typedef union
00034 {
00035   float float_part;
00036   int int_part;
00037   void *ptr_part;
00038   const char *char_part;
00039 } VALUE;
00040 
00041 class VARIABLE;
00042 
00043 typedef void (*variables_io) (VARIABLE * variable, char *string);
00044 
00050 class VARIABLE
00051 {
00052   public:
00053     void *address;
00054     const char *string;
00055     VALUE default_value;
00056     variables_io type_reader;
00057     variables_io type_writer;
00058 };
00059 
00061 extern VALUE dummy;
00062 
00063 /*----------------------------------------------------------------------
00064               M a c r o s
00065 ----------------------------------------------------------------------*/
00066 /*    To hide variable names for relase to UNLV DONT put the variable names in
00067   the executable: Toggle be either defining or not defining SECURE_NAMES*/
00068 /* #define SECURE_NAMES defined in secnames.h when necessary */
00069 #ifdef SECURE_NAMES
00070 
00074 /*
00075 #define float_variable(name,string,default)                \
00076 dummy.float_part = default;                              \
00077 add_32bit_variable (&name, "", dummy, float_read, float_write)
00078 */
00079 
00084 /*
00085 #define string_variable(name,string,default)              \
00086 dummy.char_part = default;                    \
00087 add_ptr_variable (&name, "", dummy, string_read, string_write)
00088 */
00089 
00094 /*
00095 #define int_variable(name,string,default)                 \
00096 dummy.int_part = default;                              \
00097 add_32bit_variable (&name, "", dummy, int_read, int_write)
00098 */
00099 
00100 #else // SECURE_NAMES
00101 
00106 #define float_variable(name,string,default)                \
00107 dummy.float_part = default;                              \
00108 add_32bit_variable (&name, string, dummy, float_read, float_write)
00109 
00114 #define string_variable(name,string,default)              \
00115 dummy.char_part = default;                    \
00116 add_ptr_variable (&name, string, dummy, string_read, string_write)
00117 
00122 #define int_variable(name,string,default)                 \
00123 dummy.int_part = default;                              \
00124 add_32bit_variable (&name, string, dummy, int_read, int_write)
00125 #endif // SECURE_NAMES
00126 
00127 /*--------------------------------------------------------------------------
00128         Public Function Prototoypes
00129 ----------------------------------------------------------------------------*/
00130 void free_variables();
00131 
00132 void add_ptr_variable(void *address,
00133                       const char *string,
00134                       VALUE default_value,
00135                       variables_io reader,
00136                       variables_io writer);
00137 
00138 void add_32bit_variable(void *address,
00139                   const char *string,
00140                   VALUE default_value,
00141                   variables_io reader,
00142                   variables_io writer);
00143 
00144 void float_read(VARIABLE *variable, char *string); 
00145 
00146 void float_write(VARIABLE *variable, char *string); 
00147 
00148 void int_read(VARIABLE *variable, char *string); 
00149 
00150 void int_write(VARIABLE *variable, char *string); 
00151 
00152 void read_variables(const char *filename); 
00153 
00154 int same_var_name(void *item1,   //VARIABLE *variable,
00155                   void *item2);  //char     *string)
00156 
00157 void string_read(VARIABLE *variable, char *string); 
00158 
00159 void string_write(VARIABLE *variable, char *string); 
00160 
00161 char *strip_line(char *string); 
00162 #endif

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