summaryrefslogtreecommitdiff
path: root/src/main/ActiveThorns.c
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-10-14 16:26:19 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-10-14 16:26:19 +0000
commit53b6ac14a0dccc345bab160446c0236a90b05c88 (patch)
treec47da8a35a61b4f8d14b2ab75dbb240ec316f326 /src/main/ActiveThorns.c
parent8d89e92aa46c4c26199f49126d859388260436a9 (diff)
Additions to parameter stuff and activethorns - thanks Andre.
Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@1042 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/ActiveThorns.c')
-rw-r--r--src/main/ActiveThorns.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/main/ActiveThorns.c b/src/main/ActiveThorns.c
index b38bbf6b..18ded6bd 100644
--- a/src/main/ActiveThorns.c
+++ b/src/main/ActiveThorns.c
@@ -447,6 +447,20 @@ int CCTKi_ListImplementations(FILE *file, const char *format, int active)
return retval;
}
+ /*@@
+ @routine CCTK_ImpList
+ @date Thu Oct 14 16:14:22 1999
+ @author Tom Goodale
+ @desc
+ Returns the list of implementations.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
int CCTK_ImpList(int active, char ***list, int *n_implementations)
{
int retval;
@@ -476,6 +490,108 @@ int CCTK_ImpList(int active, char ***list, int *n_implementations)
return retval;
}
+
+
+ /*@@
+ @routine CCTK_ThornList
+ @date Thu Oct 14 16:04:59 1999
+ @author Andre Merzky
+ @desc
+ Returns a list of thorns.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int CCTK_ThornList (const char* imp, char ***list, int *n_thorns)
+{
+ int retval;
+ t_sktree *node;
+ t_sktree *thornlist;
+ int alloc_size = 0;
+
+ /* FIXME */
+#define _MY_THORN_JUNK_SIZE 10
+
+ /* find all thorns for implementation */
+ thornlist = (t_sktree*) CCTK_ImpThornList (imp);
+
+
+ /* got thornlist? */
+ if (thornlist)
+ {
+ /* then we can start allocatin list */
+ alloc_size += _MY_THORN_JUNK_SIZE;
+ *list = (char **) malloc (alloc_size * sizeof (char *));
+
+ /* success? */
+ if (! (*list))
+ {
+ fprintf (stderr, "Cannot malloc paramlist*\n");
+ return (-1);
+ }
+ /* recourse thorn tree */
+ for (node = SKTreeFindFirst (thornlist), *n_thorns = 0;
+ node;
+ node = node->next, retval++)
+ {
+ /* list long enough? */
+ if ((*n_thorns) >= alloc_size)
+ {
+ /* no: realloc! */
+ alloc_size += _MY_THORN_JUNK_SIZE;
+ *list = (char **) realloc ((*list), alloc_size);
+
+ /* success? */
+ if (! (*list)) {
+ fprintf (stderr, "Cannot realloc paramlist*\n");
+ return (-1);
+ }
+
+ }
+
+ /* store thorn */
+ (*list)[*n_thorns] = (char *) malloc ((strlen (node->key) + 1) * sizeof (char));
+ strcpy ((*list)[*n_thorns], node->key);
+ (*n_thorns)++;
+ }
+ }
+
+ /* if necessary, shrink paramlist again. */
+ if ((*n_thorns) < alloc_size)
+ {
+ alloc_size += (*n_thorns);
+ *list = (char **) realloc ((*list), alloc_size);
+
+ if (! (*list))
+ {
+ fprintf (stderr, "Cannot realloc list*\n");
+ return (-1);
+ }
+ }
+
+ /* done */
+ return retval;
+}
+
+
+ /*@@
+ @routine CCTK_ActivatingThorn
+ @date Thu Oct 14 16:08:42 1999
+ @author Tom Goodale
+ @desc
+ Finds the thorn which activated a particular implementation
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
const char *CCTK_ActivatingThorn(const char *name)
{
const char *retval;