/* ISC license. */ #include #include #include #include #include #include size_t tipidee_response_error (buffer *b, tipidee_rql const *rql, char const *rsl, char const *text, uint32_t options) { size_t n = 0 ; static char const txt1[] = "\n" ; static char const txt2[] = "\n\n

" ; static char const txt3[] = "

\n

\n" ; static char const txt4[] = "\n

\n\n\n" ; n += tipidee_response_status_line(b, rql, rsl) ; n += tipidee_response_header_common_put_g(buffer_1, options) ; if (!(options & 2)) { char fmt[SIZE_FMT] ; n += buffer_putsnoflush(buffer_1, "Content-Type: text/html; charset=UTF-8\r\n") ; n += buffer_putsnoflush(buffer_1, "Content-Length: ") ; n += buffer_putnoflush(buffer_1, fmt, size_fmt(fmt, sizeof(txt1) + sizeof(txt2) + sizeof(txt3) + sizeof(txt4) - 4 + 2 * strlen(rsl) + strlen(text))) ; n += buffer_putnoflush(buffer_1, "\r\n", 2) ; } n += buffer_putnoflush(buffer_1, "\r\n", 2) ; if (rql->m != TIPIDEE_METHOD_HEAD) { n += buffer_putsnoflush(buffer_1, txt1) ; n += buffer_putsnoflush(buffer_1, rsl) ; n += buffer_putsnoflush(buffer_1, txt2) ; n += buffer_putsnoflush(buffer_1, rsl) ; n += buffer_putsnoflush(buffer_1, txt3) ; n += buffer_putsnoflush(buffer_1, text) ; n += buffer_putsnoflush(buffer_1, txt4) ; } return n ; }