1433d6423SLionel Sambuc /*
2433d6423SLionel Sambuc * Changes:
3433d6423SLionel Sambuc * Mar 07, 2010: Created (Cristiano Giuffrida)
4433d6423SLionel Sambuc */
5433d6423SLionel Sambuc
6433d6423SLionel Sambuc #include "inc.h"
7433d6423SLionel Sambuc
8433d6423SLionel Sambuc /* A single error entry. */
9433d6423SLionel Sambuc struct errentry {
10433d6423SLionel Sambuc int errnum;
11433d6423SLionel Sambuc char* errstr;
12433d6423SLionel Sambuc };
13433d6423SLionel Sambuc
14433d6423SLionel Sambuc /* Initialization errors. */
15433d6423SLionel Sambuc static struct errentry init_errlist[] = {
16*fb6bd596SCristiano Giuffrida { ENOSYS, "service does not support the requested initialization type" },
17*fb6bd596SCristiano Giuffrida { ERESTART, "service requested an initialization reset" }
18433d6423SLionel Sambuc };
19433d6423SLionel Sambuc static const int init_nerr = sizeof(init_errlist) / sizeof(init_errlist[0]);
20433d6423SLionel Sambuc
21433d6423SLionel Sambuc /* Live update errors. */
22433d6423SLionel Sambuc static struct errentry lu_errlist[] = {
23433d6423SLionel Sambuc { ENOSYS, "service does not support live update" },
24433d6423SLionel Sambuc { EINVAL, "service does not support the required state" },
25433d6423SLionel Sambuc { EBUSY, "service is not able to prepare for the update now" },
26433d6423SLionel Sambuc { EGENERIC, "generic error occurred while preparing for the update" }
27433d6423SLionel Sambuc };
28433d6423SLionel Sambuc static const int lu_nerr = sizeof(lu_errlist) / sizeof(lu_errlist[0]);
29433d6423SLionel Sambuc
30433d6423SLionel Sambuc /*===========================================================================*
31433d6423SLionel Sambuc * rs_strerror *
32433d6423SLionel Sambuc *===========================================================================*/
rs_strerror(int errnum,struct errentry * errlist,const int nerr)33433d6423SLionel Sambuc static char * rs_strerror(int errnum, struct errentry *errlist, const int nerr)
34433d6423SLionel Sambuc {
35433d6423SLionel Sambuc int i;
36433d6423SLionel Sambuc
37433d6423SLionel Sambuc for(i=0; i < nerr; i++) {
38433d6423SLionel Sambuc if(errnum == errlist[i].errnum)
39433d6423SLionel Sambuc return errlist[i].errstr;
40433d6423SLionel Sambuc }
41433d6423SLionel Sambuc
42433d6423SLionel Sambuc return strerror(-errnum);
43433d6423SLionel Sambuc }
44433d6423SLionel Sambuc
45433d6423SLionel Sambuc /*===========================================================================*
46433d6423SLionel Sambuc * init_strerror *
47433d6423SLionel Sambuc *===========================================================================*/
init_strerror(int errnum)48433d6423SLionel Sambuc char * init_strerror(int errnum)
49433d6423SLionel Sambuc {
50433d6423SLionel Sambuc return rs_strerror(errnum, init_errlist, init_nerr);
51433d6423SLionel Sambuc }
52433d6423SLionel Sambuc
53433d6423SLionel Sambuc /*===========================================================================*
54433d6423SLionel Sambuc * lu_strerror *
55433d6423SLionel Sambuc *===========================================================================*/
lu_strerror(int errnum)56433d6423SLionel Sambuc char * lu_strerror(int errnum)
57433d6423SLionel Sambuc {
58433d6423SLionel Sambuc return rs_strerror(errnum, lu_errlist, lu_nerr);
59433d6423SLionel Sambuc }
60