summaryrefslogtreecommitdiffstats
path: root/src/search.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2021-12-20 22:52:48 +0200
committergramanas <anastasis.gramm2@gmail.com>2021-12-20 22:52:48 +0200
commitdbd6366285b23483567f2c1dc814fc9f371c4c64 (patch)
tree6df025dc5e668ddc618fddde289c4c2b1025e8dd /src/search.c
parentbf4733f991bb9e643ebc697d6f9f92b3bb6ad69c (diff)
downloadfoodtools-dbd6366285b23483567f2c1dc814fc9f371c4c64.tar.gz
foodtools-dbd6366285b23483567f2c1dc814fc9f371c4c64.tar.bz2
foodtools-dbd6366285b23483567f2c1dc814fc9f371c4c64.zip
merge steps
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;
+}