972810f6cf
remove strlcpy & strlcat from string.h document suspicious strlcpy call convert strlcat.h users to string-extra Change-Id: I313e75db86385c0e6d1aee75d252093be4935f60
39 lines
1.5 KiB
C
39 lines
1.5 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2022 William Wilgus
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#include <string.h>
|
|
#include "strmemccpy.h"
|
|
|
|
/*
|
|
* Copy src to string dst of size siz. At most siz-1 characters
|
|
* will be copied. Always NUL terminates (unless siz == 0).
|
|
* Returns strlen(src); if retval >= siz, truncation occurred.
|
|
*/
|
|
size_t strlcpy(char *dst, const char *src, size_t siz)
|
|
{
|
|
/* Copy as many bytes as will fit */
|
|
char *d = strmemccpy(dst, src, siz);
|
|
if (d)
|
|
return (d - dst - 1); /* count does not include NUL */
|
|
|
|
/* Not enough room in dst, traverse rest of src */
|
|
return(siz + strlen(src+siz)); /* count does not include NUL */
|
|
}
|