asloptions.c revision 1.6
1/****************************************************************************** 2 * 3 * Module Name: asloptions - compiler command line processing 4 * 5 *****************************************************************************/ 6 7/* 8 * Copyright (C) 2000 - 2017, 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 Gbl_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 Gbl_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 /* Get the required argument */ 312 313 if (AcpiGetoptArgument (argc, argv)) 314 { 315 return (-1); 316 } 317 318 Gbl_DoCompile = FALSE; 319 break; 320 321 case 'a': 322 323 /* Get the required argument */ 324 325 if (AcpiGetoptArgument (argc, argv)) 326 { 327 return (-1); 328 } 329 330 Gbl_DoCompile = FALSE; 331 Gbl_DisassembleAll = TRUE; 332 break; 333 334 case 'b': /* Do not convert buffers to resource descriptors */ 335 336 AcpiGbl_NoResourceDisassembly = TRUE; 337 break; 338 339 case 'c': 340 341 break; 342 343 case 'f': 344 345 AcpiGbl_ForceAmlDisassembly = TRUE; 346 break; 347 348 case 'l': /* Use legacy ASL code (not ASL+) for disassembly */ 349 350 Gbl_DoCompile = FALSE; 351 AcpiGbl_CstyleDisassembly = FALSE; 352 break; 353 354 default: 355 356 printf ("Unknown option: -d%s\n", AcpiGbl_Optarg); 357 return (-1); 358 } 359 360 AcpiGbl_DisasmFlag = TRUE; 361 break; 362 363 case 'D': /* Define a symbol */ 364 365 PrAddDefine (AcpiGbl_Optarg, NULL, TRUE); 366 break; 367 368 case 'e': /* External files for disassembler */ 369 370 /* Get entire list of external files */ 371 372 AcpiGbl_Optind--; 373 argv[AcpiGbl_Optind] = AcpiGbl_Optarg; 374 375 while (argv[AcpiGbl_Optind] && 376 (argv[AcpiGbl_Optind][0] != '-')) 377 { 378 Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]); 379 if (ACPI_FAILURE (Status)) 380 { 381 printf ("Could not add %s to external list\n", 382 argv[AcpiGbl_Optind]); 383 return (-1); 384 } 385 386 AcpiGbl_Optind++; 387 } 388 break; 389 390 case 'f': 391 392 switch (AcpiGbl_Optarg[0]) 393 { 394 case '^': /* Ignore errors and force creation of aml file */ 395 396 Gbl_IgnoreErrors = TRUE; 397 break; 398 399 case 'e': /* Disassembler: Get external declaration file */ 400 401 if (AcpiGetoptArgument (argc, argv)) 402 { 403 return (-1); 404 } 405 406 Gbl_ExternalRefFilename = AcpiGbl_Optarg; 407 break; 408 409 default: 410 411 printf ("Unknown option: -f%s\n", AcpiGbl_Optarg); 412 return (-1); 413 } 414 break; 415 416 case 'G': 417 418 Gbl_CompileGeneric = TRUE; 419 break; 420 421 case 'g': /* Get all ACPI tables */ 422 423 printf ("-g option is deprecated, use acpidump utility instead\n"); 424 exit (1); 425 426 case 'h': 427 428 switch (AcpiGbl_Optarg[0]) 429 { 430 case '^': 431 432 Usage (); 433 exit (0); 434 435 case 'c': 436 437 UtDisplayConstantOpcodes (); 438 exit (0); 439 440 case 'd': 441 442 AslDisassemblyHelp (); 443 exit (0); 444 445 case 'f': 446 447 AslFilenameHelp (); 448 exit (0); 449 450 case 'r': 451 452 /* reserved names */ 453 454 ApDisplayReservedNames (); 455 exit (0); 456 457 case 't': 458 459 UtDisplaySupportedTables (); 460 exit (0); 461 462 default: 463 464 printf ("Unknown option: -h%s\n", AcpiGbl_Optarg); 465 return (-1); 466 } 467 468 case 'I': /* Add an include file search directory */ 469 470 FlAddIncludeDirectory (AcpiGbl_Optarg); 471 break; 472 473 case 'i': /* Output AML as an include file */ 474 475 switch (AcpiGbl_Optarg[0]) 476 { 477 case 'a': 478 479 /* Produce assembly code include file */ 480 481 Gbl_AsmIncludeOutputFlag = TRUE; 482 break; 483 484 case 'c': 485 486 /* Produce C include file */ 487 488 Gbl_C_IncludeOutputFlag = TRUE; 489 break; 490 491 case 'n': 492 493 /* Compiler/Disassembler: Ignore the NOOP operator */ 494 495 AcpiGbl_IgnoreNoopOperator = TRUE; 496 break; 497 498 default: 499 500 printf ("Unknown option: -i%s\n", AcpiGbl_Optarg); 501 return (-1); 502 } 503 break; 504 505 case 'l': /* Listing files */ 506 507 switch (AcpiGbl_Optarg[0]) 508 { 509 case '^': 510 511 /* Produce listing file (Mixed source/aml) */ 512 513 Gbl_ListingFlag = TRUE; 514 AcpiGbl_DmOpt_Listing = TRUE; 515 break; 516 517 case 'i': 518 519 /* Produce preprocessor output file */ 520 521 Gbl_PreprocessorOutputFlag = TRUE; 522 break; 523 524 case 'm': 525 526 /* Produce hardware map summary file */ 527 528 Gbl_MapfileFlag = TRUE; 529 break; 530 531 case 'n': 532 533 /* Produce namespace file */ 534 535 Gbl_NsOutputFlag = TRUE; 536 break; 537 538 case 's': 539 540 /* Produce combined source file */ 541 542 Gbl_SourceOutputFlag = TRUE; 543 break; 544 545 case 'x': 546 547 /* Produce cross-reference file */ 548 549 Gbl_CrossReferenceOutput = TRUE; 550 break; 551 552 default: 553 554 printf ("Unknown option: -l%s\n", AcpiGbl_Optarg); 555 return (-1); 556 } 557 break; 558 559 case 'm': /* Set line buffer size */ 560 561 Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; 562 if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) 563 { 564 Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; 565 } 566 printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); 567 break; 568 569 case 'n': /* Parse only */ 570 571 Gbl_ParseOnlyFlag = TRUE; 572 break; 573 574 case 'o': /* Control compiler AML optimizations */ 575 576 switch (AcpiGbl_Optarg[0]) 577 { 578 case 'a': 579 580 /* Disable all optimizations */ 581 582 Gbl_FoldConstants = FALSE; 583 Gbl_IntegerOptimizationFlag = FALSE; 584 Gbl_ReferenceOptimizationFlag = FALSE; 585 Gbl_OptimizeTrivialParseNodes = FALSE; 586 587 break; 588 589 case 'c': 590 591 /* Display compile time(s) */ 592 593 Gbl_CompileTimesFlag = TRUE; 594 break; 595 596 case 'd': 597 598 /* Disable disassembler code optimizations */ 599 600 AcpiGbl_DoDisassemblerOptimizations = FALSE; 601 break; 602 603 case 'e': 604 605 /* Disassembler: Emit embedded external operators */ 606 607 AcpiGbl_DmEmitExternalOpcodes = TRUE; 608 break; 609 610 case 'E': 611 612 /* 613 * iASL: keep External opcodes in place. 614 * No affect if Gbl_DoExternals is false. 615 */ 616 617 Gbl_DoExternalsInPlace = TRUE; 618 break; 619 620 case 'f': 621 622 /* Disable folding on "normal" expressions */ 623 624 Gbl_FoldConstants = FALSE; 625 break; 626 627 case 'i': 628 629 /* Disable integer optimization to constants */ 630 631 Gbl_IntegerOptimizationFlag = FALSE; 632 break; 633 634 case 'n': 635 636 /* Disable named reference optimization */ 637 638 Gbl_ReferenceOptimizationFlag = FALSE; 639 break; 640 641 case 't': 642 643 /* Disable heavy typechecking */ 644 645 Gbl_DoTypechecking = FALSE; 646 break; 647 648 default: 649 650 printf ("Unknown option: -c%s\n", AcpiGbl_Optarg); 651 return (-1); 652 } 653 break; 654 655 case 'P': /* Preprocessor options */ 656 657 switch (AcpiGbl_Optarg[0]) 658 { 659 case '^': /* Proprocess only, emit (.i) file */ 660 661 Gbl_PreprocessOnly = TRUE; 662 Gbl_PreprocessorOutputFlag = TRUE; 663 break; 664 665 case 'n': /* Disable preprocessor */ 666 667 Gbl_PreprocessFlag = FALSE; 668 break; 669 670 default: 671 672 printf ("Unknown option: -P%s\n", AcpiGbl_Optarg); 673 return (-1); 674 } 675 break; 676 677 case 'p': /* Override default AML output filename */ 678 679 Gbl_OutputFilenamePrefix = AcpiGbl_Optarg; 680 UtConvertBackslashes (Gbl_OutputFilenamePrefix); 681 Gbl_UseDefaultAmlFilename = FALSE; 682 break; 683 684 case 'q': /* ASL/ASl+ converter: compile only and leave badaml. */ 685 686 printf ("Convert ASL to ASL+ with comments\n"); 687 Gbl_FoldConstants = FALSE; 688 Gbl_IntegerOptimizationFlag = FALSE; 689 Gbl_ReferenceOptimizationFlag = FALSE; 690 Gbl_OptimizeTrivialParseNodes = FALSE; 691 Gbl_CaptureComments = TRUE; 692 Gbl_DoExternalsInPlace = TRUE; 693 return (0); 694 695 case 'r': /* Override revision found in table header */ 696 697 Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); 698 break; 699 700 case 's': /* Create AML in a source code file */ 701 702 switch (AcpiGbl_Optarg[0]) 703 { 704 case 'a': 705 706 /* Produce assembly code output file */ 707 708 Gbl_AsmOutputFlag = TRUE; 709 break; 710 711 case 'c': 712 713 /* Produce C hex output file */ 714 715 Gbl_C_OutputFlag = TRUE; 716 break; 717 718 case 'o': 719 720 /* Produce AML offset table in C */ 721 722 Gbl_C_OffsetTableFlag = TRUE; 723 break; 724 725 default: 726 727 printf ("Unknown option: -s%s\n", AcpiGbl_Optarg); 728 return (-1); 729 } 730 break; 731 732 case 't': /* Produce hex table output file */ 733 734 switch (AcpiGbl_Optarg[0]) 735 { 736 case 'a': 737 738 Gbl_HexOutputFlag = HEX_OUTPUT_ASM; 739 break; 740 741 case 'c': 742 743 Gbl_HexOutputFlag = HEX_OUTPUT_C; 744 break; 745 746 case 's': 747 748 Gbl_HexOutputFlag = HEX_OUTPUT_ASL; 749 break; 750 751 default: 752 753 printf ("Unknown option: -t%s\n", AcpiGbl_Optarg); 754 return (-1); 755 } 756 break; 757 758 case 'T': /* Create a ACPI table template file */ 759 760 Gbl_DoTemplates = TRUE; 761 break; 762 763 case 'v': /* Version and verbosity settings */ 764 765 switch (AcpiGbl_Optarg[0]) 766 { 767 case '^': 768 769 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 770 exit (0); 771 772 case 'a': 773 774 /* Disable all error/warning/remark messages */ 775 776 Gbl_NoErrors = TRUE; 777 break; 778 779 case 'd': 780 781 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME)); 782 printf (ACPI_COMMON_BUILD_TIME); 783 exit (0); 784 785 case 'e': 786 787 /* Disable all warning/remark messages (errors only) */ 788 789 Gbl_DisplayRemarks = FALSE; 790 Gbl_DisplayWarnings = FALSE; 791 break; 792 793 case 'i': 794 /* 795 * Support for integrated development environment(s). 796 * 797 * 1) No compiler signon 798 * 2) Send stderr messages to stdout 799 * 3) Less verbose error messages (single line only for each) 800 * 4) Error/warning messages are formatted appropriately to 801 * be recognized by MS Visual Studio 802 */ 803 Gbl_VerboseErrors = FALSE; 804 Gbl_DoSignon = FALSE; 805 Gbl_Files[ASL_FILE_STDERR].Handle = stdout; 806 break; 807 808 case 'o': 809 810 Gbl_DisplayOptimizations = TRUE; 811 break; 812 813 case 'r': 814 815 Gbl_DisplayRemarks = FALSE; 816 break; 817 818 case 's': 819 820 Gbl_DoSignon = FALSE; 821 break; 822 823 case 't': 824 825 Gbl_VerboseTemplates = TRUE; 826 break; 827 828 case 'w': 829 830 /* Get the required argument */ 831 832 if (AcpiGetoptArgument (argc, argv)) 833 { 834 return (-1); 835 } 836 837 Status = AslDisableException (AcpiGbl_Optarg); 838 if (ACPI_FAILURE (Status)) 839 { 840 return (-1); 841 } 842 break; 843 844 case 'x': 845 846 /* Get the required argument */ 847 848 if (AcpiGetoptArgument (argc, argv)) 849 { 850 return (-1); 851 } 852 853 Status = AslExpectException (AcpiGbl_Optarg); 854 if (ACPI_FAILURE (Status)) 855 { 856 return (-1); 857 } 858 break; 859 860 default: 861 862 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); 863 return (-1); 864 } 865 break; 866 867 case 'w': /* Set warning levels */ 868 869 switch (AcpiGbl_Optarg[0]) 870 { 871 case '1': 872 873 Gbl_WarningLevel = ASL_WARNING; 874 break; 875 876 case '2': 877 878 Gbl_WarningLevel = ASL_WARNING2; 879 break; 880 881 case '3': 882 883 Gbl_WarningLevel = ASL_WARNING3; 884 break; 885 886 case 'e': 887 888 Gbl_WarningsAsErrors = TRUE; 889 break; 890 891 default: 892 893 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg); 894 return (-1); 895 } 896 break; 897 898 case 'x': /* Set debug print output level */ 899 900 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16); 901 break; 902 903 case 'z': 904 905 Gbl_UseOriginalCompilerId = TRUE; 906 break; 907 908 default: 909 910 return (-1); 911 } 912 913 return (0); 914} 915 916 917/******************************************************************************* 918 * 919 * FUNCTION: AslMergeOptionTokens 920 * 921 * PARAMETERS: InBuffer - Input containing an option string 922 * OutBuffer - Merged output buffer 923 * 924 * RETURN: None 925 * 926 * DESCRIPTION: Remove all whitespace from an option string. 927 * 928 ******************************************************************************/ 929 930static void 931AslMergeOptionTokens ( 932 char *InBuffer, 933 char *OutBuffer) 934{ 935 char *Token; 936 937 938 *OutBuffer = 0; 939 940 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS); 941 while (Token) 942 { 943 strcat (OutBuffer, Token); 944 Token = strtok (NULL, ASL_TOKEN_SEPARATORS); 945 } 946} 947 948 949/******************************************************************************* 950 * 951 * FUNCTION: AslDoResponseFile 952 * 953 * PARAMETERS: Filename - Name of the response file 954 * 955 * RETURN: Status 956 * 957 * DESCRIPTION: Open a response file and process all options within. 958 * 959 ******************************************************************************/ 960 961static int 962AslDoResponseFile ( 963 char *Filename) 964{ 965 char *argv = StringBuffer2; 966 FILE *ResponseFile; 967 int OptStatus = 0; 968 int Opterr; 969 int Optind; 970 971 972 ResponseFile = fopen (Filename, "r"); 973 if (!ResponseFile) 974 { 975 printf ("Could not open command file %s, %s\n", 976 Filename, strerror (errno)); 977 return (-1); 978 } 979 980 /* Must save the current GetOpt globals */ 981 982 Opterr = AcpiGbl_Opterr; 983 Optind = AcpiGbl_Optind; 984 985 /* 986 * Process all lines in the response file. There must be one complete 987 * option per line 988 */ 989 while (fgets (StringBuffer, ASL_MSG_BUFFER_SIZE, ResponseFile)) 990 { 991 /* Compress all tokens, allowing us to use a single argv entry */ 992 993 AslMergeOptionTokens (StringBuffer, StringBuffer2); 994 995 /* Process the option */ 996 997 AcpiGbl_Opterr = 0; 998 AcpiGbl_Optind = 0; 999 1000 OptStatus = AslDoOptions (1, &argv, TRUE); 1001 if (OptStatus) 1002 { 1003 printf ("Invalid option in command file %s: %s\n", 1004 Filename, StringBuffer); 1005 break; 1006 } 1007 } 1008 1009 /* Restore the GetOpt globals */ 1010 1011 AcpiGbl_Opterr = Opterr; 1012 AcpiGbl_Optind = Optind; 1013 1014 fclose (ResponseFile); 1015 return (OptStatus); 1016} 1017