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 55... Line 85...
55
#include "non-local.h"
85
#include "non-local.h"
56
 
86
 
57
/*--------------------------------------------------------------------------*/
87
/*--------------------------------------------------------------------------*/
58
 
88
 
59
void
89
void
60
non_local_list_init PROTO_N ((non_locals))
90
non_local_list_init(NonLocalListP non_locals)
61
		    PROTO_T (NonLocalListP non_locals)
-
 
62
{
91
{
63
    non_locals->head = NIL (NonLocalEntryP);
92
    non_locals->head = NIL(NonLocalEntryP);
64
    non_locals->tail = &(non_locals->head);
93
    non_locals->tail = &(non_locals->head);
65
}
94
}
66
 
95
 
67
NonLocalEntryP
96
NonLocalEntryP
68
non_local_list_add PROTO_N ((non_locals, name, type))
97
non_local_list_add(NonLocalListP non_locals, EntryP name, EntryP type)
69
		   PROTO_T (NonLocalListP non_locals X
-
 
70
			    EntryP        name X
-
 
71
			    EntryP        type)
-
 
72
{
98
{
73
    NonLocalEntryP entry = ALLOCATE (NonLocalEntryT);
99
    NonLocalEntryP entry = ALLOCATE(NonLocalEntryT);
74
 
100
 
75
    entry->next         = NIL (NonLocalEntryP);
101
    entry->next         = NIL(NonLocalEntryP);
76
    entry->name         = name;
102
    entry->name         = name;
77
    entry->type         = type;
103
    entry->type         = type;
78
    entry->initialiser  = NIL (EntryP);
104
    entry->initialiser  = NIL(EntryP);
79
    *(non_locals->tail) = entry;
105
    *(non_locals->tail) = entry;
80
    non_locals->tail    = &(entry->next);
106
    non_locals->tail    = &(entry->next);
81
    return (entry);
107
    return(entry);
82
}
108
}
83
 
109
 
84
BoolT
110
BoolT
85
non_local_list_is_empty PROTO_N ((non_locals))
111
non_local_list_is_empty(NonLocalListP non_locals)
86
			PROTO_T (NonLocalListP non_locals)
-
 
87
{
112
{
88
    return (non_locals->head == NIL (NonLocalEntryP));
113
    return(non_locals->head == NIL(NonLocalEntryP));
89
}
114
}
90
 
115
 
91
void
116
void
92
non_local_list_iter_for_table PROTO_N ((non_locals, proc, closure))
117
non_local_list_iter_for_table(NonLocalListP non_locals,
93
			      PROTO_T (NonLocalListP non_locals X
-
 
94
				       void        (*proc) PROTO_S ((EntryP,
118
			      void (*proc)(EntryP, GenericP),
95
								     GenericP))
-
 
96
				       X
-
 
97
				       GenericP      closure)
119
			      GenericP closure)
98
{
120
{
99
    NonLocalEntryP non_local;
121
    NonLocalEntryP non_local;
100
 
122
 
101
    for (non_local = non_locals->head; non_local;
123
    for (non_local = non_locals->head; non_local;
102
	 non_local = non_local->next) {
124
	 non_local = non_local->next) {
103
	entry_iter (non_local->type, TRUE, proc, closure);
125
	entry_iter(non_local->type, TRUE, proc, closure);
104
	if (non_local->initialiser) {
126
	if (non_local->initialiser) {
105
	    entry_iter (non_local->initialiser, TRUE, proc, closure);
127
	    entry_iter(non_local->initialiser, TRUE, proc, closure);
106
	}
128
	}
107
    }
129
    }
108
}
130
}
109
 
131
 
110
void
132
void
111
non_local_list_destroy PROTO_N ((non_locals))
133
non_local_list_destroy(NonLocalListP non_locals)
112
		       PROTO_T (NonLocalListP non_locals)
-
 
