From: Huck Boles Date: Tue, 1 Nov 2022 03:00:01 +0000 (-0500) Subject: automatic backup X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=738c6113940f6ec5b0ec40082ee3fb889a155798;p=odot.git automatic backup --- 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 83d7c43..8bb53e8 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 fa4aeee..8bb2b34 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 234c447..dde057a 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 605f6ab..4654a52 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 46791e7..cfe8c8e 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/dialogue.c.blob b/.ccls-cache/@home@huck@.repos@odot/dialogue.c.blob index 47b96a6..a2f6501 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/dialogue.c.blob and b/.ccls-cache/@home@huck@.repos@odot/dialogue.c.blob differ diff --git a/.ccls-cache/@home@huck@.repos@odot/file.c b/.ccls-cache/@home@huck@.repos@odot/file.c index 9449bae..ddf96f1 100644 --- a/.ccls-cache/@home@huck@.repos@odot/file.c +++ b/.ccls-cache/@home@huck@.repos@odot/file.c @@ -6,12 +6,13 @@ extern FILE *fp; enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; + void add(void){ fp = fopen(TODOLIST, "a"); - if (fp == NULL) - error('f'); - fputs(strcat(note,"\n"),fp); - fclose(fp); + if (fp != NULL){ + fputs(strcat(note,"\n"),fp); + fclose(fp); + } } void rem(void){ @@ -19,8 +20,6 @@ void rem(void){ FILE *tmp = fopen("temp", "w"); fp = fopen(TODOLIST, "r"); - if (fp == NULL) - error('f'); while (fgets(s, MAXLINE, fp) != NULL){ @@ -40,14 +39,30 @@ void rem(void){ } void show(void){ - char *c = (char *) malloc(MAXLINE * sizeof(int)); + char *c; - if (fp == NULL) - error('f'); + c = (char *) malloc(MAXLINE * sizeof(int)); + fp = fopen(TODOLIST,"r"); while (fgets(c, MAXLINE, fp) != NULL ) - printf("\t\t\033[1;3%im*\033[0m %s",geturgency(urgency), c); + printf("\t\t\033[1;35m*\033[0m %s", c); fclose(fp); free(c); } +int listcheck(void){ + char *s; + + fp = fopen(TODOLIST, "r"); + s = (char *) malloc(MAXLINE * sizeof(char)); + + while (fgets(s, MAXLINE, fp) != NULL){ + s[strlen(s) - 1] = 0; + if (strcmp(note, s) == 0){ + free(s); + return 1; + } + } + free(s); + return 0; +} diff --git a/.ccls-cache/@home@huck@.repos@odot/file.c.blob b/.ccls-cache/@home@huck@.repos@odot/file.c.blob index 2417fd5..77dfd27 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/func.c.blob b/.ccls-cache/@home@huck@.repos@odot/func.c.blob index c06aab0..d7698c7 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/func.c.blob and b/.ccls-cache/@home@huck@.repos@odot/func.c.blob differ diff --git a/.ccls-cache/@home@huck@.repos@odot/input.c.blob b/.ccls-cache/@home@huck@.repos@odot/input.c.blob index 36a66b3..f93f99d 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.blob b/.ccls-cache/@home@huck@.repos@odot/main.c.blob index 2c2f711..1df34ab 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 81a5ea9..c465e23 100644 --- a/.ccls-cache/@home@huck@.repos@odot/odot.h +++ b/.ccls-cache/@home@huck@.repos@odot/odot.h @@ -23,15 +23,15 @@ void add(void); void rem(void); void show(void); -int listcheck(struct task); +int listcheck(void); int geturgency(int); char *gettime(void); void error(char); struct task maketask(int n, char **arg); -void puttask(struct task n, FILE *fp); -struct task gettask(FILE *fp); +void puttask(struct task n); +struct task gettask(void); char *note, *o; int urgency; diff --git a/.ccls-cache/@home@huck@.repos@odot/odot.h.blob b/.ccls-cache/@home@huck@.repos@odot/odot.h.blob index e61d6f5..4fa2ad9 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/.ccls-cache/@home@huck@.repos@odot/structure.c b/.ccls-cache/@home@huck@.repos@odot/structure.c index ecdfb7f..3f75b10 100644 --- a/.ccls-cache/@home@huck@.repos@odot/structure.c +++ b/.ccls-cache/@home@huck@.repos@odot/structure.c @@ -16,13 +16,11 @@ struct task maketask(int n, char **arg){ return temp; } -void puttask(struct task n, FILE *fp){ - +void puttask(struct task n){ fprintf(fp, "%i\t%s\t%s\t%s\t%i\n",n.length,n.task,n.date,n.due,n.urgency); - } -struct task gettask(FILE *fp){ +struct task gettask(void){ struct task tmp; fscanf(fp,"%i\t%s\t%s\t%s\t%i\n",&tmp.length,tmp.task,tmp.date,tmp.due,&tmp.urgency); diff --git a/.ccls-cache/@home@huck@.repos@odot/structure.c.blob b/.ccls-cache/@home@huck@.repos@odot/structure.c.blob index c697e64..d154812 100644 Binary files a/.ccls-cache/@home@huck@.repos@odot/structure.c.blob and b/.ccls-cache/@home@huck@.repos@odot/structure.c.blob differ diff --git a/file.c b/file.c index 9449bae..ddf96f1 100644 --- a/file.c +++ b/file.c @@ -6,12 +6,13 @@ extern FILE *fp; enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; + void add(void){ fp = fopen(TODOLIST, "a"); - if (fp == NULL) - error('f'); - fputs(strcat(note,"\n"),fp); - fclose(fp); + if (fp != NULL){ + fputs(strcat(note,"\n"),fp); + fclose(fp); + } } void rem(void){ @@ -19,8 +20,6 @@ void rem(void){ FILE *tmp = fopen("temp", "w"); fp = fopen(TODOLIST, "r"); - if (fp == NULL) - error('f'); while (fgets(s, MAXLINE, fp) != NULL){ @@ -40,14 +39,30 @@ void rem(void){ } void show(void){ - char *c = (char *) malloc(MAXLINE * sizeof(int)); + char *c; - if (fp == NULL) - error('f'); + c = (char *) malloc(MAXLINE * sizeof(int)); + fp = fopen(TODOLIST,"r"); while (fgets(c, MAXLINE, fp) != NULL ) - printf("\t\t\033[1;3%im*\033[0m %s",geturgency(urgency), c); + printf("\t\t\033[1;35m*\033[0m %s", c); fclose(fp); free(c); } +int listcheck(void){ + char *s; + + fp = fopen(TODOLIST, "r"); + s = (char *) malloc(MAXLINE * sizeof(char)); + + while (fgets(s, MAXLINE, fp) != NULL){ + s[strlen(s) - 1] = 0; + if (strcmp(note, s) == 0){ + free(s); + return 1; + } + } + free(s); + return 0; +} diff --git a/odot.h b/odot.h index 81a5ea9..c465e23 100644 --- a/odot.h +++ b/odot.h @@ -23,15 +23,15 @@ void add(void); void rem(void); void show(void); -int listcheck(struct task); +int listcheck(void); int geturgency(int); char *gettime(void); void error(char); struct task maketask(int n, char **arg); -void puttask(struct task n, FILE *fp); -struct task gettask(FILE *fp); +void puttask(struct task n); +struct task gettask(void); char *note, *o; int urgency; diff --git a/structure.c b/structure.c index ecdfb7f..3f75b10 100644 --- a/structure.c +++ b/structure.c @@ -16,13 +16,11 @@ struct task maketask(int n, char **arg){ return temp; } -void puttask(struct task n, FILE *fp){ - +void puttask(struct task n){ fprintf(fp, "%i\t%s\t%s\t%s\t%i\n",n.length,n.task,n.date,n.due,n.urgency); - } -struct task gettask(FILE *fp){ +struct task gettask(void){ struct task tmp; fscanf(fp,"%i\t%s\t%s\t%s\t%i\n",&tmp.length,tmp.task,tmp.date,tmp.due,&tmp.urgency);