tAdd a way to display the configuration name. - 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 a6963a776475852f96f9e579bff9223b4779d380
 (DIR) parent 8baae4976cc9f03cd1c03e9c06c242de5ce137b2
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Wed, 26 Nov 2014 19:27:19 +0100
       
       Add a way to display the configuration name.
       
       Diffstat:
         cfg.c                               |      20 +++++++++++++++++---
       
       1 file changed, 17 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/cfg.c b/cfg.c
       t@@ -39,7 +39,11 @@ config_init(char *cfgn)
                cfg->path = memdup(path, strlen(path)+1);
                free(path);
        
       -        cfg->name = memdup(cfgn, strlen(cfgn)+1);
       +        if (cfg->name == NULL) {
       +                cfg->name = memdup("default", 8);
       +        } else {
       +                cfg->name = memdup(cfgn, strlen(cfgn)+1);
       +        }
        
                return cfg;
        }
       t@@ -171,7 +175,7 @@ void
        configusage(void)
        {
                die("usage: %s [-hiqv] [-c cfg] [-e cfg|-l|key"
       -                        " [value]]|-d key|-s regex]\n", argv0);
       +                        " [value]]|-d key|-s regex|-n]\n", argv0);
        }
        
        int
       t@@ -190,7 +194,8 @@ configmain(int argc, char *argv[])
                        DODELETE = 0x08,
                        DOSEARCH = 0x10,
                        DOINIT = 0x20,
       -                DODEFAULT = 0x40
       +                DODEFAULT = 0x40,
       +                DONAMECFG = 0x80
                };
        
                status = 0;
       t@@ -213,6 +218,9 @@ configmain(int argc, char *argv[])
                case 'i':
                        status |= DOINIT;
                        break;
       +        case 'n':
       +                status |= DONAMECFG;
       +                break;
                case 'q':
                        status |= BEQUIET;
                        break;
       t@@ -245,6 +253,12 @@ configmain(int argc, char *argv[])
        
                cfg = config_init(cfgn);
        
       +        if (status & DONAMECFG) {
       +                if (cfg->name != NULL)
       +                        printf("%s\n", cfg->name);
       +                return 0;
       +        }
       +
                if (status & DOLIST) {
                        if (config_len(cfg) > 0) {
                                llist_sort(cfg->values);