mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
Rewritten history_get() prototype to match static_get().
This commit is contained in:
parent
46cfc37f2b
commit
5de1a9ce0c
3 changed files with 14 additions and 15 deletions
13
data.c
13
data.c
|
@ -1681,18 +1681,23 @@ void history_add(snac *snac, const char *id, const char *content, int size)
|
|||
}
|
||||
|
||||
|
||||
xs_str *history_get(snac *snac, const char *id)
|
||||
int history_get(snac *snac, const char *id, xs_str **content, int *size,
|
||||
const char *inm, xs_str **etag)
|
||||
{
|
||||
xs_str *content = NULL;
|
||||
xs *fn = _history_fn(snac, id);
|
||||
FILE *f;
|
||||
int status = 404;
|
||||
|
||||
if (fn && (f = fopen(fn, "r")) != NULL) {
|
||||
content = xs_readall(f);
|
||||
*content = xs_readall(f);
|
||||
fclose(f);
|
||||
|
||||
*size = strlen(*content);
|
||||
|
||||
status = 200;
|
||||
}
|
||||
|
||||
return content;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
|
13
html.c
13
html.c
|
@ -1875,9 +1875,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||
if (cache && history_mtime(&snac, h) > timeline_mtime(&snac)) {
|
||||
snac_debug(&snac, 1, xs_fmt("serving cached local timeline"));
|
||||
|
||||
*body = history_get(&snac, h);
|
||||
*b_size = strlen(*body);
|
||||
status = 200;
|
||||
status = history_get(&snac, h, body, b_size, NULL, NULL);
|
||||
}
|
||||
else {
|
||||
xs *list = timeline_list(&snac, "public", skip, show);
|
||||
|
@ -1905,9 +1903,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||
if (cache && history_mtime(&snac, "timeline.html_") > timeline_mtime(&snac)) {
|
||||
snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
|
||||
|
||||
*body = history_get(&snac, "timeline.html_");
|
||||
*b_size = strlen(*body);
|
||||
status = 200;
|
||||
status = history_get(&snac, "timeline.html_", body, b_size, NULL, NULL);
|
||||
}
|
||||
else {
|
||||
snac_debug(&snac, 1, xs_fmt("building timeline"));
|
||||
|
@ -1996,10 +1992,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||
status = 404;
|
||||
}
|
||||
else
|
||||
if ((*body = history_get(&snac, id)) != NULL) {
|
||||
*b_size = strlen(*body);
|
||||
status = 200;
|
||||
}
|
||||
status = history_get(&snac, id, body, b_size, NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
3
snac.h
3
snac.h
|
@ -150,7 +150,8 @@ xs_str *static_get_meta(snac *snac, const char *id);
|
|||
|
||||
double history_mtime(snac *snac, const char *id);
|
||||
void history_add(snac *snac, const char *id, const char *content, int size);
|
||||
xs_str *history_get(snac *snac, const char *id);
|
||||
int history_get(snac *snac, const char *id, xs_str **content, int *size,
|
||||
const char *inm, xs_str **etag);
|
||||
int history_del(snac *snac, const char *id);
|
||||
xs_list *history_list(snac *snac);
|
||||
|
||||
|
|
Loading…
Reference in a new issue