summaryrefslogtreecommitdiff
path: root/ccc/stringutil.c
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-14 16:46:27 +0200
committerPatrick Simianer <p@simianer.de>2014-06-14 16:46:27 +0200
commit26c490f404731d053a6205719b6246502c07b449 (patch)
tree3aa721098f1251dfbf2249ecd2736434c13b1d48 /ccc/stringutil.c
init
Diffstat (limited to 'ccc/stringutil.c')
-rw-r--r--ccc/stringutil.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ccc/stringutil.c b/ccc/stringutil.c
new file mode 100644
index 0000000..aab4f03
--- /dev/null
+++ b/ccc/stringutil.c
@@ -0,0 +1,22 @@
+#include "stringutil.h"
+
+
+char*
+strend(char* s)
+{
+ if (strlen(s) == 0) return '\0';
+ while(*s != '\0')
+ ++s;
+ return --s;
+}
+
+bool
+endswith(char* s, char* suff)
+{
+ if (strlen(s) < strlen(suff)) return false;
+ char* a = strend(s)-(strlen(suff)-1);
+ if (!a) return false;
+ if (!strcmp(a, suff)) return true;
+ return false;
+}
+