xmlNodePtr options = NULL; xmlNodePtr xml_root_node = NULL; char *buffer = NULL;
admin_msg_callback(IPC_Channel * server, void *private_data){	int lpc = 0;	IPC_Message *msg = NULL;	gboolean hack_return_good = TRUE;	static int received_responses = 0;	char *filename;	int filename_len = 0;	const char *result = NULL;	xmlNodePtr options = NULL;	xmlNodePtr xml_root_node = NULL;	char *buffer = NULL;	g_source_remove(message_timer_id);	while (server->ch_status != IPC_DISCONNECT	       && server->ops->is_message_pending(server) == TRUE) {		if (server->ops->recv(server, &msg) != IPC_OK) {			perror("Receive failure:");			return !hack_return_good;		}		if (msg == NULL) {			crm_trace("No message this time");			continue;		}		lpc++;		buffer =(char *) msg->msg_body;		crm_verbose("Got xml [text=%s]", buffer);		xml_root_node = find_xml_in_ipcmessage(msg, TRUE);		if (xml_root_node == NULL) {			crm_info(			       "XML in IPC message was not valid... "			       "discarding.");			continue;		} else if (validate_crm_message(xml_root_node,					 crm_system_name,					 admin_uuid,					 XML_ATTR_RESPONSE) == FALSE) {			crm_info(			       "Message was not a CRM response. Discarding.");			continue;		}		options = find_xml_node(xml_root_node, XML_TAG_OPTIONS, FALSE);				result = xmlGetProp(options, XML_ATTR_RESULT);		if(result == NULL || strcmp(result, "ok") == 0) {			result = "pass";		} else {			result = "fail";		}				received_responses++;		if(DO_HEALTH) {			xmlNodePtr ping = find_xml_node(				xml_root_node, XML_CRM_TAG_PING, FALSE);			const char *state = xmlGetProp(ping, "crmd_state");			printf("Status of %s@%s: %s (%s)\n",			       xmlGetProp(ping, XML_PING_ATTR_SYSFROM),			       xmlGetProp(xml_root_node, XML_ATTR_HOSTFROM),			       state,			       xmlGetProp(ping, XML_PING_ATTR_STATUS));						if(BE_SILENT && state != NULL) {				fprintf(stderr, "%s\n", state);			}					} else if(DO_WHOIS_DC) {			const char *dc = xmlGetProp(				xml_root_node, XML_ATTR_HOSTFROM);						printf("Designated Controller is: %s\n", dc);			if(BE_SILENT && dc != NULL) {				fprintf(stderr, "%s\n", dc);			}		}				if (this_msg_reference != NULL) {			/* in testing mode... */			/* 31 = "test-_.xml" + an_int_as_string + '\0' */			filename_len = 31 + strlen(this_msg_reference);			crm_malloc(filename, sizeof(char) * filename_len);			if(filename != NULL) {				sprintf(filename, "%s-%s_%d.xml",					result, this_msg_reference,					received_responses);								filename[filename_len - 1] = '\0';				if (xmlSaveFormatFile(					    filename, xml_root_node->doc, 1) < 0) {					crm_crit("Could not save response to"						 " %s_%s_%d.xml",						 this_msg_reference,						 result, received_responses);				}			}		}	}	if (server->ch_status == IPC_DISCONNECT) {		crm_verbose("admin_msg_callback: received HUP");		return !hack_return_good;	}	if (received_responses >= expected_responses) {		crm_verbose(		       "Recieved expected number (%d) of messages from Heartbeat."		       "  Exiting normally.", expected_responses);		g_main_quit(mainloop);		return !hack_return_good;	}	message_timer_id = Gmain_timeout_add(		message_timeout_ms, admin_message_timeout, NULL);			return hack_return_good;}