FreeBSD/sys/contrib/dev/acpica/compiler/aslfiles.c
/*******************************************************************************
 *
 * FUNCTION:    FlOpenIncludeWithPrefix
 *
 * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be a zero
 *                                length string.
 *              Filename        - The include filename from the source ASL.
 *
 * RETURN:      Valid file descriptor if successful. Null otherwise.
 *
 * DESCRIPTION: Open an include file and push it on the input file stack.
 *
 ******************************************************************************/
FlOpenIncludeWithPrefix
PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be a zero
length string.
Filename        - The include filename from the source ASL.

Valid file descriptor if successful. Null otherwise.

Open an include file and push it on the input file stack.
FlOpenIncludeWithPrefix PARAMETERS : PrefixDir - Prefix directory pathname . Can be a zero length string . Filename - The include filename from the source ASL . Valid file descriptor if successful . Null otherwise . Open an include file and push it on the input file stack .
static FILE *
FlOpenIncludeWithPrefix (
    char                    *PrefixDir,
    ACPI_PARSE_OBJECT       *Op,
    char                    *Filename)
{
    FILE                    *IncludeFile;
    char                    *Pathname;
    UINT32                  OriginalLineNumber;
    Pathname = FlMergePathnames (PrefixDir, Filename);
    DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
        Pathname);
    IncludeFile = fopen (Pathname, "r");
    if (!IncludeFile)
    {
        fprintf (stderr, "Could not open include file %s\n", Pathname);
        ACPI_FREE (Pathname);
        return (NULL);
    }
    Gbl_CurrentLineNumber--;
    OriginalLineNumber = Gbl_CurrentLineNumber;
    while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
    {
        if (Gbl_CurrentLineBuffer[0] == '#')
        {
            AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE,
                Op, "use #include instead");
        }
    }
    Gbl_CurrentLineNumber = OriginalLineNumber;
    fseek (IncludeFile, 0, SEEK_SET);
    AslPushInputFileStack (IncludeFile, Pathname);
    return (IncludeFile);
}
static FILE * FlOpenIncludeWithPrefix ( char * PrefixDir , ACPI_PARSE_OBJECT * Op , char * Filename ) { FILE * IncludeFile ; char * Pathname ; UINT32 OriginalLineNumber ; Pathname = FlMergePathnames ( PrefixDir , Filename ) ; DbgPrint ( ASL_PARSE_OUTPUT , " \" \" \n \n " , Pathname ) ; IncludeFile = fopen ( Pathname , " " ) ; if ( ! IncludeFile ) { fprintf ( stderr , " \n " , Pathname ) ; ACPI_FREE ( Pathname ) ; return ( NULL ) ; } Gbl_CurrentLineNumber -- ; OriginalLineNumber = Gbl_CurrentLineNumber ; while ( DtGetNextLine ( IncludeFile , DT_ALLOW_MULTILINE_QUOTES ) != ASL_EOF ) { if ( Gbl_CurrentLineBuffer [ 0 ] == ' ' ) { AslError ( ASL_ERROR , ASL_MSG_INCLUDE_FILE , Op , " " ) ; } } Gbl_CurrentLineNumber = OriginalLineNumber ; fseek ( IncludeFile , 0 , SEEK_SET ) ; AslPushInputFileStack ( IncludeFile , Pathname ) ; return ( IncludeFile ) ; }
FUNCTION:    FlOpenIncludeWithPrefix
 PARAMETERS:  PrefixDir       - Prefix directory pathname.
FUNCTION : FlOpenIncludeWithPrefix PARAMETERS : PrefixDir - Prefix directory pathname .
/* Build the full pathname to the file */ /* Attempt to open the file, push if successful */ /*
     * Check the entire include file for any # preprocessor directives.
     * This is because there may be some confusion between the #include
     * preprocessor directive and the ASL Include statement. A file included
     * by the ASL include cannot contain preprocessor directives because
     * the preprocessor has already run by the time the ASL include is
     * recognized (by the compiler, not the preprocessor.)
     *
     * Note: DtGetNextLine strips/ignores comments.
     * Save current line number since DtGetNextLine modifies it.
     */ /* Must seek back to the start of the file */ /* Push the include file on the open input file stack */