|
|
d9285e |
/*******************************************************************/
|
|
|
d9285e |
/* slibtool: a skinny libtool implementation, written in C */
|
|
|
d9285e |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
d9285e |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
d9285e |
/*******************************************************************/
|
|
|
d9285e |
|
|
|
d9285e |
#include <time.h>
|
|
|
d9285e |
#include <locale.h>
|
|
|
76c5e9 |
#include <regex.h>
|
|
|
d9285e |
#include <inttypes.h>
|
|
|
d9285e |
#include <slibtool/slibtool.h>
|
|
|
d9285e |
#include <slibtool/slibtool_output.h>
|
|
|
d9285e |
#include "slibtool_driver_impl.h"
|
|
|
d9285e |
#include "slibtool_dprintf_impl.h"
|
|
|
d9285e |
#include "slibtool_errinfo_impl.h"
|
|
|
d9285e |
#include "slibtool_ar_impl.h"
|
|
|
d9285e |
|
|
|
d9285e |
#define SLBT_PRETTY_FLAGS (SLBT_PRETTY_YAML \
|
|
|
d9285e |
| SLBT_PRETTY_POSIX \
|
|
|
d9285e |
| SLBT_PRETTY_HEXDATA)
|
|
|
d9285e |
|
|
|
d9285e |
static int slbt_ar_output_symbols_posix(
|
|
|
d9285e |
const struct slbt_driver_ctx * dctx,
|
|
|
d9285e |
struct slbt_archive_meta_impl * mctx,
|
|
|
d9285e |
const struct slbt_fd_ctx * fdctx)
|
|
|
d9285e |
{
|
|
|
d9285e |
int fdout;
|
|
|
76c5e9 |
const char * regex;
|
|
|
d9285e |
const char ** symv;
|
|
|
76c5e9 |
regex_t regctx;
|
|
|
76c5e9 |
regmatch_t pmatch[2] = {0};
|
|
|
d9285e |
|
|
|
d9285e |
fdout = fdctx->fdout;
|
|
|
d9285e |
|
|
|
76c5e9 |
if ((regex = dctx->cctx->regex))
|
|
|
76c5e9 |
if (regcomp(®ctx,regex,REG_NEWLINE))
|
|
|
76c5e9 |
return SLBT_CUSTOM_ERROR(
|
|
|
76c5e9 |
dctx,
|
|
|
76c5e9 |
SLBT_ERR_FLOW_ERROR);
|
|
|
76c5e9 |
|
|
|
d9285e |
for (symv=mctx->symstrv; *symv; symv++)
|
|
|
76c5e9 |
if (!regex || !regexec(®ctx,*symv,1,pmatch,0))
|
|
|
76c5e9 |
if (slbt_dprintf(fdout,"%s\n",*symv) < 0)
|
|
|
76c5e9 |
return SLBT_SYSTEM_ERROR(dctx,0);
|
|
|
76c5e9 |
|
|
|
76c5e9 |
if (regex)
|
|
|
76c5e9 |
regfree(®ctx);
|
|
|
d9285e |
|
|
|
d9285e |
return 0;
|
|
|
d9285e |
}
|
|
|
d9285e |
|
|
|
d9285e |
static int slbt_ar_output_symbols_yaml(
|
|
|
d9285e |
const struct slbt_driver_ctx * dctx,
|
|
|
d9285e |
struct slbt_archive_meta_impl * mctx,
|
|
|
d9285e |
const struct slbt_fd_ctx * fdctx)
|
|
|
d9285e |
{
|
|
|
d9285e |
(void)dctx;
|
|
|
d9285e |
(void)mctx;
|
|
|
d9285e |
(void)fdctx;
|
|
|
d9285e |
|
|
|
d9285e |
return 0;
|
|
|
d9285e |
}
|
|
|
d9285e |
|
|
|
d9285e |
int slbt_ar_output_symbols(const struct slbt_archive_meta * meta)
|
|
|
d9285e |
{
|
|
|
d9285e |
struct slbt_archive_meta_impl * mctx;
|
|
|
d9285e |
const struct slbt_driver_ctx * dctx;
|
|
|
d9285e |
struct slbt_fd_ctx fdctx;
|
|
|
d9285e |
|
|
|
d9285e |
mctx = slbt_archive_meta_ictx(meta);
|
|
|
d9285e |
dctx = (slbt_archive_meta_ictx(meta))->dctx;
|
|
|
d9285e |
|
|
|
d9285e |
if (slbt_get_driver_fdctx(dctx,&fdctx) < 0)
|
|
|
d9285e |
return SLBT_NESTED_ERROR(dctx);
|
|
|
d9285e |
|
|
|
d9285e |
if (!meta->a_memberv)
|
|
|
d9285e |
return 0;
|
|
|
d9285e |
|
|
|
d9285e |
switch (dctx->cctx->fmtflags & SLBT_PRETTY_FLAGS) {
|
|
|
d9285e |
case SLBT_PRETTY_YAML:
|
|
|
d9285e |
return slbt_ar_output_symbols_yaml(
|
|
|
d9285e |
dctx,mctx,&fdctx);
|
|
|
d9285e |
|
|
|
d9285e |
case SLBT_PRETTY_POSIX:
|
|
|
d9285e |
return slbt_ar_output_symbols_posix(
|
|
|
d9285e |
dctx,mctx,&fdctx);
|
|
|
d9285e |
|
|
|
d9285e |
default:
|
|
|
d9285e |
return slbt_ar_output_symbols_yaml(
|
|
|
d9285e |
dctx,mctx,&fdctx);
|
|
|
d9285e |
}
|
|
|
d9285e |
}
|