2 * "$Id: flstring.c 7903 2010-11-28 21:06:39Z matt $"
4 * BSD string functions for the Fast Light Tool Kit (FLTK).
6 * Copyright 1998-2010 by Bill Spitzak and others.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * Please report all bugs and problems on the following page:
25 * http://www.fltk.org/str.php
32 * 'fl_strlcat()' - Safely concatenate two strings.
35 size_t /* O - Length of string */
36 fl_strlcat(char *dst
, /* O - Destination string */
37 const char *src
, /* I - Source string */
38 size_t size
) { /* I - Size of destination string buffer */
39 size_t srclen
; /* Length of source string */
40 size_t dstlen
; /* Length of destination string */
44 * Figure out how much room is left...
50 if (!size
) return (dstlen
); /* No room, return immediately... */
53 * Figure out how much room is needed...
59 * Copy the appropriate amount...
62 if (srclen
> size
) srclen
= size
;
64 memcpy(dst
+ dstlen
, src
, srclen
);
65 dst
[dstlen
+ srclen
] = '\0';
67 return (dstlen
+ srclen
);
72 * 'fl_strlcpy()' - Safely copy two strings.
75 size_t /* O - Length of string */
76 fl_strlcpy(char *dst
, /* O - Destination string */
77 const char *src
, /* I - Source string */
78 size_t size
) { /* I - Size of destination string buffer */
79 size_t srclen
; /* Length of source string */
83 * Figure out how much room is needed...
91 * Copy the appropriate amount...
94 if (srclen
> size
) srclen
= size
;
96 memcpy(dst
, src
, srclen
);
104 * End of "$Id: flstring.c 7903 2010-11-28 21:06:39Z matt $".