Esempio n. 1
0
void sha_clearLocalData(ShmemArray *array, unsigned int elementNumber)
{
   int i;
   if (elementNumber < array->elementCount)
   {
      if (array->elements[elementNumber].localData)
      {
         if (array->elements[elementNumber].localDataCleanupCallbacks != NULL)
         {
            for (i=wolist_count(array->elements[elementNumber].localDataCleanupCallbacks)-1; i>=0; i--)
            {
               sha_clearLocalDataCallback clear_func = (sha_clearLocalDataCallback) wolist_elementAt(array->elements[elementNumber].localDataCleanupCallbacks, i);
               if (clear_func)
                  clear_func(array, elementNumber);
               wolist_removeAt(array->elements[elementNumber].localDataCleanupCallbacks, i);
            }
            wolist_dealloc(array->elements[elementNumber].localDataCleanupCallbacks);
            array->elements[elementNumber].localDataCleanupCallbacks = NULL;
         }
         sd_perform(array->elements[elementNumber].localData, sha_warnAboutLeftoverLocalData, 0);
         sd_free(array->elements[elementNumber].localData);
         array->elements[elementNumber].localData = NULL;
      }
   }
}
Esempio n. 2
0
/*
 * This function cleans up all the lists and dictionaries created while parsing the config.
 */
static void freeWOXMLEdits(WOXMLEdits *config)
{
   int i;

   for (i=0; i<wolist_count(config->new_apps); i++)
      st_free(wolist_elementAt(config->new_apps, i));
   wolist_dealloc(config->new_apps);

   for (i=0; i<wolist_count(config->new_app_instances); i++)
   {
      int j;
      list *instances = wolist_elementAt(config->new_app_instances, i);
      for (j=0; j<wolist_count(instances); j++)
         st_free(wolist_elementAt(instances, j));
      wolist_dealloc(instances);
   }
   wolist_dealloc(config->new_app_instances);
}
Esempio n. 3
0
/*
 *	The entry point for the parser.
 *      Returns nonzero if there was an error during parsing.
 */
static int xml_parseConfiguration(char *buf, int len)
{
   XMLCDocumentHandler handler;
   WOXMLEdits config;
   XMLCParser *parser;
   int error = 0, i;

   /* initialize the config struct */
   config.current_element = NULL;
   config.new_apps = wolist_new(16);
   config.current_app = NULL;
   config.current_app_instances = NULL;
   config.current_instance = NULL;
   config.new_app_instances =  wolist_new(16);
   config.error = 0;
   config.errorLocation = buf;
   
   if (len == 0)
      return 1; 		/* no content is considered an error */
   
   /* Set up a new document handler struct for the parser */
   memcpy(&handler, &_document, sizeof(XMLCDocumentHandler));
   handler.document = (XMLCDocument *)(&config);

   /* set up and invoke the xml parser */
   parser = xmlcParserInit();
   xmlcTokenizerSetBuffer(parser->tokenizer, buf, len);
   xmlcParserSetPreserveWhiteSpace(parser, 0);
   error = (int)xmlcParserParse(parser, &handler);

   if (error != 0) {
      /* config error */
      WOLog(WO_ERR,"Error parsing configuration: %s", xmlcParserErrorDescription(error));
      if ((intptr_t)config.errorLocation < (intptr_t)buf + len)
      {
         char *badconfig = WOMALLOC((len+1)*sizeof(char));
         strncpy(badconfig, buf, len);
         badconfig[len] = '\0';
         WOLog(WO_ERR,"Error near:\n%s", config.errorLocation);
         WOFREE(badconfig);
      }
   } else {
      /*
       *	load the new settings...
       */
      if (config.new_apps)
         for (i=0; i<wolist_count(config.new_apps); i++)
            ac_updateApplication((strtbl *)wolist_elementAt(config.new_apps, i), (list *)wolist_elementAt(config.new_app_instances, i));
   }

   /* clean up and return */
   freeWOXMLEdits(&config);
   xmlcParserDealloc(parser);
   return error;
}