1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*@@
@file RecordImplementation.c
@date Wed Jan 13 21:03:55 1999
@author Tom Goodale
@desc
@enddesc
@@*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "StoreNamedData.h"
static char *rcsid = "$Header$";
typedef struct
{
int n_thorns;
char **thornlist;
} t_ImplementationData;
static pNamedData *implementation_data = NULL;
/*@@
@routine CCTKi_RegisterImplementation
@date Wed Jan 13 23:23:00 1999
@author Tom Goodale
@desc
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
int CCTKi_RegisterImplementation(const char *implementation,
const char *thorn)
{
int retval;
char **temp;
t_ImplementationData *data;
if((data = (t_ImplementationData *)GetNamedData(implementation_data, implementation)))
{
data->n_thorns++;
temp = (char **)realloc(data->thornlist,data->n_thorns*sizeof(char *));
if(temp)
{
data->thornlist = temp;
data->thornlist[data->n_thorns-1] = (char *)malloc((strlen(thorn)+1)*sizeof(char));
if(data->thornlist[data->n_thorns-1])
{
strcpy(data->thornlist[data->n_thorns-1], thorn);
retval = 0;
}
else
{
retval = 4;
}
}
else
{
fprintf(stderr, "Unable to allocate memory for new thorn %s\n", thorn);
retval = 1;
}
}
else
{
data = (t_ImplementationData *)malloc(sizeof(t_ImplementationData));
if(data)
{
data->thornlist = (char **)malloc(sizeof(char *));
if(data->thornlist)
{
data->thornlist[0] = (char *)malloc((strlen(thorn)+1)*sizeof(char));
if(data->thornlist[0])
{
strcpy(data->thornlist[0], thorn);
data->n_thorns = 1;
StoreNamedData(&implementation_data,implementation, data);
retval = 0;
}
else
{
retval = 4;
}
}
else
{
fprintf(stderr, "Unable to allocate memory for new thorn %s\n", thorn);
retval = 3;
}
}
else
{
fprintf(stderr, "Unable to allocate memory for new thorn %s\n", thorn);
retval = 2;
}
}
return retval;
}
/*@@
@routine GetImplementationThorns
@date Wed Jan 13 23:22:43 1999
@author Tom Goodale
@desc
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
int GetImplementationThorns(const char *implementation, char ***thornlist)
{
int retval;
t_ImplementationData *data;
if((data = (t_ImplementationData *)GetNamedData(implementation_data, implementation)))
{
*thornlist = data->thornlist;
retval = data->n_thorns;
}
else
{
*thornlist = NULL;
retval = 0;
}
return retval;
}
|