summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-05-08 10:27:30 +0200
committerdefault <nobody@localhost>2024-05-08 10:27:30 +0200
commitdc74cac6c9c3f6e9edc848381422a1f124abac73 (patch)
treeafa60f85839300e03affa44ed792d79cbe9626cd /data.c
parent3ab733cdf5a71b9a27399e8336e0c236c13d67fb (diff)
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)
/** searches **/
xs_list *search_by_content(snac *user, const xs_list *timeline,
- const char *regex, int timeout)
+ const char *regex, int max_secs, int *timeout)
/* returns a list of posts which content matches the regex */
{
xs_list *r = xs_list_new();
- if (timeout == 0)
- timeout = 3;
+ if (max_secs == 0)
+ max_secs = 3;
int c = 0;
char *v;
- time_t t = time(NULL) + timeout;
+ time_t t = time(NULL) + max_secs;
+ *timeout = 0;
while (xs_list_next(timeline, &v, &c)) {
xs *post = NULL;
/* timeout? */
- if (time(NULL) > t)
+ if (time(NULL) > t) {
+ *timeout = 1;
break;
+ }
int status;