view osdep/strl.c @ 15438:5f6e6d6cccbc

1.924: windows priority support patch 1.925: Added support of audio stream switching in the MPEG demuxer using the #-key 1.926: Online audio switching is for MPEG files only at the moment. 1.927: Better defaults encoding settings for XviD 1.928: changed :vaspect option to float type 1.929: HRTF update 1.930: Use | for alternatives and - for ranges in option parameter descriptions. 1.931: Make the -priority warning obey the standard formatting. 1.932: hrtf typo fix
author kraymer
date Fri, 13 May 2005 16:50:36 +0000
parents f48dc20c9185
children da29ac12242d
line wrap: on
line source

/* strl(cat|cpy) implementation for systems that do not have it in libc */
/* strl.c - strlcpy/strlcat implementation
 * Time-stamp: <2004-03-14 njk>
 * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
 */

#include "../config.h"

#ifndef HAVE_STRLCPY
unsigned int strlcpy (char *dest, const char *src, unsigned int size)
{
	register unsigned int i;

	for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
		dest[i] = src[i];

	dest[i] = '\0';

	return i;
}
#endif

#ifndef HAVE_STRLCAT
unsigned int strlcat (char *dest, const char *src, unsigned int size)
{
#if 0
	register unsigned int i, j;

	for(i=0; size > 0 && dest[i] != '\0'; size--, i++);
	for(j=0; size > 0 && src[j] != '\0'; size--, i++, j++)
		dest[i] = src[j];

	dest[i] = '\0';
	return i;
#else
	register char *d = dest;
	register const char *s = src;

	for (; size > 0 && *d != '\0'; size--, d++);
	for (; size > 0 && *s != '\0'; size--, d++, s++)
		*d = *s;

	*d = '\0';
	return (d - dest) + (s - src);
#endif 
}
#endif