Changeset 4793:a5f42917b666 in roaraudio


Ignore:
Timestamp:
03/14/11 14:25:13 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Moved error string lookup from VS into error.c (pr1)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r4788 r4793  
    1313        * Added support for a simple trap mechanism (pr1) 
    1414        * Added simple authfile support to roard (pr1) 
     15        * Moved error string lookup from VS into error.c (pr1) 
    1516 
    1617v. 0.4beta3 - Wed Jan 26 2011 23:26 CET 
  • include/libroar/error.h

    r4708 r4793  
    7575void   roar_err_to_errno(void); 
    7676 
     77const char * roar_error2str(const int error); 
     78 
    7779#endif 
    7880 
  • libroar/error.c

    r4708 r4793  
    230230} 
    231231 
     232 
     233const char * roar_error2str(const int error) { 
     234 const struct { 
     235  const int    err; 
     236  const char * msg; 
     237 } msgs[] = { 
     238  {ROAR_ERROR_NONE,        "No error"}, 
     239  {ROAR_ERROR_PERM,        "Operation not permitted"}, 
     240  {ROAR_ERROR_NOENT,       "No such object, file or directory"}, 
     241  {ROAR_ERROR_BADMSG,      "Bad message"}, 
     242  {ROAR_ERROR_BUSY,        "Device or resource busy"}, 
     243  {ROAR_ERROR_CONNREFUSED, "Connection refused"}, 
     244  {ROAR_ERROR_NOSYS,       "Function not implemented"}, 
     245  {ROAR_ERROR_NOTSUP,      "Operation not supported"}, 
     246  {ROAR_ERROR_PIPE,        "Broken pipe"}, 
     247  {ROAR_ERROR_PROTO,       "Protocol error"}, 
     248  {ROAR_ERROR_RANGE,       "Result too large or parameter out of range"}, 
     249  {ROAR_ERROR_MSGSIZE,     "Message too long"}, 
     250  {ROAR_ERROR_NOMEM,       "Not enough space"}, 
     251  {ROAR_ERROR_INVAL,       "Invalid argument"}, 
     252  {-1, NULL} 
     253 }; 
     254 int i; 
     255 
     256 for (i = 0; msgs[i].msg != NULL; i++) 
     257  if ( msgs[i].err == error ) 
     258   return msgs[i].msg; 
     259 
     260 return NULL; 
     261} 
     262 
    232263//ll 
  • libroar/vs.c

    r4772 r4793  
    8181 
    8282const char * roar_vs_strerr(int error) { 
    83  const struct { 
    84   int err; 
    85   const char * msg; 
    86  } msgs[] = { 
    87   {ROAR_ERROR_NONE,        "No error"}, 
    88   {ROAR_ERROR_PERM,        "Operation not permitted"}, 
    89   {ROAR_ERROR_NOENT,       "No such object, file or directory"}, 
    90   {ROAR_ERROR_BADMSG,      "Bad message"}, 
    91   {ROAR_ERROR_BUSY,        "Device or resource busy"}, 
    92   {ROAR_ERROR_CONNREFUSED, "Connection refused"}, 
    93   {ROAR_ERROR_NOSYS,       "Function not implemented"}, 
    94   {ROAR_ERROR_NOTSUP,      "Operation not supported"}, 
    95   {ROAR_ERROR_PIPE,        "Broken pipe"}, 
    96   {ROAR_ERROR_PROTO,       "Protocol error"}, 
    97   {ROAR_ERROR_RANGE,       "Result too large or parameter out of range"}, 
    98   {ROAR_ERROR_MSGSIZE,     "Message too long"}, 
    99   {ROAR_ERROR_NOMEM,       "Not enough space"}, 
    100   {ROAR_ERROR_INVAL,       "Invalid argument"}, 
    101   {-1, NULL} 
    102  }; 
    103  int i; 
    104  
    105  for (i = 0; msgs[i].msg != NULL; i++) 
    106   if ( msgs[i].err == error ) 
    107    return msgs[i].msg; 
    108  
    109  return "(unknown)"; 
     83 const char * ret = roar_error2str(error); 
     84 
     85 if ( ret == NULL ) 
     86  return "(unknown)"; 
     87 
     88 return ret; 
    11089} 
    11190 
Note: See TracChangeset for help on using the changeset viewer.