int int_value = atoi(old_value);
int_value = atoi(old_value);
processCibRequest(xmlNodePtr command){	const char *reply_cc       = NULL;	const char *status         = "failed";	const char *op             = NULL;	const char *verbose        = NULL;	const char *section        = NULL;	const char *output_section = NULL;	xmlNodePtr failed          = NULL;	xmlNodePtr cib_answer      = NULL;	xmlNodePtr cib_section     = NULL;	xmlNodePtr options	   = NULL;	gboolean update_the_cib = FALSE;	int cib_update_op = CIB_OP_NONE;	FNIN();		options = find_xml_node(command, XML_TAG_OPTIONS);		op         = xmlGetProp(options, XML_ATTR_OP);	verbose    = xmlGetProp(options, XML_ATTR_VERBOSE);	section    = xmlGetProp(options, XML_ATTR_FILTER_TYPE);	failed     = create_xml_node(NULL, XML_TAG_FAILED);//	cib_answer = create_xml_node(NULL, XML_MSG_TAG);//	add_node_copy(cib_answer, options);	// sanity checks	if (command == NULL) {		cl_log(LOG_INFO,		       "The (%s) received an empty message",		       CRM_SYSTEM_CIB);		FNRET(NULL);	}	if(op == NULL)		cl_log(LOG_WARNING, "No operation specified\n");	else if(strcmp("noop", op) == 0) ;	else if (strcmp(CRM_OPERATION_PING, op) == 0) {		CRM_DEBUG("Handling a ping");		status = "ok";		cib_answer =			createPingAnswerFragment(CRM_SYSTEM_CIB, status);			} else if (strcmp(CRM_OPERATION_BUMP, op) == 0) {		xmlNodePtr tmpCib = copy_xml_node_recursive(get_the_CIB(), 1);		CRM_DEBUG3("Handling a %s for section=%s of the cib",			   CRM_OPERATION_BUMP, section);				// modify the timestamp		set_node_tstamp(tmpCib);		char *new_value = NULL;		char *old_value = xmlGetProp(tmpCib, "generation");		if(old_value != NULL) {			new_value = (char*)ha_malloc(128*(sizeof(char)));			int int_value = atoi(old_value);			sprintf(new_value, "%d", ++int_value);		} else {			new_value = ha_strdup("0");		}				set_xml_property_copy(tmpCib, "generation", new_value);		ha_free(new_value);		activateCibXml(tmpCib);		reply_cc = "dc";			} else if (strcmp("query", op) == 0) {		CRM_DEBUG2("Handling a query for section=%s of the cib",			   section);		/* force a pick-up of the relevant section before		 * returning		 */		verbose = "true"; 		status = "ok";			} else if (strcmp(CRM_OPERATION_ERASE, op) == 0) {		xmlNodePtr new_cib = createEmptyCib();		// Preserve generation counters etc		copy_in_properties(get_the_CIB(), new_cib);				if (activateCibXml(new_cib) < 0)			status = "erase of CIB failed";		else {			status = "ok";			reply_cc = "dc";		}	} else if (strcmp(CRM_OPERATION_CREATE, op) == 0) {		update_the_cib = TRUE;		cib_update_op = CIB_OP_ADD;			} else if (strcmp(CRM_OPERATION_UPDATE, op) == 0) {		update_the_cib = TRUE;		cib_update_op = CIB_OP_MODIFY;			} else if (strcmp(CRM_OPERATION_DELETE, op) == 0) {		update_the_cib = TRUE;		cib_update_op = CIB_OP_DELETE;	} else if (strcmp(CRM_OPERATION_FORWARD, op) == 0) {		/* force a pick-up of the /entire/ CIB before		 * returning		 */		section = NULL;		verbose = "true"; 		status = "ok";		/* this will reply to the DC and leaves it up to it to direct		 * the message appropriately		 */			} else if (strcmp(CRM_OPERATION_STORE, op) == 0) {		xmlNodePtr cib_updates = NULL;		xmlNodePtr tmpCib = copy_xml_node_recursive(get_the_CIB(), 1);		const char *node_path[2];				CRM_DEBUG("Storing DC copy of the cib");		node_path[0] = XML_TAG_FRAGMENT;		node_path[1] = XML_TAG_CIB;		cib_updates = find_xml_node_nested(command, node_path, 2);		/* copy in any version tags etc verbatum */		copy_in_properties(cib_updates, tmpCib);				/* replace the following sections verbatum */		replace_section(XML_CIB_TAG_NODES,       tmpCib, command);		replace_section(XML_CIB_TAG_RESOURCES,   tmpCib, command);		replace_section(XML_CIB_TAG_CONSTRAINTS, tmpCib, command);				/* incorporate the info from the DC and then send it back */		updateList(tmpCib, command, failed,			   CIB_OP_MODIFY,			   XML_CIB_TAG_STATUS);		if(check_generation(cib_updates, tmpCib) == FALSE)			status = "discarded old update";		else if (activateCibXml(tmpCib) < 0)			status = "dc update failed";		else			status = "ok";		/* Force a pick-up of the merged status section and send it		 * back to the DC (but only if the DC asked for it by		 * setting verbose=true)		 *///		verbose = "true"; 		section = XML_CIB_TAG_STATUS;			} else if (strcmp("replace", op) == 0) {		CRM_DEBUG2("Replacing section=%s of the cib", section);		xmlNodePtr tmpCib = find_xml_node(command, XML_TAG_CIB);		xmlNodePtr section_xml = find_xml_node(command,						       XML_TAG_FRAGMENT);		section = xmlGetProp(section_xml, XML_ATTR_SECTION);				if (strcmp("all", section) == 0) {			replace_section(XML_CIB_TAG_NODES,     tmpCib,command);			replace_section(XML_CIB_TAG_RESOURCES, tmpCib,command);			replace_section(XML_CIB_TAG_STATUS,    tmpCib,command);			replace_section(XML_CIB_TAG_CONSTRAINTS,tmpCib,command);		} else {			replace_section(section, tmpCib, command);		}		/*if(check_generation(cib_updates, tmpCib) == FALSE)			status = "discarded old update";			else */		if (activateCibXml(tmpCib) < 0)			status = "replacement failed";		else			status = "ok";	} else {		status = "not supported";		cl_log(LOG_ERR, "Action [%s] is not supported by the CIB", op);	}    	if (update_the_cib) {		CRM_DEBUG("Backing up CIB");		xmlNodePtr tmpCib = copy_xml_node_recursive(get_the_CIB(), 1);		CRM_DEBUG("Updating temporary CIB");		xmlNodePtr section_xml = find_xml_node(command,						       XML_TAG_FRAGMENT);		section = xmlGetProp(section_xml, XML_ATTR_SECTION);		CRM_DEBUG3("Updating section=%s of the cib (op=%s)",			   section, op);			// should we be doing this?			// do logging						// make changes to a temp copy then activate		if(section == NULL) {			cl_log(LOG_ERR, "No section specified in %s",			       XML_ATTR_FILTER_TYPE);			status = "no section specified";		} else if(strcmp("all", section) == 0			  && cib_update_op == CIB_OP_DELETE) {			// delete			/* order is very important here */			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_STATUS);			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_CONSTRAINTS);			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_RESOURCES);			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_NODES);		} else if(strcmp("all", section) == 0) {			/* order is very important here */			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_NODES);			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_RESOURCES);			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_CONSTRAINTS);			updateList(tmpCib, command, failed, cib_update_op,				   XML_CIB_TAG_STATUS);		} else {			status = updateList(tmpCib, command, failed, cib_update_op, section);		}				CRM_DEBUG("Activating temporary CIB");		/* if(check_generation(cib_updates, tmpCib) == FALSE) *//* 			status = "discarded old update"; *//* 		else  */		if (activateCibXml(tmpCib) < 0) {			status = "update activation failed";		} else if (failed->children != NULL) {			status = "some updates failed";			reply_cc = "dc";					} else {			status = "ok";			reply_cc = "dc";		}				CRM_DEBUG2("CIB update status: %s", status);	}	output_section = section;	/* dont de-allocate cib_section, its the real thing */	if (failed->children != NULL || strcmp("ok", status) != 0) {		output_section = "all";		cib_section = get_object_root(NULL, get_the_CIB());	} else if (verbose != NULL && strcmp("true", verbose) == 0) {		cib_section = get_object_root(output_section, get_the_CIB());	}	if(cib_section != NULL) {		cib_answer = createCibFragmentAnswer(output_section,						     cib_section,						     failed);	}    	set_xml_property_copy(options, XML_ATTR_FILTER_TYPE, output_section); 	set_xml_property_copy(options, XML_ATTR_RESULT, status); 	if(reply_cc != NULL) {		set_xml_property_copy(options, XML_ATTR_SYSCC, reply_cc);	}		free_xml(failed);	FNRET(cib_answer);}