commit 33229bf

grunfink  ·  2026-09-10 15:54:22 +0000 UTC
parent 954f988
Moved words_in_content() to data.c.
3 files changed,  +26, -23
M data.c
M html.c
M snac.h
M data.c
+24, -0
 1@@ -15,6 +15,7 @@
 2 #include "xs_random.h"
 3 #include "xs_po.h"
 4 #include "xs_http.h"
 5+#include "xs_list_tools.h"
 6 
 7 #include "snac.h"
 8 
 9@@ -3418,6 +3419,29 @@ int grave(const char *objid, snac_op op)
10 }
11 
12 
13+const xs_str *words_in_content(const xs_list *words, const xs_val *content)
14+/* returns a word that matches any of the words in content */
15+{
16+    if (!xs_is_list(words) || !xs_is_string(content)) {
17+        return NULL;
18+    }
19+    xs *c = xs_split(content, " ");
20+    xs *sc = xs_list_sort(c, NULL);
21+
22+    const xs_str *wv;
23+    const xs_str *cv;
24+    xs_list_foreach(words, wv) {
25+        xs_list_foreach(sc, cv) {
26+            xs_tolower_i((xs_str*)cv);
27+            if(xs_str_in(cv, wv) != -1)
28+                return wv;
29+        }
30+    }
31+
32+    return NULL;
33+}
34+
35+
36 /** notifications **/
37 
38 xs_str *notify_check_time(snac *snac, int reset)
M html.c
+0, -23
 1@@ -2320,29 +2320,6 @@ xs_html *html_entry_controls(snac *user, const char *actor,
 2 }
 3 
 4 
 5-static const xs_str* words_in_content(const xs_list *words, const xs_val *content)
 6-/* returns a word that matches any of the words in content */
 7-{
 8-    if (!xs_is_list(words) || !xs_is_string(content)) {
 9-        return NULL;
10-    }
11-    xs *c = xs_split(content, " ");
12-    xs *sc = xs_list_sort(c, NULL);
13-
14-    const xs_str *wv;
15-    const xs_str *cv;
16-    xs_list_foreach(words, wv) {
17-        xs_list_foreach(sc, cv) {
18-            xs_tolower_i((xs_str*)cv);
19-            if(xs_str_in(cv, wv) != -1)
20-                return wv;
21-        }
22-    }
23-
24-    return NULL;
25-}
26-
27-
28 xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
29                    int level, const char *md5, int hide_children, int tb_friendly)
30 {
M snac.h
+2, -0
1@@ -316,6 +316,8 @@ int instance_failure(const char *url, snac_op op);
2 
3 int grave(const char *objid, snac_op op);
4 
5+const xs_str *words_in_content(const xs_list *words, const xs_val *content);
6+
7 void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
8 void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries);
9 void enqueue_output_raw(const char *keyid, const char *seckey,