util: add strip_hostname() to strip of leading '\\'.
authorGünther Deschner <gd@samba.org>
Thu, 8 May 2008 12:16:50 +0000 (14:16 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 26 May 2008 09:50:46 +0000 (11:50 +0200)
Guenther
(cherry picked from commit dbf96120d8b33e592bfd3e9df1777f1670e218be)

source/lib/util.c

index 5f95bcc558ff38462f8003e5e2b0e25bac96e433..0a32f0faa9356a07372e1c703f302955a1aedca8 100644 (file)
@@ -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;
+}