Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
7 7u83 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
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
7 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
7 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
7 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
7 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
7 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
#include "config.h"
62
#include "object.h"
63
#include "hash.h"
64
#include "name.h"
65
#include "type.h"
66
#include "utility.h"
7 7u83 67
#include "variable.h"
2 7u83 68
 
69
 
70
/*
71
    CURRENT OBJECT
72
 
73
    This is the current object, which is affected by any file property
74
    changes.
75
*/
76
 
7 7u83 77
object *crt_object = null;
2 7u83 78
 
79
 
80
/*
81
    SET A STRING VARIABLE
82
 
83
    This routine sets the string variable with identifier v to have value s.
84
*/
85
 
7 7u83 86
void
87
set_string(char *v, char *s)
2 7u83 88
{
7 7u83 89
    boolean known = 0;
90
    switch (v [1]) {
91
	case 'A': {
92
	    if (streq(v, "$APINAME")) {
93
		if (crt_object) {
94
		    info *i = crt_object->u.u_info;
95
		    i->api = s;
96
		    i->prefix = null;
2 7u83 97
		}
7 7u83 98
		known = 1;
2 7u83 99
	    }
7 7u83 100
	    break;
2 7u83 101
	}
7 7u83 102
	case 'B': {
103
	    if (streq(v, "$BLOCKNAME")) {
104
		if (crt_object) {
105
		    info *i = crt_object->u.u_info;
106
		    if (*s) {
107
			i->block = hack_name(s, "_Aa0");
2 7u83 108
		    } else {
7 7u83 109
			i->block = null;
2 7u83 110
		    }
111
		}
7 7u83 112
		known = 1;
2 7u83 113
	    }
7 7u83 114
	    break;
2 7u83 115
	}
7 7u83 116
	case 'F': {
117
	    if (streq(v, "$FILE")) {
118
		filename = s;
119
		known = 1;
120
	    } else if (streq(v, "$FILENAME")) {
121
		if (crt_object) {
122
		    info *i = crt_object->u.u_info;
123
		    i->file = s;
124
		    i->prefix = null;
2 7u83 125
		}
7 7u83 126
		known = 1;
2 7u83 127
	    }
7 7u83 128
	    break;
2 7u83 129
	}
7 7u83 130
	case 'I': {
131
	    if (streq(v, "$INCLNAME")) {
132
		if (crt_object) {
133
		    info *i = crt_object->u.u_info;
134
		    if (*s) {
135
			char *dir = output_incl_dir;
136
			char *sub = null;
137
			i->incl = include_name(dir, i->api, s, sub);
2 7u83 138
		    } else {
7 7u83 139
			i->incl = null;
2 7u83 140
		    }
141
		}
7 7u83 142
		known = 1;
2 7u83 143
	    }
7 7u83 144
	    break;
2 7u83 145
	}
7 7u83 146
	case 'L': {
147
	    if (streq(v, "$LINKAGE")) {
148
		if (crt_object) {
149
		    info *i = crt_object->u.u_info;
150
		    if (*s) {
151
			i->linkage = s;
2 7u83 152
		    } else {
7 7u83 153
			i->linkage = null;
2 7u83 154
		    }
155
		}
7 7u83 156
		known = 1;
2 7u83 157
	    }
7 7u83 158
	    break;
2 7u83 159
	}
7 7u83 160
	case 'M': {
161
	    if (streq(v, "$METHOD")) {
162
		if (crt_object) {
163
		    info *i = crt_object->u.u_info;
164
		    i->method = s;
165
		    if (i->src && streq(s, "TNC")) {
166
			int n = (int)strlen(i->src) - 1;
167
			i->src [n] = 'p';
2 7u83 168
		    }
169
		}
7 7u83 170
		known = 1;
2 7u83 171
	    }
7 7u83 172
	    break;
2 7u83 173
	}
7 7u83 174
	case 'N': {
175
	    if (streq(v, "$NAMESPACE")) {
176
		if (crt_object) {
177
		    info *i = crt_object->u.u_info;
178
		    if (*s) {
179
			i->nspace = s;
2 7u83 180
		    } else {
7 7u83 181
			i->nspace = null;
2 7u83 182
		    }
183
		}
7 7u83 184
		known = 1;
2 7u83 185
	    }
7 7u83 186
	    break;
2 7u83 187
	}
7 7u83 188
	case 'P': {
189
	    if (streq(v, "$PREFIX")) {
190
		if (crt_object)crt_object->u.u_info->prefix = s;
191
		known = 1;
192
	    } else if (streq(v, "$PROTECT")) {
193
		if (crt_object)crt_object->u.u_info->protect = s;
194
		known = 1;
2 7u83 195
	    }
7 7u83 196
	    break;
2 7u83 197
	}
7 7u83 198
	case 'S': {
199
	    if (streq(v, "$SOURCENAME")) {
200
		if (crt_object) {
201
		    info *i = crt_object->u.u_info;
202
		    if (*s) {
203
			char *dir = output_src_dir;
204
			char *sub = null;
205
			i->src = src_name(dir, i->api, s, sub);
2 7u83 206
		    } else {
7 7u83 207
			i->src = null;
2 7u83 208
		    }
209
		}
7 7u83 210
		known = 1;
211
	    } else if (streq(v, "$SUBSETNAME")) {
212
		if (crt_object) {
213
		    info *i = crt_object->u.u_info;
214
		    i->subset = s;
215
		    i->prefix = null;
2 7u83 216
		}
7 7u83 217
		known = 1;
2 7u83 218
	    }
7 7u83 219
	    break;
2 7u83 220
	}
7 7u83 221
	case 'V': {
222
	    if (streq(v, "$VERSION")) {
223
		if (crt_object)crt_object->u.u_info->version = s;
224
		known = 1;
2 7u83 225
	    }
7 7u83 226
	    break;
2 7u83 227
	}
228
    }
7 7u83 229
    if (!known)error(ERR_SERIOUS, "Unknown string variable, '%s'", v);
230
    return;
2 7u83 231
}
232
 
233
 
234
/*
235
    SET AN INTEGER VARIABLE
236
 
237
    This routine sets the integer variable with identifier v to have value n.
238
*/
239
 
7 7u83 240
void
241
set_integer(char *v, int n)
2 7u83 242
{
7 7u83 243
    boolean known = 0;
244
    switch (v [1]) {
245
	case 'I': {
246
	    if (streq(v, "$INTERFACE")) {
247
		if (crt_object) {
248
		    crt_object->u.u_info->tokens = (boolean)n;
2 7u83 249
		}
7 7u83 250
		known = 1;
2 7u83 251
	    }
7 7u83 252
	    break;
2 7u83 253
	}
7 7u83 254
	case 'L': {
255
	    if (streq(v, "$LINE")) {
256
		line_no = n;
257
		known = 1;
2 7u83 258
	    }
7 7u83 259
	    break;
2 7u83 260
	}
7 7u83 261
	case 'U': {
262
	    if (streq(v, "$UNIQUE")) {
263
		unique_names = (boolean)n;
264
		known = 1;
2 7u83 265
	    }
7 7u83 266
	    break;
2 7u83 267
	}
7 7u83 268
	case 'V': {
269
	    if (streq(v, "$VERBOSE")) {
270
		verbose = n;
271
		known = 1;
2 7u83 272
	    }
7 7u83 273
	    break;
2 7u83 274
	}
275
    }
7 7u83 276
    if (!known)error(ERR_SERIOUS, "Unknown integer variable, '%s'", v);
277
    return;
2 7u83 278
}