ipmi_sdr_print_entity(struct ipmi_intf *intf, char *entitystr)
{
	struct sdr_record_list *list, *entry;
	struct entity_id entity;
	unsigned id = 0;
	unsigned instance = 0;
	int rc = 0;

	if (!entitystr ||
	    strncasecmp(entitystr, "help", 4) == 0 ||
	    strncasecmp(entitystr, "list", 4) == 0) {
		print_valstr_2col(entity_id_vals, "Entity IDs", -1);
		return 0;
	}

	if (sscanf(entitystr, "%u.%u", &id, &instance) != 2) {
		/* perhaps no instance was passed
		 * in which case we want all instances for this entity
		 * so set entity.instance = 0x7f to indicate this
		 */
		if (sscanf(entitystr, "%u", &id) != 1) {
			int i, j=0;

			/* now try string input */
			for (i = 0; entity_id_vals[i].str; i++) {
				if (strncasecmp(entitystr, entity_id_vals[i].str,
						__maxlen(entitystr, entity_id_vals[i].str)) == 0) {
					entity.id = entity_id_vals[i].val;
					entity.instance = 0x7f;
					j=1;
				}
			}
			if (j == 0) {
				lprintf(LOG_ERR, "Invalid entity: %s", entitystr);
				return -1;
			}
		} else {
			entity.id = id;
			entity.instance = 0x7f;
		}
	} else {
		entity.id = id;
		entity.instance = instance;
	}

	list = ipmi_sdr_find_sdr_byentity(intf, &entity);

	for (entry = list; entry; entry = entry->next) {
		rc = ipmi_sdr_print_listentry(intf, entry);
	}

	__sdr_list_empty(list);

	return rc;
}
ipmi_sdr_print_entity(struct ipmi_intf *intf, char *entitystr)
{
	struct sdr_record_list *list, *entry;
	struct entity_id entity;
	unsigned id = 0;
	unsigned instance = 0;
	int rc = 0;

	if (!entitystr ||
	    strncasecmp(entitystr, "help", 4) == 0 ||
	    strncasecmp(entitystr, "list", 4) == 0) {
		print_valstr_2col(entity_id_vals, "Entity IDs", -1);
		return 0;
	}

	if (sscanf(entitystr, "%u.%u", &id, &instance) != 2) {
		 
		if (sscanf(entitystr, "%u", &id) != 1) {
			int i, j=0;

			 
			for (i = 0; entity_id_vals[i].str; i++) {
				if (strncasecmp(entitystr, entity_id_vals[i].str,
						__maxlen(entitystr, entity_id_vals[i].str)) == 0) {
					entity.id = entity_id_vals[i].val;
					entity.instance = 0x7f;
					j=1;
				}
			}
			if (j == 0) {
				lprintf(LOG_ERR, "Invalid entity: %s", entitystr);
				return -1;
			}
		} else {
			entity.id = id;
			entity.instance = 0x7f;
		}
	} else {
		entity.id = id;
		entity.instance = instance;
	}

	list = ipmi_sdr_find_sdr_byentity(intf, &entity);

	for (entry = list; entry; entry = entry->next) {
		rc = ipmi_sdr_print_listentry(intf, entry);
	}

	__sdr_list_empty(list);

	return rc;
}