summaryrefslogtreecommitdiff
path: root/src/im_str.cpp
diff options
context:
space:
mode:
authorscuri <scuri>2008-10-17 06:10:15 +0000
committerscuri <scuri>2008-10-17 06:10:15 +0000
commit5a422aba704c375a307a902bafe658342e209906 (patch)
tree5005011e086bb863d8fb587ad3319bbec59b2447 /src/im_str.cpp
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/im_str.cpp')
-rw-r--r--src/im_str.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/im_str.cpp b/src/im_str.cpp
new file mode 100644
index 0000000..f50dcf1
--- /dev/null
+++ b/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;
+}
+