diff options
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | README.md | 23 | ||||
-rw-r--r-- | images/image.png | bin | 0 -> 4185545 bytes | |||
-rw-r--r-- | logo.png | bin | 0 -> 37120 bytes | |||
-rw-r--r-- | ouija.c | 6 | ||||
-rw-r--r-- | session.c | 22 | ||||
-rw-r--r-- | utils.c | 17 | ||||
-rw-r--r-- | utils.h | 3 |
8 files changed, 70 insertions, 16 deletions
@@ -1,8 +1,13 @@ build: clean - gcc -o ouija ouija.c session.c utils.c - -debug: clean - gcc -g -o ouija ouija.c session.c utils.c + cc -o ouija ouija.c session.c utils.c clean: - rm -rf ouija + rm -rf ouija + +install: build + mkdir -p /usr/local/bin + cp -f ouija /usr/local/bin + chmod 755 /usr/local/bin + +uninstall: + rm -rf /usr/local/bin/ouija @@ -1,2 +1,25 @@ # Ouija Board +Just a ouija board based on time and question randomness +## Inspiration +Inspired by Terry Davis TempleOS Timer Random Tongues which he used to communicate with God. + +Since TRT was written in HolyC and this random word generator is written in C I decided to call it a Ouija Board. + +![TempleOS Timer Random Tongues](images/image.png) + +## How to Use + +### Compile +#### Portable +`make` + +#### Installable +`make install` + +### Run +If you already have a `dictionary.dict` file in your path, just run: +`ouija` + +If you have the file saved in another folder, just type: +`ouija /path/to/dictionary` diff --git a/images/image.png b/images/image.png Binary files differnew file mode 100644 index 0000000..34e58e0 --- /dev/null +++ b/images/image.png diff --git a/logo.png b/logo.png Binary files differnew file mode 100644 index 0000000..8681e3b --- /dev/null +++ b/logo.png @@ -1,6 +1,6 @@ -#include "session.h" #include <stdio.h> #include <stdlib.h> +#include "session.h" int main(int argc, char **argv) { @@ -27,6 +27,10 @@ int main(int argc, char **argv) startSession(dictionary); fclose(dictionary); } + else + { + printf("No Dictionary Found\n"); + } return 0; } @@ -8,15 +8,25 @@ void startSession(FILE *dictionary) if ( dictionary != NULL ) { int totalWords = lineCounter(dictionary); - char *word; + char *word, *question = (char *) calloc(MAX_LINE, sizeof(char));; char reload = '\0'; - while( reload != 'q' ) + printf("WELCOME\n" + "Type GOODBYE to exit\n\n"); + + while( strcmp(question, "GOODBYE\n") != 0 ) { - word = getLine(dictionary, getRandomNumber(1, totalWords)); - printf("%s", word); - free(word); - reload = getchar(); + printf("Enter a question: "); + fgets(question, MAX_LINE, stdin); + + if ( strcmp(question, "GOODBYE\n") != 0 ) + { + word = getLine(dictionary, getRandomNumber(1, totalWords, question)); + printf("-> %s", word); + free(word); + } } + + free(question); } } @@ -1,7 +1,8 @@ #include <stdio.h> -#include <unistd.h> #include <stdlib.h> +#include <string.h> #include <time.h> +#include <unistd.h> #include <sys/time.h> #include "utils.h" @@ -10,6 +11,16 @@ int checkIfFileExists(char *path) return access(path, F_OK); } +int numerize(char *string) +{ + int val = 0; + for( int i = 0; i < strlen(string); i++ ) + { + val += string[i]; + } + return val; +} + int lineCounter(FILE *dictionary) { int words = 0; @@ -41,12 +52,12 @@ char* getLine(FILE *dictionary, int lineNumber) return line; } -int getRandomNumber(int min, int max) +int getRandomNumber(int min, int max, char *question) { // Adding Randomize Time Values for Less Chances of Running into Seed Collisions struct timeval randtime; gettimeofday(&randtime,NULL); - srand((randtime.tv_sec * 100 + time(NULL)) + (randtime.tv_usec / 100 - time(NULL))); + srand(((randtime.tv_sec * 100) + time(NULL) * numerize(question)) + ((randtime.tv_usec / 100) - time(NULL) * numerize(question))); return ((rand() % (max - min + 1)) + 1); } @@ -3,6 +3,7 @@ #define MAX_LINE 256 int checkIfFileExists(char *path); +int numerize(char *string); int lineCounter(FILE *dictionary); char* getLine(FILE *dictionary, int line); -int getRandomNumber(int min, int max); +int getRandomNumber(int min, int max, char *question); |