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 |
/**** non-local.c --- Non local name ADT.
|
|
|
32 |
*
|
|
|
33 |
** Author: Steve Folkes <smf@hermes.mod.uk>
|
|
|
34 |
*
|
|
|
35 |
**** Commentary:
|
|
|
36 |
*
|
|
|
37 |
* This file implements the non local name list manipulation routines.
|
|
|
38 |
*
|
|
|
39 |
**** Change Log:
|
|
|
40 |
* $Log: non-local.c,v $
|
|
|
41 |
* Revision 1.1.1.1 1998/01/17 15:57:46 release
|
|
|
42 |
* First version to be checked into rolling release.
|
|
|
43 |
*
|
|
|
44 |
* Revision 1.2 1994/12/15 09:58:27 smf
|
|
|
45 |
* Brought into line with OSSG C Coding Standards Document, as per
|
|
|
46 |
* "CR94_178.sid+tld-update".
|
|
|
47 |
*
|
|
|
48 |
* Revision 1.1.1.1 1994/07/25 16:04:36 smf
|
|
|
49 |
* Initial import of SID 1.8 non shared files.
|
|
|
50 |
*
|
|
|
51 |
**/
|
|
|
52 |
|
|
|
53 |
/****************************************************************************/
|
|
|
54 |
|
|
|
55 |
#include "non-local.h"
|
|
|
56 |
|
|
|
57 |
/*--------------------------------------------------------------------------*/
|
|
|
58 |
|
|
|
59 |
void
|
|
|
60 |
non_local_list_init PROTO_N ((non_locals))
|
|
|
61 |
PROTO_T (NonLocalListP non_locals)
|
|
|
62 |
{
|
|
|
63 |
non_locals->head = NIL (NonLocalEntryP);
|
|
|
64 |
non_locals->tail = &(non_locals->head);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
NonLocalEntryP
|
|
|
68 |
non_local_list_add PROTO_N ((non_locals, name, type))
|
|
|
69 |
PROTO_T (NonLocalListP non_locals X
|
|
|
70 |
EntryP name X
|
|
|
71 |
EntryP type)
|
|
|
72 |
{
|
|
|
73 |
NonLocalEntryP entry = ALLOCATE (NonLocalEntryT);
|
|
|
74 |
|
|
|
75 |
entry->next = NIL (NonLocalEntryP);
|
|
|
76 |
entry->name = name;
|
|
|
77 |
entry->type = type;
|
|
|
78 |
entry->initialiser = NIL (EntryP);
|
|
|
79 |
*(non_locals->tail) = entry;
|
|
|
80 |
non_locals->tail = &(entry->next);
|
|
|
81 |
return (entry);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
BoolT
|
|
|
85 |
non_local_list_is_empty PROTO_N ((non_locals))
|
|
|
86 |
PROTO_T (NonLocalListP non_locals)
|
|
|
87 |
{
|
|
|
88 |
return (non_locals->head == NIL (NonLocalEntryP));
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
void
|
|
|
92 |
non_local_list_iter_for_table PROTO_N ((non_locals, proc, closure))
|
|
|
93 |
PROTO_T (NonLocalListP non_locals X
|
|
|
94 |
void (*proc) PROTO_S ((EntryP,
|
|
|
95 |
GenericP))
|
|
|
96 |
X
|
|
|
97 |
GenericP closure)
|
|
|
98 |
{
|
|
|
99 |
NonLocalEntryP non_local;
|
|
|
100 |
|
|
|
101 |
for (non_local = non_locals->head; non_local;
|
|
|
102 |
non_local = non_local->next) {
|
|
|
103 |
entry_iter (non_local->type, TRUE, proc, closure);
|
|
|
104 |
if (non_local->initialiser) {
|
|
|
105 |
entry_iter (non_local->initialiser, TRUE, proc, closure);
|
|
|
106 |
}
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
void
|
|
|
111 |
non_local_list_destroy PROTO_N ((non_locals))
|
|
|
112 |
PROTO_T (NonLocalListP non_locals)
|
|
|
113 |
{
|
|
|
114 |
NonLocalEntryP entry = non_locals->head;
|
|
|
115 |
|
|
|
116 |
while (entry) {
|
|
|
117 |
NonLocalEntryP tmp = entry->next;
|
|
|
118 |
|
|
|
119 |
DEALLOCATE (entry);
|
|
|
120 |
entry = tmp;
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
void
|
|
|
125 |
write_non_locals PROTO_N ((ostream, non_locals))
|
|
|
126 |
PROTO_T (OStreamP ostream X
|
|
|
127 |
NonLocalListP non_locals)
|
|
|
128 |
{
|
|
|
129 |
NonLocalEntryP non_local;
|
|
|
130 |
|
|
|
131 |
for (non_local = non_locals->head; non_local;
|
|
|
132 |
non_local = non_local->next) {
|
|
|
133 |
ASSERT (non_local->type);
|
|
|
134 |
ASSERT (non_local->name);
|
|
|
135 |
write_tab (ostream);
|
|
|
136 |
write_key (ostream, entry_key (non_local->name));
|
|
|
137 |
write_cstring (ostream, ": ");
|
|
|
138 |
write_key (ostream, entry_key (non_local->type));
|
|
|
139 |
if (non_local->initialiser) {
|
|
|
140 |
write_cstring (ostream, " = <");
|
|
|
141 |
write_key (ostream, entry_key (non_local->initialiser));
|
|
|
142 |
write_char (ostream, '>');
|
|
|
143 |
}
|
|
|
144 |
write_char (ostream, ';');
|
|
|
145 |
write_newline (ostream);
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
void
|
|
|
150 |
non_local_entry_set_initialiser PROTO_N ((non_local, init))
|
|
|
151 |
PROTO_T (NonLocalEntryP non_local X
|
|
|
152 |
EntryP init)
|
|
|
153 |
{
|
|
|
154 |
non_local->initialiser = init;
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
EntryP
|
|
|
158 |
non_local_entry_get_initialiser PROTO_N ((non_local))
|
|
|
159 |
PROTO_T (NonLocalEntryP non_local)
|
|
|
160 |
{
|
|
|
161 |
return (non_local->initialiser);
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
EntryP
|
|
|
165 |
non_local_entry_get_name PROTO_N ((non_local))
|
|
|
166 |
PROTO_T (NonLocalEntryP non_local)
|
|
|
167 |
{
|
|
|
168 |
return (non_local->name);
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
EntryP
|
|
|
172 |
non_local_entry_get_type PROTO_N ((non_local))
|
|
|
173 |
PROTO_T (NonLocalEntryP non_local)
|
|
|
174 |
{
|
|
|
175 |
return (non_local->type);
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
/*
|
|
|
179 |
* Local variables(smf):
|
|
|
180 |
* eval: (include::add-path-entry "../os-interface" "../library")
|
|
|
181 |
* eval: (include::add-path-entry "../generated")
|
|
|
182 |
* end:
|
|
|
183 |
**/
|