summaryrefslogtreecommitdiff
path: root/im/src/im_str.cpp
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-04 11:56:41 -0800
committerPixel <pixel@nobis-crew.org>2009-11-04 11:59:33 -0800
commitd577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch)
tree590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /im/src/im_str.cpp
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'im/src/im_str.cpp')
-rwxr-xr-xim/src/im_str.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/im/src/im_str.cpp b/im/src/im_str.cpp
new file mode 100755
index 0000000..f50dcf1
--- /dev/null
+++ b/im/src/im_str.cpp
@@ -0,0 +1,67 @@
+/** \file
+ * \brief String Utilities
+ *
+ * See Copyright Notice in im_lib.h
+ * $Id: im_str.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $
+ */
+
+
+#include <stdlib.h>
+#include <memory.h>
+#include <assert.h>
+
+#include "im_util.h"
+
+int imStrEqual(const char* str1, const char* str2)
+{
+ assert(str1);
+ assert(str2);
+
+ /* While both strings are equal and not 0 */
+ while (*str1 == *str2 && *str1)
+ {
+ str1++;
+ str2++;
+ }
+
+ /* Is last char not equal ? */
+ if (*str1 != *str2)
+ return 0;
+
+ return 1;
+}
+
+int imStrNLen(const char* str, int max_len)
+{
+ assert(str);
+
+ const char* start_str = str;
+
+ while(max_len && *str)
+ {
+ max_len--;
+ str++;
+ }
+
+ return str - start_str;
+}
+
+int imStrCheck(const void* data, int count)
+{
+ const char* str = (char*)data;
+
+ if (str[count-1] == 0)
+ return 1;
+
+ while(count && *str)
+ {
+ count--;
+ str++;
+ }
+
+ if (count > 0)
+ return 1;
+
+ return 0;
+}
+