Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
#include "config.h"
32
#include "errors.h"
33
#include "error.h"
34
#include "lex.h"
35
#include "process.h"
36
#include "syntax.h"
37
 
38
 
39
/*
40
    MAIN ROUTINE
41
 
42
    This is the main routine.  It processes the command-line options,
43
    reads the input file, and writes the output files.
44
*/
45
 
46
int main
47
    PROTO_N ( ( argc, argv ) )
48
    PROTO_T ( int argc X char **argv )
49
{
50
    int a ;
51
    int act = 0 ;
52
    int too_many = 0 ;
53
    char *input = NULL ;
54
    char *output = NULL ;
55
 
56
    /* Process arguments */
57
    set_progname ( argv [0], "1.1" ) ;
58
    for ( a = 1 ; a < argc ; a++ ) {
59
	char *arg = argv [a] ;
60
	if ( arg [0] == '-' && arg [1] ) {
61
	    int known = 0 ;
62
	    switch ( arg [1] ) {
63
		case 'd' : {
64
		    if ( arg [2] ) break ;
65
		    act = 1 ;
66
		    known = 1 ;
67
		    break ;
68
		}
69
		case 'n' : {
70
		    if ( arg [2] ) break ;
71
		    act = 2 ;
72
		    known = 1 ;
73
		    break ;
74
		}
75
		case 'u' : {
76
		    if ( arg [2] ) break ;
77
		    act = 3 ;
78
		    known = 1 ;
79
		    break ;
80
		}
81
		case 'v' : {
82
		    if ( arg [2] ) break ;
83
		    report_version () ;
84
		    known = 1 ;
85
		    break ;
86
		}
87
	    }
88
	    if ( !known ) {
89
		error ( ERROR_WARNING, "Unknown option, '%s'", arg ) ;
90
	    }
91
	} else {
92
	    if ( input == NULL ) {
93
		input = arg ;
94
	    } else if ( output == NULL ) {
95
		output = arg ;
96
	    } else {
97
		too_many = 1 ;
98
	    }
99
	}
100
    }
101
 
102
    /* Check arguments */
103
    if ( too_many ) error ( ERROR_WARNING, "Too many arguments" ) ;
104
 
105
    /* Process the input */
106
    process_file ( input ) ;
107
    output_all ( output, act ) ;
108
    return ( exit_status ) ;
109
}