#ifndef XPKMASTER_GETERROR_C
#define XPKMASTER_GETERROR_C

/* Routinesheader

	Name:		geterror.c
	Main:		xpkmaster
	Versionstring:	$VER: geterror.c 1.0 (05.10.96)
	Author:		SDI
	Distribution:	PD
	Description:	Error message generator

 1.0   05.10.96 : first real version
*/

#include "xpkmaster.h"
#include "xpk_strings.h"
#include <exec/types.h>

#define MINERROR -32

void geterror(struct XpkBuffer *xbuf)
{
  STRPTR res;
  STRPTR buf = xbuf->xb_ErrBuf;

  if(!buf)
    return;

  if(*xbuf->xb_ErrMsg)
    res = xbuf->xb_ErrMsg;
  else if (xbuf->xb_Result > 0 || xbuf->xb_Result < MINERROR)
    res = strings[TXT_UNKNOWN_ERROR];
  else
    res = XpkErrs[-xbuf->xb_Result];

  if(xbuf->xb_Flags & XMF_SHORTERR)
    sprintf(buf, "%.50s", res);
  else
    sprintf(buf, strings[FMT_LONG_ERROR],
    xbuf->xb_Flags & XMF_PACKING ? strings[TXT_PACKING] :
    strings[TXT_UNPACKING], xbuf->xb_Prog.xp_FileName, res);
}

#endif /* XPKMASTER_GETERROR_C */
