aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 17:31:24 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 17:45:23 +0300
commit455e12faaf5efd997ff74ad04c0fcc62608477a5 (patch)
tree46d24aba487fb2ea76078ef4da60357ff0a340e4 /src/config.c
parent2f5d961c798802f1e467de1cd310f661e0a45fa7 (diff)
downloadeclat-455e12faaf5efd997ff74ad04c0fcc62608477a5.tar.gz
eclat-455e12faaf5efd997ff74ad04c0fcc62608477a5.tar.bz2
Use forlan to format the output.
* lib/forlan.h (forlan_lex_begin): Remove (forlan_lex_from_buffer) (forlan_lex_from_file): New protos. (forlan_parse): Remove. (forlan_parse_bufferm,forlan_parse_file): New protos. * lib/forlangrm.y (forlan_parse): Remove. (forlan_parse_bufferm,forlan_parse_file): New functions. * lib/forlanlex.l (YY_INPUT): Optionally, read input from file. (forlan_lex_begin): Remove (forlan_lex_from_buffer) (forlan_lex_from_file): New functions. * src/cmdline.opt: New options: --format, --sort * src/config.c: New statement: format. * src/eclat.c: Use output format scripts, if provided. * src/eclat.conf: Define output format for DescribeTags. * src/eclat.h: Include forlan.h (define_format): New proto. * tests/tforlan.c: New option: -s
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c
index b718486..82033d3 100644
--- a/src/config.c
+++ b/src/config.c
@@ -96,6 +96,34 @@ cb_region(enum grecs_callback_command cmd,
return 0;
}
+static int
+cb_format(enum grecs_callback_command cmd,
+ grecs_locus_t *locus,
+ void *varptr,
+ grecs_value_t *value,
+ void *cb_data)
+{
+ struct ec2_param *p, key;
+ int install = 1;
+
+ if (cmd != grecs_callback_set_value) {
+ grecs_error(locus, 0, "Unexpected block statement");
+ return 1;
+ }
+ if (!value || value->type != GRECS_TYPE_ARRAY || value->v.arg.c != 2) {
+ grecs_error(locus, 0, "expected two strings");
+ return 1;
+ }
+ if (value->v.arg.v[0]->type != GRECS_TYPE_STRING ||
+ value->v.arg.v[1]->type != GRECS_TYPE_STRING) {
+ grecs_error(locus, 0, "expected two strings");
+ return 1;
+ }
+ define_format(value->v.arg.v[0]->v.string,
+ value->v.arg.v[1]->v.string,
+ &value->v.arg.v[1]->locus);
+}
+
static struct grecs_keyword eclat_kw[] = {
{ "default-endpoint", "hostname",
"Set default EC2 endpoint",
@@ -109,7 +137,9 @@ static struct grecs_keyword eclat_kw[] = {
{ "default-region", "name",
"Define default AWS region",
grecs_type_string, GRECS_DFLT, &region_name },
-
+ { "format", "<command: string> <format: string>",
+ "Set default format for the <command>",
+ grecs_type_string, GRECS_MULT, NULL, 0, cb_format },
{ NULL }
};

Return to:

Send suggestions and report system problems to the System administrator.