void xml_help_for_event(struct op_event const * event)
{
	uint i;
	int nr_counters;
	int has_nested = strcmp(event->unit->name, "zero");
	char buffer[MAX_BUFFER];

	buffer[0] = '\0';
	open_xml_element(HELP_EVENT, 1, buffer);
	init_xml_str_attr(HELP_EVENT_NAME, event->name, buffer);
	xml_do_arch_specific_event_help(event, buffer);
	init_xml_str_attr(HELP_EVENT_DESC, event->desc, buffer);

	nr_counters = op_get_nr_counters(cpu_type);
	init_xml_int_attr(HELP_COUNTER_MASK, event->counter_mask, buffer);
	init_xml_int_attr(HELP_MIN_COUNT, event->min_count, buffer);

	if (has_nested) {
		close_xml_element(NONE, 1, buffer);
		open_xml_element(HELP_UNIT_MASKS, 1, buffer);
		init_xml_int_attr(HELP_DEFAULT_MASK, event->unit->default_mask, buffer);
		close_xml_element(NONE, 1, buffer);
		for (i = 0; i < event->unit->num; i++) {
			open_xml_element(HELP_UNIT_MASK, 1, buffer);
			init_xml_int_attr(HELP_UNIT_MASK_VALUE,
					  event->unit->um[i].value, buffer);
			init_xml_str_attr(HELP_UNIT_MASK_DESC,
					  event->unit->um[i].desc, buffer);
			close_xml_element(NONE, 0, buffer);
		}
		close_xml_element(HELP_UNIT_MASKS, 0, buffer);
	}
	close_xml_element(has_nested ? HELP_EVENT : NONE, has_nested, buffer);
	printf("%s", buffer);
}
Example #2
0
void xml_help_for_event(struct op_event const * event)
{
	uint i;
	int has_nested = strcmp(event->unit->name, "zero");

	buffer[0] = '\0';
	open_xml_element(HELP_EVENT, 1, buffer, MAX_BUFFER);
	init_xml_str_attr(HELP_EVENT_NAME, event->name, buffer, MAX_BUFFER);
	xml_do_arch_specific_event_help(event, buffer, MAX_BUFFER);
	init_xml_str_attr(HELP_EVENT_DESC, event->desc, buffer, MAX_BUFFER);

	init_xml_int_attr(HELP_COUNTER_MASK, event->counter_mask, buffer,
			  MAX_BUFFER);
	if (event->ext)
		init_xml_str_attr(HELP_EXT, event->ext, buffer, MAX_BUFFER);
	init_xml_int_attr(HELP_MIN_COUNT, event->min_count,
			  buffer, MAX_BUFFER);

	if (has_nested) {
		char um_type[10];
		close_xml_element(NONE, 1, buffer, MAX_BUFFER);
		open_xml_element(HELP_UNIT_MASKS, 1, buffer, MAX_BUFFER);
		init_xml_int_attr(HELP_DEFAULT_MASK, event->unit->default_mask,
				  buffer, MAX_BUFFER);
		switch (event->unit->unit_type_mask){
		case utm_bitmask:
			strncpy(um_type, "bitmask", sizeof(um_type));
			break;
		case utm_exclusive:
			strncpy(um_type, "exclusive", sizeof(um_type));
			break;
		case utm_mandatory:
			strncpy(um_type, "mandatory", sizeof(um_type));
			break;
		}
		init_xml_str_attr(HELP_UNIT_MASKS_CATEGORY, um_type, buffer, MAX_BUFFER);
		close_xml_element(NONE, 1, buffer, MAX_BUFFER);
		for (i = 0; i < event->unit->num; i++) {
			open_xml_element(HELP_UNIT_MASK, 1, buffer, MAX_BUFFER);
			init_xml_int_attr(HELP_UNIT_MASK_VALUE,
					  event->unit->um[i].value,
					  buffer, MAX_BUFFER);
			init_xml_str_attr(HELP_UNIT_MASK_DESC,
					  event->unit->um[i].desc,
					  buffer, MAX_BUFFER);
			if (event->unit->um[i].extra)
				init_xml_int_attr(HELP_UNIT_EXTRA_VALUE,
					          event->unit->um[i].extra,
					          buffer, MAX_BUFFER);
			close_xml_element(NONE, 0, buffer, MAX_BUFFER);
		}
		close_xml_element(HELP_UNIT_MASKS, 0, buffer, MAX_BUFFER);
	}
	close_xml_element(has_nested ? HELP_EVENT : NONE, has_nested,
			  buffer, MAX_BUFFER);
	printf("%s", buffer);
}
void open_xml_events(char const * title, char const * doc, op_cpu the_cpu_type)
{
	char const * schema_version = "1.1";

	buffer[0] = '\0';
	cpu_type = the_cpu_type;
	open_xml_element(HELP_EVENTS, 1, buffer, MAX_BUFFER);
	init_xml_str_attr(SCHEMA_VERSION, schema_version, buffer, MAX_BUFFER);
	close_xml_element(NONE, 1, buffer, MAX_BUFFER);
	open_xml_element(HELP_HEADER, 1, buffer, MAX_BUFFER);
	init_xml_str_attr(HELP_TITLE, title, buffer, MAX_BUFFER);
	init_xml_str_attr(HELP_DOC, doc, buffer, MAX_BUFFER);
	close_xml_element(NONE, 0, buffer, MAX_BUFFER);
	printf("%s", buffer);
}