- // read from task file
- board_file = fopen(default_board_file, "r");
- if (!board_file) {
- printf("File does not exist\n");
- return 1;
- }
- fclose(board_file);
+ // read command line args
+ flag = getopt(argc, argv, "o:n:");
+ switch (flag) {
+ case 'o':
+
+ // read from task file (might need to check for read and write permissions)
+ board_file = fopen(optarg, "r");
+ if (!board_file) {
+ printf("%s does not exist\n", optarg);
+ return 1;
+ }
+
+ char* lineptr = read_todo(board_file);
+ printf("lineptr: %p\n", lineptr);
+ printf("first: %c\n", *lineptr);
+ free(lineptr);
+ fclose(board_file);
+
+ break;
+
+ case 'n':
+
+ // make sure file does not exist
+ // however, it maybe be possible that an different error has occured (besides the file not existing)
+ if (access(optarg, F_OK) == 0) {
+ printf("%s already exists\n", optarg);
+ return 1;
+ }
+ // create a file here
+ printf("Successfully created %s\n", optarg);
+ break;
+
+ case -1:
+ case '?':
+ printf("Help string\n");
+ return 2;
+ }
+
+
+
+ return 0;