Changeset 5554:974f701cf7b5 in roaraudio


Ignore:
Timestamp:
07/07/12 13:55:15 (5 years ago)
Author:
phi
Branch:
default
Message:

support to convert EAI_* error codes (Closes: #255)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5548 r5554  
    55          (Closes: #176) 
    66        * Done more hardending work. 
    7         * Improved error handling (including on win32) (Closes: #235) 
     7        * Improved error handling (including on win32) (Closes: #235, #255) 
    88        * Added small DTMF library. 
    99        * Added filter based on Goertzel algorithm. 
  • include/libroar/error.h

    r5544 r5554  
    4848 ROAR_ERROR_TYPE_YIFF, 
    4949 ROAR_ERROR_TYPE_APPLICATION, 
    50  ROAR_ERROR_TYPE_HTTP 
     50 ROAR_ERROR_TYPE_HTTP, 
     51 ROAR_ERROR_TYPE_EAI /* getaddrinfo() and friends */ 
    5152}; 
    5253 
  • libroar/error.c

    r5544 r5554  
    10161016 {ROAR_ERROR_TYPE_WINSOCK, WSA_QOS_RESERVED_PETYPE, ROAR_ERROR_???}, 
    10171017#endif 
     1018#endif 
     1019 {ROAR_ERROR_TYPE_EAI, 0 /* defined value, see manpage */, ROAR_ERROR_NONE}, 
     1020#ifdef EAI_ADDRFAMILY 
     1021 {ROAR_ERROR_TYPE_EAI, EAI_ADDRFAMILY, ROAR_ERROR_NOENT}, 
     1022#endif 
     1023#ifdef EAI_AGAIN 
     1024 {ROAR_ERROR_TYPE_EAI, EAI_AGAIN, ROAR_ERROR_AGAIN}, 
     1025#endif 
     1026#ifdef EAI_BADFLAGS 
     1027 {ROAR_ERROR_TYPE_EAI, EAI_BADFLAGS, ROAR_ERROR_INVAL}, 
     1028#endif 
     1029#ifdef EAI_FAIL 
     1030 {ROAR_ERROR_TYPE_EAI, EAI_FAIL, ROAR_ERROR_RIO}, 
     1031#endif 
     1032#ifdef EAI_FAMILY 
     1033 {ROAR_ERROR_TYPE_EAI, EAI_FAMILY, ROAR_ERROR_AFNOTSUP}, 
     1034#endif 
     1035#ifdef EAI_MEMORY 
     1036 {ROAR_ERROR_TYPE_EAI, EAI_MEMORY, ROAR_ERROR_NOMEM}, 
     1037#endif 
     1038#ifdef EAI_NODATA 
     1039 {ROAR_ERROR_TYPE_EAI, EAI_NODATA, ROAR_ERROR_NODATA}, 
     1040#endif 
     1041#ifdef EAI_NONAME 
     1042 {ROAR_ERROR_TYPE_EAI, EAI_NONAME, ROAR_ERROR_NOENT}, 
     1043#endif 
     1044#ifdef EAI_SERVICE 
     1045 {ROAR_ERROR_TYPE_EAI, EAI_SERVICE, ROAR_ERROR_PROTONOSUP}, 
     1046#endif 
     1047#ifdef EAI_SOCKTYPE 
     1048 {ROAR_ERROR_TYPE_EAI, EAI_SOCKTYPE, ROAR_ERROR_INVAL}, 
     1049#endif 
     1050#ifdef EAI_SYSTEM 
     1051// {ROAR_ERROR_TYPE_EAI, EAI_SYSTEM, ROAR_ERROR_???}, 
    10181052#endif 
    10191053}; 
  • libroar/socket.c

    r5528 r5554  
    686686 
    687687  ret = getaddrinfo(host, port_as_string, &hints, &res); 
    688   switch (ret) { 
    689    case 0: /* no error */; break; 
    690 #ifdef EAI_ADDRFAMILY 
    691    case EAI_ADDRFAMILY: roar_err_set(ROAR_ERROR_NOENT);    break; 
    692 #endif 
    693    case EAI_AGAIN:      roar_err_set(ROAR_ERROR_AGAIN);    break; 
    694    case EAI_BADFLAGS:   roar_err_set(ROAR_ERROR_INVAL);    break; 
    695    case EAI_FAIL:       roar_err_set(ROAR_ERROR_RIO);      break; 
    696    case EAI_FAMILY:     roar_err_set(ROAR_ERROR_AFNOTSUP); break; 
    697    case EAI_MEMORY:     roar_err_set(ROAR_ERROR_NOMEM);    break; 
    698 #ifdef EAI_NODATA 
    699    case EAI_NODATA:     roar_err_set(ROAR_ERROR_NODATA);   break; 
    700 #endif 
    701    case EAI_NONAME:     roar_err_set(ROAR_ERROR_NOENT);    break; 
    702    case EAI_SERVICE:    roar_err_set(ROAR_ERROR_PROTONOSUP); break; 
    703    case EAI_SOCKTYPE:   roar_err_set(ROAR_ERROR_INVAL);    break; 
    704    case EAI_SYSTEM:     roar_err_from_errno();             break; 
    705    default: 
    706      roar_err_set(ROAR_ERROR_UNKNOWN); 
    707     break; 
    708   } 
    709   if ( ret != 0 ) 
    710    return -1; 
     688  if ( ret == EAI_SYSTEM ) { 
     689   roar_err_from_errno(); 
     690   return -1; 
     691  } else if ( ret != 0 ) { 
     692   roar_err_convert(&roar_error, ROAR_ERROR_TYPE_ROARAUDIO, ret, ROAR_ERROR_TYPE_EAI); 
     693   return -1; 
     694  } 
    711695 
    712696  if ( af_guessed ) { 
Note: See TracChangeset for help on using the changeset viewer.