commit 7939347171a791b258516ee7ce589dc403328c78 from: Omar Polo via: Thomas Adam date: Sat Aug 27 17:51:57 2022 UTC gotwebd: add fcgi_printf instead of fcgi_gen_response which outputs only a fixed strings provide a printf-like fcgi_printf: it greatly simplifies the generation of the HTML pages. While here also (probably) fix some HTML errors: the output was verified with the W3C validator and it's correct (in the sense that the tags are properly closed, there are still some other things the validator complains about.) ok/encouragement baseprime@, ok jamsek Thanks for reading such a boring diff! commit - 4b553fec9a9b5b083e5b564787f948254a2dde29 commit + 7939347171a791b258516ee7ce589dc403328c78 blob - 9b91a5046089c8ec9d7b5c06d33e50782850f82f blob + bdfdd35a553466d74a4e3ede850696fce898a0d3 --- gotwebd/fcgi.c +++ gotwebd/fcgi.c @@ -24,6 +24,8 @@ #include #include +#include +#include #include #include #include @@ -309,6 +311,27 @@ fcgi_timeout(int fd, short events, void *arg) } int +fcgi_printf(struct request *c, const char *fmt, ...) +{ + va_list ap; + char *str; + int r; + + va_start(ap, fmt); + r = vasprintf(&str, fmt, ap); + va_end(ap); + + if (r == -1) { + log_warn("%s: asprintf", __func__); + return -1; + } + + r = fcgi_gen_binary_response(c, str, r); + free(str); + return r; +} + +int fcgi_gen_binary_response(struct request *c, const uint8_t *data, int len) { int r; @@ -347,14 +370,6 @@ fcgi_gen_binary_response(struct request *c, const uint return 0; } -int -fcgi_gen_response(struct request *c, const char *data) -{ - if (data == NULL || *data == '\0') - return 0; - return fcgi_gen_binary_response(c, data, strlen(data)); -} - static int send_response(struct request *c, int type, const uint8_t *data, size_t len) blob - c87753eb142bed716b3f35a8c0220ffda1b98a05 blob + b260b7fe9f656659b2df03066a6a98ffc06fbbec --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -829,10 +829,10 @@ got_output_repo_tree(struct request *c) struct got_reflist_head refs; struct got_tree_object *tree = NULL; struct repo_dir *repo_dir = t->repo_dir; + const char *name, *index_page_str, *folder; char *id_str = NULL; - char *path = NULL, *in_repo_path = NULL, *build_folder = NULL; - char *modestr = NULL, *name = NULL; - int nentries, i; + char *path = NULL, *in_repo_path = NULL, *modestr = NULL; + int nentries, i, r; TAILQ_INIT(&refs); @@ -871,6 +871,9 @@ got_output_repo_tree(struct request *c) nentries = got_object_tree_get_nentries(tree); + index_page_str = qs->index_page_str ? qs->index_page_str : ""; + folder = qs->folder ? qs->folder : ""; + for (i = 0; i < nentries; i++) { struct got_tree_entry *te; mode_t mode; @@ -917,226 +920,55 @@ got_output_repo_tree(struct request *c) } } - name = strdup(got_tree_entry_get_name(te)); - if (name == NULL) { - error = got_error_from_errno("strdup"); - goto done; - } if (S_ISDIR(mode)) { - if (asprintf(&build_folder, "%s/%s", - qs->folder ? qs->folder : "", - got_tree_entry_get_name(te)) == -1) { - error = got_error_from_errno("asprintf"); - goto done; - } - - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - - if (fcgi_gen_response(c, "\n" + "\n" /* .tree_line */ + "
 
