Blame src/output/pe_output_image_category.c

007c7f
/***************************************************************/
007c7f
/*  perk: PE Resource Kit                                      */
425fb8
/*  Copyright (C) 2015--2021  SysDeer Technologies, LLC        */
007c7f
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
007c7f
/***************************************************************/
007c7f
007c7f
#include <stdio.h>
007c7f
007c7f
#include <perk/perk.h>
007c7f
#include <perk/perk_output.h>
67bba7
#include "perk_driver_impl.h"
67bba7
#include "perk_dprintf_impl.h"
007c7f
#include "perk_errinfo_impl.h"
007c7f
cd4ace
int pe_output_image_category(
007c7f
	const struct pe_driver_ctx *	dctx,
67bba7
	const struct pe_image_meta *	meta)
007c7f
{
67bba7
	int				fdout;
50a830
	struct pe_info_string		abi;
919d9d
	struct pe_info_string		subtype;
a97030
	struct pe_info_string		subsystem;
58df62
	struct pe_info_string		framework;
58df62
67bba7
	fdout = pe_driver_fdout(dctx);
007c7f
50a830
	pe_get_image_abi      (meta,&abi;;
919d9d
	pe_get_image_subtype  (meta,&subtype);
a97030
	pe_get_image_subsystem(meta,&subsystem);
58df62
	pe_get_image_framework(meta,&framework);
58df62
007c7f
	if (dctx->cctx->fmtflags & PERK_PRETTY_YAML) {
67bba7
		if (pe_dprintf(
67bba7
				fdout,
67bba7
				"category:\n- %s:\n- %s:\n- %s:\n- %s:\n",
50a830
				abi.buffer,
919d9d
				subtype.buffer,
a97030
				subsystem.buffer,
58df62
				framework.buffer) < 0)
f11c1f
			return PERK_FILE_ERROR(dctx);
007c7f
	} else {
67bba7
		if (pe_dprintf(
67bba7
				fdout,
67bba7
				"%s-%s-%s-%s\n",
50a830
				abi.buffer,
919d9d
				subtype.buffer,
a97030
				subsystem.buffer,
58df62
				framework.buffer) < 0)
f11c1f
			return PERK_FILE_ERROR(dctx);
007c7f
	}
007c7f
f11c1f
	return 0;
007c7f
}