diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 11 |
1 files changed, 8 insertions, 3 deletions
| @@ -2491,9 +2491,12 @@ void notify_clear(snac *snac) | |||
| 2491 | 2491 | ||
| 2492 | /** searches **/ | 2492 | /** searches **/ |
| 2493 | 2493 | ||
| 2494 | xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, int *timeout) | 2494 | xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, int max_res, 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 | if (regex == NULL || *regex == '\0') | ||
| 2498 | return xs_list_new(); | ||
| 2499 | |||
| 2497 | xs_set seen; | 2500 | xs_set seen; |
| 2498 | 2501 | ||
| 2499 | xs_set_init(&seen); | 2502 | xs_set_init(&seen); |
| @@ -2517,7 +2520,7 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i | |||
| 2517 | xs_list_next(pub_tl, &pub_md5, &pub_c); | 2520 | xs_list_next(pub_tl, &pub_md5, &pub_c); |
| 2518 | xs_list_next(priv_tl, &priv_md5, &priv_c); | 2521 | xs_list_next(priv_tl, &priv_md5, &priv_c); |
| 2519 | 2522 | ||
| 2520 | for (;;) { | 2523 | while (max_res > 0) { |
| 2521 | char *md5 = NULL; | 2524 | char *md5 = NULL; |
| 2522 | enum { NONE, PUBLIC, PRIVATE } from = NONE; | 2525 | enum { NONE, PUBLIC, PRIVATE } from = NONE; |
| 2523 | 2526 | ||
| @@ -2587,8 +2590,10 @@ xs_list *content_search(snac *user, const char *regex, int priv, int max_secs, i | |||
| 2587 | /* apply regex */ | 2590 | /* apply regex */ |
| 2588 | xs *l = xs_regex_select_n(c, regex, 1); | 2591 | xs *l = xs_regex_select_n(c, regex, 1); |
| 2589 | 2592 | ||
| 2590 | if (xs_list_len(l)) | 2593 | if (xs_list_len(l)) { |
| 2591 | xs_set_add(&seen, md5); | 2594 | xs_set_add(&seen, md5); |
| 2595 | max_res--; | ||
| 2596 | } | ||
| 2592 | } | 2597 | } |
| 2593 | 2598 | ||
| 2594 | return xs_set_result(&seen); | 2599 | return xs_set_result(&seen); |