/*
* Data structure types.
*/
/**
* This type is used as replacement to legacy C string, and used throughout
* the library. By convention, the string is NOT null terminated.
*/
struct pj_str_t
{
/** Buffer pointer, which is by convention NOT null terminated. */
char *ptr;
/** The length of the string. */
pj_ssize_t slen;
};
//下面的这些代码是在pjsip/pjlib/src/pj/string.c中实现的。
PJ_DEF(unsigned long) pj_strtoul(const pj_str_t *str)
{
unsigned long value;
unsigned i;
PJ_CHECK_STACK();
value = 0;
for (i=0; i<(unsigned)str->slen; ++i) {
if (!pj_isdigit(str->ptr[i]))
break;
value = value * 10 + (str->ptr[i] - '0');
}
return value;
}
PJ_DEF(long) pj_strtol(const pj_str_t *str)
{
PJ_CHECK_STACK();
if (str->slen > 0 && (str->ptr[0] == '+' || str->ptr[0] == '-')) {
pjsip 字符串转整数处理基本函数实现
最新推荐文章于 2021-05-17 08:29:36 发布