tAdding tmpl and creating non-existing config files. - rohrpost - A commandline mail client to change the world as we see it.
 (HTM) git clone git://r-36.net/rohrpost
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 8056ab10c09a65ba9a15a09e33d2b8a6dc867539
 (DIR) parent 565c7d9c4b3bc10141f15e0f9bb82e97c36144b3
 (HTM) 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(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       t@@ -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}
 (DIR) diff --git a/cfg.c b/cfg.c
       t@@ -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);
        
       t@@ -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);
 (DIR) diff --git a/inc.c b/inc.c
       t@@ -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);
        
 (DIR) diff --git a/mark.c b/mark.c
       t@@ -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);
 (DIR) diff --git a/txtdb.c b/txtdb.c
       t@@ -138,8 +138,6 @@ txtdb_read(char *file)
                        return NULL;
                }
        
       -        txtdb->path = memdup(file, strlen(file)+1);
       -
                return txtdb;
        }
        
       t@@ -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;