asloptions.c revision 1.8
1/****************************************************************************** 2 * 3 * Module Name: asloptions - compiler command line processing 4 * 5 *****************************************************************************/ 6 7/* 8 * Copyright (C) 2000 - 2018, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44#include "aslcompiler.h" 45#include "acapps.h" 46#include "acdisasm.h" 47 48#define _COMPONENT ACPI_COMPILER 49 ACPI_MODULE_NAME ("asloption") 50 51 52/* Local prototypes */ 53 54static int 55AslDoOptions ( 56 int argc, 57 char **argv, 58 BOOLEAN IsResponseFile); 59 60static void 61AslMergeOptionTokens ( 62 char *InBuffer, 63 char *OutBuffer); 64 65static int 66AslDoResponseFile ( 67 char *Filename); 68 69 70#define ASL_TOKEN_SEPARATORS " \t\n" 71#define ASL_SUPPORTED_OPTIONS "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|t|T+G^v^w|x:z" 72 73 74/******************************************************************************* 75 * 76 * FUNCTION: AslCommandLine 77 * 78 * PARAMETERS: argc/argv 79 * 80 * RETURN: Last argv index 81 * 82 * DESCRIPTION: Command line processing 83 * 84 ******************************************************************************/ 85 86int 87AslCommandLine ( 88 int argc, 89 char **argv) 90{ 91 int BadCommandLine = 0; 92 ACPI_STATUS Status; 93 94 95 /* Minimum command line contains at least the command and an input file */ 96 97 if (argc < 2) 98 { 99 Usage (); 100 exit (1); 101 } 102 103 /* Process all command line options */ 104 105 BadCommandLine = AslDoOptions (argc, argv, FALSE); 106 107 if (Gbl_DoTemplates) 108 { 109 Status = DtCreateTemplates (argv); 110 if (ACPI_FAILURE (Status)) 111 { 112 exit (-1); 113 } 114 exit (1); 115 } 116 117 /* Next parameter must be the input filename */ 118 119 if (!argv[AcpiGbl_Optind] && 120 !AcpiGbl_DisasmFlag) 121 { 122 printf ("Missing input filename\n"); 123 BadCommandLine = TRUE; 124 } 125 126 if (Gbl_DoSignon) 127 { 128 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 129 if (Gbl_IgnoreErrors) 130 { 131 printf ("Ignoring all errors, forcing AML file generation\n\n"); 132 } 133 } 134 135 if (BadCommandLine) 136 { 137 printf ("Use -h option for help information\n"); 138 exit (1); 139 } 140 141 return (AcpiGbl_Optind); 142} 143 144 145/******************************************************************************* 146 * 147 * FUNCTION: AslDoOptions 148 * 149 * PARAMETERS: argc/argv - Standard argc/argv 150 * IsResponseFile - TRUE if executing a response file. 151 * 152 * RETURN: Status 153 * 154 * DESCRIPTION: Command line option processing 155 * 156 ******************************************************************************/ 157 158static int 159AslDoOptions ( 160 int argc, 161 char **argv, 162 BOOLEAN IsResponseFile) 163{ 164 ACPI_STATUS Status; 165 UINT32 j; 166 167 168 /* Get the command line options */ 169 170 while ((j = AcpiGetopt (argc, argv, ASL_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) 171 { 172 case '@': /* Begin a response file */ 173 174 if (IsResponseFile) 175 { 176 printf ("Nested command files are not supported\n"); 177 return (-1); 178 } 179 180 if (AslDoResponseFile (AcpiGbl_Optarg)) 181 { 182 return (-1); 183 } 184 break; 185 186 case 'a': /* Debug options */ 187 188 switch (AcpiGbl_Optarg[0]) 189 { 190 case 'r': 191 192 Gbl_EnableReferenceTypechecking = TRUE; 193 break; 194 195 default: 196 197 printf ("Unknown option: -a%s\n", AcpiGbl_Optarg); 198 return (-1); 199 } 200 201 break; 202 203 204 case 'b': /* Debug options */ 205 206 switch (AcpiGbl_Optarg[0]) 207 { 208 209 case 'c': 210 211 printf ("Debug ASL to ASL+ conversion\n"); 212 213 Gbl_DoAslConversion = TRUE; 214 Gbl_FoldConstants = FALSE; 215 Gbl_IntegerOptimizationFlag = FALSE; 216 Gbl_ReferenceOptimizationFlag = FALSE; 217 Gbl_OptimizeTrivialParseNodes = FALSE; 218 AcpiGbl_CaptureComments = TRUE; 219 AcpiGbl_DoDisassemblerOptimizations = FALSE; 220 AcpiGbl_DebugAslConversion = TRUE; 221 AcpiGbl_DmEmitExternalOpcodes = TRUE; 222 Gbl_DoExternalsInPlace = TRUE; 223 224 return (0); 225 226 case 'f': 227 228 AslCompilerdebug = 1; /* same as yydebug */ 229 DtParserdebug = 1; 230 PrParserdebug = 1; 231 Gbl_DebugFlag = TRUE; 232 Gbl_KeepPreprocessorTempFile = TRUE; 233 break; 234 235 case 'p': /* Prune ASL parse tree */ 236 237 /* Get the required argument */ 238 239 if (AcpiGetoptArgument (argc, argv)) 240 { 241 return (-1); 242 } 243 244 Gbl_PruneParseTree = TRUE; 245 Gbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 246 break; 247 248 case 's': 249 250 Gbl_DebugFlag = TRUE; 251 break; 252 253 case 't': 254 255 /* Get the required argument */ 256 257 if (AcpiGetoptArgument (argc, argv)) 258 { 259 return (-1); 260 } 261 262 Gbl_PruneType = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 263 break; 264 265 default: 266 267 printf ("Unknown option: -b%s\n", AcpiGbl_Optarg); 268 return (-1); 269 } 270 271 break; 272 273 case 'c': 274 275 switch (AcpiGbl_Optarg[0]) 276 { 277 278 case 'a': 279 280 printf ("Convert ASL to ASL+ with comments\n"); 281 Gbl_DoAslConversion = TRUE; 282 Gbl_FoldConstants = FALSE; 283 Gbl_IntegerOptimizationFlag = FALSE; 284 Gbl_ReferenceOptimizationFlag = FALSE; 285 Gbl_OptimizeTrivialParseNodes = FALSE; 286 AcpiGbl_CaptureComments = TRUE; 287 AcpiGbl_DoDisassemblerOptimizations = FALSE; 288 AcpiGbl_DmEmitExternalOpcodes = TRUE; 289 Gbl_DoExternalsInPlace = TRUE; 290 291 return (0); 292 293 case 'r': 294 295 Gbl_NoResourceChecking = TRUE; 296 break; 297 298 default: 299 300 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 301 return (-1); 302 } 303 break; 304 305 case 'd': /* Disassembler */ 306 307 switch (AcpiGbl_Optarg[0]) 308 { 309 case '^': 310 311 Gbl_DoCompile = FALSE; 312 break; 313 314 case 'a': 315 316 Gbl_DoCompile = FALSE; 317 Gbl_DisassembleAll = TRUE; 318 break; 319 320 case 'b': /* Do not convert buffers to resource descriptors */ 321 322 AcpiGbl_NoResourceDisassembly = TRUE; 323 break; 324 325 case 'c': 326 327 break; 328 329 case 'f': 330 331 AcpiGbl_ForceAmlDisassembly = TRUE; 332 break; 333 334 case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ 335 336 Gbl_DoCompile = FALSE; 337 AcpiGbl_CstyleDisassembly = FALSE; 338 break; 339 340 default: 341 342 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 343 return (-1); 344 } 345 346 AcpiGbl_DisasmFlag = TRUE; 347 break; 348 349 case 'D': /* Define a symbol */ 350 351 PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 352 break; 353 354 case 'e': /* External files for disassembler */ 355 356 /* Get entire list of external files */ 357 358 AcpiGbl_Optind--; 359 argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 360 361 while (argv[AcpiGbl_Optind] && 362 (argv[AcpiGbl_Optind][0] != '-')) 363 { 364 Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 365 if (ACPI_FAILURE (Status)) 366 { 367 printf ("Could not add %s to external list\n", 368 argv[AcpiGbl_Optind]); 369 return (-1); 370 } 371 372 AcpiGbl_Optind++; 373 } 374 break; 375 376 case 'f': 377 378 switch (AcpiGbl_Optarg[0]) 379 { 380 case '^': /* Ignore errors and force creation of aml file */ 381 382 Gbl_IgnoreErrors = TRUE; 383 break; 384 385 case 'e': /* Disassembler: Get external declaration file */ 386 387 if (AcpiGetoptArgument (argc, argv)) 388 { 389 return (-1); 390 } 391 392 Gbl_ExternalRefFilename = AcpiGbl_Optarg; 393 break; 394 395 default: 396 397 printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 398 return (-1); 399 } 400 break; 401 402 case 'G': 403 404 Gbl_CompileGeneric = TRUE; 405 break; 406 407 case 'g': /* Get all ACPI tables */ 408 409 printf ("-g option is deprecated, use acpidump utility instead\n"); 410 exit (1); 411 412 case 'h': 413 414 switch (AcpiGbl_Optarg[0]) 415 { 416 case '^': 417 418 Usage (); 419 exit (0); 420 421 case 'c': 422 423 UtDisplayConstantOpcodes (); 424 exit (0); 425 426 case 'd': 427 428 AslDisassemblyHelp (); 429 exit (0); 430 431 case 'f': 432 433 AslFilenameHelp (); 434 exit (0); 435 436 case 'r': 437 438 /* reserved names */ 439 440 ApDisplayReservedNames (); 441 exit (0); 442 443 case 't': 444 445 UtDisplaySupportedTables (); 446 exit (0); 447 448 default: 449 450 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 451 return (-1); 452 } 453 454 case 'I': /* Add an include file search directory */ 455 456 FlAddIncludeDirectory (AcpiGbl_Optarg); 457 break; 458 459 case 'i': /* Output AML as an include file */ 460 461 switch (AcpiGbl_Optarg[0]) 462 { 463 case 'a': 464 465 /* Produce assembly code include file */ 466 467 Gbl_AsmIncludeOutputFlag = TRUE; 468 break; 469 470 case 'c': 471 472 /* Produce C include file */ 473 474 Gbl_C_IncludeOutputFlag = TRUE; 475 break; 476 477 case 'n': 478 479 /* Compiler/Disassembler: Ignore the NOOP operator */ 480 481 AcpiGbl_IgnoreNoopOperator = TRUE; 482 break; 483 484 default: 485 486 printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 487 return (-1); 488 } 489 break; 490 491 case 'l': /* Listing files */ 492 493 switch (AcpiGbl_Optarg[0]) 494 { 495 case '^': 496 497 /* Produce listing file (Mixed source/aml) */ 498 499 Gbl_ListingFlag = TRUE; 500 AcpiGbl_DmOpt_Listing = TRUE; 501 break; 502 503 case 'i': 504 505 /* Produce preprocessor output file */ 506 507 Gbl_PreprocessorOutputFlag = TRUE; 508 break; 509 510 case 'm': 511 512 /* Produce hardware map summary file */ 513 514 Gbl_MapfileFlag = TRUE; 515 break; 516 517 case 'n': 518 519 /* Produce namespace file */ 520 521 Gbl_NsOutputFlag = TRUE; 522 break; 523 524 case 's': 525 526 /* Produce combined source file */ 527 528 Gbl_SourceOutputFlag = TRUE; 529 break; 530 531 case 'x': 532 533 /* Produce cross-reference file */ 534 535 Gbl_CrossReferenceOutput = TRUE; 536 break; 537 538 default: 539 540 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 541 return (-1); 542 } 543 break; 544 545 case 'm': /* Set line buffer size */ 546 547 Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 548 if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 549 { 550 Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 551 } 552 printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 553 break; 554 555 case 'n': /* Parse only */ 556 557 Gbl_ParseOnlyFlag = TRUE; 558 break; 559 560 case 'o': /* Control compiler AML optimizations */ 561 562 switch (AcpiGbl_Optarg[0]) 563 { 564 case 'a': 565 566 /* Disable all optimizations */ 567 568 Gbl_FoldConstants = FALSE; 569 Gbl_IntegerOptimizationFlag = FALSE; 570 Gbl_ReferenceOptimizationFlag = FALSE; 571 Gbl_OptimizeTrivialParseNodes = FALSE; 572 573 break; 574 575 case 'c': 576 577 /* Display compile time(s) */ 578 579 Gbl_CompileTimesFlag = TRUE; 580 break; 581 582 case 'd': 583 584 /* Disable disassembler code optimizations */ 585 586 AcpiGbl_DoDisassemblerOptimizations = FALSE; 587 break; 588 589 case 'e': 590 591 /* Disassembler: Emit embedded external operators */ 592 593 AcpiGbl_DmEmitExternalOpcodes = TRUE; 594 break; 595 596 case 'E': 597 598 /* 599 * iASL: keep External opcodes in place. 600 * No affect if Gbl_DoExternals is false. 601 */ 602 603 Gbl_DoExternalsInPlace = TRUE; 604 break; 605 606 case 'f': 607 608 /* Disable folding on "normal" expressions */ 609 610 Gbl_FoldConstants = FALSE; 611 break; 612 613 case 'i': 614 615 /* Disable integer optimization to constants */ 616 617 Gbl_IntegerOptimizationFlag = FALSE; 618 break; 619 620 case 'n': 621 622 /* Disable named reference optimization */ 623 624 Gbl_ReferenceOptimizationFlag = FALSE; 625 break; 626 627 case 't': 628 629 /* Disable heavy typechecking */ 630 631 Gbl_DoTypechecking = FALSE; 632 break; 633 634 default: 635 636 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 637 return (-1); 638 } 639 break; 640 641 case 'P': /* Preprocessor options */ 642 643 switch (AcpiGbl_Optarg[0]) 644 { 645 case '^': /* Proprocess only, emit (.i) file */ 646 647 Gbl_PreprocessOnly = TRUE; 648 Gbl_PreprocessorOutputFlag = TRUE; 649 break; 650 651 case 'n': /* Disable preprocessor */ 652 653 Gbl_PreprocessFlag = FALSE; 654 break; 655 656 default: 657 658 printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 659 return (-1); 660 } 661 break; 662 663 case 'p': /* Override default AML output filename */ 664 665 Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 666 UtConvertBackslashes (Gbl_OutputFilenamePrefix); 667 Gbl_UseDefaultAmlFilename = FALSE; 668 break; 669 670 case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */ 671 672 printf ("Convert ASL to ASL+ with comments\n"); 673 Gbl_FoldConstants = FALSE; 674 Gbl_IntegerOptimizationFlag = FALSE; 675 Gbl_ReferenceOptimizationFlag = FALSE; 676 Gbl_OptimizeTrivialParseNodes = FALSE; 677 Gbl_DoExternalsInPlace = TRUE; 678 AcpiGbl_CaptureComments = TRUE; 679 return (0); 680 681 case 'r': /* Override revision found in table header */ 682 683 Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 684 break; 685 686 case 's': /* Create AML in a source code file */ 687 688 switch (AcpiGbl_Optarg[0]) 689 { 690 case 'a': 691 692 /* Produce assembly code output file */ 693 694 Gbl_AsmOutputFlag = TRUE; 695 break; 696 697 case 'c': 698 699 /* Produce C hex output file */ 700 701 Gbl_C_OutputFlag = TRUE; 702 break; 703 704 case 'o': 705 706 /* Produce AML offset table in C */ 707 708 Gbl_C_OffsetTableFlag = TRUE; 709 break; 710 711 default: 712 713 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 714 return (-1); 715 } 716 break; 717 718 case 't': /* Produce hex table output file */ 719 720 switch (AcpiGbl_Optarg[0]) 721 { 722 case 'a': 723 724 Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 725 break; 726 727 case 'c': 728 729 Gbl_HexOutputFlag = HEX_OUTPUT_C; 730 break; 731 732 case 's': 733 734 Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 735 break; 736 737 default: 738 739 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 740 return (-1); 741 } 742 break; 743 744 case 'T': /* Create a ACPI table template file */ 745 746 Gbl_DoTemplates = TRUE; 747 break; 748 749 case 'v': /* Version and verbosity settings */ 750 751 switch (AcpiGbl_Optarg[0]) 752 { 753 case '^': 754 755 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 756 exit (0); 757 758 case 'a': 759 760 /* Disable all error/warning/remark messages */ 761 762 Gbl_NoErrors = TRUE; 763 break; 764 765 case 'd': 766 767 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 768 printf (ACPI_COMMON_BUILD_TIME); 769 exit (0); 770 771 case 'e': 772 773 /* Disable all warning/remark messages (errors only) */ 774 775 Gbl_DisplayRemarks = FALSE; 776 Gbl_DisplayWarnings = FALSE; 777 break; 778 779 case 'i': 780 /* 781 * Support for integrated development environment(s). 782 * 783 * 1) No compiler signon 784 * 2) Send stderr messages to stdout 785 * 3) Less verbose error messages (single line only for each) 786 * 4) Error/warning messages are formatted appropriately to 787 * be recognized by MS Visual Studio 788 */ 789 Gbl_VerboseErrors = FALSE; 790 Gbl_DoSignon = FALSE; 791 Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 792 break; 793 794 case 'o': 795 796 Gbl_DisplayOptimizations = TRUE; 797 break; 798 799 case 'r': 800 801 Gbl_DisplayRemarks = FALSE; 802 break; 803 804 case 's': 805 806 Gbl_DoSignon = FALSE; 807 break; 808 809 case 't': 810 811 Gbl_VerboseTemplates = TRUE; 812 break; 813 814 case 'w': 815 816 /* Get the required argument */ 817 818 if (AcpiGetoptArgument (argc, argv)) 819 { 820 return (-1); 821 } 822 823 Status = AslDisableException (AcpiGbl_Optarg); 824 if (ACPI_FAILURE (Status)) 825 { 826 return (-1); 827 } 828 break; 829 830 case 'x': 831 832 /* Get the required argument */ 833 834 if (AcpiGetoptArgument (argc, argv)) 835 { 836 return (-1); 837 } 838 839 Status = AslExpectException (AcpiGbl_Optarg); 840 if (ACPI_FAILURE (Status)) 841 { 842 return (-1); 843 } 844 break; 845 846 default: 847 848 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 849 return (-1); 850 } 851 break; 852 853 case 'w': /* Set warning levels */ 854 855 switch (AcpiGbl_Optarg[0]) 856 { 857 case '1': 858 859 Gbl_WarningLevel = ASL_WARNING; 860 break; 861 862 case '2': 863 864 Gbl_WarningLevel = ASL_WARNING2; 865 break; 866 867 case '3': 868 869 Gbl_WarningLevel = ASL_WARNING3; 870 break; 871 872 case 'e': 873 874 Gbl_WarningsAsErrors = TRUE; 875 break; 876 877 default: 878 879 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 880 return (-1); 881 } 882 break; 883 884 case 'x': /* Set debug print output level */ 885 886 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 887 break; 888 889 case 'z': 890 891 Gbl_UseOriginalCompilerId = TRUE; 892 break; 893 894 default: 895 896 return (-1); 897 } 898 899 return (0); 900} 901 902 903/******************************************************************************* 904 * 905 * FUNCTION: AslMergeOptionTokens 906 * 907 * PARAMETERS: InBuffer - Input containing an option string 908 * OutBuffer - Merged output buffer 909 * 910 * RETURN: None 911 * 912 * DESCRIPTION: Remove all whitespace from an option string. 913 * 914 ******************************************************************************/ 915 916static void 917AslMergeOptionTokens ( 918 char *InBuffer, 919 char *OutBuffer) 920{ 921 char *Token; 922 923 924 *OutBuffer = 0; 925 926 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 927 while (Token) 928 { 929 strcat (OutBuffer, Token); 930 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 931 } 932} 933 934 935/******************************************************************************* 936 * 937 * FUNCTION: AslDoResponseFile 938 * 939 * PARAMETERS: Filename - Name of the response file 940 * 941 * RETURN: Status 942 * 943 * DESCRIPTION: Open a response file and process all options within. 944 * 945 ******************************************************************************/ 946 947static int 948AslDoResponseFile ( 949 char *Filename) 950{ 951 char *argv = StringBuffer2; 952 FILE *ResponseFile; 953 int OptStatus = 0; 954 int Opterr; 955 int Optind; 956 957 958 ResponseFile = fopen (Filename, "r"); 959 if (!ResponseFile) 960 { 961 printf ("Could not open command file %s, %s\n", 962 Filename, strerror (errno)); 963 return (-1); 964 } 965 966 /* Must save the current GetOpt globals */ 967 968 Opterr = AcpiGbl_Opterr; 969 Optind = AcpiGbl_Optind; 970 971 /* 972 * Process all lines in the response file. There must be one complete 973 * option per line 974 */ 975 while (fgets (StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile)) 976 { 977 /* Compress all tokens, allowing us to use a single argv entry */ 978 979 AslMergeOptionTokens (StringBuffer, StringBuffer2); 980 981 /* Process the option */ 982 983 AcpiGbl_Opterr = 0; 984 AcpiGbl_Optind = 0; 985 986 OptStatus = AslDoOptions (1, &argv, TRUE); 987 if (OptStatus) 988 { 989 printf ("Invalid option in command file %s: %s\n", 990 Filename, StringBuffer); 991 break; 992 } 993 } 994 995 /* Restore the GetOpt globals */ 996 997 AcpiGbl_Opterr = Opterr; 998 AcpiGbl_Optind = Optind; 999 1000 fclose (ResponseFile); 1001 return (OptStatus); 1002} 1003