OpenMW
libs/platform/string.h
Go to the documentation of this file.
00001 // Wrapper for string.h on Mac and MinGW
00002 #ifndef _STRING_WRAPPER_H
00003 #define _STRING_WRAPPER_H
00004 
00005 #ifdef __APPLE__
00006 #include <Availability.h>
00007 #endif
00008 
00009 #include <string.h>
00010 #if (defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1070) || defined(__MINGW32__)
00011 // need our own implementation of strnlen
00012 #ifdef __MINGW32__
00013 static size_t strnlen(const char *s, size_t n)
00014 {
00015     const char *p = (const char *)memchr(s, 0, n);
00016     return(p ? p-s : n);
00017 }
00018 #elif (defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
00019 static size_t mw_strnlen(const char *s, size_t n)
00020 {
00021     if (strnlen != NULL) {
00022         return strnlen(s, n);
00023     }
00024     else {
00025         const char *p = (const char *)memchr(s, 0, n);
00026         return(p ? p-s : n);
00027     }
00028 }
00029 #define strnlen mw_strnlen
00030 #endif
00031 
00032 #endif
00033 
00034 #endif