Blame src/output/pe_output_image_sections.c

437706
/***************************************************************/
437706
/*  perk: PE Resource Kit                                      */
437706
/*  Copyright (C) 2015--2016  Z. Gilboa                        */
437706
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
437706
/***************************************************************/
437706
437706
#include <stdio.h>
437706
437706
#include <perk/perk.h>
437706
#include <perk/perk_output.h>
437706
#include "perk_errinfo_impl.h"
437706
437706
int pe_output_image_sections(
437706
	const struct pe_driver_ctx *	dctx,
437706
	const struct pe_image_meta *	meta,
437706
	FILE *				fout)
437706
{
437706
	int		i;
437706
	const char * 	dash = "";
437706
437706
	if (!fout)
437706
		fout = stdout;
437706
437706
	if (dctx->cctx->fmtflags & PERK_PRETTY_YAML) {
437706
		if (fputs("sections:\n",fout) < 0)
437706
			return PERK_FILE_ERROR(dctx);
437706
437706
		dash = "- ";
437706
	}
437706
da15f0
	for (i=0; i<meta->coff.cfh_num_of_sections; i++)
437706
		if (fprintf(fout,"%s%s\n",
437706
				dash,
9740a3
				meta->sectbl[i].sh_long_name
9740a3
					? meta->sectbl[i].sh_long_name
9740a3
					: meta->sectbl[i].sh_name) < 0)
437706
			return PERK_FILE_ERROR(dctx);
437706
437706
	return 0;
437706
}