Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
external
sofia-sip
Commits
3ee17105
Commit
3ee17105
authored
Sep 07, 2006
by
Pekka Pessi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msg module: using isize_t, usize_t, issize_t in API.
darcs-hash:20060906223842-65a35-b09275217b51097b4725b616a5beea20ec7cbca0.gz
parent
56c7fb39
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
583 additions
and
522 deletions
+583
-522
libsofia-sip-ua/msg/msg.c
libsofia-sip-ua/msg/msg.c
+2
-2
libsofia-sip-ua/msg/msg_auth.c
libsofia-sip-ua/msg/msg_auth.c
+10
-11
libsofia-sip-ua/msg/msg_basic.c
libsofia-sip-ua/msg/msg_basic.c
+28
-27
libsofia-sip-ua/msg/msg_date.c
libsofia-sip-ua/msg/msg_date.c
+10
-7
libsofia-sip-ua/msg/msg_generic.c
libsofia-sip-ua/msg/msg_generic.c
+45
-30
libsofia-sip-ua/msg/msg_header_copy.c
libsofia-sip-ua/msg/msg_header_copy.c
+10
-10
libsofia-sip-ua/msg/msg_header_make.c
libsofia-sip-ua/msg/msg_header_make.c
+20
-12
libsofia-sip-ua/msg/msg_internal.h
libsofia-sip-ua/msg/msg_internal.h
+29
-6
libsofia-sip-ua/msg/msg_mclass.c
libsofia-sip-ua/msg/msg_mclass.c
+2
-2
libsofia-sip-ua/msg/msg_mime.c
libsofia-sip-ua/msg/msg_mime.c
+79
-81
libsofia-sip-ua/msg/msg_parser.c
libsofia-sip-ua/msg/msg_parser.c
+95
-85
libsofia-sip-ua/msg/msg_parser_util.c
libsofia-sip-ua/msg/msg_parser_util.c
+83
-73
libsofia-sip-ua/msg/msg_tag.c
libsofia-sip-ua/msg/msg_tag.c
+21
-7
libsofia-sip-ua/msg/sofia-sip/msg.h
libsofia-sip-ua/msg/sofia-sip/msg.h
+2
-2
libsofia-sip-ua/msg/sofia-sip/msg_addr.h
libsofia-sip-ua/msg/sofia-sip/msg_addr.h
+8
-8
libsofia-sip-ua/msg/sofia-sip/msg_buffer.h
libsofia-sip-ua/msg/sofia-sip/msg_buffer.h
+6
-6
libsofia-sip-ua/msg/sofia-sip/msg_date.h
libsofia-sip-ua/msg/sofia-sip/msg_date.h
+9
-9
libsofia-sip-ua/msg/sofia-sip/msg_header.h
libsofia-sip-ua/msg/sofia-sip/msg_header.h
+21
-24
libsofia-sip-ua/msg/sofia-sip/msg_mclass.h
libsofia-sip-ua/msg/sofia-sip/msg_mclass.h
+4
-4
libsofia-sip-ua/msg/sofia-sip/msg_mclass_hash.h
libsofia-sip-ua/msg/sofia-sip/msg_mclass_hash.h
+2
-2
libsofia-sip-ua/msg/sofia-sip/msg_mime.h
libsofia-sip-ua/msg/sofia-sip/msg_mime.h
+5
-5
libsofia-sip-ua/msg/sofia-sip/msg_parser.h
libsofia-sip-ua/msg/sofia-sip/msg_parser.h
+66
-66
libsofia-sip-ua/msg/sofia-sip/msg_types.h
libsofia-sip-ua/msg/sofia-sip/msg_types.h
+10
-28
libsofia-sip-ua/msg/test_class.c
libsofia-sip-ua/msg/test_class.c
+14
-14
libsofia-sip-ua/msg/test_class.h
libsofia-sip-ua/msg/test_class.h
+2
-1
No files found.
libsofia-sip-ua/msg/msg.c
View file @
3ee17105
...
...
@@ -251,9 +251,9 @@ su_sockaddr_t *msg_addr(msg_t *msg)
int
msg_get_address
(
msg_t
*
msg
,
su_sockaddr_t
*
su
,
socklen_t
*
return_len
)
{
if
(
msg
&&
return_len
&&
*
return_len
>=
msg
->
m_addrinfo
.
ai_addrlen
)
{
*
return_len
=
msg
->
m_addrinfo
.
ai_addrlen
;
*
return_len
=
(
socklen_t
)
msg
->
m_addrinfo
.
ai_addrlen
;
if
(
su
)
memcpy
(
su
,
msg
->
m_addr
,
*
return_len
=
msg
->
m_addrinfo
.
ai_addrlen
);
memcpy
(
su
,
msg
->
m_addr
,
msg
->
m_addrinfo
.
ai_addrlen
);
return
0
;
}
if
(
msg
)
...
...
libsofia-sip-ua/msg/msg_auth.c
View file @
3ee17105
...
...
@@ -88,10 +88,10 @@ static int msg_auth_item_scan(char *start)
*/
/** Parse security headers. */
i
n
t
msg_auth_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
n
t
slen
)
i
ssize_
t
msg_auth_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
size_
t
slen
)
{
msg_auth_t
*
au
=
(
msg_auth_t
*
)
h
;
...
...
@@ -105,7 +105,7 @@ int msg_auth_d(su_home_t *home,
NULL
/* msg_auth_item_scan */
);
}
i
n
t
msg_auth_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
f
)
i
ssize_
t
msg_auth_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
f
)
{
msg_auth_t
const
*
au
=
(
msg_auth_t
*
)
h
;
int
compact
=
MSG_IS_COMPACT
(
f
);
...
...
@@ -131,22 +131,21 @@ int msg_auth_e(char b[], int bsiz, msg_header_t const *h, int f)
* @return
* Size of strings related to msg_auth_t object.
*/
i
n
t
msg_auth_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
)
i
size_
t
msg_auth_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
)
{
int
rv
=
offset
;
msg_auth_t
const
*
au
=
h
->
sh_auth
;
MSG_PARAMS_SIZE
(
rv
,
au
->
au_params
);
rv
+=
MSG_STRING_SIZE
(
au
->
au_scheme
);
MSG_PARAMS_SIZE
(
offset
,
au
->
au_params
);
offset
+=
MSG_STRING_SIZE
(
au
->
au_scheme
);
return
rv
;
return
offset
;
}
/**Duplicate one msg_auth_t object. */
char
*
msg_auth_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
i
size_
t
xtra
)
{
msg_auth_t
*
au
=
dst
->
sh_auth
;
msg_auth_t
const
*
o
=
src
->
sh_auth
;
...
...
libsofia-sip-ua/msg/msg_basic.c
View file @
3ee17105
...
...
@@ -38,13 +38,6 @@
#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <sofia-sip/su_alloc.h>
#include <sofia-sip/msg.h>
...
...
@@ -52,6 +45,14 @@
#include <sofia-sip/msg_parser.h>
#include <sofia-sip/msg_header.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#define msg_generic_update NULL
/* ====================================================================== */
...
...
@@ -72,32 +73,32 @@
* Type for erroneous headers.
*/
i
n
t
msg_error_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
);
i
size_
t
msg_error_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
);
char
*
msg_error_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
);
char
*
b
,
i
size_
t
xtra
);
msg_hclass_t
msg_error_class
[]
=
MSG_HEADER_CLASS
(
msg_
,
error
,
""
,
""
,
er_common
,
append
,
msg_error
,
msg_generic
);
i
n
t
msg_error_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
n
t
slen
)
i
ssize_
t
msg_error_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
size_
t
slen
)
{
return
0
;
}
i
n
t
msg_error_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_error_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
/* There is no way to encode an erroneous header */
return
0
;
}
i
n
t
msg_error_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
)
i
size_
t
msg_error_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
)
{
return
msg_default_dup_xtra
(
h
,
offset
);
}
char
*
msg_error_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
char
*
b
,
i
size_
t
xtra
)
{
return
msg_default_dup_one
(
dst
,
src
,
b
,
xtra
);
}
...
...
@@ -127,7 +128,7 @@ msg_hclass_t msg_unknown_class[] =
MSG_HEADER_CLASS
(
msg_
,
unknown
,
""
,
""
,
un_common
,
append
,
msg_unknown
,
msg_generic
);
i
n
t
msg_unknown_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
n
t
slen
)
i
ssize_
t
msg_unknown_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
size_
t
slen
)
{
msg_unknown_t
*
un
=
(
msg_unknown_t
*
)
h
;
...
...
@@ -142,7 +143,7 @@ int msg_unknown_d(su_home_t *home, msg_header_t *h, char *s, int slen)
return
0
;
}
i
n
t
msg_unknown_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_unknown_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
char
*
b0
=
b
,
*
end
=
b
+
bsiz
;
msg_unknown_t
*
un
=
(
msg_unknown_t
*
)
h
;
...
...
@@ -156,14 +157,14 @@ int msg_unknown_e(char b[], int bsiz, msg_header_t const *h, int flags)
return
b
-
b0
;
}
i
n
t
msg_unknown_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
)
i
size_
t
msg_unknown_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
)
{
msg_unknown_t
const
*
un
=
(
msg_unknown_t
*
)
h
;
return
offset
+
MSG_STRING_SIZE
(
un
->
un_name
)
+
MSG_STRING_SIZE
(
un
->
un_value
);
}
char
*
msg_unknown_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
char
*
b
,
i
size_
t
xtra
)
{
msg_unknown_t
*
un
=
(
msg_unknown_t
*
)
dst
;
msg_unknown_t
const
*
o
=
(
msg_unknown_t
*
)
src
;
...
...
@@ -208,7 +209,7 @@ MSG_HEADER_CLASS(msg_, payload, NULL, "", pl_common, append,
msg_payload
,
msg_generic
);
/** Create a MIME payload */
msg_payload_t
*
msg_payload_create
(
su_home_t
*
home
,
void
const
*
data
,
in
t
len
)
msg_payload_t
*
msg_payload_create
(
su_home_t
*
home
,
void
const
*
data
,
usize_
t
len
)
{
msg_header_t
*
h
=
msg_header_alloc
(
home
,
msg_payload_class
,
len
+
1
);
msg_payload_t
*
pl
=
h
->
sh_payload
;
...
...
@@ -230,7 +231,7 @@ msg_payload_t *msg_payload_create(su_home_t *home, void const *data, int len)
}
/** Parse payload. */
i
n
t
msg_payload_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
n
t
slen
)
i
ssize_
t
msg_payload_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
size_
t
slen
)
{
h
->
sh_payload
->
pl_len
=
slen
;
h
->
sh_payload
->
pl_data
=
s
;
...
...
@@ -241,9 +242,9 @@ int msg_payload_d(su_home_t *home, msg_header_t *h, char *s, int slen)
return
0
;
}
i
n
t
msg_payload_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_payload_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
in
t
len
=
h
->
sh_payload
->
pl_len
;
size_
t
len
=
h
->
sh_payload
->
pl_len
;
if
(
bsiz
>
0
)
{
memcpy
(
b
,
h
->
sh_payload
->
pl_data
,
bsiz
>
len
?
len
:
bsiz
);
...
...
@@ -253,7 +254,7 @@ int msg_payload_e(char b[], int bsiz, msg_header_t const *h, int flags)
return
len
;
}
i
n
t
msg_payload_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
)
i
size_
t
msg_payload_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
)
{
return
offset
+
h
->
sh_payload
->
pl_len
+
1
;
}
...
...
@@ -261,7 +262,7 @@ int msg_payload_dup_xtra(msg_header_t const *h, int offset)
char
*
msg_payload_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
i
size_
t
xtra
)
{
msg_payload_t
*
pl
=
dst
->
sh_payload
;
msg_payload_t
const
*
o
=
src
->
sh_payload
;
...
...
@@ -316,7 +317,7 @@ MSG_HEADER_CLASS(msg_, separator, NULL, "", sep_common, single,
#define CRLF_TEST(s) ((s[0]) == '\r' ? ((s[1]) == '\n') + 1 : (s[0])=='\n')
/** Parse a separator line. */
i
n
t
msg_separator_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
n
t
slen
)
i
ssize_
t
msg_separator_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
size_
t
slen
)
{
int
len
=
CRLF_TEST
(
s
);
...
...
@@ -330,14 +331,14 @@ int msg_separator_d(su_home_t *home, msg_header_t *h, char *s, int slen)
}
/** Encode a separator line. */
i
n
t
msg_separator_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_separator_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
in
t
n
=
strlen
(
h
->
sh_separator
->
sep_data
);
size_
t
n
=
strlen
(
h
->
sh_separator
->
sep_data
);
if
(
bsiz
>
n
)
strcpy
(
b
,
h
->
sh_separator
->
sep_data
);
return
n
;
return
(
issize_t
)
n
;
}
msg_separator_t
*
msg_separator_create
(
su_home_t
*
home
)
...
...
libsofia-sip-ua/msg/msg_date.c
View file @
3ee17105
...
...
@@ -175,7 +175,7 @@ int time_d(char const **ss,
* | "Sep" | "Oct" | "Nov" | "Dec"
* @endverbatim
*/
i
n
t
msg_date_d
(
char
const
**
ss
,
msg_time_t
*
date
)
i
ssize_
t
msg_date_d
(
char
const
**
ss
,
msg_time_t
*
date
)
{
char
const
*
s
=
*
ss
;
char
const
*
wkday
;
...
...
@@ -321,7 +321,7 @@ int msg_date_d(char const **ss, msg_time_t *date)
*
* @return The function msg_date_e() returns the size of the formatted date.
*/
i
n
t
msg_date_e
(
char
b
[],
i
n
t
bsiz
,
msg_time_t
http_date
)
i
ssize_
t
msg_date_e
(
char
b
[],
i
size_
t
bsiz
,
msg_time_t
http_date
)
{
msg_time_t
sec
,
min
,
hour
,
wkday
,
day
,
month
,
year
;
msg_time_t
days_per_month
,
leap_year
;
...
...
@@ -363,19 +363,22 @@ int msg_date_e(char b[], int bsiz, msg_time_t http_date)
*
* The function msg_delta_d() decodes a http-delta field.
*/
i
n
t
msg_delta_d
(
char
const
**
ss
,
msg_time_t
*
delta
)
i
ssize_
t
msg_delta_d
(
char
const
**
ss
,
msg_time_t
*
delta
)
{
if
(
!
is_digit
(
**
ss
))
char
const
*
s
=
*
ss
;
if
(
!
is_digit
(
*
s
))
return
-
1
;
*
delta
=
strtoul
(
*
ss
,
(
char
**
)
ss
,
10
);
skip_lws
(
ss
);
return
0
;
return
*
ss
-
s
;
}
/**Encode http-delta
*/
i
n
t
msg_delta_e
(
char
b
[],
i
n
t
bsiz
,
msg_time_t
delta
)
i
ssize_
t
msg_delta_e
(
char
b
[],
i
size_
t
bsiz
,
msg_time_t
delta
)
{
return
snprintf
(
b
,
bsiz
,
"%lu"
,
(
unsigned
long
)
delta
);
}
...
...
@@ -384,7 +387,7 @@ int msg_delta_e(char b[], int bsiz, msg_time_t delta)
*
* The function msg_date_delta_d() decodes a http-date or http-delta field.
*/
i
n
t
msg_date_delta_d
(
char
const
**
ss
,
i
ssize_
t
msg_date_delta_d
(
char
const
**
ss
,
msg_time_t
*
date
,
msg_time_t
*
delta
)
{
...
...
libsofia-sip-ua/msg/msg_generic.c
View file @
3ee17105
...
...
@@ -34,13 +34,6 @@
#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <sofia-sip/su_alloc.h>
#include "sofia-sip/msg.h"
...
...
@@ -48,6 +41,14 @@
#include "sofia-sip/msg_parser.h"
#include "sofia-sip/msg_header.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
/**
* Parse a generic header.
*
...
...
@@ -61,10 +62,10 @@
* @retval 0 when successful,
* @retval -1 upon an error.
*/
i
n
t
msg_generic_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
in
t
slen
)
i
ssize_
t
msg_generic_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
isize_
t
slen
)
{
h
->
sh_generic
->
g_string
=
s
;
return
0
;
...
...
@@ -76,19 +77,19 @@ int msg_generic_d(su_home_t *home,
* The function @c msg_generic_e encodes a generic header.
*
*/
i
n
t
msg_generic_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_generic_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
msg_generic_t
const
*
g
=
h
->
sh_generic
;
in
t
n
=
strlen
(
g
->
g_string
);
size_
t
n
=
strlen
(
g
->
g_string
);
if
(
bsiz
>
n
)
strcpy
(
b
,
g
->
g_string
);
return
n
;
return
(
issize_t
)
n
;
}
/** Calculate the size of strings associated with a @c msg_generic_t object. */
i
n
t
msg_generic_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
)
i
size_
t
msg_generic_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
)
{
msg_generic_t
const
*
g
=
h
->
sh_generic
;
return
offset
+
MSG_STRING_SIZE
(
g
->
g_string
);
...
...
@@ -98,7 +99,7 @@ int msg_generic_dup_xtra(msg_header_t const *h, int offset)
char
*
msg_generic_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
i
size_
t
xtra
)
{
char
*
end
=
b
+
xtra
;
MSG_STRING_DUP
(
b
,
dst
->
sh_generic
->
g_string
,
src
->
sh_generic
->
g_string
);
...
...
@@ -106,14 +107,15 @@ char *msg_generic_dup_one(msg_header_t *dst,
return
b
;
}
i
n
t
msg_numeric_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
in
t
slen
)
i
ssize_
t
msg_numeric_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
isize_
t
slen
)
{
int
retval
;
uint32_t
value
=
0
;
issize_t
retval
=
msg_uint32_d
(
&
s
,
&
value
);
retval
=
msg_uint32_d
(
&
s
,
(
uint32_t
*
)
&
h
->
sh_numeric
->
x_value
)
;
h
->
sh_numeric
->
x_value
=
value
;
if
(
*
s
)
return
-
1
;
...
...
@@ -121,20 +123,25 @@ int msg_numeric_d(su_home_t *home,
return
retval
;
}
i
n
t
msg_numeric_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_numeric_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
return
snprintf
(
b
,
bsiz
,
"%lu"
,
h
->
sh_numeric
->
x_value
);
uint32_t
value
=
h
->
sh_numeric
->
x_value
;
if
(
h
->
sh_numeric
->
x_value
>
0xffffffff
)
return
-
1
;
return
snprintf
(
b
,
bsiz
,
"%lu"
,
(
unsigned
long
)
value
);
}
/* ====================================================================== */
/* Comma-separated list */
i
n
t
msg_list_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
n
t
slen
)
i
ssize_
t
msg_list_d
(
su_home_t
*
home
,
msg_header_t
*
h
,
char
*
s
,
i
size_
t
slen
)
{
return
msg_commalist_d
(
home
,
&
s
,
&
h
->
sh_list
->
k_items
,
NULL
);
}
i
n
t
msg_list_e
(
char
b
[],
i
n
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
i
ssize_
t
msg_list_e
(
char
b
[],
i
size_
t
bsiz
,
msg_header_t
const
*
h
,
int
flags
)
{
int
compact
=
MSG_IS_COMPACT
(
flags
);
char
*
b0
=
b
,
*
end
=
b
+
bsiz
;
...
...
@@ -155,7 +162,7 @@ int msg_list_e(char b[], int bsiz, msg_header_t const *h, int flags)
* @return
* Size of strings related to msg_auth_t object.
*/
i
n
t
msg_list_dup_xtra
(
msg_header_t
const
*
h
,
i
n
t
offset
)
i
size_
t
msg_list_dup_xtra
(
msg_header_t
const
*
h
,
i
size_
t
offset
)
{
MSG_PARAMS_SIZE
(
offset
,
h
->
sh_list
->
k_items
);
return
offset
;
...
...
@@ -164,7 +171,7 @@ int msg_list_dup_xtra(msg_header_t const *h, int offset)
char
*
msg_list_dup_one
(
msg_header_t
*
dst
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
i
size_
t
xtra
)
{
char
*
end
=
b
+
xtra
;
msg_param_t
const
**
items
=
(
msg_param_t
const
**
)
&
dst
->
sh_list
->
k_items
;
...
...
@@ -176,7 +183,11 @@ char *msg_list_dup_one(msg_header_t *dst,
return
b
;
}
/** Append a list of constant items to a list. */
/** Append a list of constant items to a list.
*
* @retval 0 when successful
* @retval -1 upon an error
*/
int
msg_list_append_items
(
su_home_t
*
home
,
msg_list_t
*
k
,
msg_param_t
const
items
[])
...
...
@@ -197,7 +208,11 @@ int msg_list_append_items(su_home_t *home,
return
0
;
}
/** Replace a list of constant items */
/** Replace a list of constant items.
*
* @retval 0 when successful
* @retval -1 upon an error
*/
int
msg_list_replace_items
(
su_home_t
*
home
,
msg_list_t
*
k
,
msg_param_t
const
items
[])
{
...
...
libsofia-sip-ua/msg/msg_header_copy.c
View file @
3ee17105
...
...
@@ -52,7 +52,7 @@
/** Calculate size of a parameter vector */
static
inline
in
t
msg_params_copy_xtra
(
msg_param_t
const
pp
[],
in
t
offset
)
size_
t
msg_params_copy_xtra
(
msg_param_t
const
pp
[],
size_
t
offset
)
{
int
n
=
msg_params_count
(
pp
);
if
(
n
)
{
...
...
@@ -64,7 +64,7 @@ int msg_params_copy_xtra(msg_param_t const pp[], int offset)
/** Copy a vector of parameters */
static
inline
char
*
msg_params_copy
(
char
*
b
,
in
t
size
,
char
*
msg_params_copy
(
char
*
b
,
size_
t
size
,
msg_param_t
**
dst
,
msg_param_t
const
src
[])
{
...
...
@@ -99,7 +99,7 @@ static msg_header_t *msg_header_copy_one_as(su_home_t *home,
msg_header_t
const
*
src
)
{
msg_header_t
*
h
;
in
t
size
=
hc
->
hc_size
,
xtra
;
size_
t
size
=
hc
->
hc_size
,
xtra
;
msg_param_t
const
*
params
;
char
*
end
;
...
...
@@ -112,7 +112,7 @@ static msg_header_t *msg_header_copy_one_as(su_home_t *home,
xtra
=
0
;
}
if
(
!
(
h
=
msg_header_alloc
(
home
,
hc
,
xtra
)))
if
(
!
(
h
=
msg_header_alloc
(
home
,
hc
,
(
isize_t
)
xtra
)))
return
NULL
;
/* error */
memcpy
(
&
h
->
sh_data
,
&
src
->
sh_data
,
size
-
offsetof
(
msg_common_t
,
h_data
));
...
...
@@ -214,7 +214,7 @@ msg_header_t *msg_header_dup_one(su_home_t *home,
msg_header_t
const
*
src
)
{
msg_hclass_t
*
hc
;
in
t
size
,
xtra
;
size_
t
size
,
xtra
;
msg_header_t
*
h
;
char
*
end
;
...
...
@@ -270,11 +270,11 @@ msg_header_t *msg_header_dup_as(su_home_t *home, msg_hclass_t *hc,
assert
(
hc
);
for
(
prev
=
&
rv
;
src
;
src
=
src
->
sh_next
,
prev
=
&
h
->
sh_next
)
{
in
t
size
=
hc
->
hc_size
;
in
t
xtra
=
hc
->
hc_dxtra
(
src
,
size
)
-
size
;
size_
t
size
=
hc
->
hc_size
;
size_
t
xtra
=
hc
->
hc_dxtra
(
src
,
size
)
-
size
;
char
*
end
;
if
(
!
(
h
=
msg_header_alloc
(
home
,
hc
,
xtra
)))
if
(
!
(
h
=
msg_header_alloc
(
home
,
hc
,
(
isize_t
)
xtra
)))
break
;
/* error */
if
(
!
rv
)
...
...
@@ -322,7 +322,7 @@ msg_header_t *msg_header_dup(su_home_t *home, msg_header_t const *h)
}
/** Calculate extra size of a plain header. */
i
n
t
msg_default_dup_xtra
(
msg_header_t
const
*
header
,
i
n
t
offset
)
i
size_
t
msg_default_dup_xtra
(
msg_header_t
const
*
header
,
i
size_
t
offset
)
{
return
offset
;
}
...
...
@@ -344,7 +344,7 @@ int msg_default_dup_xtra(msg_header_t const *header, int offset)
char
*
msg_default_dup_one
(
msg_header_t
*
h
,
msg_header_t
const
*
src
,
char
*
b
,
i
n
t
xtra
)
i
size_
t
xtra
)
{
memcpy
(
&
h
->
sh_header_next
[
1
],
&
src
->
sh_header_next
[
1
],
...
...
libsofia-sip-ua/msg/msg_header_make.c
View file @
3ee17105
...
...
@@ -35,11 +35,20 @@
#include "config.h"
#include <sofia-sip/su_alloc.h>
#include "sofia-sip/msg.h"
#include "sofia-sip/bnf.h"
#include "sofia-sip/msg_parser.h"
#include "sofia-sip/msg_header.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include <errno.h>
#if defined(va_copy)
/* Xyzzy */
...
...
@@ -51,19 +60,12 @@
#include <assert.h>
#include <sofia-sip/su_alloc.h>
#include "sofia-sip/msg.h"
#include "sofia-sip/bnf.h"
#include "sofia-sip/msg_parser.h"
#include "sofia-sip/msg_header.h"
/** Make a header from a value string. */
msg_header_t
*
msg_header_make
(
su_home_t
*
home
,
msg_hclass_t
*
hc
,
char
const
*
s
)
{
in
t
xtra
;
size_
t
xtra
;
msg_header_t
*
h
;
int
normal
=
hc
->
hc_name
||
(
hc
->
hc_hash
!=
msg_payload_hash
&&
...
...
@@ -107,8 +109,8 @@ msg_header_t *msg_header_vformat(su_home_t *home,
{
msg_header_t
*
h
;
int
n
,
xtra
=
64
;
/* reasonable default */
int
n
;
size_t
xtra
=
64
;
/* reasonable default */
/* Quick path */
if
(
!
fmt
||
!
strchr
(
fmt
,
'%'
))
...
...
@@ -130,22 +132,28 @@ msg_header_t *msg_header_vformat(su_home_t *home,
n
=
vsnprintf
(
MSG_HEADER_DATA
(
h
),
xtra
,
fmt
,
aq
);
va_end
(
aq
);
if
(
n
>=
0
&&
n
<
xtra
)
if
(
n
>=
0
&&
(
size_t
)
n
<
xtra
)
break
;
/* Try again with more space */
su_free
(
home
,
h
);
if
(
xtra
>=
INT_MAX
)
return
NULL
;
if
(
n
>=
0
)
xtra
=
n
+
1
;
/* precisely what is needed */
else
xtra
*=
2
;
/* glibc 2.0 - twice the old size */
if
(
xtra
>
INT_MAX
)
xtra
=
INT_MAX
;
if
(
!
(
h
=
msg_header_alloc
(
home
,
hc
,
xtra
)))
return
NULL
;
}