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 32... Line 62...
32
#include "object.h"
62
#include "object.h"
33
#include "hash.h"
63
#include "hash.h"
34
#include "name.h"
64
#include "name.h"
35
#include "type.h"
65
#include "type.h"
36
#include "utility.h"
66
#include "utility.h"
-
 
67
#include "variable.h"
37
 
68
 
38
 
69
 
39
/*
70
/*
40
    CURRENT OBJECT
71
    CURRENT OBJECT
41
 
72
 
42
    This is the current object, which is affected by any file property
73
    This is the current object, which is affected by any file property
43
    changes.
74
    changes.
44
*/
75
*/
45
 
76
 
46
object *crt_object = null ;
77
object *crt_object = null;
47
 
78
 
48
 
79
 
49
/*
80
/*
50
    SET A STRING VARIABLE
81
    SET A STRING VARIABLE
51
 
82
 
52
    This routine sets the string variable with identifier v to have value s.
83
    This routine sets the string variable with identifier v to have value s.
53
*/
84
*/
54
 
85
 
55
void set_string
86
void
56
    PROTO_N ( ( v, s ) )
-
 
57
    PROTO_T ( char *v X char *s )
87
set_string(char *v, char *s)
58
{
88
{
59
    boolean known = 0 ;
89
    boolean known = 0;
60
    switch ( v [1] ) {
90
    switch (v [1]) {
61
	case 'A' : {
91
	case 'A': {
62
	    if ( streq ( v, "$APINAME" ) ) {
92
	    if (streq(v, "$APINAME")) {
63
		if ( crt_object ) {
93
		if (crt_object) {
64
		    info *i = crt_object->u.u_info ;
94
		    info *i = crt_object->u.u_info;
65
		    i->api = s ;
95
		    i->api = s;
66
		    i->prefix = null ;
96
		    i->prefix = null;
67
		}
97
		}
68
		known = 1 ;
98
		known = 1;
69
	    }
99
	    }
70
	    break ;
100
	    break;
71
	}
101
	}
72
	case 'B' : {
102
	case 'B': {
73
	    if ( streq ( v, "$BLOCKNAME" ) ) {
103
	    if (streq(v, "$BLOCKNAME")) {
74
		if ( crt_object ) {
104
		if (crt_object) {
75
		    info *i = crt_object->u.u_info ;
105
		    info *i = crt_object->u.u_info;
76
		    if ( *s ) {
106
		    if (*s) {
77
			i->block = hack_name ( s, "_Aa0" ) ;
107
			i->block = hack_name(s, "_Aa0");
78
		    } else {
108
		    } else {
79
			i->block = null ;
109
			i->block = null;
80
		    }
110
		    }
81
		}
111
		}
82
		known = 1 ;
112
		known = 1;
83
	    }
113
	    }
84
	    break ;
114
	    break;
85
	}
115
	}
86
	case 'F' : {
116
	case 'F': {
87
	    if ( streq ( v, "$FILE" ) ) {
117
	    if (streq(v, "$FILE")) {
88
		filename = s ;
118
		filename = s;
89
		known = 1 ;
119
		known = 1;
90
	    } else if ( streq ( v, "$FILENAME" ) ) {
120
	    } else if (streq(v, "$FILENAME")) {
91
		if ( crt_object ) {
121
		if (crt_object) {
92
		    info *i = crt_object->u.u_info ;
122
		    info *i = crt_object->u.u_info;
93
		    i->file = s ;
123
		    i->file = s;
94
		    i->prefix = null ;
124
		    i->prefix = null;
95
		}
125
		}
96
		known = 1 ;
126
		known = 1;
97
	    }
127
	    }
98
	    break ;
128
	    break;
99
	}
129
	}
100
	case 'I' : {
130
	case 'I': {
101
	    if ( streq ( v, "$INCLNAME" ) ) {
131
	    if (streq(v, "$INCLNAME")) {
102
		if ( crt_object ) {
132
		if (crt_object) {
103
		    info *i = crt_object->u.u_info ;
133
		    info *i = crt_object->u.u_info;
104
		    if ( *s ) {
134
		    if (*s) {
105
			char *dir = output_incl_dir ;
135
			char *dir = output_incl_dir;
106
			char *sub = null ;
136
			char *sub = null;
107
			i->incl = include_name ( dir, i->api, s, sub ) ;
137
			i->incl = include_name(dir, i->api, s, sub);
108
		    } else {
138
		    } else {
109
			i->incl = null ;
139
			i->incl = null;
110
		    }
140
		    }
111
		}
141
		}
112
		known = 1 ;
142
		known = 1;
113
	    }
143
	    }
114
	    break ;
144
	    break;
115
	}
145
	}
116
	case 'L' : {
146
	case 'L': {
117
	    if ( streq ( v, "$LINKAGE" ) ) {
147
	    if (streq(v, "$LINKAGE")) {
118
		if ( crt_object ) {
148
		if (crt_object) {
119
		    info *i = crt_object->u.u_info ;
149
		    info *i = crt_object->u.u_info;
120
		    if ( *s ) {
150
		    if (*s) {
121
			i->linkage = s ;
151
			i->linkage = s;
122
		    } else {
152
		    } else {
123
			i->linkage = null ;
153
			i->linkage = null;
124
		    }
154
		    }
125
		}
155
		}
126
		known = 1 ;
156
		known = 1;
127
	    }
157
	    }
128
	    break ;
158
	    break;
129
	}
159
	}
130
	case 'M' : {
160
	case 'M': {
131
	    if ( streq ( v, "$METHOD" ) ) {
161
	    if (streq(v, "$METHOD")) {
132
		if ( crt_object ) {
162
		if (crt_object) {
133
		    info *i = crt_object->u.u_info ;
163
		    info *i = crt_object->u.u_info;
134
		    i->method = s ;
164
		    i->method = s;
135
		    if ( i->src && streq ( s, "TNC" ) ) {
165
		    if (i->src && streq(s, "TNC")) {
136
			int n = ( int ) strlen ( i->src ) - 1 ;
166
			int n = (int)strlen(i->src) - 1;
137
			i->src [n] = 'p' ;
167
			i->src [n] = 'p';
138
		    }
168
		    }
139
		}
169
		}
140
		known = 1 ;
170
		known = 1;
141
	    }
171
	    }
142
	    break ;
172
	    break;
143
	}
173
	}
144
	case 'N' : {
174
	case 'N': {
145
	    if ( streq ( v, "$NAMESPACE" ) ) {
175
	    if (streq(v, "$NAMESPACE")) {
146
		if ( crt_object ) {
176
		if (crt_object) {
147
		    info *i = crt_object->u.u_info ;
177
		    info *i = crt_object->u.u_info;
148
		    if ( *s ) {
178
		    if (*s) {
149
			i->nspace = s ;
179
			i->nspace = s;
150
		    } else {
180
		    } else {
151
			i->nspace = null ;
181
			i->nspace = null;
152
		    }
182
		    }
153
		}
183
		}
154
		known = 1 ;
184
		known = 1;
155
	    }
185
	    }
156
	    break ;
186
	    break;
157
	}
187
	}
158
	case 'P' : {
188
	case 'P': {
159
	    if ( streq ( v, "$PREFIX" ) ) {
189
	    if (streq(v, "$PREFIX")) {
160
		if ( crt_object ) crt_object->u.u_info->prefix = s ;
190
		if (crt_object)crt_object->u.u_info->prefix = s;
161
		known = 1 ;
191
		known = 1;
162
	    } else if ( streq ( v, "$PROTECT" ) ) {
192
	    } else if (streq(v, "$PROTECT")) {
163
		if ( crt_object ) crt_object->u.u_info->protect = s ;
193
		if (crt_object)crt_object->u.u_info->protect = s;
164
		known = 1 ;
194
		known = 1;
165
	    }
195
	    }
166
	    break ;
196
	    break;
167
	}
197
	}
168
	case 'S' : {
198
	case 'S': {
169
	    if ( streq ( v, "$SOURCENAME" ) ) {
199
	    if (streq(v, "$SOURCENAME")) {
170
		if ( crt_object ) {
200
		if (crt_object) {
171
		    info *i = crt_object->u.u_info ;
201
		    info *i = crt_object->u.u_info;
172
		    if ( *s ) {
202
		    if (*s) {
173
			char *dir = output_src_dir ;
203
			char *dir = output_src_dir;
174
			char *sub = null ;
204
			char *sub = null;
175
			i->src = src_name ( dir, i->api, s, sub ) ;
205
			i->src = src_name(dir, i->api, s, sub);
176
		    } else {
206
		    } else {
177
			i->src = null ;
207
			i->src = null;
178
		    }
208
		    }
179
		}
209
		}
180
		known = 1 ;
210
		known = 1;
181
	    } else if ( streq ( v, "$SUBSETNAME" ) ) {
211
	    } else if (streq(v, "$SUBSETNAME")) {
182
		if ( crt_object ) {
212
		if (crt_object) {
183
		    info *i = crt_object->u.u_info ;
213
		    info *i = crt_object->u.u_info;
184
		    i->subset = s ;
214
		    i->subset = s;
185
		    i->prefix = null ;
215
		    i->prefix = null;
186
		}
216
		}
187
		known = 1 ;
217
		known = 1;
188
	    }
218
	    }
189
	    break ;
219
	    break;
190
	}
220
	}
191
	case 'V' : {
221
	case 'V': {
192
	    if ( streq ( v, "$VERSION" ) ) {
222
	    if (streq(v, "$VERSION")) {
193
		if ( crt_object ) crt_object->u.u_info->version = s ;
223
		if (crt_object)crt_object->u.u_info->version = s;
194
		known = 1 ;
224
		known = 1;
195
	    }
225
	    }
196
	    break ;
226
	    break;
197
	}
227
	}
198
    }
228
    }
199
    if ( !known ) error ( ERR_SERIOUS, "Unknown string variable, '%s'", v ) ;
229
    if (!known)error(ERR_SERIOUS, "Unknown string variable, '%s'", v);
200
    return ;
230
    return;
201
}
231
}
202
 
