res = fprintf(file_output_strm, "%s", buffer); fflush(file_output_strm);
CRM_DEV_ASSERT(buffer != NULL && strlen(buffer) > 0); if(buffer != NULL && strlen(buffer) > 0) { res = fprintf(file_output_strm, "%s", buffer); fflush(file_output_strm); }
write_xml_file(crm_data_t *xml_node, const char *filename) {	int res = 0;	char now_str[30];	time_t now;	crm_debug("Writing XML out to %s", filename);	crm_validate_data(xml_node);	if (xml_node == NULL) {		return -1;	}	crm_validate_data(xml_node);	crm_xml_debug(xml_node, "Writing out");	crm_validate_data(xml_node);		now = time(NULL);	ctime_r(&now, now_str);	now_str[24] = EOS; /* replace the newline */	set_xml_property_copy(xml_node, "last_written", now_str);	crm_validate_data(xml_node);	crm_xml_debug(xml_node, "Writing out revised xml");	crm_validate_data(xml_node);	#ifdef USE_LIBXML	if (xml_node->doc == NULL) {		xmlDocPtr foo = NULL;		crm_insane("Creating doc pointer for %s", xml_node->name);		foo = xmlNewDoc("1.0");		xmlDocSetRootElement(foo, xml_node);		xmlSetTreeDoc(xml_node, foo);	}	/* save it.	 * set arg 3 to 0 to disable line breaks,1 to enable	 * res == num bytes saved	 */	res = xmlSaveFormatFile(filename, xml_node->doc, 1);	/* for some reason, reading back after saving with	 * line-breaks doesnt go real well 	 */#else	{		FILE *file_output_strm = fopen(filename, "w");		char *buffer = dump_xml_formatted(xml_node);		res = fprintf(file_output_strm, "%s", buffer);		fflush(file_output_strm);		crm_free(buffer);	}#endif	crm_debug("Saved %d bytes to the Cib as XML", res);	return res;}