plugins for wvkbd using swipeGuess
Diffstat (limited to 'quick5.c')
-rw-r--r--quick5.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/quick5.c b/quick5.c
new file mode 100644
index 0000000..7391a77
--- /dev/null
+++ b/quick5.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <ctype.h>
+#include <string.h>
+
+#define BUFSIZE 1024
+char wordBuff[BUFSIZE];
+
+// fgets, but without the newline/tab.
+char *fgetst(char *restrict s, int size, FILE *restrict stream) {
+ char *r = fgets(s, size, stream);
+ if (r) {
+ char * sp = s;
+ for(; sp[0] != '\0'; sp++) {
+ if (sp[0] == '\n' || sp[0] == '\t') {
+ sp[0] = '\0';
+ }
+ }
+ }
+ return r;
+}
+
+bool strdif(char* a, char* b) {
+ for (;a[0];) {
+ if (tolower(a[0]) != tolower(b[0])){
+ return true;
+ }
+ a++;
+ b++;
+ if (!b[0])return true;
+ }
+ return false;
+}
+
+int main(int argc, char **argv) {
+ if(argc!=2)return 1;
+ int found = 0;
+ size_t len = strlen(argv[1]);
+
+ while (found < 5 && fgetst(wordBuff, BUFSIZE, stdin)) {
+ if (!strdif(argv[1], wordBuff)) {
+ if (found > 0) printf("\t");
+ printf("%s", wordBuff+len);
+ found++;
+ }
+ }
+ printf("\n");
+ return 0;
+}