[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 9068dfe: Four common options now usable in con
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 9068dfe: Four common options now usable in config files |
Date: |
Fri, 11 Nov 2016 22:15:00 +0000 (UTC) |
branch: master
commit 9068dfeda9b7b993a2a9e6ba35560309646aa5b4
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Four common options now usable in config files
Not all the common options could be used (read from or written to) in
configuration files until now. So with this commit, the four common options
`--quiet', `--onlydirconf', `--dontdelete', and `--keepinputdir' are now
read from and written to configuration files.
Note that options like `--cite', `--printparams', `--setusrconf',
`--setdirconf', along with `--help', `--usage' and `--version' don't need
to be put in the configuration files, so not all common options needed to
be included there.
This finishes task #14219.
---
lib/commonargs.h | 5 +++++
lib/commonparams.h | 4 ++++
lib/configfiles.h | 58 ++++++++++++++++++++++++++++++++++++++++++++--------
3 files changed, 58 insertions(+), 9 deletions(-)
diff --git a/lib/commonargs.h b/lib/commonargs.h
index 7881e39..99425e2 100644
--- a/lib/commonargs.h
+++ b/lib/commonargs.h
@@ -213,9 +213,11 @@ gal_checkset_commonargs_cparse_opt(int key, char *arg,
struct argp_state *state)
switch(key)
{
+
/* Operating modes: */
case 'q':
cp->verb=0;
+ cp->quietset=1;
break;
case 'P':
cp->printparams=1;
@@ -236,6 +238,7 @@ gal_checkset_commonargs_cparse_opt(int key, char *arg,
struct argp_state *state)
break;
case 1001:
cp->onlydirconf=1;
+ cp->onlydirconfset=1;
break;
case 1002:
cp->onlyversion=arg;
@@ -255,9 +258,11 @@ gal_checkset_commonargs_cparse_opt(int key, char *arg,
struct argp_state *state)
break;
case 'D':
cp->dontdelete=1;
+ cp->dontdeleteset=1;
break;
case 'K':
cp->removedirinfo=0;
+ cp->removedirinfoset=1;
break;
diff --git a/lib/commonparams.h b/lib/commonparams.h
index f5b6259..d426e00 100644
--- a/lib/commonparams.h
+++ b/lib/commonparams.h
@@ -50,11 +50,15 @@ struct gal_commonparams
int nolog; /* ==1: do not make a log file. */
/* Check: */
+ int quietset; /* If the verbose flag is called. */
int numthreadsset; /* If the number of threads are set. */
int onlyversionset; /* If the only version option is set. */
+ int onlydirconfset; /* If --onlydirconf was set before this. */
int hduset; /* If the input image extension is set. */
int outputset; /* If the output is set. */
int nologset; /* If nolog is set. */
+ int dontdeleteset; /* If the --dontdelete option was called. */
+ int removedirinfoset; /* If --keepinputdir was called. */
};
#endif
diff --git a/lib/configfiles.h b/lib/configfiles.h
index 09db2f6..1dfba5d 100644
--- a/lib/configfiles.h
+++ b/lib/configfiles.h
@@ -190,6 +190,15 @@ __BEGIN_C_DECLS /* From C++ preparations */
configuration file. Since these two checks are within an if-else
structure, they should not be placed within an `{' and `}'. */
#define GAL_CONFIGFILES_READ_COMMONOPTIONS_FROM_CONF \
+ else if(strcmp(name, "quiet")==0) \
+ { \
+ int tint; \
+ if(cp->quietset) continue; \
+ gal_checkset_int_zero_or_one(value, &tint, name, key, SPACK, \
+ filename, lineno); \
+ cp->verb=!tint; \
+ cp->quietset=1; \
+ } \
else if(strcmp(name, "numthreads")==0) \
{ \
if(cp->numthreadsset) continue; \
@@ -197,6 +206,20 @@ __BEGIN_C_DECLS /* From C++ preparations */
SPACK, filename, lineno); \
cp->numthreadsset=1; \
} \
+ else if(strcmp(name, "onlydirconf")==0) \
+ { \
+ if(cp->onlydirconfset) continue; \
+ gal_checkset_int_zero_or_one(value, &cp->onlydirconf, name, \
+ key, SPACK, filename, lineno); \
+ cp->onlydirconfset=1; \
+ } \
+ else if(strcmp(name, "onlyversion")==0) \
+ { \
+ if(cp->onlyversionset) continue; \
+ gal_checkset_allocate_copy_set(value, &cp->onlyversion, \
+ &cp->onlyversionset); \
+ cp->onlyversionset=1; \
+ } \
else if(strcmp(name, "nolog")==0) \
{ \
if(cp->nologset) continue; \
@@ -204,15 +227,24 @@ __BEGIN_C_DECLS /* From C++ preparations */
SPACK, filename, lineno); \
cp->nologset=1; \
} \
- else if(strcmp(name, "onlydirconf")==0) \
+ \
+ \
+ else if(strcmp(name, "dontdelete")==0) \
{ \
- if(cp->onlydirconf==0) \
- gal_checkset_int_zero_or_one(value, &cp->onlydirconf, name, \
- key, SPACK, filename, lineno); \
+ if(cp->dontdeleteset) continue; \
+ gal_checkset_int_zero_or_one(value, &cp->dontdelete, name, key, \
+ SPACK, filename, lineno); \
+ cp->dontdeleteset=1; \
+ } \
+ else if(strcmp(name, "keepinputdir")==0) \
+ { \
+ int tint; \
+ if(cp->removedirinfoset) continue; \
+ gal_checkset_int_zero_or_one(value, &tint, name, key, \
+ SPACK, filename, lineno); \
+ cp->removedirinfo=!tint; \
+ cp->removedirinfoset=1; \
} \
- else if(strcmp(name, "onlyversion")==0) \
- gal_checkset_allocate_copy_set(value, &cp->onlyversion, \
- &cp->onlyversionset); \
@@ -221,13 +253,21 @@ __BEGIN_C_DECLS /* From C++ preparations */
/* Write common options: */
#define GAL_CONFIGFILES_PRINT_COMMONOPTIONS { \
+ if(cp->quietset) \
+ fprintf(fp, CONF_SHOWFMT"%d\n", "quiet", !p->cp.verb); \
if(cp->numthreadsset) \
fprintf(fp, CONF_SHOWFMT"%zu\n", "numthreads", p->cp.numthreads); \
- if(cp->nologset) \
- fprintf(fp, CONF_SHOWFMT"%d\n", "nolog", p->cp.nolog); \
+ if(cp->onlydirconfset) \
+ fprintf(fp, CONF_SHOWFMT"%d\n", "onlydirconf", p->cp.onlydirconf);\
if(cp->onlyversionset) \
GAL_CHECKSET_PRINT_STRING_MAYBE_WITH_SPACE("onlyversion", \
cp->onlyversion); \
+ if(cp->nologset) \
+ fprintf(fp, CONF_SHOWFMT"%d\n", "nolog", p->cp.nolog); \
+ if(cp->dontdeleteset) \
+ fprintf(fp, CONF_SHOWFMT"%d\n", "dontdelete", p->cp.dontdelete); \
+ if(cp->removedirinfoset) \
+ fprintf(fp, CONF_SHOWFMT"%d\n", "keepinputdir", !p->cp.removedirinfo); \
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 9068dfe: Four common options now usable in config files,
Mohammad Akhlaghi <=