From 138060f7bf5f48b607ede0302b7eaa420e1058ac Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Sat, 26 Nov 2022 14:14:52 -0600 Subject: [PATCH] Makefile --- Makefile | 14 ++++++++++++++ main.c | 47 +++++++++++++++++++++++++++++------------------ odot | Bin 21208 -> 0 bytes 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 Makefile delete mode 100755 odot diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1708218 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +SHELL = /bin/bash +PROG = odot +PREFIX ?= /usr +BINDIR ?= $(PREFIX)/bin +SHAREDIR ?= $(HOME)/.local/share + + +install : main.c + sudo gcc main.c -o '$(BINDIR)/$(PROG)' + [[ ! -d '$(SHAREDIR)/$(PROG))' ]] && mkdir -p '$(SHAREDIR)/$(PROG)' + +clean : + rm -rf '$(SHAREDIR)/$(PROG)' + diff --git a/main.c b/main.c index a9058a7..6c36855 100644 --- a/main.c +++ b/main.c @@ -3,19 +3,27 @@ #include #define MAXLINE 500 -#define LIST "/home/huck/.local/state/odot/todo.txt" -#define DONE "/home/huck/.local/state/odot/done.txt" -#define TMP "/home/huck/.local/state/odot/odot.txt" int getopt(int, char **); char *getnote(int, char **); +void envar(void); void addnote(char *); void show(); -char *hash(char *); +char *list; +char *done; +char *tmp; int main(int argc, char *argv[]){ + extern char *list; + extern char *done; + extern char *tmp; + + char *homedir = getenv("HOME"); + list = strcat(homedir,"/.local/share/odot/todo.txt"); + done = strcat(homedir,"/.local/share/odot/done.txt"); + tmp = strcat(homedir,"/.local/share/odot/tmp.txt"); if (argc == 1){ show(); @@ -35,47 +43,53 @@ char *getnote(int n, char *arg[]){ } void addnote(char *note){ + extern char *list; + extern char *done; + extern char *tmp; + int i = 0; char *buf = malloc(MAXLINE * sizeof(char)); - FILE *fp = fopen(LIST,"r"); - FILE *fdone = fopen(DONE,"a"); - FILE *tmp = fopen(TMP,"w"); + FILE *fp = fopen(list,"r"); + FILE *fdone = fopen(done,"a"); + FILE *tfp = fopen(tmp,"w"); if(!fp || !tmp || !fdone) exit(1); while(fgets(buf, MAXLINE, fp)){ if (strcmp(note,buf) > 0){ - fputs(buf,tmp); + fputs(buf,tfp); } else if (strcmp(note,buf) == 0){ fputs(note,fdone); printf("Removed from list: %s", note); i++; } else if (strcmp(note,buf) < 0){ if (i == 0){ - fputs(note,tmp); + fputs(note,tfp); printf("Added to list: %s", note); i++; } - fputs(buf,tmp); + fputs(buf,tfp); } } if (i == 0){ - fputs(note,tmp); + fputs(note,tfp); printf("Added to list: %s", note); } - fclose(tmp); + fclose(tfp); fclose(fp); fclose(fdone); free(buf); - remove(LIST); - rename(TMP,LIST); + remove(list); + rename(tmp,list); return; } void show(void){ - FILE *fp = fopen(LIST,"r"); + extern char *list; + + FILE *fp = fopen(list,"r"); char *buf = malloc(MAXLINE * sizeof(char)); printf("\033[36;1mTODO\033[0m:\n"); @@ -88,6 +102,3 @@ void show(void){ return; } -char *hash(char *note){ - -} diff --git a/odot b/odot deleted file mode 100755 index 2ef5f6aa3c2cdba0a7a6085ca2be2c9660147e57..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21208 zcmeHP4Rl;bb)L7o(ylD)$C7{J1h1XgIH6iuj_t@v6t8Try(0dLEkkGtFRR@rX`9uq zvisJS-8wP2&Z%+J<3Jinn$reODW!pyA2%hWfPx`*3O#k8Bq;BMhdj2?KwT&+4JV!`^~*~X70>;JMZ_-*p6*J%MvE}#SMbeWV1q|y5NI7ngNN5 zPSJpTrMN=WLJmkwl}8mpsY=iK%4taBeo)#iCNl%QRKdbf(?U|(&6Xb06&NaXKWJA& zBQ00bHd!cyp{CrcFHB>ku*^OBH7Xz(T58AGoNtrG;(S**eMraU&oni56lpi6?Z&j7 zM|FK;nwoerCfqu8JS%AwWlT|-3sGq|qU|c_R;_O+>tNdVLpSwbsc(!Lg-UMJKKl5h6duPEH&4SOJ1%C{97+Yn!0lpXUCWWBI^dUx6> zC+`f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