ReactOS 0.4.15-dev-7842-g558ab78
strlcpy.c
Go to the documentation of this file.
1/* @(#)strlcpy.c 1.4 09/07/08 Copyright 2006-2009 J. Schilling */
2#include <schily/mconfig.h>
3#ifndef lint
4static UConst char sccsid[] =
5 "@(#)strlcpy.c 1.4 09/07/08 Copyright 2006-2009 J. Schilling";
6#endif
7/*
8 * strlcpy() to be used if missing in libc
9 *
10 * Copyright (c) 2006-2009 J. Schilling
11 */
12/*
13 * The contents of this file are subject to the terms of the
14 * Common Development and Distribution License, Version 1.0 only
15 * (the "License"). You may not use this file except in compliance
16 * with the License.
17 *
18 * See the file CDDL.Schily.txt in this distribution for details.
19 *
20 * When distributing Covered Code, include this CDDL HEADER in each
21 * file and include the License file CDDL.Schily.txt from this distribution.
22 */
23
24#include <schily/standard.h>
25#include <schily/unistd.h>
26#include <schily/libport.h>
27
28#ifndef HAVE_STRLCPY
29
30EXPORT size_t
32 register char *s1;
33 register const char *s2;
34 register size_t len;
35{
36 const char *os2 = s2;
37
38 if (len > 0) {
39 while (--len > 0 && (*s1++ = *s2++) != '\0')
40 ;
41 if (len == 0) {
42 *s1 = '\0';
43 while (*s2++ != '\0')
44 ;
45 }
46 } else {
47 while (*s2++ != '\0')
48 ;
49 }
50 return (--s2 - os2);
51}
52#endif /* HAVE_STRLCPY */
#define UConst
Definition: ccomdefs.h:72
GLenum GLsizei len
Definition: glext.h:6722
struct S1 s1
struct S2 s2
static UConst char sccsid[]
Definition: strlcpy.c:4
EXPORT size_t strlcpy(char *s1, const char *s2, size_t len)
Definition: strlcpy.c:31