Mercurial > mplayer.hg
comparison osdep/strlcpy.c @ 21857:8d9e6b4fbf4d
Split strl.c into strl(cat|cpy).c and move #ifdefs into the build system.
author | diego |
---|---|
date | Wed, 10 Jan 2007 20:23:24 +0000 |
parents | |
children | 9fb716ab06a3 |
comparison
equal
deleted
inserted
replaced
21856:e268886eb13d | 21857:8d9e6b4fbf4d |
---|---|
1 /* strlcpy implementation for systems that do not have it in libc | |
2 * Time-stamp: <2004-03-14 njk> | |
3 * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx> | |
4 */ | |
5 | |
6 #include "config.h" | |
7 | |
8 unsigned int strlcpy (char *dest, const char *src, unsigned int size) | |
9 { | |
10 register unsigned int i = 0; | |
11 | |
12 if (size > 0) { | |
13 size--; | |
14 for (i=0; size > 0 && src[i] != '\0'; ++i, size--) | |
15 dest[i] = src[i]; | |
16 | |
17 dest[i] = '\0'; | |
18 } | |
19 while (src[i++]); | |
20 | |
21 return i; | |
22 } |