physfs_internal.h
changeset 828 ee871d51510d
parent 809 116b8fe30371
child 836 6514fba91816
--- a/physfs_internal.h	Thu Mar 15 07:33:14 2007 +0000
+++ b/physfs_internal.h	Thu Mar 15 08:16:23 2007 +0000
@@ -16,6 +16,8 @@
 
 #include "physfs.h"
 
+#include <stdlib.h>  /* make sure NULL is defined... */
+
 #ifdef HAVE_ASSERT_H
 #include <assert.h>
 #elif (!defined assert)
@@ -1264,6 +1266,8 @@
 #define GOTO_MACRO_MUTEX(e, m, g) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; }
 #define GOTO_IF_MACRO_MUTEX(c, e, m, g) if (c) { __PHYSFS_setError(e); __PHYSFS_platformReleaseMutex(m); goto g; }
 
+#define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )
+
 #ifdef __GNUC__
 #define LONGLONGLITERAL(x) x##LL
 #else
@@ -1283,6 +1287,39 @@
 )
 
 /*
+ * This is a strcasecmp() or stricmp() replacement that expects both strings
+ *  to be in UTF-8 encoding. It will do "case folding" to decide if the
+ *  Unicode codepoints in the strings match.
+ *
+ * It will report which string is "greater than" the other, but be aware that
+ *  this doesn't necessarily mean anything: 'a' may be "less than" 'b', but
+ *  a random Kanji codepoint has no meaningful alphabetically relationship to
+ *  a Greek Lambda, but being able to assign a reliable "value" makes sorting
+ *  algorithms possible, if not entirely sane. Most cases should treat the
+ *  return value as "equal" or "not equal".
+ */
+int __PHYSFS_utf8strcasecmp(const char *s1, const char *s2);
+
+/*
+ * This works like __PHYSFS_utf8strcasecmp(), but takes a character (NOT BYTE
+ *  COUNT) argument, like strcasencmp().
+ */
+int __PHYSFS_utf8strnicmp(const char *s1, const char *s2, PHYSFS_uint32 l);
+
+/*
+ * stricmp() that guarantees to only work with low ASCII. The C runtime
+ *  stricmp() might try to apply a locale/codepage/etc, which we don't want.
+ */
+int __PHYSFS_stricmpASCII(const char *s1, const char *s2);
+
+/*
+ * strnicmp() that guarantees to only work with low ASCII. The C runtime
+ *  strnicmp() might try to apply a locale/codepage/etc, which we don't want.
+ */
+int __PHYSFS_strnicmpASCII(const char *s1, const char *s2, PHYSFS_uint32 l);
+
+
+/*
  * The current allocator. Not valid before PHYSFS_init is called!
  */
 extern PHYSFS_Allocator __PHYSFS_AllocatorHooks;
@@ -1517,16 +1554,6 @@
 PHYSFS_uint64 __PHYSFS_platformGetThreadID(void);
 
 /*
- * This is a pass-through to whatever stricmp() is called on your platform.
- */
-int __PHYSFS_platformStricmp(const char *str1, const char *str2);
-
-/*
- * This is a pass-through to whatever strnicmp() is called on your platform.
- */
-int __PHYSFS_platformStrnicmp(const char *s1, const char *s2, PHYSFS_uint32 l);
-
-/*
  * Return non-zero if filename (in platform-dependent notation) exists.
  *  Symlinks should NOT be followed; at this stage, we do not care what the
  *  symlink points to. Please call __PHYSFS_SetError() with the details of