From e556dfbb932759f7159735cc7559bd6e89ec7d12 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 8 May 2008 14:16:50 +0200 Subject: util: add strip_hostname() to strip of leading '\\'. Guenther (This used to be commit dbf96120d8b33e592bfd3e9df1777f1670e218be) --- source3/lib/util.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source3/lib/util.c b/source3/lib/util.c index a137d7cd8b..a6b436cc6a 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; +} -- cgit