* Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(dst) + strlen(src); if retval >= siz, truncation occurred. */
| 192 | * Returns strlen(dst) + strlen(src); if retval >= siz, truncation occurred. |
| 193 | */ |
| 194 | size_t |
| 195 | dmStrlCat(char *dst, const char *src, size_t siz) |
| 196 | { |
| 197 | char *d = dst; |
| 198 | const char *s = src; |
| 199 | size_t n = siz; |
| 200 | size_t dlen; |
| 201 | |
| 202 | /* Find the end of dst and adjust bytes left but don't go past end */ |
| 203 | while (*d != '\0' && n-- != 0) |
| 204 | d++; |
| 205 | dlen = d - dst; |
| 206 | n = siz - dlen; |
| 207 | |
| 208 | if (n == 0) |
| 209 | return(dlen + strlen(s)); |
| 210 | while (*s != '\0') { |
| 211 | if (n != 1) { |
| 212 | *d++ = *s; |
| 213 | n--; |
| 214 | } |
| 215 | s++; |
| 216 | } |
| 217 | *d = '\0'; |
| 218 | |
| 219 | return(dlen + (s - src)); /* count does not include NUL */ |
| 220 | } |
| 221 | |
| 222 | int dmStrCaseCmp(const char *s1, const char *s2) |
| 223 | { |
no outgoing calls