2
* @OPENGROUP_COPYRIGHT@
4
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
5
* Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
6
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
7
* the full copyright text.
9
* This software is subject to an open license. It may only be
10
* used on, with or for operating systems which are themselves open
11
* source systems. You must contact The Open Group for a license
12
* allowing distribution and sublicensing of this software on, with,
13
* or for operating systems which are not Open Source programs.
15
* See http://www.opengroup.org/openmotif/license for full
16
* details of the license agreement. Any use, reproduction, or
17
* distribution of the program constitutes recipient's acceptance of
20
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
21
* PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
* KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
23
* WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
24
* OR FITNESS FOR A PARTICULAR PURPOSE
26
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
27
* NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
28
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
30
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
33
* EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGES.
41
static char rcsid[] = "$XConsortium: UilCmd.c /main/11 1995/07/14 09:32:29 drk $"
51
* (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
57
** User Interface Language Compiler (UIL)
61
** Command line interpreter for the
74
#include "UilCmdDef.h"
79
** GLOBAL DECLARATIONS
83
externaldef(uil_comp_glbl) cmd_command_line_type Uil_cmd_z_command = {
84
NULL, /* *ac_source_file */
85
NULL, /* *ac_resource_file */
86
NULL, /* *ac_listing_file */
87
0, /* include_dir_count */
88
NULL, /* **ac_include_dir */
89
1, /* v_listing_file */
90
1, /* v_resource_file */
91
1, /* v_show_machine_code */
92
1, /* v_report_info_msg */
93
1, /* v_report_warn_msg */
95
1, /* v_issue_summary */
96
0, /* status_update_delay */
97
NULL, /* (*message_cb)() */
98
NULL, /* *message_data */
99
NULL, /* (*status_cb)() */
100
NULL, /* *status_data */
101
1, /* v_use_setlocal */
102
NULL, /* *ac_database */
110
** FUNCTIONAL DESCRIPTION:
112
** This procedure parses the command line and places the
113
** results of the parse in the global structure "Uil_cmd_z_command".
115
** FORMAL PARAMETERS:
117
** l_arg_count: number of command arguments
118
** rac_arg_value: array of pointers to null terminated character strings
119
** each of which is one of the command line arguments
127
** Uil_cmd_z_command: respository for command line info
135
** Uil_cmd_z_command is set
139
void cmd_decode_command_line( l_arg_count, rac_arg_value )
141
char *rac_arg_value[ ];
144
static char *include_list [Uil_k_max_include_dir_count];
147
Uil_cmd_z_command.ac_source_file = NULL;
148
Uil_cmd_z_command.ac_resource_file = NULL;
149
Uil_cmd_z_command.ac_listing_file = NULL;
150
Uil_cmd_z_command.include_dir_count = 0;
151
Uil_cmd_z_command.ac_include_dir = (char **)include_list;
152
Uil_cmd_z_command.v_resource_file = TRUE;
153
Uil_cmd_z_command.v_listing_file = FALSE;
154
Uil_cmd_z_command.v_show_machine_code = FALSE;
155
Uil_cmd_z_command.v_report_info_msg = TRUE;
156
Uil_cmd_z_command.v_report_warn_msg = TRUE;
157
Uil_cmd_z_command.v_parse_tree = FALSE;
158
Uil_cmd_z_command.v_use_setlocale = FALSE;
159
Uil_cmd_z_command.status_update_delay = 0;
160
Uil_cmd_z_command.message_cb = (Uil_continue_type(*)())NULL;
161
Uil_cmd_z_command.status_cb = (Uil_continue_type(*)())NULL;
162
Uil_cmd_z_command.ac_database = NULL;
163
Uil_cmd_z_command.v_database = FALSE;
166
uil_v_dump_tokens = FALSE;
167
uil_v_dump_symbols = FALSE;
170
/* traverse the options on the command line */
172
for (i = 1; i < l_arg_count; i++)
174
/* check for an output file */
176
if ( strcmp("-o", rac_arg_value[ i ]) == 0 )
178
/* the next argument is the output file name */
180
/* check next field is not an option */
182
if (((i+1) >= l_arg_count) ||
183
( '-' == rac_arg_value[ i+1 ][ 0 ] ))
185
diag_issue_diagnostic
187
diag_k_no_source, diag_k_no_column,
194
if (Uil_cmd_z_command.ac_resource_file == NULL)
195
Uil_cmd_z_command.ac_resource_file = rac_arg_value[ i+1 ];
197
diag_issue_diagnostic
199
diag_k_no_source, diag_k_no_column,
205
/* check for a binary database file */
207
else if ( strcmp("-wmd", rac_arg_value[ i ]) == 0 )
209
/* the next argument is the binary database file name */
211
/* check next field is not an option */
213
if (((i+1) >= l_arg_count) ||
214
( '-' == rac_arg_value[ i+1 ][ 0 ] ))
216
diag_issue_diagnostic
218
diag_k_no_source, diag_k_no_column,
220
"binary database file"
225
if (!Uil_cmd_z_command.v_database)
227
Uil_cmd_z_command.v_database = TRUE;
228
Uil_cmd_z_command.ac_database = rac_arg_value[ i+1 ];
231
diag_issue_diagnostic
233
diag_k_no_source, diag_k_no_column,
239
/* check for an listing file */
241
else if ( strcmp("-v", rac_arg_value[ i ]) == 0 )
243
/* the next argument is the listing file name */
245
/* check next field is not an option */
247
if (((i+1) >= l_arg_count) ||
248
( '-' == rac_arg_value[ i+1 ][ 0 ] ))
250
diag_issue_diagnostic
252
diag_k_no_source, diag_k_no_column,
259
if (!Uil_cmd_z_command.v_listing_file)
261
Uil_cmd_z_command.v_listing_file = TRUE;
262
Uil_cmd_z_command.ac_listing_file = rac_arg_value[ i+1 ];
265
diag_issue_diagnostic
267
diag_k_no_source, diag_k_no_column,
273
/* check for the machine code option */
275
else if ( strcmp("-m", rac_arg_value[ i ]) == 0 )
277
Uil_cmd_z_command.v_show_machine_code = TRUE;
280
/* check if warnings are to be supressed */
282
else if ( strcmp("-w", rac_arg_value[ i ]) == 0 )
284
Uil_cmd_z_command.v_report_info_msg = FALSE;
285
Uil_cmd_z_command.v_report_warn_msg = FALSE;
288
/* check if setlocale is to be enabled */
290
else if ( strcmp("-s", rac_arg_value[ i ]) == 0 )
292
Uil_cmd_z_command.v_use_setlocale = TRUE;
295
/* check for an unexpected option */
297
else if ( '-' == rac_arg_value[ i ][ 0 ] )
300
/* check for an include directory */
302
if ( 'I' == rac_arg_value[ i ][ 1 ] )
304
if (Uil_cmd_z_command.include_dir_count < Uil_k_max_include_dir_count)
306
include_list[Uil_cmd_z_command.include_dir_count++] =
307
& rac_arg_value[i] [2];
309
diag_issue_diagnostic
311
diag_k_no_source, diag_k_no_column,
312
rac_arg_value[ i ], Uil_k_max_include_dir_count
316
diag_issue_diagnostic
318
diag_k_no_source, diag_k_no_column,
324
/* assume it is a UIL source file specification
325
* validation of the file spec is done when file is opened */
329
if (Uil_cmd_z_command.ac_source_file == NULL)
330
Uil_cmd_z_command.ac_source_file = rac_arg_value[ i ];
332
diag_issue_diagnostic
334
diag_k_no_source, diag_k_no_column,
341
** Check for a source file - otherwise issue a diagnostic.
344
if (Uil_cmd_z_command.ac_source_file == NULL)
345
diag_issue_diagnostic
346
( d_no_source, diag_k_no_source, diag_k_no_column );
348
if (Uil_cmd_z_command.ac_resource_file == NULL)
350
Uil_cmd_z_command.ac_resource_file = XtMalloc (strlen ("a.uid") + 1);
351
strcpy (Uil_cmd_z_command.ac_resource_file,"a.uid");
355
** Machine code listing only makes sense if listing is set.
358
Uil_cmd_z_command.v_show_machine_code =
359
( Uil_cmd_z_command.v_listing_file &
360
Uil_cmd_z_command.v_show_machine_code);