2005-09-27 17:20:56 +02:00
|
|
|
#ifndef STRING_S_H__
|
|
|
|
#define STRING_S_H__
|
2005-02-28 16:36:19 +01:00
|
|
|
|
2005-03-18 23:44:55 +01:00
|
|
|
#include "posix_types.h" // size_t
|
2005-09-27 17:20:56 +02:00
|
|
|
#include "config.h"
|
2005-02-28 16:50:35 +01:00
|
|
|
|
2005-09-27 17:20:56 +02:00
|
|
|
// only declare these functions if using our implementation
|
|
|
|
// (otherwise, we risk incompatibilities)
|
|
|
|
#if !HAVE_STRING_S
|
2005-02-28 16:36:19 +01:00
|
|
|
|
2005-09-27 17:20:56 +02:00
|
|
|
// (conflicts with glibc definitions)
|
2005-08-09 18:23:19 +02:00
|
|
|
#if !OS_UNIX
|
2005-02-28 16:36:19 +01:00
|
|
|
// return length [in characters] of a string, not including the trailing
|
|
|
|
// null character. to protect against access violations, only the
|
|
|
|
// first <max_len> characters are examined; if the null character is
|
|
|
|
// not encountered by then, <max_len> is returned.
|
2005-07-04 19:03:08 +02:00
|
|
|
extern size_t strnlen(const char* str, size_t max_len);
|
|
|
|
extern size_t wcsnlen(const wchar_t* str, size_t max_len);
|
2005-08-07 23:58:36 +02:00
|
|
|
#endif
|
2005-02-28 16:36:19 +01:00
|
|
|
|
|
|
|
// copy at most <max_src_chars> (not including trailing null) from
|
|
|
|
// <src> into <dst>, which must not overlap.
|
|
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
|
|
//
|
|
|
|
// note: padding with zeroes is not called for by NG1031.
|
2005-02-28 16:50:35 +01:00
|
|
|
extern int strncpy_s(char* dst, size_t max_dst_chars, const char* src, size_t max_src_chars);
|
|
|
|
extern int wcsncpy_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src, size_t max_src_chars);
|
2005-02-28 16:36:19 +01:00
|
|
|
|
|
|
|
// copy <src> (including trailing null) into <dst>, which must not overlap.
|
|
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
|
|
//
|
|
|
|
// note: implemented as tncpy_s(dst, max_dst_chars, src, SIZE_MAX)
|
2005-02-28 16:50:35 +01:00
|
|
|
extern int strcpy_s(char* dst, size_t max_dst_chars, const char* src);
|
|
|
|
extern int wcscpy_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
|
2005-02-28 16:36:19 +01:00
|
|
|
|
|
|
|
// append at most <max_src_chars> (not including trailing null) from
|
|
|
|
// <src> to <dst>, which must not overlap.
|
|
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
2005-02-28 16:50:35 +01:00
|
|
|
extern int strncat_s(char* dst, size_t max_dst_chars, const char* src, size_t max_src_chars);
|
|
|
|
extern int wcsncat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src, size_t max_src_chars);
|
2005-02-28 16:36:19 +01:00
|
|
|
|
|
|
|
// append <src> to <dst>, which must not overlap.
|
|
|
|
// if thereby <max_dst_chars> (including null) would be exceeded,
|
|
|
|
// <dst> is set to the empty string and ERANGE returned; otherwise,
|
|
|
|
// 0 is returned to indicate success and that <dst> is null-terminated.
|
|
|
|
//
|
|
|
|
// note: implemented as tncat_s(dst, max_dst_chars, src, SIZE_MAX)
|
2005-02-28 16:50:35 +01:00
|
|
|
extern int strcat_s(char* dst, size_t max_dst_chars, const char* src);
|
|
|
|
extern int wcscat_s(wchar_t* dst, size_t max_dst_chars, const wchar_t* src);
|
2005-02-28 16:36:19 +01:00
|
|
|
|
2005-09-27 17:20:56 +02:00
|
|
|
#endif // #if !HAVE_STRING_S
|
2005-02-28 16:36:19 +01:00
|
|
|
|
2005-09-27 17:20:56 +02:00
|
|
|
#endif // #ifndef STRING_S_H__
|