diff options
Diffstat (limited to 'source/compiler/aslfiles.c')
| -rw-r--r-- | source/compiler/aslfiles.c | 348 | 
1 files changed, 1 insertions, 347 deletions
| diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index f63504af4540..142b5a335c71 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -1,6 +1,6 @@  /******************************************************************************   * - * Module Name: aslfiles - file I/O suppoert + * Module Name: aslfiles - File support functions   *   *****************************************************************************/ @@ -64,352 +64,6 @@ FlParseInputPathname (  /*******************************************************************************   * - * FUNCTION:    AslAbort - * - * PARAMETERS:  None - * - * RETURN:      None - * - * DESCRIPTION: Dump the error log and abort the compiler. Used for serious - *              I/O errors - * - ******************************************************************************/ - -void -AslAbort ( -    void) -{ - -    AePrintErrorLog (ASL_FILE_STDERR); -    if (Gbl_DebugFlag) -    { -        /* Print error summary to stdout also */ - -        AePrintErrorLog (ASL_FILE_STDOUT); -    } - -    exit (1); -} - - -/******************************************************************************* - * - * FUNCTION:    FlFileError - * - * PARAMETERS:  FileId              - Index into file info array - *              ErrorId             - Index into error message array - * - * RETURN:      None - * - * DESCRIPTION: Decode errno to an error message and add the entire error - *              to the error log. - * - ******************************************************************************/ - -void -FlFileError ( -    UINT32                  FileId, -    UINT8                   ErrorId) -{ - -    sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, -        strerror (errno)); -    AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer); -} - - -/******************************************************************************* - * - * FUNCTION:    FlOpenFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Filename            - file pathname to open - *              Mode                - Open mode for fopen - * - * RETURN:      None - * - * DESCRIPTION: Open a file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlOpenFile ( -    UINT32                  FileId, -    char                    *Filename, -    char                    *Mode) -{ -    FILE                    *File; - - -    File = fopen (Filename, Mode); -    if (!File) -    { -        FlFileError (FileId, ASL_MSG_OPEN); -        AslAbort (); -    } - -    Gbl_Files[FileId].Filename = Filename; -    Gbl_Files[FileId].Handle   = File; -} - - -/******************************************************************************* - * - * FUNCTION:    FlGetFileSize - * - * PARAMETERS:  FileId              - Index into file info array - * - * RETURN:      File Size - * - * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open. - * - ******************************************************************************/ - -UINT32 -FlGetFileSize ( -    UINT32                  FileId) -{ -    FILE                    *fp; -    UINT32                  FileSize; -    long                    Offset; - - -    fp = Gbl_Files[FileId].Handle; -    Offset = ftell (fp); - -    fseek (fp, 0, SEEK_END); -    FileSize = (UINT32) ftell (fp); - -    /* Restore file pointer */ - -    fseek (fp, Offset, SEEK_SET); -    return (FileSize); -} - - -/******************************************************************************* - * - * FUNCTION:    FlReadFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Buffer              - Where to place the data - *              Length              - Amount to read - * - * RETURN:      Status. AE_ERROR indicates EOF. - * - * DESCRIPTION: Read data from an open file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -ACPI_STATUS -FlReadFile ( -    UINT32                  FileId, -    void                    *Buffer, -    UINT32                  Length) -{ -    UINT32                  Actual; - - -    /* Read and check for error */ - -    Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle); -    if (Actual < Length) -    { -        if (feof (Gbl_Files[FileId].Handle)) -        { -            /* End-of-file, just return error */ - -            return (AE_ERROR); -        } - -        FlFileError (FileId, ASL_MSG_READ); -        AslAbort (); -    } - -    return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION:    FlWriteFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Buffer              - Data to write - *              Length              - Amount of data to write - * - * RETURN:      None - * - * DESCRIPTION: Write data to an open file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlWriteFile ( -    UINT32                  FileId, -    void                    *Buffer, -    UINT32                  Length) -{ -    UINT32                  Actual; - - -    /* Write and check for error */ - -    Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle); -    if (Actual != Length) -    { -        FlFileError (FileId, ASL_MSG_WRITE); -        AslAbort (); -    } -} - - -/******************************************************************************* - * - * FUNCTION:    FlPrintFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Format              - Printf format string - *              ...                 - Printf arguments - * - * RETURN:      None - * - * DESCRIPTION: Formatted write to an open file. - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlPrintFile ( -    UINT32                  FileId, -    char                    *Format, -    ...) -{ -    INT32                   Actual; -    va_list                 Args; - - -    va_start (Args, Format); - -    Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args); -    va_end (Args); - -    if (Actual == -1) -    { -        FlFileError (FileId, ASL_MSG_WRITE); -        AslAbort (); -    } -} - - -/******************************************************************************* - * - * FUNCTION:    FlSeekFile - * - * PARAMETERS:  FileId              - Index into file info array - *              Offset              - Absolute byte offset in file - * - * RETURN:      None - * - * DESCRIPTION: Seek to absolute offset - *              NOTE: Aborts compiler on any error. - * - ******************************************************************************/ - -void -FlSeekFile ( -    UINT32                  FileId, -    long                    Offset) -{ -    int                     Error; - - -    Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET); -    if (Error) -    { -        FlFileError (FileId, ASL_MSG_SEEK); -        AslAbort (); -    } -} - - -/******************************************************************************* - * - * FUNCTION:    FlCloseFile - * - * PARAMETERS:  FileId              - Index into file info array - * - * RETURN:      None - * - * DESCRIPTION: Close an open file. Aborts compiler on error - * - ******************************************************************************/ - -void -FlCloseFile ( -    UINT32                  FileId) -{ -    int                     Error; - - -    if (!Gbl_Files[FileId].Handle) -    { -        return; -    } - -    Error = fclose (Gbl_Files[FileId].Handle); -    if (Error) -    { -        FlFileError (FileId, ASL_MSG_CLOSE); -        AslAbort (); -    } - -    Gbl_Files[FileId].Handle = NULL; -    return; -} - - -/******************************************************************************* - * - * FUNCTION:    FlDeleteFile - * - * PARAMETERS:  FileId              - Index into file info array - * - * RETURN:      None - * - * DESCRIPTION: Delete a file. - * - ******************************************************************************/ - -void -FlDeleteFile ( -    UINT32                  FileId) -{ -    ASL_FILE_INFO           *Info = &Gbl_Files[FileId]; - - -    if (!Info->Filename) -    { -        return; -    } - -    if (remove (Info->Filename)) -    { -        printf ("%s (%s file) ", -            Info->Filename, Info->Description); -        perror ("Could not delete"); -    } - -    Info->Filename = NULL; -    return; -} - - -/******************************************************************************* - *   * FUNCTION:    FlSetLineNumber   *   * PARAMETERS:  Op        - Parse node for the LINE asl statement | 
