From e87f6d8163aea9cc9b071a96759250804238b0f3 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 21 Sep 2000 13:19:32 +0000 Subject: Moved advertised file stuff from GHExtensions.c to here. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@96 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a --- src/AdvertisedFiles.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 src/AdvertisedFiles.c diff --git a/src/AdvertisedFiles.c b/src/AdvertisedFiles.c new file mode 100644 index 0000000..a24ae5b --- /dev/null +++ b/src/AdvertisedFiles.c @@ -0,0 +1,143 @@ + /*@@ + @file AdvertisedFiles.c + @date Mon 18 Sep 2000 + @author Thomas Radke + @desc + IOUtil file advertising stuff. + @enddesc + @history + @endhistory + @@*/ + +#include + +#include "cctk.h" +#include "StoreNamedData.h" +#include "ioGH.h" +#include "ioutil_AdvertisedFiles.h" + + +static char *rcsid = "$Header$"; +CCTK_FILEVERSION(CactusBase_IOUtil_AdvertisedFiles_c) + + +/******************************************************************** + ********************* Local Data ***************************** + ********************************************************************/ + +/* database holding all registered listeners for file advertising */ +static pNamedData *listener_DB = NULL; + + + /*@@ + @routine IOUtil_RegisterAdvertisedFileListener + @date Wed May 17 2000 + @author Thomas Radke + @desc + Registers a listener with its callbacks for + advertised file handling + @enddesc + @history + @endhistory + @var GH + @vdesc pointer to grid hierarchy + @vtype cGH * + @vio in + @endvar + @var listener + @vdesc identification of the listener to be registered + @vtype const char * + @vio in + @endvar + @var callbacks + @vdesc structure containing the listener's callback routines + @vtype const ioAdvertisedFileListenerCallbacks * + @vio in + @endvar + @returntype int + @returndesc This routine returns + 0 on success + -1 if memory allocation failed or NULL pointers were passed + @endreturndesc +@@*/ + +int IOUtil_RegisterAdvertisedFileListener (cGH *GH, const char *listener, + const ioAdvertisedFileListenerCallbacks *callbacks) +{ + ioGH *myGH; + int retval = -1; + ioAdvertisedFileListenerCallbacks *new_callbacks; + + + if (listener && callbacks) + { + new_callbacks = (ioAdvertisedFileListenerCallbacks *) + malloc (sizeof (ioAdvertisedFileListenerCallbacks)); + if (new_callbacks) + { + *new_callbacks = *callbacks; + myGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + retval = StoreNamedData (&listener_DB, listener, new_callbacks); + if (retval) + free (new_callbacks); + } + } + + return (retval); +} + + +/*@@ + @routine IOUtil_AdvertiseFile + @date Wed May 17 2000 + @author Thomas Radke + @desc + Adds a filename to the list of advertised files for downloading. + The routine calls all listeners which are currently registered + for advertised file handling. + @enddesc + @history + @endhistory + @var GH + @vdesc pointer to grid hierarchy + @vtype cGH * + @vio in + @endvar + @var filename + @vdesc name of the file to advertise + @vtype const char * + @vio in + @endvar + @var description + @vdesc structure which describes the file + @vtype const ioAdvertisedFileDesc * + @vio in + @endvar + @returntype int + @returndesc This routine returns the logically OR'ed return values + of all listeners' advertise callbacks called. + @endreturndesc +@@*/ + +int IOUtil_AdvertiseFile (cGH *GH, const char *filename, + const ioAdvertisedFileDesc *description) +{ + int retval = 0; + pNamedData *listener; + ioAdvertisedFileListenerCallbacks *callbacks; + + + /* get the listener database from IOUtil's GH extension */ + listener = listener_DB; + + /* loop through all listeners' advertise() callbacks */ + while (listener) + { + callbacks = (ioAdvertisedFileListenerCallbacks *) listener->data; + if (callbacks && callbacks->advertise) + retval |= (callbacks->advertise) (GH, filename, description); + listener = listener->next; + } + + return (retval); +} -- cgit v1.2.3