Home | History | Annotate | Line # | Download | only in compiler
aslfiles.c revision 1.1.1.4
      1 /******************************************************************************
      2  *
      3  * Module Name: aslfiles - File support functions
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2014, Intel Corp.
      9  * All rights reserved.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions, and the following disclaimer,
     16  *    without modification.
     17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  *    including a substantially similar Disclaimer requirement for further
     21  *    binary redistribution.
     22  * 3. Neither the names of the above-listed copyright holders nor the names
     23  *    of any contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * Alternatively, this software may be distributed under the terms of the
     27  * GNU General Public License ("GPL") version 2 as published by the Free
     28  * Software Foundation.
     29  *
     30  * NO WARRANTY
     31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  * POSSIBILITY OF SUCH DAMAGES.
     42  */
     43 
     44 #include "aslcompiler.h"
     45 #include "acapps.h"
     46 
     47 #define _COMPONENT          ACPI_COMPILER
     48         ACPI_MODULE_NAME    ("aslfiles")
     49 
     50 /* Local prototypes */
     51 
     52 FILE *
     53 FlOpenIncludeWithPrefix (
     54     char                    *PrefixDir,
     55     char                    *Filename);
     56 
     57 
     58 #ifdef ACPI_OBSOLETE_FUNCTIONS
     59 ACPI_STATUS
     60 FlParseInputPathname (
     61     char                    *InputFilename);
     62 #endif
     63 
     64 
     65 /*******************************************************************************
     66  *
     67  * FUNCTION:    FlSetLineNumber
     68  *
     69  * PARAMETERS:  Op        - Parse node for the LINE asl statement
     70  *
     71  * RETURN:      None.
     72  *
     73  * DESCRIPTION: Set the current line number
     74  *
     75  ******************************************************************************/
     76 
     77 void
     78 FlSetLineNumber (
     79     UINT32                  LineNumber)
     80 {
     81 
     82     DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n",
     83          LineNumber, Gbl_LogicalLineNumber);
     84 
     85     Gbl_CurrentLineNumber = LineNumber;
     86     Gbl_LogicalLineNumber = LineNumber;
     87 }
     88 
     89 
     90 /*******************************************************************************
     91  *
     92  * FUNCTION:    FlSetFilename
     93  *
     94  * PARAMETERS:  Op        - Parse node for the LINE asl statement
     95  *
     96  * RETURN:      None.
     97  *
     98  * DESCRIPTION: Set the current filename
     99  *
    100  ******************************************************************************/
    101 
    102 void
    103 FlSetFilename (
    104     char                    *Filename)
    105 {
    106 
    107     DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n",
    108          Filename, Gbl_Files[ASL_FILE_INPUT].Filename);
    109 
    110     /* No need to free any existing filename */
    111 
    112     Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
    113 }
    114 
    115 
    116 /*******************************************************************************
    117  *
    118  * FUNCTION:    FlAddIncludeDirectory
    119  *
    120  * PARAMETERS:  Dir             - Directory pathname string
    121  *
    122  * RETURN:      None
    123  *
    124  * DESCRIPTION: Add a directory the list of include prefix directories.
    125  *
    126  ******************************************************************************/
    127 
    128 void
    129 FlAddIncludeDirectory (
    130     char                    *Dir)
    131 {
    132     ASL_INCLUDE_DIR         *NewDir;
    133     ASL_INCLUDE_DIR         *NextDir;
    134     ASL_INCLUDE_DIR         *PrevDir = NULL;
    135     UINT32                  NeedsSeparator = 0;
    136     size_t                  DirLength;
    137 
    138 
    139     DirLength = strlen (Dir);
    140     if (!DirLength)
    141     {
    142         return;
    143     }
    144 
    145     /* Make sure that the pathname ends with a path separator */
    146 
    147     if ((Dir[DirLength-1] != '/') &&
    148         (Dir[DirLength-1] != '\\'))
    149     {
    150         NeedsSeparator = 1;
    151     }
    152 
    153     NewDir = ACPI_ALLOCATE_ZEROED (sizeof (ASL_INCLUDE_DIR));
    154     NewDir->Dir = ACPI_ALLOCATE (DirLength + 1 + NeedsSeparator);
    155     strcpy (NewDir->Dir, Dir);
    156     if (NeedsSeparator)
    157     {
    158         strcat (NewDir->Dir, "/");
    159     }
    160 
    161     /*
    162      * Preserve command line ordering of -I options by adding new elements
    163      * at the end of the list
    164      */
    165     NextDir = Gbl_IncludeDirList;
    166     while (NextDir)
    167     {
    168         PrevDir = NextDir;
    169         NextDir = NextDir->Next;
    170     }
    171 
    172     if (PrevDir)
    173     {
    174         PrevDir->Next = NewDir;
    175     }
    176     else
    177     {
    178         Gbl_IncludeDirList = NewDir;
    179     }
    180 }
    181 
    182 
    183 /*******************************************************************************
    184  *
    185  * FUNCTION:    FlMergePathnames
    186  *
    187  * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be NULL or
    188  *                                a zero length string.
    189  *              FilePathname    - The include filename from the source ASL.
    190  *
    191  * RETURN:      Merged pathname string
    192  *
    193  * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
    194  *              arrive at a minimal length string. Merge can occur if the
    195  *              FilePathname is relative to the PrefixDir.
    196  *
    197  ******************************************************************************/
    198 
    199 char *
    200 FlMergePathnames (
    201     char                    *PrefixDir,
    202     char                    *FilePathname)
    203 {
    204     char                    *CommonPath;
    205     char                    *Pathname;
    206     char                    *LastElement;
    207 
    208 
    209     DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
    210         "Include: FilePathname - \"%s\"\n",
    211          PrefixDir, FilePathname);
    212 
    213     /*
    214      * If there is no prefix directory or if the file pathname is absolute,
    215      * just return the original file pathname
    216      */
    217     if (!PrefixDir || (!*PrefixDir) ||
    218         (*FilePathname == '/') ||
    219          (FilePathname[1] == ':'))
    220     {
    221         Pathname = UtStringCacheCalloc (strlen (FilePathname) + 1);
    222         strcpy (Pathname, FilePathname);
    223         goto ConvertBackslashes;
    224     }
    225 
    226     /* Need a local copy of the prefix directory path */
    227 
    228     CommonPath = UtStringCacheCalloc (strlen (PrefixDir) + 1);
    229     strcpy (CommonPath, PrefixDir);
    230 
    231     /*
    232      * Walk forward through the file path, and simultaneously backward
    233      * through the prefix directory path until there are no more
    234      * relative references at the start of the file path.
    235      */
    236     while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
    237     {
    238         /* Remove last element of the prefix directory path */
    239 
    240         LastElement = strrchr (CommonPath, '/');
    241         if (!LastElement)
    242         {
    243             goto ConcatenatePaths;
    244         }
    245 
    246         *LastElement = 0;   /* Terminate CommonPath string */
    247         FilePathname += 3;  /* Point to next path element */
    248     }
    249 
    250     /*
    251      * Remove the last element of the prefix directory path (it is the same as
    252      * the first element of the file pathname), and build the final merged
    253      * pathname.
    254      */
    255     LastElement = strrchr (CommonPath, '/');
    256     if (LastElement)
    257     {
    258         *LastElement = 0;
    259     }
    260 
    261     /* Build the final merged pathname */
    262 
    263 ConcatenatePaths:
    264     Pathname = UtStringCacheCalloc (strlen (CommonPath) + strlen (FilePathname) + 2);
    265     if (LastElement && *CommonPath)
    266     {
    267         strcpy (Pathname, CommonPath);
    268         strcat (Pathname, "/");
    269     }
    270     strcat (Pathname, FilePathname);
    271 
    272     /* Convert all backslashes to normal slashes */
    273 
    274 ConvertBackslashes:
    275     UtConvertBackslashes (Pathname);
    276 
    277     DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
    278          Pathname);
    279     return (Pathname);
    280 }
    281 
    282 
    283 /*******************************************************************************
    284  *
    285  * FUNCTION:    FlOpenIncludeWithPrefix
    286  *
    287  * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be a zero
    288  *                                length string.
    289  *              Filename        - The include filename from the source ASL.
    290  *
    291  * RETURN:      Valid file descriptor if successful. Null otherwise.
    292  *
    293  * DESCRIPTION: Open an include file and push it on the input file stack.
    294  *
    295  ******************************************************************************/
    296 
    297 FILE *
    298 FlOpenIncludeWithPrefix (
    299     char                    *PrefixDir,
    300     char                    *Filename)
    301 {
    302     FILE                    *IncludeFile;
    303     char                    *Pathname;
    304 
    305 
    306     /* Build the full pathname to the file */
    307 
    308     Pathname = FlMergePathnames (PrefixDir, Filename);
    309 
    310     DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
    311         Pathname);
    312 
    313     /* Attempt to open the file, push if successful */
    314 
    315     IncludeFile = fopen (Pathname, "r");
    316     if (!IncludeFile)
    317     {
    318         fprintf (stderr, "Could not open include file %s\n", Pathname);
    319         ACPI_FREE (Pathname);
    320         return (NULL);
    321     }
    322 
    323     /* Push the include file on the open input file stack */
    324 
    325     AslPushInputFileStack (IncludeFile, Pathname);
    326     return (IncludeFile);
    327 }
    328 
    329 
    330 /*******************************************************************************
    331  *
    332  * FUNCTION:    FlOpenIncludeFile
    333  *
    334  * PARAMETERS:  Op        - Parse node for the INCLUDE ASL statement
    335  *
    336  * RETURN:      None.
    337  *
    338  * DESCRIPTION: Open an include file and push it on the input file stack.
    339  *
    340  ******************************************************************************/
    341 
    342 void
    343 FlOpenIncludeFile (
    344     ACPI_PARSE_OBJECT       *Op)
    345 {
    346     FILE                    *IncludeFile;
    347     ASL_INCLUDE_DIR         *NextDir;
    348 
    349 
    350     /* Op must be valid */
    351 
    352     if (!Op)
    353     {
    354         AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
    355             Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
    356             Gbl_InputByteCount, Gbl_CurrentColumn,
    357             Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
    358 
    359         return;
    360     }
    361 
    362     /*
    363      * Flush out the "include ()" statement on this line, start
    364      * the actual include file on the next line
    365      */
    366     AslResetCurrentLineBuffer ();
    367     FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
    368     Gbl_CurrentLineOffset++;
    369 
    370 
    371     /* Attempt to open the include file */
    372 
    373     /* If the file specifies an absolute path, just open it */
    374 
    375     if ((Op->Asl.Value.String[0] == '/')  ||
    376         (Op->Asl.Value.String[0] == '\\') ||
    377         (Op->Asl.Value.String[1] == ':'))
    378     {
    379         IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String);
    380         if (!IncludeFile)
    381         {
    382             goto ErrorExit;
    383         }
    384         return;
    385     }
    386 
    387     /*
    388      * The include filename is not an absolute path.
    389      *
    390      * First, search for the file within the "local" directory -- meaning
    391      * the same directory that contains the source file.
    392      *
    393      * Construct the file pathname from the global directory name.
    394      */
    395     IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String);
    396     if (IncludeFile)
    397     {
    398         return;
    399     }
    400 
    401     /*
    402      * Second, search for the file within the (possibly multiple) directories
    403      * specified by the -I option on the command line.
    404      */
    405     NextDir = Gbl_IncludeDirList;
    406     while (NextDir)
    407     {
    408         IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String);
    409         if (IncludeFile)
    410         {
    411             return;
    412         }
    413 
    414         NextDir = NextDir->Next;
    415     }
    416 
    417     /* We could not open the include file after trying very hard */
    418 
    419 ErrorExit:
    420     sprintf (MsgBuffer, "%s, %s", Op->Asl.Value.String, strerror (errno));
    421     AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
    422 }
    423 
    424 
    425 /*******************************************************************************
    426  *
    427  * FUNCTION:    FlOpenInputFile
    428  *
    429  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
    430  *                                    compiled
    431  *
    432  * RETURN:      Status
    433  *
    434  * DESCRIPTION: Open the specified input file, and save the directory path to
    435  *              the file so that include files can be opened in
    436  *              the same directory.
    437  *
    438  ******************************************************************************/
    439 
    440 ACPI_STATUS
    441 FlOpenInputFile (
    442     char                    *InputFilename)
    443 {
    444 
    445     /* Open the input ASL file, text mode */
    446 
    447     FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt");
    448     AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
    449 
    450     return (AE_OK);
    451 }
    452 
    453 
    454 /*******************************************************************************
    455  *
    456  * FUNCTION:    FlOpenAmlOutputFile
    457  *
    458  * PARAMETERS:  FilenamePrefix       - The user-specified ASL source file
    459  *
    460  * RETURN:      Status
    461  *
    462  * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
    463  *              is created in the same directory as the parent input file.
    464  *
    465  ******************************************************************************/
    466 
    467 ACPI_STATUS
    468 FlOpenAmlOutputFile (
    469     char                    *FilenamePrefix)
    470 {
    471     char                    *Filename;
    472 
    473 
    474     /* Output filename usually comes from the ASL itself */
    475 
    476     Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
    477     if (!Filename)
    478     {
    479         /* Create the output AML filename */
    480 
    481         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
    482         if (!Filename)
    483         {
    484             AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
    485                 0, 0, 0, 0, NULL, NULL);
    486             return (AE_ERROR);
    487         }
    488     }
    489 
    490     /* Open the output AML file in binary mode */
    491 
    492     FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
    493     return (AE_OK);
    494 }
    495 
    496 
    497 /*******************************************************************************
    498  *
    499  * FUNCTION:    FlOpenMiscOutputFiles
    500  *
    501  * PARAMETERS:  FilenamePrefix       - The user-specified ASL source file
    502  *
    503  * RETURN:      Status
    504  *
    505  * DESCRIPTION: Create and open the various output files needed, depending on
    506  *              the command line options
    507  *
    508  ******************************************************************************/
    509 
    510 ACPI_STATUS
    511 FlOpenMiscOutputFiles (
    512     char                    *FilenamePrefix)
    513 {
    514     char                    *Filename;
    515 
    516 
    517     /* All done for disassembler */
    518 
    519     if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE)
    520     {
    521         return (AE_OK);
    522     }
    523 
    524     /* Create/Open a hex output file if asked */
    525 
    526     if (Gbl_HexOutputFlag)
    527     {
    528         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
    529         if (!Filename)
    530         {
    531             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    532                 0, 0, 0, 0, NULL, NULL);
    533             return (AE_ERROR);
    534         }
    535 
    536         /* Open the hex file, text mode */
    537 
    538         FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t");
    539 
    540         AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
    541         AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
    542     }
    543 
    544     /* Create/Open a debug output file if asked */
    545 
    546     if (Gbl_DebugFlag)
    547     {
    548         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
    549         if (!Filename)
    550         {
    551             AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
    552                 0, 0, 0, 0, NULL, NULL);
    553             return (AE_ERROR);
    554         }
    555 
    556         /* Open the debug file as STDERR, text mode */
    557 
    558         /* TBD: hide this behind a FlReopenFile function */
    559 
    560         Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
    561         Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
    562             freopen (Filename, "w+t", stderr);
    563 
    564         if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
    565         {
    566             AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
    567                 0, 0, 0, 0, NULL, NULL);
    568             return (AE_ERROR);
    569         }
    570 
    571         AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
    572         AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
    573     }
    574 
    575     /* Create/Open a listing output file if asked */
    576 
    577     if (Gbl_ListingFlag)
    578     {
    579         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
    580         if (!Filename)
    581         {
    582             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    583                 0, 0, 0, 0, NULL, NULL);
    584             return (AE_ERROR);
    585         }
    586 
    587         /* Open the listing file, text mode */
    588 
    589         FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t");
    590 
    591         AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
    592         AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
    593     }
    594 
    595     /* Create the preprocessor output file if preprocessor enabled */
    596 
    597     if (Gbl_PreprocessFlag)
    598     {
    599         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR);
    600         if (!Filename)
    601         {
    602             AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
    603                 0, 0, 0, 0, NULL, NULL);
    604             return (AE_ERROR);
    605         }
    606 
    607         FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
    608     }
    609 
    610     /* All done for data table compiler */
    611 
    612     if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
    613     {
    614         return (AE_OK);
    615     }
    616 
    617     /* Create/Open a combined source output file */
    618 
    619     Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
    620     if (!Filename)
    621     {
    622         AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    623             0, 0, 0, 0, NULL, NULL);
    624         return (AE_ERROR);
    625     }
    626 
    627     /*
    628      * Open the source output file, binary mode (so that LF does not get
    629      * expanded to CR/LF on some systems, messing up our seek
    630      * calculations.)
    631      */
    632     FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
    633 
    634 /*
    635 // TBD: TEMP
    636 //    AslCompilerin = Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
    637 */
    638     /* Create/Open a assembly code source output file if asked */
    639 
    640     if (Gbl_AsmOutputFlag)
    641     {
    642         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
    643         if (!Filename)
    644         {
    645             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    646                 0, 0, 0, 0, NULL, NULL);
    647             return (AE_ERROR);
    648         }
    649 
    650         /* Open the assembly code source file, text mode */
    651 
    652         FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t");
    653 
    654         AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
    655         AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
    656     }
    657 
    658     /* Create/Open a C code source output file if asked */
    659 
    660     if (Gbl_C_OutputFlag)
    661     {
    662         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
    663         if (!Filename)
    664         {
    665             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    666                 0, 0, 0, 0, NULL, NULL);
    667             return (AE_ERROR);
    668         }
    669 
    670         /* Open the C code source file, text mode */
    671 
    672         FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t");
    673 
    674         FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
    675         AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
    676         AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
    677     }
    678 
    679     /* Create/Open a C code source output file for the offset table if asked */
    680 
    681     if (Gbl_C_OffsetTableFlag)
    682     {
    683         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET);
    684         if (!Filename)
    685         {
    686             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    687                 0, 0, 0, 0, NULL, NULL);
    688             return (AE_ERROR);
    689         }
    690 
    691         /* Open the C code source file, text mode */
    692 
    693         FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t");
    694 
    695         FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n");
    696         AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT);
    697         AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT);
    698     }
    699 
    700     /* Create/Open a assembly include output file if asked */
    701 
    702     if (Gbl_AsmIncludeOutputFlag)
    703     {
    704         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
    705         if (!Filename)
    706         {
    707             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    708                 0, 0, 0, 0, NULL, NULL);
    709             return (AE_ERROR);
    710         }
    711 
    712         /* Open the assembly include file, text mode */
    713 
    714         FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t");
    715 
    716         AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
    717         AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
    718     }
    719 
    720     /* Create/Open a C include output file if asked */
    721 
    722     if (Gbl_C_IncludeOutputFlag)
    723     {
    724         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
    725         if (!Filename)
    726         {
    727             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    728                 0, 0, 0, 0, NULL, NULL);
    729             return (AE_ERROR);
    730         }
    731 
    732         /* Open the C include file, text mode */
    733 
    734         FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t");
    735 
    736         FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
    737         AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
    738         AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
    739     }
    740 
    741     /* Create a namespace output file if asked */
    742 
    743     if (Gbl_NsOutputFlag)
    744     {
    745         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
    746         if (!Filename)
    747         {
    748             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    749                 0, 0, 0, 0, NULL, NULL);
    750             return (AE_ERROR);
    751         }
    752 
    753         /* Open the namespace file, text mode */
    754 
    755         FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t");
    756 
    757         AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
    758         AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
    759     }
    760 
    761     return (AE_OK);
    762 }
    763 
    764 
    765 #ifdef ACPI_OBSOLETE_FUNCTIONS
    766 /*******************************************************************************
    767  *
    768  * FUNCTION:    FlParseInputPathname
    769  *
    770  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
    771  *                                    compiled
    772  *
    773  * RETURN:      Status
    774  *
    775  * DESCRIPTION: Split the input path into a directory and filename part
    776  *              1) Directory part used to open include files
    777  *              2) Filename part used to generate output filenames
    778  *
    779  ******************************************************************************/
    780 
    781 ACPI_STATUS
    782 FlParseInputPathname (
    783     char                    *InputFilename)
    784 {
    785     char                    *Substring;
    786 
    787 
    788     if (!InputFilename)
    789     {
    790         return (AE_OK);
    791     }
    792 
    793     /* Get the path to the input filename's directory */
    794 
    795     Gbl_DirectoryPath = strdup (InputFilename);
    796     if (!Gbl_DirectoryPath)
    797     {
    798         return (AE_NO_MEMORY);
    799     }
    800 
    801     Substring = strrchr (Gbl_DirectoryPath, '\\');
    802     if (!Substring)
    803     {
    804         Substring = strrchr (Gbl_DirectoryPath, '/');
    805         if (!Substring)
    806         {
    807             Substring = strrchr (Gbl_DirectoryPath, ':');
    808         }
    809     }
    810 
    811     if (!Substring)
    812     {
    813         Gbl_DirectoryPath[0] = 0;
    814         if (Gbl_UseDefaultAmlFilename)
    815         {
    816             Gbl_OutputFilenamePrefix = strdup (InputFilename);
    817         }
    818     }
    819     else
    820     {
    821         if (Gbl_UseDefaultAmlFilename)
    822         {
    823             Gbl_OutputFilenamePrefix = strdup (Substring + 1);
    824         }
    825         *(Substring+1) = 0;
    826     }
    827 
    828     UtConvertBackslashes (Gbl_OutputFilenamePrefix);
    829     return (AE_OK);
    830 }
    831 #endif
    832