mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
Use MD5_HEX_SIZE in more places.
This commit is contained in:
parent
c06132579c
commit
de628c5f33
3 changed files with 12 additions and 14 deletions
18
data.c
18
data.c
|
@ -541,17 +541,15 @@ int index_in(const char *fn, const char *id)
|
|||
}
|
||||
|
||||
|
||||
int index_first(const char *fn, char *line, int size)
|
||||
int index_first(const char *fn, char md5[MD5_HEX_SIZE])
|
||||
/* reads the first entry of an index */
|
||||
{
|
||||
FILE *f;
|
||||
int ret = 0;
|
||||
|
||||
if ((f = fopen(fn, "r")) != NULL) {
|
||||
flock(fileno(f), LOCK_SH);
|
||||
|
||||
if (fgets(line, size, f) != NULL) {
|
||||
line[MD5_HEX_SIZE - 1] = '\0';
|
||||
if (fread(md5, MD5_HEX_SIZE, 1, f)) {
|
||||
md5[MD5_HEX_SIZE - 1] = '\0';
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
|
@ -958,13 +956,13 @@ xs_list *object_announces(const char *id)
|
|||
}
|
||||
|
||||
|
||||
int object_parent(const char *md5, char *buf, int size)
|
||||
int object_parent(const char *md5, char parent[MD5_HEX_SIZE])
|
||||
/* returns the object parent, if any */
|
||||
{
|
||||
xs *fn = _object_fn_by_md5(md5, "object_parent");
|
||||
|
||||
fn = xs_replace_i(fn, ".json", "_p.idx");
|
||||
return index_first(fn, buf, size);
|
||||
return index_first(fn, parent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1268,15 +1266,15 @@ xs_list *timeline_top_level(snac *snac, const xs_list *list)
|
|||
|
||||
int c = 0;
|
||||
while (xs_list_next(list, &v, &c)) {
|
||||
char line[256] = "";
|
||||
char line[MD5_HEX_SIZE] = "";
|
||||
|
||||
strncpy(line, v, sizeof(line));
|
||||
|
||||
for (;;) {
|
||||
char line2[256];
|
||||
char line2[MD5_HEX_SIZE];
|
||||
|
||||
/* if it doesn't have a parent, use this */
|
||||
if (!object_parent(line, line2, sizeof(line2)))
|
||||
if (!object_parent(line, line2))
|
||||
break;
|
||||
|
||||
/* well, there is a parent... but is it here? */
|
||||
|
|
|
@ -2186,12 +2186,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
xs *des = xs_list_new();
|
||||
xs_list *p;
|
||||
const xs_str *v;
|
||||
char pid[64];
|
||||
char pid[MD5_HEX_SIZE];
|
||||
|
||||
/* build the [grand]parent list, moving up */
|
||||
strncpy(pid, id, sizeof(pid));
|
||||
|
||||
while (object_parent(pid, pid, sizeof(pid))) {
|
||||
while (object_parent(pid, pid)) {
|
||||
xs *m2 = NULL;
|
||||
|
||||
if (valid_status(timeline_get_by_md5(&snac1, pid, &m2))) {
|
||||
|
|
4
snac.h
4
snac.h
|
@ -100,7 +100,7 @@ double f_ctime(const char *fn);
|
|||
int index_add_md5(const char *fn, const char *md5);
|
||||
int index_add(const char *fn, const char *id);
|
||||
int index_gc(const char *fn);
|
||||
int index_first(const char *fn, char *buf, int size);
|
||||
int index_first(const char *fn, char md5[MD5_HEX_SIZE]);
|
||||
int index_len(const char *fn);
|
||||
xs_list *index_list(const char *fn, int max);
|
||||
int index_desc_next(FILE *f, char md5[MD5_HEX_SIZE]);
|
||||
|
@ -130,7 +130,7 @@ int object_announces_len(const char *id);
|
|||
xs_list *object_children(const char *id);
|
||||
xs_list *object_likes(const char *id);
|
||||
xs_list *object_announces(const char *id);
|
||||
int object_parent(const char *id, char *buf, int size);
|
||||
int object_parent(const char *md5, char parent[MD5_HEX_SIZE]);
|
||||
|
||||
int object_user_cache_add(snac *snac, const char *id, const char *cachedir);
|
||||
int object_user_cache_del(snac *snac, const char *id, const char *cachedir);
|
||||
|
|
Loading…
Reference in a new issue