import less(1)
[unleashed/tickless.git] / usr / src / lib / libast / common / string / strlcpy.c
blobe2fe9b7913232958558ccafaf3460e6f0cfdd20a
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
24 * strlcpy implementation
27 #define strlcpy ______strlcpy
29 #include <ast.h>
31 #undef strlcpy
33 #undef _def_map_ast
34 #include <ast_map.h>
36 #if _lib_strlcpy
38 NoN(strlcpy)
40 #else
43 * copy at most n chars from t into s
44 * result 0 terminated if n>0
45 * strlen(t) returned
48 #if defined(__EXPORT__)
49 #define extern __EXPORT__
50 #endif
52 extern size_t
53 strlcpy(register char* s, register const char* t, register size_t n)
55 const char* o = t;
57 if (n)
60 if (!--n)
62 *s = 0;
63 break;
65 } while (*s++ = *t++);
66 if (!n)
67 while (*t++);
68 return t - o - 1;
71 #endif