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