| 1 | /*************************************************************************** |
| 2 | |
| 3 | TITLE: ls_sym.h |
| 4 | |
| 5 | ---------------------------------------------------------------------------- |
| 6 | |
| 7 | FUNCTION: Header file for symbol table routines |
| 8 | |
| 9 | ---------------------------------------------------------------------------- |
| 10 | |
| 11 | MODULE STATUS: production |
| 12 | |
| 13 | ---------------------------------------------------------------------------- |
| 14 | |
| 15 | GENEALOGY: Created 930629 by E. B. Jackson |
| 16 | |
| 17 | ---------------------------------------------------------------------------- |
| 18 | |
| 19 | DESIGNED BY: Bruce Jackson |
| 20 | |
| 21 | CODED BY: same |
| 22 | |
| 23 | MAINTAINED BY: |
| 24 | |
| 25 | ---------------------------------------------------------------------------- |
| 26 | |
| 27 | MODIFICATION HISTORY: |
| 28 | |
| 29 | DATE PURPOSE BY |
| 30 | |
| 31 | 950227 Added header and declarations for ls_print_findsym_error(), |
| 32 | ls_get_double(), and ls_get_double() routines. EBJ |
| 33 | |
| 34 | 950302 Added structure for symbol description. EBJ |
| 35 | |
| 36 | 950306 Added ls_get_sym_val() and ls_set_sym_val() routines. |
| 37 | This is now the production version. EBJ |
| 38 | |
| 39 | CURRENT RCS HEADER: |
| 40 | |
| 41 | $Header$ |
| 42 | $Log$ |
| 43 | Revision 1.1 2002/09/10 01:14:02 curt |
| 44 | Initial revision |
| 45 | |
| 46 | Revision 1.1.1.1 1999/06/17 18:07:33 curt |
| 47 | Start of 0.7.x branch |
| 48 | |
| 49 | Revision 1.1.1.1 1999/04/05 21:32:45 curt |
| 50 | Start of 0.6.x branch. |
| 51 | |
| 52 | Revision 1.3 1998/08/06 12:46:40 curt |
| 53 | Header change. |
| 54 | |
| 55 | Revision 1.2 1998/01/22 02:59:34 curt |
| 56 | Changed #ifdef FILE_H to #ifdef _FILE_H |
| 57 | |
| 58 | Revision 1.1 1997/05/29 00:10:00 curt |
| 59 | Initial Flight Gear revision. |
| 60 | |
| 61 | * Revision 1.9 1995/03/07 12:52:33 bjax |
| 62 | * This production version now specified ls_get_sym_val() and ls_put_sym_val(). |
| 63 | * |
| 64 | * Revision 1.6.1.2 1995/03/06 18:45:41 bjax |
| 65 | * Added def'n of ls_get_sym_val() and ls_set_sym_val(); changed symbol_rec |
| 66 | * Addr field from void * to char *. |
| 67 | * EBJ |
| 68 | * |
| 69 | * Revision 1.6.1.1 1995/03/03 01:17:44 bjax |
| 70 | * Experimental version with just ls_get_double and ls_set_double() routines. |
| 71 | * |
| 72 | * Revision 1.6 1995/02/27 19:50:49 bjax |
| 73 | * Added header and declarations for ls_print_findsym_error(), |
| 74 | * ls_get_double(), and ls_set_double(). EBJ |
| 75 | * |
| 76 | |
| 77 | ---------------------------------------------------------------------------- |
| 78 | |
| 79 | REFERENCES: |
| 80 | |
| 81 | ---------------------------------------------------------------------------- |
| 82 | |
| 83 | CALLED BY: |
| 84 | |
| 85 | ---------------------------------------------------------------------------- |
| 86 | |
| 87 | CALLS TO: |
| 88 | |
| 89 | ---------------------------------------------------------------------------- |
| 90 | |
| 91 | INPUTS: |
| 92 | |
| 93 | ---------------------------------------------------------------------------- |
| 94 | |
| 95 | OUTPUTS: |
| 96 | |
| 97 | --------------------------------------------------------------------------*/ |
| 98 | |
| 99 | #ifndef _LS_SYM_H |
| 100 | #define _LS_SYM_H |
| 101 | |
| 102 | |
| 103 | /* Return codes */ |
| 104 | |
| 105 | #define SYM_NOT_LOADED -2 |
| 106 | #define SYM_UNEXPECTED_ERR -1 |
| 107 | #define SYM_OK 0 |
| 108 | #define SYM_OPEN_ERR 1 |
| 109 | #define SYM_NO_SYMS 2 |
| 110 | #define SYM_MOD_NOT_FOUND 3 |
| 111 | #define SYM_VAR_NOT_FOUND 4 |
| 112 | #define SYM_NOT_SCALAR 5 |
| 113 | #define SYM_NOT_STATIC 6 |
| 114 | #define SYM_MEMORY_ERR 7 |
| 115 | #define SYM_UNMATCHED_PAREN 8 |
| 116 | #define SYM_BAD_SYNTAX 9 |
| 117 | #define SYM_INDEX_BOUNDS_ERR 10 |
| 118 | |
| 119 | typedef enum {Unknown, Char, UChar, SHint, USHint, Sint, Uint, Slng, Ulng, flt, dbl} vartype; |
| 120 | |
| 121 | typedef char SYMBOL_NAME[64]; |
| 122 | typedef vartype SYMBOL_TYPE; |
| 123 | |
| 124 | |
| 125 | |
| 126 | typedef struct |
| 127 | { |
| 128 | SYMBOL_NAME Mod_Name; |
| 129 | SYMBOL_NAME Par_Name; |
| 130 | SYMBOL_TYPE Par_Type; |
| 131 | SYMBOL_NAME Alias; |
| 132 | char *Addr; |
| 133 | } symbol_rec; |
| 134 | |
| 135 | |
| 136 | extern int ls_findsym( const char *modname, const char *varname, |
| 137 | char **addr, vartype *vtype ); |
| 138 | |
| 139 | extern void ls_print_findsym_error(int result, |
| 140 | char *mod_name, |
| 141 | char *var_name); |
| 142 | |
| 143 | extern double ls_get_double(vartype sym_type, void *addr ); |
| 144 | |
| 145 | extern void ls_set_double(vartype sym_type, void *addr, double value ); |
| 146 | |
| 147 | extern double ls_get_sym_val( symbol_rec *symrec, int *error ); |
| 148 | |
| 149 | /* This routine attempts to return the present value of the symbol |
| 150 | described in symbol_rec. If Addr is non-zero, the value of that |
| 151 | location, interpreted as type double, will be returned. If Addr |
| 152 | is zero, and Mod_Name and Par_Name are both not null strings, |
| 153 | the ls_findsym() routine is used to try to obtain the address |
| 154 | by looking at debugger symbol tables in the executable image, and |
| 155 | the value of the double contained at that address is returned, |
| 156 | and the symbol record is updated to contain the address of that |
| 157 | symbol. If an error is discovered, 'error' will be non-zero and |
| 158 | and error message is printed on stderr. */ |
| 159 | |
| 160 | extern void ls_set_sym_val( symbol_rec *symrec, double value ); |
| 161 | |
| 162 | /* This routine sets the value of a double at the location pointed |
| 163 | to by the symbol_rec's Addr field, if Addr is non-zero. If Addr |
| 164 | is zero, and Mod_Name and Par_Name are both not null strings, |
| 165 | the ls_findsym() routine is used to try to obtain the address |
| 166 | by looking at debugger symbol tables in the executable image, and |
| 167 | the value of the double contained at that address is returned, |
| 168 | and the symbol record is updated to contain the address of that |
| 169 | symbol. If an error is discovered, 'error' will be non-zero and |
| 170 | and error message is printed on stderr. */ |
| 171 | |
| 172 | |
| 173 | #endif /* _LS_SYM_H */ |
| 174 | |
| 175 |