113
{
134
{
114
    NonLocalEntryP entry = non_locals->head;
135
    NonLocalEntryP entry = non_locals->head;
115
 
136
 
116
    while (entry) {
137
    while (entry) {
117
	NonLocalEntryP tmp = entry->next;
138
	NonLocalEntryP tmp = entry->next;
118
 
139
 
119
	DEALLOCATE (entry);
140
	DEALLOCATE(entry);
120
	entry = tmp;
141
	entry = tmp;
121
    }
142
    }
122
}
143
}
123
 
144
 
124
void
145
void
125
write_non_locals PROTO_N ((ostream, non_locals))
146
write_non_locals(OStreamP ostream, NonLocalListP non_locals)
126
		 PROTO_T (OStreamP      ostream X
-
 
127
			  NonLocalListP non_locals)
-
 
128
{
147
{
129
    NonLocalEntryP non_local;
148
    NonLocalEntryP non_local;
130
 
149
 
131
    for (non_local = non_locals->head; non_local;
150
    for (non_local = non_locals->head; non_local;
132
	 non_local = non_local->next) {
151
	 non_local = non_local->next) {
133
	ASSERT (non_local->type);
152
	ASSERT(non_local->type);
134
	ASSERT (non_local->name);
153
	ASSERT(non_local->name);
135
	write_tab (ostream);
154
	write_tab(ostream);
136
	write_key (ostream, entry_key (non_local->name));
155
	write_key(ostream, entry_key(non_local->name));
137
	write_cstring (ostream, ": ");
156
	write_cstring(ostream, ": ");
138
	write_key (ostream, entry_key (non_local->type));
157
	write_key(ostream, entry_key(non_local->type));
139
	if (non_local->initialiser) {
158
	if (non_local->initialiser) {
140
	    write_cstring (ostream, " = <");
159
	    write_cstring(ostream, " = <");
141
	    write_key (ostream, entry_key (non_local->initialiser));
160
	    write_key(ostream, entry_key(non_local->initialiser));
142
	    write_char (ostream, '>');
161
	    write_char(ostream, '>');
143
	}
162
	}
144
	write_char (ostream, ';');
163
	write_char(ostream, ';');
145
	write_newline (ostream);
164
	write_newline(ostream);
146
    }
165
    }
147
}
166
}
148
 
167
 
149
void
168
void
150
non_local_entry_set_initialiser PROTO_N ((non_local, init))
169
non_local_entry_set_initialiser(NonLocalEntryP non_local, EntryP init)
151
				PROTO_T (NonLocalEntryP non_local X
-
 
152
					 EntryP         init)
-
 
153
{
170
{
154
    non_local->initialiser = init;
171
    non_local->initialiser = init;
155
}
172
}
156
 
173
 
157
EntryP
174
EntryP
158
non_local_entry_get_initialiser PROTO_N ((non_local))
175
non_local_entry_get_initialiser(NonLocalEntryP non_local)
159
				PROTO_T (NonLocalEntryP non_local)
-
 
160
{
176
{
161
    return (non_local->initialiser);
177
    return(non_local->initialiser);
162
}
178
}
163
 
179
 
164
EntryP
180
EntryP
165
non_local_entry_get_name PROTO_N ((non_local))
181
non_local_entry_get_name(NonLocalEntryP non_local)
166
			 PROTO_T (NonLocalEntryP non_local)
-
 
167
{
182
{
168
    return (non_local->name);
183
    return(non_local->name);
169
}
184
}
170
 
185
 
171
EntryP
186
EntryP
172
non_local_entry_get_type PROTO_N ((non_local))
187
non_local_entry_get_type(NonLocalEntryP non_local)
173
			 PROTO_T (NonLocalEntryP non_local)
-
 
174
{
188
{
175
    return (non_local->type);
189
    return(non_local->type);
176
}
190
}
177

191

178
/*
192
/*
179
 * Local variables(smf):
193
 * Local variables(smf):
180
 * eval: (include::add-path-entry "../os-interface" "../library")
194
 * eval: (include::add-path-entry "../os-interface" "../library")