Join any number of strings together, putting them in "dest". The return * value is the length of all the strings, regardless of whether the null- * terminated whole fits in destsize. Your list of string pointers must end * with a NULL to indicate the end of the list. */
| 910 | * terminated whole fits in destsize. Your list of string pointers must end |
| 911 | * with a NULL to indicate the end of the list. */ |
| 912 | size_t stringjoin(char *dest, size_t destsize, ...) |
| 913 | { |
| 914 | va_list ap; |
| 915 | size_t len, ret = 0; |
| 916 | const char *src; |
| 917 | |
| 918 | va_start(ap, destsize); |
| 919 | while (1) { |
| 920 | if (!(src = va_arg(ap, const char *))) |
| 921 | break; |
| 922 | len = strlen(src); |
| 923 | ret += len; |
| 924 | if (destsize > 1) { |
| 925 | if (len >= destsize) |
| 926 | len = destsize - 1; |
| 927 | memcpy(dest, src, len); |
| 928 | destsize -= len; |
| 929 | dest += len; |
| 930 | } |
| 931 | } |
| 932 | *dest = '\0'; |
| 933 | va_end(ap); |
| 934 | |
| 935 | return ret; |
| 936 | } |
| 937 | |
| 938 | int count_dir_elements(const char *p) |
| 939 | { |
no outgoing calls
no test coverage detected