
/* strerror.c */

#include <libraries/dos.h>
#include <functions.h>

#include <stdio.h>
#include <errno.h>

#define ERROR_BUFFER_LENGTH 100

/* FIXME: The AmigaDOS Manual (3rd ed.) doesn't say this is valid but
   I'm hoping it is. */
#define NOTHING NULL

char *
strerror (error)
     int error;
{
  static char error_string[ERROR_BUFFER_LENGTH];

  if (error < sys_nerr && error >= 0)
    return sys_errlist[error];

  if (Fault (error, NOTHING, (UBYTE *) error_string, ERROR_BUFFER_LENGTH))
    return error_string;

  sprintf (error_string, "error %d", error);
  return error_string;
}
