From f086c93150a5743a95a71779c4739c2b151aea2f Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Thu, 15 Jul 2010 13:32:11 +0000 Subject: Fixed #1104: Append ".local" to the system's hostname in IOS 4. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3238 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pj/sock_bsd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'pjlib/src') diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index 36761bce..2551e641 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -450,7 +450,24 @@ PJ_DEF(const pj_str_t*) pj_gethostname(void) hostname.ptr[0] = '\0'; hostname.slen = 0; } else { - hostname.slen = strlen(buf); + hostname.slen = strlen(buf); +#if defined(PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX) && \ + PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX!=0 + { + const pj_str_t suffix = {".local", 6}; + + if (hostname.slen < suffix.slen || + pj_ansi_strnicmp(hostname.ptr + hostname.slen - + suffix.slen, suffix.ptr, suffix.slen)) + { + if (hostname.slen + suffix.slen + 1 < sizeof(buf)) + pj_strcat(&hostname, &suffix); + else + hostname.slen = 0; + hostname.ptr[hostname.slen] = '\0'; + } + } +#endif } } return &hostname; -- cgit v1.2.3