int ul_cbuff_is_ready(const ul_cbuff_msg_head_t *msg);
int ul_cbuff_head_alloc(ul_cbuff_t *buff, ul_cbuff_put_info_t *put_info, unsigned int size, unsigned int flags);
int ul_cbuff_head_put(ul_cbuff_t *buff, ul_cbuff_put_info_t *put_info);
-ul_cbuff_loc_t ul_cbuff_head_loc(ul_cbuff_t *buff, ul_cbuff_msg_head_t *msg_head);
-ul_cbuff_loc_t ul_cbuff_next_loc(ul_cbuff_t *buff, ul_cbuff_msg_head_t *msg_head);
+ul_cbuff_loc_t ul_cbuff_head_loc(const ul_cbuff_t *buff, const ul_cbuff_msg_head_t *msg_head);
+ul_cbuff_loc_t ul_cbuff_next_loc(const ul_cbuff_t *buff, const ul_cbuff_msg_head_t *msg_head);
+int ul_cbuff_msg_head2data(const ul_cbuff_t *buff, ul_cbuff_data_info_t *data, const ul_cbuff_msg_head_t *msg_head);
int ul_cbuff_tail_attach(ul_cbuff_t *buff, ul_cbuff_tail_info_t *tail_info, int mode);
int ul_cbuff_tail_incontact(ul_cbuff_t *buff, ul_cbuff_tail_info_t *tail_info);
int ul_cbuff_tail_test(ul_cbuff_t *buff, ul_cbuff_tail_info_t *tail_info);
}
ul_cbuff_inline ul_cbuff_loc_t
-ul_cbuff_head_loc(ul_cbuff_t *buff, ul_cbuff_msg_head_t *msg_head)
+ul_cbuff_head_loc(const ul_cbuff_t *buff, const ul_cbuff_msg_head_t *msg_head)
{
return (unsigned char*)msg_head-buff->buff_start;
}
ul_cbuff_inline ul_cbuff_loc_t
-ul_cbuff_next_loc(ul_cbuff_t *buff, ul_cbuff_msg_head_t *msg_head)
+ul_cbuff_next_loc(const ul_cbuff_t *buff, const ul_cbuff_msg_head_t *msg_head)
{
ul_cbuff_loc_t loc;
unsigned int size;
return loc;
}
+ul_cbuff_inline int
+ul_cbuff_msg_head2data(const ul_cbuff_t *buff, ul_cbuff_data_info_t *data, const ul_cbuff_msg_head_t *msg_head)
+{
+ ul_cbuff_loc_t res_size;
+ unsigned int length;
+ ul_cbuff_loc_t msg_loc=(unsigned char *)msg_head-buff->buff_start;
+
+ res_size=buff->state->buff_size-msg_loc;
+ length=msg_head->length;
+
+ if(res_size > ul_cbuff_msg_head_size){
+ data->ptr=(unsigned char*)msg_head+ul_cbuff_msg_head_size;
+ if(res_size-ul_cbuff_msg_head_size >= length){
+ data->cont_len=length;
+ data->wrap_ptr=NULL;
+ data->wrap_len=0;
+ }else{
+ data->cont_len=res_size-ul_cbuff_msg_head_size;
+ data->wrap_ptr=buff->buff_start;
+ data->wrap_len=length-(res_size-ul_cbuff_msg_head_size);
+ }
+ } else {
+ data->ptr=buff->buff_start;
+ data->cont_len=length;
+ data->wrap_ptr=NULL;
+ data->wrap_len=0;
+ }
+ return msg_head->flags;
+}
+
ul_cbuff_inline int
ul_cbuff_tail_attach(ul_cbuff_t *buff, ul_cbuff_tail_info_t *tail_info, int mode)
{
ul_cbuff_inline int
ul_cbuff_tail_test(ul_cbuff_t *buff, ul_cbuff_tail_info_t *tail_info)
{
- ul_cbuff_loc_t res_size;
- unsigned int length;
ul_cbuff_msg_head_t *msg_head=tail_info->msg_head;
if(!msg_head)
if(!ul_cbuff_is_ready(msg_head))
return 0;
- res_size=buff->state->buff_size-((unsigned char*)msg_head-buff->buff_start);
- length=msg_head->length;
-
- if(res_size > ul_cbuff_msg_head_size){
- tail_info->data.ptr=(unsigned char*)msg_head+ul_cbuff_msg_head_size;
- if(res_size-ul_cbuff_msg_head_size >= length){
- tail_info->data.cont_len=length;
- tail_info->data.wrap_ptr=NULL;
- tail_info->data.wrap_len=0;
- }else{
- tail_info->data.cont_len=res_size-ul_cbuff_msg_head_size;
- tail_info->data.wrap_ptr=buff->buff_start;
- tail_info->data.wrap_len=length-(res_size-ul_cbuff_msg_head_size);
- }
- } else {
- tail_info->data.ptr=buff->buff_start;
- tail_info->data.cont_len=length;
- tail_info->data.wrap_ptr=NULL;
- tail_info->data.wrap_len=0;
- }
- return msg_head->flags;
+ return ul_cbuff_msg_head2data(buff, &tail_info->data, msg_head);
}
ul_cbuff_inline int