* Like strncpy but does not 0 fill the buffer and always null * terminates. * * @param bufsize is the size of the destination buffer. * * @return index of the terminating byte. **/
| 116 | * @return index of the terminating byte. |
| 117 | **/ |
| 118 | size_t strlcpy(char *d, const char *s, size_t bufsize) |
| 119 | { |
| 120 | size_t len = strlen(s); |
| 121 | size_t ret = len; |
| 122 | if (bufsize > 0) { |
| 123 | if (len >= bufsize) |
| 124 | len = bufsize-1; |
| 125 | memcpy(d, s, len); |
| 126 | d[len] = 0; |
| 127 | } |
| 128 | return ret; |
| 129 | } |
| 130 | #endif |
| 131 | |
| 132 | #ifndef HAVE_STRLCAT |
no outgoing calls