diff options
-rw-r--r-- | NEWS | 15 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/cfpeek.1 | 6 | ||||
-rw-r--r-- | doc/cfpeek.texi | 5 | ||||
-rw-r--r-- | src/cfpeek.c | 3 | ||||
-rw-r--r-- | src/cfpeek.h | 3 | ||||
-rw-r--r-- | src/cmdline.opt | 6 | ||||
-rw-r--r-- | src/guile.c | 6 | ||||
-rw-r--r-- | src/script.c | 9 |
9 files changed, 51 insertions, 4 deletions
@@ -1,10 +1,23 @@ -Cfpeek NEWS -- history of user-visible changes. 2012-03-30 +Cfpeek NEWS -- history of user-visible changes. 2012-08-14 Copyright (C) 2011, 2012 Sergey Poznyakoff See the end of file for copying conditions. Please send cfpeek bug reports to <bug-cfpeek@gnu.org.ua> +Version 1.1.90 (Git) + +* New command line option --done (-d) + +This option is a counterpart of --init and supplies a cleanup +expression, i.e. an expression that will be evaluated when the +main loop has iterated over all nodes in the tree. + +* New parser: DHCPD + +A parser for dhcpd.conf file. + + Version 1.1, 2012-03-30 * New command line option --init (-i) diff --git a/configure.ac b/configure.ac index 5ee8bc2..4792a9c 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ # along with cfpeek. If not, see <http://www.gnu.org/licenses/>. AC_PREREQ(2.63) -AC_INIT([cfpeek], 1.1, [bug-cfpeek@gnu.org.ua],, +AC_INIT([cfpeek], 1.1.90, [bug-cfpeek@gnu.org.ua],, [http://www.gnu.org.ua/software/cfpeek]) AC_CONFIG_SRCDIR([src/cfpeek.c]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/doc/cfpeek.1 b/doc/cfpeek.1 index ff8ffa9..ca76ec1 100644 --- a/doc/cfpeek.1 +++ b/doc/cfpeek.1 @@ -14,7 +14,7 @@ .\" You should have received a copy of the GNU General Public License .\" along with cfpeek. If not, see <http://www.gnu.org/licenses/>. .\" -.TH CFPEEK 1 "August 13, 2012" "CFPEEK" "Cfpeek User Reference" +.TH CFPEEK 1 "August 14, 2012" "CFPEEK" "Cfpeek User Reference" .SH NAME cfpeek \- retrieve values from a structured configuration file .SH SYNOPSIS @@ -434,6 +434,10 @@ This option provides an initialization expression, which is evaluated once, after loading the script file, if one is specified, and before starting the main loop. .TP +\fB\-d\fR, \fB\-\-done=\fIEXPR\fR +This option supplies a cleanup expression. The expression will be +evaluated once, after the main loop finishes. +.TP \fB\-l\fR, \fB\-\-lang\fR=\fINAME\fR Select scripting language to use. This is reserved for future use. .SS Preprocessor control diff --git a/doc/cfpeek.texi b/doc/cfpeek.texi index f2eae83..6b59e02 100644 --- a/doc/cfpeek.texi +++ b/doc/cfpeek.texi @@ -673,6 +673,11 @@ provides an initialization expression @var{expr}. This expression is evaluated once, after loading the script file, if one is specified, and before starting the main loop. +@xopindex{done,d,described} +Similarly, the option @option{--done=@var{expr}} (@option{-d +@var{expr}}) introduces a Scheme expression to be evaluated at the end +of the run, after all nodes have been processed. + @menu * Scripting Example:: @end menu diff --git a/src/cfpeek.c b/src/cfpeek.c index c096dda..1b4e125 100644 --- a/src/cfpeek.c +++ b/src/cfpeek.c @@ -28,6 +28,7 @@ unsigned max_matches; char *script_file; char *script_expr; char *script_init_expr; +char *script_done_expr; #define MODE_GLOB 0 #define MODE_LITERAL 1 @@ -269,6 +270,7 @@ main(int argc, char **argv) if (argc < 2) { flags |= GRECS_NODE_FLAG_DESCEND; scan_tree(tree); + script_done(); exit(EX_OK); } @@ -294,5 +296,6 @@ main(int argc, char **argv) } cfp->free_buf(match_buf); } + script_done(); exit(rc); } diff --git a/src/cfpeek.h b/src/cfpeek.h index c5694cf..7c7d610 100644 --- a/src/cfpeek.h +++ b/src/cfpeek.h @@ -35,13 +35,16 @@ extern char *program_name; extern char *script_file; extern char *script_expr; extern char *script_init_expr; +extern char *script_done_expr; void script_select(const char *lang); void script_init(void); int script_run(struct grecs_node *node); +void script_done(void); void guile_init(void); void guile_apply(struct grecs_node *node); +void guile_done(void); diff --git a/src/cmdline.opt b/src/cmdline.opt index 55bc403..c4afef4 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -313,6 +313,12 @@ BEGIN script_init_expr = optarg; END +OPTION(done,d,EXPR, + [<final cleanup expession>]) +BEGIN + script_done_expr = optarg; +END + GROUP(Preprocessor control) OPTION(include-directory,I,DIR, diff --git a/src/guile.c b/src/guile.c index 254d671..1190fa7 100644 --- a/src/guile.c +++ b/src/guile.c @@ -881,3 +881,9 @@ guile_apply(struct grecs_node *node) } } +void +guile_done() +{ + if (script_done_expr) + scm_c_eval_string(script_done_expr); +} diff --git a/src/script.c b/src/script.c index 869df55..45049fd 100644 --- a/src/script.c +++ b/src/script.c @@ -22,11 +22,12 @@ struct script_tab { char *suf; void (*init)(void); void (*run)(struct grecs_node *); + void (*done)(void); }; static struct script_tab script_tab[] = { #ifdef GUILE_VERSION_NUMBER - { "scheme", "scm\0", guile_init, guile_apply }, + { "scheme", "scm\0", guile_init, guile_apply, guile_done }, #endif { NULL } }; @@ -103,3 +104,9 @@ script_run(struct grecs_node *node) return 1; } +void +script_done() +{ + if (cur_script) + cur_script->done(); +} |