summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2010-07-15 13:32:11 +0000
committerLiong Sauw Ming <ming@teluu.com>2010-07-15 13:32:11 +0000
commitf086c93150a5743a95a71779c4739c2b151aea2f (patch)
tree0680fbdff425adc717ab7d72863049210610224c
parent4a4a96e9bd530e5f12dd10d85dcd9944ca3a1da6 (diff)
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
-rw-r--r--pjlib/include/pj/compat/os_auto.h.in9
-rw-r--r--pjlib/src/pj/sock_bsd.c19
2 files changed, 27 insertions, 1 deletions
diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in
index 2b414650..35ccf0c3 100644
--- a/pjlib/include/pj/compat/os_auto.h.in
+++ b/pjlib/include/pj/compat/os_auto.h.in
@@ -169,6 +169,15 @@
/* The type of atomic variable value: */
#undef PJ_ATOMIC_VALUE_TYPE
+/* Append ".local" suffix to the system's hostname? */
+#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
+# include "TargetConditionals.h"
+# if defined(__IPHONE_4_0) && \
+ __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0
+# define PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX 1
+# endif
+#endif
+
/* If 1, use Read/Write mutex emulation for platforms that don't support it */
#undef PJ_EMULATE_RWMUTEX
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;