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