Blame src/internal/slibtool_errinfo_impl.c

5bf1b0
/*******************************************************************/
5bf1b0
/*  slibtool: a skinny libtool implementation, written in C        */
bb281c
/*  Copyright (C) 2016--2021  SysDeer Technologies, LLC            */
5bf1b0
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
5bf1b0
/*******************************************************************/
5bf1b0
5bf1b0
#include <slibtool/slibtool.h>
5bf1b0
#include "slibtool_driver_impl.h"
5bf1b0
#include "slibtool_errinfo_impl.h"
5bf1b0
5bf1b0
int slbt_record_error(
5bf1b0
	const struct slbt_driver_ctx *	dctx,
cacd3e
	int				esyscode,
cacd3e
	int				elibcode,
cacd3e
	const char *			efunction,
cacd3e
	int				eline,
cacd3e
	unsigned			eflags,
cacd3e
	void *				eany)
5bf1b0
{
5bf1b0
	struct slbt_driver_ctx_impl *	ictx;
5bf1b0
	struct slbt_error_info *	erri;
5bf1b0
5bf1b0
	ictx = slbt_get_driver_ictx(dctx);
5bf1b0
5bf1b0
	if (ictx->errinfp == ictx->erricap)
5bf1b0
		return -1;
5bf1b0
5bf1b0
	*ictx->errinfp = &ictx->erribuf[ictx->errinfp - ictx->erriptr];
5bf1b0
	erri = *ictx->errinfp;
5bf1b0
cacd3e
	erri->edctx     = dctx;
cacd3e
	erri->esyscode  = esyscode;
cacd3e
	erri->elibcode  = elibcode;
cacd3e
	erri->efunction = efunction;
cacd3e
	erri->eline     = eline;
cacd3e
	erri->eflags    = eflags;
6beda1
	erri->eany      = (eany && (esyscode == ENOENT)) ? strdup(eany) : eany;
5bf1b0
5bf1b0
	ictx->errinfp++;
5bf1b0
5bf1b0
	return -1;
5bf1b0
}