aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-28 14:15:44 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-09-28 14:15:44 +0300
commit4aef6e9feff509e8cb267473d505e82dd794df78 (patch)
tree7fd0ae1364812384858a7dfbf665c542b2d3ca0e /src/config.c
parentac1d6cbbcf5323d5db59886b98a24c45bafa64b8 (diff)
downloadeclat-4aef6e9feff509e8cb267473d505e82dd794df78.tar.gz
eclat-4aef6e9feff509e8cb267473d505e82dd794df78.tar.bz2
Add user-defined formats.
* etc/Makefile.am: Minor fixes. * src/cmdline.opt: New option --format. Add alias --formfile to --format-file * src/config.c: New configuration statement "define-format". * src/eclat.c (define_format): Rename to set_command_format. All uses changed. (define_format,find_format): New functions (read_format): Compile named format, if supplied with the --format option. * src/eclat.h: Update.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c
index aa60323..69835b9 100644
--- a/src/config.c
+++ b/src/config.c
@@ -103,9 +103,6 @@ cb_format(enum grecs_callback_command cmd,
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;
@@ -119,9 +116,36 @@ cb_format(enum grecs_callback_command cmd,
grecs_error(locus, 0, "expected two strings");
return 1;
}
+ set_command_format(value->v.arg.v[0]->v.string,
+ value->v.arg.v[1]->v.string,
+ &value->v.arg.v[1]->locus);
+}
+
+static int
+cb_define_format(enum grecs_callback_command cmd,
+ grecs_locus_t *locus,
+ void *varptr,
+ grecs_value_t *value,
+ void *cb_data)
+{
+ 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);
+ return 0;
}
static struct grecs_keyword eclat_kw[] = {
@@ -138,8 +162,11 @@ static struct grecs_keyword eclat_kw[] = {
"Define default AWS region",
grecs_type_string, GRECS_DFLT, &region_name },
{ "format", "<command: string> <format: string>",
- "Set default format for the <command>",
+ "Set default format for <command>",
grecs_type_string, GRECS_MULT, NULL, 0, cb_format },
+ { "define-format", "<name: string> <format: string>",
+ "Define a named format",
+ grecs_type_string, GRECS_MULT, NULL, 0, cb_define_format },
{ "format-file", "file", "Read format from <file>",
grecs_type_string, GRECS_DFLT, &format_file },
{ NULL }

Return to:

Send suggestions and report system problems to the System administrator.