static int r_core_bin_file_print(RCore *core, RBinFile *binfile, int mode) {
	RListIter *iter;
	RBinObject *obj;
	const char *name = binfile ? binfile->file : NULL;
	(void)r_bin_get_info (core->bin); // XXX is this necssary for proper iniitialization
	ut32 id = binfile ? binfile->id : 0;
	ut32 fd = binfile ? binfile->fd : 0;
	ut32 bin_sz = binfile ? binfile->size : 0;
	// TODO: handle mode to print in json and r2 commands

	if (!binfile) {
		return false;
	}
	switch (mode) {
	case '*':
		r_list_foreach (binfile->objs, iter, obj) {
			r_cons_printf ("oba 0x%08"PFMT64x" %s # %d\n", obj->boffset, name, obj->id);
		}
		break;
	case 'q':
		r_list_foreach (binfile->objs, iter, obj) {
			r_cons_printf ("%d\n", obj->id);
		}
		break;
	case 'j':
		r_cons_printf ("{\"name\":\"%s\",\"fd\":%d,\"id\":%d,\"size\":%d,\"objs\":[",
			name, fd, id, bin_sz);
		r_list_foreach (binfile->objs, iter, obj) {
			RBinInfo *info = obj->info;
			ut8 bits = info ? info->bits : 0;
			const char *arch = info ? info->arch : "unknown";
			r_cons_printf ("{\"objid\":%d,\"arch\":\"%s\",\"bits\":%d,\"binoffset\":%"
					PFMT64d",\"objsize\":%"PFMT64d"}",
					obj->id, arch, bits, obj->boffset, obj->obj_size);
			if (iter->n) {
				r_cons_print (",");
			}
		}
		r_cons_print ("]}");
		break;
	default:
		r_list_foreach (binfile->objs, iter, obj) {
			RBinInfo *info = obj->info;
			ut8 bits = info ? info->bits : 0;
			const char *arch = info ? info->arch : "unknown";
			if (!arch) {
				arch = r_config_get (core->config, "asm.arch");
			}
			r_cons_printf ("%4d  %s-%d at:0x%08"PFMT64x" sz:%"PFMT64d" ",
					obj->id, arch, bits, obj->boffset, obj->obj_size );
			r_cons_printf ("fd:%d %s\n", fd, name);
		}
		break;
	}
	return true;
}
static int r_core_bin_file_print(RCore *core, RBinFile *binfile, int mode) {
	RListIter *iter;
	RBinObject *obj;
	const char *name = binfile ? binfile->file : NULL;
	(void)r_bin_get_info (core->bin);  
	ut32 id = binfile ? binfile->id : 0;
	ut32 fd = binfile ? binfile->fd : 0;
	ut32 bin_sz = binfile ? binfile->size : 0;
	 

	if (!binfile) {
		return false;
	}
	switch (mode) {
	case '*':
		r_list_foreach (binfile->objs, iter, obj) {
			r_cons_printf ("oba 0x%08"PFMT64x" %s # %d\n", obj->boffset, name, obj->id);
		}
		break;
	case 'q':
		r_list_foreach (binfile->objs, iter, obj) {
			r_cons_printf ("%d\n", obj->id);
		}
		break;
	case 'j':
		r_cons_printf ("{\"name\":\"%s\",\"fd\":%d,\"id\":%d,\"size\":%d,\"objs\":[",
			name, fd, id, bin_sz);
		r_list_foreach (binfile->objs, iter, obj) {
			RBinInfo *info = obj->info;
			ut8 bits = info ? info->bits : 0;
			const char *arch = info ? info->arch : "unknown";
			r_cons_printf ("{\"objid\":%d,\"arch\":\"%s\",\"bits\":%d,\"binoffset\":%"
					PFMT64d",\"objsize\":%"PFMT64d"}",
					obj->id, arch, bits, obj->boffset, obj->obj_size);
			if (iter->n) {
				r_cons_print (",");
			}
		}
		r_cons_print ("]}");
		break;
	default:
		r_list_foreach (binfile->objs, iter, obj) {
			RBinInfo *info = obj->info;
			ut8 bits = info ? info->bits : 0;
			const char *arch = info ? info->arch : "unknown";
			if (!arch) {
				arch = r_config_get (core->config, "asm.arch");
			}
			r_cons_printf ("%4d  %s-%d at:0x%08"PFMT64x" sz:%"PFMT64d" ",
					obj->id, arch, bits, obj->boffset, obj->obj_size );
			r_cons_printf ("fd:%d %s\n", fd, name);
		}
		break;
	}
	return true;
}