From: Günther Deschner Date: Thu, 8 May 2008 12:16:50 +0000 (+0200) Subject: util: add strip_hostname() to strip of leading '\\'. X-Git-Tag: samba-4.0.0alpha6~801^2~1444 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e556dfbb932759f7159735cc7559bd6e89ec7d12;p=thirdparty%2Fsamba.git util: add strip_hostname() to strip of leading '\\'. Guenther (This used to be commit dbf96120d8b33e592bfd3e9df1777f1670e218be) --- diff --git a/source3/lib/util.c b/source3/lib/util.c index a137d7cd8b7..a6b436cc6a9 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3453,3 +3453,22 @@ bool is_valid_policy_hnd(const POLICY_HND *hnd) return (memcmp(&tmp, hnd, sizeof(tmp)) != 0); } +/**************************************************************** + strip off leading '\\' from a hostname +****************************************************************/ + +const char *strip_hostname(const char *s) +{ + if (!s) { + return NULL; + } + + if (strlen_m(s) < 3) { + return s; + } + + if (s[0] == '\\') s++; + if (s[0] == '\\') s++; + + return s; +}