/* * Called from the xml parser. * Here is where we begin parsing <application>... or <instance>... * or <adaptor>... */ static void createElement(XMLCDocument *document, const XMLCCharacter *name, const unsigned int length) { WOXMLEdits *config = (WOXMLEdits *)document; if (config->error != 0) /* would be nice to tell parser to stop */ return; config->errorLocation = name; if (length == 7 && strncasecmp(name, "adaptor", length) == 0) { /* do nothing; don't generate a warning */ } else if (length == 11 && strncasecmp(name, "application", length) == 0) { /* begin <application> */ if (config->current_element != NULL) { WOLog(WO_ERR,"Error parsing config: found unexpected <application> tag"); config->error = 1; return; } /* create new app settings dictionary, instance list, and set current_element to the app dictionary*/ config->current_app = st_new(8); wolist_add(config->new_apps, config->current_app); config->current_app_instances = wolist_new(8); wolist_add(config->new_app_instances, config->current_app_instances); config->current_element = config->current_app; } else if (length == 8 && strncasecmp(name, "instance", length) == 0) { /* begin <instance> */ if (config->current_element != config->current_app || config->current_app == NULL) { WOLog(WO_ERR,"Error parsing config: found unexpected <instance> tag"); config->error = 1; return; } /* create new instance settings dictionary and set current_element to point to it */ config->current_instance = st_new(8); wolist_add(config->current_app_instances, config->current_instance); config->current_element = config->current_instance; } else { /* Got something unexpected. Ignore the tag. */ char *buffer = WOMALLOC(length+1); strncpy(buffer,name,length); buffer[length] = '\0'; WOLog(WO_WARN,"Unknown tag in XML: \"%s\"",buffer); config->current_element = NULL; WOFREE(buffer); } return; }
void *sha_setLocalDataForKey(ShmemArray *array, unsigned int elementNumber, const char *key, void *data, sha_clearLocalDataCallback clearCallback) { void *oldValue = NULL; if (elementNumber < array->elementCount) { if (!array->elements[elementNumber].localData) array->elements[elementNumber].localData = sd_new(1); oldValue = sd_add(array->elements[elementNumber].localData, key, data); if (clearCallback != NULL) { if (!array->elements[elementNumber].localDataCleanupCallbacks) array->elements[elementNumber].localDataCleanupCallbacks = wolist_new(1); if (wolist_indexOf(array->elements[elementNumber].localDataCleanupCallbacks, (void *)clearCallback) == wolist_elementNotFound) wolist_add(array->elements[elementNumber].localDataCleanupCallbacks, (void *)clearCallback); } } return oldValue; }