|
|
5d46be |
/*******************************************************************/
|
|
|
5d46be |
/* slibtool: a skinny libtool implementation, written in C */
|
|
|
5d46be |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
5d46be |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
5d46be |
/*******************************************************************/
|
|
|
5d46be |
|
|
|
5d46be |
#include <slibtool/slibtool.h>
|
|
|
5d46be |
#include <slibtool/slibtool_output.h>
|
|
|
5d46be |
#include "slibtool_driver_impl.h"
|
|
|
5d46be |
#include "slibtool_dprintf_impl.h"
|
|
|
5d46be |
#include "slibtool_errinfo_impl.h"
|
|
|
5d46be |
#include "slibtool_ar_impl.h"
|
|
|
5d46be |
|
|
|
5d46be |
#define SLBT_PRETTY_FLAGS (SLBT_PRETTY_YAML \
|
|
|
5d46be |
| SLBT_PRETTY_POSIX \
|
|
|
5d46be |
| SLBT_PRETTY_HEXDATA)
|
|
|
5d46be |
|
|
|
5d46be |
|
|
|
5d46be |
static int slbt_ar_output_arname_posix(
|
|
|
5d46be |
const struct slbt_driver_ctx * dctx,
|
|
|
5d46be |
const struct slbt_archive_ctx * actx,
|
|
|
5d46be |
const struct slbt_fd_ctx * fdctx)
|
|
|
5d46be |
{
|
|
|
5d46be |
(void)dctx;
|
|
|
5d46be |
(void)actx;
|
|
|
5d46be |
(void)fdctx;
|
|
|
5d46be |
|
|
|
5d46be |
/* posix ar(1) does not print the <archive> file-name */
|
|
|
5d46be |
|
|
|
5d46be |
return 0;
|
|
|
5d46be |
}
|
|
|
5d46be |
|
|
|
5d46be |
static int slbt_ar_output_arname_yaml(
|
|
|
5d46be |
const struct slbt_driver_ctx * dctx,
|
|
|
5d46be |
const struct slbt_archive_ctx * actx,
|
|
|
5d46be |
const struct slbt_fd_ctx * fdctx)
|
|
|
5d46be |
{
|
|
|
5d46be |
const char * path;
|
|
|
5d46be |
const char mema[] = "<memory_object>";
|
|
|
5d46be |
|
|
|
5d46be |
path = actx->path && *actx->path ? *actx->path : mema;
|
|
|
5d46be |
|
|
|
5d46be |
if (slbt_dprintf(fdctx->fdout,"Archive: %s\n",path) < 0)
|
|
|
5d46be |
return SLBT_SYSTEM_ERROR(dctx,0);
|
|
|
5d46be |
|
|
|
5d46be |
return 0;
|
|
|
5d46be |
}
|
|
|
5d46be |
|
|
|
5d46be |
int slbt_ar_output_arname(const struct slbt_archive_ctx * actx)
|
|
|
5d46be |
{
|
|
|
5d46be |
const struct slbt_driver_ctx * dctx;
|
|
|
5d46be |
struct slbt_fd_ctx fdctx;
|
|
|
5d46be |
|
|
|
5d46be |
dctx = (slbt_get_archive_ictx(actx))->dctx;
|
|
|
5d46be |
|
|
|
5d46be |
if (slbt_get_driver_fdctx(dctx,&fdctx) < 0)
|
|
|
5d46be |
return SLBT_NESTED_ERROR(dctx);
|
|
|
5d46be |
|
|
|
5d46be |
switch (dctx->cctx->fmtflags & SLBT_PRETTY_FLAGS) {
|
|
|
5d46be |
case SLBT_PRETTY_YAML:
|
|
|
5d46be |
return slbt_ar_output_arname_yaml(
|
|
|
5d46be |
dctx,actx,&fdctx);
|
|
|
5d46be |
|
|
|
5d46be |
case SLBT_PRETTY_POSIX:
|
|
|
5d46be |
return slbt_ar_output_arname_posix(
|
|
|
5d46be |
dctx,actx,&fdctx);
|
|
|
5d46be |
|
|
|
5d46be |
default:
|
|
|
5d46be |
return slbt_ar_output_arname_yaml(
|
|
|
5d46be |
dctx,actx,&fdctx);
|
|
|
5d46be |
}
|
|
|
5d46be |
}
|