Home | History | Annotate | Line # | Download | only in compiler
      1   1.1    jruoho /******************************************************************************
      2   1.1    jruoho  *
      3   1.2  christos  * Module Name: aslfiles - File support functions
      4   1.1    jruoho  *
      5   1.1    jruoho  *****************************************************************************/
      6   1.1    jruoho 
      7  1.22  christos /******************************************************************************
      8  1.22  christos  *
      9  1.22  christos  * 1. Copyright Notice
     10  1.22  christos  *
     11  1.23  christos  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12   1.1    jruoho  * All rights reserved.
     13   1.1    jruoho  *
     14  1.22  christos  * 2. License
     15  1.22  christos  *
     16  1.22  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.22  christos  * rights. You may have additional license terms from the party that provided
     18  1.22  christos  * you this software, covering your right to use that party's intellectual
     19  1.22  christos  * property rights.
     20  1.22  christos  *
     21  1.22  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.22  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.22  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.22  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.22  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.22  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.22  christos  *
     28  1.22  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.22  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.22  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.22  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.22  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.22  christos  * license, and in no event shall the patent license extend to any additions
     34  1.22  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.22  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.22  christos  *
     37  1.22  christos  * The above copyright and patent license is granted only if the following
     38  1.22  christos  * conditions are met:
     39  1.22  christos  *
     40  1.22  christos  * 3. Conditions
     41  1.22  christos  *
     42  1.22  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.22  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.22  christos  * Code or modification with rights to further distribute source must include
     45  1.22  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.22  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.22  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.22  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.22  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.22  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.22  christos  * must include a prominent statement that the modification is derived,
     52  1.22  christos  * directly or indirectly, from Original Intel Code.
     53  1.22  christos  *
     54  1.22  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.22  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.22  christos  * Code or modification without rights to further distribute source must
     57  1.22  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.22  christos  * documentation and/or other materials provided with distribution. In
     59  1.22  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.22  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.22  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.22  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.22  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.22  christos  * make.
     65  1.22  christos  *
     66  1.22  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.22  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.22  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.22  christos  * provision in the documentation and/or other materials provided with the
     70  1.22  christos  * distribution.
     71  1.22  christos  *
     72  1.22  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.22  christos  * Intel Code.
     74  1.22  christos  *
     75  1.22  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.22  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.22  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.22  christos  * without prior written authorization from Intel.
     79  1.22  christos  *
     80  1.22  christos  * 4. Disclaimer and Export Compliance
     81  1.22  christos  *
     82  1.22  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.22  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.22  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.22  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.22  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.22  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.22  christos  * PARTICULAR PURPOSE.
     89  1.22  christos  *
     90  1.22  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.22  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.22  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.22  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.22  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.22  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.22  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.22  christos  * LIMITED REMEDY.
     98  1.22  christos  *
     99  1.22  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.22  christos  * software or system incorporating such software without first obtaining any
    101  1.22  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.22  christos  * any other agency or department of the United States Government. In the
    103  1.22  christos  * event Licensee exports any such software from the United States or
    104  1.22  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.22  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.22  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.22  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.22  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.22  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.22  christos  * United States government or any agency thereof requires an export license,
    111  1.22  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.22  christos  * such license, approval or letter.
    113  1.22  christos  *
    114  1.22  christos  *****************************************************************************
    115  1.22  christos  *
    116  1.22  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.22  christos  * following license:
    118  1.22  christos  *
    119   1.2  christos  * Redistribution and use in source and binary forms, with or without
    120   1.2  christos  * modification, are permitted provided that the following conditions
    121   1.2  christos  * are met:
    122   1.2  christos  * 1. Redistributions of source code must retain the above copyright
    123   1.2  christos  *    notice, this list of conditions, and the following disclaimer,
    124   1.2  christos  *    without modification.
    125   1.2  christos  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.2  christos  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.2  christos  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.2  christos  *    including a substantially similar Disclaimer requirement for further
    129   1.2  christos  *    binary redistribution.
    130   1.2  christos  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.2  christos  *    of any contributors may be used to endorse or promote products derived
    132   1.2  christos  *    from this software without specific prior written permission.
    133   1.2  christos  *
    134   1.2  christos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.2  christos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.17  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.2  christos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.22  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.22  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.22  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.22  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.22  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.22  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.22  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.22  christos  *
    146  1.22  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.22  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.22  christos  * Software Foundation.
    149  1.22  christos  *
    150  1.22  christos  *****************************************************************************/
    151   1.1    jruoho 
    152   1.1    jruoho #include "aslcompiler.h"
    153   1.1    jruoho #include "acapps.h"
    154   1.1    jruoho 
    155   1.1    jruoho #define _COMPONENT          ACPI_COMPILER
    156   1.1    jruoho         ACPI_MODULE_NAME    ("aslfiles")
    157   1.1    jruoho 
    158   1.1    jruoho /* Local prototypes */
    159   1.1    jruoho 
    160   1.5  christos static FILE *
    161   1.1    jruoho FlOpenIncludeWithPrefix (
    162   1.1    jruoho     char                    *PrefixDir,
    163   1.5  christos     ACPI_PARSE_OBJECT       *Op,
    164   1.1    jruoho     char                    *Filename);
    165   1.1    jruoho 
    166  1.14  christos static BOOLEAN
    167  1.14  christos FlInputFileExists (
    168  1.14  christos     char                    *InputFilename);
    169  1.14  christos 
    170   1.1    jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
    171   1.1    jruoho ACPI_STATUS
    172   1.1    jruoho FlParseInputPathname (
    173   1.1    jruoho     char                    *InputFilename);
    174   1.1    jruoho #endif
    175   1.1    jruoho 
    176   1.1    jruoho 
    177   1.1    jruoho /*******************************************************************************
    178   1.1    jruoho  *
    179  1.13  christos  * FUNCTION:    FlInitOneFile
    180  1.13  christos  *
    181  1.13  christos  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
    182  1.13  christos  *                                    compiled
    183  1.13  christos  *
    184  1.13  christos  * RETURN:      Status
    185  1.13  christos  *
    186  1.13  christos  * DESCRIPTION: Initialize global file structure for one input file. This file
    187  1.13  christos  *              structure contains references to input, output, debugging, and
    188  1.13  christos  *              other miscellaneous files that are associated for a single
    189  1.13  christos  *              input ASL file.
    190  1.13  christos  *
    191  1.13  christos  ******************************************************************************/
    192  1.13  christos 
    193  1.13  christos ACPI_STATUS
    194  1.13  christos FlInitOneFile (
    195  1.13  christos     char                    *InputFilename)
    196  1.13  christos {
    197  1.13  christos     UINT32                  i;
    198  1.13  christos     ASL_GLOBAL_FILE_NODE    *NewFileNode;
    199  1.13  christos 
    200  1.13  christos 
    201  1.13  christos     if (FlInputFileExists (InputFilename))
    202  1.13  christos     {
    203  1.13  christos         AslError (ASL_ERROR, ASL_MSG_DUPLICATE_INPUT_FILE, NULL, InputFilename);
    204  1.13  christos         return (AE_ALREADY_EXISTS);
    205  1.13  christos     }
    206  1.13  christos 
    207  1.13  christos     NewFileNode = ACPI_CAST_PTR (ASL_GLOBAL_FILE_NODE,
    208  1.13  christos         UtLocalCacheCalloc (sizeof (ASL_GLOBAL_FILE_NODE)));
    209  1.13  christos 
    210  1.13  christos     NewFileNode->ParserErrorDetected = FALSE;
    211  1.13  christos     NewFileNode->Next = AslGbl_FilesList;
    212  1.13  christos 
    213  1.13  christos     AslGbl_FilesList = NewFileNode;
    214  1.13  christos     AslGbl_Files = NewFileNode->Files;
    215  1.13  christos 
    216  1.13  christos     for (i = 0; i < ASL_NUM_FILES; i++)
    217  1.13  christos     {
    218  1.13  christos         AslGbl_Files[i].Handle = NULL;
    219  1.13  christos         AslGbl_Files[i].Filename = NULL;
    220  1.13  christos     }
    221  1.13  christos 
    222  1.13  christos     AslGbl_Files[ASL_FILE_STDOUT].Handle   = stdout;
    223  1.13  christos     AslGbl_Files[ASL_FILE_STDOUT].Filename = "STDOUT";
    224  1.13  christos 
    225  1.13  christos     if (AslGbl_VerboseErrors)
    226  1.13  christos     {
    227  1.13  christos         AslGbl_Files[ASL_FILE_STDERR].Handle = stderr;
    228  1.13  christos     }
    229  1.13  christos     else
    230  1.13  christos     {
    231  1.13  christos         AslGbl_Files[ASL_FILE_STDERR].Handle = stdout;
    232  1.13  christos     }
    233  1.13  christos 
    234  1.13  christos     AslGbl_Files[ASL_FILE_STDERR].Filename = "STDERR";
    235  1.13  christos     return (AE_OK);
    236  1.13  christos }
    237  1.13  christos 
    238  1.13  christos 
    239  1.13  christos /*******************************************************************************
    240  1.13  christos  *
    241  1.13  christos  * FUNCTION:    FlInputFileExists
    242  1.13  christos  *
    243  1.13  christos  * PARAMETERS:  Filename       - File name to be searched
    244  1.13  christos  *
    245  1.13  christos  * RETURN:      Status
    246  1.13  christos  *
    247  1.13  christos  * DESCRIPTION: Returns true if the file name already exists.
    248  1.13  christos  *
    249  1.13  christos  ******************************************************************************/
    250  1.13  christos 
    251  1.14  christos static BOOLEAN
    252  1.13  christos FlInputFileExists (
    253  1.13  christos     char                    *Filename)
    254  1.13  christos {
    255  1.13  christos     ASL_GLOBAL_FILE_NODE    *Current = AslGbl_FilesList;
    256  1.13  christos 
    257  1.13  christos 
    258  1.13  christos     while (Current)
    259  1.13  christos     {
    260  1.13  christos         if (!strcmp (Filename, Current->Files[ASL_FILE_INPUT].Filename))
    261  1.13  christos         {
    262  1.13  christos             return (TRUE);
    263  1.13  christos         }
    264  1.13  christos 
    265  1.13  christos         Current = Current->Next;
    266  1.13  christos     }
    267  1.13  christos 
    268  1.13  christos     return (FALSE);
    269  1.13  christos }
    270  1.13  christos 
    271  1.13  christos 
    272  1.13  christos /*******************************************************************************
    273  1.13  christos  *
    274  1.13  christos  * FUNCTION:    FlSwitchFileSet
    275  1.13  christos  *
    276  1.13  christos  * PARAMETERS:  Op        - Parse node for the LINE asl statement
    277  1.13  christos  *
    278  1.13  christos  * RETURN:      None.
    279  1.13  christos  *
    280  1.13  christos  * DESCRIPTION: Set the current line number
    281  1.13  christos  *
    282  1.13  christos  ******************************************************************************/
    283  1.13  christos 
    284  1.13  christos ASL_FILE_SWITCH_STATUS
    285  1.13  christos FlSwitchFileSet (
    286  1.13  christos     char                    *InputFilename)
    287  1.13  christos {
    288  1.13  christos     ASL_GLOBAL_FILE_NODE    *Current = AslGbl_FilesList;
    289  1.13  christos     char                    *PrevFilename = Current->Files[ASL_FILE_INPUT].Filename;
    290  1.13  christos 
    291  1.13  christos 
    292  1.13  christos     while (Current)
    293  1.13  christos     {
    294  1.13  christos         if (!strcmp(Current->Files[ASL_FILE_INPUT].Filename, InputFilename))
    295  1.13  christos         {
    296  1.13  christos             AslGbl_Files = Current->Files;
    297  1.13  christos             AslGbl_TableSignature = Current->TableSignature;
    298  1.13  christos             AslGbl_TableId = Current->TableId;
    299  1.13  christos 
    300  1.13  christos             if (!strcmp (InputFilename, PrevFilename))
    301  1.13  christos             {
    302  1.13  christos                 return (SWITCH_TO_SAME_FILE);
    303  1.13  christos             }
    304  1.13  christos             else
    305  1.13  christos             {
    306  1.13  christos                 return (SWITCH_TO_DIFFERENT_FILE);
    307  1.13  christos             }
    308  1.13  christos         }
    309  1.13  christos 
    310  1.13  christos         Current = Current->Next;
    311  1.13  christos     }
    312  1.13  christos 
    313  1.13  christos     return (FILE_NOT_FOUND);
    314  1.13  christos }
    315  1.13  christos 
    316  1.13  christos 
    317  1.13  christos /*******************************************************************************
    318  1.13  christos  *
    319  1.13  christos  * FUNCTION:    FlGetFileHandle
    320  1.13  christos  *
    321  1.13  christos  * PARAMETERS:  OutFileId       - denotes file type of output handle
    322  1.13  christos  *              InFileId        - denotes file type of the input Filename
    323  1.13  christos  *              Filename
    324  1.13  christos  *
    325  1.13  christos  * RETURN:      File handle
    326  1.13  christos  *
    327  1.13  christos  * DESCRIPTION: Get the file handle for a particular filename/FileId. This
    328  1.13  christos  *              function also allows the caller to specify the file Id of the
    329  1.13  christos  *              desired type.
    330  1.13  christos  *
    331  1.13  christos  ******************************************************************************/
    332  1.13  christos 
    333  1.13  christos FILE *
    334  1.13  christos FlGetFileHandle (
    335  1.13  christos     UINT32                  OutFileId,
    336  1.13  christos     UINT32                  InFileId,
    337  1.13  christos     char                    *Filename)
    338  1.13  christos {
    339  1.13  christos     ASL_GLOBAL_FILE_NODE    *Current = AslGbl_FilesList;
    340  1.13  christos 
    341  1.13  christos 
    342  1.13  christos     if (!Filename)
    343  1.13  christos     {
    344  1.13  christos         return (NULL);
    345  1.13  christos     }
    346  1.13  christos 
    347  1.13  christos     while (Current)
    348  1.13  christos     {
    349  1.22  christos         if (!strcmp (Current->Files[InFileId].Filename, Filename))
    350  1.13  christos         {
    351  1.13  christos             return (Current->Files[OutFileId].Handle);
    352  1.13  christos         }
    353  1.13  christos 
    354  1.13  christos         Current = Current->Next;
    355  1.13  christos     }
    356  1.13  christos 
    357  1.13  christos     return (NULL);
    358  1.13  christos }
    359  1.13  christos 
    360  1.13  christos 
    361  1.13  christos /*******************************************************************************
    362  1.13  christos  *
    363  1.13  christos  * FUNCTION:    FlGetFileNode
    364  1.13  christos  *
    365  1.13  christos  * PARAMETERS:  FileId        - File type (ID) of the input Filename
    366  1.13  christos  *              Filename      - File to search for
    367  1.13  christos  *
    368  1.13  christos  * RETURN:      A global file node
    369  1.13  christos  *
    370  1.13  christos  * DESCRIPTION: Get the file node for a particular filename/FileId.
    371  1.13  christos  *
    372  1.13  christos  ******************************************************************************/
    373  1.13  christos 
    374  1.13  christos ASL_GLOBAL_FILE_NODE *
    375  1.13  christos FlGetFileNode (
    376  1.13  christos     UINT32                  FileId,
    377  1.13  christos     char                    *Filename)
    378  1.13  christos {
    379  1.13  christos     ASL_GLOBAL_FILE_NODE    *Current = AslGbl_FilesList;
    380  1.13  christos 
    381  1.13  christos 
    382  1.13  christos     if (!Filename)
    383  1.13  christos     {
    384  1.13  christos         return (NULL);
    385  1.13  christos     }
    386  1.13  christos 
    387  1.13  christos     while (Current)
    388  1.13  christos     {
    389  1.13  christos         if (!strcmp (Current->Files[FileId].Filename, Filename))
    390  1.13  christos         {
    391  1.13  christos             return (Current);
    392  1.13  christos         }
    393  1.13  christos 
    394  1.13  christos         Current = Current->Next;
    395  1.13  christos     }
    396  1.13  christos 
    397  1.13  christos     return (NULL);
    398  1.13  christos }
    399  1.13  christos 
    400  1.13  christos 
    401  1.13  christos /*******************************************************************************
    402  1.13  christos  *
    403  1.13  christos  * FUNCTION:    FlGetCurrentFileNode
    404  1.13  christos  *
    405  1.13  christos  * PARAMETERS:  None
    406  1.13  christos  *
    407  1.13  christos  * RETURN:      Global file node
    408  1.13  christos  *
    409  1.13  christos  * DESCRIPTION: Get the current input file node
    410  1.13  christos  *
    411  1.13  christos  ******************************************************************************/
    412  1.13  christos 
    413  1.13  christos ASL_GLOBAL_FILE_NODE *
    414  1.13  christos FlGetCurrentFileNode (
    415  1.13  christos     void)
    416  1.13  christos {
    417  1.15  christos     ASL_GLOBAL_FILE_NODE    *FileNode =
    418  1.15  christos         FlGetFileNode (ASL_FILE_INPUT,AslGbl_Files[ASL_FILE_INPUT].Filename);
    419  1.15  christos 
    420  1.15  christos 
    421  1.15  christos     if (!FileNode)
    422  1.15  christos     {
    423  1.15  christos         /*
    424  1.15  christos          * If the current file node does not exist after initializing the file
    425  1.15  christos          * node structures, something went wrong and this is an unrecoverable
    426  1.15  christos          * condition.
    427  1.15  christos          */
    428  1.15  christos         FlFileError (ASL_FILE_INPUT, ASL_MSG_COMPILER_INTERNAL);
    429  1.15  christos         AslAbort ();
    430  1.15  christos     }
    431  1.15  christos 
    432  1.15  christos     return (FileNode);
    433  1.13  christos }
    434  1.13  christos 
    435  1.13  christos 
    436  1.13  christos /*******************************************************************************
    437  1.13  christos  *
    438   1.2  christos  * FUNCTION:    FlSetLineNumber
    439   1.1    jruoho  *
    440   1.2  christos  * PARAMETERS:  Op        - Parse node for the LINE asl statement
    441   1.1    jruoho  *
    442   1.2  christos  * RETURN:      None.
    443   1.1    jruoho  *
    444   1.2  christos  * DESCRIPTION: Set the current line number
    445   1.1    jruoho  *
    446   1.1    jruoho  ******************************************************************************/
    447   1.1    jruoho 
    448   1.1    jruoho void
    449   1.2  christos FlSetLineNumber (
    450   1.2  christos     UINT32                  LineNumber)
    451   1.1    jruoho {
    452   1.1    jruoho 
    453   1.2  christos     DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New line number %u (old %u)\n",
    454  1.12  christos          LineNumber, AslGbl_LogicalLineNumber);
    455   1.1    jruoho 
    456  1.12  christos     AslGbl_CurrentLineNumber = LineNumber;
    457   1.1    jruoho }
    458   1.1    jruoho 
    459   1.1    jruoho 
    460   1.1    jruoho /*******************************************************************************
    461   1.1    jruoho  *
    462   1.2  christos  * FUNCTION:    FlSetFilename
    463   1.1    jruoho  *
    464   1.1    jruoho  * PARAMETERS:  Op        - Parse node for the LINE asl statement
    465   1.1    jruoho  *
    466   1.1    jruoho  * RETURN:      None.
    467   1.1    jruoho  *
    468   1.2  christos  * DESCRIPTION: Set the current filename
    469   1.1    jruoho  *
    470   1.1    jruoho  ******************************************************************************/
    471   1.1    jruoho 
    472   1.1    jruoho void
    473   1.2  christos FlSetFilename (
    474   1.2  christos     char                    *Filename)
    475   1.1    jruoho {
    476   1.1    jruoho 
    477   1.2  christos     DbgPrint (ASL_PARSE_OUTPUT, "\n#line: New filename %s (old %s)\n",
    478  1.12  christos          Filename, AslGbl_Files[ASL_FILE_INPUT].Filename);
    479   1.2  christos 
    480   1.3  christos     /* No need to free any existing filename */
    481   1.3  christos 
    482  1.12  christos     AslGbl_Files[ASL_FILE_INPUT].Filename = Filename;
    483   1.1    jruoho }
    484   1.1    jruoho 
    485   1.1    jruoho 
    486   1.1    jruoho /*******************************************************************************
    487   1.1    jruoho  *
    488   1.1    jruoho  * FUNCTION:    FlAddIncludeDirectory
    489   1.1    jruoho  *
    490   1.1    jruoho  * PARAMETERS:  Dir             - Directory pathname string
    491   1.1    jruoho  *
    492   1.1    jruoho  * RETURN:      None
    493   1.1    jruoho  *
    494   1.1    jruoho  * DESCRIPTION: Add a directory the list of include prefix directories.
    495   1.1    jruoho  *
    496   1.1    jruoho  ******************************************************************************/
    497   1.1    jruoho 
    498   1.1    jruoho void
    499   1.1    jruoho FlAddIncludeDirectory (
    500   1.1    jruoho     char                    *Dir)
    501   1.1    jruoho {
    502   1.1    jruoho     ASL_INCLUDE_DIR         *NewDir;
    503   1.1    jruoho     ASL_INCLUDE_DIR         *NextDir;
    504   1.1    jruoho     ASL_INCLUDE_DIR         *PrevDir = NULL;
    505   1.1    jruoho     UINT32                  NeedsSeparator = 0;
    506   1.1    jruoho     size_t                  DirLength;
    507   1.1    jruoho 
    508   1.1    jruoho 
    509   1.1    jruoho     DirLength = strlen (Dir);
    510   1.1    jruoho     if (!DirLength)
    511   1.1    jruoho     {
    512   1.1    jruoho         return;
    513   1.1    jruoho     }
    514   1.1    jruoho 
    515   1.1    jruoho     /* Make sure that the pathname ends with a path separator */
    516   1.1    jruoho 
    517   1.1    jruoho     if ((Dir[DirLength-1] != '/') &&
    518   1.1    jruoho         (Dir[DirLength-1] != '\\'))
    519   1.1    jruoho     {
    520   1.1    jruoho         NeedsSeparator = 1;
    521   1.1    jruoho     }
    522   1.1    jruoho 
    523  1.12  christos     NewDir = ACPI_CAST_PTR (ASL_INCLUDE_DIR,
    524  1.12  christos         UtLocalCacheCalloc (sizeof (ASL_INCLUDE_DIR)));
    525  1.12  christos     NewDir->Dir = UtLocalCacheCalloc (DirLength + 1 + NeedsSeparator);
    526   1.1    jruoho     strcpy (NewDir->Dir, Dir);
    527   1.1    jruoho     if (NeedsSeparator)
    528   1.1    jruoho     {
    529   1.1    jruoho         strcat (NewDir->Dir, "/");
    530   1.1    jruoho     }
    531   1.1    jruoho 
    532   1.1    jruoho     /*
    533   1.1    jruoho      * Preserve command line ordering of -I options by adding new elements
    534   1.1    jruoho      * at the end of the list
    535   1.1    jruoho      */
    536  1.12  christos     NextDir = AslGbl_IncludeDirList;
    537   1.1    jruoho     while (NextDir)
    538   1.1    jruoho     {
    539   1.1    jruoho         PrevDir = NextDir;
    540   1.1    jruoho         NextDir = NextDir->Next;
    541   1.1    jruoho     }
    542   1.1    jruoho 
    543   1.1    jruoho     if (PrevDir)
    544   1.1    jruoho     {
    545   1.1    jruoho         PrevDir->Next = NewDir;
    546   1.1    jruoho     }
    547   1.1    jruoho     else
    548   1.1    jruoho     {
    549  1.12  christos         AslGbl_IncludeDirList = NewDir;
    550   1.1    jruoho     }
    551   1.1    jruoho }
    552   1.1    jruoho 
    553   1.1    jruoho 
    554   1.1    jruoho /*******************************************************************************
    555   1.1    jruoho  *
    556   1.2  christos  * FUNCTION:    FlMergePathnames
    557   1.2  christos  *
    558   1.2  christos  * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be NULL or
    559   1.2  christos  *                                a zero length string.
    560   1.2  christos  *              FilePathname    - The include filename from the source ASL.
    561   1.2  christos  *
    562   1.2  christos  * RETURN:      Merged pathname string
    563   1.2  christos  *
    564   1.2  christos  * DESCRIPTION: Merge two pathnames that (probably) have common elements, to
    565   1.2  christos  *              arrive at a minimal length string. Merge can occur if the
    566   1.2  christos  *              FilePathname is relative to the PrefixDir.
    567   1.2  christos  *
    568   1.2  christos  ******************************************************************************/
    569   1.2  christos 
    570   1.2  christos char *
    571   1.2  christos FlMergePathnames (
    572   1.2  christos     char                    *PrefixDir,
    573   1.2  christos     char                    *FilePathname)
    574   1.2  christos {
    575   1.2  christos     char                    *CommonPath;
    576   1.2  christos     char                    *Pathname;
    577   1.2  christos     char                    *LastElement;
    578   1.2  christos 
    579   1.2  christos 
    580   1.2  christos     DbgPrint (ASL_PARSE_OUTPUT, "Include: Prefix path - \"%s\"\n"
    581   1.2  christos         "Include: FilePathname - \"%s\"\n",
    582   1.2  christos          PrefixDir, FilePathname);
    583   1.2  christos 
    584   1.2  christos     /*
    585   1.2  christos      * If there is no prefix directory or if the file pathname is absolute,
    586   1.2  christos      * just return the original file pathname
    587   1.2  christos      */
    588   1.2  christos     if (!PrefixDir || (!*PrefixDir) ||
    589   1.2  christos         (*FilePathname == '/') ||
    590   1.2  christos          (FilePathname[1] == ':'))
    591   1.2  christos     {
    592  1.10  christos         Pathname = UtLocalCacheCalloc (strlen (FilePathname) + 1);
    593   1.2  christos         strcpy (Pathname, FilePathname);
    594   1.2  christos         goto ConvertBackslashes;
    595   1.2  christos     }
    596   1.2  christos 
    597   1.2  christos     /* Need a local copy of the prefix directory path */
    598   1.2  christos 
    599  1.10  christos     CommonPath = UtLocalCacheCalloc (strlen (PrefixDir) + 1);
    600   1.2  christos     strcpy (CommonPath, PrefixDir);
    601   1.2  christos 
    602   1.2  christos     /*
    603   1.2  christos      * Walk forward through the file path, and simultaneously backward
    604   1.2  christos      * through the prefix directory path until there are no more
    605   1.2  christos      * relative references at the start of the file path.
    606   1.2  christos      */
    607   1.2  christos     while (*FilePathname && (!strncmp (FilePathname, "../", 3)))
    608   1.2  christos     {
    609   1.2  christos         /* Remove last element of the prefix directory path */
    610   1.2  christos 
    611   1.2  christos         LastElement = strrchr (CommonPath, '/');
    612   1.2  christos         if (!LastElement)
    613   1.2  christos         {
    614   1.2  christos             goto ConcatenatePaths;
    615   1.2  christos         }
    616   1.2  christos 
    617   1.2  christos         *LastElement = 0;   /* Terminate CommonPath string */
    618   1.2  christos         FilePathname += 3;  /* Point to next path element */
    619   1.2  christos     }
    620   1.2  christos 
    621   1.2  christos     /*
    622   1.2  christos      * Remove the last element of the prefix directory path (it is the same as
    623   1.2  christos      * the first element of the file pathname), and build the final merged
    624   1.2  christos      * pathname.
    625   1.2  christos      */
    626   1.2  christos     LastElement = strrchr (CommonPath, '/');
    627   1.2  christos     if (LastElement)
    628   1.2  christos     {
    629   1.2  christos         *LastElement = 0;
    630   1.2  christos     }
    631   1.2  christos 
    632   1.2  christos     /* Build the final merged pathname */
    633   1.2  christos 
    634   1.2  christos ConcatenatePaths:
    635  1.10  christos     Pathname = UtLocalCacheCalloc (
    636   1.6  christos         strlen (CommonPath) + strlen (FilePathname) + 2);
    637   1.2  christos     if (LastElement && *CommonPath)
    638   1.2  christos     {
    639   1.2  christos         strcpy (Pathname, CommonPath);
    640   1.2  christos         strcat (Pathname, "/");
    641   1.2  christos     }
    642   1.2  christos     strcat (Pathname, FilePathname);
    643   1.2  christos 
    644   1.2  christos     /* Convert all backslashes to normal slashes */
    645   1.2  christos 
    646   1.2  christos ConvertBackslashes:
    647   1.2  christos     UtConvertBackslashes (Pathname);
    648   1.2  christos 
    649   1.2  christos     DbgPrint (ASL_PARSE_OUTPUT, "Include: Merged Pathname - \"%s\"\n",
    650   1.2  christos          Pathname);
    651   1.2  christos     return (Pathname);
    652   1.2  christos }
    653   1.2  christos 
    654   1.2  christos 
    655   1.2  christos /*******************************************************************************
    656   1.2  christos  *
    657   1.1    jruoho  * FUNCTION:    FlOpenIncludeWithPrefix
    658   1.1    jruoho  *
    659   1.1    jruoho  * PARAMETERS:  PrefixDir       - Prefix directory pathname. Can be a zero
    660   1.1    jruoho  *                                length string.
    661   1.1    jruoho  *              Filename        - The include filename from the source ASL.
    662   1.1    jruoho  *
    663   1.1    jruoho  * RETURN:      Valid file descriptor if successful. Null otherwise.
    664   1.1    jruoho  *
    665   1.1    jruoho  * DESCRIPTION: Open an include file and push it on the input file stack.
    666   1.1    jruoho  *
    667   1.1    jruoho  ******************************************************************************/
    668   1.1    jruoho 
    669   1.5  christos static FILE *
    670   1.1    jruoho FlOpenIncludeWithPrefix (
    671   1.1    jruoho     char                    *PrefixDir,
    672   1.5  christos     ACPI_PARSE_OBJECT       *Op,
    673   1.1    jruoho     char                    *Filename)
    674   1.1    jruoho {
    675   1.1    jruoho     FILE                    *IncludeFile;
    676   1.1    jruoho     char                    *Pathname;
    677   1.5  christos     UINT32                  OriginalLineNumber;
    678   1.1    jruoho 
    679   1.1    jruoho 
    680   1.1    jruoho     /* Build the full pathname to the file */
    681   1.1    jruoho 
    682   1.2  christos     Pathname = FlMergePathnames (PrefixDir, Filename);
    683   1.1    jruoho 
    684   1.2  christos     DbgPrint (ASL_PARSE_OUTPUT, "Include: Opening file - \"%s\"\n\n",
    685   1.1    jruoho         Pathname);
    686   1.1    jruoho 
    687   1.1    jruoho     /* Attempt to open the file, push if successful */
    688   1.1    jruoho 
    689   1.1    jruoho     IncludeFile = fopen (Pathname, "r");
    690   1.2  christos     if (!IncludeFile)
    691   1.1    jruoho     {
    692   1.2  christos         return (NULL);
    693   1.2  christos     }
    694   1.1    jruoho 
    695   1.5  christos     /*
    696   1.5  christos      * Check the entire include file for any # preprocessor directives.
    697   1.5  christos      * This is because there may be some confusion between the #include
    698   1.5  christos      * preprocessor directive and the ASL Include statement. A file included
    699   1.5  christos      * by the ASL include cannot contain preprocessor directives because
    700   1.5  christos      * the preprocessor has already run by the time the ASL include is
    701   1.5  christos      * recognized (by the compiler, not the preprocessor.)
    702   1.5  christos      *
    703   1.5  christos      * Note: DtGetNextLine strips/ignores comments.
    704   1.5  christos      * Save current line number since DtGetNextLine modifies it.
    705   1.5  christos      */
    706  1.12  christos     AslGbl_CurrentLineNumber--;
    707  1.12  christos     OriginalLineNumber = AslGbl_CurrentLineNumber;
    708   1.6  christos 
    709   1.5  christos     while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
    710   1.5  christos     {
    711  1.12  christos         if (AslGbl_CurrentLineBuffer[0] == '#')
    712   1.5  christos         {
    713   1.5  christos             AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE,
    714   1.5  christos                 Op, "use #include instead");
    715   1.5  christos         }
    716   1.5  christos     }
    717   1.6  christos 
    718  1.12  christos     AslGbl_CurrentLineNumber = OriginalLineNumber;
    719   1.5  christos 
    720   1.5  christos     /* Must seek back to the start of the file */
    721   1.5  christos 
    722   1.5  christos     fseek (IncludeFile, 0, SEEK_SET);
    723   1.5  christos 
    724   1.2  christos     /* Push the include file on the open input file stack */
    725   1.1    jruoho 
    726   1.2  christos     AslPushInputFileStack (IncludeFile, Pathname);
    727   1.2  christos     return (IncludeFile);
    728   1.1    jruoho }
    729   1.1    jruoho 
    730   1.1    jruoho 
    731   1.1    jruoho /*******************************************************************************
    732   1.1    jruoho  *
    733   1.1    jruoho  * FUNCTION:    FlOpenIncludeFile
    734   1.1    jruoho  *
    735   1.1    jruoho  * PARAMETERS:  Op        - Parse node for the INCLUDE ASL statement
    736   1.1    jruoho  *
    737   1.1    jruoho  * RETURN:      None.
    738   1.1    jruoho  *
    739   1.1    jruoho  * DESCRIPTION: Open an include file and push it on the input file stack.
    740   1.1    jruoho  *
    741   1.1    jruoho  ******************************************************************************/
    742   1.1    jruoho 
    743   1.1    jruoho void
    744   1.1    jruoho FlOpenIncludeFile (
    745   1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    746   1.1    jruoho {
    747   1.1    jruoho     FILE                    *IncludeFile;
    748   1.1    jruoho     ASL_INCLUDE_DIR         *NextDir;
    749   1.1    jruoho 
    750   1.1    jruoho 
    751   1.1    jruoho     /* Op must be valid */
    752   1.1    jruoho 
    753   1.1    jruoho     if (!Op)
    754   1.1    jruoho     {
    755   1.1    jruoho         AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
    756  1.12  christos             AslGbl_CurrentLineNumber, AslGbl_LogicalLineNumber,
    757  1.12  christos             AslGbl_InputByteCount, AslGbl_CurrentColumn,
    758  1.12  christos             AslGbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
    759   1.1    jruoho 
    760   1.1    jruoho         return;
    761   1.1    jruoho     }
    762   1.1    jruoho 
    763   1.1    jruoho     /*
    764   1.1    jruoho      * Flush out the "include ()" statement on this line, start
    765   1.1    jruoho      * the actual include file on the next line
    766   1.1    jruoho      */
    767   1.2  christos     AslResetCurrentLineBuffer ();
    768   1.1    jruoho     FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
    769  1.12  christos     AslGbl_CurrentLineOffset++;
    770   1.1    jruoho 
    771   1.1    jruoho 
    772   1.1    jruoho     /* Attempt to open the include file */
    773   1.1    jruoho 
    774   1.1    jruoho     /* If the file specifies an absolute path, just open it */
    775   1.1    jruoho 
    776   1.1    jruoho     if ((Op->Asl.Value.String[0] == '/')  ||
    777   1.1    jruoho         (Op->Asl.Value.String[0] == '\\') ||
    778   1.1    jruoho         (Op->Asl.Value.String[1] == ':'))
    779   1.1    jruoho     {
    780   1.5  christos         IncludeFile = FlOpenIncludeWithPrefix ("", Op, Op->Asl.Value.String);
    781   1.1    jruoho         if (!IncludeFile)
    782   1.1    jruoho         {
    783   1.1    jruoho             goto ErrorExit;
    784   1.1    jruoho         }
    785   1.1    jruoho         return;
    786   1.1    jruoho     }
    787   1.1    jruoho 
    788   1.1    jruoho     /*
    789   1.1    jruoho      * The include filename is not an absolute path.
    790   1.1    jruoho      *
    791   1.1    jruoho      * First, search for the file within the "local" directory -- meaning
    792   1.1    jruoho      * the same directory that contains the source file.
    793   1.1    jruoho      *
    794   1.1    jruoho      * Construct the file pathname from the global directory name.
    795   1.1    jruoho      */
    796   1.6  christos     IncludeFile = FlOpenIncludeWithPrefix (
    797  1.12  christos         AslGbl_DirectoryPath, Op, Op->Asl.Value.String);
    798   1.1    jruoho     if (IncludeFile)
    799   1.1    jruoho     {
    800   1.1    jruoho         return;
    801   1.1    jruoho     }
    802   1.1    jruoho 
    803   1.1    jruoho     /*
    804   1.1    jruoho      * Second, search for the file within the (possibly multiple) directories
    805   1.1    jruoho      * specified by the -I option on the command line.
    806   1.1    jruoho      */
    807  1.12  christos     NextDir = AslGbl_IncludeDirList;
    808   1.1    jruoho     while (NextDir)
    809   1.1    jruoho     {
    810   1.6  christos         IncludeFile = FlOpenIncludeWithPrefix (
    811   1.6  christos             NextDir->Dir, Op, Op->Asl.Value.String);
    812   1.1    jruoho         if (IncludeFile)
    813   1.1    jruoho         {
    814   1.1    jruoho             return;
    815   1.1    jruoho         }
    816   1.1    jruoho 
    817   1.1    jruoho         NextDir = NextDir->Next;
    818   1.1    jruoho     }
    819   1.1    jruoho 
    820   1.1    jruoho     /* We could not open the include file after trying very hard */
    821   1.1    jruoho 
    822   1.1    jruoho ErrorExit:
    823  1.12  christos     snprintf (AslGbl_MsgBuffer, sizeof(AslGbl_MsgBuffer), "%s, %s", Op->Asl.Value.String, strerror (errno));
    824  1.12  christos     AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, AslGbl_MsgBuffer);
    825   1.1    jruoho }
    826   1.1    jruoho 
    827   1.1    jruoho 
    828   1.1    jruoho /*******************************************************************************
    829   1.1    jruoho  *
    830   1.1    jruoho  * FUNCTION:    FlOpenInputFile
    831   1.1    jruoho  *
    832   1.1    jruoho  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
    833   1.1    jruoho  *                                    compiled
    834   1.1    jruoho  *
    835   1.1    jruoho  * RETURN:      Status
    836   1.1    jruoho  *
    837   1.1    jruoho  * DESCRIPTION: Open the specified input file, and save the directory path to
    838  1.18  christos  *              the file so that include files can be opened in the same
    839  1.18  christos  *              directory. NOTE: File is opened in text mode.
    840   1.1    jruoho  *
    841   1.1    jruoho  ******************************************************************************/
    842   1.1    jruoho 
    843   1.1    jruoho ACPI_STATUS
    844   1.1    jruoho FlOpenInputFile (
    845   1.1    jruoho     char                    *InputFilename)
    846   1.1    jruoho {
    847   1.1    jruoho 
    848   1.1    jruoho     /* Open the input ASL file, text mode */
    849   1.1    jruoho 
    850   1.2  christos     FlOpenFile (ASL_FILE_INPUT, InputFilename, "rt");
    851  1.12  christos     AslCompilerin = AslGbl_Files[ASL_FILE_INPUT].Handle;
    852   1.1    jruoho 
    853   1.1    jruoho     return (AE_OK);
    854   1.1    jruoho }
    855   1.1    jruoho 
    856   1.1    jruoho 
    857   1.1    jruoho /*******************************************************************************
    858   1.1    jruoho  *
    859   1.1    jruoho  * FUNCTION:    FlOpenAmlOutputFile
    860   1.1    jruoho  *
    861   1.1    jruoho  * PARAMETERS:  FilenamePrefix       - The user-specified ASL source file
    862   1.1    jruoho  *
    863   1.1    jruoho  * RETURN:      Status
    864   1.1    jruoho  *
    865   1.2  christos  * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
    866   1.1    jruoho  *              is created in the same directory as the parent input file.
    867   1.1    jruoho  *
    868   1.1    jruoho  ******************************************************************************/
    869   1.1    jruoho 
    870   1.1    jruoho ACPI_STATUS
    871   1.1    jruoho FlOpenAmlOutputFile (
    872   1.1    jruoho     char                    *FilenamePrefix)
    873   1.1    jruoho {
    874   1.1    jruoho     char                    *Filename;
    875   1.1    jruoho 
    876   1.1    jruoho 
    877   1.1    jruoho     /* Output filename usually comes from the ASL itself */
    878   1.1    jruoho 
    879  1.12  christos     Filename = AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename;
    880   1.1    jruoho     if (!Filename)
    881   1.1    jruoho     {
    882   1.1    jruoho         /* Create the output AML filename */
    883  1.11  christos         if (!AcpiGbl_CaptureComments)
    884   1.9  christos         {
    885   1.9  christos             Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
    886   1.9  christos         }
    887   1.9  christos         else
    888   1.9  christos         {
    889   1.9  christos             Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_AML);
    890   1.9  christos         }
    891   1.1    jruoho         if (!Filename)
    892   1.1    jruoho         {
    893   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
    894   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
    895   1.1    jruoho             return (AE_ERROR);
    896   1.1    jruoho         }
    897   1.4  christos 
    898  1.12  christos         AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename = Filename;
    899   1.1    jruoho     }
    900   1.1    jruoho 
    901   1.1    jruoho     /* Open the output AML file in binary mode */
    902   1.1    jruoho 
    903   1.1    jruoho     FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
    904   1.1    jruoho     return (AE_OK);
    905   1.1    jruoho }
    906   1.1    jruoho 
    907   1.1    jruoho 
    908   1.1    jruoho /*******************************************************************************
    909   1.1    jruoho  *
    910   1.1    jruoho  * FUNCTION:    FlOpenMiscOutputFiles
    911   1.1    jruoho  *
    912   1.1    jruoho  * PARAMETERS:  FilenamePrefix       - The user-specified ASL source file
    913   1.1    jruoho  *
    914   1.1    jruoho  * RETURN:      Status
    915   1.1    jruoho  *
    916   1.1    jruoho  * DESCRIPTION: Create and open the various output files needed, depending on
    917   1.1    jruoho  *              the command line options
    918   1.1    jruoho  *
    919   1.1    jruoho  ******************************************************************************/
    920   1.1    jruoho 
    921   1.1    jruoho ACPI_STATUS
    922   1.1    jruoho FlOpenMiscOutputFiles (
    923   1.1    jruoho     char                    *FilenamePrefix)
    924   1.1    jruoho {
    925   1.1    jruoho     char                    *Filename;
    926   1.1    jruoho 
    927   1.1    jruoho 
    928   1.5  christos      /* Create/Open a map file if requested */
    929   1.5  christos 
    930  1.12  christos     if (AslGbl_MapfileFlag)
    931   1.5  christos     {
    932   1.5  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_MAP);
    933   1.5  christos         if (!Filename)
    934   1.5  christos         {
    935   1.5  christos             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    936   1.5  christos                 0, 0, 0, 0, NULL, NULL);
    937   1.5  christos             return (AE_ERROR);
    938   1.5  christos         }
    939   1.5  christos 
    940   1.5  christos         /* Open the hex file, text mode (closed at compiler exit) */
    941   1.5  christos 
    942   1.5  christos         FlOpenFile (ASL_FILE_MAP_OUTPUT, Filename, "w+t");
    943   1.5  christos 
    944   1.5  christos         AslCompilerSignon (ASL_FILE_MAP_OUTPUT);
    945   1.5  christos         AslCompilerFileHeader (ASL_FILE_MAP_OUTPUT);
    946   1.5  christos     }
    947   1.5  christos 
    948   1.2  christos     /* All done for disassembler */
    949   1.2  christos 
    950  1.12  christos     if (AslGbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE)
    951   1.2  christos     {
    952   1.2  christos         return (AE_OK);
    953   1.2  christos     }
    954   1.2  christos 
    955   1.2  christos     /* Create/Open a hex output file if asked */
    956   1.1    jruoho 
    957  1.12  christos     if (AslGbl_HexOutputFlag)
    958   1.1    jruoho     {
    959   1.2  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
    960   1.2  christos         if (!Filename)
    961   1.2  christos         {
    962   1.2  christos             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
    963   1.2  christos                 0, 0, 0, 0, NULL, NULL);
    964   1.2  christos             return (AE_ERROR);
    965   1.2  christos         }
    966   1.2  christos 
    967   1.2  christos         /* Open the hex file, text mode */
    968   1.2  christos 
    969   1.2  christos         FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+t");
    970   1.2  christos 
    971   1.2  christos         AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
    972   1.2  christos         AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
    973   1.1    jruoho     }
    974   1.1    jruoho 
    975   1.2  christos     /* Create/Open a debug output file if asked */
    976   1.2  christos 
    977  1.12  christos     if (AslGbl_DebugFlag)
    978   1.2  christos     {
    979   1.2  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
    980   1.2  christos         if (!Filename)
    981   1.2  christos         {
    982   1.2  christos             AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
    983   1.2  christos                 0, 0, 0, 0, NULL, NULL);
    984   1.2  christos             return (AE_ERROR);
    985   1.2  christos         }
    986   1.2  christos 
    987   1.2  christos         /* Open the debug file as STDERR, text mode */
    988   1.2  christos 
    989  1.12  christos         AslGbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
    990  1.12  christos         AslGbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
    991   1.2  christos             freopen (Filename, "w+t", stderr);
    992   1.2  christos 
    993  1.12  christos         if (!AslGbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
    994   1.2  christos         {
    995   1.4  christos             /*
    996   1.5  christos              * A problem with freopen is that on error, we no longer
    997   1.5  christos              * have stderr and cannot emit normal error messages.
    998   1.5  christos              * Emit error to stdout, close files, and exit.
    999   1.4  christos              */
   1000   1.5  christos             fprintf (stdout,
   1001   1.5  christos                 "\nCould not open debug output file: %s\n\n", Filename);
   1002   1.5  christos 
   1003   1.5  christos             CmCleanupAndExit ();
   1004   1.5  christos             exit (1);
   1005   1.2  christos         }
   1006   1.2  christos 
   1007   1.2  christos         AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
   1008   1.2  christos         AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
   1009   1.2  christos     }
   1010   1.1    jruoho 
   1011   1.7  christos     /* Create/Open a cross-reference output file if asked */
   1012   1.7  christos 
   1013  1.12  christos     if (AslGbl_CrossReferenceOutput)
   1014   1.7  christos     {
   1015   1.7  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_XREF);
   1016   1.7  christos         if (!Filename)
   1017   1.7  christos         {
   1018   1.7  christos             AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
   1019   1.7  christos                 0, 0, 0, 0, NULL, NULL);
   1020   1.7  christos             return (AE_ERROR);
   1021   1.7  christos         }
   1022   1.7  christos 
   1023   1.7  christos         FlOpenFile (ASL_FILE_XREF_OUTPUT, Filename, "w+t");
   1024   1.7  christos 
   1025   1.7  christos         AslCompilerSignon (ASL_FILE_XREF_OUTPUT);
   1026   1.7  christos         AslCompilerFileHeader (ASL_FILE_XREF_OUTPUT);
   1027   1.7  christos     }
   1028   1.7  christos 
   1029   1.1    jruoho     /* Create/Open a listing output file if asked */
   1030   1.1    jruoho 
   1031  1.12  christos     if (AslGbl_ListingFlag)
   1032   1.1    jruoho     {
   1033   1.1    jruoho         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
   1034   1.1    jruoho         if (!Filename)
   1035   1.1    jruoho         {
   1036   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1037   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
   1038   1.1    jruoho             return (AE_ERROR);
   1039   1.1    jruoho         }
   1040   1.1    jruoho 
   1041   1.1    jruoho         /* Open the listing file, text mode */
   1042   1.1    jruoho 
   1043   1.2  christos         FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+t");
   1044   1.1    jruoho 
   1045   1.1    jruoho         AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
   1046   1.1    jruoho         AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
   1047   1.1    jruoho     }
   1048   1.1    jruoho 
   1049   1.5  christos     /* Create the preprocessor output temp file if preprocessor enabled */
   1050   1.2  christos 
   1051  1.12  christos     if (AslGbl_PreprocessFlag)
   1052   1.2  christos     {
   1053   1.2  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROCESSOR);
   1054   1.2  christos         if (!Filename)
   1055   1.2  christos         {
   1056   1.2  christos             AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
   1057   1.2  christos                 0, 0, 0, 0, NULL, NULL);
   1058   1.2  christos             return (AE_ERROR);
   1059   1.2  christos         }
   1060   1.2  christos 
   1061   1.2  christos         FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
   1062   1.2  christos     }
   1063   1.2  christos 
   1064   1.5  christos     /*
   1065   1.5  christos      * Create the "user" preprocessor output file if -li flag set.
   1066   1.5  christos      * Note, this file contains no embedded #line directives.
   1067   1.5  christos      */
   1068  1.12  christos     if (AslGbl_PreprocessorOutputFlag)
   1069   1.5  christos     {
   1070   1.5  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER);
   1071   1.5  christos         if (!Filename)
   1072   1.5  christos         {
   1073   1.5  christos             AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
   1074   1.5  christos                 0, 0, 0, 0, NULL, NULL);
   1075   1.5  christos             return (AE_ERROR);
   1076   1.5  christos         }
   1077   1.5  christos 
   1078   1.5  christos         FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t");
   1079   1.5  christos     }
   1080   1.5  christos 
   1081   1.2  christos     /* All done for data table compiler */
   1082   1.2  christos 
   1083  1.12  christos     if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
   1084   1.2  christos     {
   1085   1.2  christos         return (AE_OK);
   1086   1.2  christos     }
   1087   1.2  christos 
   1088   1.2  christos     /* Create/Open a combined source output file */
   1089   1.2  christos 
   1090   1.2  christos     Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
   1091   1.2  christos     if (!Filename)
   1092   1.2  christos     {
   1093   1.2  christos         AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1094   1.2  christos             0, 0, 0, 0, NULL, NULL);
   1095   1.2  christos         return (AE_ERROR);
   1096   1.2  christos     }
   1097   1.2  christos 
   1098   1.2  christos     /*
   1099   1.2  christos      * Open the source output file, binary mode (so that LF does not get
   1100   1.2  christos      * expanded to CR/LF on some systems, messing up our seek
   1101   1.2  christos      * calculations.)
   1102   1.2  christos      */
   1103   1.2  christos     FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
   1104   1.2  christos 
   1105   1.2  christos /*
   1106   1.2  christos // TBD: TEMP
   1107  1.12  christos //    AslCompilerin = AslGbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle;
   1108   1.2  christos */
   1109   1.1    jruoho     /* Create/Open a assembly code source output file if asked */
   1110   1.1    jruoho 
   1111  1.12  christos     if (AslGbl_AsmOutputFlag)
   1112   1.1    jruoho     {
   1113   1.1    jruoho         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
   1114   1.1    jruoho         if (!Filename)
   1115   1.1    jruoho         {
   1116   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1117   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
   1118   1.1    jruoho             return (AE_ERROR);
   1119   1.1    jruoho         }
   1120   1.1    jruoho 
   1121   1.1    jruoho         /* Open the assembly code source file, text mode */
   1122   1.1    jruoho 
   1123   1.2  christos         FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+t");
   1124   1.1    jruoho 
   1125   1.1    jruoho         AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
   1126   1.1    jruoho         AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
   1127   1.1    jruoho     }
   1128   1.1    jruoho 
   1129   1.1    jruoho     /* Create/Open a C code source output file if asked */
   1130   1.1    jruoho 
   1131  1.12  christos     if (AslGbl_C_OutputFlag)
   1132   1.1    jruoho     {
   1133   1.1    jruoho         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
   1134   1.1    jruoho         if (!Filename)
   1135   1.1    jruoho         {
   1136   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1137   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
   1138   1.1    jruoho             return (AE_ERROR);
   1139   1.1    jruoho         }
   1140   1.1    jruoho 
   1141   1.1    jruoho         /* Open the C code source file, text mode */
   1142   1.1    jruoho 
   1143   1.2  christos         FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+t");
   1144   1.1    jruoho 
   1145   1.1    jruoho         FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
   1146   1.1    jruoho         AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
   1147   1.1    jruoho         AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
   1148   1.1    jruoho     }
   1149   1.1    jruoho 
   1150   1.2  christos     /* Create/Open a C code source output file for the offset table if asked */
   1151   1.2  christos 
   1152  1.12  christos     if (AslGbl_C_OffsetTableFlag)
   1153   1.2  christos     {
   1154   1.2  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_OFFSET);
   1155   1.2  christos         if (!Filename)
   1156   1.2  christos         {
   1157   1.2  christos             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1158   1.2  christos                 0, 0, 0, 0, NULL, NULL);
   1159   1.2  christos             return (AE_ERROR);
   1160   1.2  christos         }
   1161   1.2  christos 
   1162   1.2  christos         /* Open the C code source file, text mode */
   1163   1.2  christos 
   1164   1.2  christos         FlOpenFile (ASL_FILE_C_OFFSET_OUTPUT, Filename, "w+t");
   1165   1.2  christos 
   1166   1.2  christos         FlPrintFile (ASL_FILE_C_OFFSET_OUTPUT, "/*\n");
   1167   1.2  christos         AslCompilerSignon (ASL_FILE_C_OFFSET_OUTPUT);
   1168   1.2  christos         AslCompilerFileHeader (ASL_FILE_C_OFFSET_OUTPUT);
   1169   1.2  christos     }
   1170   1.2  christos 
   1171   1.1    jruoho     /* Create/Open a assembly include output file if asked */
   1172   1.1    jruoho 
   1173  1.12  christos     if (AslGbl_AsmIncludeOutputFlag)
   1174   1.1    jruoho     {
   1175   1.1    jruoho         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
   1176   1.1    jruoho         if (!Filename)
   1177   1.1    jruoho         {
   1178   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1179   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
   1180   1.1    jruoho             return (AE_ERROR);
   1181   1.1    jruoho         }
   1182   1.1    jruoho 
   1183   1.1    jruoho         /* Open the assembly include file, text mode */
   1184   1.1    jruoho 
   1185   1.2  christos         FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+t");
   1186   1.1    jruoho 
   1187   1.1    jruoho         AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
   1188   1.1    jruoho         AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
   1189   1.1    jruoho     }
   1190   1.1    jruoho 
   1191   1.1    jruoho     /* Create/Open a C include output file if asked */
   1192   1.1    jruoho 
   1193  1.12  christos     if (AslGbl_C_IncludeOutputFlag)
   1194   1.1    jruoho     {
   1195   1.1    jruoho         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
   1196   1.1    jruoho         if (!Filename)
   1197   1.1    jruoho         {
   1198   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1199   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
   1200   1.1    jruoho             return (AE_ERROR);
   1201   1.1    jruoho         }
   1202   1.1    jruoho 
   1203   1.1    jruoho         /* Open the C include file, text mode */
   1204   1.1    jruoho 
   1205   1.2  christos         FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+t");
   1206   1.1    jruoho 
   1207   1.1    jruoho         FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
   1208   1.1    jruoho         AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
   1209   1.1    jruoho         AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
   1210   1.1    jruoho     }
   1211   1.1    jruoho 
   1212   1.1    jruoho     /* Create a namespace output file if asked */
   1213   1.1    jruoho 
   1214  1.12  christos     if (AslGbl_NsOutputFlag)
   1215   1.1    jruoho     {
   1216   1.1    jruoho         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
   1217   1.1    jruoho         if (!Filename)
   1218   1.1    jruoho         {
   1219   1.1    jruoho             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1220   1.1    jruoho                 0, 0, 0, 0, NULL, NULL);
   1221   1.1    jruoho             return (AE_ERROR);
   1222   1.1    jruoho         }
   1223   1.1    jruoho 
   1224   1.1    jruoho         /* Open the namespace file, text mode */
   1225   1.1    jruoho 
   1226   1.2  christos         FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+t");
   1227   1.1    jruoho 
   1228   1.1    jruoho         AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
   1229   1.1    jruoho         AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
   1230   1.1    jruoho     }
   1231   1.1    jruoho 
   1232   1.9  christos     /* Create a debug file for the converter */
   1233   1.9  christos 
   1234   1.9  christos     if (AcpiGbl_DebugAslConversion)
   1235   1.9  christos     {
   1236   1.9  christos         Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_DEBUG);
   1237   1.9  christos         if (!Filename)
   1238   1.9  christos         {
   1239   1.9  christos             AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
   1240   1.9  christos                 0, 0, 0, 0, NULL, NULL);
   1241   1.9  christos             return (AE_ERROR);
   1242   1.9  christos         }
   1243   1.9  christos 
   1244   1.9  christos         /* Open the converter debug file, text mode */
   1245   1.9  christos 
   1246   1.9  christos         FlOpenFile (ASL_FILE_CONV_DEBUG_OUTPUT, Filename, "w+t");
   1247   1.9  christos 
   1248   1.9  christos         AslCompilerSignon (ASL_FILE_CONV_DEBUG_OUTPUT);
   1249   1.9  christos         AslCompilerFileHeader (ASL_FILE_CONV_DEBUG_OUTPUT);
   1250   1.9  christos 
   1251  1.12  christos         AcpiGbl_ConvDebugFile = AslGbl_Files[ASL_FILE_CONV_DEBUG_OUTPUT].Handle;
   1252   1.9  christos     }
   1253   1.9  christos 
   1254   1.1    jruoho     return (AE_OK);
   1255   1.1    jruoho }
   1256   1.1    jruoho 
   1257   1.1    jruoho 
   1258   1.1    jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
   1259   1.1    jruoho /*******************************************************************************
   1260   1.1    jruoho  *
   1261   1.1    jruoho  * FUNCTION:    FlParseInputPathname
   1262   1.1    jruoho  *
   1263   1.1    jruoho  * PARAMETERS:  InputFilename       - The user-specified ASL source file to be
   1264   1.1    jruoho  *                                    compiled
   1265   1.1    jruoho  *
   1266   1.1    jruoho  * RETURN:      Status
   1267   1.1    jruoho  *
   1268   1.1    jruoho  * DESCRIPTION: Split the input path into a directory and filename part
   1269   1.1    jruoho  *              1) Directory part used to open include files
   1270   1.1    jruoho  *              2) Filename part used to generate output filenames
   1271   1.1    jruoho  *
   1272   1.1    jruoho  ******************************************************************************/
   1273   1.1    jruoho 
   1274   1.1    jruoho ACPI_STATUS
   1275   1.1    jruoho FlParseInputPathname (
   1276   1.1    jruoho     char                    *InputFilename)
   1277   1.1    jruoho {
   1278   1.1    jruoho     char                    *Substring;
   1279   1.1    jruoho 
   1280   1.1    jruoho 
   1281   1.1    jruoho     if (!InputFilename)
   1282   1.1    jruoho     {
   1283   1.1    jruoho         return (AE_OK);
   1284   1.1    jruoho     }
   1285   1.1    jruoho 
   1286   1.1    jruoho     /* Get the path to the input filename's directory */
   1287   1.1    jruoho 
   1288  1.12  christos     AslGbl_DirectoryPath = strdup (InputFilename);
   1289  1.12  christos     if (!AslGbl_DirectoryPath)
   1290   1.1    jruoho     {
   1291   1.1    jruoho         return (AE_NO_MEMORY);
   1292   1.1    jruoho     }
   1293   1.1    jruoho 
   1294  1.12  christos     Substring = strrchr (AslGbl_DirectoryPath, '\\');
   1295   1.1    jruoho     if (!Substring)
   1296   1.1    jruoho     {
   1297  1.12  christos         Substring = strrchr (AslGbl_DirectoryPath, '/');
   1298   1.1    jruoho         if (!Substring)
   1299   1.1    jruoho         {
   1300  1.12  christos             Substring = strrchr (AslGbl_DirectoryPath, ':');
   1301   1.1    jruoho         }
   1302   1.1    jruoho     }
   1303   1.1    jruoho 
   1304   1.1    jruoho     if (!Substring)
   1305   1.1    jruoho     {
   1306  1.12  christos         AslGbl_DirectoryPath[0] = 0;
   1307  1.12  christos         if (AslGbl_UseDefaultAmlFilename)
   1308   1.1    jruoho         {
   1309  1.12  christos             AslGbl_OutputFilenamePrefix = strdup (InputFilename);
   1310   1.1    jruoho         }
   1311   1.1    jruoho     }
   1312   1.1    jruoho     else
   1313   1.1    jruoho     {
   1314  1.12  christos         if (AslGbl_UseDefaultAmlFilename)
   1315   1.1    jruoho         {
   1316  1.12  christos             AslGbl_OutputFilenamePrefix = strdup (Substring + 1);
   1317   1.1    jruoho         }
   1318   1.1    jruoho         *(Substring+1) = 0;
   1319   1.1    jruoho     }
   1320   1.1    jruoho 
   1321  1.12  christos     UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
   1322   1.1    jruoho     return (AE_OK);
   1323   1.1    jruoho }
   1324   1.1    jruoho #endif
   1325