]>
Commit | Line | Data |
---|---|---|
1 | /* VMS version of getargs; Uses DCL command parsing. | |
2 | Copyright 1989, 1992 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of Bison, the GNU Compiler Compiler. | |
5 | ||
6 | Bison is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | Bison is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with Bison; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | ||
22 | #include <ctype.h> | |
23 | #include <stdio.h> | |
24 | #include "files.h" | |
25 | ||
26 | /* | |
27 | * VMS version of getargs: Uses DCL command parsing | |
28 | * (argc and argv are ignored) | |
29 | */ | |
30 | int verbose_flag; | |
31 | int defines_flag; | |
32 | int debug_flag; | |
33 | int no_lines_flag; | |
34 | extern int no_parser_flag; | |
35 | extern int token_table_flag; | |
36 | extern int raw_flag; | |
37 | extern int yacc_flag; | |
38 | extern char * version_string; | |
39 | ||
40 | getargs (int argc, char *argv[]) | |
41 | { | |
42 | register char *cp; | |
43 | static char Input_File[256]; | |
44 | static char output_spec[256], name_prefix_spec[256], file_prefix_spec[256]; | |
45 | extern char *infile; | |
46 | ||
47 | verbose_flag = 0; | |
48 | defines_flag = 0; | |
49 | debug_flag = 0; | |
50 | yacc_flag = 0; | |
51 | no_lines_flag = 0; | |
52 | no_parser_flag = 0; | |
53 | token_table_flag = 0; | |
54 | raw_flag = 0; | |
55 | /* | |
56 | * Check for /VERBOSE qualifier | |
57 | */ | |
58 | if (cli_present("BISON$VERBOSE")) verbose_flag = 1; | |
59 | /* | |
60 | * Check for /DEFINES qualifier | |
61 | */ | |
62 | if (cli_present("BISON$DEFINES")) defines_flag = 1; | |
63 | /* | |
64 | * Check for /FIXED_OUTFILES qualifier | |
65 | */ | |
66 | if (cli_present("BISON$FIXED_OUTFILES")) yacc_flag = 1; | |
67 | if (cli_present("BISON$YACC")) yacc_flag = 1; | |
68 | /* | |
69 | * Check for /VERSION qualifier | |
70 | */ | |
71 | if (cli_present("BISON$VERSION")) printf("%s",version_string); | |
72 | /* | |
73 | * Check for /NOLINES qualifier | |
74 | */ | |
75 | if (cli_present("BISON$NOLINES")) no_lines_flag = 1; | |
76 | /* | |
77 | * Check for /NOPARSER qualifier | |
78 | */ | |
79 | if (cli_present("BISON$NOPARSER")) no_parser_flag = 1; | |
80 | /* | |
81 | * Check for /RAW qualifier | |
82 | */ | |
83 | if (cli_present("BISON$RAW")) raw_flag = 1; | |
84 | /* | |
85 | * Check for /TOKEN_TABLE qualifier | |
86 | */ | |
87 | if (cli_present("BISON$TOKEN_TABLE")) token_table_flag = 1; | |
88 | /* | |
89 | * Check for /DEBUG qualifier | |
90 | */ | |
91 | if (cli_present("BISON$DEBUG")) debug_flag = 1; | |
92 | /* | |
93 | * Get the filename | |
94 | */ | |
95 | cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File)); | |
96 | /* | |
97 | * Lowercaseify the input filename | |
98 | */ | |
99 | cp = Input_File; | |
100 | while(*cp) | |
101 | { | |
102 | if (isupper(*cp)) *cp = tolower(*cp); | |
103 | cp++; | |
104 | } | |
105 | infile = Input_File; | |
106 | /* | |
107 | * Get the output file | |
108 | */ | |
109 | if (cli_present("BISON$OUTPUT")) | |
110 | { | |
111 | cli_get_value("BISON$OUTPUT", output_spec, sizeof(output_spec)); | |
112 | for (cp = spec_outfile = output_spec; *cp; cp++) | |
113 | if (isupper(*cp)) | |
114 | *cp = tolower(*cp); | |
115 | } | |
116 | /* | |
117 | * Get the output file | |
118 | */ | |
119 | if (cli_present("BISON$FILE_PREFIX")) | |
120 | { | |
121 | cli_get_value("BISON$FILE_PREFIX", file_prefix_spec, | |
122 | sizeof(file_prefix_spec)); | |
123 | for (cp = spec_file_prefix = file_prefix_spec; *cp; cp++) | |
124 | if (isupper(*cp)) | |
125 | *cp = tolower(*cp); | |
126 | } | |
127 | /* | |
128 | * Get the output file | |
129 | */ | |
130 | if (cli_present("BISON$NAME_PREFIX")) | |
131 | { | |
132 | cli_get_value("BISON$NAME_PREFIX", name_prefix_spec, | |
133 | sizeof(name_prefix_spec)); | |
134 | for (cp = spec_name_prefix = name_prefix_spec; *cp; cp++) | |
135 | if (isupper(*cp)) | |
136 | *cp = tolower(*cp); | |
137 | } | |
138 | } | |
139 | ||
140 | /************ DCL PARSING ROUTINES **********/ | |
141 | ||
142 | /* | |
143 | * See if "NAME" is present | |
144 | */ | |
145 | int | |
146 | cli_present (char *Name) | |
147 | { | |
148 | struct {int Size; char *Ptr;} Descr; | |
149 | ||
150 | Descr.Ptr = Name; | |
151 | Descr.Size = strlen(Name); | |
152 | return (cli$present(&Descr) & 1) ? 1 : 0; | |
153 | } | |
154 | ||
155 | /* | |
156 | * Get value of "NAME" | |
157 | */ | |
158 | int | |
159 | cli_get_value (char *Name, char *Buffer, int Size) | |
160 | { | |
161 | struct {int Size; char *Ptr;} Descr1,Descr2; | |
162 | ||
163 | Descr1.Ptr = Name; | |
164 | Descr1.Size = strlen(Name); | |
165 | Descr2.Ptr = Buffer; | |
166 | Descr2.Size = Size-1; | |
167 | if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) { | |
168 | Buffer[Descr2.Size] = 0; | |
169 | return 1; | |
170 | } | |
171 | return 0; | |
172 | } |