2002-12-27 08:53:07 +00:00
|
|
|
/* err.c - error handling routines */
|
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2004-02-24 17:21:53 +00:00
|
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
2002-12-27 08:53:07 +00:00
|
|
|
*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB is free software; you can redistribute it and/or modify
|
2002-12-27 08:53:07 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2004-04-04 13:46:03 +00:00
|
|
|
* along with GRUB; if not, write to the Free Software
|
2002-12-27 08:53:07 +00:00
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/err.h>
|
|
|
|
#include <grub/misc.h>
|
2002-12-27 08:53:07 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#define GRUB_MAX_ERRMSG 256
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_err_t grub_errno;
|
|
|
|
char grub_errmsg[GRUB_MAX_ERRMSG];
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_err_t
|
|
|
|
grub_error (grub_err_t n, const char *fmt, ...)
|
2002-12-27 08:53:07 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_errno = n;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
va_start (ap, fmt);
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_vsprintf (grub_errmsg, fmt, ap);
|
2002-12-27 08:53:07 +00:00
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_fatal (const char *fmt, ...)
|
2002-12-27 08:53:07 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start (ap, fmt);
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_vprintf (fmt, ap);
|
2002-12-27 08:53:07 +00:00
|
|
|
va_end (ap);
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_stop ();
|
2002-12-27 08:53:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_print_error (void)
|
2002-12-27 08:53:07 +00:00
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
if (grub_errno != GRUB_ERR_NONE)
|
|
|
|
grub_printf ("error: %s\n", grub_errmsg);
|
2002-12-27 08:53:07 +00:00
|
|
|
}
|