Blame src/internal/mdso_errinfo_impl.c

4ecd08
/****************************************************************/
4ecd08
/*  mdso: midipix dso scavenger                                 */
4ecd08
/*  Copyright (C) 2015--2016  Z. Gilboa                         */
4ecd08
/*  Released under GPLv2 and GPLv3; see COPYING.MDSO.           */
4ecd08
/****************************************************************/
4ecd08
4ecd08
#include <mdso/mdso.h>
4ecd08
#include "mdso_driver_impl.h"
4ecd08
#include "mdso_errinfo_impl.h"
4ecd08
4ecd08
int mdso_record_error(
4ecd08
	const struct mdso_driver_ctx *	dctx,
4ecd08
	int				syserror,
4ecd08
	int				liberror,
4ecd08
	const char *			function,
4ecd08
	int				line,
4ecd08
	unsigned			flags,
4ecd08
	void *				ctx)
4ecd08
{
4ecd08
	struct mdso_driver_ctx_impl *	ictx;
4ecd08
	struct mdso_error_info *	erri;
4ecd08
4ecd08
	ictx = mdso_get_driver_ictx(dctx);
4ecd08
4ecd08
	if (ictx->errinfp == ictx->erricap)
4ecd08
		return -1;
4ecd08
4ecd08
	*ictx->errinfp = &ictx->erribuf[ictx->errinfp - ictx->erriptr];
4ecd08
	erri = *ictx->errinfp;
4ecd08
4ecd08
	erri->syserror = syserror;
4ecd08
	erri->liberror = liberror;
4ecd08
	erri->function = function;
4ecd08
	erri->line     = line;
4ecd08
	erri->flags    = flags;
4ecd08
	erri->ctx      = ctx;
4ecd08
4ecd08
	ictx->errinfp++;
4ecd08
4ecd08
	return -1;
4ecd08
}