]>
Commit | Line | Data |
---|---|---|
22a89eed | 1 | /* VMS version of getargs; Uses DCL command parsing. |
6dd6d212 | 2 | Copyright (C) 1989, 1992 Free Software Foundation, Inc. |
22a89eed | 3 | |
6dd6d212 | 4 | This file is part of Bison, the GNU Compiler Compiler. |
22a89eed | 5 | |
6dd6d212 RS |
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. | |
22a89eed | 10 | |
6dd6d212 RS |
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, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
22a89eed RS |
19 | |
20 | ||
21 | #include <ctype.h> | |
22 | #include <stdio.h> | |
23 | #include "files.h" | |
24 | ||
25 | /* | |
6dd6d212 | 26 | * VMS version of getargs: Uses DCL command parsing |
22a89eed RS |
27 | * (argc and argv are ignored) |
28 | */ | |
29 | int verboseflag; | |
30 | int definesflag; | |
31 | int debugflag; | |
32 | int nolinesflag; | |
6dd6d212 RS |
33 | extern int noparserflag; |
34 | extern int toknumflag; | |
35 | extern int rawtoknumflag; | |
22a89eed RS |
36 | extern int fixed_outfiles; |
37 | extern char * version_string; | |
38 | ||
39 | /* Allocate storgate and initialize, since bison uses them elsewhere. */ | |
40 | char *spec_name_prefix; | |
41 | char *spec_file_prefix; | |
42 | ||
43 | getargs(argc,argv) | |
44 | int argc; | |
45 | char *argv[]; | |
46 | { | |
47 | register char *cp; | |
48 | static char Input_File[256]; | |
49 | static char output_spec[256], name_prefix_spec[256], file_prefix_spec[256]; | |
50 | extern char *infile; | |
51 | ||
52 | verboseflag = 0; | |
53 | definesflag = 0; | |
54 | debugflag = 0; | |
55 | fixed_outfiles = 0; | |
56 | nolinesflag = 0; | |
6dd6d212 RS |
57 | noparserflag = 0; |
58 | toknumflag = 0; | |
59 | rawtoknumflag = 0; | |
22a89eed RS |
60 | /* |
61 | * Check for /VERBOSE qualifier | |
62 | */ | |
63 | if (cli_present("BISON$VERBOSE")) verboseflag = 1; | |
64 | /* | |
65 | * Check for /DEFINES qualifier | |
66 | */ | |
67 | if (cli_present("BISON$DEFINES")) definesflag = 1; | |
68 | /* | |
69 | * Check for /FIXED_OUTFILES qualifier | |
70 | */ | |
71 | if (cli_present("BISON$FIXED_OUTFILES")) fixed_outfiles = 1; | |
72 | if (cli_present("BISON$YACC")) fixed_outfiles = 1; | |
73 | /* | |
74 | * Check for /VERSION qualifier | |
75 | */ | |
76 | if (cli_present("BISON$VERSION")) printf("%s",version_string); | |
77 | /* | |
78 | * Check for /NOLINES qualifier | |
79 | */ | |
80 | if (cli_present("BISON$NOLINES")) nolinesflag = 1; | |
6dd6d212 RS |
81 | /* |
82 | * Check for /NOPARSER qualifier | |
83 | */ | |
84 | if (cli_present("BISON$NOPARSER")) noparserflag = 1; | |
85 | /* | |
86 | * Check for /RAW qualifier | |
87 | */ | |
88 | if (cli_present("BISON$RAW")) rawtoknumflag = 1; | |
89 | /* | |
90 | * Check for /TOKEN_TABLE qualifier | |
91 | */ | |
92 | if (cli_present("BISON$TOKEN_TABLE")) toknumflag = 1; | |
22a89eed RS |
93 | /* |
94 | * Check for /DEBUG qualifier | |
95 | */ | |
96 | if (cli_present("BISON$DEBUG")) debugflag = 1; | |
97 | /* | |
98 | * Get the filename | |
99 | */ | |
100 | cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File)); | |
101 | /* | |
102 | * Lowercaseify the input filename | |
103 | */ | |
104 | cp = Input_File; | |
105 | while(*cp) | |
106 | { | |
107 | if (isupper(*cp)) *cp = tolower(*cp); | |
108 | cp++; | |
109 | } | |
110 | infile = Input_File; | |
111 | /* | |
112 | * Get the output file | |
113 | */ | |
114 | if (cli_present("BISON$OUTPUT")) | |
115 | { | |
116 | cli_get_value("BISON$OUTPUT", output_spec, sizeof(output_spec)); | |
117 | for (cp = spec_outfile = output_spec; *cp; cp++) | |
118 | if (isupper(*cp)) | |
119 | *cp = tolower(*cp); | |
120 | } | |
121 | /* | |
122 | * Get the output file | |
123 | */ | |
124 | if (cli_present("BISON$FILE_PREFIX")) | |
125 | { | |
126 | cli_get_value("BISON$FILE_PREFIX", file_prefix_spec, | |
127 | sizeof(file_prefix_spec)); | |
128 | for (cp = spec_file_prefix = file_prefix_spec; *cp; cp++) | |
129 | if (isupper(*cp)) | |
130 | *cp = tolower(*cp); | |
131 | } | |
132 | /* | |
133 | * Get the output file | |
134 | */ | |
135 | if (cli_present("BISON$NAME_PREFIX")) | |
136 | { | |
137 | cli_get_value("BISON$NAME_PREFIX", name_prefix_spec, | |
138 | sizeof(name_prefix_spec)); | |
139 | for (cp = spec_name_prefix = name_prefix_spec; *cp; cp++) | |
140 | if (isupper(*cp)) | |
141 | *cp = tolower(*cp); | |
142 | } | |
143 | } | |
144 | ||
145 | /************ DCL PARSING ROUTINES **********/ | |
146 | ||
147 | /* | |
148 | * See if "NAME" is present | |
149 | */ | |
150 | int | |
151 | cli_present(Name) | |
152 | char *Name; | |
153 | { | |
154 | struct {int Size; char *Ptr;} Descr; | |
155 | ||
156 | Descr.Ptr = Name; | |
157 | Descr.Size = strlen(Name); | |
158 | return((cli$present(&Descr) & 1) ? 1 : 0); | |
159 | } | |
160 | ||
161 | /* | |
162 | * Get value of "NAME" | |
163 | */ | |
164 | int | |
165 | cli_get_value(Name,Buffer,Size) | |
166 | char *Name; | |
167 | char *Buffer; | |
168 | { | |
169 | struct {int Size; char *Ptr;} Descr1,Descr2; | |
170 | ||
171 | Descr1.Ptr = Name; | |
172 | Descr1.Size = strlen(Name); | |
173 | Descr2.Ptr = Buffer; | |
174 | Descr2.Size = Size-1; | |
175 | if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) { | |
176 | Buffer[Descr2.Size] = 0; | |
177 | return(1); | |
178 | } | |
179 | return(0); | |
180 | } |