/*  _str.h internal version of "C" string.h functions

    Definitions for string functions.

*/

/*
 *      C/C++ Run Time Library - Version 12.0
 *
 *      Copyright (c) 1987, 2005 by Borland Software Corporation
 *      All Rights Reserved.
 *
 */

/* $Revision: 9.15.2.2 $ */

#ifndef __STRING_H
#define __STRING_H
#define _INC_STRING  /* MSC Guard name */

#include <_stddef.h>

#if !defined(__STDC__) && defined(__USELOCALES__)
#if !defined(__LOCALE_H)

#ifdef _USE_OLDER_RW_STL
# include <oldstl/locale.h>
#else
# include <locale.h>
#endif

#endif
#endif  /* !__STDC__ && __USELOCALES__ */

#if !defined(RC_INVOKED)

#ifndef __MEM_H
#include <mem.h>  /* All mem... functions have now been moved to MEM.H */
#endif

#if defined(__STDC__)
#pragma warn -nak
#endif

#endif  /* !RC_INVOKED */

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
namespace std {
#endif /* __cplusplus */

#define wcscmpi(s1,s2)      _wcsicmp(s1,s2)
#define _wcscmpi(s1,s2)     _wcsicmp(s1,s2)
#define wcsncmpi(s1,s2,n)   _wcsnicmp(s1,s2,n)
#define _wcsncmpi(s1,s2,n)  _wcsnicmp(s1,s2,n)

_SIZE_T          _RTLENTRY  _EXPFUNC wcslen(const wchar_t *__s);
wchar_t *       _RTLENTRY  _EXPFUNC wcscpy(wchar_t *__dst, const wchar_t *__src);
wchar_t *       _RTLENTRY  _EXPFUNC wcscat(wchar_t *__dest, const wchar_t *__src);
wchar_t *       _RTLENTRY  _EXPFUNC wcschr(const wchar_t *__s, int __c);
int             _RTLENTRY  _EXPFUNC wcscmp(const wchar_t *__s1, const wchar_t *__s2);
int             _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
_SIZE_T          _RTLENTRY  _EXPFUNC wcscspn(const wchar_t *__s1, const wchar_t *__s2);
wchar_t *       _RTLENTRY  _EXPFUNC _wcsdup(const wchar_t *__s);
int             _RTLENTRY  _EXPFUNC wcsncmp(const wchar_t *__s1, const wchar_t *__s2, _SIZE_T __maxlen);
wchar_t *       _RTLENTRY  _EXPFUNC wcsncpy(wchar_t *__dest, const wchar_t *__src, _SIZE_T __maxlen);
wchar_t *       _RTLENTRY  _EXPFUNC _wcsnset(wchar_t *__s, wchar_t __ch, _SIZE_T __n);
wchar_t *       _RTLENTRY  _EXPFUNC wcspbrk(const wchar_t *__s1, const wchar_t *__s2);
wchar_t *       _RTLENTRY  _EXPFUNC wcsrchr(const wchar_t *__s, wchar_t __c);
wchar_t *       _RTLENTRY  _EXPFUNC _wcsrev(wchar_t *__s);
wchar_t *       _RTLENTRY  _EXPFUNC _wcsset(wchar_t*__s, wchar_t __ch);
_SIZE_T          _RTLENTRY  _EXPFUNC wcsspn(const wchar_t *__s1, const wchar_t *__s2);
wchar_t *       _RTLENTRY  _EXPFUNC wcsstr(const wchar_t *__s1, const wchar_t *__s2);
wchar_t *       _RTLENTRY  _EXPFUNC wcstok(wchar_t *__s1, const wchar_t *__s2);
wchar_t *       _RTLENTRY  _EXPFUNC wcsncat(wchar_t *__dest, const wchar_t *__src, _SIZE_T __maxlen);
wchar_t *       _RTLENTRY  _EXPFUNC wcspcpy(wchar_t *__dest, const wchar_t *__src);
wchar_t *       _RTLENTRY  _EXPFUNC _wcspcpy(wchar_t *__dest, const wchar_t *__src);
int             _RTLENTRY  _EXPFUNC _wcsicmp(const wchar_t *__s1, const wchar_t *__s2);
int             _RTLENTRY  _EXPFUNC _wcsnicmp(const wchar_t *__s1, const wchar_t *__s2, _SIZE_T __maxlen);
wchar_t *       _RTLENTRYF _EXPFUNC _wcslwr(wchar_t *__s);
wchar_t *       _RTLENTRYF _EXPFUNC _wcsupr(wchar_t *__s);
wchar_t *       _RTLENTRYF _EXPFUNC _lwcslwr(wchar_t *__s);
wchar_t *       _RTLENTRYF _EXPFUNC _lwcsupr(wchar_t *__s);
wchar_t *       _RTLENTRY  _EXPFUNC __wcserror(const wchar_t *__s);
wchar_t *       _RTLENTRY  _EXPFUNC _wcserror(int __errnum);

char _FAR * _RTLENTRYF _EXPFUNC strcat(char _FAR *__dest, const char _FAR *__src);
int         _RTLENTRYF _EXPFUNC strcmp(const char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRYF _EXPFUNC strcpy(char _FAR *__dest, const char _FAR *__src);
_SIZE_T      _RTLENTRY  _EXPFUNC strcspn(const char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRY  _EXPFUNC strerror(int __errnum);
_SIZE_T      _RTLENTRYF _EXPFUNC strlen(const char _FAR *__s);
char _FAR * _RTLENTRYF _EXPFUNC strncat(char _FAR *__dest, const char _FAR *__src,
                                        _SIZE_T __maxlen);
int         _RTLENTRYF _EXPFUNC strncmp(const char _FAR *__s1, const char _FAR *__s2,
                                        _SIZE_T __maxlen);
char _FAR * _RTLENTRYF _EXPFUNC strncpy(char _FAR *__dest, const char _FAR *__src,
                                        _SIZE_T __maxlen);
_SIZE_T      _RTLENTRY  _EXPFUNC strspn(const char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRYF _EXPFUNC strtok(char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRY  _EXPFUNC _strerror(const char _FAR *__s);

#if !defined(__STDC__)
/* compatibility with other compilers */
#define strcmpi(s1,s2)      stricmp(s1,s2)
#define strncmpi(s1,s2,n)   strnicmp(s1,s2,n)

char _FAR * _RTLENTRYF _EXPFUNC   _lstrlwr(char _FAR *__s);
char _FAR * _RTLENTRYF _EXPFUNC   _lstrupr(char _FAR *__s);
char _FAR * _RTLENTRYF _EXPFUNC32 stpcpy(char _FAR *__dest, const char _FAR *__src);
char _FAR * _RTLENTRY  _EXPFUNC32 _stpcpy(char _FAR *__dest, const char _FAR *__src);
char _FAR * _RTLENTRY  _EXPFUNC   strdup(const char _FAR *__s);
int         _RTLENTRYF _EXPFUNC   stricmp(const char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRYF _EXPFUNC   strlwr(char _FAR *__s);
int         _RTLENTRYF _EXPFUNC   strnicmp(const char _FAR *__s1, const char _FAR *__s2,
                                           _SIZE_T __maxlen);
char _FAR * _RTLENTRY  _EXPFUNC   strnset(char _FAR *__s, int __ch, _SIZE_T __n);
char _FAR * _RTLENTRY  _EXPFUNC   strrev(char _FAR *__s);
char _FAR * _RTLENTRY  _EXPFUNC   strset(char _FAR *__s, int __ch);
char _FAR * _RTLENTRYF _EXPFUNC   strupr(char _FAR *__s);
#endif  /* !__STDC__ */

#if defined(__cplusplus)
extern "C++"
{
          char _FAR * _RTLENTRYF _EXPFUNC   strchr(char _FAR * __s, int __c);
    const char _FAR * _RTLENTRYF _EXPFUNC   strchr(const char _FAR * __s, int __c);
          char _FAR * _RTLENTRYF _EXPFUNC   strrchr(char _FAR *__s, int __c);
    const char _FAR * _RTLENTRYF _EXPFUNC   strrchr(const char _FAR *__s, int __c);
          char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(char _FAR *__s1, const char _FAR *__s2);
    const char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(const char _FAR *__s1, const char _FAR *__s2);
          char _FAR * _RTLENTRY  _EXPFUNC   strstr(char _FAR *__s1, const char _FAR *__s2);
    const char _FAR * _RTLENTRY  _EXPFUNC   strstr(const char _FAR *__s1, const char _FAR *__s2);
}
#else
          char _FAR * _RTLENTRYF _EXPFUNC   strchr(const char _FAR * __s, int __c);
          char _FAR * _RTLENTRYF _EXPFUNC   strrchr(const char _FAR *__s, int __c);
          char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(const char _FAR *__s1, const char _FAR *__s2);
          char _FAR * _RTLENTRY  _EXPFUNC   strstr(const char _FAR *__s1, const char _FAR *__s2);
#endif

/* Intrinsic functions */

/* Intrinsics must be prototyped outside of any namespace */
#ifdef __cplusplus
} /* std */
#endif /* __cplusplus */

char _FAR * _RTLENTRY             __stpcpy__(char _FAR *__dest, const char _FAR *__src);
char _FAR * _RTLENTRYF _EXPFUNC16 __strcat__(char _FAR *__dest, const char _FAR *__src);
char _FAR * _RTLENTRY  _EXPFUNC16 __strchr__(const char _FAR *__s, int __c);
int         _RTLENTRYF _EXPFUNC16 __strcmp__(const char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRYF _EXPFUNC16 __strcpy__(char _FAR *__dest, const char _FAR *__src);
int         _RTLENTRYF _EXPFUNC16 _rtl_strcmp(const char _FAR *__s1, const char _FAR *__s2);
char _FAR * _RTLENTRYF _EXPFUNC16 _rtl_strcpy(char _FAR *__dest, const char _FAR *__src);
_SIZE_T     _RTLENTRYF _EXPFUNC16 __strlen__(const char _FAR *__s);
char _FAR * _RTLENTRY  _EXPFUNC16 __strncat__(char _FAR *__dest, const char _FAR *__src,
                                              _SIZE_T __maxlen);
int         _RTLENTRY  _EXPFUNC16 __strncmp__(const char _FAR *__s1, const char _FAR *__s2,
                                              _SIZE_T __maxlen);
char _FAR * _RTLENTRYF _EXPFUNC16 __strncpy__(char _FAR *__dest, const char _FAR *__src,
                                              _SIZE_T __maxlen);
char _FAR * _RTLENTRY  _EXPFUNC16 __strnset__(char _FAR *__s, int __ch, _SIZE_T __n);
char _FAR * _RTLENTRYF _EXPFUNC16 __strrchr__(const char _FAR *__s, int __c);
char _FAR * _RTLENTRY  _EXPFUNC16 __strset__(char _FAR *__s, int __ch);

/* Now that the intrinsics are finished, turn the namespace back on */
#ifdef __cplusplus
namespace std {
#endif /* __cplusplus */

/*
    The way we do intrinsics is a little funny.  The compiler automagically
    defines a macro that maps strcpy to __strcpy__.  That's ok unless someone
    tries std::strcpy.  Same applies to other intrinsics.  So we 'deal' with it
    by providing inline versions of std::strcpy that live in std:: and which
    delegate to the real intrinsic ::__strcpy__.
*/
#ifdef __cplusplus
#ifdef strcpy
#undef strcpy
inline char _FAR * _RTLENTRYF strcpy(char _FAR *__dest, const char _FAR *__src)
{
    return __strcpy__(__dest, __src);
}
#endif

#ifdef strcmp
#undef strcmp
inline int _RTLENTRYF strcmp(const char _FAR *__s1, const char _FAR *__s2)
{
    return __strcmp__(__s1, __s2);
}
#endif

#ifdef strcat
#undef strcat
inline char _FAR * _RTLENTRYF strcat(char _FAR *__dest, const char _FAR *__src)
{
    return __strcat__(__dest, __src);
}
#endif

#ifdef strchr
#undef strchr
inline char _FAR * _RTLENTRY strchr(const char _FAR *__s, int __c)
{
    return __strchr__(__s, __c);
}
#endif

#ifdef strcpy
#undef strcpy
inline char _FAR * _RTLENTRYF strcpy(char _FAR *__dest, const char _FAR *__src)
{
    return __strcpy__(__dest, __src);
}
#endif

#ifdef strlen
#undef strlen
inline _SIZE_T _RTLENTRYF strlen(const char _FAR *__s)
{
    return __strlen__(__s);
}
#endif

#ifdef strncat
#undef strncat
inline char _FAR * _RTLENTRY strncat(char _FAR *__dest, const char _FAR *__src,_SIZE_T __maxlen)
{
    return __strncat__(__dest, __src, __maxlen);
}
#endif

#ifdef strncmp
#undef strncmp
inline int _RTLENTRY strncmp(const char _FAR *__s1, const char _FAR *__s2,_SIZE_T __maxlen)
{
    return __strncmp__(__s2, __s2, __maxlen);
}
#endif

#ifdef strncpy
#undef strncpy
inline char _FAR * _RTLENTRY strncpy(char _FAR *__dest, const char _FAR *__src,_SIZE_T __maxlen)
{
    return __strncpy__(__dest, __src, __maxlen);
}
#endif

#ifdef strnset
#undef strnset
inline char _FAR * _RTLENTRY strnset(char _FAR *__s, int __ch, _SIZE_T __n)
{
    return __strnset__(__s, __ch, __n);
}
#endif

#ifdef strrchr
#undef strrchr
inline char _FAR * _RTLENTRYF strrchr(const char _FAR *__s, int __c)
{
    return __strrchr__(__s, __c);
}
#endif

#ifdef strset
#undef strset
inline char _FAR * _RTLENTRY strset(char _FAR *__s, int __ch)
{
    return __strset__(__s, __ch);
}
#endif

#endif /* __cplusplus */

#if defined(__MSC) && !defined(__MFC_COMPAT__)
#define _strnicmp(s1,s2,s3) strnicmp(s1,s2,s3)
#define _stricmp(s1,s2)     stricmp(s1,s2)
#define _strdup(s1)         strdup(s1)
#define _strupr(s1)         strupr(s1)
#define _strlwr(s1)         strlwr(s1)
#define _strrev(s1)         strrev(s1)
#endif  /* __MSC */

#if defined(__MFC_COMPAT__)
__inline char _FAR * _RTLENTRY  _strrev(char _FAR *__s) { return strrev(__s); }

__inline char _FAR * _RTLENTRY  _strset(char _FAR *__s, int __ch)
                              { return strset(__s, __ch); }
__inline char _FAR * _RTLENTRY  _strnset(char _FAR *__s, int __ch, _SIZE_T __n)
                              { return strnset(__s, __ch, __n); }
__inline char _FAR * _RTLENTRYF _strupr(char _FAR *__s) { return strupr(__s); }

__inline char _FAR * _RTLENTRYF _strlwr(char _FAR *__s) { return strlwr(__s); }

__inline char _FAR * _RTLENTRY  _strdup(const char _FAR *__s)
                              { return strdup(__s); }
__inline int         _RTLENTRYF _strcmpi(const char _FAR *__s1, const char _FAR *__s2)
                              { return stricmp (__s1, __s2); }
__inline int         _RTLENTRYF _stricmp(const char _FAR *__s1, const char _FAR *__s2)
                              { return stricmp (__s1, __s2); }
__inline int         _RTLENTRYF _strcmp(const char _FAR *__s1, const char _FAR *__s2)
                              { return strcmp (__s1, __s2); }
__inline int         _RTLENTRYF _strnicmp(const char _FAR *__s1, const char _FAR *__s2, _SIZE_T __maxlen)
                              { return strnicmp (__s1, __s2, __maxlen); }
#endif

int    _RTLENTRY  _EXPFUNC _lstrcoll(const char * __s1, const char * __s2);
int    _RTLENTRY  _EXPFUNC _lstricoll(const char * __s1, const char * __s2);
int    _RTLENTRY  _EXPFUNC _lstrncoll(const char * __s1, const char * __s2, const int __len);
int    _RTLENTRY  _EXPFUNC _lstrnicoll(const char * __s1, const char * __s2, int __len);
_SIZE_T _RTLENTRY  _EXPFUNC _lstrxfrm(char * __s1, const char * __s2,_SIZE_T __n );
int    _RTLENTRY  _EXPFUNC strcoll(const char * __s1, const char * __s2);
int    _RTLENTRY  _EXPFUNC _stricoll(const char * __s1, const char * __s2);
int    _RTLENTRY  _EXPFUNC _strncoll(const char * __s1, const char * __s2, _SIZE_T __n);
int    _RTLENTRY  _EXPFUNC _strnicoll(const char * __s1, const char * __s2, int __len);
_SIZE_T _RTLENTRY  _EXPFUNC strxfrm(char * __s1, const char * __s2,_SIZE_T __n );

int    _RTLENTRY  _EXPFUNC _lwcscoll(const wchar_t * __s1, const wchar_t * __s2);
int    _RTLENTRY  _EXPFUNC _lwcsicoll(const wchar_t * __s1, const wchar_t * __s2);
int    _RTLENTRY  _EXPFUNC _lwcsncoll(const wchar_t * __s1, const wchar_t * __s2, const int __len);
int    _RTLENTRY  _EXPFUNC _lwcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
_SIZE_T _RTLENTRY  _EXPFUNC _lwcsxfrm(wchar_t * __s1, const wchar_t * __s2,_SIZE_T __n );
int    _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
int    _RTLENTRY  _EXPFUNC _wcsicoll(const wchar_t * __s1, const wchar_t * __s2);
int    _RTLENTRY  _EXPFUNC _wcsncoll(const wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n);
int    _RTLENTRY  _EXPFUNC _wcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
_SIZE_T _RTLENTRY  _EXPFUNC wcsxfrm(wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n );


#if !defined(__STDC__) /* NON_ANSI  */
#define _fstrcat   strcat
#define _fstrchr   strchr
#define _fstrcmp   strcmp
#define _fstrcpy   strcpy
#define _fstrcspn  strcspn
#define _fstrdup   strdup
#define _fstricmp  stricmp
#define _fstrlen   strlen
#define _fstrlwr   strlwr
#define _fstrncat  strncat
#define _fstrncmp  strncmp
#define _fstrncpy  strncpy
#define _fstrnicmp strnicmp
#define _fstrnset  strnset
#define _fstrpbrk  strpbrk
#define _fstrrchr  strrchr
#define _fstrrev   strrev
#define _fstrset   strset
#define _fstrspn   strspn
#define _fstrstr   strstr
#define _fstrtok   strtok
#define _fstrupr   strupr
#endif /* __STDC__  */

#if defined(__USELOCALES__)
#define  strupr     _lstrupr
#define  strlwr     _lstrlwr
#define  strcoll    _lstrcoll
#define  stricoll   _lstricoll
#define  strncoll   _lstrncoll
#define  strnicoll  _lstrnicoll
#define  strxfrm    _lstrxfrm
#endif  /* __USELOCALES__ */

#if !defined(RC_INVOKED)

#if defined(__STDC__)
#pragma warn .nak
#endif

#endif  /* !RC_INVOKED */

#ifdef __cplusplus
} /* std */
#endif /* __cplusplus */

#ifdef __cplusplus
}
#endif

#endif  /* __STRING_H */

#if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__STRING_H_USING_LIST)
#define __STRING_H_USING_LIST
#if !defined(__STDC__)
    using std::_lstrlwr;
    using std::_lstrupr;
    using std::_stpcpy;
    using std::strdup;
    using std::stricmp;
    using std::strlwr;
    using std::strnicmp;
    using std::strrev;
    using std::strupr;
#endif
#if defined(__MFC_COMPAT__)

    using std::_strrev;
    using std::_strset;
    using std::_strnset;
    using std::_strupr;
    using std::_strdup;
    using std::_strlwr;
    using std::_strcmpi;
    using std::_stricmp;
    using std::_strcmp;
    using std::_strnicmp;
#endif
    using std::_lstrcoll;
    using std::_lstricoll;
    using std::_lstrncoll;
    using std::_lstrnicoll;
    using std::_lstrxfrm;
    using std::_lwcscoll;
    using std::_lwcsicoll;
    using std::_lwcslwr;
    using std::_lwcsncoll;
    using std::_lwcsnicoll;
    using std::_lwcsupr;
    using std::_lwcsxfrm;
    using std::_stricoll;
    using std::_strncoll;
    using std::_strnicoll;
    using std::_wcsdup;
    using std::_wcsicmp;
    using std::_wcsicoll;
    using std::_wcslwr;
    using std::_wcsncoll;
    using std::_wcsnicmp;
    using std::_wcsnicoll;
    using std::_wcsnset;
    using std::_wcspcpy;
    using std::_wcsrev;
    using std::_wcsset;
    using std::_wcsupr;

#if !defined(__STDC__)
    using std::strnset;
    using std::stpcpy;
    using std::strset;
    using std::_strerror;
    using std::_wcserror;
    using std::__wcserror;
#endif /* __STDC__ */

    using std::strcat;
    using std::strchr;
    using std::strcmp;
    using std::strcpy;
    using std::strlen;
    using std::strncat;
    using std::strncmp;
    using std::strncpy;
    using std::strrchr;

    using std::strcspn;
    using std::strerror;
    using std::strpbrk;
    using std::strspn;
    using std::strstr;
    using std::strtok;
    using std::strxfrm;
    using std::strcoll;

    using std::wcscat;
    using std::wcschr;
    using std::wcscmp;
    using std::wcscoll;
    using std::wcscpy;
    using std::wcscspn;
    using std::wcslen;
    using std::wcsncat;
    using std::wcsncmp;
    using std::wcsncpy;
    using std::wcspbrk;
    using std::wcspcpy;
    using std::wcsrchr;
    using std::wcsspn;
    using std::wcsstr;
    using std::wcstok;
    using std::wcsxfrm;
#endif /* __USING_CNAME__ */
