Subversion Repositories Kolibri OS

Rev

Rev 6102 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1966 serge 1
/*
2
 *  linux/lib/string.c
3
 *
4
 *  Copyright (C) 1991, 1992  Linus Torvalds
5
 */
6
 
7
/*
8
 * stupid library routines.. The optimized versions should generally be found
9
 * as inline code in 
10
 *
11
 * These are buggy as well..
12
 *
13
 * * Fri Jun 25 1999, Ingo Oeser 
14
 * -  Added strsep() which will replace strtok() soon (because strsep() is
15
 *    reentrant and should be faster). Use only strsep() in new code, please.
16
 *
17
 * * Sat Feb 09 2002, Jason Thomas ,
18
 *                    Matthew Hawkins 
19
 * -  Kissed strtok() goodbye
20
 */
21
 
22
#include 
23
#include 
24
#include 
25
#include 
26
 
27
 
28
#ifndef __HAVE_ARCH_STRLCPY
29
/**
30
 * strlcpy - Copy a %NUL terminated string into a sized buffer
31
 * @dest: Where to copy the string to
32
 * @src: Where to copy the string from
33
 * @size: size of destination buffer
34
 *
35
 * Compatible with *BSD: the result is always a valid
36
 * NUL-terminated string that fits in the buffer (unless,
37
 * of course, the buffer size is zero). It does not pad
38
 * out the result like strncpy() does.
39
 */
40
size_t strlcpy(char *dest, const char *src, size_t size)
41
{
42
    size_t ret = strlen(src);
43
 
44
    if (size) {
45
        size_t len = (ret >= size) ? size - 1 : ret;
46
        memcpy(dest, src, len);
47
        dest[len] = '\0';
48
    }
49
    return ret;
50
}
51
EXPORT_SYMBOL(strlcpy);
52
#endif
53