232
 
203
 
233
 
204
/*
234
/*
205
    SET AN INTEGER VARIABLE
235
    SET AN INTEGER VARIABLE
206
 
236
 
207
    This routine sets the integer variable with identifier v to have value n.
237
    This routine sets the integer variable with identifier v to have value n.
208
*/
238
*/
209
 
239
 
210
void set_integer
240
void
211
    PROTO_N ( ( v, n ) )
-
 
212
    PROTO_T ( char *v X int n )
241
set_integer(char *v, int n)
213
{
242
{
214
    boolean known = 0 ;
243
    boolean known = 0;
215
    switch ( v [1] ) {
244
    switch (v [1]) {
216
	case 'I' : {
245
	case 'I': {
217
	    if ( streq ( v, "$INTERFACE" ) ) {
246
	    if (streq(v, "$INTERFACE")) {
218
		if ( crt_object ) {
247
		if (crt_object) {
219
		    crt_object->u.u_info->tokens = ( boolean ) n ;
248
		    crt_object->u.u_info->tokens = (boolean)n;
220
		}
249
		}
221
		known = 1 ;
250
		known = 1;
222
	    }
251
	    }
223
	    break ;
252
	    break;
224
	}
253
	}
225
	case 'L' : {
254
	case 'L': {
226
	    if ( streq ( v, "$LINE" ) ) {
255
	    if (streq(v, "$LINE")) {
227
		line_no = n ;
256
		line_no = n;
228
		known = 1 ;
257
		known = 1;
229
	    }
258
	    }
230
	    break ;
259
	    break;
231
	}
260
	}
232
	case 'U' : {
261
	case 'U': {
233
	    if ( streq ( v, "$UNIQUE" ) ) {
262
	    if (streq(v, "$UNIQUE")) {
234
		unique_names = ( boolean ) n ;
263
		unique_names = (boolean)n;
235
		known = 1 ;
264
		known = 1;
236
	    }
265
	    }
237
	    break ;
266
	    break;
238
	}
267
	}
239
	case 'V' : {
268
	case 'V': {
240
	    if ( streq ( v, "$VERBOSE" ) ) {
269
	    if (streq(v, "$VERBOSE")) {
241
		verbose = n ;
270
		verbose = n;
242
		known = 1 ;
271
		known = 1;
243
	    }
272
	    }
244
	    break ;
273
	    break;
245
	}
274
	}
246
    }
275
    }
247
    if ( !known ) error ( ERR_SERIOUS, "Unknown integer variable, '%s'", v ) ;
276
    if (!known)error(ERR_SERIOUS, "Unknown integer variable, '%s'", v);
248
    return ;
277
    return;
249
}
278
}