From d7340d18f92004f71ca5cca752af2e1629649f1a Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Sat, 26 Nov 2022 14:48:54 -0600 Subject: [PATCH] bug fixes --- Makefile | 9 ++++----- README.md | 33 ++++++++++++++++++++------------- main.c | 15 ++++++++++++--- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 1708218..8717a93 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,13 @@ SHELL = /bin/bash PROG = odot -PREFIX ?= /usr -BINDIR ?= $(PREFIX)/bin -SHAREDIR ?= $(HOME)/.local/share +BINDIR ?= /bin +STATEDIR ?= $(HOME)/.local/state install : main.c sudo gcc main.c -o '$(BINDIR)/$(PROG)' - [[ ! -d '$(SHAREDIR)/$(PROG))' ]] && mkdir -p '$(SHAREDIR)/$(PROG)' + [[ ! -d '$(STATEDIR)/$(PROG))' ]] && mkdir -p '$(STATEDIR)/$(PROG)' clean : - rm -rf '$(SHAREDIR)/$(PROG)' + rm -rf '$(STATEDIR)/$(PROG)' diff --git a/README.md b/README.md index 7ea75c7..eb946a1 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,30 @@ # odot Todo manager written in C -Usage: +Extremely basic to use, simply call ***odot*** with a task to add or +remove it from the list, or call ***odot*** all by iteself to see the +current todo list in alphabetical order. - Add new task to list: +* Usage: + + - Add new task to list: - $ odot [new task not on list] + $ odot [new task not on list] + + - Remove task from list: - Remove task from list: - - $ odot [task already on list] + $ odot [task already on list] - Show list: + - Show list: - $ odot + $ odot -Installation: +* Installation: + + $ git clone https://github.com/huboles/odot.git + $ cd odot + $ make install + +***odot*** stores current and completed tasks in plaintext .txt files, located at +$HOME/.local/share/odot. - $ git clone https://github.com/huboles/odot.git - $ cd odot - $ sudo gcc *.c -o /usr/bin/odot - $ mkdir $HOME/.local/state/odot diff --git a/main.c b/main.c index 6c36855..a2285f5 100644 --- a/main.c +++ b/main.c @@ -21,15 +21,24 @@ int main(int argc, char *argv[]){ 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"); + + list = malloc((strlen(homedir)+22)*sizeof(char)); + done = malloc((strlen(homedir)+22)*sizeof(char)); + tmp = malloc((strlen(homedir)+21)*sizeof(char)); + + sprintf(list,"%s/.local/state/odot/todo.txt",homedir); + sprintf(done,"%s/.local/state/odot/done.txt",homedir); + sprintf(tmp,"%s/.local/state/odot/tmp.txt",homedir); if (argc == 1){ show(); } else { addnote(getnote(argc,argv)); } + + free(tmp); + free(done); + free(list); return 0; } -- 2.45.2