MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / write_format

Method write_format

dependencies/httplib/httplib.h:1515–1546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1513
1514template <typename... Args>
1515inline ssize_t Stream::write_format(const char *fmt, const Args &...args) {
1516 const auto bufsiz = 2048;
1517 std::array<char, bufsiz> buf{};
1518
1519#if defined(_MSC_VER) && _MSC_VER < 1900
1520 auto sn = _snprintf_s(buf.data(), bufsiz, _TRUNCATE, fmt, args...);
1521#else
1522 auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...);
1523#endif
1524 if (sn <= 0) { return sn; }
1525
1526 auto n = static_cast<size_t>(sn);
1527
1528 if (n >= buf.size() - 1) {
1529 std::vector<char> glowable_buf(buf.size());
1530
1531 while (n >= glowable_buf.size() - 1) {
1532 glowable_buf.resize(glowable_buf.size() * 2);
1533#if defined(_MSC_VER) && _MSC_VER < 1900
1534 n = static_cast<size_t>(_snprintf_s(&glowable_buf[0], glowable_buf.size(),
1535 glowable_buf.size() - 1, fmt,
1536 args...));
1537#else
1538 n = static_cast<size_t>(
1539 snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...));
1540#endif
1541 }
1542 return write(&glowable_buf[0], n);
1543 } else {
1544 return write(buf.data(), n);
1545 }
1546}
1547
1548inline void default_socket_options(socket_t sock) {
1549 int yes = 1;

Callers 4

write_headersFunction · 0.80
write_response_coreMethod · 0.80
process_requestMethod · 0.80
write_requestMethod · 0.80

Calls 3

snprintfFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected