diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-08-14 08:35:48 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-08-14 08:44:04 +0300 |
commit | b46d05edecdbf77cb37205d9d29688851c5cd94c (patch) | |
tree | a942c7193de4b7485d82fae4dd04ff0dcebd24fd | |
parent | e0c4fa084b5d59f862276ddfa72b56b4a77babe1 (diff) | |
download | cfpeek-b46d05edecdbf77cb37205d9d29688851c5cd94c.tar.gz cfpeek-b46d05edecdbf77cb37205d9d29688851c5cd94c.tar.bz2 |
New option --done=expr supplies a cleanup expression.
This expression is run once, when the main loop has finished iterating
over all nodes.
* doc/cfpeek.1: Document the --done option.
* doc/cfpeek.texi: Likewise.
* NEWS: Update.
* configure.ac: Version 1.1.90
* src/cfpeek.c (script_done_expr): New variable.
(main): Call script_done before exiting.
* src/cfpeek.h (script_done_expr): New extern
(script_done, guile_done): New protos.
* src/cmdline.opt (done): New option.
* src/guile.c (guile_done): New function.
* src/script.c (script_tab) <done>: New member.
(script_tab): Fill in the new structure member.
(script_done): New function.
-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 @@ | |||
1 | Cfpeek NEWS -- history of user-visible changes. 2012-03-30 | 1 | Cfpeek NEWS -- history of user-visible changes. 2012-08-14 |
2 | Copyright (C) 2011, 2012 Sergey Poznyakoff | 2 | Copyright (C) 2011, 2012 Sergey Poznyakoff |
3 | See the end of file for copying conditions. | 3 | See the end of file for copying conditions. |
4 | 4 | ||
5 | Please send cfpeek bug reports to <bug-cfpeek@gnu.org.ua> | 5 | Please send cfpeek bug reports to <bug-cfpeek@gnu.org.ua> |
6 | 6 | ||
7 | 7 | ||
8 | Version 1.1.90 (Git) | ||
9 | |||
10 | * New command line option --done (-d) | ||
11 | |||
12 | This option is a counterpart of --init and supplies a cleanup | ||
13 | expression, i.e. an expression that will be evaluated when the | ||
14 | main loop has iterated over all nodes in the tree. | ||
15 | |||
16 | * New parser: DHCPD | ||
17 | |||
18 | A parser for dhcpd.conf file. | ||
19 | |||
20 | |||
8 | Version 1.1, 2012-03-30 | 21 | Version 1.1, 2012-03-30 |
9 | 22 | ||
10 | * New command line option --init (-i) | 23 | * 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 @@ | |||
15 | # along with cfpeek. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with cfpeek. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | AC_PREREQ(2.63) | 17 | AC_PREREQ(2.63) |
18 | AC_INIT([cfpeek], 1.1, [bug-cfpeek@gnu.org.ua],, | 18 | AC_INIT([cfpeek], 1.1.90, [bug-cfpeek@gnu.org.ua],, |
19 | [http://www.gnu.org.ua/software/cfpeek]) | 19 | [http://www.gnu.org.ua/software/cfpeek]) |
20 | AC_CONFIG_SRCDIR([src/cfpeek.c]) | 20 | AC_CONFIG_SRCDIR([src/cfpeek.c]) |
21 | AC_CONFIG_AUX_DIR([build-aux]) | 21 | 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 @@ | |||
14 | .\" You should have received a copy of the GNU General Public License | 14 | .\" You should have received a copy of the GNU General Public License |
15 | .\" along with cfpeek. If not, see <http://www.gnu.org/licenses/>. | 15 | .\" along with cfpeek. If not, see <http://www.gnu.org/licenses/>. |
16 | .\" | 16 | .\" |
17 | .TH CFPEEK 1 "August 13, 2012" "CFPEEK" "Cfpeek User Reference" | 17 | .TH CFPEEK 1 "August 14, 2012" "CFPEEK" "Cfpeek User Reference" |
18 | .SH NAME | 18 | .SH NAME |
19 | cfpeek \- retrieve values from a structured configuration file | 19 | cfpeek \- retrieve values from a structured configuration file |
20 | .SH SYNOPSIS | 20 | .SH SYNOPSIS |
@@ -434,6 +434,10 @@ This option provides an initialization expression, which is evaluated | |||
434 | once, after loading the script file, if one is specified, and before | 434 | once, after loading the script file, if one is specified, and before |
435 | starting the main loop. | 435 | starting the main loop. |
436 | .TP | 436 | .TP |
437 | \fB\-d\fR, \fB\-\-done=\fIEXPR\fR | ||
438 | This option supplies a cleanup expression. The expression will be | ||
439 | evaluated once, after the main loop finishes. | ||
440 | .TP | ||
437 | \fB\-l\fR, \fB\-\-lang\fR=\fINAME\fR | 441 | \fB\-l\fR, \fB\-\-lang\fR=\fINAME\fR |
438 | Select scripting language to use. This is reserved for future use. | 442 | Select scripting language to use. This is reserved for future use. |
439 | .SS Preprocessor control | 443 | .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 | |||
673 | evaluated once, after loading the script file, if one is specified, | 673 | evaluated once, after loading the script file, if one is specified, |
674 | and before starting the main loop. | 674 | and before starting the main loop. |
675 | 675 | ||
676 | @xopindex{done,d,described} | ||
677 | Similarly, the option @option{--done=@var{expr}} (@option{-d | ||
678 | @var{expr}}) introduces a Scheme expression to be evaluated at the end | ||
679 | of the run, after all nodes have been processed. | ||
680 | |||
676 | @menu | 681 | @menu |
677 | * Scripting Example:: | 682 | * Scripting Example:: |
678 | @end menu | 683 | @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; | |||
28 | char *script_file; | 28 | char *script_file; |
29 | char *script_expr; | 29 | char *script_expr; |
30 | char *script_init_expr; | 30 | char *script_init_expr; |
31 | char *script_done_expr; | ||
31 | 32 | ||
32 | #define MODE_GLOB 0 | 33 | #define MODE_GLOB 0 |
33 | #define MODE_LITERAL 1 | 34 | #define MODE_LITERAL 1 |
@@ -269,6 +270,7 @@ main(int argc, char **argv) | |||
269 | if (argc < 2) { | 270 | if (argc < 2) { |
270 | flags |= GRECS_NODE_FLAG_DESCEND; | 271 | flags |= GRECS_NODE_FLAG_DESCEND; |
271 | scan_tree(tree); | 272 | scan_tree(tree); |
273 | script_done(); | ||
272 | exit(EX_OK); | 274 | exit(EX_OK); |
273 | } | 275 | } |
274 | 276 | ||
@@ -294,5 +296,6 @@ main(int argc, char **argv) | |||
294 | } | 296 | } |
295 | cfp->free_buf(match_buf); | 297 | cfp->free_buf(match_buf); |
296 | } | 298 | } |
299 | script_done(); | ||
297 | exit(rc); | 300 | exit(rc); |
298 | } | 301 | } |
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; | |||
35 | extern char *script_file; | 35 | extern char *script_file; |
36 | extern char *script_expr; | 36 | extern char *script_expr; |
37 | extern char *script_init_expr; | 37 | extern char *script_init_expr; |
38 | extern char *script_done_expr; | ||
38 | 39 | ||
39 | void script_select(const char *lang); | 40 | void script_select(const char *lang); |
40 | void script_init(void); | 41 | void script_init(void); |
41 | int script_run(struct grecs_node *node); | 42 | int script_run(struct grecs_node *node); |
43 | void script_done(void); | ||
42 | 44 | ||
43 | void guile_init(void); | 45 | void guile_init(void); |
44 | void guile_apply(struct grecs_node *node); | 46 | void guile_apply(struct grecs_node *node); |
47 | void guile_done(void); | ||
45 | 48 | ||
46 | 49 | ||
47 | 50 | ||
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 | |||
313 | script_init_expr = optarg; | 313 | script_init_expr = optarg; |
314 | END | 314 | END |
315 | 315 | ||
316 | OPTION(done,d,EXPR, | ||
317 | [<final cleanup expession>]) | ||
318 | BEGIN | ||
319 | script_done_expr = optarg; | ||
320 | END | ||
321 | |||
316 | GROUP(Preprocessor control) | 322 | GROUP(Preprocessor control) |
317 | 323 | ||
318 | OPTION(include-directory,I,DIR, | 324 | 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) | |||
881 | } | 881 | } |
882 | } | 882 | } |
883 | 883 | ||
884 | void | ||
885 | guile_done() | ||
886 | { | ||
887 | if (script_done_expr) | ||
888 | scm_c_eval_string(script_done_expr); | ||
889 | } | ||
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 { | |||
22 | char *suf; | 22 | char *suf; |
23 | void (*init)(void); | 23 | void (*init)(void); |
24 | void (*run)(struct grecs_node *); | 24 | void (*run)(struct grecs_node *); |
25 | void (*done)(void); | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | static struct script_tab script_tab[] = { | 28 | static struct script_tab script_tab[] = { |
28 | #ifdef GUILE_VERSION_NUMBER | 29 | #ifdef GUILE_VERSION_NUMBER |
29 | { "scheme", "scm\0", guile_init, guile_apply }, | 30 | { "scheme", "scm\0", guile_init, guile_apply, guile_done }, |
30 | #endif | 31 | #endif |
31 | { NULL } | 32 | { NULL } |
32 | }; | 33 | }; |
@@ -103,3 +104,9 @@ script_run(struct grecs_node *node) | |||
103 | return 1; | 104 | return 1; |
104 | } | 105 | } |
105 | 106 | ||
107 | void | ||
108 | script_done() | ||
109 | { | ||
110 | if (cur_script) | ||
111 | cur_script->done(); | ||
112 | } | ||