Blame alsactl/init_sysdeps.c

Packit Service a9274b
/*
Packit Service a9274b
 * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
Packit Service a9274b
 * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
Packit Service a9274b
 *
Packit Service a9274b
 *	This program is free software; you can redistribute it and/or modify it
Packit Service a9274b
 *	under the terms of the GNU General Public License as published by the
Packit Service a9274b
 *	Free Software Foundation version 2 of the License.
Packit Service a9274b
 * 
Packit Service a9274b
 *	This program is distributed in the hope that it will be useful, but
Packit Service a9274b
 *	WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a9274b
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service a9274b
 *	General Public License for more details.
Packit Service a9274b
 * 
Packit Service a9274b
 *	You should have received a copy of the GNU General Public License along
Packit Service a9274b
 *	with this program; if not, write to the Free Software Foundation, Inc.,
Packit Service a9274b
 *	51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Packit Service a9274b
 *
Packit Service a9274b
 */
Packit Service a9274b
Packit Service a9274b
#if defined(__GLIBC__) && !(defined(__UCLIBC__) && defined(__USE_BSD))
Packit Service a9274b
static size_t strlcpy(char *dst, const char *src, size_t size)
Packit Service a9274b
{
Packit Service a9274b
	size_t bytes = 0;
Packit Service a9274b
	char *q = dst;
Packit Service a9274b
	const char *p = src;
Packit Service a9274b
	char ch;
Packit Service a9274b
Packit Service a9274b
	while ((ch = *p++)) {
Packit Service a9274b
		if (bytes+1 < size)
Packit Service a9274b
			*q++ = ch;
Packit Service a9274b
		bytes++;
Packit Service a9274b
	}
Packit Service a9274b
Packit Service a9274b
	/* If size == 0 there is no space for a final null... */
Packit Service a9274b
	if (size)
Packit Service a9274b
		*q = '\0';
Packit Service a9274b
	return bytes;
Packit Service a9274b
}
Packit Service a9274b
Packit Service a9274b
static size_t strlcat(char *dst, const char *src, size_t size)
Packit Service a9274b
{
Packit Service a9274b
	size_t bytes = 0;
Packit Service a9274b
	char *q = dst;
Packit Service a9274b
	const char *p = src;
Packit Service a9274b
	char ch;
Packit Service a9274b
Packit Service a9274b
	while (bytes < size && *q) {
Packit Service a9274b
		q++;
Packit Service a9274b
		bytes++;
Packit Service a9274b
	}
Packit Service a9274b
	if (bytes == size)
Packit Service a9274b
		return (bytes + strlen(src));
Packit Service a9274b
Packit Service a9274b
	while ((ch = *p++)) {
Packit Service a9274b
		if (bytes+1 < size)
Packit Service a9274b
		*q++ = ch;
Packit Service a9274b
		bytes++;
Packit Service a9274b
	}
Packit Service a9274b
Packit Service a9274b
	*q = '\0';
Packit Service a9274b
	return bytes;
Packit Service a9274b
}
Packit Service a9274b
#endif /* __GLIBC__ */