diff --git a/runner.c b/runner.c index e69de29..eee0d2b 100644 --- a/runner.c +++ b/runner.c @@ -0,0 +1,26 @@ +#include runner.h + +int main(int argc, char *argv[]) { + char *check_input; + + //check_input can be compared to INVALID_ARG and DIFF_ARG to determine if -tok and holds the generated file name if it is + check_input = is_tok(argc, argv); + + return 0; //not sure what to do yet +} + +char *is_tok(int argc, char *argv[]) { + if (argc == 3 && strcmp("-tok", argv[1])) { + char *input_prog = argv[2]; + int file_len = strlen(input); + //check that input program is a .alpha file + if (strcmp(".alpha", input_prog[file_len - ALPHA_OFFSET]) != 0) { + return INVALID_ARG; + } + char *FILE_tok[file_len - ALPHA_OFFSET + TOK_LEN]; + strncpy(input, FILE_tok, file_len - ALPHA_OFFSET); //copy name of prog before .alpha + strcpy(".tok", FILE_tok[file_len - ALPHA_OFFSET]); //add .tok to end of file name + return FILE_tok; + } + return DIFF_ARG; +} diff --git a/runner.h b/runner.h new file mode 100644 index 0000000..dff315f --- /dev/null +++ b/runner.h @@ -0,0 +1,8 @@ +#define ALPHA_OFFSET 5 +#define TOK_LEN 3 +#define INVALID_ARG "invalid" +#define DIFF_ARG "diff" +#include + +int main(int argc, char* argv); +char *is_tok(int argc, char* argv);