Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 52... Line 82...
52
 
82
 
53
/*
83
/*
54
    MAIN ROUTINE
84
    MAIN ROUTINE
55
*/
85
*/
56
 
86
 
57
int main
87
int
58
    PROTO_N ( ( argc, argv ) )
-
 
59
    PROTO_T ( int argc X char **argv )
88
main(int argc, char **argv)
60
{
89
{
61
    char c ;
90
    char c;
62
    int input, output ;
91
    int input, output;
63
    int a, b, stage = 1 ;
92
    int a, b, stage = 1;
64
 
93
 
65
    /* Read the arguments */
94
    /* Read the arguments */
66
    for ( a = 1 ; a < argc ; a++ ) {
95
    for (a = 1; a < argc; a++) {
67
	if ( argv [a][0] == '-' ) {
96
	if (argv[a][0] == '-') {
68
	    b = 1 ;
97
	    b = 1;
69
	    if ( argv [a][1] == 'n' ) {
98
	    if (argv[a][1] == 'n') {
70
		maxcol = 0 ;
99
		maxcol = 0;
71
		while ( c = argv [a][ ++b ], is_digit ( c ) ) {
100
		while (c = argv[a][++b], is_digit(c)) {
72
		    maxcol = 10 * maxcol + digit ( c ) ;
101
		    maxcol = 10 * maxcol + digit(c);
73
		}
102
		}
74
	    } else {
103
	    } else {
75
		while ( c = argv [a][ b++ ], c != 0 ) {
104
		while (c = argv[a][b++], c != 0) {
76
		    switch ( c ) {
105
		    switch (c) {
77
			case 'd' : dflag = 0 ; break ;
106
			case 'd': dflag = 0; break;
78
			case 'g' : diagnostics = 1 ; break ;
107
			case 'g': diagnostics = 1; break;
79
			case 'h' : helpflag = 0 ; break ;
108
			case 'h': helpflag = 0; break;
80
			case 'i' : /* Compatibility */ break ;
109
			case 'i' : /* Compatibility */ break ;
81
			case 'p' : progress = 1 ; break ;
110
			case 'p': progress = 1; break;
82
			case 'q' : quickflag = 1 ; break ;
111
			case 'q': quickflag = 1; break;
83
			case 'r' : recover = 1 ; break ;
112
			case 'r': recover = 1; break;
84
			case 'x' : versions = 0 ; break ;
113
			case 'x': versions = 0; break;
85
			case 'A' : {
114
			case 'A': {
86
			    diagnostics = 1 ;
115
			    diagnostics = 1;
87
			    show_usage = 1 ;
116
			    show_usage = 1;
88
			    versions = 1 ;
117
			    versions = 1;
89
			    break ;
118
			    break;
90
			}
119
			}
91
			case 'D' : dump = 1 ; break ;
120
			case 'D': dump = 1; break;
92
			case 'E' : show_stuff = 1 ; break ;
121
			case 'E': show_stuff = 1; break;
93
			case 'S' : skip_pass = 0 ; break ;
122
			case 'S': skip_pass = 0; break;
94
			case 'T' : show_skip = 1 ; break ;
123
			case 'T': show_skip = 1; break;
95
			case 'U' : show_usage = 1 ; break ;
124
			case 'U': show_usage = 1; break;
96
			case 'V' : dumb_mode = 1 ; break ;
125
			case 'V': dumb_mode = 1; break;
97
			case 'W' : warn_undeclared = 1 ; break ;
126
			case 'W': warn_undeclared = 1; break;
98
 
127
 
99
			case 'v' : {
128
			case 'v': {
100
			    /* Version number */
129
			    /* Version number */
101
			    IGNORE fprintf ( stderr, "%s: %s",
130
			    IGNORE fprintf(stderr, "%s: %s",
102
					     progname, version_string ) ;
131
					     progname, version_string);
103
			    IGNORE fprintf ( stderr, " (TDF %d.%d)",
132
			    IGNORE fprintf(stderr, " (TDF %d.%d)",
104
					     version_major, version_minor ) ;
133
					     version_major, version_minor);
105
			    IGNORE fprintf ( stderr, " (release %s)\n",
134
			    IGNORE fprintf(stderr, " (release %s)\n",
106
					     RELEASE ) ;
135
					     RELEASE);
107
			    break ;
136
			    break;
108
			}
137
			}
109
		    }
138
		    }
110
		}
139
		}
111
	    }
140
	    }
112
	} else {
141
	} else {
113
	    /* Handle files */
142
	    /* Handle files */
114
	    switch ( stage ) {
143
	    switch (stage) {
115
		case 1  : input = a ; stage = 2 ; break ;
144
		case 1 : input = a; stage = 2; break;
116
		case 2  : output = a ; stage = 3 ; break ;
145
		case 2 : output = a; stage = 3; break;
117
		default : stage = 4 ; break ;
146
		default : stage = 4; break;
118
	    }
147
	    }
119
	}
148
	}
120
    }
149
    }
121
 
150
 
122
    /* Open the files */
151
    /* Open the files */
123
    switch ( stage ) {
152
    switch (stage) {
124
	case 1 : {
153
	case 1: {
125
	    fatal_error ( "Not enough arguments" ) ;
154
	    fatal_error("Not enough arguments");
126
	    break ;
155
	    break;
127
	}
156
	}
128
	case 2 : {
157
	case 2: {
129
	    SET ( input ) ;
158
	    SET(input);
130
	    open_files ( argv [ input ], ( char * ) null ) ;
159
	    open_files(argv[input],(char *)null);
131
	    break ;
160
	    break;
132
	}
161
	}
133
	case 3 : {
162
	case 3: {
134
	    SET ( input ) ;
163
	    SET(input);
135
	    SET ( output ) ;
164
	    SET(output);
136
	    open_files ( argv [ input ], argv [ output ] ) ;
165
	    open_files(argv[input], argv[output]);
137
	    break ;
166
	    break;
138
	}
167
	}
139
	default : {
168
	default : {
140
	    fatal_error ( "Too many arguments" ) ;
169
	    fatal_error("Too many arguments");
141
	    break ;
170
	    break;
142
	}
171
	}
143
    }
172
    }
144
 
173
 
145
    /* Perform binary dump if required */
174
    /* Perform binary dump if required */
146
    if ( dump ) {
175
    if (dump) {
147
	long f ;
176
	long f;
148
	int bits = 0, n = 1 ;
177
	int bits = 0, n = 1;
149
	while ( f = fetch ( 1 ), !read_error ) {
178
	while (f = fetch(1), !read_error) {
150
	    if ( n == 1 ) IGNORE fprintf ( pp_file, "%d :\t", bits / 8 ) ;
179
	    if (n == 1)IGNORE fprintf(pp_file, "%d :\t", bits / 8);
151
	    IGNORE fputc ( ( f ? '1' : '0' ), pp_file ) ;
180
	    IGNORE fputc((f ? '1' : '0'), pp_file);
152
	    if ( n == 64 ) {
181
	    if (n == 64) {
153
		IGNORE fputc ( '\n', pp_file ) ;
182
		IGNORE fputc('\n', pp_file);
154
		n = 1 ;
183
		n = 1;
155
	    } else {
184
	    } else {
156
		if ( n % 8 == 0 ) IGNORE fputc ( ' ', pp_file ) ;
185
		if (n % 8 == 0)IGNORE fputc(' ', pp_file);
157
		n++ ;
186
		n++;
158
	    }
187
	    }
159
	    bits++ ;
188
	    bits++;
160
	}
189
	}
161
	if ( n != 1 ) IGNORE fputc ( '\n', pp_file ) ;
190
	if (n != 1)IGNORE fputc('\n', pp_file);
162
	exit ( 0 ) ;
191
	exit(0);
163
    }
192
    }
164
 
193
 
165
    /* Call the main routines */
194
    /* Call the main routines */
166
    if ( diagnostics || show_usage ) do_foreign_sorts = 1 ;
195
    if (diagnostics || show_usage) do_foreign_sorts = 1;
167
    init_foreign_sorts () ;
196
    init_foreign_sorts();
168
    initialize_tree () ;
197
    initialize_tree();
169
    de_capsule () ;
198
    de_capsule();
170
    pretty_tree () ;
199
    pretty_tree();
171
    return ( exit_status ) ;
200
    return(exit_status);
172
}
201
}