1*9160SSherry.Moore@Sun.COM /* 2*9160SSherry.Moore@Sun.COM * CDDL HEADER START 3*9160SSherry.Moore@Sun.COM * 4*9160SSherry.Moore@Sun.COM * The contents of this file are subject to the terms of the 5*9160SSherry.Moore@Sun.COM * Common Development and Distribution License (the "License"). 6*9160SSherry.Moore@Sun.COM * You may not use this file except in compliance with the License. 7*9160SSherry.Moore@Sun.COM * 8*9160SSherry.Moore@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9160SSherry.Moore@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*9160SSherry.Moore@Sun.COM * See the License for the specific language governing permissions 11*9160SSherry.Moore@Sun.COM * and limitations under the License. 12*9160SSherry.Moore@Sun.COM * 13*9160SSherry.Moore@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*9160SSherry.Moore@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9160SSherry.Moore@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*9160SSherry.Moore@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*9160SSherry.Moore@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*9160SSherry.Moore@Sun.COM * 19*9160SSherry.Moore@Sun.COM * CDDL HEADER END 20*9160SSherry.Moore@Sun.COM */ 21*9160SSherry.Moore@Sun.COM /* 22*9160SSherry.Moore@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*9160SSherry.Moore@Sun.COM * Use is subject to license terms. 24*9160SSherry.Moore@Sun.COM */ 25*9160SSherry.Moore@Sun.COM 26*9160SSherry.Moore@Sun.COM #include <stdlib.h> 27*9160SSherry.Moore@Sun.COM #include <string.h> 28*9160SSherry.Moore@Sun.COM #include <locale.h> 29*9160SSherry.Moore@Sun.COM #include <libintl.h> 30*9160SSherry.Moore@Sun.COM #include "libgrub_errno.h" 31*9160SSherry.Moore@Sun.COM 32*9160SSherry.Moore@Sun.COM #define MAKE_STRING(x) # x 33*9160SSherry.Moore@Sun.COM 34*9160SSherry.Moore@Sun.COM static const struct { 35*9160SSherry.Moore@Sun.COM int ge_num; /* error number */ 36*9160SSherry.Moore@Sun.COM char *ge_name; /* error name */ 37*9160SSherry.Moore@Sun.COM char *ge_msg; /* error message */ 38*9160SSherry.Moore@Sun.COM } _grub_errstr[] = { 39*9160SSherry.Moore@Sun.COM /* 40*9160SSherry.Moore@Sun.COM * TRANSLATION_NOTE 41*9160SSherry.Moore@Sun.COM * The following message strings that begin with EG_ do not 42*9160SSherry.Moore@Sun.COM * need to be translated. 43*9160SSherry.Moore@Sun.COM */ 44*9160SSherry.Moore@Sun.COM #define grub_errno_def(num, desc) { num, MAKE_STRING(num), desc}, 45*9160SSherry.Moore@Sun.COM #include "libgrub_errno.def" 46*9160SSherry.Moore@Sun.COM }; 47*9160SSherry.Moore@Sun.COM 48*9160SSherry.Moore@Sun.COM #define GRUB_ERRNO_INDEX(n) ((n) - (EG_START + 1)) 49*9160SSherry.Moore@Sun.COM 50*9160SSherry.Moore@Sun.COM const char * grub_strerror(int err)51*9160SSherry.Moore@Sun.COMgrub_strerror(int err) 52*9160SSherry.Moore@Sun.COM { 53*9160SSherry.Moore@Sun.COM return (err <= EG_START || err >= EG_END ? 54*9160SSherry.Moore@Sun.COM strerror(err) : 55*9160SSherry.Moore@Sun.COM dgettext(TEXT_DOMAIN, _grub_errstr[ GRUB_ERRNO_INDEX(err)].ge_msg)); 56*9160SSherry.Moore@Sun.COM } 57*9160SSherry.Moore@Sun.COM 58*9160SSherry.Moore@Sun.COM const char * grub_errname(int err)59*9160SSherry.Moore@Sun.COMgrub_errname(int err) 60*9160SSherry.Moore@Sun.COM { 61*9160SSherry.Moore@Sun.COM return (err <= EG_START || err >= EG_END ? 62*9160SSherry.Moore@Sun.COM gettext("Not libgrubmgmt specific") : 63*9160SSherry.Moore@Sun.COM gettext(_grub_errstr[ GRUB_ERRNO_INDEX(err)].ge_name)); 64*9160SSherry.Moore@Sun.COM } 65