tools/makedep.c
/*******************************************************************
 *         add_include
 *
 * Add an include file if it doesn't already exists.
 */
add_include
Add an include file if it doesn't already exists.
add_include Add an include file if it doesn ' t already exists .
static INCL_FILE *add_include( INCL_FILE *pFile, const char *name, int line, int system )
{
    INCL_FILE *include;
    char *ext;
    int pos;
    for (pos = 0; pos < MAX_INCLUDES; pos++) if (!pFile->files[pos]) break;
    if (pos >= MAX_INCLUDES)
        fatal_error( "%s: %s: error: too many included files, please fix MAX_INCLUDES\n",
                     ProgramName, pFile->name );
    if (!memcmp( name, "../", 3 ))
        fatal_error( "%s:%d: error: #include directive with relative path not allowed\n",
                     pFile->filename, line );
    if (!strcmp( name, "config.h" ))
    {
        if ((ext = strrchr( pFile->filename, '.' )) && !strcmp( ext, ".h" ))
            fatal_error( "%s:%d: error: config.h must not be included by a header file\n",
                         pFile->filename, line );
        if (pos)
            fatal_error( "%s:%d: error: config.h must be included before anything else\n",
                         pFile->filename, line );
    }
    else if (!strcmp( name, "wine/port.h" ))
    {
        if ((ext = strrchr( pFile->filename, '.' )) && !strcmp( ext, ".h" ))
            fatal_error( "%s:%d: error: wine/port.h must not be included by a header file\n",
                         pFile->filename, line );
        if (!pos) fatal_error( "%s:%d: error: config.h must be included before wine/port.h\n",
                               pFile->filename, line );
        if (pos > 1)
            fatal_error( "%s:%d: error: wine/port.h must be included before everything except config.h\n",
                         pFile->filename, line );
        if (strcmp( pFile->files[0]->name, "config.h" ))
            fatal_error( "%s:%d: error: config.h must be included before wine/port.h\n",
                         pFile->filename, line );
    }
    LIST_FOR_EACH_ENTRY( include, &includes, INCL_FILE, entry )
        if (!strcmp( name, include->name )) goto found;
    include = xmalloc( sizeof(INCL_FILE) );
    memset( include, 0, sizeof(INCL_FILE) );
    include->name = xstrdup(name);
    include->included_by = pFile;
    include->included_line = line;
    include->system = system;
    list_add_tail( &includes, &include->entry );
found:
    pFile->files[pos] = include;
    return include;
}
static INCL_FILE * add_include ( INCL_FILE * pFile , const char * name , int line , int system ) { INCL_FILE * include ; char * ext ; int pos ; for ( pos = 0 ; pos < MAX_INCLUDES ; pos ++ ) if ( ! pFile -> files [ pos ] ) break ; if ( pos >= MAX_INCLUDES ) fatal_error ( " \n " , ProgramName , pFile -> name ) ; if ( ! memcmp ( name , " " , 3 ) ) fatal_error ( " \n " , pFile -> filename , line ) ; if ( ! strcmp ( name , " " ) ) { if ( ( ext = strrchr ( pFile -> filename , ' ' ) ) && ! strcmp ( ext , " " ) ) fatal_error ( " \n " , pFile -> filename , line ) ; if ( pos ) fatal_error ( " \n " , pFile -> filename , line ) ; } else if ( ! strcmp ( name , " " ) ) { if ( ( ext = strrchr ( pFile -> filename , ' ' ) ) && ! strcmp ( ext , " " ) ) fatal_error ( " \n " , pFile -> filename , line ) ; if ( ! pos ) fatal_error ( " \n " , pFile -> filename , line ) ; if ( pos > 1 ) fatal_error ( " \n " , pFile -> filename , line ) ; if ( strcmp ( pFile -> files [ 0 ] -> name , " " ) ) fatal_error ( " \n " , pFile -> filename , line ) ; } LIST_FOR_EACH_ENTRY ( include , & includes , INCL_FILE , entry ) if ( ! strcmp ( name , include -> name ) ) goto found ; include = xmalloc ( sizeof ( INCL_FILE ) ) ; memset ( include , 0 , sizeof ( INCL_FILE ) ) ; include -> name = xstrdup ( name ) ; include -> included_by = pFile ; include -> included_line = line ; include -> system = system ; list_add_tail ( & includes , & include -> entry ) ; found : pFile -> files [ pos ] = include ; return include ; }
add_include
 Add an include file if it doesn't already exists.
add_include Add an include file if it doesn ' t already exists .
/* enforce some rules for the Wine tree */