Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
sofia-sip
Commits
c493b26b
Commit
c493b26b
authored
Mar 15, 2006
by
Pekka Pessi
Browse files
Added host_has_domain_invalid().
darcs-hash:20060315150405-65a35-76d861b0b9b510221605394f77dccdcb251e907f.gz
parent
e4eba7f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
libsofia-sip-ua/bnf/bnf.c
libsofia-sip-ua/bnf/bnf.c
+23
-3
libsofia-sip-ua/bnf/sofia-sip/hostdomain.h
libsofia-sip-ua/bnf/sofia-sip/hostdomain.h
+1
-0
libsofia-sip-ua/bnf/torture_bnf.c
libsofia-sip-ua/bnf/torture_bnf.c
+18
-0
No files found.
libsofia-sip-ua/bnf/bnf.c
View file @
c493b26b
...
...
@@ -446,7 +446,7 @@ int span_ip6_reference(char const *host)
{
/* IPv6reference = "[" IPv6address "]" */
if
(
host
[
0
]
==
'['
)
{
if
(
host
&&
host
[
0
]
==
'['
)
{
int
n
=
span_ip6_address
(
host
+
1
);
if
(
n
>
0
&&
host
[
n
+
1
]
==
']'
)
return
n
+
2
;
...
...
@@ -710,8 +710,8 @@ int host_is_ip_address(char const *string)
*/
int
host_is_domain
(
char
*
string
)
{
int
n
=
span_domain
(
string
);
return
n
>
0
&&
string
[
n
]
==
'\0'
;
int
n
=
string
?
span_domain
(
string
)
:
0
;
return
string
&&
n
>
0
&&
string
[
n
]
==
'\0'
;
}
/** Return true if @a string is valid a host name.
...
...
@@ -723,3 +723,23 @@ int host_is_valid(char const *string)
int
n
=
span_host
(
string
);
return
n
>
0
&&
string
[
n
]
==
'\0'
;
}
/** Return true if @a string has domain name in "invalid." domain.
*
*/
int
host_has_domain_invalid
(
char
const
*
string
)
{
int
n
=
span_domain
(
string
);
if
(
n
>=
7
&&
string
[
n
]
==
'\0'
)
{
static
char
const
invalid
[]
=
".invalid"
;
if
(
string
[
n
-
1
]
==
'.'
)
/* .invalid. perhaps? */
n
--
;
if
(
n
==
7
/* strlen("invalid") */
)
return
strncasecmp
(
string
,
invalid
+
1
,
7
)
==
0
;
else
return
strncasecmp
(
string
+
n
-
8
,
invalid
,
8
)
==
0
;
}
return
0
;
}
libsofia-sip-ua/bnf/sofia-sip/hostdomain.h
View file @
c493b26b
...
...
@@ -47,6 +47,7 @@ SOFIAPUBFUN int host_ip6_reference(char const *string);
SOFIAPUBFUN
int
host_is_ip_address
(
char
const
*
string
);
SOFIAPUBFUN
int
host_is_domain
(
char
*
string
);
SOFIAPUBFUN
int
host_is_valid
(
char
const
*
string
);
SOFIAPUBFUN
int
host_has_domain_invalid
(
char
const
*
string
);
SOFIA_END_DECLS
...
...
libsofia-sip-ua/bnf/torture_bnf.c
View file @
c493b26b
...
...
@@ -240,10 +240,20 @@ int ip_test(void)
int n = sizeof(input) - sizeof(output); \
TEST(scanner(&s), n); TEST_S(s, output); TEST_S(s0, canonic); } while(0)
#include <sofia-sip/hostdomain.h>
int
host_test
(
void
)
{
BEGIN
();
TEST
(
host_is_ip4_address
(
NULL
),
0
);
TEST
(
host_is_ip6_address
(
NULL
),
0
);
TEST
(
host_ip6_reference
(
NULL
),
0
);
TEST
(
host_is_ip_address
(
NULL
),
0
);
TEST
(
host_is_domain
(
NULL
),
0
);
TEST
(
host_is_valid
(
NULL
),
0
);
TEST
(
host_has_domain_invalid
(
NULL
),
0
);
TEST
(
span_host
(
"rama"
),
4
);
TEST
(
span_host
(
"ra-ma.1-2.3-4.a4-9."
),
19
);
TEST
(
span_host
(
"a.1.b"
),
5
);
...
...
@@ -279,6 +289,14 @@ int host_test(void)
TEST
(
span_domain
(
"a.b.-"
),
0
);
TEST
(
span_domain
(
"a.b-"
),
0
);
TEST
(
host_has_domain_invalid
(
"invalid"
),
1
);
TEST
(
host_has_domain_invalid
(
"invalid."
),
1
);
TEST
(
host_has_domain_invalid
(
"1.invalid"
),
1
);
TEST
(
host_has_domain_invalid
(
"1.invalid."
),
1
);
TEST
(
host_has_domain_invalid
(
"1invalid"
),
0
);
TEST
(
host_has_domain_invalid
(
"valid."
),
0
);
TEST
(
host_has_domain_invalid
(
"1-.invalid."
),
0
);
END
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment