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 |
/**** cstring-list.c --- String list ADT.
|
|
|
32 |
*
|
|
|
33 |
** Author: Steve Folkes <smf@hermes.mod.uk>
|
|
|
34 |
*
|
|
|
35 |
**** Commentary:
|
|
|
36 |
*
|
|
|
37 |
* This file implements the string list facility specified in the file
|
|
|
38 |
* "cstring-list.h". See that file for more details.
|
|
|
39 |
*
|
|
|
40 |
**** Change Log:
|
|
|
41 |
* $Log: cstring-list.c,v $
|
|
|
42 |
* Revision 1.1.1.1 1998/01/17 15:57:17 release
|
|
|
43 |
* First version to be checked into rolling release.
|
|
|
44 |
*
|
|
|
45 |
* Revision 1.2 1994/12/12 11:44:30 smf
|
|
|
46 |
* Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
|
|
|
47 |
* OSSG C Coding Standards.
|
|
|
48 |
*
|
|
|
49 |
* Revision 1.1.1.1 1994/07/25 16:05:48 smf
|
|
|
50 |
* Initial import of library shared files.
|
|
|
51 |
*
|
|
|
52 |
**/
|
|
|
53 |
|
|
|
54 |
/****************************************************************************/
|
|
|
55 |
|
|
|
56 |
#include "cstring.h"
|
|
|
57 |
#include "cstring-list.h"
|
|
|
58 |
|
|
|
59 |
/*--------------------------------------------------------------------------*/
|
|
|
60 |
|
|
|
61 |
void
|
|
|
62 |
cstring_list_init PROTO_N ((list))
|
|
|
63 |
PROTO_T (CStringListP list)
|
|
|
64 |
{
|
|
|
65 |
list->head = NIL (CStringListEntryP);
|
|
|
66 |
list->tail = &(list->head);
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
void
|
|
|
70 |
cstring_list_append PROTO_N ((list, string))
|
|
|
71 |
PROTO_T (CStringListP list X
|
|
|
72 |
CStringP string)
|
|
|
73 |
{
|
|
|
74 |
CStringListEntryP entry = ALLOCATE (CStringListEntryT);
|
|
|
75 |
|
|
|
76 |
entry->next = NIL (CStringListEntryP);
|
|
|
77 |
entry->string = string;
|
|
|
78 |
*(list->tail) = entry;
|
|
|
79 |
list->tail = &(entry->next);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
BoolT
|
|
|
83 |
cstring_list_contains PROTO_N ((list, string))
|
|
|
84 |
PROTO_T (CStringListP list X
|
|
|
85 |
CStringP string)
|
|
|
86 |
{
|
|
|
87 |
CStringListEntryP entry = list->head;
|
|
|
88 |
while (entry != NIL (CStringListEntryP)) {
|
|
|
89 |
if (cstring_equal (string, entry->string)) {
|
|
|
90 |
return (TRUE);
|
|
|
91 |
}
|
|
|
92 |
entry = entry->next;
|
|
|
93 |
}
|
|
|
94 |
return (FALSE);
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
CStringListEntryP
|
|
|
98 |
cstring_list_head PROTO_N ((list))
|
|
|
99 |
PROTO_T (CStringListP list)
|
|
|
100 |
{
|
|
|
101 |
return (list->head);
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
CStringP
|
|
|
105 |
cstring_list_entry_string PROTO_N ((entry))
|
|
|
106 |
PROTO_T (CStringListEntryP entry)
|
|
|
107 |
{
|
|
|
108 |
return (entry->string);
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
CStringListEntryP
|
|
|
112 |
cstring_list_entry_deallocate PROTO_N ((entry))
|
|
|
113 |
PROTO_T (CStringListEntryP entry)
|
|
|
114 |
{
|
|
|
115 |
CStringListEntryP next = entry->next;
|
|
|
116 |
|
|
|
117 |
DEALLOCATE (entry);
|
|
|
118 |
return (next);
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
/*
|
|
|
122 |
* Local variables(smf):
|
|
|
123 |
* eval: (include::add-path-entry "../os-interface" "../generated")
|
|
|
124 |
* end:
|
|
|
125 |
**/
|