--- embedtools/src/cfger.c 2017/06/29 08:29:46 1.4 +++ embedtools/src/cfger.c 2017/06/30 08:40:48 1.4.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: cfger.c,v 1.4 2017/06/29 08:29:46 misho Exp $ + * $Id: cfger.c,v 1.4.2.1 2017/06/30 08:40:48 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -60,12 +60,13 @@ Usage() "=== %s === %s@%s ===\n\n" " Syntax: cfger [options] [data]\n\n" "\t-v\t\tVerbose ...\n" - "\t-q\t\tQuiet mode\n" - "\t-S\t\tShell script mode\n" - "\t-C\t\tWithout comment header\n" + "\t-q\t\tQuiet mode in Get variable mode. Output is only variable value\n" + "\t-S\t\tShell script mode, without whitespaces between attribute and value\n" + "\t-C\t\tWithout program comment header\n" + "\t-J\t\tFilter output, just variables, exclude entire different data from a/v pair\n" "\t-o \tOutput result to file\n" "\t-l\t\tList A/V pairs\n" - "\t-c \tAdds comment on header of file\n" + "\t-c \tAdds comment on program header of file\n" "\t-s \tSet A/V pair\n" "\t-g \tGet value from A/V pair\n" "*\"attr\" format: [section/]attribute\n" @@ -75,15 +76,16 @@ Usage() int main(int argc, char **argv) { - char ch, *str, m = 0, q = 0, sh = 42, szAttr[STRSIZ], szName[PATH_MAX] = { 0 }; + char ch, *str, m = 0, q = 0, sh = 42, jv = 0, szAttr[STRSIZ], szName[PATH_MAX] = { 0 }; int ret = 0; ait_val_t data = AIT_VAL_INITIALIZER(data); FILE *out = stdout; time_t tim; struct tm tm; char cm = 42, szComment[STRSIZ] = { [0 ... STRSIZ - 1] = 0 }, szTim[STRSIZ] = { 0 }; + ait_val_t *v; - while ((ch = getopt(argc, argv, "hvqlSCs:g:o:c:")) != -1) + while ((ch = getopt(argc, argv, "hvqlSJCs:g:o:c:")) != -1) switch (ch) { case 'v': Verbose++; @@ -97,6 +99,9 @@ main(int argc, char **argv) case 'C': cm ^= cm; break; + case 'J': + jv = 42; + break; case 'o': strlcpy(szName, optarg, sizeof szName); break; @@ -194,7 +199,13 @@ main(int argc, char **argv) fprintf(out, "# Auto-generated file %s from cfger at %s\n#\n# %s\n\n", *argv, szTim, szComment); } - cfgWriteConfig(out, &cfg, sh); + if (jv) + cfgWriteConfig(out, &cfg, sh); + else { + v = cfgWriteLines(out, NULL, NULL, NULL, &cfg); + ait_freeVar(&v); + } + break; } end: