summaryrefslogtreecommitdiff
path: root/src/main/RecordImplementation.c
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-01-13 20:32:37 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-01-13 20:32:37 +0000
commit1e947263c8f387494c2b97f1820a82e06a711f30 (patch)
tree1ba830a7470d3588da1a1c0ce507aa27a551ab21 /src/main/RecordImplementation.c
parent2cd6be2a219451c2d56490a6c1416f3e04998a80 (diff)
Added functions to register thorns.
Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@50 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/RecordImplementation.c')
-rw-r--r--src/main/RecordImplementation.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/main/RecordImplementation.c b/src/main/RecordImplementation.c
new file mode 100644
index 00000000..9bac6526
--- /dev/null
+++ b/src/main/RecordImplementation.c
@@ -0,0 +1,96 @@
+ /*@@
+ @file RecordImplementation.c
+ @date Wed Jan 13 21:03:55 1999
+ @author Tom Goodale
+ @desc
+
+ @enddesc
+ @@*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "StoreNamedData.h";
+
+
+
+typedef struct
+{
+ int n_thorns;
+ char **thornlist;
+} t_ImplementationData;
+
+static pNamedData *implementation_data = NULL;
+
+
+int CCTK_RecordImplementation(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;
+}
+