diff options
| author | 2024-05-08 11:00:50 +0200 | |
|---|---|---|
| committer | 2024-05-08 11:00:50 +0200 | |
| commit | 52ba7f030ed50f22b7fbf437e83c9415ed0e91ed (patch) | |
| tree | 83fa1f640cf4f4f9082074f499a31743ba46d134 | |
| parent | Added a timeout flag to search_by_content(). (diff) | |
| download | snac2-52ba7f030ed50f22b7fbf437e83c9415ed0e91ed.tar.gz snac2-52ba7f030ed50f22b7fbf437e83c9415ed0e91ed.tar.xz snac2-52ba7f030ed50f22b7fbf437e83c9415ed0e91ed.zip | |
Renamed to content_search().
| -rw-r--r-- | data.c | 2 | ||||
| -rw-r--r-- | main.c | 21 | ||||
| -rw-r--r-- | snac.h | 4 |
3 files changed, 23 insertions, 4 deletions
| @@ -2490,7 +2490,7 @@ void notify_clear(snac *snac) | |||
| 2490 | 2490 | ||
| 2491 | /** searches **/ | 2491 | /** searches **/ |
| 2492 | 2492 | ||
| 2493 | xs_list *search_by_content(snac *user, const xs_list *timeline, | 2493 | xs_list *content_search(snac *user, const xs_list *timeline, |
| 2494 | const char *regex, int max_secs, int *timeout) | 2494 | const char *regex, int max_secs, int *timeout) |
| 2495 | /* returns a list of posts which content matches the regex */ | 2495 | /* returns a list of posts which content matches the regex */ |
| 2496 | { | 2496 | { |
| @@ -380,7 +380,26 @@ int main(int argc, char *argv[]) | |||
| 380 | int to; | 380 | int to; |
| 381 | 381 | ||
| 382 | /* 'url' contains the regex */ | 382 | /* 'url' contains the regex */ |
| 383 | xs *r = search_by_content(&snac, tl, url, 10, &to); | 383 | xs *r = content_search(&snac, tl, url, 10, &to); |
| 384 | |||
| 385 | int c = 0; | ||
| 386 | char *v; | ||
| 387 | |||
| 388 | /* print results as standalone links */ | ||
| 389 | while (xs_list_next(r, &v, &c)) { | ||
| 390 | printf("%s/admin/p/%s\n", snac.actor, v); | ||
| 391 | } | ||
| 392 | |||
| 393 | return 0; | ||
| 394 | } | ||
| 395 | |||
| 396 | if (strcmp(cmd, "search2") == 0) { /** **/ | ||
| 397 | /* undocumented (for testing only) */ | ||
| 398 | xs *tl = timeline_simple_list(&snac, "public", 0, XS_ALL); | ||
| 399 | int to; | ||
| 400 | |||
| 401 | /* 'url' contains the regex */ | ||
| 402 | xs *r = content_search(&snac, tl, url, 10, &to); | ||
| 384 | 403 | ||
| 385 | int c = 0; | 404 | int c = 0; |
| 386 | char *v; | 405 | char *v; |
| @@ -179,8 +179,8 @@ xs_list *list_timeline(snac *user, const char *list, int skip, int show); | |||
| 179 | xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); | 179 | xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op); |
| 180 | void list_distribute(snac *user, const char *who, const xs_dict *post); | 180 | void list_distribute(snac *user, const char *who, const xs_dict *post); |
| 181 | 181 | ||
| 182 | xs_list *search_by_content(snac *user, const xs_list *timeline, | 182 | xs_list *content_search(snac *user, const xs_list *timeline, |
| 183 | const char *regex, int max_secs, int *timeout); | 183 | const char *regex, int max_secs, int *timeout); |
| 184 | 184 | ||
| 185 | int actor_add(const char *actor, xs_dict *msg); | 185 | int actor_add(const char *actor, xs_dict *msg); |
| 186 | int actor_get(const char *actor, xs_dict **data); | 186 | int actor_get(const char *actor, xs_dict **data); |