summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2024-05-08 10:27:30 +0200
committerGravatar default2024-05-08 10:27:30 +0200
commitdc74cac6c9c3f6e9edc848381422a1f124abac73 (patch)
treeafa60f85839300e03affa44ed792d79cbe9626cd /data.c
parentNew function search_by_content(). (diff)
downloadsnac2-dc74cac6c9c3f6e9edc848381422a1f124abac73.tar.gz
snac2-dc74cac6c9c3f6e9edc848381422a1f124abac73.tar.xz
snac2-dc74cac6c9c3f6e9edc848381422a1f124abac73.zip
Added a timeout flag to search_by_content().
Diffstat (limited to 'data.c')
-rw-r--r--data.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/data.c b/data.c
index bc9f979..82f36a4 100644
--- a/data.c
+++ b/data.c
@@ -2491,25 +2491,28 @@ void notify_clear(snac *snac)
2491/** searches **/ 2491/** searches **/
2492 2492
2493xs_list *search_by_content(snac *user, const xs_list *timeline, 2493xs_list *search_by_content(snac *user, const xs_list *timeline,
2494 const char *regex, 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{
2497 xs_list *r = xs_list_new(); 2497 xs_list *r = xs_list_new();
2498 2498
2499 if (timeout == 0) 2499 if (max_secs == 0)
2500 timeout = 3; 2500 max_secs = 3;
2501 2501
2502 int c = 0; 2502 int c = 0;
2503 char *v; 2503 char *v;
2504 2504
2505 time_t t = time(NULL) + timeout; 2505 time_t t = time(NULL) + max_secs;
2506 *timeout = 0;
2506 2507
2507 while (xs_list_next(timeline, &v, &c)) { 2508 while (xs_list_next(timeline, &v, &c)) {
2508 xs *post = NULL; 2509 xs *post = NULL;
2509 2510
2510 /* timeout? */ 2511 /* timeout? */
2511 if (time(NULL) > t) 2512 if (time(NULL) > t) {
2513 *timeout = 1;
2512 break; 2514 break;
2515 }
2513 2516
2514 int status; 2517 int status;
2515 2518