i386/identcpu.c: Add VIA Nano support
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / compiler / aslfiles.c
blob616fdd4bd40aa5b50c760a5a08989dae7c9dcb53
2 /******************************************************************************
4 * Module Name: aslfiles - file I/O suppoert
5 * $Revision: 1.53 $
7 *****************************************************************************/
9 /******************************************************************************
11 * 1. Copyright Notice
13 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
14 * All rights reserved.
16 * 2. License
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
42 * 3. Conditions
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
118 #include "aslcompiler.h"
119 #include "acapps.h"
121 #define _COMPONENT ACPI_COMPILER
122 ACPI_MODULE_NAME ("aslfiles")
124 /* Local prototypes */
126 static void
127 FlOpenFile (
128 UINT32 FileId,
129 char *Filename,
130 char *Mode);
132 static FILE *
133 FlOpenLocalFile (
134 char *LocalName,
135 char *Mode);
137 #ifdef ACPI_OBSOLETE_FUNCTIONS
138 ACPI_STATUS
139 FlParseInputPathname (
140 char *InputFilename);
141 #endif
144 /*******************************************************************************
146 * FUNCTION: AslAbort
148 * PARAMETERS: None
150 * RETURN: None
152 * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
153 * I/O errors
155 ******************************************************************************/
157 void
158 AslAbort (
159 void)
162 AePrintErrorLog (ASL_FILE_STDOUT);
163 if (Gbl_DebugFlag)
165 /* Print error summary to the debug file */
167 AePrintErrorLog (ASL_FILE_STDERR);
170 exit (1);
174 /*******************************************************************************
176 * FUNCTION: FlOpenLocalFile
178 * PARAMETERS: LocalName - Single filename (not a pathname)
179 * Mode - Open mode for fopen
181 * RETURN: File descriptor
183 * DESCRIPTION: Build a complete pathname for the input filename and open
184 * the file.
186 ******************************************************************************/
188 static FILE *
189 FlOpenLocalFile (
190 char *LocalName,
191 char *Mode)
194 strcpy (StringBuffer, Gbl_DirectoryPath);
195 strcat (StringBuffer, LocalName);
197 DbgPrint (ASL_PARSE_OUTPUT, "FlOpenLocalFile: %s\n", StringBuffer);
198 return (fopen (StringBuffer, (const char *) Mode));
202 /*******************************************************************************
204 * FUNCTION: FlFileError
206 * PARAMETERS: FileId - Index into file info array
207 * ErrorId - Index into error message array
209 * RETURN: None
211 * DESCRIPTION: Decode errno to an error message and add the entire error
212 * to the error log.
214 ******************************************************************************/
216 void
217 FlFileError (
218 UINT32 FileId,
219 UINT8 ErrorId)
222 sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename,
223 strerror (errno));
224 AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer);
228 /*******************************************************************************
230 * FUNCTION: FlOpenFile
232 * PARAMETERS: FileId - Index into file info array
233 * Filename - file pathname to open
234 * Mode - Open mode for fopen
236 * RETURN: None
238 * DESCRIPTION: Open a file.
239 * NOTE: Aborts compiler on any error.
241 ******************************************************************************/
243 static void
244 FlOpenFile (
245 UINT32 FileId,
246 char *Filename,
247 char *Mode)
249 FILE *File;
252 File = fopen (Filename, Mode);
254 Gbl_Files[FileId].Filename = Filename;
255 Gbl_Files[FileId].Handle = File;
257 if (!File)
259 FlFileError (FileId, ASL_MSG_OPEN);
260 AslAbort ();
265 /*******************************************************************************
267 * FUNCTION: FlReadFile
269 * PARAMETERS: FileId - Index into file info array
270 * Buffer - Where to place the data
271 * Length - Amount to read
273 * RETURN: Status. AE_ERROR indicates EOF.
275 * DESCRIPTION: Read data from an open file.
276 * NOTE: Aborts compiler on any error.
278 ******************************************************************************/
280 ACPI_STATUS
281 FlReadFile (
282 UINT32 FileId,
283 void *Buffer,
284 UINT32 Length)
286 UINT32 Actual;
289 /* Read and check for error */
291 Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle);
292 if (Actual != Length)
294 if (feof (Gbl_Files[FileId].Handle))
296 /* End-of-file, just return error */
298 return (AE_ERROR);
301 FlFileError (FileId, ASL_MSG_READ);
302 AslAbort ();
305 return (AE_OK);
309 /*******************************************************************************
311 * FUNCTION: FlWriteFile
313 * PARAMETERS: FileId - Index into file info array
314 * Buffer - Data to write
315 * Length - Amount of data to write
317 * RETURN: None
319 * DESCRIPTION: Write data to an open file.
320 * NOTE: Aborts compiler on any error.
322 ******************************************************************************/
324 void
325 FlWriteFile (
326 UINT32 FileId,
327 void *Buffer,
328 UINT32 Length)
330 UINT32 Actual;
333 /* Write and check for error */
335 Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle);
336 if (Actual != Length)
338 FlFileError (FileId, ASL_MSG_WRITE);
339 AslAbort ();
344 /*******************************************************************************
346 * FUNCTION: FlPrintFile
348 * PARAMETERS: FileId - Index into file info array
349 * Format - Printf format string
350 * ... - Printf arguments
352 * RETURN: None
354 * DESCRIPTION: Formatted write to an open file.
355 * NOTE: Aborts compiler on any error.
357 ******************************************************************************/
359 void
360 FlPrintFile (
361 UINT32 FileId,
362 char *Format,
363 ...)
365 INT32 Actual;
366 va_list Args;
369 va_start (Args, Format);
371 Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
372 if (Actual == -1)
374 FlFileError (FileId, ASL_MSG_WRITE);
375 AslAbort ();
380 /*******************************************************************************
382 * FUNCTION: FlSeekFile
384 * PARAMETERS: FileId - Index into file info array
385 * Offset - Absolute byte offset in file
387 * RETURN: None
389 * DESCRIPTION: Seek to absolute offset
390 * NOTE: Aborts compiler on any error.
392 ******************************************************************************/
394 void
395 FlSeekFile (
396 UINT32 FileId,
397 long Offset)
399 int Error;
402 Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
403 if (Error)
405 FlFileError (FileId, ASL_MSG_SEEK);
406 AslAbort ();
411 /*******************************************************************************
413 * FUNCTION: FlCloseFile
415 * PARAMETERS: FileId - Index into file info array
417 * RETURN: None
419 * DESCRIPTION: Close an open file. Aborts compiler on error
421 ******************************************************************************/
423 void
424 FlCloseFile (
425 UINT32 FileId)
427 int Error;
430 if (!Gbl_Files[FileId].Handle)
432 return;
435 Error = fclose (Gbl_Files[FileId].Handle);
436 Gbl_Files[FileId].Handle = NULL;
438 if (Error)
440 FlFileError (FileId, ASL_MSG_CLOSE);
441 AslAbort ();
444 return;
448 /*******************************************************************************
450 * FUNCTION: FlSetLineNumber
452 * PARAMETERS: Op - Parse node for the LINE asl statement
454 * RETURN: None.
456 * DESCRIPTION: Set the current line number
458 ******************************************************************************/
460 void
461 FlSetLineNumber (
462 ACPI_PARSE_OBJECT *Op)
465 Gbl_CurrentLineNumber = (UINT32) Op->Asl.Value.Integer;
466 Gbl_LogicalLineNumber = (UINT32) Op->Asl.Value.Integer;
470 /*******************************************************************************
472 * FUNCTION: FlOpenIncludeFile
474 * PARAMETERS: Op - Parse node for the INCLUDE ASL statement
476 * RETURN: None.
478 * DESCRIPTION: Open an include file and push it on the input file stack.
480 ******************************************************************************/
482 void
483 FlOpenIncludeFile (
484 ACPI_PARSE_OBJECT *Op)
486 FILE *IncFile;
489 /* Op must be valid */
491 if (!Op)
493 AslCommonError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN,
494 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
495 Gbl_InputByteCount, Gbl_CurrentColumn,
496 Gbl_Files[ASL_FILE_INPUT].Filename, " - Null parse node");
498 return;
502 * Flush out the "include ()" statement on this line, start
503 * the actual include file on the next line
505 ResetCurrentLineBuffer ();
506 FlPrintFile (ASL_FILE_SOURCE_OUTPUT, "\n");
507 Gbl_CurrentLineOffset++;
509 /* Prepend the directory pathname and open the include file */
511 DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n",
512 Op->Asl.Value.String);
513 IncFile = FlOpenLocalFile (Op->Asl.Value.String, "r");
514 if (!IncFile)
516 sprintf (MsgBuffer, "%s (%s)", Op->Asl.Value.String, strerror (errno));
517 AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, Op, MsgBuffer);
518 return;
521 /* Push the include file on the open input file stack */
523 AslPushInputFileStack (IncFile, Op->Asl.Value.String);
527 /*******************************************************************************
529 * FUNCTION: FlOpenInputFile
531 * PARAMETERS: InputFilename - The user-specified ASL source file to be
532 * compiled
534 * RETURN: Status
536 * DESCRIPTION: Open the specified input file, and save the directory path to
537 * the file so that include files can be opened in
538 * the same directory.
540 ******************************************************************************/
542 ACPI_STATUS
543 FlOpenInputFile (
544 char *InputFilename)
547 /* Open the input ASL file, text mode */
549 FlOpenFile (ASL_FILE_INPUT, InputFilename, "r");
550 AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
552 return (AE_OK);
556 /*******************************************************************************
558 * FUNCTION: FlOpenAmlOutputFile
560 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
562 * RETURN: Status
564 * DESCRIPTION: Create the output filename (*.AML) and open the file. The file
565 * is created in the same directory as the parent input file.
567 ******************************************************************************/
569 ACPI_STATUS
570 FlOpenAmlOutputFile (
571 char *FilenamePrefix)
573 char *Filename;
576 /* Output filename usually comes from the ASL itself */
578 Filename = Gbl_Files[ASL_FILE_AML_OUTPUT].Filename;
579 if (!Filename)
581 /* Create the output AML filename */
583 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
584 if (!Filename)
586 AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
587 0, 0, 0, 0, NULL, NULL);
588 return (AE_ERROR);
592 /* Open the output AML file in binary mode */
594 FlOpenFile (ASL_FILE_AML_OUTPUT, Filename, "w+b");
595 return (AE_OK);
599 /*******************************************************************************
601 * FUNCTION: FlOpenMiscOutputFiles
603 * PARAMETERS: FilenamePrefix - The user-specified ASL source file
605 * RETURN: Status
607 * DESCRIPTION: Create and open the various output files needed, depending on
608 * the command line options
610 ******************************************************************************/
612 ACPI_STATUS
613 FlOpenMiscOutputFiles (
614 char *FilenamePrefix)
616 char *Filename;
619 /* Create/Open a combined source output file */
621 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE);
622 if (!Filename)
624 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
625 0, 0, 0, 0, NULL, NULL);
626 return (AE_ERROR);
630 * Open the source output file, binary mode (so that LF does not get
631 * expanded to CR/LF on some systems, messing up our seek
632 * calculations.)
634 FlOpenFile (ASL_FILE_SOURCE_OUTPUT, Filename, "w+b");
636 /* Create/Open a listing output file if asked */
638 if (Gbl_ListingFlag)
640 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING);
641 if (!Filename)
643 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
644 0, 0, 0, 0, NULL, NULL);
645 return (AE_ERROR);
648 /* Open the listing file, text mode */
650 FlOpenFile (ASL_FILE_LISTING_OUTPUT, Filename, "w+");
652 AslCompilerSignon (ASL_FILE_LISTING_OUTPUT);
653 AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
656 /* Create/Open a assembly code source output file if asked */
658 if (Gbl_AsmOutputFlag)
660 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE);
661 if (!Filename)
663 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
664 0, 0, 0, 0, NULL, NULL);
665 return (AE_ERROR);
668 /* Open the assembly code source file, text mode */
670 FlOpenFile (ASL_FILE_ASM_SOURCE_OUTPUT, Filename, "w+");
672 AslCompilerSignon (ASL_FILE_ASM_SOURCE_OUTPUT);
673 AslCompilerFileHeader (ASL_FILE_ASM_SOURCE_OUTPUT);
676 /* Create/Open a C code source output file if asked */
678 if (Gbl_C_OutputFlag)
680 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE);
681 if (!Filename)
683 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
684 0, 0, 0, 0, NULL, NULL);
685 return (AE_ERROR);
688 /* Open the C code source file, text mode */
690 FlOpenFile (ASL_FILE_C_SOURCE_OUTPUT, Filename, "w+");
692 FlPrintFile (ASL_FILE_C_SOURCE_OUTPUT, "/*\n");
693 AslCompilerSignon (ASL_FILE_C_SOURCE_OUTPUT);
694 AslCompilerFileHeader (ASL_FILE_C_SOURCE_OUTPUT);
697 /* Create/Open a assembly include output file if asked */
699 if (Gbl_AsmIncludeOutputFlag)
701 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE);
702 if (!Filename)
704 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
705 0, 0, 0, 0, NULL, NULL);
706 return (AE_ERROR);
709 /* Open the assembly include file, text mode */
711 FlOpenFile (ASL_FILE_ASM_INCLUDE_OUTPUT, Filename, "w+");
713 AslCompilerSignon (ASL_FILE_ASM_INCLUDE_OUTPUT);
714 AslCompilerFileHeader (ASL_FILE_ASM_INCLUDE_OUTPUT);
717 /* Create/Open a C include output file if asked */
719 if (Gbl_C_IncludeOutputFlag)
721 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE);
722 if (!Filename)
724 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
725 0, 0, 0, 0, NULL, NULL);
726 return (AE_ERROR);
729 /* Open the C include file, text mode */
731 FlOpenFile (ASL_FILE_C_INCLUDE_OUTPUT, Filename, "w+");
733 FlPrintFile (ASL_FILE_C_INCLUDE_OUTPUT, "/*\n");
734 AslCompilerSignon (ASL_FILE_C_INCLUDE_OUTPUT);
735 AslCompilerFileHeader (ASL_FILE_C_INCLUDE_OUTPUT);
738 /* Create/Open a hex output file if asked */
740 if (Gbl_HexOutputFlag)
742 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP);
743 if (!Filename)
745 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
746 0, 0, 0, 0, NULL, NULL);
747 return (AE_ERROR);
750 /* Open the hex file, text mode */
752 FlOpenFile (ASL_FILE_HEX_OUTPUT, Filename, "w+");
754 AslCompilerSignon (ASL_FILE_HEX_OUTPUT);
755 AslCompilerFileHeader (ASL_FILE_HEX_OUTPUT);
758 /* Create a namespace output file if asked */
760 if (Gbl_NsOutputFlag)
762 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE);
763 if (!Filename)
765 AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
766 0, 0, 0, 0, NULL, NULL);
767 return (AE_ERROR);
770 /* Open the namespace file, text mode */
772 FlOpenFile (ASL_FILE_NAMESPACE_OUTPUT, Filename, "w+");
774 AslCompilerSignon (ASL_FILE_NAMESPACE_OUTPUT);
775 AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
778 /* Create/Open a debug output file if asked */
780 if (Gbl_DebugFlag)
782 Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG);
783 if (!Filename)
785 AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME,
786 0, 0, 0, 0, NULL, NULL);
787 return (AE_ERROR);
790 /* Open the debug file as STDERR, text mode */
792 /* TBD: hide this behind a FlReopenFile function */
794 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
795 Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
796 freopen (Filename, "w+t", stderr);
798 AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
799 AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT);
802 return (AE_OK);
806 #ifdef ACPI_OBSOLETE_FUNCTIONS
807 /*******************************************************************************
809 * FUNCTION: FlParseInputPathname
811 * PARAMETERS: InputFilename - The user-specified ASL source file to be
812 * compiled
814 * RETURN: Status
816 * DESCRIPTION: Split the input path into a directory and filename part
817 * 1) Directory part used to open include files
818 * 2) Filename part used to generate output filenames
820 ******************************************************************************/
822 ACPI_STATUS
823 FlParseInputPathname (
824 char *InputFilename)
826 char *Substring;
829 if (!InputFilename)
831 return (AE_OK);
834 /* Get the path to the input filename's directory */
836 Gbl_DirectoryPath = strdup (InputFilename);
837 if (!Gbl_DirectoryPath)
839 return (AE_NO_MEMORY);
842 Substring = strrchr (Gbl_DirectoryPath, '\\');
843 if (!Substring)
845 Substring = strrchr (Gbl_DirectoryPath, '/');
846 if (!Substring)
848 Substring = strrchr (Gbl_DirectoryPath, ':');
852 if (!Substring)
854 Gbl_DirectoryPath[0] = 0;
855 if (Gbl_UseDefaultAmlFilename)
857 Gbl_OutputFilenamePrefix = strdup (InputFilename);
860 else
862 if (Gbl_UseDefaultAmlFilename)
864 Gbl_OutputFilenamePrefix = strdup (Substring + 1);
866 *(Substring+1) = 0;
869 return (AE_OK);
871 #endif