From: Huck Boles Date: Thu, 17 Nov 2022 06:00:10 +0000 (-0600) Subject: Thu Nov 17 12:00:10 AM CST 2022 automatic backup X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=b590c9d28d2266cd0848e515019cf9fc95b7fd26;p=odot.git Thu Nov 17 12:00:10 AM CST 2022 automatic backup --- diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@types.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@types.h.blob index 2a97e0c..80141a7 100644 Binary files a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@types.h.blob and b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@types.h.blob differ diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@wordsize.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@wordsize.h.blob index bcbe4f3..fc978a6 100644 Binary files a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@wordsize.h.blob and b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@wordsize.h.blob differ diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@features-time64.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@features-time64.h.blob index a2c8cf8..5a61925 100644 Binary files a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@features-time64.h.blob and b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@features-time64.h.blob differ diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@gnu@stubs.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@gnu@stubs.h.blob index 4d6b49e..1cd7b8d 100644 Binary files a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@gnu@stubs.h.blob and b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@gnu@stubs.h.blob differ diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdc-predef.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdc-predef.h.blob index b299ad6..bddb0b5 100644 Binary files a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdc-predef.h.blob and b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdc-predef.h.blob differ diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdio.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdio.h.blob index d8ef87d..88a88c1 100644 Binary files a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdio.h.blob and b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdio.h.blob differ diff --git a/.ccls-cache/@home@huck@.repos@odot/file.c b/.ccls-cache/@home@huck@.repos@odot/file.c index 2d5b277..4fbcfb9 100644 --- a/.ccls-cache/@home@huck@.repos@odot/file.c +++ b/.ccls-cache/@home@huck@.repos@odot/file.c @@ -1,63 +1,71 @@ #include "odot.h" void add(struct task t, FILE *fp){ - printf("\nalloc\n"); - char *c = malloc(strlen(t.task)*sizeof(char)); - printf("\nfopen\n"); - FILE *buf = fopen("odot.tmp", "w"); + printf("\talloc\n"); + char *line = malloc(MAXLINE*sizeof(char)); + printf("\tfopen\n"); + FILE *buf = fopen("/home/huck/.local/state/odot/odot.txt", "w+"); int i = 0; - printf("\nloopstart\n"); - int j = 0; - while (fgets(c,strlen(t.task),fp) != NULL){ - printf("\n%i-nloop\n", j++); - switch (listcheck(t,fp)){ - case 3: - dialogue("Already on todo list", t.task, CYAN); - printf("Remove from list?"); - if (check() == 0){ + printf("\tNULLcheck\n"); + if (fgets(line,MAXLINE,fp) == NULL){ + puttask(t,buf); + } else { + printf("\tloopstart\n"); + int j = 0; + while (fgets(line,MAXLINE,fp) != NULL){ + printf("\t%i-nloop\n", ++j); + switch (listcheck(t,line)){ + case 3: + dialogue("Already on todo list", t.task, CYAN); + printf("Remove from list?"); + if (check() == 0){ + break; + } else { + puttask(gettask(line), buf); + break; + } + case 1: + dialogue("Already on list in a different group", gettask(line).group, YELLOW); + if (check() == 0){ + puttask(t,buf); + i++; + } + puttask(gettask(line), buf); break; - } else { - puttask(gettask(fp), buf); + default: + /* first time t.task is lexigraphically greater than a previous task */ + if (i == 0 && strcmp(line,t.task) > 0){ + puttask(t,buf); + ++i; + } + puttask(gettask(line), buf); break; - } - case 1: - dialogue("Already on list in a different group", gettask(fp).group, YELLOW); - if (check() == 0){ - puttask(t,buf); - i++; - } - puttask(gettask(fp), buf); - break; - default: - /* first time t.task is lexigraphically greater than a previous task */ - if (i == 0 && strcmp(c,t.task) > 0){ - puttask(t,buf); - ++i; - } - puttask(gettask(fp), buf); - break; + } } } - free(c); fclose(fp); fclose(buf); - remove("/home/huck/.local/state/odot/todo"); - rename("odot.tmp", "/home/huck/.local/state/odot/todo"); + remove("/home/huck/.local/state/odot/todo.txt"); + rename("/home/huck/.local/state/odot/odot.txt", "/home/huck/.local/state/odot/todo.txt"); + free(line); + fp = fopen("/home/huck/.local/state/odot/todo.txt", "w+"); + if (!fp) + error(1); return; } void rem(struct task t, FILE *fp){ char *s = malloc(MAXLINE * sizeof(char)); - FILE *buf = fopen("odot.tmp", "w"); + FILE *buf = fopen("/home/huck/.local/state/odot/odot.txt", "w+"); int i = 0; while (fgets(s, MAXLINE, fp) != NULL){ s[strlen(s) - 1] = 0; if (strcmp(t.task, s) != 0){ - fputs(strcat(s,"\n"),buf); + fputs(strcat(s,"\t"),buf); } else { i++; } @@ -66,8 +74,10 @@ void rem(struct task t, FILE *fp){ fclose(fp); fclose(buf); - remove ("/home/huck/.local/state/odot/todo"); - rename("odot.tmp", "/home/huck/.local/state/odot/todo"); + remove ("/home/huck/.local/state/odot/todo.txt"); + rename("/home/huck/.local/state/odot/odot.txt", "/home/huck/.local/state/odot/todo.txt"); + + fp = fopen("/home/huck/.local/state/odot/todo.txt", "w+"); if (i == 0){ dialogue("Task not found", t.task, YELLOW); @@ -76,18 +86,24 @@ void rem(struct task t, FILE *fp){ add(t,fp); } } - free(s); + } void show(char *group, FILE *fp){ - char *c = malloc(sizeof(char)); + char *task = malloc(MAXLINE * sizeof(char)); + struct task tmp; + + printf("\twhileloop\n"); + int j = 0; - while (fgets(c, 1, fp) != NULL ){ - if (strcmp(group, "all") == 0 || strcmp(gettask(fp).group, group) == 0){ - formattask(gettask(fp)); + while ((fgets(task, MAXLINE, fp)) != NULL ){ + printf("\t%i-nloop\n", ++j); + tmp = gettask(task); + if (strcmp(group, "all") == 0 || strcmp(tmp.group, group) == 0){ + formattask(tmp); } } - free(c); + free(task); } diff --git a/.ccls-cache/@home@huck@.repos@odot/file.c.blob b/.ccls-cache/@home@huck@.repos@odot/file.c.blob index 6379548..3d1f47f 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/file.c.blob and b/.ccls-cache/@home@huck@.repos@odot/file.c.blob differ diff --git a/.ccls-cache/@home@huck@.repos@odot/input.c b/.ccls-cache/@home@huck@.repos@odot/input.c index 0cb2c50..4d39442 100644 --- a/.ccls-cache/@home@huck@.repos@odot/input.c +++ b/.ccls-cache/@home@huck@.repos@odot/input.c @@ -1,26 +1,28 @@ #include "odot.h" struct task getnote(int n, char *arg[], char *group){ - char *s = malloc(MAXLINE * sizeof(char)); + char *note = malloc(MAXLINE * sizeof(char)); struct task tmp; - if (n == 1) - printf("\nreturn from note\n"); + if (n == 1){ + printf("\t\treturn from note\n"); return tmp; + } - while(n-- > 0){ - printf("\n%i-nloop\n",n); - if (*arg[0] != '-'){ - strcat(s, *arg); - strcat(s, (n > 1) ? " " : ""); + while(--n > 0){ + printf("\t%i-nloop\n",n); + if ((*++arg)[0] != '-'){ + strcat(note, *arg); + strcat(note, " "); } else if (strcmp(*arg,"-g") == 0){ - strcpy(group, *arg); + strcpy(group, (*++arg)); + n--; } } - strcpy(tmp.task, s); - strcpy(tmp.group, group); - free(s); + printf("\t%s %s getnote\n",note,group); + tmp = maketask(note,group); + free(note); return tmp; } @@ -32,19 +34,19 @@ struct task getnote(int n, char *arg[], char *group){ short getopt(int n, char *arg[]){ short options; - printf("\nreturn1\n"); + printf("\treturn1\n"); /* show list if no arguments given */ if (n == 1) return 1; - printf("\ncheckopt\n"); + printf("\tcheckopt\n"); while (--n > 0 && (*++arg)[0] == '-'){ /* if theres a d delete, otherwise add */ options += strchr(*arg, 's') ? 1 : 0; options += strchr(*arg, 'n') ? 2 : 0; options += strchr(*arg, 'd') ? 4 : 0; } - printf("%i", options); + printf("\t%i-optcode\n", options); if ((options - 5) > 0) error(2); return options; @@ -52,25 +54,31 @@ short getopt(int n, char *arg[]){ struct task maketask(char *task, char *group){ + printf("\tmaketask\n"); struct task tmp; + + tmp.task = malloc(strlen(task) * sizeof(char)); + tmp.group = malloc(strlen(group) * sizeof(char)); + + strcpy(tmp.task,task); + strcpy(tmp.group,(strcmp(tmp.group,"") == 0) ? "all" : group); - tmp.task = task; - tmp.date = 0; - /* add to all group if group isn't specified */ - tmp.group = (strcmp(group,"") == 0) ? "all" : group; + printf("\t%s-task %s-group\n",tmp.task,tmp.group); return tmp; } -struct task gettask(FILE *fp){ +struct task gettask(char *c){ + printf("\tgettask\n"); struct task tmp; - fscanf(fp,"%s\t%s\t%i\n",tmp.task,tmp.group,&tmp.date); + sscanf(c,"%s\t%s",tmp.task,tmp.group); return tmp; } void puttask(struct task t, FILE *fp){ - fprintf(fp,"%s\t%s\t%i\n",t.task,t.group,t.date); + printf("\t%s %s puttask\n", t.task, t.group); + fprintf(fp,"%s\t%s\n",t.task,t.group); } diff --git a/.ccls-cache/@home@huck@.repos@odot/input.c.blob b/.ccls-cache/@home@huck@.repos@odot/input.c.blob index 19f6e3c..a84d4cc 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/input.c.blob and b/.ccls-cache/@home@huck@.repos@odot/input.c.blob differ diff --git a/.ccls-cache/@home@huck@.repos@odot/main.c b/.ccls-cache/@home@huck@.repos@odot/main.c index 9b86cd1..e498acf 100644 --- a/.ccls-cache/@home@huck@.repos@odot/main.c +++ b/.ccls-cache/@home@huck@.repos@odot/main.c @@ -1,46 +1,46 @@ #include "odot.h" int main(int argc, char *argv[]){ - printf("\nstart\n"); + printf("\tstart\n"); struct task note; short opt; FILE *fp; char *group = malloc(MAXLINE*sizeof(char)); - printf("\nfopen\n"); - fp = fopen("/home/huck/.local/state/odot/todo", "w+"); + printf("\tfopen\n"); + fp = fopen("/home/huck/.local/state/odot/todo.txt", "w+"); if (!fp){ error(1); } - printf("\ngetopt\n"); + printf("\tgetopt\n"); opt = getopt(argc, argv); - printf("\ngetnote\n"); + printf("\tgetnote\n"); note = getnote(argc, argv, group); if (opt >= 4){ - printf("\nrem\n"); + printf("\trem\n"); rem(note, fp); - } else { - printf("\nadd\n"); + } else if (opt >= 2){ + printf("\tadd\n"); add(note, fp); } if (opt % 2 != 0){ - printf("\nshow\n"); + printf("\tshow\n"); show(group, fp); } - - free(group); + printf("\texiting\n"); fclose(fp); + free(group); return 0; } void error(int err){ switch (err) { case 1: - fprintf(stderr,"ERROR: COULD NOT ACCESS FILE: %s\n", "/home/huck/.local/state/odot/todo"); + fprintf(stderr,"ERROR: COULD NOT ACCESS FILE: %s\n", "/home/huck/.local/state/odot/todo.txt"); break; case 2: fprintf(stderr,"ERROR: CANT ADD AND REMOVE SAME TASK\n"); @@ -55,7 +55,7 @@ void dialogue(char *m1, char *m2, int c){ } void formattask(struct task t){ - printf("* %s\t%s\t%i", t.task, t.group, t.date); + printf("* %s\t%s\n", t.task, t.group); } /* Returns: @@ -64,17 +64,13 @@ void formattask(struct task t){ 2 - Group matches 3 - Both match */ -int listcheck(struct task t, FILE *fp){ +int listcheck(struct task t, char *c){ int i; - i += (strcmp(t.task,gettask(fp).task) == 0) ? 1 : 0; - i += (strcmp(t.group,gettask(fp).group) == 0) ? 2 : 0; + i += (strcmp(t.task,gettask(c).task) == 0) ? 1 : 0; + i += (strcmp(t.group,gettask(c).group) == 0) ? 2 : 0; return i; } -char *gettime(void){ - return NULL; -} - /* returns 0 for yes and 1 for no */ int check(void){ printf("Continue? [y/n] (y):"); diff --git a/.ccls-cache/@home@huck@.repos@odot/main.c.blob b/.ccls-cache/@home@huck@.repos@odot/main.c.blob index e10b157..ecc8316 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/main.c.blob and b/.ccls-cache/@home@huck@.repos@odot/main.c.blob differ diff --git a/.ccls-cache/@home@huck@.repos@odot/odot.h b/.ccls-cache/@home@huck@.repos@odot/odot.h index 78c3548..1cd5ff2 100644 --- a/.ccls-cache/@home@huck@.repos@odot/odot.h +++ b/.ccls-cache/@home@huck@.repos@odot/odot.h @@ -10,7 +10,6 @@ struct task { char *task; - int date; char *group; }; @@ -21,7 +20,7 @@ void add(struct task, FILE *); void rem(struct task, FILE *); void show(char *group, FILE *); -int listcheck(struct task, FILE *); +int listcheck(struct task, char *); int geturgency(int); char *gettime(void); @@ -32,6 +31,6 @@ int check(void); struct task maketask(char *, char *); void puttask(struct task n, FILE*); -struct task gettask(FILE *); +struct task gettask(char *); enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; diff --git a/.ccls-cache/@home@huck@.repos@odot/odot.h.blob b/.ccls-cache/@home@huck@.repos@odot/odot.h.blob index ee68686..bbbd5b8 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/odot.h.blob and b/.ccls-cache/@home@huck@.repos@odot/odot.h.blob differ diff --git a/file.c b/file.c index 2d5b277..4fbcfb9 100644 --- a/file.c +++ b/file.c @@ -1,63 +1,71 @@ #include "odot.h" void add(struct task t, FILE *fp){ - printf("\nalloc\n"); - char *c = malloc(strlen(t.task)*sizeof(char)); - printf("\nfopen\n"); - FILE *buf = fopen("odot.tmp", "w"); + printf("\talloc\n"); + char *line = malloc(MAXLINE*sizeof(char)); + printf("\tfopen\n"); + FILE *buf = fopen("/home/huck/.local/state/odot/odot.txt", "w+"); int i = 0; - printf("\nloopstart\n"); - int j = 0; - while (fgets(c,strlen(t.task),fp) != NULL){ - printf("\n%i-nloop\n", j++); - switch (listcheck(t,fp)){ - case 3: - dialogue("Already on todo list", t.task, CYAN); - printf("Remove from list?"); - if (check() == 0){ + printf("\tNULLcheck\n"); + if (fgets(line,MAXLINE,fp) == NULL){ + puttask(t,buf); + } else { + printf("\tloopstart\n"); + int j = 0; + while (fgets(line,MAXLINE,fp) != NULL){ + printf("\t%i-nloop\n", ++j); + switch (listcheck(t,line)){ + case 3: + dialogue("Already on todo list", t.task, CYAN); + printf("Remove from list?"); + if (check() == 0){ + break; + } else { + puttask(gettask(line), buf); + break; + } + case 1: + dialogue("Already on list in a different group", gettask(line).group, YELLOW); + if (check() == 0){ + puttask(t,buf); + i++; + } + puttask(gettask(line), buf); break; - } else { - puttask(gettask(fp), buf); + default: + /* first time t.task is lexigraphically greater than a previous task */ + if (i == 0 && strcmp(line,t.task) > 0){ + puttask(t,buf); + ++i; + } + puttask(gettask(line), buf); break; - } - case 1: - dialogue("Already on list in a different group", gettask(fp).group, YELLOW); - if (check() == 0){ - puttask(t,buf); - i++; - } - puttask(gettask(fp), buf); - break; - default: - /* first time t.task is lexigraphically greater than a previous task */ - if (i == 0 && strcmp(c,t.task) > 0){ - puttask(t,buf); - ++i; - } - puttask(gettask(fp), buf); - break; + } } } - free(c); fclose(fp); fclose(buf); - remove("/home/huck/.local/state/odot/todo"); - rename("odot.tmp", "/home/huck/.local/state/odot/todo"); + remove("/home/huck/.local/state/odot/todo.txt"); + rename("/home/huck/.local/state/odot/odot.txt", "/home/huck/.local/state/odot/todo.txt"); + free(line); + fp = fopen("/home/huck/.local/state/odot/todo.txt", "w+"); + if (!fp) + error(1); return; } void rem(struct task t, FILE *fp){ char *s = malloc(MAXLINE * sizeof(char)); - FILE *buf = fopen("odot.tmp", "w"); + FILE *buf = fopen("/home/huck/.local/state/odot/odot.txt", "w+"); int i = 0; while (fgets(s, MAXLINE, fp) != NULL){ s[strlen(s) - 1] = 0; if (strcmp(t.task, s) != 0){ - fputs(strcat(s,"\n"),buf); + fputs(strcat(s,"\t"),buf); } else { i++; } @@ -66,8 +74,10 @@ void rem(struct task t, FILE *fp){ fclose(fp); fclose(buf); - remove ("/home/huck/.local/state/odot/todo"); - rename("odot.tmp", "/home/huck/.local/state/odot/todo"); + remove ("/home/huck/.local/state/odot/todo.txt"); + rename("/home/huck/.local/state/odot/odot.txt", "/home/huck/.local/state/odot/todo.txt"); + + fp = fopen("/home/huck/.local/state/odot/todo.txt", "w+"); if (i == 0){ dialogue("Task not found", t.task, YELLOW); @@ -76,18 +86,24 @@ void rem(struct task t, FILE *fp){ add(t,fp); } } - free(s); + } void show(char *group, FILE *fp){ - char *c = malloc(sizeof(char)); + char *task = malloc(MAXLINE * sizeof(char)); + struct task tmp; + + printf("\twhileloop\n"); + int j = 0; - while (fgets(c, 1, fp) != NULL ){ - if (strcmp(group, "all") == 0 || strcmp(gettask(fp).group, group) == 0){ - formattask(gettask(fp)); + while ((fgets(task, MAXLINE, fp)) != NULL ){ + printf("\t%i-nloop\n", ++j); + tmp = gettask(task); + if (strcmp(group, "all") == 0 || strcmp(tmp.group, group) == 0){ + formattask(tmp); } } - free(c); + free(task); } diff --git a/input.c b/input.c index 0cb2c50..4d39442 100644 --- a/input.c +++ b/input.c @@ -1,26 +1,28 @@ #include "odot.h" struct task getnote(int n, char *arg[], char *group){ - char *s = malloc(MAXLINE * sizeof(char)); + char *note = malloc(MAXLINE * sizeof(char)); struct task tmp; - if (n == 1) - printf("\nreturn from note\n"); + if (n == 1){ + printf("\t\treturn from note\n"); return tmp; + } - while(n-- > 0){ - printf("\n%i-nloop\n",n); - if (*arg[0] != '-'){ - strcat(s, *arg); - strcat(s, (n > 1) ? " " : ""); + while(--n > 0){ + printf("\t%i-nloop\n",n); + if ((*++arg)[0] != '-'){ + strcat(note, *arg); + strcat(note, " "); } else if (strcmp(*arg,"-g") == 0){ - strcpy(group, *arg); + strcpy(group, (*++arg)); + n--; } } - strcpy(tmp.task, s); - strcpy(tmp.group, group); - free(s); + printf("\t%s %s getnote\n",note,group); + tmp = maketask(note,group); + free(note); return tmp; } @@ -32,19 +34,19 @@ struct task getnote(int n, char *arg[], char *group){ short getopt(int n, char *arg[]){ short options; - printf("\nreturn1\n"); + printf("\treturn1\n"); /* show list if no arguments given */ if (n == 1) return 1; - printf("\ncheckopt\n"); + printf("\tcheckopt\n"); while (--n > 0 && (*++arg)[0] == '-'){ /* if theres a d delete, otherwise add */ options += strchr(*arg, 's') ? 1 : 0; options += strchr(*arg, 'n') ? 2 : 0; options += strchr(*arg, 'd') ? 4 : 0; } - printf("%i", options); + printf("\t%i-optcode\n", options); if ((options - 5) > 0) error(2); return options; @@ -52,25 +54,31 @@ short getopt(int n, char *arg[]){ struct task maketask(char *task, char *group){ + printf("\tmaketask\n"); struct task tmp; + + tmp.task = malloc(strlen(task) * sizeof(char)); + tmp.group = malloc(strlen(group) * sizeof(char)); + + strcpy(tmp.task,task); + strcpy(tmp.group,(strcmp(tmp.group,"") == 0) ? "all" : group); - tmp.task = task; - tmp.date = 0; - /* add to all group if group isn't specified */ - tmp.group = (strcmp(group,"") == 0) ? "all" : group; + printf("\t%s-task %s-group\n",tmp.task,tmp.group); return tmp; } -struct task gettask(FILE *fp){ +struct task gettask(char *c){ + printf("\tgettask\n"); struct task tmp; - fscanf(fp,"%s\t%s\t%i\n",tmp.task,tmp.group,&tmp.date); + sscanf(c,"%s\t%s",tmp.task,tmp.group); return tmp; } void puttask(struct task t, FILE *fp){ - fprintf(fp,"%s\t%s\t%i\n",t.task,t.group,t.date); + printf("\t%s %s puttask\n", t.task, t.group); + fprintf(fp,"%s\t%s\n",t.task,t.group); } diff --git a/main.c b/main.c index 9b86cd1..e498acf 100644 --- a/main.c +++ b/main.c @@ -1,46 +1,46 @@ #include "odot.h" int main(int argc, char *argv[]){ - printf("\nstart\n"); + printf("\tstart\n"); struct task note; short opt; FILE *fp; char *group = malloc(MAXLINE*sizeof(char)); - printf("\nfopen\n"); - fp = fopen("/home/huck/.local/state/odot/todo", "w+"); + printf("\tfopen\n"); + fp = fopen("/home/huck/.local/state/odot/todo.txt", "w+"); if (!fp){ error(1); } - printf("\ngetopt\n"); + printf("\tgetopt\n"); opt = getopt(argc, argv); - printf("\ngetnote\n"); + printf("\tgetnote\n"); note = getnote(argc, argv, group); if (opt >= 4){ - printf("\nrem\n"); + printf("\trem\n"); rem(note, fp); - } else { - printf("\nadd\n"); + } else if (opt >= 2){ + printf("\tadd\n"); add(note, fp); } if (opt % 2 != 0){ - printf("\nshow\n"); + printf("\tshow\n"); show(group, fp); } - - free(group); + printf("\texiting\n"); fclose(fp); + free(group); return 0; } void error(int err){ switch (err) { case 1: - fprintf(stderr,"ERROR: COULD NOT ACCESS FILE: %s\n", "/home/huck/.local/state/odot/todo"); + fprintf(stderr,"ERROR: COULD NOT ACCESS FILE: %s\n", "/home/huck/.local/state/odot/todo.txt"); break; case 2: fprintf(stderr,"ERROR: CANT ADD AND REMOVE SAME TASK\n"); @@ -55,7 +55,7 @@ void dialogue(char *m1, char *m2, int c){ } void formattask(struct task t){ - printf("* %s\t%s\t%i", t.task, t.group, t.date); + printf("* %s\t%s\n", t.task, t.group); } /* Returns: @@ -64,17 +64,13 @@ void formattask(struct task t){ 2 - Group matches 3 - Both match */ -int listcheck(struct task t, FILE *fp){ +int listcheck(struct task t, char *c){ int i; - i += (strcmp(t.task,gettask(fp).task) == 0) ? 1 : 0; - i += (strcmp(t.group,gettask(fp).group) == 0) ? 2 : 0; + i += (strcmp(t.task,gettask(c).task) == 0) ? 1 : 0; + i += (strcmp(t.group,gettask(c).group) == 0) ? 2 : 0; return i; } -char *gettime(void){ - return NULL; -} - /* returns 0 for yes and 1 for no */ int check(void){ printf("Continue? [y/n] (y):"); diff --git a/odot b/odot index 1c93fb8..f13d228 100755 Binary files a/odot and b/odot differ diff --git a/odot.h b/odot.h index 78c3548..1cd5ff2 100644 --- a/odot.h +++ b/odot.h @@ -10,7 +10,6 @@ struct task { char *task; - int date; char *group; }; @@ -21,7 +20,7 @@ void add(struct task, FILE *); void rem(struct task, FILE *); void show(char *group, FILE *); -int listcheck(struct task, FILE *); +int listcheck(struct task, char *); int geturgency(int); char *gettime(void); @@ -32,6 +31,6 @@ int check(void); struct task maketask(char *, char *); void puttask(struct task n, FILE*); -struct task gettask(FILE *); +struct task gettask(char *); enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};