The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

hdrmacro.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Functions

char * macro_header_get (const char *macro_name)
void macro_headers (TARGET *t)


Function Documentation

char* macro_header_get const char *  macro_name  ) 
 

Definition at line 127 of file hdrmacro.c.

References hashcheck, HASHDATA, HEADER_MACRO, header_macros_hash, header_macro::symbol, and v.

Referenced by headers1().

00128 {
00129   HEADER_MACRO  var, *v = &var;
00130 
00131   v->symbol = (char*)macro_name;
00132 
00133   if( header_macros_hash && hashcheck( header_macros_hash, (HASHDATA **)&v ) )
00134   {
00135     if ( DEBUG_HEADER )
00136       printf( "### macro '%s' evaluated to '%s'\n", macro_name, v->filename );
00137     return v->filename;
00138   }
00139   return 0;  
00140 }

void macro_headers TARGET t  ) 
 

Definition at line 70 of file hdrmacro.c.

References _target::boundname, regexp::endp, f(), fclose(), header_macro::filename, HASHDATA, hashenter, hashinit(), HEADER_MACRO, header_macros_hash, _target::name, newstr(), regex_compile(), regexec(), regexp::startp, header_macro::symbol, TARGET, and v.

Referenced by builtin_hdrmacro().

00071 {
00072     static regexp *re = 0;
00073     FILE        *f;
00074     char        buf[ 1024 ];
00075     
00076     if ( DEBUG_HEADER )
00077         printf( "macro header scan for %s\n", t->name );
00078 
00079     /* this regexp is used to detect lines of the form       */
00080     /* "#define  MACRO  <....>" or "#define  MACRO  "....."  */
00081     /* in the header macro files..                           */
00082     if ( re == 0 )
00083     {
00084         re = regex_compile(
00085             "^[         ]*#[    ]*define[       ]*([A-Za-z][A-Za-z0-9_]*)[      ]*"
00086             "[<\"]([^\">]*)[\">].*$" );
00087     }
00088     
00089     if( !( f = fopen( t->boundname, "r" ) ) )
00090         return;
00091 
00092     while( fgets( buf, sizeof( buf ), f ) )
00093     {
00094         HEADER_MACRO  var, *v = &var;
00095 
00096         if ( regexec( re, buf ) && re->startp[1] )
00097         {
00098             /* we detected a line that looks like "#define  MACRO  filename */
00099             re->endp[1][0] = '\0';
00100             re->endp[2][0] = '\0';
00101         
00102             if ( DEBUG_HEADER )
00103                 printf( "macro '%s' used to define filename '%s' in '%s'\n",
00104                         re->startp[1], re->startp[2], t->boundname );
00105 
00106             /* add macro definition to hash table */
00107             if ( !header_macros_hash )
00108                 header_macros_hash = hashinit( sizeof( HEADER_MACRO ), "hdrmacros" );
00109 
00110             v->symbol   = re->startp[1];
00111             v->filename = 0;
00112             if ( hashenter( header_macros_hash, (HASHDATA **)&v ) )
00113             {
00114                 v->symbol   = newstr( re->startp[1] );  /* never freed */
00115                 v->filename = newstr( re->startp[2] );  /* never freed */
00116             }
00117             /* XXXX: FOR NOW, WE IGNORE MULTIPLE MACRO DEFINITIONS !! */
00118             /*       WE MIGHT AS WELL USE A LIST TO STORE THEM..      */
00119         }
00120     }
00121 
00122     fclose( f );
00123 }

Here is the call graph for this function:


Generated on Mon Nov 8 17:08:01 2004 for MPT by  doxygen 1.3.9.1