mirror of
https://gitea.psi.ch/ELOG/mxml.git
synced 2026-09-09 01:23:22 +00:00
Check for predefined strlcpy (as in newer gcc versions)
This commit is contained in:
parent
19a939ec26
commit
6531dc4ae2
2
mxml.h
2
mxml.h
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
Contents: Header file for mxml.c
|
Contents: Header file for mxml.c
|
||||||
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -6,8 +6,6 @@
|
|||||||
Contents: Contains strlcpy and strlcat which are versions of
|
Contents: Contains strlcpy and strlcat which are versions of
|
||||||
strcpy and strcat, but which avoid buffer overflows
|
strcpy and strcat, but which avoid buffer overflows
|
||||||
|
|
||||||
$Id:$
|
|
||||||
|
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -19,6 +17,8 @@
|
|||||||
* will be copied. Always NUL terminates (unless size == 0).
|
* will be copied. Always NUL terminates (unless size == 0).
|
||||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||||
*/
|
*/
|
||||||
|
#ifndef STRLCPY_DEFINED
|
||||||
|
|
||||||
size_t strlcpy(char *dst, const char *src, size_t size)
|
size_t strlcpy(char *dst, const char *src, size_t size)
|
||||||
{
|
{
|
||||||
char *d = dst;
|
char *d = dst;
|
||||||
@ -80,3 +80,5 @@ size_t strlcat(char *dst, const char *src, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif // STRLCPY_DEFINED
|
||||||
|
|||||||
@ -5,13 +5,16 @@
|
|||||||
|
|
||||||
Contents: Header file for strlcpy.c
|
Contents: Header file for strlcpy.c
|
||||||
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
#ifndef _STRLCPY_H_
|
#ifndef _STRLCPY_H_
|
||||||
#define _STRLCPY_H_
|
#define _STRLCPY_H_
|
||||||
|
|
||||||
|
// some version of gcc have a built-in strlcpy
|
||||||
|
#ifdef strlcpy
|
||||||
|
#define STRLCPY_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -24,8 +27,10 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef STRLCPY_DEFINED
|
||||||
size_t EXPRT strlcpy(char *dst, const char *src, size_t size);
|
size_t EXPRT strlcpy(char *dst, const char *src, size_t size);
|
||||||
size_t EXPRT strlcat(char *dst, const char *src, size_t size);
|
size_t EXPRT strlcat(char *dst, const char *src, size_t size);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user