inet_msg_pack.c
来自「最新MTK手机软件源码」· C语言 代码 · 共 1,737 行 · 第 1/5 页
C
1,737 行
}
else
{
l = _snprintf(buf, buf_len, "%s", inet_method_name_table[method->int_value]);
}
CHECK_INET_PACK_ENBUF(l) * r_size = l;
return INET_RESULT_OK;
} /* end of inet_msg_pack_method */
/*****************************************************************************
* FUNCTION
* inet_msg_pack_method_list
* DESCRIPTION
* This function packs the xxxx header value.
* PARAMETERS
* app_type [IN] application type
* arg [IN] pointer of header value
* buf [IN] buffer to store packed header value
* buf_len [IN] available data size of buffer
* r_size [IN/OUT] real data size to pack
* RETURNS
* INET result code
*****************************************************************************/
inet_result_enum inet_msg_pack_method_list(
kal_uint8 app_type,
void *arg,
kal_char *buf,
kal_int32 buf_len,
kal_int32 *r_size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 size = 0, l;
inet_result_enum ret;
inet_int_str_list_struct *mtd_list = (inet_int_str_list_struct*) arg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
CHECK_INET_PARAM(arg, INET_RESULT_ERROR) while (mtd_list)
{
if (mtd_list->object)
{
if ((ret = inet_msg_pack_method(
app_type,
(void*)mtd_list->object,
buf + size,
buf_len - size,
&l)) != INET_RESULT_OK)
{
return ret;
}
size += l;
if (mtd_list->next && mtd_list->next->object)
{
l = _snprintf(buf + size, buf_len - size, ", ");
CHECK_INET_PACK_ENBUF(l) size += l;
}
}
mtd_list = mtd_list->next;
}
*r_size = size;
return INET_RESULT_OK;
} /* end of sip_msg_pack_method */
/*****************************************************************************
* FUNCTION
* inet_msg_pack_cookie
* DESCRIPTION
* This function packs the cache-control header value.
* PARAMETERS
* app_type [IN] application type
* arg [IN] pointer of header value
* buf [IN] buffer to store packed header value
* buf_len [IN] available data size of buffer
* r_size [IN/OUT] real data size to pack
* RETURNS
* INET result code
*****************************************************************************/
inet_result_enum inet_msg_pack_cookie(
kal_uint8 app_type,
void *arg,
kal_char *buf,
kal_int32 buf_len,
kal_int32 *r_size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 m, size = 0;
inet_cookie_list_struct *cookies_list = (inet_cookie_list_struct*) arg;
kal_int8 version = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
CHECK_INET_PARAM(arg, INET_RESULT_ERROR) if (cookies_list->object)
{
version = cookies_list->object->version;
if (version != 0)
{
m = _snprintf(buf + size, buf_len - size, "$Version=%d;", version);
CHECK_INET_PACK_ENBUF(m);
size += m;
}
}
while (cookies_list)
{
if (cookies_list->object)
{
if (cookies_list->object->name)
{
m = _snprintf(buf + size, buf_len - size, "%s", cookies_list->object->name);
CHECK_INET_PACK_ENBUF(m);
size += m;
if (cookies_list->object->value != NULL)
{
m = _snprintf(buf + size, buf_len - size, "=%s", cookies_list->object->value);
CHECK_INET_PACK_ENBUF(m);
size += m;
}
}
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* 0 */
}
cookies_list = cookies_list->next;
if (cookies_list && cookies_list->object && cookies_list->object->name)
{
m = _snprintf(buf + size, buf_len - size, "%s", "; ");
CHECK_INET_PACK_ENBUF(m);
size += m;
}
}
*r_size = size;
return INET_RESULT_OK;
} /* inet_msg_pack_cookie */
/*****************************************************************************
* FUNCTION
* inet_msg_pack_cache_control
* DESCRIPTION
* This function packs the cache-control header value.
* PARAMETERS
* app_type [IN] application type
* arg [IN] pointer of header value
* buf [IN] buffer to store packed header value
* buf_len [IN] available data size of buffer
* r_size [IN/OUT] real data size to pack
* RETURNS
* INET result code
*****************************************************************************/
inet_result_enum inet_msg_pack_cache_control(
kal_uint8 app_type,
void *arg,
kal_char *buf,
kal_int32 buf_len,
kal_int32 *r_size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 m, size = 0;
inet_int_str_list_struct *cache_control_list = (inet_int_str_list_struct*) arg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
CHECK_INET_PARAM(arg, INET_RESULT_ERROR) while (cache_control_list)
{
/* && cache_control_list->next */
if (cache_control_list->object)
{
if (cache_control_list->object->int_value < INET_CACHE_CONTROL_NUM)
{
m = _snprintf(
buf + size,
buf_len - size,
"%s",
inet_cache_control_name_table[cache_control_list->object->int_value]);
CHECK_INET_PACK_ENBUF(m);
size += m;
if (cache_control_list->object->str_value != NULL)
{
m = _snprintf(buf + size, buf_len - size, "=%s", cache_control_list->object->str_value);
CHECK_INET_PACK_ENBUF(m);
size += m;
}
}
else if (cache_control_list->object->int_value != INET_CACHE_CONTROL_UNRECOGNIZED &&
cache_control_list->object->str_value != NULL)
{
m = _snprintf(buf + size, buf_len - size, "%s", cache_control_list->object->str_value);
CHECK_INET_PACK_ENBUF(m);
size += m;
}
if (cache_control_list->next != NULL && cache_control_list->next->object != NULL)
{
m = _snprintf(buf + size, buf_len - size, "%s", ", ");
CHECK_INET_PACK_ENBUF(m);
size += m;
}
}
cache_control_list = cache_control_list->next;
}
*r_size = size;
return INET_RESULT_OK;
} /* inet_msg_pack_cache_control */
/*****************************************************************************
* FUNCTION
* inet_msg_pack_addr_list
* DESCRIPTION
* This function packs the inet_addr_list_struct header value.
* PARAMETERS
* app_type [IN] application type
* arg [IN] pointer of header value
* buf [IN] buffer to store packed header value
* buf_len [IN] available data size of buffer
* r_size [IN/OUT] real data size to pack
* RETURNS
* INET result code
*****************************************************************************/
//Ex1:<sip:ad-hoc@mtk.com.tw>
//Ex2: Kevin <sip:ad-hoc@mtk.com.tw>
//Ex3: sip:ad-hoc@mtk.com.tw
inet_result_enum inet_msg_pack_addr_list(
kal_uint8 app_type,
void *arg,
kal_char *buf,
kal_int32 buf_len,
kal_int32 *r_size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 l;
kal_int32 size = 0;
inet_result_enum ret;
inet_addr_list_struct *addr_list = (inet_addr_list_struct*) arg;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
CHECK_INET_PARAM(arg, INET_RESULT_ERROR) while (addr_list)
{
if (addr_list->object)
{
inet_addr_struct *addr = addr_list->object;
if (addr->display_name)
{
l = _snprintf(buf + size, buf_len - size, "%s ", addr->display_name);
CHECK_INET_PACK_ENBUF(l) size += l;
}
if (addr->uri)
{
kal_bool not_star = KAL_TRUE;
if (addr->uri->host)
{
if (strcmp(addr->uri->host, "*") == 0)
{
not_star = KAL_FALSE;
}
}
if (not_star)
{
if (buf_len <= 2)
{
return INET_RESULT_NO_ENBUF;
}
strcat(buf + size, "<");
size++;
}
if ((ret = inet_msg_pack_uri(app_type, (void*)addr->uri, buf + size, buf_len - size, &l)) != INET_RESULT_OK)
{
return ret;
}
CHECK_INET_PACK_ENBUF(l) size += l;
if (not_star)
{
strcat(buf + size, ">");
size++;
}
}
if (addr->param_list)
{
if ((ret = inet_msg_pack_param_list(
app_type,
(void*)addr->param_list,
buf + size,
buf_len - size,
&l)) != INET_RESULT_OK)
{
return ret;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?