Changeset 4869:431d1b8794f0 in roaraudio
- Timestamp:
- 04/26/11 09:22:05 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/error.h
r4793 r4869 39 39 #include "libroar.h" 40 40 41 int roar_errno;41 extern int roar_errno; 42 42 43 43 struct roar_message; … … 71 71 int roar_err_parsemsg(struct roar_message * mes, struct roar_error_frame * frame); 72 72 73 int * roar_errno2(void); 74 73 75 void roar_err_clear(void); 76 void roar_err_set(const int error); 74 77 void roar_err_from_errno(void); 75 78 void roar_err_to_errno(void); -
libroar/error.c
r4793 r4869 36 36 #include "libroar.h" 37 37 38 int roar_errno = ROAR_ERROR_NONE; 39 38 40 int roar_err_int(struct roar_error_frame * frame) { 39 41 if ( frame == NULL ) … … 99 101 } 100 102 103 int * roar_errno2(void) { 104 return &roar_errno; 105 } 106 101 107 void roar_err_clear(void) { 102 roar_errno = ROAR_ERROR_NONE; 108 *roar_errno2() = ROAR_ERROR_NONE; 109 } 110 111 void roar_err_set(const int error) { 112 *roar_errno2() = error; 103 113 } 104 114 105 115 void roar_err_from_errno(void) { 116 int _roar_errno = ROAR_ERROR_NONE; 117 106 118 switch (errno) { 107 119 #ifdef EPERM 108 case EPERM: roar_errno = ROAR_ERROR_PERM; break;120 case EPERM: _roar_errno = ROAR_ERROR_PERM; break; 109 121 #endif 110 122 #ifdef ENOENT 111 case ENOENT: roar_errno = ROAR_ERROR_NOENT; break;123 case ENOENT: _roar_errno = ROAR_ERROR_NOENT; break; 112 124 #endif 113 125 #ifdef EBADMSG 114 case EBADMSG: roar_errno = ROAR_ERROR_BADMSG; break;126 case EBADMSG: _roar_errno = ROAR_ERROR_BADMSG; break; 115 127 #endif 116 128 #ifdef EBUSY 117 case EBUSY: roar_errno = ROAR_ERROR_BUSY; break;129 case EBUSY: _roar_errno = ROAR_ERROR_BUSY; break; 118 130 #endif 119 131 #ifdef ECONNREFUSED 120 case ECONNREFUSED: roar_errno = ROAR_ERROR_CONNREFUSED; break;132 case ECONNREFUSED: _roar_errno = ROAR_ERROR_CONNREFUSED; break; 121 133 #endif 122 134 #ifdef ENOSYS 123 case ENOSYS: roar_errno = ROAR_ERROR_NOSYS; break;135 case ENOSYS: _roar_errno = ROAR_ERROR_NOSYS; break; 124 136 #endif 125 137 #ifdef ENOTSUP 126 case ENOTSUP: roar_errno = ROAR_ERROR_NOTSUP; break;138 case ENOTSUP: _roar_errno = ROAR_ERROR_NOTSUP; break; 127 139 #endif 128 140 #ifdef EPIPE 129 case EPIPE: roar_errno = ROAR_ERROR_PIPE; break;141 case EPIPE: _roar_errno = ROAR_ERROR_PIPE; break; 130 142 #endif 131 143 #ifdef EPROTO 132 case EPROTO: roar_errno = ROAR_ERROR_PROTO; break;144 case EPROTO: _roar_errno = ROAR_ERROR_PROTO; break; 133 145 #endif 134 146 #ifdef ERANGE 135 case ERANGE: roar_errno = ROAR_ERROR_RANGE; break;147 case ERANGE: _roar_errno = ROAR_ERROR_RANGE; break; 136 148 #endif 137 149 #ifdef EMSGSIZE 138 case EMSGSIZE: roar_errno = ROAR_ERROR_MSGSIZE; break;150 case EMSGSIZE: _roar_errno = ROAR_ERROR_MSGSIZE; break; 139 151 #endif 140 152 #ifdef ENOMEM 141 case ENOMEM: roar_errno = ROAR_ERROR_NOMEM; break;153 case ENOMEM: _roar_errno = ROAR_ERROR_NOMEM; break; 142 154 #endif 143 155 #ifdef EINVAL 144 case EINVAL: roar_errno = ROAR_ERROR_INVAL; break;156 case EINVAL: _roar_errno = ROAR_ERROR_INVAL; break; 145 157 #endif 146 158 default: 147 roar_errno = ROAR_ERROR_UNKNOWN;159 _roar_errno = ROAR_ERROR_UNKNOWN; 148 160 break; 149 161 } 162 163 roar_err_set(_roar_errno); 150 164 } 151 165 152 166 void roar_err_to_errno(void) { 153 switch (roar_errno) { 167 int * err = roar_errno2(); 168 switch (*err) { 154 169 case ROAR_ERROR_NONE: 155 170 errno = 0; // just gussing
Note: See TracChangeset
for help on using the changeset viewer.