1 2 /* user defined headers */ 3 #include <kvm/util.h> 4 #include <kvm/strbuf.h> 5 6 int prefixcmp(const char *str, const char *prefix) 7 { 8 for (; ; str++, prefix++) { 9 if (!*prefix) 10 return 0; 11 else if (*str != *prefix) 12 return (unsigned char)*prefix - (unsigned char)*str; 13 } 14 } 15 16 /** 17 * strlcat - Append a length-limited, %NUL-terminated string to another 18 * @dest: The string to be appended to 19 * @src: The string to append to it 20 * @count: The size of the destination buffer. 21 */ 22 size_t strlcat(char *dest, const char *src, size_t count) 23 { 24 size_t dsize = strlen(dest); 25 size_t len = strlen(src); 26 size_t res = dsize + len; 27 28 DIE_IF(dsize >= count); 29 30 dest += dsize; 31 count -= dsize; 32 if (len >= count) 33 len = count - 1; 34 35 memcpy(dest, src, len); 36 dest[len] = 0; 37 38 return res; 39 } 40