]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
strutil.c: Add a case-insensitive version of StrUtil_EndsWith.
authorOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:21 +0000 (14:21 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:21 +0000 (14:21 -0700)
Common header file change; not applicable to open-vm-tools.

open-vm-tools/lib/include/strutil.h
open-vm-tools/lib/include/vm_product_versions.h
open-vm-tools/lib/misc/strutil.c

index e7585eef1c849c06724790016a7eed641ad841f9..8a4be3d1a31dd39f303ad7dd6f215c92c96b08d1 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -61,6 +61,7 @@ size_t StrUtil_GetLongestLineLength(const char *buf, size_t bufLength);
 Bool StrUtil_StartsWith(const char *s, const char *prefix);
 Bool StrUtil_CaselessStartsWith(const char *s, const char *prefix);
 Bool StrUtil_EndsWith(const char *s, const char *suffix);
+Bool StrUtil_CaselessEndsWith(const char *s, const char *suffix);
 Bool StrUtil_IsASCII(const char *s);
 
 Bool StrUtil_VDynBufPrintf(struct DynBuf *b, const char *fmt, va_list args);
index c66edea45c63f201b47b1c22ecdda060b143ecfa..3ba3f6ae2791e70a7bacc27ecff12ed4352ffadd 100644 (file)
 #define FLEX_CLIENT_VERSION_NUMBER "8.0.0"
 #define FLEX_CLIENT_VERSION "e.x.p"
 
-#define GANTRY_VERSION "e.x.p"
+#define GANTRY_VERSION "1.0.0"
 
 /*
  * In the *-main branches, FUSION_VERSION should always be set to "e.x.p".
index 27f230bd133e3cc144d1d81ea18294ae09ae9009..425d76bc0c69cff69076c056e90f0c4e032730a9 100644 (file)
@@ -914,8 +914,8 @@ StrUtil_EndsWith(const char *s,      // IN
    size_t slen;
    size_t suffixlen;
 
-   ASSERT(s);
-   ASSERT(suffix);
+   ASSERT(s != NULL);
+   ASSERT(suffix != NULL);
 
    slen = strlen(s);
    suffixlen = strlen(suffix);
@@ -928,6 +928,45 @@ StrUtil_EndsWith(const char *s,      // IN
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * StrUtil_CaselessEndsWith --
+ *
+ *      A case-insensitive version of StrUtil_EndsWith.
+ *
+ * Results:
+ *      TRUE  if string 'suffix' is found at the end of string 's'
+ *      FALSE otherwise.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+StrUtil_CaselessEndsWith(const char *s,      // IN
+                         const char *suffix) // IN
+{
+   size_t slen;
+   size_t suffixlen;
+
+   ASSERT(s != NULL);
+   ASSERT(suffix != NULL);
+   ASSERT(StrUtil_IsASCII(suffix));
+
+   slen = strlen(s);
+   suffixlen = strlen(suffix);
+
+   if (suffixlen > slen) {
+      return FALSE;
+   }
+
+   return Str_Strcasecmp(s + (slen - suffixlen), suffix) == 0;
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *