#include "vars.h" #define NULL 0 extern int debug; DefineVar( pch_varname , pch_value ) char *pch_varname, *pch_value; { int pos; pos = _Lookup( pch_varname ); if( debug ) printf( "Found var '%s' at position %d, defining as %s\n", pch_varname,pos, pch_value ); if( NULL != avr_Vars[ pos ].string) printf("Redefining %s\n", pch_varname ); avr_Vars[pos].string = pch_value; } char * VarLookup( pch_varname ) char *pch_varname; { int pos; pos = _Lookup( pch_varname ); if( debug ) printf("found '%s' at position %d, value is %s\n", pch_varname, pos, avr_Vars[pos].string ); return avr_Vars[pos].string; } static int _Lookup( pch_varname ) char *pch_varname; { int pos; avr_Vars[n_Vars].pch_name = pch_varname; avr_Vars[n_Vars].string = NULL; pos = 0; while( strcmp(pch_varname, avr_Vars[pos].pch_name )) pos++; if( pos == n_Vars ) n_Vars++; return pos; } int n_Vars = 0; struct var avr_Vars[ MAXVARS ];