version 1.1.2.3, 2014/01/30 08:36:39
|
version 1.5, 2017/06/30 08:41:50
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004 - 2014 | Copyright 2004 - 2017 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 60 Usage()
|
Line 60 Usage()
|
"=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
" Syntax: cfger [options] <file_config> [data]\n\n" |
" Syntax: cfger [options] <file_config> [data]\n\n" |
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\n" |
"\t-q\t\tQuiet mode\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 <output>\tOutput result to file\n" |
"\t-o <output>\tOutput result to file\n" |
"\t-l\t\tList A/V pairs\n" |
"\t-l\t\tList A/V pairs\n" |
|
"\t-c <comment>\tAdds comment on program header of file\n" |
"\t-s <attr>\tSet A/V pair\n" |
"\t-s <attr>\tSet A/V pair\n" |
"\t-g <attr>\tGet value from A/V pair\n" |
"\t-g <attr>\tGet value from A/V pair\n" |
"*\"attr\" format: [section/]attribute\n" |
"*\"attr\" format: [section/]attribute\n" |
Line 72 Usage()
|
Line 76 Usage()
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char ch, *str, m = 0, q = 0, 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; |
int ret = 0; |
ait_val_t data = AIT_VAL_INITIALIZER(data); |
ait_val_t data = AIT_VAL_INITIALIZER(data); |
FILE *out = stdout; |
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, "hvqls:g:o:")) != -1) | while ((ch = getopt(argc, argv, "hvqlSJCs:g:o:c:")) != -1) |
switch (ch) { |
switch (ch) { |
case 'v': |
case 'v': |
Verbose++; |
Verbose++; |
Line 85 main(int argc, char **argv)
|
Line 93 main(int argc, char **argv)
|
case 'q': |
case 'q': |
q = 42; |
q = 42; |
break; |
break; |
|
case 'S': |
|
sh ^= sh; |
|
break; |
|
case 'C': |
|
cm ^= cm; |
|
break; |
|
case 'J': |
|
jv = 42; |
|
break; |
case 'o': |
case 'o': |
strlcpy(szName, optarg, sizeof szName); |
strlcpy(szName, optarg, sizeof szName); |
break; |
break; |
|
case 'c': |
|
strlcpy(szComment, optarg, sizeof szComment); |
|
break; |
case 'l': |
case 'l': |
if (m) { |
if (m) { |
Usage(); |
Usage(); |
Line 171 main(int argc, char **argv)
|
Line 191 main(int argc, char **argv)
|
} |
} |
case 'l': |
case 'l': |
default: |
default: |
cfgWriteConfig(out, &cfg, 42); | if (cm) { |
| time(&tim); |
| localtime_r(&tim, &tm); |
| strftime(szTim, sizeof szTim, "%Y-%m-%d %H:%M:%S", &tm); |
| |
| fprintf(out, "# Auto-generated file %s from cfger at %s\n#\n# %s\n\n", *argv, szTim, szComment); |
| } |
| |
| if (jv) |
| cfgWriteConfig(out, &cfg, sh); |
| else { |
| v = cfgWriteLines(out, NULL, NULL, NULL, &cfg); |
| ait_freeVar(&v); |
| } |
| |
break; |
break; |
} |
} |
end: |
end: |