ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/strlcpy.c
Revision: 2.1
Committed: Wed Jan 17 22:36:44 2018 UTC (6 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Added strlcpy.c compatibility module for non-BSD systems

File Contents

# User Rev Content
1 greg 2.1 #ifndef lint
2     static const char RCSid[] = "$Id: strcmp.c,v 2.3 2003/02/25 02:47:22 greg Exp $";
3     #endif
4     /*
5     * String copy routines similar to strncpy
6     */
7    
8     #include "copyright.h"
9    
10     int
11     strlcpy(char *dst, const char *src, int siz)
12     {
13     int n = siz;
14    
15     while (--n > 0)
16     if (!(*dst++ = *src++))
17     return(siz-1-n);
18     *dst = '\0';
19     return(siz-1);
20     }
21    
22     int
23     strlcat(char *dst, const char *src, int siz)
24     {
25     int n = siz;
26    
27     while (*dst && --n > 0)
28     ++dst;
29     if (n <= 0)
30     return(siz);
31     return(siz-n + strlcpy(dst, src, n));
32     }