\n" + "
\n", /* .tree_wrapper */ + index_page_str, qs->path, rc->commit_id, + folder, name, name, modestr); + if (r == -1) goto done; - if (fcgi_gen_response(c, build_folder) == -1) - goto done; - if (fcgi_gen_response(c, "'>") == -1) - goto done; - if (fcgi_gen_response(c, name) == -1) - goto done; - if (fcgi_gen_response(c, modestr) == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, " ") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "\n") == -1) - goto done; - } else { - free(name); - name = strdup(got_tree_entry_get_name(te)); - if (name == NULL) { - error = got_error_from_errno("strdup"); - goto done; - } - - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - - if (fcgi_gen_response(c, - "") == -1) - goto done; - if (fcgi_gen_response(c, name) == -1) - goto done; - if (fcgi_gen_response(c, modestr) == -1) - goto done; - - if (fcgi_gen_response(c, "") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - - if (fcgi_gen_response(c, - "") == -1) - goto done; - - if (fcgi_gen_response(c, "commits") == -1) - goto done; - if (fcgi_gen_response(c, "\n") == -1) - goto done; - - if (fcgi_gen_response(c, " | \n") == -1) - goto done; - - if (fcgi_gen_response(c, - "") == -1) - goto done; - - if (fcgi_gen_response(c, "blame") == -1) - goto done; - if (fcgi_gen_response(c, "\n") == -1) + name = got_tree_entry_get_name(te); + r = fcgi_printf(c, + "
\n" + "
" + "%s%s" + "
\n" /* .tree_line */ + "
" + "commits\n" + " | \n" + "blame\n" + "
\n" /* .tree_line_blank */ + "
\n", /* .tree_wrapper */ + index_page_str, qs->path, rc->commit_id, + folder, name, name, modestr, + index_page_str, qs->path, rc->commit_id, + folder, name, + index_page_str, qs->path, rc->commit_id, + folder, name); + if (r == -1) goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; } free(id_str); id_str = NULL; - free(build_folder); - build_folder = NULL; - free(name); - name = NULL; free(modestr); modestr = NULL; } done: free(id_str); - free(build_folder); free(modestr); free(path); - free(name); got_ref_list_free(&refs); if (commit) got_object_commit_close(commit); @@ -1286,11 +1118,13 @@ got_gotweb_blame_cb(void *arg, int nlines, int lineno, struct transport *t = c->t; struct querystring *qs = t->qs; struct repo_dir *repo_dir = t->repo_dir; + const char *index_page_str; char *line = NULL, *eline = NULL; size_t linesize = 0; off_t offset; struct tm tm; time_t committer_time; + int r; if (nlines != a->nlines || (lineno != -1 && lineno < 1) || lineno > a->nlines) @@ -1334,10 +1168,10 @@ got_gotweb_blame_cb(void *arg, int nlines, int lineno, goto done; } + index_page_str = qs->index_page_str ? qs->index_page_str : ""; + while (a->lineno_cur <= a->nlines && bline->annotated) { - int out_buff_size = 100; char *smallerthan, *at, *nl, *committer; - char out_buff[out_buff_size]; size_t len; if (getline(&line, &linesize, a->f) == -1) { @@ -1360,69 +1194,30 @@ got_gotweb_blame_cb(void *arg, int nlines, int lineno, nl = strchr(line, '\n'); if (nl) *nl = '\0'; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (snprintf(out_buff, strlen(out_buff), "%.*d", a->nlines_prec, - a->lineno_cur) < 0) - goto done; - if (fcgi_gen_response(c, out_buff) == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, bline->datebuf) == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, committer) == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; err = gotweb_escape_html(&eline, line); if (err) goto done; - if (fcgi_gen_response(c, eline) == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) + r = fcgi_printf(c, "
" + "
%.*d
" + "
" + "" + "%.8s" + "
" + "
%s
" + "
%s
" + "
%s
" + "
", /* .blame_wrapper */ + a->nlines_prec, a->lineno_cur, + index_page_str, repo_dir->name, bline->id_str, + bline->id_str, + bline->datebuf, + committer, + eline); + if (r == -1) goto done; + a->lineno_cur++; bline = &a->lines[a->lineno_cur - 1]; } @@ -1767,12 +1562,7 @@ got_output_repo_diff(struct request *c) goto done; } } - if (fcgi_gen_response(c, "
") == -1) - goto done; + newline = strchr(line, '\n'); if (newline) *newline = '\0'; @@ -1780,13 +1570,12 @@ got_output_repo_diff(struct request *c) error = gotweb_escape_html(&eline, line); if (error) goto done; - if (fcgi_gen_response(c, eline) == -1) - goto done; + + fcgi_printf(c, "
%s
\n", + color ? color : "", eline); free(eline); eline = NULL; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; if (linelen > 0) wrlen = wrlen + linelen; free(color); blob - f7cde29268502cd5e4efef53f0888a485aca6057 blob + 47031c77bce94400b4f9954d55e4fe06835ff4b4 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -118,7 +118,7 @@ gotweb_process_request(struct request *c) struct querystring *qs = NULL; struct repo_dir *repo_dir = NULL; uint8_t err[] = "gotwebd experienced an error: "; - int html = 0; + int r, html = 0; /* init the transport */ error = gotweb_init_transport(&c->t); @@ -269,29 +269,27 @@ render: break; case ERR: default: - if (fcgi_gen_response(c, "
") == -1) - goto err; - if (fcgi_gen_response(c, "Error: Bad Querystring\n") == -1) - goto err; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
%s
\n", + "Erorr: Bad Querystring"); + if (r == -1) goto err; break; } goto done; err: - if (html && fcgi_gen_response(c, "
") == -1) + if (html && fcgi_printf(c, "
") == -1) return; - if (fcgi_gen_response(c, err) == -1) + if (fcgi_printf(c, "%s", err) == -1) return; if (error) { - if (fcgi_gen_response(c, (uint8_t *)error->msg) == -1) + if (fcgi_printf(c, "%s", error->msg) == -1) return; } else { - if (fcgi_gen_response(c, "see daemon logs for details") == -1) + if (fcgi_printf(c, "see daemon logs for details") == -1) return; } - if (html && fcgi_gen_response(c, "
\n") == -1) + if (html && fcgi_printf(c, "
\n") == -1) return; done: if (c->t->repo != NULL && qs->action != INDEX) @@ -627,205 +625,124 @@ gotweb_free_transport(struct transport *t) const struct got_error * gotweb_render_content_type(struct request *c, const uint8_t *type) { - const struct got_error *error = NULL; - char *h = NULL; - - if (asprintf(&h, "Content-type: %s\r\n\r\n", type) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - - fcgi_gen_response(c, h); -done: - free(h); - - return error; + fcgi_printf(c, "Content-Type: %s\r\n\r\n", type); + return NULL; } const struct got_error * gotweb_render_content_type_file(struct request *c, const uint8_t *type, char *file) { - const struct got_error *error = NULL; - char *h = NULL; - - if (asprintf(&h, "Content-type: %s\r\n" + fcgi_printf(c, "Content-type: %s\r\n" "Content-disposition: attachment; filename=%s\r\n\r\n", - type, file) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - - fcgi_gen_response(c, h); -done: - free(h); - - return error; + type, file); + return NULL; } static const struct got_error * gotweb_render_header(struct request *c) { - const struct got_error *error = NULL; struct server *srv = c->srv; struct querystring *qs = c->t->qs; - char *title = NULL, *droot = NULL, *css = NULL, *gotlink = NULL; - char *gotimg = NULL, *sitelink = NULL, *summlink = NULL; + char droot[PATH_MAX]; + int r; if (strlen(c->document_root) > 0) { - if (asprintf(&droot, "/%s/", c->document_root) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - } else { - if (asprintf(&droot, "/") == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - } + r = snprintf(droot, sizeof(droot), "/%s/", c->document_root); + if (r < 0 || (size_t)r >= sizeof(droot)) + return got_error(GOT_ERR_NO_SPACE); + } else + strlcpy(droot, "/", sizeof(droot)); - if (asprintf(&title, "%s\n", srv->site_name) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - if (asprintf(&css, - "\n", - droot, srv->custom_css) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - if (asprintf(&gotlink, "", - srv->logo_url) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - if (asprintf(&gotimg, "", - droot, srv->logo) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - if (asprintf(&sitelink, "%s", c->document_root, qs->index_page, - srv->site_link) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); - goto done; - } - if (asprintf(&summlink, "%s", c->document_root, - qs->index_page, qs->path, qs->path) == -1) { - error = got_error_from_errno2("%s: asprintf", __func__); + r = fcgi_printf(c, "\n" + "\n" + "\n" + "%s\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "
\n" + "\n" /* #header */ + "
\n" + "\n" /* #content */ + "
\n" /* #gw_body */ + "\n\n", siteowner); + + free(escaped_owner); + return NULL; } static const struct got_error * @@ -863,12 +779,11 @@ gotweb_render_navs(struct request *c) struct querystring *qs = t->qs; struct server *srv = c->srv; char *nhref = NULL, *phref = NULL; - int disp = 0; + int r, disp = 0; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n\n"); /* #nav_next */ + fcgi_printf(c, "
\n"); /* #np_wrapper */ done: free(t->next_id); t->next_id = NULL; @@ -1034,10 +944,14 @@ gotweb_render_index(struct request *c) struct repo_dir *repo_dir = NULL; DIR *d; struct dirent **sd_dent; + const char *index_page_str; char *c_path = NULL; struct stat st; unsigned int d_cnt, d_i, d_disp = 0; + int r; + index_page_str = qs->index_page_str ? qs->index_page_str : ""; + d = opendir(srv->repos_path); if (d == NULL) { error = got_error_from_errno2("opendir", srv->repos_path); @@ -1069,24 +983,24 @@ gotweb_render_index(struct request *c) c_path = NULL; } - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Project
\n"); + if (r == -1) goto done; - if (fcgi_gen_response(c, - "
Project
\n") == -1) - goto done; + if (srv->show_repo_description) - if (fcgi_gen_response(c, "
" + if (fcgi_printf(c, "
" "Description
\n") == -1) goto done; if (srv->show_repo_owner) - if (fcgi_gen_response(c, "
" + if (fcgi_printf(c, "
" "Owner
\n") == -1) goto done; if (srv->show_repo_age) - if (fcgi_gen_response(c, "
" + if (fcgi_printf(c, "
" "Last Change
\n") == -1) goto done; - if (fcgi_gen_response(c, "
\n") == -1) + if (fcgi_printf(c, "
\n") == -1) /* #index_header */ goto done; for (d_i = 0; d_i < d_cnt; d_i++) { @@ -1127,149 +1041,69 @@ gotweb_render_index(struct request *c) render: d_disp++; t->prev_disp++; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, "\n" + "", /* .index_project */ + index_page_str, repo_dir->name, + repo_dir->name); + if (r == -1) goto done; - if (fcgi_gen_response(c, qs->index_page_str) == -1) - goto done; - if (fcgi_gen_response(c, "&path=") == -1) - goto done; - if (fcgi_gen_response(c, repo_dir->name) == -1) - goto done; - if (fcgi_gen_response(c, "&action=summary'>") == -1) - goto done; - if (fcgi_gen_response(c, repo_dir->name) == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (srv->show_repo_description) { - if (fcgi_gen_response(c, - "
\n") == -1) + r = fcgi_printf(c, + "
\n" + "%s
\n", repo_dir->description); + if (r == -1) goto done; - if (fcgi_gen_response(c, repo_dir->description) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; } if (srv->show_repo_owner) { - if (fcgi_gen_response(c, - "
") == -1) + r = fcgi_printf(c, "
" + "%s
\n", repo_dir->owner); + if (r == -1) goto done; - if (fcgi_gen_response(c, repo_dir->owner) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; } if (srv->show_repo_age) { - if (fcgi_gen_response(c, - "
") == -1) + r = fcgi_printf(c, "
" + "%s
\n", repo_dir->age); + if (r == -1) goto done; - if (fcgi_gen_response(c, repo_dir->age) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; } - if (fcgi_gen_response(c, "\n", /* .index_wrapper */ + index_page_str, repo_dir->name, + index_page_str, repo_dir->name, + index_page_str, repo_dir->name, + index_page_str, repo_dir->name, + index_page_str, repo_dir->name); + if (r == -1) goto done; - if (fcgi_gen_response(c, qs->index_page_str) == -1) - goto done; - if (fcgi_gen_response(c, "&path=") == -1) - goto done; - if (fcgi_gen_response(c, repo_dir->name) == -1) - goto done; - if (fcgi_gen_response(c, "&action=summary'>") == -1) - goto done; - if (fcgi_gen_response(c, "summary") == -1) - goto done; - if (fcgi_gen_response(c, " | ") == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "commit briefs") == -1) - goto done; - if (fcgi_gen_response(c, " | ") == -1) - goto done; - - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "commits") == -1) - goto done; - if (fcgi_gen_response(c, " | ") == -1) - goto done; - - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "tags") == -1) - goto done; - if (fcgi_gen_response(c, " | ") == -1) - goto done; - - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "tree") == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - gotweb_free_repo_dir(repo_dir); repo_dir = NULL; error = got_repo_close(t->repo); @@ -1280,18 +1114,16 @@ render: break; } if (srv->max_repos_display == 0) - goto div; + goto done; if (srv->max_repos > 0 && srv->max_repos < srv->max_repos_display) - goto div; + goto done; if (t->repos_total <= srv->max_repos || t->repos_total <= srv->max_repos_display) - goto div; + goto done; error = gotweb_render_navs(c); if (error) goto done; -div: - fcgi_gen_response(c, "
\n"); done: if (d != NULL && closedir(d) == EOF && error == NULL) error = got_error_from_errno("closedir"); @@ -1305,6 +1137,7 @@ gotweb_render_blame(struct request *c) struct transport *t = c->t; struct repo_commit *rc = NULL; char *age = NULL; + int r; error = got_get_repo_commits(c, 1); if (error) @@ -1316,58 +1149,32 @@ gotweb_render_blame(struct request *c) if (error) goto done; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Blame
\n" + "
\n" /* #blame_title_wrapper */ + "
\n" + "
\n" + "
\n" + "
Date:
\n" + "
%s
\n" + "
Message:
\n" + "
%s
\n" + "
\n" /* #blame_header */ + "
\n" /* #blame_header_wrapper */ + "
\n" + "
\n", + age ? age : "", + rc->commit_msg); + if (r == -1) goto done; - if (fcgi_gen_response(c, "
Blame
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Date:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Message:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_msg) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - error = got_output_file_blame(c); if (error) goto done; - fcgi_gen_response(c, "
\n"); + fcgi_printf(c, "
\n" /* #blame */ + "
\n"); /* #blame_content */ done: - fcgi_gen_response(c, "
\n"); return error; } @@ -1380,18 +1187,18 @@ gotweb_render_briefs(struct request *c) struct transport *t = c->t; struct querystring *qs = t->qs; struct repo_dir *repo_dir = t->repo_dir; + const char *index_page_str; char *smallerthan, *newline; char *age = NULL; + int r; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, - "
Commit Briefs
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; + index_page_str = qs->index_page_str ? qs->index_page_str : ""; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Commit Briefs
\n" + "
\n" /* #briefs_title_wrapper */ + "
\n"); + if (r == -1) goto done; if (qs->action == SUMMARY) { @@ -1406,123 +1213,52 @@ gotweb_render_briefs(struct request *c) error = gotweb_get_time_str(&age, rc->committer_time, TM_DIFF); if (error) goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; smallerthan = strchr(rc->author, '<'); if (smallerthan) *smallerthan = '\0'; - if (fcgi_gen_response(c, rc->author) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; newline = strchr(rc->commit_msg, '\n'); if (newline) *newline = '\0'; - if (fcgi_gen_response(c, "%s
\n" + "
%s
\n" + "
" + "%s", + age ? age : "", + rc->author, + index_page_str, repo_dir->name, rc->commit_id, qs->headref, + rc->commit_msg); + if (r == -1) goto done; - if (fcgi_gen_response(c, qs->index_page_str) == -1) - goto done; - if (fcgi_gen_response(c, "&path=") == -1) - goto done; - if (fcgi_gen_response(c, repo_dir->name) == -1) - goto done; - if (fcgi_gen_response(c, "&action=diff&commit=") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_id) == -1) - goto done; - if (fcgi_gen_response(c, "&headref=") == -1) - goto done; - if (fcgi_gen_response(c, qs->headref) == -1) - goto done; - if (fcgi_gen_response(c, "'>") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_msg) == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; + if (rc->refs_str) { - if (fcgi_gen_response(c, - " (") == -1) + r = fcgi_printf(c, + " (%s)", + rc->refs_str); + if (r == -1) goto done; - if (fcgi_gen_response(c, rc->refs_str) == -1) - goto done; - if (fcgi_gen_response(c, ")") == -1) - goto done; } - if (fcgi_gen_response(c, "
\n") == -1) + if (fcgi_printf(c, "
\n") == -1) /* .briefs_log */ goto done; - if (fcgi_gen_response(c, "\n") == -1) - goto done; - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - free(age); age = NULL; } @@ -1532,7 +1268,7 @@ gotweb_render_briefs(struct request *c) if (error) goto done; } - fcgi_gen_response(c, "
\n"); + fcgi_printf(c, "
\n"); /* #briefs_content */ done: free(age); return error; @@ -1547,18 +1283,17 @@ gotweb_render_commits(struct request *c) struct transport *t = c->t; struct querystring *qs = t->qs; struct repo_dir *repo_dir = t->repo_dir; + const char *index_page_str; char *age = NULL, *author = NULL; - /* int commit_found = 0; */ + int r; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, - "
Commits
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; + index_page_str = qs->index_page_str ? qs->index_page_str : ""; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Commits
\n" + "
\n" /* .commits_title_wrapper */ + "
\n"); + if (r == -1) goto done; error = got_get_repo_commits(c, srv->max_commits_display); @@ -1571,115 +1306,40 @@ gotweb_render_commits(struct request *c) goto done; error = gotweb_escape_html(&author, rc->author); if (error) - goto done; - - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - - if (fcgi_gen_response(c, "
Commit:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_id) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Author:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, author ? author : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Date:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, rc->commit_msg) == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) goto done; - if (fcgi_gen_response(c, "\n") == -1) - goto done; - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; free(age); age = NULL; free(author); @@ -1691,8 +1351,7 @@ gotweb_render_commits(struct request *c) if (error) goto done; } - if (fcgi_gen_response(c, "
\n") == -1) - goto done; + fcgi_printf(c, "
\n"); /* .commits_content */ done: free(age); return error; @@ -1707,8 +1366,12 @@ gotweb_render_branches(struct request *c) struct transport *t = c->t; struct querystring *qs = t->qs; struct got_repository *repo = t->repo; + const char *index_page_str; char *age = NULL; + int r; + index_page_str = qs->index_page_str ? qs->index_page_str : ""; + TAILQ_INIT(&refs); error = got_ref_list(&refs, repo, "refs/heads", @@ -1716,17 +1379,13 @@ gotweb_render_branches(struct request *c) if (error) goto done; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Branches
\n" + "
\n" /* #branches_title_wrapper */ + "
\n"); + if (r == -1) goto done; - if (fcgi_gen_response(c, - "
Branches
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - TAILQ_FOREACH(re, &refs, entry) { char *refname = NULL; @@ -1749,132 +1408,41 @@ gotweb_render_branches(struct request *c) if (strncmp(refname, "refs/heads/", 11) == 0) refname += 11; - if (fcgi_gen_response(c, "
") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, " ") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, refname) == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "\n") == -1) - goto done; - - if (fcgi_gen_response(c, - "
\n") == -1) - goto done; - - /* branches_wrapper */ - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - free(age); age = NULL; } - fcgi_gen_response(c, "
\n"); + fcgi_printf(c, "
\n"); /* #branches_content */ done: return error; } @@ -1886,6 +1454,7 @@ gotweb_render_tree(struct request *c) struct transport *t = c->t; struct repo_commit *rc = NULL; char *age = NULL; + int r; error = got_get_repo_commits(c, 1); if (error) @@ -1897,67 +1466,34 @@ gotweb_render_tree(struct request *c) if (error) goto done; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Tree
\n" + "
\n" /* #tree_title_wrapper */ + "
\n" + "
\n" + "
\n" + "
Tree:
\n" + "
%s
\n" + "
Date:
\n" + "
%s
\n" + "
Message:
\n" + "
%s
\n" + "
\n" /* #tree_header */ + "
\n" /* #tree_header_wrapper */ + "
\n" + "
\n", + rc->tree_id, + age ? age : "", + rc->commit_msg); + if (r == -1) goto done; - if (fcgi_gen_response(c, "
Tree
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Tree:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->tree_id) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Date:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Message:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_msg) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - error = got_output_repo_tree(c); if (error) goto done; - fcgi_gen_response(c, "
\n"); - fcgi_gen_response(c, "
\n"); + fcgi_printf(c, "
\n"); /* #tree */ + fcgi_printf(c, "
\n"); /* #tree_content */ done: return error; } @@ -1969,6 +1505,7 @@ gotweb_render_diff(struct request *c) struct transport *t = c->t; struct repo_commit *rc = NULL; char *age = NULL, *author = NULL; + int r; error = got_get_repo_commits(c, 1); if (error) @@ -1981,103 +1518,46 @@ gotweb_render_diff(struct request *c) goto done; error = gotweb_escape_html(&author, rc->author); if (error) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, - "
Commit Diff
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Diff:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->parent_id) == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_id) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Commit:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_id) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Tree:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->tree_id) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Author:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, author ? author : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Date:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Message:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rc->commit_msg) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Commit Diff
\n" + "
\n" /* #diff_title_wrapper */ + "
\n" + "
\n" + "
\n" + "
Diff:
\n" + "
%s
%s
\n" + "
Commit:
\n" + "
%s
\n" + "
Tree:
\n" + "
%s
\n" + "
Author:
\n" + "
%s
\n" + "
Date:
\n" + "
%s
\n" + "
Message:
\n" + "
%s
\n" + "
\n" /* #diff_header */ + "
\n" /* #diff_header_wrapper */ + "
\n" + "
\n", + rc->parent_id, rc->commit_id, + rc->commit_id, + rc->tree_id, + author ? author : "", + age ? age : "", + rc->commit_msg); + if (r == -1) goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; error = got_output_repo_diff(c); if (error) goto done; - fcgi_gen_response(c, "
\n"); + fcgi_printf(c, "
\n"); /* #diff */ + fcgi_printf(c, "
\n"); /* #diff_content */ done: - fcgi_gen_response(c, "
\n"); free(age); free(author); return error; @@ -2089,66 +1569,50 @@ gotweb_render_summary(struct request *c) const struct got_error *error = NULL; struct transport *t = c->t; struct server *srv = c->srv; + int r; - if (fcgi_gen_response(c, "
\n") == -1) + if (fcgi_printf(c, "
\n") == -1) goto done; - if (!srv->show_repo_description) - goto owner; + if (srv->show_repo_description) { + r = fcgi_printf(c, + "
Description:
\n" + "
%s
\n", + t->repo_dir->description); + if (r == -1) + goto done; + } - if (fcgi_gen_response(c, "
" - "Description:
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, t->repo_dir->description) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; -owner: - if (!srv->show_repo_owner) - goto last_change; + if (srv->show_repo_owner) { + r = fcgi_printf(c, + "
Owner:
\n" + "
%s
\n", + t->repo_dir->owner); + if (r == -1) + goto done; + } - if (fcgi_gen_response(c, "
" - "Owner:
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, t->repo_dir->owner) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; -last_change: - if (!srv->show_repo_age) - goto clone_url; + if (srv->show_repo_age) { + r = fcgi_printf(c, + "
Last Change:
\n" + "
%s
\n", + t->repo_dir->age); + if (r == -1) + goto done; + } - if (fcgi_gen_response(c, "
" - "Last Change:
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, t->repo_dir->age) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; -clone_url: - if (!srv->show_repo_cloneurl) - goto content; + if (srv->show_repo_cloneurl) { + r = fcgi_printf(c, + "
Clone URL:
\n" + "
%s
\n", + t->repo_dir->url ? t->repo_dir->url : ""); + if (r == -1) + goto done; + } - if (fcgi_gen_response(c, "
" - "Clone URL:
\n") == -1) + r = fcgi_printf(c, "
\n"); /* #summary_wrapper */ + if (r == -1) goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, t->repo_dir->url) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; -content: - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "\n") == -1) - goto done; error = gotweb_render_briefs(c); if (error) { @@ -2196,84 +1660,35 @@ gotweb_render_tag(struct request *c) if (error) goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
Tag
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Commit:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rt->commit_id) == -1) - goto done; - if (strncmp(rt->tag_name, "refs/", 5) == 0) rt->tag_name += 5; - if (fcgi_gen_response(c, " (") == -1) - goto done; - if (fcgi_gen_response(c, rt->tag_name) == -1) - goto done; - if (fcgi_gen_response(c, ")") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Tagger:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, author ? author : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Date:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
Message:" - "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, rt->commit_msg) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, rt->tag_commit) == -1) - goto done; + fcgi_printf(c, "
\n" + "
Tag
\n" + "
\n" /* #tags_title_wrapper */ + "
\n" + "
\n" + "
\n" + "
Commit:
\n" + "
%s" + " (%s)
\n" + "
Tagger:
\n" + "
%s
\n" + "
Date:
\n" + "
%s
\n" + "
Message:
\n" + "
%s
\n" + "
\n" /* #tag_header */ + "
\n" + "
\n%s
" + "
", /* tag_header_wrapper */ + rt->commit_id, + rt->tag_name, + author ? author : "", + age ? age : "", + rt->commit_msg, + rt->tag_commit); - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - fcgi_gen_response(c, "
\n"); done: free(age); free(author); @@ -2289,10 +1704,13 @@ gotweb_render_tags(struct request *c) struct transport *t = c->t; struct querystring *qs = t->qs; struct repo_dir *repo_dir = t->repo_dir; + const char *index_page_str; char *newline; char *age = NULL; - int commit_found = 0; + int r, commit_found = 0; + index_page_str = qs->index_page_str ? qs->index_page_str : ""; + if (qs->action == BRIEFS) { qs->action = TAGS; error = got_get_repo_tags(c, D_MAXSLCOMMDISP); @@ -2301,27 +1719,18 @@ gotweb_render_tags(struct request *c) if (error) goto done; - if (fcgi_gen_response(c, "
\n") == -1) + r = fcgi_printf(c, "
\n" + "
Tags
\n" + "
\n" /* #tags_title_wrapper */ + "
\n"); + if (r == -1) goto done; - if (fcgi_gen_response(c, - "
Tags
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (t->tag_count == 0) { - if (fcgi_gen_response(c, "
") == -1) + r = fcgi_printf(c, "
%s\n
\n", + "This repository contains no tags"); + if (r == -1) goto done; - if (fcgi_gen_response(c, - "This repository contains no tags\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; } TAILQ_FOREACH(rt, &t->repo_tags, entry) { @@ -2334,126 +1743,43 @@ gotweb_render_tags(struct request *c) error = gotweb_get_time_str(&age, rt->tagger_time, TM_DIFF); if (error) goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; - if (fcgi_gen_response(c, age ? age : "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; if (strncmp(rt->tag_name, "refs/tags/", 10) == 0) rt->tag_name += 10; - if (fcgi_gen_response(c, rt->tag_name) == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - if (fcgi_gen_response(c, "
") == -1) - goto done; if (rt->tag_commit != NULL) { newline = strchr(rt->tag_commit, '\n'); if (newline) *newline = '\0'; } - if (fcgi_gen_response(c, "") == -1) - goto done; - if (rt->tag_commit != NULL && - fcgi_gen_response(c, rt->tag_commit) == -1) - goto done; - if (fcgi_gen_response(c, "") == -1) - goto done; - if (fcgi_gen_response(c, "
\n") == -1) - goto done; - - if (fcgi_gen_response(c, "\n") == -1) - goto done; - if (fcgi_gen_response(c, - "
\n") == -1) + r = fcgi_printf(c, "
%s
\n" + "
%s
\n" + "
" + "" + "%s" + "
\n" /* .tag_log */ + "\n" /* .navs_wrapper */ + "
\n", + age ? age : "", + rt->tag_name, + index_page_str, repo_dir->name, rt->commit_id, + rt->tag_commit ? rt->tag_commit : "", + index_page_str, repo_dir->name, rt->commit_id, + index_page_str, repo_dir->name, rt->commit_id, + index_page_str, repo_dir->name, rt->commit_id); + if (r == -1) goto done; free(age); @@ -2464,7 +1790,7 @@ gotweb_render_tags(struct request *c) if (error) goto done; } - fcgi_gen_response(c, "
\n"); + fcgi_printf(c, "
\n"); /* #tags_content */ done: free(age); return error; blob - 71be6a49025d52f2768a5f9a8f625964d6a23e38 blob + d908471eeceff6cfcb6cf32db263b9fc5e018ba4 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -427,7 +427,9 @@ void fcgi_timeout(int, short, void *); void fcgi_cleanup_request(struct request *); void fcgi_create_end_record(struct request *); void dump_fcgi_record(const char *, struct fcgi_record_header *); -int fcgi_gen_response(struct request *, const char *); +int fcgi_printf(struct request *, const char *, ...) + __attribute__((__format__(printf, 2, 3))) + __attribute__((__nonnull__(2))); int fcgi_gen_binary_response(struct request *, const uint8_t *, int); /* got_operations.c */