35 |
|
static sg_error error = SG_ERROR_NONE; |
36 |
|
#define ERROR_ARG_MAX 256 |
37 |
|
static char error_arg[ERROR_ARG_MAX]; |
38 |
< |
static char error_strerror[ERROR_ARG_MAX]; |
38 |
> |
static int errno_value = 0; |
39 |
|
|
40 |
|
void sg_set_error(sg_error code, const char *arg) { |
41 |
+ |
errno_value = 0; |
42 |
|
error = code; |
43 |
|
if (arg != NULL) { |
44 |
|
sg_strlcpy(error_arg, arg, sizeof error_arg); |
49 |
|
} |
50 |
|
} |
51 |
|
|
52 |
< |
void sg_set_error_with_errno(sg_error code, const char *arg, int use_errno) { |
52 |
< |
if(use_errno) { |
53 |
< |
sg_strlcpy(error_strerror, strerror(errno), sizeof error_strerror); |
54 |
< |
} |
55 |
< |
else { |
56 |
< |
/* FIXME is this the best idea? */ |
57 |
< |
error_strerror[0] = '\0'; |
58 |
< |
} |
52 |
> |
void sg_set_error_with_errno(sg_error code, const char *arg) { |
53 |
|
sg_set_error(code, arg); |
54 |
+ |
errno_value = errno; |
55 |
|
} |
56 |
|
|
57 |
|
sg_error sg_get_error() { |
62 |
|
return error_arg; |
63 |
|
} |
64 |
|
|
65 |
< |
const char *sg_get_error_strerror() { |
66 |
< |
return error_strerror; |
65 |
> |
int sg_get_error_errno() { |
66 |
> |
return errno_value; |
67 |
|
} |
68 |
|
|
69 |
|
const char *sg_str_error(sg_error code) { |
128 |
|
return "unsupported function"; |
129 |
|
case SG_ERROR_XSW_VER_MISMATCH: |
130 |
|
return "XSW version mismatch"; |
131 |
+ |
case SG_ERROR_PSTAT: |
132 |
+ |
return "pstat failed"; |
133 |
|
} |
134 |
|
return "unknown error"; |
135 |
|
} |