summaryrefslogtreecommitdiffstats
path: root/src/search.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/search.c b/src/search.c
new file mode 100644
index 0000000..cf2eab9
--- /dev/null
+++ b/src/search.c
@@ -0,0 +1,19 @@
+#include "util.h"
+#include "search.h"
+
+/**
+ * Query recipe `r` for input `s` and return 1 if found 0 otherwise
+ */
+int
+query_for_items(const recipe * r, const char * s, int strict)
+{
+ for (int i = 0; i < r->in; i++)
+ if (strict) {
+ if (!strcmp(r->i[i]->name, s))
+ return 1;
+ } else {
+ if (strstr(r->i[i]->name, s) != NULL)
+ return 1;
+ }
+ return 0;
+}