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