|
|
e2e2c2 |
/***************************************************************/
|
|
|
e2e2c2 |
|
|
|
ced38a |
|
|
|
e2e2c2 |
|
|
|
e2e2c2 |
/***************************************************************/
|
|
|
e2e2c2 |
|
|
|
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>
|
|
|
67bba7 |
#include "perk_driver_impl.h"
|
|
|
67bba7 |
#include "perk_dprintf_impl.h"
|
|
|
251206 |
#include "perk_errinfo_impl.h"
|
|
|
9c5807 |
|
|
|
67bba7 |
static int pretty_header(
|
|
|
67bba7 |
int fdout,
|
|
|
67bba7 |
const struct pe_common_ctx * cctx)
|
|
|
e343a6 |
{
|
|
|
6025fb |
return (cctx->fmtflags & PERK_PRETTY_YAML)
|
|
|
67bba7 |
? pe_dprintf(fdout,"imports:\n")
|
|
|
6025fb |
: 0;
|
|
|
e343a6 |
}
|
|
|
0d3dde |
|
|
|
67bba7 |
static int pretty_implib_header(
|
|
|
67bba7 |
int fdout,
|
|
|
67bba7 |
const struct pe_common_ctx * cctx,
|
|
|
67bba7 |
const char * name)
|
|
|
e343a6 |
{
|
|
|
e343a6 |
if ((cctx->fmtflags & PERK_PRETTY_YAML) && (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS))
|
|
|
67bba7 |
return pe_dprintf(fdout," %s:\n",name);
|
|
|
e343a6 |
else if (cctx->fmtflags & PERK_PRETTY_YAML)
|
|
|
67bba7 |
return pe_dprintf(fdout,"- %s:\n",name);
|
|
|
e343a6 |
else if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
|
|
|
67bba7 |
return pe_dprintf(fdout,"%s:\n",name);
|
|
|
e343a6 |
else
|
|
|
67bba7 |
return pe_dprintf(fdout,"%s\n",name);
|
|
|
e343a6 |
}
|
|
|
0d3dde |
|
|
|
67bba7 |
static int pretty_implib_item(
|
|
|
67bba7 |
int fdout,
|
|
|
67bba7 |
const struct pe_common_ctx * cctx,
|
|
|
67bba7 |
const char * name)
|
|
|
0d3dde |
{
|
|
|
0d3dde |
if (cctx->fmtflags & PERK_PRETTY_YAML)
|
|
|
67bba7 |
return pe_dprintf(fdout," - %s\n",name);
|
|
|
0d3dde |
else
|
|
|
67bba7 |
return pe_dprintf(fdout,"%s\n",name);
|
|
|
0d3dde |
}
|
|
|
0d3dde |
|
|
|
9c5807 |
int pe_output_import_libraries(
|
|
|
251206 |
const struct pe_driver_ctx * dctx,
|
|
|
67bba7 |
const struct pe_image_meta * m)
|
|
|
9c5807 |
{
|
|
|
67bba7 |
int fdout;
|
|
|
251206 |
int i;
|
|
|
251206 |
unsigned j;
|
|
|
251206 |
const struct pe_common_ctx * cctx = dctx->cctx;
|
|
|
9c5807 |
|
|
|
67bba7 |
fdout = pe_driver_fdout(dctx);
|
|
|
67bba7 |
|
|
|
2111da |
if (!m->m_stats.t_nimplibs)
|
|
|
9c5807 |
return 0;
|
|
|
9c5807 |
|
|
|
67bba7 |
if ((pretty_header(fdout,cctx)) < 0)
|
|
|
f11c1f |
return PERK_FILE_ERROR(dctx);
|
|
|
0d3dde |
|
|
|
2111da |
for (i=0; i<m->m_stats.t_nimplibs; i++) {
|
|
|
67bba7 |
if ((pretty_implib_header(
|
|
|
67bba7 |
fdout,cctx,
|
|
|
67bba7 |
m->m_idata[i].ih_name)) < 0)
|
|
|
f11c1f |
return PERK_FILE_ERROR(dctx);
|
|
|
9c5807 |
|
|
|
9c5807 |
if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS)
|
|
|
58ced9 |
for (j=0; j<m->m_idata[i].ih_count; j++)
|
|
|
58ced9 |
if (m->m_idata[i].ih_items[j].ii_name)
|
|
|
6025fb |
if ((pretty_implib_item(
|
|
|
67bba7 |
fdout,cctx,
|
|
|
67bba7 |
m->m_idata[i].ih_items[j].ii_name)) < 0)
|
|
|
f11c1f |
return PERK_FILE_ERROR(dctx);
|
|
|
9c5807 |
}
|
|
|
9c5807 |
|
|
|
f11c1f |
return 0;
|
|
|
9c5807 |
}
|