Commit 727dc12f authored by Pekka Pessi's avatar Pekka Pessi

sresolv: using <sofia-sip/su_string.h> functions

darcs-hash:20090108211228-db55f-5f04433ac86cd1bfb8c44513d584698bccff7666.gz
parent 4984b3d8
......@@ -41,6 +41,7 @@
#define SRES_CONTEXT_T struct context
#include "sofia-sip/sresolv.h"
#include "sofia-sip/su_string.h"
char const name[] = "sip_resolve";
......@@ -121,7 +122,7 @@ void answer_to_naptr_query(sres_context_t *sr,
switch (na->na_flags[0]) {
case 's': /* srv */
if (strncasecmp("SIP+", na->na_services, 4))
if (!su_casenmatch("SIP+", na->na_services, 4))
/* Something else but SIP */
break;
query_srv(sr, na->na_replace);
......@@ -129,7 +130,7 @@ void answer_to_naptr_query(sres_context_t *sr,
return;
case 'a':
if (strncasecmp("SIP+", na->na_services, 4))
if (!su_casenmatch("SIP+", na->na_services, 4))
/* Something else but SIP */
break;
query_a(sr, na->na_replace);
......
......@@ -83,6 +83,7 @@ typedef int socklen_t;
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/su_strlst.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/su_errno.h>
#include "sofia-sip/htable.h"
......@@ -1572,8 +1573,8 @@ sres_record_compare(sres_record_t const *aa, sres_record_t const *bb)
{
sres_soa_record_t const *A = aa->sr_soa, *B = bb->sr_soa;
D = A->soa_serial - B->soa_serial; if (D) return D;
D = strcasecmp(A->soa_mname, B->soa_mname); if (D) return D;
D = strcasecmp(A->soa_rname, B->soa_rname); if (D) return D;
D = su_strcasecmp(A->soa_mname, B->soa_mname); if (D) return D;
D = su_strcasecmp(A->soa_rname, B->soa_rname); if (D) return D;
D = A->soa_refresh - B->soa_refresh; if (D) return D;
D = A->soa_retry - B->soa_retry; if (D) return D;
D = A->soa_expire - B->soa_expire; if (D) return D;
......@@ -1591,7 +1592,7 @@ sres_record_compare(sres_record_t const *aa, sres_record_t const *bb)
D = A->a6_prelen - B->a6_prelen; if (D) return D;
D = !A->a6_prename - !B->a6_prename;
if (D == 0 && A->a6_prename && B->a6_prename)
D = strcasecmp(A->a6_prename, B->a6_prename); if (D) return D;
D = su_strcasecmp(A->a6_prename, B->a6_prename); if (D) return D;
return memcmp(&A->a6_suffix, &B->a6_suffix, sizeof A->a6_suffix);
}
case sres_type_aaaa:
......@@ -2251,7 +2252,7 @@ int sres_parse_config(sres_config_t *c, FILE *f)
len = strcspn(b, " \t");
value = b + len; value += strspn(value, " \t");
#define MATCH(token) (len == strlen(token) && strncasecmp(token, b, len) == 0)
#define MATCH(token) (len == strlen(token) && su_casenmatch(token, b, len))
if (MATCH("nameserver")) {
if (sres_parse_nameserver(c, value) < 0)
......
......@@ -64,6 +64,7 @@ typedef unsigned _int32 uint32_t;
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/su_strlst.h>
#include <sofia-sip/su_string.h>
#include <sofia-sip/htable.h>
#include <sofia-sip/heap.h>
......@@ -209,7 +210,7 @@ int sres_cache_get(sres_cache_t *cache,
now <= (*rr_iter)->rr_expires &&
(type == sres_qtype_any || rr->sr_type == type) &&
rr->sr_name != NULL &&
strcasecmp(rr->sr_name, domain) == 0)
su_casematch(rr->sr_name, domain))
rr_count++;
}
......@@ -236,7 +237,7 @@ int sres_cache_get(sres_cache_t *cache,
now <= (*rr_iter)->rr_expires &&
(type == sres_qtype_any || rr->sr_type == type) &&
rr->sr_name != NULL &&
strcasecmp(rr->sr_name, domain) == 0) {
su_casematch(rr->sr_name, domain)) {
SU_DEBUG_9(("rr found in cache: %s %02d\n",
rr->sr_name, rr->sr_type));
......@@ -335,7 +336,7 @@ sres_cache_store(sres_cache_t *cache, sres_record_t *rr, time_t now)
if (!!or->sr_name != !!rr->sr_name)
continue;
if (or->sr_name != rr->sr_name &&
strcasecmp(or->sr_name, rr->sr_name) != 0)
!su_casematch(or->sr_name, rr->sr_name))
continue;
if (rr->sr_type != sres_type_soa /* There can be only one */
&& sres_record_compare(or, rr))
......@@ -526,13 +527,13 @@ int sres_cache_set_srv_priority(sres_cache_t *cache,
if (rr && rr->sr_name &&
sres_type_srv == rr->sr_type &&
strcasecmp(rr->sr_name, domain) == 0) {
su_casematch(rr->sr_name, domain)) {
(*iter)->rr_expires = expires;
if ((port == 0 || rr->sr_srv->srv_port == port) &&
rr->sr_srv->srv_target &&
strcasecmp(rr->sr_srv->srv_target, target) == 0) {
su_casematch(rr->sr_srv->srv_target, target)) {
/* record found --> change priority of server */
rr->sr_srv->srv_priority = priority;
ret++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment