jcs
/detritus
/amendments
/49
*: Use PAGE_CAN_READ_MORE macro in protocol handlers
page->request will not be null during a fetch but the connection is
done reading so use that as a hint that no more data is coming.
jcs made amendment 49 about 1 year ago
--- finger.c Thu Nov 14 22:57:44 2024
+++ finger.c Wed Nov 20 13:23:27 2024
@@ -48,7 +48,7 @@ finger_request_init(page_handle pageh)
char *output;
size_t output_len;
- if (page->uri->port = 0)
+ if (page->uri->port == 0)
page->uri->port = FINGER_PORT;
if (page->uri->path[0] == '\0' ||
@@ -86,7 +86,7 @@ finger_process(page_handle pageh)
bool ret = true;
if (page->content_pos == page->content_len)
- return (page->request != NULL);
+ return PAGE_CAN_READ_MORE(page);
if (page->content_pos == 0)
browser_commit_to_loading_page(page->browser);
@@ -114,7 +114,7 @@ finger_process(page_handle pageh)
}
}
- if (page->request == NULL && page->content_pos < page->content_len) {
+ if (!PAGE_CAN_READ_MORE(page) && page->content_pos < page->content_len) {
/* no request to fetch more content, finish */
browser_print(page->browser, page->content + page->content_pos,
page->content_len - page->content_pos, false);
--- gemini.c Fri Nov 15 11:43:02 2024
+++ gemini.c Wed Nov 20 13:22:54 2024
@@ -92,7 +92,7 @@ gemini_process(page_handle pageh)
bool newline, gemtext;
if (page->content_pos == page->content_len)
- return (page->request != NULL);
+ return PAGE_CAN_READ_MORE(page);
if (page->parse_state == PARSE_STATE_HEADER) {
for (n = page->content_pos; n < page->content_len; n++) {
@@ -143,7 +143,7 @@ gemini_process(page_handle pageh)
for (n = page->content_pos; n < page->content_len; n++) {
if (page->content[n] != '\n' &&
- !(n == page->content_len - 1 && page->request == NULL))
+ !(n == page->content_len - 1 && !PAGE_CAN_READ_MORE(page)))
continue;
len = n - page->content_pos + 1;
@@ -160,7 +160,7 @@ gemini_process(page_handle pageh)
len--;
trail++;
}
- } else if (page->request != NULL)
+ } else if (PAGE_CAN_READ_MORE(page))
/* no newline at the end and fetching, so wait for more data */
return true;
@@ -329,16 +329,13 @@ print_line:
page->content_pos += skip + len + trail;
}
- if (page->request == NULL && page->content_pos < page->content_len) {
+ if (!PAGE_CAN_READ_MORE(page) && page->content_pos < page->content_len) {
browser_print(page->browser, page->content + page->content_pos,
page->content_len - page->content_pos, false);
page->content_pos = page->content_len;
}
- if (page->content_pos == page->content_len)
- return (page->request != NULL);
-
- return true;
+ return PAGE_CAN_READ_MORE(page);
}
void
--- gopher.c Fri Nov 15 15:24:41 2024
+++ gopher.c Wed Nov 20 13:24:14 2024
@@ -158,7 +158,7 @@ gopher_process(page_handle pageh)
}
if (page->content_pos == page->content_len)
- return (page->request != NULL);
+ return PAGE_CAN_READ_MORE(page);
if (page->content_type[0] == '1') {
/* gopher menu */
@@ -172,7 +172,7 @@ gopher_process(page_handle pageh)
}
}
- if (page->request == NULL &&
+ if (!PAGE_CAN_READ_MORE(page) &&
page->content_pos < page->content_len) {
gopher_print_menu(page, page->content + page->content_pos,
page->content_len - page->content_pos);
@@ -201,7 +201,7 @@ gopher_process(page_handle pageh)
}
}
- if (page->request == NULL &&
+ if (!PAGE_CAN_READ_MORE(page) &&
page->content_pos < page->content_len) {
browser_print(page->browser, page->content + page->content_pos,
page->content_len - page->content_pos, false);