Changeset 4433:df25c6da63e6 in roaraudio


Ignore:
Timestamp:
10/09/10 15:00:11 (8 years ago)
Author:
phi
Branch:
default
Message:

added a lot debug lions, fixed some small bugs in size calc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/serverinfo.c

    r4430 r4433  
    7373} 
    7474 
    75 #define _add(t, m) do { if ( (sl = strlen(info->m)) != 0 ) { iebuf[idx].type = (t); iebuf[idx].len = sl; iebuf[idx].buf = (info->m); idx++; needlen += 4 + sl; } } while (0) 
     75#define _add(t, m) do { if ( info->m != NULL && (sl = strlen(info->m)) != 0 ) { iebuf[idx].type = (t); iebuf[idx].len = sl; iebuf[idx].buf = (info->m); idx++; needlen += 4 + sl; } } while (0) 
    7676 
    7777int roar_server_info_to_mes(struct roar_message * mes, struct roar_server_info * info) { 
     
    144144 char ** tptr; 
    145145 
     146 ROAR_DBG("roar_server_info(mes=%p{.datalen=%llu) = ?", mes, (long long unsigned int)mes->datalen); 
     147 
    146148 if ( mes == NULL ) 
    147149  return NULL; 
    148150 
    149151 memset(iebuf, 0, sizeof(iebuf)); 
     152 
     153 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
    150154 
    151155 // some basic texts like version: 
     
    153157  return NULL; 
    154158 
     159 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
     160 
    155161 if ( mes->data[0] != 0 ) /* version */ 
    156162  return NULL; 
    157163 
     164 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
     165 
    158166 if ( mes->data[1] != 0 ) /* reserved */ 
    159167  return NULL; 
    160168 
     169 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
     170 
    161171 d16 = (uint16_t*)mes->data; 
    162172 
    163173 idx = ROAR_NET2HOST16(d16[1]); 
     174 
     175 ROAR_DBG("roar_server_info(mes=%p): idx=%i", mes, idx); 
    164176 
    165177 // return error if our index buffer is too short. 
     
    167179  return NULL; 
    168180 
     181 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
     182 
     183 ROAR_DBG("roar_server_info(mes=%p): needlen=%llu", mes, (long long unsigned int)needlen); 
     184 
    169185 needlen += 4*idx; 
    170186 
     
    173189  return NULL; 
    174190 
     191 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
     192 
    175193 d16 = (uint16_t*)mes->data; 
    176194 dptr = &(d16[2]); 
    177195 
    178196 textpart = mes->data + (4 + 4*idx); 
     197 
     198 ROAR_DBG("roar_server_info(mes=%p): needlen=%llu", mes, (long long unsigned int)needlen); 
    179199 
    180200 for (i = 0; i < idx; i++) { 
     
    184204  needlen  += iebuf[i].len; 
    185205  textpart += iebuf[i].len; 
    186  } 
     206  dptr += 2; 
     207  ROAR_DBG("roar_server_info(mes=%p): iebuf[i]={.len=%llu,...}", mes, (long long unsigned int)iebuf[i].len); 
     208 } 
     209 
     210 ROAR_DBG("roar_server_info(mes=%p): needlen=%llu", mes, (long long unsigned int)needlen); 
    187211 
    188212 // recheck if we have all the data... 
     
    190214  return NULL; 
    191215 
     216 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
     217 
    192218 // alloc the needed space. this can be reduced in future to the actual needed value. 
    193219 ret = roar_mm_malloc(2*sizeof(struct roar_server_info) + mes->datalen); 
     
    195221 if ( ret == NULL ) 
    196222  return NULL; 
     223 
     224 ROAR_DBG("roar_server_info(mes=%p) = ?", mes); 
    197225 
    198226 // for the size see the alloc call above. 
     
    236264 } 
    237265 
     266 ROAR_DBG("roar_server_info(mes=%p) = %p", mes, ret); 
     267 
    238268 return ret; 
    239269} 
Note: See TracChangeset for help on using the changeset viewer.