aboutsummaryrefslogtreecommitdiff
path: root/src/piesctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/piesctl.c')
-rw-r--r--src/piesctl.c103
1 files changed, 48 insertions, 55 deletions
diff --git a/src/piesctl.c b/src/piesctl.c
index d790ab2..2de7ea0 100644
--- a/src/piesctl.c
+++ b/src/piesctl.c
@@ -1,5 +1,5 @@
/* This file is part of GNU Pies.
- Copyright (C) 2015-2020 Sergey Poznyakoff
+ Copyright (C) 2015-2023 Sergey Poznyakoff
GNU Pies is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -136,9 +136,7 @@ parse_config (void)
{
char *file_name;
struct grecs_node *tree;
-
- grecs_include_path_setup (DEFAULT_VERSION_INCLUDE_DIR,
- DEFAULT_INCLUDE_DIR, NULL);
+
grecs_log_to_stderr = 1;
grecs_preprocessor = pp_command_line ();
grecs_sockaddr_hints = &hints;
@@ -153,7 +151,7 @@ parse_config (void)
if (file_name)
{
if (preprocess_only)
- exit (grecs_preproc_run (file_name, grecs_preprocessor)
+ exit (grecs_preprocess (file_name, 0)
? EX_CONFIG : EX_OK);
if (verbose)
printf (_("%s: reading configuration from %s\n"),
@@ -168,7 +166,7 @@ parse_config (void)
program_name, file_name);
}
- if (!client.url)
+ if (!client.url && !default_url)
{
/* Try local instance configuration */
file_name = mkfilename (SYSCONFDIR, instance, ".conf");
@@ -180,7 +178,7 @@ parse_config (void)
printf (_("%s: reading configuration from %s\n"),
program_name, file_name);
if (preprocess_only)
- exit (grecs_preproc_run (file_name, grecs_preprocessor)
+ exit (grecs_preprocess (file_name, 0)
? EX_CONFIG : EX_OK);
tree = grecs_parse (file_name);
node = grecs_find_node (tree, "/control/socket");
@@ -744,7 +742,7 @@ shttp_print_error (struct shttp_connection *conn)
{
struct json_value *jv;
- if (conn->result && (jv = json_value_lookup (conn->result, "error_message")))
+ if (conn->result && (jv = json_value_lookup (conn->result, "message")))
{
if (jv->type == json_string)
grecs_error (NULL, 0, "%s", jv->v.s);
@@ -1075,10 +1073,6 @@ print_comp (FILE *fp, struct json_value *v, size_t n)
else
fbuf[fidx++] = '-';
}
- else if (strcmp (type, "redirector") == 0)
- {
- fbuf[fidx++] = 'R';
- }
else if (strcmp (type, "command") == 0)
{
fbuf[fidx++] = 'E';
@@ -1125,12 +1119,6 @@ print_comp (FILE *fp, struct json_value *v, size_t n)
}
}
}
- else if (strcmp (type, "redirector") == 0)
- {
- p = getval (v, "PID", json_number, 0);
- if (p)
- fprintf (fp, "%10.0f ", p->v.n);
- }
else if (strcmp (type, "command") == 0)
{
p = getval (v, "command", json_string, 0);
@@ -1465,40 +1453,44 @@ shttp_print_response_status (struct shttp_connection *conn)
if (!dump && conn->result && conn->result->type == json_arr)
{
size_t i, n = json_array_size (conn->result);
-
- for (i = 0; i < n; i++)
+
+ if (n == 0)
{
- struct json_value *elt, *v;
-
- if (json_array_get (conn->result, i, &elt) == 0)
- {
- if (elt->type != json_object)
- {
- grecs_error (NULL, 0, _("%lu: unexpected value type"),
- (unsigned long) i);
- print_json (stderr, v);
- continue;
- }
- if (json_object_get_type (elt, "tag", json_string, &v) == 0)
- {
- printf ("%s: ", v->v.s);
- if (json_object_get_type (elt, "status", json_string, &v)
- == 0)
- {
- if (strcmp (v->v.s, "OK") == 0)
- fputs (v->v.s, stdout);
- else if (json_object_get_type (elt, "error_message",
- json_string, &v) == 0)
- fputs (v->v.s, stdout);
- else
- printf (_("unknown error"));
- }
- else
- printf (_("unknown status"));
- fputc ('\n', stdout);
- }
- }
+ grecs_error (NULL, 0, _("no component matches the supplied condition"));
}
+ else
+ for (i = 0; i < n; i++)
+ {
+ struct json_value *elt, *v;
+
+ if (json_array_get (conn->result, i, &elt) == 0)
+ {
+ if (elt->type != json_object)
+ {
+ grecs_error (NULL, 0, _("%lu: unexpected value type"),
+ (unsigned long) i);
+ print_json (stderr, v);
+ continue;
+ }
+ if (json_object_get_type (elt, "tag", json_string, &v) == 0)
+ {
+ printf ("%s: ", v->v.s);
+ if (json_object_get_type (elt, "status", json_string, &v) == 0)
+ {
+ if (strcmp (v->v.s, "OK") == 0)
+ fputs (v->v.s, stdout);
+ else if (json_object_get_type (elt, "message",
+ json_string, &v) == 0)
+ fputs (v->v.s, stdout);
+ else
+ printf (_("unknown error"));
+ }
+ else
+ printf (_("unknown status"));
+ fputc ('\n', stdout);
+ }
+ }
+ }
}
}
@@ -1766,7 +1758,7 @@ telinit_format_environ (struct shttp_connection *conn)
}
else if (strcmp (val->v.s, "ER") == 0)
{
- if (json_object_get_type (conn->result, "error_message",
+ if (json_object_get_type (conn->result, "message",
json_string, &val) == 0)
fputs (val->v.s, stderr);
else
@@ -1967,7 +1959,7 @@ conf_reload (struct cmdline_parser_state *state)
val = json_object_require_type (conn->result, "status", json_string);
if (strcmp (val->v.s, "ER") == 0)
{
- if (json_object_get_type (conn->result, "error_message",
+ if (json_object_get_type (conn->result, "message",
json_string, &val) == 0)
fputs (val->v.s, stdout);
else
@@ -2042,7 +2034,7 @@ conf_file_clear (struct cmdline_parser_state *state)
val = json_object_require_type (conn->result, "status", json_string);
if (strcmp (val->v.s, "OK"))
{
- if (json_object_get_type (conn->result, "error_message",
+ if (json_object_get_type (conn->result, "message",
json_string, &val) == 0)
fputs (val->v.s, stderr);
else
@@ -2094,7 +2086,7 @@ conf_file_del (struct cmdline_parser_state *state)
val = json_object_require_type (conn->result, "status", json_string);
if (strcmp (val->v.s, "OK") == 0)
{
- if (json_object_get_type (conn->result, "error_message",
+ if (json_object_get_type (conn->result, "message",
json_string, &val) == 0)
{
fputs (val->v.s, stderr);
@@ -2119,7 +2111,7 @@ conf_file_del (struct cmdline_parser_state *state)
}
else
{
- if (json_object_get_type (conn->result, "error_message",
+ if (json_object_get_type (conn->result, "message",
json_string, &val) == 0)
fputs (val->v.s, stderr);
else
@@ -2332,6 +2324,7 @@ main (int argc, char **argv)
textdomain (PACKAGE);
#endif
grecs_print_diag_fun = piesctl_diag;
+ grecs_preprocessor = DEFAULT_PREPROCESSOR;
proginfo.print_help_hook = command_help;
parse_options (argc, argv, &i);

Return to:

Send suggestions and report system problems to the System administrator.