rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | LICENSE

commit 8056ab10c09a65ba9a15a09e33d2b8a6dc867539
parent 565c7d9c4b3bc10141f15e0f9bb82e97c36144b3
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sun, 16 Dec 2012 09:31:51 +0100

Adding tmpl and creating non-existing config files.

Diffstat:
Makefile | 2+-
cfg.c | 10+++++++---
inc.c | 7++++---
mark.c | 7++++---
txtdb.c | 3+--
5 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile @@ -38,7 +38,7 @@ dist: clean @echo creating dist tarball @mkdir -p ${NAME}-${VERSION} @cp -R LICENSE Makefile README.md config.mk \ - ${SRC} *.h ${NAME}-${VERSION} + ${SRC} *.h tmpl ${NAME}-${VERSION} @tar -cf ${NAME}-${VERSION}.tar ${NAME}-${VERSION} @gzip ${NAME}-${VERSION}.tar @rm -rf ${NAME}-${VERSION} diff --git a/cfg.c b/cfg.c @@ -61,10 +61,11 @@ config_init(char *cfgn) path = config_mkcfgpath(cfgn); cfg = config_read(path); - free(path); - - if (cfg == NULL) + if (cfg == NULL) { cfg = config_new(); + cfg->path = memdup(path, strlen(path)+1); + } + free(path); cfg->name = memdup(cfgn, strlen(cfgn)+1); @@ -92,7 +93,10 @@ config_stop(config_t *cfg) char *path; if (cfg->changed) { + fprintf(stderr, "cfg->changed\n"); path = config_mkcfgpath(cfg->name); + fprintf(stderr, "path = %s\n", path); + fprintf(stderr, "cfg->path = %s\n", cfg->path); if (config_write(cfg, NULL) == NULL) edie("config_write"); free(path); diff --git a/inc.c b/inc.c @@ -44,10 +44,11 @@ inc_init(char *cfgn) path = inc_mkincfile(cfgn); incs = inc_read(path); - free(path); - - if (incs == NULL) + if (incs == NULL) { incs = inc_new(); + incs->path = memdup(path, strlen(path)+1); + } + free(path); incs->name = memdup(cfgn, strlen(cfgn)+1); diff --git a/mark.c b/mark.c @@ -44,10 +44,11 @@ mark_init(char *cfgn, char *mailbox) path = mark_mkmarkfile(cfgn, mailbox); marks = mark_read(path); - free(path); - - if (marks == NULL) + if (marks == NULL) { marks = mark_new(); + marks->path = memdup(path, strlen(path)+1); + } + free(path); marks->data = memdup(mailbox, strlen(mailbox)+1); marks->name = memdup(cfgn, strlen(cfgn)+1); diff --git a/txtdb.c b/txtdb.c @@ -138,8 +138,6 @@ txtdb_read(char *file) return NULL; } - txtdb->path = memdup(file, strlen(file)+1); - return txtdb; } @@ -157,6 +155,7 @@ txtdb_write(txtdb_t *txtdb, char *file) } } + fprintf(stderr, "file = %s\n", file); fp = fopen(file, "w+"); if (fp == NULL) return NULL;