|
|
1.1 root 1: /* VMS version of getargs; Uses DCL command parsing.
2: Copyright (C) 1989 Free Software Foundation, Inc.
3:
4: This program is free software; you can redistribute it and/or modify
5: it under the terms of the GNU General Public License as published by
6: the Free Software Foundation; either version 2, or (at your option)
7: any later version.
8:
9: This program is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU General Public License for more details.
13:
14: You should have received a copy of the GNU General Public License
15: along with this program; if not, write to the Free Software
16: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17:
18:
19: #include <ctype.h>
20: #include <stdio.h>
21: #include "files.h"
22:
23: /*
24: * VMS version of getargs(): Uses DCL command parsing
25: * (argc and argv are ignored)
26: */
27: int verboseflag;
28: int definesflag;
29: int debugflag;
30: int nolinesflag;
31: extern int fixed_outfiles;
32: extern char * version_string;
33:
34: /* Allocate storgate and initialize, since bison uses them elsewhere. */
35: char *spec_name_prefix;
36: char *spec_file_prefix;
37:
38: getargs(argc,argv)
39: int argc;
40: 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: verboseflag = 0;
48: definesflag = 0;
49: debugflag = 0;
50: fixed_outfiles = 0;
51: nolinesflag = 0;
52: /*
53: * Check for /VERBOSE qualifier
54: */
55: if (cli_present("BISON$VERBOSE")) verboseflag = 1;
56: /*
57: * Check for /DEFINES qualifier
58: */
59: if (cli_present("BISON$DEFINES")) definesflag = 1;
60: /*
61: * Check for /FIXED_OUTFILES qualifier
62: */
63: if (cli_present("BISON$FIXED_OUTFILES")) fixed_outfiles = 1;
64: if (cli_present("BISON$YACC")) fixed_outfiles = 1;
65: /*
66: * Check for /VERSION qualifier
67: */
68: if (cli_present("BISON$VERSION")) printf("%s",version_string);
69: /*
70: * Check for /NOLINES qualifier
71: */
72: if (cli_present("BISON$NOLINES")) nolinesflag = 1;
73: /*
74: * Check for /DEBUG qualifier
75: */
76: if (cli_present("BISON$DEBUG")) debugflag = 1;
77: /*
78: * Get the filename
79: */
80: cli_get_value("BISON$INFILE", Input_File, sizeof(Input_File));
81: /*
82: * Lowercaseify the input filename
83: */
84: cp = Input_File;
85: while(*cp)
86: {
87: if (isupper(*cp)) *cp = tolower(*cp);
88: cp++;
89: }
90: infile = Input_File;
91: /*
92: * Get the output file
93: */
94: if (cli_present("BISON$OUTPUT"))
95: {
96: cli_get_value("BISON$OUTPUT", output_spec, sizeof(output_spec));
97: for (cp = spec_outfile = output_spec; *cp; cp++)
98: if (isupper(*cp))
99: *cp = tolower(*cp);
100: }
101: /*
102: * Get the output file
103: */
104: if (cli_present("BISON$FILE_PREFIX"))
105: {
106: cli_get_value("BISON$FILE_PREFIX", file_prefix_spec,
107: sizeof(file_prefix_spec));
108: for (cp = spec_file_prefix = file_prefix_spec; *cp; cp++)
109: if (isupper(*cp))
110: *cp = tolower(*cp);
111: }
112: /*
113: * Get the output file
114: */
115: if (cli_present("BISON$NAME_PREFIX"))
116: {
117: cli_get_value("BISON$NAME_PREFIX", name_prefix_spec,
118: sizeof(name_prefix_spec));
119: for (cp = spec_name_prefix = name_prefix_spec; *cp; cp++)
120: if (isupper(*cp))
121: *cp = tolower(*cp);
122: }
123: }
124:
125: /************ DCL PARSING ROUTINES **********/
126:
127: /*
128: * See if "NAME" is present
129: */
130: int
131: cli_present(Name)
132: char *Name;
133: {
134: struct {int Size; char *Ptr;} Descr;
135:
136: Descr.Ptr = Name;
137: Descr.Size = strlen(Name);
138: return((cli$present(&Descr) & 1) ? 1 : 0);
139: }
140:
141: /*
142: * Get value of "NAME"
143: */
144: int
145: cli_get_value(Name,Buffer,Size)
146: char *Name;
147: char *Buffer;
148: {
149: struct {int Size; char *Ptr;} Descr1,Descr2;
150:
151: Descr1.Ptr = Name;
152: Descr1.Size = strlen(Name);
153: Descr2.Ptr = Buffer;
154: Descr2.Size = Size-1;
155: if (cli$get_value(&Descr1,&Descr2,&Descr2.Size) & 1) {
156: Buffer[Descr2.Size] = 0;
157: return(1);
158: }
159: return(0);
160: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.