Example #1
0
PJ_DEF(int) strcasecmp(const char *s1, const char *s2)
{
    while ((*s1==*s2) || (pj_tolower(*s1)==pj_tolower(*s2))) {
	if (!*s1++)
	    return 0;
	++s2;
    }
    return (pj_tolower(*s1) < pj_tolower(*s2)) ? -1 : 1;
}
Example #2
0
int my_strncasecmp(const char *s1, const char *s2, int max_len)
{
    while (*s1 && *s2 && max_len > 0) {
        if (pj_tolower(*s1) != pj_tolower(*s2))
            return -1;
        ++s1;
        ++s2;
        --max_len;
    }
    return 0;
}
Example #3
0
PJ_DEF(int) strncasecmp(const char *s1, const char *s2, int len)
{
    if (!len) return 0;

    while ((*s1==*s2) || (pj_tolower(*s1)==pj_tolower(*s2))) {
	if (!*s1++ || --len <= 0)
	    return 0;
	++s2;
    }
    return (pj_tolower(*s1) < pj_tolower(*s2)) ? -1 : 1;
}
Example #4
0
/*
 * Finds out if qop offer contains "auth" token.
 */
static pj_bool_t has_auth_qop( pj_pool_t *pool, const pj_str_t *qop_offer)
{
    pj_str_t qop;
    char *p;

    pj_strdup_with_null( pool, &qop, qop_offer);
    p = qop.ptr;
    while (*p) {
	*p = (char)pj_tolower(*p);
	++p;
    }

    p = qop.ptr;
    while (*p) {
	if (*p=='a' && *(p+1)=='u' && *(p+2)=='t' && *(p+3)=='h') {
	    int e = *(p+4);
	    if (e=='"' || e==',' || e==0)
		return PJ_TRUE;
	    else
		p += 4;
	} else {
	    ++p;
	}
    }

    return PJ_FALSE;
}
Example #5
0
PJ_DEF(pj_uint32_t) pj_hash_calc_tolower( pj_uint32_t hval,
                                          char *result,
                                          const pj_str_t *key)
{
    long i;

#if defined(PJ_HASH_USE_OWN_TOLOWER) && PJ_HASH_USE_OWN_TOLOWER != 0
    for (i=0; i<key->slen; ++i) {
	pj_uint8_t c = key->ptr[i];
        char lower;
	if (c & 64)
	    lower = (char)(c | 32);
	else
	    lower = (char)c;
	if (result)
            result[i] = lower;
	hval = hval * PJ_HASH_MULTIPLIER + lower;
    }
#else
    for (i=0; i<key->slen; ++i) {
        char lower = (char)pj_tolower(key->ptr[i]);
	if (result)
            result[i] = lower;
	hval = hval * PJ_HASH_MULTIPLIER + lower;
    }
#endif

    return hval;
}
Example #6
0
/*
 * Create ICE session, invoked from the menu.
 */
void natclient_init_session(struct ice_trans_s* icetrans, unsigned rolechar)
{
    pj_ice_sess_role role = (pj_tolower((pj_uint8_t)rolechar)=='o' ?
                                 PJ_ICE_SESS_ROLE_CONTROLLING :
                                 PJ_ICE_SESS_ROLE_CONTROLLED);
    pj_status_t status;

    if (icetrans->icest == NULL) {
        PJ_LOG(1,(THIS_FILE, "Error: No ICE instance, create it first"));
        return;
    }

    if (pj_ice_strans_has_sess(icetrans->icest)) {
        PJ_LOG(1,(THIS_FILE, "Error: Session already created"));
        return;
    }

    status = pj_ice_strans_init_ice(icetrans->icest, role, NULL, NULL);
    if (status != PJ_SUCCESS)
        natclient_perror("error creating session", status);
    else
        PJ_LOG(3,(THIS_FILE, "ICE session created"));

    reset_rem_info(icetrans);
}
Example #7
0
/* Compare two numbers, according to RFC 3966:
 *  - both must be either local or global numbers.
 *  - The 'global-number-digits' and the 'local-number-digits' must be
 *    equal, after removing all visual separators.
 */
PJ_DEF(int) pjsip_tel_nb_cmp(const pj_str_t *number1, const pj_str_t *number2)
{
    const char *s1 = number1->ptr,
	       *e1 = number1->ptr + number1->slen,
	       *s2 = number2->ptr,
	       *e2 = number2->ptr + number2->slen;

    /* Compare each number, ignoreing visual separators. */
    while (s1!=e1 && s2!=e2) {
	int diff;

	if (pj_cis_match(&pjsip_TEL_VISUAL_SEP_SPEC, *s1)) {
	    ++s1;
	    continue;
	}
	if (pj_cis_match(&pjsip_TEL_VISUAL_SEP_SPEC, *s2)) {
	    ++s2;
	    continue;
	}

	diff = pj_tolower(*s1) - pj_tolower(*s2);
	if (!diff) {
	    ++s1, ++s2;
	    continue;
	} else
	    return diff;
    }

    /* Exhaust remaining visual separators. */
    while (s1!=e1 && pj_cis_match(&pjsip_TEL_VISUAL_SEP_SPEC, *s1))
	++s1;
    while (s2!=e2 && pj_cis_match(&pjsip_TEL_VISUAL_SEP_SPEC, *s2))
	++s2;

    if (s1==e1 && s2==e2)
	return 0;
    else if (s1==e1)
	return -1;
    else
	return 1;
}
Example #8
0
PJ_DEF(pj_uint32_t) pj_hash_calc_tolower( pj_uint32_t hval,
                                          char *result,
                                          const pj_str_t *key)
{
    long i;

    for (i=0; i<key->slen; ++i) {
        char lower = (char)pj_tolower(key->ptr[i]);
	if (result)
            result[i] = lower;
	hval = hval * PJ_HASH_MULTIPLIER + lower;
    }

    return hval;
}