#include <string.h>

#include "kernel.h"
#include "swis.h"

#include "tboxlibs/wimplib.h"

#include "msgtrans.h"

#include "debug.h"

// ensure we always have space for the error message
static _kernel_oserror mt_errmess;

char *msgtrans_lookup(char *token)
{
  char *result;
  _swix(MessageTrans_Lookup,_INR(0,3)|_OUT(2),&msgtrans,token,0,0,&result);
  return result;
}

void msgtrans_lookup_to(char *token,char *to,int length)
{
  _swix(MessageTrans_Lookup,_INR(0,3),&msgtrans,token,to,length);
}

void msgtrans_report_error_1(char *token, char *param)
{
  _kernel_oserror *e;
  mt_errmess.errnum=0;
  strcpy(mt_errmess.errmess,token);
  
  e=_swix(MessageTrans_ErrorLookup,_INR(0,7),&mt_errmess,&msgtrans,0,0,param,NULL,NULL,NULL);

  wimp_report_error(e,1,msgtrans_lookup("_TaskName"),NULL,NULL,NULL);
}

_kernel_oserror *msgtrans_errorlookup_1(char *token, char *param)
{
  mt_errmess.errnum=0;
  strcpy(mt_errmess.errmess,token);
  
  return _swix(MessageTrans_ErrorLookup,_INR(0,7),&mt_errmess,&msgtrans,0,0,param,NULL,NULL,NULL);
}
