|
|
@ -161,7 +161,10 @@ static int write_zet_link(int fd, const char *id, const char *title) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int write_topbar(int fd, enum page page, const char *id, const char *title) {
|
|
|
|
static int write_topbar(int fd, enum page page, const char *id, const char *title) {
|
|
|
|
int rc = write_buf(fd, "<form action=\"search\">");
|
|
|
|
int rc = write_buf(fd,
|
|
|
|
|
|
|
|
"<table style=\"width:100%; border-collapse:collapse\"><tr>"
|
|
|
|
|
|
|
|
"<td style=\"padding:0\">"
|
|
|
|
|
|
|
|
"<form action=\"search\">");
|
|
|
|
|
|
|
|
|
|
|
|
rc |= write_buf(fd, " ");
|
|
|
|
rc |= write_buf(fd, " ");
|
|
|
|
if (page == PAGE_ALL) rc |= write_buf(fd, "<strong>");
|
|
|
|
if (page == PAGE_ALL) rc |= write_buf(fd, "<strong>");
|
|
|
@ -188,9 +191,14 @@ static int write_topbar(int fd, enum page page, const char *id, const char *titl
|
|
|
|
|
|
|
|
|
|
|
|
if (page == PAGE_ZET) {
|
|
|
|
if (page == PAGE_ZET) {
|
|
|
|
rc |= write_zet_link(fd, id, title);
|
|
|
|
rc |= write_zet_link(fd, id, title);
|
|
|
|
|
|
|
|
rc |= write_buf(fd, "</form></td>");
|
|
|
|
|
|
|
|
rc |= write_buf(fd, "<td style=\"text-align:right; padding:0;\">"
|
|
|
|
|
|
|
|
"<a href=\"?print\">print</a></td>");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
rc |= write_buf(fd, "</form></td>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rc |= write_buf(fd, "</form>");
|
|
|
|
rc |= write_buf(fd, "</tr></table>");
|
|
|
|
return rc;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -828,6 +836,11 @@ static int dpi_serve_zet(int fd, char *path) {
|
|
|
|
"</style>"
|
|
|
|
"</style>"
|
|
|
|
"</head>");
|
|
|
|
"</head>");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: iterate
|
|
|
|
|
|
|
|
bool print = query != NULL && strncmp(query, "print", 5) == 0
|
|
|
|
|
|
|
|
&& (query[5] == '\0' || query[5] == '&' ||
|
|
|
|
|
|
|
|
(query[5] == '=' && !(query[6] == '\0' || query[6] == '&')));
|
|
|
|
|
|
|
|
if (!print) {
|
|
|
|
rc |= write_buf(fd, "<body style=\"margin:0\">");
|
|
|
|
rc |= write_buf(fd, "<body style=\"margin:0\">");
|
|
|
|
rc |= write_topbar(fd, PAGE_ZET, id, title);
|
|
|
|
rc |= write_topbar(fd, PAGE_ZET, id, title);
|
|
|
|
rc |= dprintf(fd,
|
|
|
|
rc |= dprintf(fd,
|
|
|
@ -850,6 +863,9 @@ static int dpi_serve_zet(int fd, char *path) {
|
|
|
|
if (rc < 0) warnx("dprintf");
|
|
|
|
if (rc < 0) warnx("dprintf");
|
|
|
|
close(fd);
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
rc |= write_buf(fd, "<body>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *text = note_fd >= 0 ? read_full(note_fd) : NULL;
|
|
|
|
char *text = note_fd >= 0 ? read_full(note_fd) : NULL;
|
|
|
|
if (text == NULL) {
|
|
|
|
if (text == NULL) {
|
|
|
@ -882,11 +898,16 @@ static int dpi_serve_zet(int fd, char *path) {
|
|
|
|
rc = write_all(fd, ob->data, ob->size);
|
|
|
|
rc = write_all(fd, ob->data, ob->size);
|
|
|
|
if (rc < 0) warn("write_all");
|
|
|
|
if (rc < 0) warn("write_all");
|
|
|
|
bufrelease(ob);
|
|
|
|
bufrelease(ob);
|
|
|
|
|
|
|
|
if (!print) {
|
|
|
|
rc = dprintf(fd, "</td></tr>");
|
|
|
|
rc = dprintf(fd, "</td></tr>");
|
|
|
|
if (rc < 0) warn("dprintf");
|
|
|
|
if (rc < 0) warn("dprintf");
|
|
|
|
|
|
|
|
|
|
|
|
rc = dprintf(fd, "<tr><td></td><td>");
|
|
|
|
rc = dprintf(fd, "<tr><td></td><td>");
|
|
|
|
if (rc < 0) warn("dprintf");
|
|
|
|
if (rc < 0) warn("dprintf");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
rc = write_buf(fd, "<br>");
|
|
|
|
|
|
|
|
if (rc < 0) warn("write_all");
|
|
|
|
|
|
|
|
}
|
|
|
|
struct zet_search zs;
|
|
|
|
struct zet_search zs;
|
|
|
|
bool first = true;
|
|
|
|
bool first = true;
|
|
|
|
rc = zet_search_start(&zs, id, NULL);
|
|
|
|
rc = zet_search_start(&zs, id, NULL);
|
|
|
@ -916,12 +937,16 @@ static int dpi_serve_zet(int fd, char *path) {
|
|
|
|
rc |= write_buf(fd, "</a></li>");
|
|
|
|
rc |= write_buf(fd, "</a></li>");
|
|
|
|
} while (1);
|
|
|
|
} while (1);
|
|
|
|
if (!first) (void)dprintf(fd, "</ul>");
|
|
|
|
if (!first) (void)dprintf(fd, "</ul>");
|
|
|
|
|
|
|
|
if (!print) {
|
|
|
|
rc = dprintf(fd, "</td></tr>");
|
|
|
|
rc = dprintf(fd, "</td></tr>");
|
|
|
|
if (rc < 0) warn("dprintf");
|
|
|
|
if (rc < 0) warn("dprintf");
|
|
|
|
|
|
|
|
}
|
|
|
|
(void)zet_search_close(&zs);
|
|
|
|
(void)zet_search_close(&zs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!print) {
|
|
|
|
rc = write_buf(fd, "</table>");
|
|
|
|
rc = write_buf(fd, "</table>");
|
|
|
|
if (rc < 0) warn("write_buf");
|
|
|
|
if (rc < 0) warn("write_buf");
|
|
|
|
|
|
|
|
}
|
|
|
|
rc = write_buf(fd, "</body></html>");
|
|
|
|
rc = write_buf(fd, "</body></html>");
|
|
|
|
if (rc < 0) warn("write_buf");
|
|
|
|
if (rc < 0) warn("write_buf");
|
|
|
|
|
|
|
|
|
|
|
|