Преглед на файлове

Moved words_in_content() to data.c.

grunfink преди 1 седмица
родител
ревизия
33229bf858
променени са 3 файла, в които са добавени 26 реда и са изтрити 23 реда
  1. 24 0
      data.c
  2. 0 23
      html.c
  3. 2 0
      snac.h

+ 24 - 0
data.c

@@ -15,6 +15,7 @@
 #include "xs_random.h"
 #include "xs_po.h"
 #include "xs_http.h"
+#include "xs_list_tools.h"
 
 #include "snac.h"
 
@@ -3418,6 +3419,29 @@ int grave(const char *objid, snac_op op)
 }
 
 
+const xs_str *words_in_content(const xs_list *words, const xs_val *content)
+/* returns a word that matches any of the words in content */
+{
+    if (!xs_is_list(words) || !xs_is_string(content)) {
+        return NULL;
+    }
+    xs *c = xs_split(content, " ");
+    xs *sc = xs_list_sort(c, NULL);
+
+    const xs_str *wv;
+    const xs_str *cv;
+    xs_list_foreach(words, wv) {
+        xs_list_foreach(sc, cv) {
+            xs_tolower_i((xs_str*)cv);
+            if(xs_str_in(cv, wv) != -1)
+                return wv;
+        }
+    }
+
+    return NULL;
+}
+
+
 /** notifications **/
 
 xs_str *notify_check_time(snac *snac, int reset)

+ 0 - 23
html.c

@@ -2320,29 +2320,6 @@ xs_html *html_entry_controls(snac *user, const char *actor,
 }
 
 
-static const xs_str* words_in_content(const xs_list *words, const xs_val *content)
-/* returns a word that matches any of the words in content */
-{
-    if (!xs_is_list(words) || !xs_is_string(content)) {
-        return NULL;
-    }
-    xs *c = xs_split(content, " ");
-    xs *sc = xs_list_sort(c, NULL);
-
-    const xs_str *wv;
-    const xs_str *cv;
-    xs_list_foreach(words, wv) {
-        xs_list_foreach(sc, cv) {
-            xs_tolower_i((xs_str*)cv);
-            if(xs_str_in(cv, wv) != -1)
-                return wv;
-        }
-    }
-
-    return NULL;
-}
-
-
 xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
                    int level, const char *md5, int hide_children, int tb_friendly)
 {

+ 2 - 0
snac.h

@@ -316,6 +316,8 @@ int instance_failure(const char *url, snac_op op);
 
 int grave(const char *objid, snac_op op);
 
+const xs_str *words_in_content(const xs_list *words, const xs_val *content);
+
 void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
 void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries);
 void enqueue_output_raw(const char *keyid, const char *seckey,