Changeset 5146:716400712348 in roaraudio for libroar/proto.c
- Timestamp:
- 10/15/11 12:48:07 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/proto.c
r5030 r5146 134 134 135 135 int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) { 136 return roar_recv_message2(con, mes, data, NULL); 137 } 138 int roar_recv_message2 (struct roar_connection * con, struct roar_message * mes, char ** data, 139 struct roar_error_frame * errorframe) { 136 140 struct roar_vio_calls * vio; 137 141 … … 139 143 return -1; 140 144 141 return roar_vrecv_message (vio, mes, data);145 return roar_vrecv_message2(vio, mes, data, errorframe); 142 146 } 143 147 144 148 int roar_vrecv_message(struct roar_vio_calls * vio, struct roar_message * mes, char ** data) { 149 return roar_vrecv_message2(vio, mes, data, NULL); 150 } 151 152 int roar_vrecv_message2(struct roar_vio_calls * vio, struct roar_message * mes, char ** data, 153 struct roar_error_frame * errorframe) { 145 154 // TODO: add CRC support. 146 155 char buf[_ROAR_MESS_BUF_LEN_MAX]; … … 153 162 roar_err_set(ROAR_ERROR_UNKNOWN); 154 163 155 ROAR_DBG("roar_recv_message(*): try to get a response form the server..."); 156 157 if ( mes == NULL ) 158 return -1; 164 ROAR_DBG("roar_vrecv_message2(vio=%p, mes=%p, data=%p, errorframe=%p) = ?", vio, mes, data, errorframe); 165 166 ROAR_DBG("roar_vrecv_message2(*): try to get a response form the server..."); 167 168 if ( vio == NULL || mes == NULL ) { 169 roar_err_set(ROAR_ERROR_FAULT); 170 return -1; 171 } 159 172 160 173 if ( data != NULL ) … … 168 181 } 169 182 170 ROAR_DBG("roar_ recv_message(*): Got a header");183 ROAR_DBG("roar_vrecv_message2(*): Got a header"); 171 184 172 185 mes->version = buf[0]; … … 224 237 mes->stream = -1; 225 238 226 ROAR_DBG("roar_ recv_message(*): command=%i(%s)", mes->cmd,239 ROAR_DBG("roar_vrecv_message2(*): command=%i(%s)", mes->cmd, 227 240 mes->cmd == ROAR_CMD_OK ? "OK" : (mes->cmd == ROAR_CMD_ERROR ? "ERROR" : "UNKNOWN")); 228 241 … … 230 243 231 244 if ( mes->datalen == 0 ) { 232 ROAR_DBG("roar_recv_message(*): no data in this pkg"); 233 ROAR_DBG("roar_recv_message(*) = 0"); 245 ROAR_DBG("roar_vrecv_message2(*): no data in this pkg"); 246 if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 247 roar_err_init(errorframe); 248 } 234 249 roar_err_clear(); 250 ROAR_DBG("roar_vrecv_message2(*) = 0"); 235 251 return 0; 236 252 } … … 238 254 if ( mes->datalen <= LIBROAR_BUFFER_MSGDATA ) { 239 255 if ( roar_vio_read(vio, mes->data, mes->datalen) == mes->datalen ) { 240 ROAR_DBG("roar_recv_message(*): Got data!"); 241 ROAR_DBG("roar_recv_message(*) = 0"); 256 ROAR_DBG("roar_vrecv_message2(*): Got data!"); 242 257 roar_err_clear(); 258 if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 259 if ( roar_err_parsemsg2(mes, *data, errorframe) != 0 ) { 260 roar_err_init(errorframe); 261 } 262 } 263 ROAR_DBG("roar_vrecv_message2(*) = 0"); 243 264 return 0; 244 265 } … … 258 279 if ( mes->datalen == 0 ) { 259 280 roar_err_clear(); 281 if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 282 roar_err_init(errorframe); 283 } 260 284 return 0; 261 285 } 262 286 263 287 if ( roar_vio_read(vio, *data, mes->datalen) == mes->datalen ) { 264 ROAR_DBG("roar_ recv_message(*): Got data!");265 ROAR_DBG("roar_recv_message(*) = 0"); 288 ROAR_DBG("roar_vrecv_message2(*): Got data!"); 289 266 290 roar_err_clear(); 291 if ( mes->cmd == ROAR_CMD_ERROR && errorframe != NULL ) { 292 if ( roar_err_parsemsg2(mes, *data, errorframe) != 0 ) { 293 roar_err_init(errorframe); 294 } 295 } 296 ROAR_DBG("roar_vrecv_message2(*) = 0"); 267 297 return 0; 268 298 } … … 277 307 278 308 int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) { 309 return roar_req2(con, mes, data, NULL); 310 } 311 312 int roar_req2 (struct roar_connection * con, struct roar_message * mes, char ** data, 313 struct roar_error_frame * errorframe) { 279 314 struct roar_vio_calls * vio; 280 315 … … 282 317 return -1; 283 318 284 return roar_vreq (vio, mes, data);319 return roar_vreq2(vio, mes, data, errorframe); 285 320 } 286 321 287 322 int roar_vreq (struct roar_vio_calls * vio, struct roar_message * mes, char ** data) { 323 return roar_vreq2(vio, mes, data, NULL); 324 } 325 326 int roar_vreq2 (struct roar_vio_calls * vio, struct roar_message * mes, char ** data, 327 struct roar_error_frame * errorframe) { 288 328 if ( roar_vsend_message(vio, mes, data != NULL ? *data : NULL) != 0 ) 289 329 return -1; … … 294 334 roar_vio_sync(vio); // we need to do this becasue of ssl/compressed links 295 335 296 return roar_vrecv_message (vio, mes, data);336 return roar_vrecv_message2(vio, mes, data, errorframe); 297 337 } 298 338
Note: See TracChangeset
for help on using the changeset viewer.