summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-15 16:32:58 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-15 16:32:58 +0300
commite7ec4dc4dcc484973957c69d15ca8f7aa41aa73e (patch)
tree0e44f307e79f537a14b2cc0c6710790c4be788e3 /src/client
parent66f91e9ce180f82f11f3256dbd05127fe27de893 (diff)
downloadrspamd-e7ec4dc4dcc484973957c69d15ca8f7aa41aa73e.tar.gz
rspamd-e7ec4dc4dcc484973957c69d15ca8f7aa41aa73e.zip
Add support of uptime command to rspamc.0.3.8
Update manpages. Add script for generating manpages from pod.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/rspamc.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index f7ce4e9bc..155db86c6 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -61,7 +61,8 @@ enum rspamc_command {
RSPAMC_COMMAND_LEARN,
RSPAMC_COMMAND_FUZZY_ADD,
RSPAMC_COMMAND_FUZZY_DEL,
- RSPAMC_COMMAND_STAT
+ RSPAMC_COMMAND_STAT,
+ RSPAMC_COMMAND_UPTIME
};
/*
@@ -111,6 +112,9 @@ check_rspamc_command (const gchar *cmd)
else if (g_ascii_strcasecmp (cmd, "STAT") == 0) {
return RSPAMC_COMMAND_STAT;
}
+ else if (g_ascii_strcasecmp (cmd, "UPTIME") == 0) {
+ return RSPAMC_COMMAND_UPTIME;
+ }
return RSPAMC_COMMAND_UNKNOWN;
}
@@ -526,10 +530,40 @@ rspamd_do_stat ()
res = rspamd_get_stat (&err);
if (res == NULL) {
if (err != NULL) {
- fprintf (stderr, "cannot learn message: %s\n", err->message);
+ fprintf (stderr, "cannot stat: %s\n", err->message);
}
else {
- fprintf (stderr, "cannot learn message\n");
+ fprintf (stderr, "cannot stat\n");
+ }
+ exit (EXIT_FAILURE);
+ }
+ if (tty) {
+ printf ("\033[1m");
+ }
+ PRINT_FUNC ("Results for host: %s\n\n", connect_str);
+ if (tty) {
+ printf ("\033[0m");
+ }
+ res = g_string_append_c (res, '\0');
+ printf ("%s\n", res->str);
+}
+
+static void
+rspamd_do_uptime ()
+{
+ GError *err = NULL;
+ GString *res;
+
+ /* Add server */
+ add_rspamd_server (TRUE);
+
+ res = rspamd_get_uptime (&err);
+ if (res == NULL) {
+ if (err != NULL) {
+ fprintf (stderr, "cannot uptime: %s\n", err->message);
+ }
+ else {
+ fprintf (stderr, "cannot uptime\n");
}
exit (EXIT_FAILURE);
}
@@ -580,6 +614,9 @@ main (gint argc, gchar **argv, gchar **env)
case RSPAMC_COMMAND_STAT:
rspamd_do_stat ();
break;
+ case RSPAMC_COMMAND_UPTIME:
+ rspamd_do_uptime ();
+ break;
default:
fprintf (stderr, "invalid arguments\n");
exit (EXIT_FAILURE);