ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/error.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/error.c (file contents):
Revision 1.7 by tdb, Wed Apr 7 21:08:40 2004 UTC vs.
Revision 1.14 by ats, Sun Jul 18 20:39:02 2004 UTC

# Line 26 | Line 26
26   #endif
27  
28   #include <stdlib.h>
29 + #include <string.h>
30 + #include <errno.h>
31  
32   #include "statgrab.h"
33 + #include "tools.h"
34  
35   static sg_error error = SG_ERROR_NONE;
36 + #define ERROR_ARG_MAX 256
37 + static char error_arg[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 <        /* FIXME do something with arg */
43 >        if (arg != NULL) {
44 >                sg_strlcpy(error_arg, arg, sizeof error_arg);
45 >        }
46 >        else {
47 >                /* FIXME is this the best idea? */
48 >                error_arg[0] = '\0';
49 >        }
50   }
51  
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() {
58          return error;
59   }
60  
61 + const char *sg_get_error_arg() {
62 +        return error_arg;
63 + }
64 +
65 + const int sg_get_error_errno() {
66 +        return errno_value;
67 + }
68 +
69   const char *sg_str_error(sg_error code) {
70          switch (code) {
71          case SG_ERROR_NONE:
# Line 102 | Line 128 | const char *sg_str_error(sg_error code) {
128                  return "unsupported function";
129          case SG_ERROR_XSW_VER_MISMATCH:
130                  return "XSW version mismatch";
105        default:
106                return "unknown error";
131          }
132 +        return "unknown error";
133   }
134  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines