diff options
author | Oskar <[email protected]> | 2023-10-27 23:04:22 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2023-10-27 23:04:22 +0200 |
commit | 2815c44224cdb99695248faadce10b1737f7c766 (patch) | |
tree | 8cd4ea572108fa15e1a6c07977a951fe77e02208 /test | |
parent | 37e748be88e6e72c37809018f9c163917d609cbd (diff) |
Minor changes to GET_LINE() , also did a little test to check if it worked like it should. Seems to be working...
Diffstat (limited to 'test')
-rw-r--r-- | test/testgetline.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/testgetline.c b/test/testgetline.c new file mode 100644 index 0000000..fb16c54 --- /dev/null +++ b/test/testgetline.c @@ -0,0 +1,44 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include "7ed.h" + +#define USAGE "" +#define PROGRAM_NAME "7ed" + +int main (int argc, char *argv[]) { + + +int opt; +int returnval; +long focus = 100; +char *line; +while ((opt = getopt(argc, argv, "i:")) != -1) { + switch (opt) { + + case 'i': + + returnval = GET_LINE(optarg, focus, &line); + if (returnval == 1) { + return EXIT_FAILURE; + } + printf("%s", line); + free(line); + + break; + + default: + fprintf(stderr, "%s", USAGE); + return EXIT_FAILURE; + } +} + + if (argc == 1) { + fprintf(stderr, "%s: Please provide a file.\n%s", argv[0], USAGE); + return EXIT_FAILURE; + } + +return EXIT_SUCCESS; + +}
\ No newline at end of file |