Blame src/internal/slibtool_errinfo_impl.c

5bf1b0
/*******************************************************************/
5bf1b0
/*  slibtool: a skinny libtool implementation, written in C        */
5bf1b0
/*  Copyright (C) 2016  Z. Gilboa                                  */
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,
5bf1b0
	int				syserror,
5bf1b0
	int				liberror,
5bf1b0
	const char *			function,
5bf1b0
	int				line,
5bf1b0
	unsigned			flags,
5bf1b0
	void *				ctx)
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
5bf1b0
	erri->syserror = syserror;
5bf1b0
	erri->liberror = liberror;
5bf1b0
	erri->function = function;
5bf1b0
	erri->line     = line;
5bf1b0
	erri->flags    = flags;
5bf1b0
	erri->ctx      = ctx;
5bf1b0
5bf1b0
	ictx->errinfp++;
5bf1b0
5bf1b0
	return -1;
5bf1b0
}