28 |
|
#include <stdlib.h> |
29 |
|
|
30 |
|
#include "statgrab.h" |
31 |
+ |
#include "tools.h" |
32 |
|
|
33 |
|
static sg_error error = SG_ERROR_NONE; |
34 |
+ |
#define ERROR_ARG_MAX 256 |
35 |
+ |
static char error_arg[ERROR_ARG_MAX]; |
36 |
|
|
37 |
|
void sg_set_error(sg_error code, const char *arg) { |
38 |
|
error = code; |
39 |
< |
/* FIXME do something with arg */ |
39 |
> |
if (arg != NULL) { |
40 |
> |
sg_strlcpy(error_arg, arg, sizeof error_arg); |
41 |
> |
} |
42 |
> |
else { |
43 |
> |
/* FIXME is this the best idea? */ |
44 |
> |
error_arg[0] = '\0'; |
45 |
> |
} |
46 |
|
} |
47 |
|
|
48 |
|
sg_error sg_get_error() { |
49 |
|
return error; |
50 |
|
} |
51 |
|
|
52 |
+ |
const char *sg_get_error_arg() { |
53 |
+ |
return error_arg; |
54 |
+ |
} |
55 |
+ |
|
56 |
|
const char *sg_str_error(sg_error code) { |
57 |
|
switch (code) { |
58 |
|
case SG_ERROR_NONE: |
115 |
|
return "unsupported function"; |
116 |
|
case SG_ERROR_XSW_VER_MISMATCH: |
117 |
|
return "XSW version mismatch"; |
105 |
– |
default: |
106 |
– |
return "unknown error"; |
118 |
|
} |
119 |
+ |
return "unknown error"; |
120 |
|
} |
121 |
|
|