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 "tdf.h"
33
#include "cmd_ops.h"
34
#include "spec_ops.h"
35
#include "error.h"
36
#include "input.h"
37
#include "lex.h"
38
#include "output.h"
39
#include "syntax.h"
40
 
41
 
42
/*
43
    MAIN ROUTINE
44
 
45
    This is the main routine.  It processes the command-line options,
46
    reads the input file, and writes the output files.
47
*/
48
 
49
int main
50
    PROTO_N ( ( argc, argv ) )
51
    PROTO_T ( int argc X char **argv )
52
{
53
    int a ;
54
    int too_many = 0 ;
55
    char *input = NULL ;
56
    char *templ = NULL ;
57
    char *output = NULL ;
58
 
59
    /* Process arguments */
60
    set_progname ( argv [0], "2.0" ) ;
61
    for ( a = 1 ; a < argc ; a++ ) {
62
	char *arg = argv [a] ;
63
	if ( arg [0] == '-' && arg [1] ) {
64
	    int known = 0 ;
65
	    switch ( arg [1] ) {
66
		case 'v' : {
67
		    if ( arg [2] ) break ;
68
		    report_version () ;
69
		    known = 1 ;
70
		    break ;
71
		}
72
	    }
73
	    if ( !known ) {
74
		error ( ERROR_WARNING, "Unknown option, '%s'", arg ) ;
75
	    }
76
	} else {
77
	    if ( input == NULL ) {
78
		input = arg ;
79
	    } else if ( templ == NULL ) {
80
		templ = arg ;
81
	    } else if ( output == NULL ) {
82
		output = arg ;
83
	    } else {
84
		too_many = 1 ;
85
	    }
86
	}
87
    }
88
 
89
    /* Check arguments */
90
    if ( too_many ) error ( ERROR_WARNING, "Too many arguments" ) ;
91
 
92
    /* Process the input */
93
    builtin_sorts () ;
94
    if ( open_file ( input ) ) {
95
	SPECIFICATION spec = NULL_spec ;
96
	ADVANCE_LEXER ;
97
	read_spec ( &spec ) ;
98
	close_file () ;
99
	if ( !IS_NULL_spec ( spec ) ) {
100
	    COMMAND cmd = NULL_cmd ;
101
	    if ( open_file ( templ ) ) {
102
		MAKE_cmd_simple ( 1, "<dummy>", cmd ) ;
103
		cmd = read_template ( cmd ) ;
104
		close_file () ;
105
	    }
106
	    if ( !IS_NULL_cmd ( cmd ) ) {
107
		output_spec ( output, spec, cmd ) ;
108
	    }
109
	}
110
    }
111
    return ( exit_status ) ;
112
}