From 52ba7f030ed50f22b7fbf437e83c9415ed0e91ed Mon Sep 17 00:00:00 2001 From: default Date: Wed, 8 May 2024 11:00:50 +0200 Subject: [PATCH] Renamed to content_search(). --- data.c | 2 +- main.c | 21 ++++++++++++++++++++- snac.h | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/data.c b/data.c index 82f36a4..e3292c8 100644 --- a/data.c +++ b/data.c @@ -2490,7 +2490,7 @@ void notify_clear(snac *snac) /** searches **/ -xs_list *search_by_content(snac *user, const xs_list *timeline, +xs_list *content_search(snac *user, const xs_list *timeline, const char *regex, int max_secs, int *timeout) /* returns a list of posts which content matches the regex */ { diff --git a/main.c b/main.c index 9244b5a..240e02e 100644 --- a/main.c +++ b/main.c @@ -380,7 +380,26 @@ int main(int argc, char *argv[]) int to; /* 'url' contains the regex */ - xs *r = search_by_content(&snac, tl, url, 10, &to); + xs *r = content_search(&snac, tl, url, 10, &to); + + int c = 0; + char *v; + + /* print results as standalone links */ + while (xs_list_next(r, &v, &c)) { + printf("%s/admin/p/%s\n", snac.actor, v); + } + + return 0; + } + + if (strcmp(cmd, "search2") == 0) { /** **/ + /* undocumented (for testing only) */ + xs *tl = timeline_simple_list(&snac, "public", 0, XS_ALL); + int to; + + /* 'url' contains the regex */ + xs *r = content_search(&snac, tl, url, 10, &to); int c = 0; char *v; diff --git a/snac.h b/snac.h index 7f069ab..e3b76f6 100644 --- a/snac.h +++ b/snac.h @@ -179,8 +179,8 @@ xs_list *list_timeline(snac *user, const char *list, int skip, int show); xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); void list_distribute(snac *user, const char *who, const xs_dict *post); -xs_list *search_by_content(snac *user, const xs_list *timeline, - const char *regex, int max_secs, int *timeout); +xs_list *content_search(snac *user, const xs_list *timeline, + const char *regex, int max_secs, int *timeout); int actor_add(const char *actor, xs_dict *msg); int actor_get(const char *actor, xs_dict **data);