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