Changeset 5146:716400712348 in roaraudio for libroar/auth.c


Ignore:
Timestamp:
10/15/11 12:48:07 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Moved error frame handling into proto functions (pr0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/auth.c

    r5144 r5146  
    135135 char                  * data = NULL; 
    136136 
     137 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 
     138 
     139 roar_err_init(&error_frame); 
    137140 memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy! 
    138141 
     
    162165 } 
    163166 
    164  if ( (ret = roar_req(con, &mes, &data)) == -1 ) { 
     167 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 
     168 
     169 if ( (ret = roar_req2(con, &mes, &data, &error_frame)) == -1 ) { 
    165170  authmes->type = -1; 
    166   return -1; 
    167  } 
     171  ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = -1 // next: -1", con, authmes, authmes->type); 
     172  return -1; 
     173 } 
     174 
     175 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): mes->cmd=%i", con, authmes, authmes->type, mes.cmd); 
    168176 
    169177 if ( data != NULL ) { 
     
    173181 } 
    174182 
    175  if ( mes.cmd != ROAR_CMD_OK ) { 
    176   if ( data != NULL ) { 
    177    // we currently do not support long error frames. 
    178    free(data); 
    179    return -1; 
    180   } 
    181  
     183 if ( mes.cmd == ROAR_CMD_ERROR ) 
    182184  ret = -1; 
    183   if ( roar_err_parsemsg(&mes, &error_frame) == -1 ) { 
    184    authmes->type = -1; 
    185    return -1; 
    186   } 
    187  
     185 
     186 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}): error_frame.data=%p", 
     187           con, authmes, authmes->type, error_frame.data); 
     188 
     189 if ( mes.cmd == ROAR_CMD_ERROR && error_frame.data != NULL ) { 
    188190  header = error_frame.data; 
    189191  mes.datalen = error_frame.datalen; 
    190192 } 
     193 
     194 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p{.type=%i}) = ?", con, authmes, authmes->type); 
    191195 
    192196 if ( mes.datalen < 4 ) { 
     
    197201 } 
    198202 
     203 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = ?", con, authmes); 
     204 
    199205 authmes->stage         = header[1]; 
    200206 authmes->reserved.c[0] = header[2]; 
     
    204210  free(data); 
    205211 
     212 ROAR_DBG("roar_auth_ask_server(con=%p, authmes=%p) = %i // next: %i", con, authmes, ret, authmes->type); 
    206213 return ret; 
    207214} 
     
    307314 for (i = 0; ltt[i] != _EOL; i++) { 
    308315  next = ltt[i]; 
     316  ROAR_DBG("roar_auth(con=%p): next from ltt: %s(%i)", con, roar_autht2str(next), next); 
     317 
    309318  while (next != -1) { 
    310319   done = 1; 
     
    312321   cur  = next; 
    313322   next = -1; 
     323 
     324   ROAR_DBG("roar_auth(con=%p): cur=%s(%i)", con, roar_autht2str(cur), cur); 
    314325 
    315326   switch (cur) { 
     
    322333    case ROAR_AUTH_T_RHOST: 
    323334    case ROAR_AUTH_T_NONE: 
    324       roar_auth_mes_init(&authmes, ltt[i]); 
     335      roar_auth_mes_init(&authmes, cur); 
    325336      if ( (ret = roar_auth_ask_server(con, &authmes)) == -1 ) 
    326337       done = 0; 
     
    341352    done = 0; 
    342353 
    343    if ( done ) 
     354   ROAR_DBG("roar_auth(con=%p): done=%i, next=%i", con, done, next); 
     355 
     356   if ( done ) { 
     357    ROAR_DBG("roar_auth(con=%p) = 0", con); 
    344358    return 0; 
     359   } 
    345360  } 
    346361 } 
    347362 
     363 ROAR_DBG("roar_auth(con=%p) = -1", con); 
    348364 return -1; 
    349365} 
     
    354370 char header[4] = {0, 0, 0, 0}; 
    355371 
    356  if ( ames == NULL || mes == NULL ) 
    357   return -1; 
     372 if ( ames == NULL || mes == NULL ) { 
     373  roar_err_set(ROAR_ERROR_FAULT); 
     374  return -1; 
     375 } 
    358376 
    359377 if ( data != NULL ) { 
     
    386404 char * obuf; 
    387405 
    388  if ( mes == NULL || ames == NULL ) 
    389   return -1; 
     406 if ( mes == NULL || ames == NULL ) { 
     407  roar_err_set(ROAR_ERROR_FAULT); 
     408  return -1; 
     409 } 
    390410 
    391411 if ( data != NULL ) 
Note: See TracChangeset for help on using the changeset viewer.