asloptions.c revision 1.10 1 /******************************************************************************
2 *
3 * Module Name: asloptions - compiler command line processing
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2019, 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
54 static int
55 AslDoOptions (
56 int argc,
57 char **argv,
58 BOOLEAN IsResponseFile);
59
60 static void
61 AslMergeOptionTokens (
62 char *InBuffer,
63 char *OutBuffer);
64
65 static int
66 AslDoResponseFile (
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
86 int
87 AslCommandLine (
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 (AslGbl_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 (AslGbl_DoSignon)
127 {
128 printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
129 if (AslGbl_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
158 static int
159 AslDoOptions (
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 AslGbl_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 AslGbl_DoAslConversion = TRUE;
214 AslGbl_FoldConstants = FALSE;
215 AslGbl_IntegerOptimizationFlag = FALSE;
216 AslGbl_ReferenceOptimizationFlag = FALSE;
217 AslGbl_OptimizeTrivialParseNodes = FALSE;
218 AcpiGbl_CaptureComments = TRUE;
219 AcpiGbl_DoDisassemblerOptimizations = FALSE;
220 AcpiGbl_DebugAslConversion = TRUE;
221 AcpiGbl_DmEmitExternalOpcodes = TRUE;
222 AslGbl_DoExternalsInPlace = TRUE;
223
224 return (0);
225
226 case 'f':
227
228 AslCompilerdebug = 1; /* same as yydebug */
229 DtParserdebug = 1;
230 PrParserdebug = 1;
231 AslGbl_DebugFlag = TRUE;
232 AslGbl_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 AslGbl_PruneParseTree = TRUE;
245 AslGbl_PruneDepth = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
246 break;
247
248 case 's':
249
250 AslGbl_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 AslGbl_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 AslGbl_DoAslConversion = TRUE;
282 AslGbl_FoldConstants = FALSE;
283 AslGbl_IntegerOptimizationFlag = FALSE;
284 AslGbl_ReferenceOptimizationFlag = FALSE;
285 AslGbl_OptimizeTrivialParseNodes = FALSE;
286 AcpiGbl_CaptureComments = TRUE;
287 AcpiGbl_DoDisassemblerOptimizations = FALSE;
288 AcpiGbl_DmEmitExternalOpcodes = TRUE;
289 AslGbl_DoExternalsInPlace = TRUE;
290
291 return (0);
292
293 case 'r':
294
295 AslGbl_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 AslGbl_DoCompile = FALSE;
312 break;
313
314 case 'a':
315
316 AslGbl_DoCompile = FALSE;
317 AslGbl_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 AslGbl_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 AslGbl_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 AslGbl_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 AslGbl_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 AslGbl_AsmIncludeOutputFlag = TRUE;
468 break;
469
470 case 'c':
471
472 /* Produce C include file */
473
474 AslGbl_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 AslGbl_ListingFlag = TRUE;
500 AcpiGbl_DmOpt_Listing = TRUE;
501 break;
502
503 case 'i':
504
505 /* Produce preprocessor output file */
506
507 AslGbl_PreprocessorOutputFlag = TRUE;
508 break;
509
510 case 'm':
511
512 /* Produce hardware map summary file */
513
514 AslGbl_MapfileFlag = TRUE;
515 break;
516
517 case 'n':
518
519 /* Produce namespace file */
520
521 AslGbl_NsOutputFlag = TRUE;
522 break;
523
524 case 's':
525
526 /* Produce combined source file */
527
528 AslGbl_SourceOutputFlag = TRUE;
529 break;
530
531 case 'x':
532
533 /* Produce cross-reference file */
534
535 AslGbl_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 AslGbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024;
548 if (AslGbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE)
549 {
550 AslGbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE;
551 }
552 printf ("Line Buffer Size: %u\n", AslGbl_LineBufferSize);
553 break;
554
555 case 'n': /* Parse only */
556
557 AslGbl_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 AslGbl_FoldConstants = FALSE;
569 AslGbl_IntegerOptimizationFlag = FALSE;
570 AslGbl_ReferenceOptimizationFlag = FALSE;
571 AslGbl_OptimizeTrivialParseNodes = FALSE;
572
573 break;
574
575 case 'c':
576
577 /* Display compile time(s) */
578
579 AslGbl_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 AslGbl_DoExternalsInPlace = TRUE;
604 break;
605
606 case 'f':
607
608 /* Disable folding on "normal" expressions */
609
610 AslGbl_FoldConstants = FALSE;
611 break;
612
613 case 'i':
614
615 /* Disable integer optimization to constants */
616
617 AslGbl_IntegerOptimizationFlag = FALSE;
618 break;
619
620 case 'n':
621
622 /* Disable named reference optimization */
623
624 AslGbl_ReferenceOptimizationFlag = FALSE;
625 break;
626
627 case 't':
628
629 /* Disable heavy typechecking */
630
631 AslGbl_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 AslGbl_PreprocessOnly = TRUE;
648 AslGbl_PreprocessorOutputFlag = TRUE;
649 break;
650
651 case 'n': /* Disable preprocessor */
652
653 AslGbl_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 AslGbl_OutputFilenamePrefix = AcpiGbl_Optarg;
666 UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
667 AslGbl_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 AslGbl_FoldConstants = FALSE;
674 AslGbl_IntegerOptimizationFlag = FALSE;
675 AslGbl_ReferenceOptimizationFlag = FALSE;
676 AslGbl_OptimizeTrivialParseNodes = FALSE;
677 AslGbl_DoExternalsInPlace = TRUE;
678 AcpiGbl_CaptureComments = TRUE;
679 return (0);
680
681 case 'r': /* Override revision found in table header */
682
683 AslGbl_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 AslGbl_AsmOutputFlag = TRUE;
695 break;
696
697 case 'c':
698
699 /* Produce C hex output file */
700
701 AslGbl_C_OutputFlag = TRUE;
702 break;
703
704 case 'o':
705
706 /* Produce AML offset table in C */
707
708 AslGbl_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 AslGbl_HexOutputFlag = HEX_OUTPUT_ASM;
725 break;
726
727 case 'c':
728
729 AslGbl_HexOutputFlag = HEX_OUTPUT_C;
730 break;
731
732 case 's':
733
734 AslGbl_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 AslGbl_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 AslGbl_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 AslGbl_DisplayRemarks = FALSE;
776 AslGbl_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 AslGbl_VerboseErrors = FALSE;
790 AslGbl_DoSignon = FALSE;
791 break;
792
793 case 'o':
794
795 AslGbl_DisplayOptimizations = TRUE;
796 break;
797
798 case 'r':
799
800 AslGbl_DisplayRemarks = FALSE;
801 break;
802
803 case 's':
804
805 AslGbl_DoSignon = FALSE;
806 break;
807
808 case 't':
809
810 AslGbl_VerboseTemplates = TRUE;
811 break;
812
813 case 'w':
814
815 /* Get the required argument */
816
817 if (AcpiGetoptArgument (argc, argv))
818 {
819 return (-1);
820 }
821
822 Status = AslDisableException (AcpiGbl_Optarg);
823 if (ACPI_FAILURE (Status))
824 {
825 return (-1);
826 }
827 break;
828
829 case 'x':
830
831 /* Get the required argument */
832
833 if (AcpiGetoptArgument (argc, argv))
834 {
835 return (-1);
836 }
837
838 Status = AslExpectException (AcpiGbl_Optarg);
839 if (ACPI_FAILURE (Status))
840 {
841 return (-1);
842 }
843 break;
844
845 default:
846
847 printf ("Unknown option: -v%s\n", AcpiGbl_Optarg);
848 return (-1);
849 }
850 break;
851
852 case 'w': /* Set warning levels */
853
854 switch (AcpiGbl_Optarg[0])
855 {
856 case '1':
857
858 AslGbl_WarningLevel = ASL_WARNING;
859 break;
860
861 case '2':
862
863 AslGbl_WarningLevel = ASL_WARNING2;
864 break;
865
866 case '3':
867
868 AslGbl_WarningLevel = ASL_WARNING3;
869 break;
870
871 case 'e':
872
873 AslGbl_WarningsAsErrors = TRUE;
874 break;
875
876 case 'w':
877
878 /* Get the required argument */
879
880 if (AcpiGetoptArgument (argc, argv))
881 {
882 return (-1);
883 }
884
885 Status = AslElevateException (AcpiGbl_Optarg);
886 if (ACPI_FAILURE (Status))
887 {
888 return (-1);
889 }
890 break;
891
892
893 default:
894
895 printf ("Unknown option: -w%s\n", AcpiGbl_Optarg);
896 return (-1);
897 }
898 break;
899
900 case 'x': /* Set debug print output level */
901
902 AcpiDbgLevel = strtoul (AcpiGbl_Optarg, NULL, 16);
903 break;
904
905 case 'z':
906
907 AslGbl_UseOriginalCompilerId = TRUE;
908 break;
909
910 default:
911
912 return (-1);
913 }
914
915 return (0);
916 }
917
918
919 /*******************************************************************************
920 *
921 * FUNCTION: AslMergeOptionTokens
922 *
923 * PARAMETERS: InBuffer - Input containing an option string
924 * OutBuffer - Merged output buffer
925 *
926 * RETURN: None
927 *
928 * DESCRIPTION: Remove all whitespace from an option string.
929 *
930 ******************************************************************************/
931
932 static void
933 AslMergeOptionTokens (
934 char *InBuffer,
935 char *OutBuffer)
936 {
937 char *Token;
938
939
940 *OutBuffer = 0;
941
942 Token = strtok (InBuffer, ASL_TOKEN_SEPARATORS);
943 while (Token)
944 {
945 strcat (OutBuffer, Token);
946 Token = strtok (NULL, ASL_TOKEN_SEPARATORS);
947 }
948 }
949
950
951 /*******************************************************************************
952 *
953 * FUNCTION: AslDoResponseFile
954 *
955 * PARAMETERS: Filename - Name of the response file
956 *
957 * RETURN: Status
958 *
959 * DESCRIPTION: Open a response file and process all options within.
960 *
961 ******************************************************************************/
962
963 static int
964 AslDoResponseFile (
965 char *Filename)
966 {
967 char *argv = AslGbl_StringBuffer2;
968 FILE *ResponseFile;
969 int OptStatus = 0;
970 int Opterr;
971 int Optind;
972
973
974 ResponseFile = fopen (Filename, "r");
975 if (!ResponseFile)
976 {
977 printf ("Could not open command file %s, %s\n",
978 Filename, strerror (errno));
979 return (-1);
980 }
981
982 /* Must save the current GetOpt globals */
983
984 Opterr = AcpiGbl_Opterr;
985 Optind = AcpiGbl_Optind;
986
987 /*
988 * Process all lines in the response file. There must be one complete
989 * option per line
990 */
991 while (fgets (AslGbl_StringBuffer, ASL_STRING_BUFFER_SIZE, ResponseFile))
992 {
993 /* Compress all tokens, allowing us to use a single argv entry */
994
995 AslMergeOptionTokens (AslGbl_StringBuffer, AslGbl_StringBuffer2);
996
997 /* Process the option */
998
999 AcpiGbl_Opterr = 0;
1000 AcpiGbl_Optind = 0;
1001
1002 OptStatus = AslDoOptions (1, &argv, TRUE);
1003 if (OptStatus)
1004 {
1005 printf ("Invalid option in command file %s: %s\n",
1006 Filename, AslGbl_StringBuffer);
1007 break;
1008 }
1009 }
1010
1011 /* Restore the GetOpt globals */
1012
1013 AcpiGbl_Opterr = Opterr;
1014 AcpiGbl_Optind = Optind;
1015
1016 fclose (ResponseFile);
1017 return (OptStatus);
1018 }
1019