| 612 | size_t lenC = strlen(c); |
| 613 | char* result = (char*)malloc(lenA + lenB + lenC + 1); |
| 614 | if (!result) return NULL; |
| 615 | memcpy(result, a, lenA); |
| 616 | memcpy(result + lenA, b, lenB); |
| 617 | memcpy(result + lenA + lenB, c, lenC); |
| 618 | result[lenA + lenB + lenC] = 0; |
| 619 | return result; |
| 620 | } |
| 621 | |
| 622 | char* detectTargetOS(void) { |
| 623 | #ifdef _WIN32 |
| 624 | return String_duplicate("Windows"); |
| 625 | #else |
| 626 | FILE* uname_file = POPEN("uname", "r"); |
| 627 | if (uname_file) { |
| 628 | char buf[256]; |
| 629 | if (fgets(buf, sizeof(buf), uname_file)) { |
| 630 | size_t len = strlen(buf); |
| 631 | if (len > 0 && buf[len - 1] == '\n') buf[len - 1] = 0; |
| 632 | PCLOSE(uname_file); |
| 633 | return String_duplicate(buf); |
| 634 | } |
| 635 | PCLOSE(uname_file); |
| 636 | } |
| 637 | return String_duplicate("POSIX"); |
| 638 | #endif |
| 639 | } |
| 640 | |
| 641 | void String_unescapeJsonInPlace(char* str) { |
| 642 | if (!str) return; |
no test coverage detected