mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 05:18:31 +00:00
a little update to the sofia-sip library
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4939 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
fabed21ea8
commit
853936abd3
270 files changed
+37121
-11402
No files matched your search
@@ -35,10 +35,12 @@ INTERNAL_H = msg_internal.h test_class.h
|
||||
nobase_include_sofia_HEADERS = \
|
||||
$(GENERATED_H) $(PUBLIC_H)
|
||||
|
||||
BUILT_SOURCES = $(GENERATED_H) msg_mime_table.c test_table.c test_protos.h
|
||||
GENERATED_HC = $(GENERATED_H) msg_mime_table.c test_table.c test_protos.h
|
||||
|
||||
libmsg_la_SOURCES = $(INTERNAL_H) \
|
||||
msg.c msg_tag.c \
|
||||
BUILT_SOURCES = $(GENERATED_HC)
|
||||
|
||||
libmsg_la_SOURCES = msg_internal.h \
|
||||
msg.c msg_tag.c msg_inlined.c \
|
||||
msg_mime.c msg_mime_table.c \
|
||||
msg_header_copy.c msg_header_make.c \
|
||||
msg_parser.c msg_mclass.c msg_parser_util.c \
|
||||
@@ -46,11 +48,13 @@ libmsg_la_SOURCES = $(INTERNAL_H) \
|
||||
|
||||
COVERAGE_INPUT = $(libmsg_la_SOURCES) $(include_sofia_HEADERS)
|
||||
|
||||
libtest_msg_a_SOURCES = test_class.c test_table.c test_protos.h
|
||||
libtest_msg_a_SOURCES = test_class.c test_class.h \
|
||||
test_table.c test_inlined.c test_protos.h
|
||||
|
||||
LDADD = libtest_msg.a libmsg.la \
|
||||
../bnf/libbnf.la \
|
||||
../url/liburl.la \
|
||||
../ipt/libipt.la \
|
||||
../su/libsu.la
|
||||
|
||||
test_msg_LDFLAGS = -static
|
||||
@@ -77,41 +81,43 @@ TESTS = test_msg
|
||||
# ----------------------------------------------------------------------
|
||||
# Sofia specific rules
|
||||
|
||||
include ../sofia.am
|
||||
include $(top_srcdir)/rules/sofia.am
|
||||
|
||||
MSG_PARSER_AWK = $(srcdir)/msg_parser.awk
|
||||
|
||||
AWK_MSG_AWK = $(AWK) -f $(MSG_PARSER_AWK)
|
||||
|
||||
test_protos.h: test_protos.h.in $(MSG_PARSER_AWK)
|
||||
test_table.c: test_table.c.in $(MSG_PARSER_AWK)
|
||||
${GENERATED_HC}: ${MSG_PARSER_AWK}
|
||||
|
||||
sofia-sip/msg_mime_protos.h: sofia-sip/msg_mime_protos.h.in
|
||||
sofia-sip/msg_protos.h: sofia-sip/msg_protos.h.in
|
||||
msg_mime_table.c: msg_mime_table.c.in $(MSG_PARSER_AWK)
|
||||
TEST_CLASS_H = ${srcdir}/test_class.h
|
||||
|
||||
sofia-sip/msg_mime_protos.h sofia-sip/msg_protos.h: $(MSG_PARSER_AWK)
|
||||
test_protos.h test_table.c: ${TEST_CLASS_H}
|
||||
|
||||
test_protos.h: test_class.h
|
||||
test_protos.h: ${srcdir}/test_protos.h.in
|
||||
$(AWK_MSG_AWK) module=msg_test NO_MIDDLE=1 NO_LAST=1 \
|
||||
PR=$@ TEMPLATE=$(srcdir)/test_protos.h.in $<
|
||||
PR=$@ TEMPLATE=$(srcdir)/$@.in ${TEST_CLASS_H}
|
||||
|
||||
test_table.c: test_class.h
|
||||
test_table.c: ${srcdir}/test_table.c.in
|
||||
$(AWK_MSG_AWK) module=msg_test prefix=msg \
|
||||
MC_HASH_SIZE=127 multipart=msg_multipart \
|
||||
PT=$@ TEMPLATE=$(srcdir)/test_table.c.in $<
|
||||
PT=$@ TEMPLATE=$(srcdir)/$@.in ${TEST_CLASS_H}
|
||||
|
||||
sofia-sip/msg_protos.h: sofia-sip/msg_mime.h
|
||||
SS_MIME_H = ${srcdir}/sofia-sip/msg_mime.h
|
||||
|
||||
sofia-sip/msg_protos.h sofia-sip/msg_mime_protos.h: ${SS_MIME_H}
|
||||
msg_mime_table.c: ${SS_MIME_H}
|
||||
|
||||
sofia-sip/msg_protos.h: ${srcdir}/sofia-sip/msg_protos.h.in
|
||||
@-mkdir sofia-sip 2>/dev/null || true
|
||||
$(AWK_MSG_AWK) module=msg NO_FIRST=1 NO_MIDDLE=1 \
|
||||
PR=$@ TEMPLATE=$(srcdir)/sofia-sip/msg_protos.h.in $<
|
||||
PR=$@ TEMPLATE=$(srcdir)/$@.in ${SS_MIME_H}
|
||||
|
||||
sofia-sip/msg_mime_protos.h: sofia-sip/msg_mime.h
|
||||
sofia-sip/msg_mime_protos.h: ${srcdir}/sofia-sip/msg_mime_protos.h.in
|
||||
@-mkdir sofia-sip 2>/dev/null || true
|
||||
$(AWK_MSG_AWK) module=msg NO_FIRST=1 NO_LAST=1 \
|
||||
PR=$@ TEMPLATE=$(srcdir)/sofia-sip/msg_mime_protos.h.in $<
|
||||
PR=$@ TEMPLATE=$(srcdir)/$@.in ${SS_MIME_H}
|
||||
|
||||
msg_mime_table.c: sofia-sip/msg_mime.h
|
||||
msg_mime_table.c: ${srcdir}/msg_mime_table.c.in
|
||||
$(AWK_MSG_AWK) module=msg_multipart \
|
||||
tprefix=msg prefix=mp MC_HASH_SIZE=127 \
|
||||
PT=$@ TEMPLATE=$(srcdir)/msg_mime_table.c.in $<
|
||||
PT=$@ TEMPLATE=$(srcdir)/$@.in ${SS_MIME_H}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2007 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE msg_inlined.c
|
||||
*
|
||||
* Expand inlined msg functions non-inline.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sofia-sip/su_config.h>
|
||||
|
||||
#if SU_HAVE_INLINE
|
||||
extern int xyzzy;
|
||||
#else
|
||||
#undef SU_HAVE_INLINE
|
||||
#undef su_inline
|
||||
|
||||
#define SU_HAVE_INLINE 1
|
||||
#define su_inline
|
||||
|
||||
#include "sofia-sip/msg_header.h"
|
||||
#include "sofia-sip/msg_mime_protos.h"
|
||||
|
||||
#endif
|
||||
@@ -54,11 +54,13 @@ BEGIN {
|
||||
split("", NAMES);
|
||||
split("", Comments);
|
||||
split("", COMMENTS);
|
||||
split("", experimental);
|
||||
|
||||
# indexed by the C name of the header
|
||||
split("", Since); # Non-NUL if extra
|
||||
split("", Extra); # Offset in extra headers
|
||||
|
||||
without_experimental = 0;
|
||||
template="";
|
||||
template1="";
|
||||
template2="";
|
||||
@@ -78,13 +80,18 @@ function name_hash (name)
|
||||
{
|
||||
hash = 0;
|
||||
|
||||
len = split(name, chars, "");
|
||||
len = length(name);
|
||||
|
||||
for (i = 1; i <= len; i++) {
|
||||
c = tolower(chars[i]);
|
||||
c = tolower(substr(name, i, 1));
|
||||
hash = (38501 * (hash + index(ascii, c))) % 65536;
|
||||
}
|
||||
|
||||
if (hash == 0) {
|
||||
print "*** msg_parser.awk: calculating hash failed\n";
|
||||
exit(5);
|
||||
}
|
||||
|
||||
if (0) {
|
||||
# Test that hash algorithm above agrees with the C version
|
||||
pipe = ("../msg/msg_name_hash " name);
|
||||
@@ -155,11 +162,24 @@ function protos (name, comment, hash, since)
|
||||
Extra[name] = extra++;
|
||||
}
|
||||
|
||||
expr = (without_experimental > 0 && do_hash);
|
||||
if (expr) {
|
||||
printf "%s is experimental\n", Comment;
|
||||
}
|
||||
|
||||
experimental[N] = expr;
|
||||
|
||||
if (PR) {
|
||||
if (expr) {
|
||||
print "#if SU_HAVE_EXPERIMENTAL" > PR;
|
||||
}
|
||||
replace(template, hash, name, NAME, comment, Comment, COMMENT, since);
|
||||
replace(template1, hash, name, NAME, comment, Comment, COMMENT, since);
|
||||
replace(template2, hash, name, NAME, comment, Comment, COMMENT, since);
|
||||
replace(template3, hash, name, NAME, comment, Comment, COMMENT, since);
|
||||
if (expr) {
|
||||
print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,8 +230,19 @@ function process_footer (text)
|
||||
for (i = 1; i <= n; i++) {
|
||||
l = lines[i];
|
||||
if (match(tolower(l), /#(xxxxxx(x_xxxxxxx)?|hash)#/)) {
|
||||
expr = 0;
|
||||
|
||||
for (j = 1; j <= N; j++) {
|
||||
l = lines[i];
|
||||
if (expr != experimental[j]) {
|
||||
expr = experimental[j];
|
||||
if (expr) {
|
||||
print "#if SU_HAVE_EXPERIMENTAL" > PR;
|
||||
}
|
||||
else {
|
||||
print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
|
||||
}
|
||||
}
|
||||
gsub(/#hash#/, hashes[j], l);
|
||||
gsub(/#xxxxxxx_xxxxxxx#/, comments[j], l);
|
||||
gsub(/#Xxxxxxx_Xxxxxxx#/, Comments[j], l);
|
||||
@@ -220,6 +251,10 @@ function process_footer (text)
|
||||
gsub(/#XXXXXX#/, NAMES[j], l);
|
||||
print l > PR;
|
||||
}
|
||||
|
||||
if (expr) {
|
||||
print "#endif /* SU_HAVE_EXPERIMENTAL */" > PR;
|
||||
}
|
||||
} else {
|
||||
print l > PR;
|
||||
}
|
||||
@@ -333,10 +368,11 @@ function templates ()
|
||||
}
|
||||
|
||||
/^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); }
|
||||
HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ {
|
||||
without_experimental=total; }
|
||||
HLIST && /^[a-z]/ { protos($1, $0, 0, $2); headers[total++] = $1; }
|
||||
/^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0; }
|
||||
|
||||
|
||||
/^ *\/\* === Headers start here \*\// { in_header_list=1; templates(); }
|
||||
/^ *\/\* === Headers end here \*\// { in_header_list=0; }
|
||||
|
||||
@@ -366,10 +402,13 @@ in_header_list && /^ (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ {
|
||||
END {
|
||||
if (failed) { exit };
|
||||
|
||||
if (without_experimental == 0)
|
||||
without_experimental = total;
|
||||
|
||||
if (!NO_LAST) {
|
||||
protos("unknown", "/**< Unknown headers */", -3);
|
||||
protos("error", "/**< Erroneous headers */", -4);
|
||||
protos("separator", "/**< Separator line between headers and payload */", -5);
|
||||
protos("separator", "/**< Separator line between headers and body */", -5);
|
||||
protos("payload", "/**< Message payload */", -6);
|
||||
if (multipart)
|
||||
protos("multipart", "/**< Multipart payload */", -7);
|
||||
@@ -397,6 +436,10 @@ END {
|
||||
gsub(/#DATE#/, "@date Generated: " date, header);
|
||||
print header > PT;
|
||||
|
||||
print "" > PT;
|
||||
print "#define msg_offsetof(s, f) ((unsigned short)offsetof(s ,f))" > PT;
|
||||
print "" > PT;
|
||||
|
||||
if (MC_SHORT_SIZE) {
|
||||
printf("static msg_href_t const " \
|
||||
"%s_short_forms[MC_SHORT_SIZE] = \n{\n",
|
||||
@@ -408,7 +451,7 @@ END {
|
||||
n = shorts[i];
|
||||
flags = header_flags[n]; if (flags) flags = ",\n " flags;
|
||||
|
||||
printf(" { /* %s */ %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n",
|
||||
printf(" { /* %s */ %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
|
||||
substr(lower_case, i, 1),
|
||||
tprefix, n, module, prefix, n, flags, c) \
|
||||
> PT;
|
||||
@@ -426,7 +469,16 @@ END {
|
||||
if (extra > 0) {
|
||||
printf("struct %s {\n", extra_struct) > PT;
|
||||
printf(" %s base;\n", module_struct) > PT;
|
||||
printf(" msg_header_t *extra[%u];\n", extra) > PT;
|
||||
if (total - without_experimental < extra) {
|
||||
printf(" msg_header_t *extra[%u];\n",
|
||||
extra - (total - without_experimental)) > PT;
|
||||
}
|
||||
if (total - without_experimental > 0) {
|
||||
print "#if SU_HAVE_EXPERIMENTAL" > PT;
|
||||
printf(" msg_header_t *experimental[%u];\n",
|
||||
total - without_experimental) > PT;
|
||||
print "#endif" > PT;
|
||||
}
|
||||
printf("};\n\n") > PT;
|
||||
module_struct = "struct " extra_struct;
|
||||
}
|
||||
@@ -450,11 +502,11 @@ END {
|
||||
len = split("request status separator payload unknown error", unnamed, " ");
|
||||
|
||||
for (i = 1; i <= len; i++) {
|
||||
printf(" {{ %s_%s_class, offsetof(%s_t, %s_%s) }},\n",
|
||||
printf(" {{ %s_%s_class, msg_offsetof(%s_t, %s_%s) }},\n",
|
||||
tprefix, unnamed[i], module, prefix, unnamed[i]) > PT;
|
||||
}
|
||||
if (multipart) {
|
||||
printf(" {{ %s_class, offsetof(%s_t, %s_multipart) }},\n",
|
||||
printf(" {{ %s_class, msg_offsetof(%s_t, %s_multipart) }},\n",
|
||||
multipart, module, prefix) > PT;
|
||||
} else {
|
||||
printf(" {{ NULL, 0 }},\n") > PT;
|
||||
@@ -465,7 +517,13 @@ END {
|
||||
else {
|
||||
printf(" NULL, \n") > PT;
|
||||
}
|
||||
printf(" %d, %d, \n", MC_HASH_SIZE, total) > PT;
|
||||
printf(" %d, \n", MC_HASH_SIZE) > PT;
|
||||
printf ("#if SU_HAVE_EXPERIMENTAL\n" \
|
||||
" %d,\n" \
|
||||
"#else\n" \
|
||||
" %d,\n" \
|
||||
"#endif\n", \
|
||||
total, without_experimental) > PT;
|
||||
printf(" {\n") > PT;
|
||||
|
||||
for (i = 0; i < total; i++) {
|
||||
@@ -484,6 +542,7 @@ END {
|
||||
}
|
||||
|
||||
header_hash[j] = n;
|
||||
experimental2[j] = (i >= without_experimental);
|
||||
}
|
||||
|
||||
for (i = 0; i < MC_HASH_SIZE; i++) {
|
||||
@@ -492,14 +551,23 @@ END {
|
||||
n = header_hash[i];
|
||||
flags = header_flags[n]; if (flags) flags = ",\n " flags;
|
||||
|
||||
if (experimental2[i]) {
|
||||
print "#if SU_HAVE_EXPERIMENTAL" > PT;
|
||||
}
|
||||
|
||||
if (Since[n]) {
|
||||
printf(" { %s_%s_class, offsetof(struct %s, extra[%u])%s }%s\n",
|
||||
printf(" { %s_%s_class,\n" \
|
||||
" msg_offsetof(struct %s, extra[%u])%s }%s\n",
|
||||
tprefix, n, extra_struct, Extra[n], flags, c) > PT;
|
||||
}
|
||||
else {
|
||||
printf(" { %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n",
|
||||
printf(" { %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
|
||||
tprefix, n, module, prefix, n, flags, c) > PT;
|
||||
}
|
||||
|
||||
if (experimental2[i]) {
|
||||
printf("#else\n { NULL, 0 }%s\n#endif\n", c) > PT;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf(" { NULL, 0 }%s\n", c) > PT;
|
||||
|
||||
@@ -1974,6 +1974,8 @@ msg_t *msg_make(msg_mclass_t const *mc, int flags,
|
||||
return NULL;
|
||||
|
||||
msg = msg_create(mc, flags);
|
||||
if (msg == NULL)
|
||||
return NULL;
|
||||
|
||||
su_home_preload(msg_home(msg), 1, len + 1024);
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ SOFIA_BEGIN_DECLS
|
||||
* 1) Header class definitions.
|
||||
*/
|
||||
|
||||
#if HAVE_STRUCT_KEYWORDS
|
||||
/* Do not use keywords until you fix msg_kind_foo_critical thing! */ \
|
||||
#if HAVE_STRUCT_KEYWORDS && 0
|
||||
/** Define a header class */
|
||||
#define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd) \
|
||||
{{ \
|
||||
@@ -74,6 +75,7 @@ SOFIA_BEGIN_DECLS
|
||||
hc_kind: msg_kind_##kind, \
|
||||
}}
|
||||
#else
|
||||
/** Define a header class */
|
||||
#define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd) \
|
||||
{{ \
|
||||
pr##c##_hash, \
|
||||
@@ -198,9 +200,11 @@ SOFIAPUBFUN issize_t msg_parse_next_field(su_home_t *home, msg_header_t *prev,
|
||||
|
||||
/** Duplicate string. @HI */
|
||||
#define MSG_STRING_DUP(p, d, s) \
|
||||
(void)((s)?((p)=(char*)memccpy((void *)((d)=(char*)p),(s),0,SIZE_MAX))\
|
||||
(void)((s)?((p)=(char*)memccpy((void *)((d)=(char*)p),(s),0,INT_MAX))\
|
||||
:((d)=NULL))
|
||||
|
||||
/* Solaris has broken memccpy - it considers last argument as signed */
|
||||
|
||||
/** Calculate string size. @HI */
|
||||
#define MSG_STRING_SIZE(s) ((s) ? (strlen(s) + 1) : 0)
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of the Sofia-SIP package
|
||||
*
|
||||
* Copyright (C) 2007 Nokia Corporation.
|
||||
*
|
||||
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/**@CFILE test_inlined.c
|
||||
*
|
||||
* Expand inlined test functions non-inline.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sofia-sip/su_config.h>
|
||||
|
||||
#if SU_HAVE_INLINE
|
||||
extern int xyzzy;
|
||||
#else
|
||||
#undef SU_HAVE_INLINE
|
||||
#undef su_inline
|
||||
|
||||
#define SU_HAVE_INLINE 1
|
||||
#define su_inline
|
||||
|
||||
#include "test_protos.h"
|
||||
|
||||
#endif
|
||||
@@ -59,11 +59,6 @@ static int test_flags = 0;
|
||||
|
||||
char const name[] = "test_msg";
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-v]\n", name);
|
||||
}
|
||||
|
||||
static int msg_time_test(void)
|
||||
{
|
||||
char buf[32];
|
||||
@@ -138,7 +133,6 @@ static int msg_time_test(void)
|
||||
}
|
||||
|
||||
END();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int addr_test(void)
|
||||
@@ -1688,6 +1682,12 @@ static int random_test(void)
|
||||
END();
|
||||
}
|
||||
|
||||
void usage(int exitcode)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-v] [-a]\n", name);
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int retval = 0;
|
||||
@@ -1696,8 +1696,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 1; argv[i]; i++) {
|
||||
if (strcmp(argv[i], "-v") == 0)
|
||||
test_flags |= tst_verbatim;
|
||||
else if (strcmp(argv[i], "-a") == 0)
|
||||
test_flags |= tst_abort;
|
||||
else
|
||||
usage();
|
||||
usage(1);
|
||||
}
|
||||
|
||||
retval |= msg_time_test(); fflush(stdout);
|
||||
|
||||
Reference in new issue
Block a user