1*433d6423SLionel Sambuc /* 2*433d6423SLionel Sambuc * Changes: 3*433d6423SLionel Sambuc * Mar 07, 2010: Created (Cristiano Giuffrida) 4*433d6423SLionel Sambuc */ 5*433d6423SLionel Sambuc 6*433d6423SLionel Sambuc #include "inc.h" 7*433d6423SLionel Sambuc 8*433d6423SLionel Sambuc /* A single error entry. */ 9*433d6423SLionel Sambuc struct errentry { 10*433d6423SLionel Sambuc int errnum; 11*433d6423SLionel Sambuc char* errstr; 12*433d6423SLionel Sambuc }; 13*433d6423SLionel Sambuc 14*433d6423SLionel Sambuc /* Initialization errors. */ 15*433d6423SLionel Sambuc static struct errentry init_errlist[] = { 16*433d6423SLionel Sambuc { ENOSYS, "service does not support the requested initialization type" } 17*433d6423SLionel Sambuc }; 18*433d6423SLionel Sambuc static const int init_nerr = sizeof(init_errlist) / sizeof(init_errlist[0]); 19*433d6423SLionel Sambuc 20*433d6423SLionel Sambuc /* Live update errors. */ 21*433d6423SLionel Sambuc static struct errentry lu_errlist[] = { 22*433d6423SLionel Sambuc { ENOSYS, "service does not support live update" }, 23*433d6423SLionel Sambuc { EINVAL, "service does not support the required state" }, 24*433d6423SLionel Sambuc { EBUSY, "service is not able to prepare for the update now" }, 25*433d6423SLionel Sambuc { EGENERIC, "generic error occurred while preparing for the update" } 26*433d6423SLionel Sambuc }; 27*433d6423SLionel Sambuc static const int lu_nerr = sizeof(lu_errlist) / sizeof(lu_errlist[0]); 28*433d6423SLionel Sambuc 29*433d6423SLionel Sambuc /*===========================================================================* 30*433d6423SLionel Sambuc * rs_strerror * 31*433d6423SLionel Sambuc *===========================================================================*/ 32*433d6423SLionel Sambuc static char * rs_strerror(int errnum, struct errentry *errlist, const int nerr) 33*433d6423SLionel Sambuc { 34*433d6423SLionel Sambuc int i; 35*433d6423SLionel Sambuc 36*433d6423SLionel Sambuc for(i=0; i < nerr; i++) { 37*433d6423SLionel Sambuc if(errnum == errlist[i].errnum) 38*433d6423SLionel Sambuc return errlist[i].errstr; 39*433d6423SLionel Sambuc } 40*433d6423SLionel Sambuc 41*433d6423SLionel Sambuc return strerror(-errnum); 42*433d6423SLionel Sambuc } 43*433d6423SLionel Sambuc 44*433d6423SLionel Sambuc /*===========================================================================* 45*433d6423SLionel Sambuc * init_strerror * 46*433d6423SLionel Sambuc *===========================================================================*/ 47*433d6423SLionel Sambuc char * init_strerror(int errnum) 48*433d6423SLionel Sambuc { 49*433d6423SLionel Sambuc return rs_strerror(errnum, init_errlist, init_nerr); 50*433d6423SLionel Sambuc } 51*433d6423SLionel Sambuc 52*433d6423SLionel Sambuc /*===========================================================================* 53*433d6423SLionel Sambuc * lu_strerror * 54*433d6423SLionel Sambuc *===========================================================================*/ 55*433d6423SLionel Sambuc char * lu_strerror(int errnum) 56*433d6423SLionel Sambuc { 57*433d6423SLionel Sambuc return rs_strerror(errnum, lu_errlist, lu_nerr); 58*433d6423SLionel Sambuc } 59