1420 fprintf(stderr, "\n" ); |
1420 fprintf(stderr, "\n" ); |
1421 fprintf(stderr, "returning valid frame of %d bytes.\n", frame_length); |
1421 fprintf(stderr, "returning valid frame of %d bytes.\n", frame_length); |
1422 #endif |
1422 #endif |
1423 /* set the data pointer */ |
1423 /* set the data pointer */ |
1424 *recv_data_ptr = lb_data(&(buf->data_buf)); |
1424 *recv_data_ptr = lb_data(&(buf->data_buf)); |
1425 /* remove the frame bytes off the buffer */ |
1425 /* Mark the frame bytes to be deleted off the buffer by the next call to lb_data_purge() */ |
1426 lb_data_purge(&(buf->data_buf), frame_length); |
1426 /* Notice that we cannot delete the frame bytes right away, as they will still be accessed by whoever |
|
1427 * called read_frame(). We can only delete this data on the next call to read_frame() |
|
1428 */ |
|
1429 lb_data_mark_for_purge(&(buf->data_buf), frame_length); |
1427 /* reset the search_history flag */ |
1430 /* reset the search_history flag */ |
1428 buf->frame_search_history = 0; |
1431 buf->frame_search_history = 0; |
1429 /* if the buffer becomes empty, then reset boundary flag */ |
1432 /* if the buffer becomes empty, then reset boundary flag */ |
1430 if (lb_data_count(&(buf->data_buf)) <= 0) |
1433 if (lb_data_count(&(buf->data_buf)) <= 0) |
1431 buf->found_frame_boundary = 0; |
1434 buf->found_frame_boundary = 0; |
1530 |
1533 |
1531 /* assume error... */ |
1534 /* assume error... */ |
1532 *recv_data_ptr = NULL; |
1535 *recv_data_ptr = NULL; |
1533 |
1536 |
1534 /*===================================* |
1537 /*===================================* |
|
1538 * Delete any previously received data that has already been returned as a valid frame in * |
|
1539 *===================================*/ |
|
1540 /* Delete any previously received data that has already been returned as a valid frame in |
|
1541 * the previous invocation of read_frame(). |
|
1542 * Notice that the data that will be deleted hass ben marked for deletion by calling |
|
1543 * lb_data_mark_for_purge() in return_frame() |
|
1544 */ |
|
1545 lb_data_purge(&(recv_buf->data_buf), 0); |
|
1546 |
|
1547 /*===================================* |
1535 * Check for frame in left over data * |
1548 * Check for frame in left over data * |
1536 *===================================*/ |
1549 *===================================*/ |
1537 /* If we have any data left over from previous call to read_frame() |
1550 /* If we have any data left over from previous call to read_frame() |
1538 * (i.e. this very same function), then we try to interpret that |
1551 * (i.e. this very same function), then we try to interpret that |
1539 * data, and do not wait for any extra bytes... |
1552 * data, and do not wait for any extra bytes... |