Blame src/output/pe_output_import_libraries.c

9c5807
#include <stdint.h>
9c5807
#include <stdlib.h>
9c5807
#include <stdio.h>
9c5807
#include <string.h>
9c5807
#include <errno.h>
9c5807
9c5807
#include <perk/perk.h>
9c5807
#include <perk/perk_output.h>
9c5807
#include "perk_output_impl.h"
9c5807
9c5807
int pe_output_import_libraries(
9c5807
	const struct pe_image_meta *	m,
9c5807
	const struct pe_common_ctx *	cctx,
9c5807
	FILE *				fout)
9c5807
{
9c5807
	FILE *	ftmp;
9c5807
	int	i,j;
9c5807
9c5807
	if (!m->summary.num_of_implibs)
9c5807
		return 0;
9c5807
9c5807
	if (!(fout = pe_output_prolog(cctx,fout,&ftmp)))
9c5807
		return -1;
9c5807
9c5807
	for (i=0; i<m->summary.num_of_implibs; i++) {
9c5807
		if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
9c5807
			fprintf(fout,"%s:\n",m->idata[i].name);
9c5807
		else
9c5807
			fprintf(fout,"%s\n",m->idata[i].name);
9c5807
9c5807
		if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
9c5807
			for (j=0; j<m->idata[i].count; j++)
9c5807
				if (m->idata[i].items[j].name)
9c5807
					fprintf(fout,"==> %s\n",
9c5807
						m->idata[i].items[j].name);
9c5807
	}
9c5807
9c5807
	return pe_output_epilog(0,ftmp);
9c5807
}