diff common/strhelp.c @ 131:9104b1b2e4da

Added string comparison functions.
author Sascha Wilde <wilde@intevation.de>
date Mon, 24 Mar 2014 13:32:12 +0100
parents c602d8cfa619
children c719d3fdbc15
line wrap: on
line diff
--- a/common/strhelp.c	Mon Mar 24 10:06:43 2014 +0100
+++ b/common/strhelp.c	Mon Mar 24 13:32:12 2014 +0100
@@ -1,4 +1,4 @@
-
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -102,3 +102,24 @@
       free (str_array);
     }
 }
+
+bool
+str_equal (char *s1, char *s2)
+{
+  size_t l1 = strlen(s1);
+  size_t l2 = strlen(s2);
+  if ((l1 == l2) &&
+      (strncmp(s1, s2, l1) == 0))
+    return true;
+  else
+    return false;
+}
+
+bool
+str_starts_with (char *s1, char *s2)
+{
+  if (strncmp(s1, s2, strlen(s2)) == 0)
+    return true;
+  else
+    return false;
+}

http://wald.intevation.org/projects/trustbridge/