Commit 6ffc4152 authored by Pekka Pessi's avatar Pekka Pessi

soa: added soa_tag_filter() function.

darcs-hash:20061019141751-65a35-7fb375f3168950c501dab0e2cc34d6aeaed03e68.gz
parent 95a4ad47
......@@ -10,6 +10,8 @@
INCLUDES = -I$(srcdir)/../sdp -I../sdp \
-I$(srcdir)/../sip -I../sip \
-I$(srcdir)/../msg -I../msg \
-I$(srcdir)/../url -I../url \
-I$(srcdir)/../ipt -I../ipt \
-I$(srcdir)/../bnf -I../bnf \
-I$(srcdir)/../su -I../su
......@@ -39,6 +41,8 @@ COVERAGE_INPUT = $(libsoa_la_SOURCES) $(include_sofia_HEADERS)
LDADD = libsoa.la \
../sip/libsip.la \
../msg/libmsg.la \
../url/liburl.la \
../sdp/libsdp.la \
../ipt/libipt.la \
../bnf/libbnf.la \
......
......@@ -33,12 +33,36 @@
#include <sofia-sip/su.h>
#if 1
#define TAG_NAMESPACE soa_tag_namespace
#else
/* Definition used by tag_dll.awk */
#define TAG_NAMESPACE "soa"
#endif
#include <sofia-sip/soa.h>
#include <sofia-sip/su_tag_class.h>
#include <sofia-sip/sdp_tag.h>
#include <string.h>
char const soa_tag_namespace[] = "soa";
/** Filter soa tags. */
int soa_tag_filter(tagi_t const *f, tagi_t const *t)
{
char const *ns;
if (!t || !t->t_tag)
return 0;
ns = t->t_tag->tt_ns;
if (!ns)
return 0;
return ns == soa_tag_namespace || strcmp(ns, soa_tag_namespace) == 0;
}
/**@def SOATAG_ANY()
*
* Filter tag matching any SOATAG_*() item.
......
......@@ -146,6 +146,8 @@ SOFIAPUBFUN int soa_is_remote_video_active(soa_session_t const *ss);
SOFIAPUBFUN int soa_is_remote_image_active(soa_session_t const *ss);
SOFIAPUBFUN int soa_is_remote_chat_active(soa_session_t const *ss);
SOFIAPUBFUN int soa_tag_filter(tagi_t const *f, tagi_t const *t);
SOFIA_END_DECLS
#endif
......@@ -53,6 +53,7 @@ struct context;
#include <sofia-sip/sdp.h>
#include <sofia-sip/su_log.h>
#include <sofia-sip/sip_tag.h>
extern su_log_t soa_log[];
......@@ -158,6 +159,33 @@ int test_api_errors(struct context *ctx)
END();
}
int test_soa_tags(struct context *ctx)
{
BEGIN();
su_home_t home[1] = { SU_HOME_INIT(home) };
tagi_t *t;
tagi_t const soafilter[] = {
{ TAG_FILTER(soa_tag_filter) },
{ TAG_NULL() }
};
t = tl_filtered_tlist(home, soafilter,
SIPTAG_FROM_STR("sip:my.domain"),
SOATAG_USER_SDP_STR("v=0"),
SOATAG_HOLD("*"),
TAG_END());
TEST_1(t);
TEST(t[0].t_tag, soatag_user_sdp_str);
TEST(t[1].t_tag, soatag_hold);
TEST_1(t[2].t_tag == NULL || t[2].t_tag == tag_null);
su_home_deinit(home);
END();
}
int test_init(struct context *ctx, char *argv[])
{
BEGIN();
......@@ -1291,6 +1319,7 @@ int main(int argc, char *argv[])
} while(0)
retval |= test_api_errors(ctx); SINGLE_FAILURE_CHECK();
retval |= test_soa_tags(ctx); SINGLE_FAILURE_CHECK();
retval |= test_init(ctx, argv + i); SINGLE_FAILURE_CHECK();
if (retval == 0) {
retval |= test_params(ctx); SINGLE_FAILURE_CHECK();
......
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