Changeset 4869:431d1b8794f0 in roaraudio


Ignore:
Timestamp:
04/26/11 09:22:05 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

implemented roar_errno2()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/error.h

    r4793 r4869  
    3939#include "libroar.h" 
    4040 
    41 int roar_errno; 
     41extern int roar_errno; 
    4242 
    4343struct roar_message; 
     
    7171int    roar_err_parsemsg(struct roar_message * mes, struct roar_error_frame * frame); 
    7272 
     73int *  roar_errno2(void); 
     74 
    7375void   roar_err_clear(void); 
     76void   roar_err_set(const int error); 
    7477void   roar_err_from_errno(void); 
    7578void   roar_err_to_errno(void); 
  • libroar/error.c

    r4793 r4869  
    3636#include "libroar.h" 
    3737 
     38int roar_errno = ROAR_ERROR_NONE; 
     39 
    3840int    roar_err_int(struct roar_error_frame * frame) { 
    3941 if ( frame == NULL ) 
     
    99101} 
    100102 
     103int *  roar_errno2(void) { 
     104 return &roar_errno; 
     105} 
     106 
    101107void   roar_err_clear(void) { 
    102  roar_errno = ROAR_ERROR_NONE; 
     108 *roar_errno2() = ROAR_ERROR_NONE; 
     109} 
     110 
     111void   roar_err_set(const int error) { 
     112 *roar_errno2() = error; 
    103113} 
    104114 
    105115void   roar_err_from_errno(void) { 
     116 int _roar_errno = ROAR_ERROR_NONE; 
     117 
    106118 switch (errno) { 
    107119#ifdef EPERM 
    108   case EPERM:        roar_errno = ROAR_ERROR_PERM; break; 
     120  case EPERM:        _roar_errno = ROAR_ERROR_PERM; break; 
    109121#endif 
    110122#ifdef ENOENT 
    111   case ENOENT:       roar_errno = ROAR_ERROR_NOENT; break; 
     123  case ENOENT:       _roar_errno = ROAR_ERROR_NOENT; break; 
    112124#endif 
    113125#ifdef EBADMSG 
    114   case EBADMSG:      roar_errno = ROAR_ERROR_BADMSG; break; 
     126  case EBADMSG:      _roar_errno = ROAR_ERROR_BADMSG; break; 
    115127#endif 
    116128#ifdef EBUSY 
    117   case EBUSY:        roar_errno = ROAR_ERROR_BUSY; break; 
     129  case EBUSY:        _roar_errno = ROAR_ERROR_BUSY; break; 
    118130#endif 
    119131#ifdef ECONNREFUSED 
    120   case ECONNREFUSED: roar_errno = ROAR_ERROR_CONNREFUSED; break; 
     132  case ECONNREFUSED: _roar_errno = ROAR_ERROR_CONNREFUSED; break; 
    121133#endif 
    122134#ifdef ENOSYS 
    123   case ENOSYS:       roar_errno = ROAR_ERROR_NOSYS; break; 
     135  case ENOSYS:       _roar_errno = ROAR_ERROR_NOSYS; break; 
    124136#endif 
    125137#ifdef ENOTSUP 
    126   case ENOTSUP:      roar_errno = ROAR_ERROR_NOTSUP; break; 
     138  case ENOTSUP:      _roar_errno = ROAR_ERROR_NOTSUP; break; 
    127139#endif 
    128140#ifdef EPIPE 
    129   case EPIPE:        roar_errno = ROAR_ERROR_PIPE; break; 
     141  case EPIPE:        _roar_errno = ROAR_ERROR_PIPE; break; 
    130142#endif 
    131143#ifdef EPROTO 
    132   case EPROTO:       roar_errno = ROAR_ERROR_PROTO; break; 
     144  case EPROTO:       _roar_errno = ROAR_ERROR_PROTO; break; 
    133145#endif 
    134146#ifdef ERANGE 
    135   case ERANGE:       roar_errno = ROAR_ERROR_RANGE; break; 
     147  case ERANGE:       _roar_errno = ROAR_ERROR_RANGE; break; 
    136148#endif 
    137149#ifdef EMSGSIZE 
    138   case EMSGSIZE:     roar_errno = ROAR_ERROR_MSGSIZE; break; 
     150  case EMSGSIZE:     _roar_errno = ROAR_ERROR_MSGSIZE; break; 
    139151#endif 
    140152#ifdef ENOMEM 
    141   case ENOMEM:       roar_errno = ROAR_ERROR_NOMEM; break; 
     153  case ENOMEM:       _roar_errno = ROAR_ERROR_NOMEM; break; 
    142154#endif 
    143155#ifdef EINVAL 
    144   case EINVAL:       roar_errno = ROAR_ERROR_INVAL; break; 
     156  case EINVAL:       _roar_errno = ROAR_ERROR_INVAL; break; 
    145157#endif 
    146158  default: 
    147     roar_errno = ROAR_ERROR_UNKNOWN; 
     159    _roar_errno = ROAR_ERROR_UNKNOWN; 
    148160   break; 
    149161 } 
     162 
     163 roar_err_set(_roar_errno); 
    150164} 
    151165 
    152166void   roar_err_to_errno(void) { 
    153  switch (roar_errno) { 
     167 int * err = roar_errno2(); 
     168 switch (*err) { 
    154169  case ROAR_ERROR_NONE: 
    155170    errno = 0; // just gussing 
Note: See TracChangeset for help on using the changeset viewer.