diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-07-29 20:35:00 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-07-29 20:35:00 +0400 |
commit | 4c4773d96b1b2a157009590908fce032696281c5 (patch) | |
tree | c9709f5a21b4eafbfee04327884cb5c6d39006e4 /src/client | |
parent | 513e304bc6255492eee5c78c97d222037087f429 (diff) | |
download | rspamd-4c4773d96b1b2a157009590908fce032696281c5.tar.gz rspamd-4c4773d96b1b2a157009590908fce032696281c5.zip |
* Fix build under CentOS 5 with old glib 2.12
* Fix build of rspamd with CMAKE_BINARY_DIR differs from CMAKE_SOURCE_DIR
Rework include style.
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/client/rspamc.c | 141 |
2 files changed, 75 insertions, 72 deletions
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 38a482d3c..1f2a50b09 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -2,11 +2,15 @@ SET(RSPAMCSRC rspamc.c) ADD_EXECUTABLE(rspamc ${RSPAMCSRC}) -SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I.. -I../../lib") +SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib") TARGET_LINK_LIBRARIES(rspamc rspamdserver) TARGET_LINK_LIBRARIES(rspamc rspamdclient) TARGET_LINK_LIBRARIES(rspamc ${CMAKE_REQUIRED_LIBRARIES}) TARGET_LINK_LIBRARIES(rspamc ${GLIB2_LIBRARIES}) SET_TARGET_PROPERTIES(rspamc PROPERTIES VERSION ${RSPAMD_VERSION}) +IF(GLIB_COMPAT) + TARGET_LINK_LIBRARIES(rspamc glibadditions) +ENDIF(GLIB_COMPAT) + INSTALL(TARGETS rspamc RUNTIME DESTINATION bin) diff --git a/src/client/rspamc.c b/src/client/rspamc.c index a1d79dc96..4f65c6d8f 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -23,7 +23,7 @@ */ #include "config.h" -#include "../../lib/librspamdclient.h" +#include "librspamdclient.h" #define PRINT_FUNC printf @@ -175,14 +175,65 @@ add_rspamd_server (gboolean is_control) } static void +show_symbol_result (gpointer key, gpointer value, gpointer ud) +{ + struct rspamd_symbol *s = value; + GList *cur; + static gboolean first = TRUE; + + if (verbose) { + if (tty) { + PRINT_FUNC ("\n\033[1mSymbol\033[0m - %s(%.2f)", s->name, s->weight); + } + else { + PRINT_FUNC ("\nSymbol - %s(%.2f)", s->name, s->weight); + } + if (s->options) { + PRINT_FUNC (": "); + cur = g_list_first (s->options); + while (cur) { + if (cur->next) { + PRINT_FUNC ("%s,", (const gchar *)cur->data); + } + else { + PRINT_FUNC ("%s", (const gchar *)cur->data); + } + cur = g_list_next (cur); + } + } + if (s->description) { + PRINT_FUNC (" - \"%s\"", s->description); + } + } + else { + if (! first) { + PRINT_FUNC (", "); + } + else { + first = FALSE; + } + PRINT_FUNC ("%s(%.2f)", s->name, s->weight); + + if (s->options) { + PRINT_FUNC ("("); + cur = g_list_first (s->options); + while (cur) { + if (cur->next) { + PRINT_FUNC ("%s,", (const gchar *)cur->data); + } + else { + PRINT_FUNC ("%s)", (const gchar *)cur->data); + } + cur = g_list_next (cur); + } + } + } +} + +static void show_metric_result (gpointer key, gpointer value, gpointer ud) { struct rspamd_metric *metric = value; - struct rspamd_symbol *s; - GList *cur; - GHashTableIter it; - gpointer k, v; - gboolean first; if (metric->is_skipped) { PRINT_FUNC ("\n%s: Skipped\n", (const gchar *)key); @@ -213,70 +264,26 @@ show_metric_result (gpointer key, gpointer value, gpointer ud) } } if (metric->symbols) { - first = TRUE; - g_hash_table_iter_init (&it, metric->symbols); - while (g_hash_table_iter_next (&it, &k, &v)) { - s = v; - if (verbose) { - if (tty) { - PRINT_FUNC ("\n\033[1mSymbol\033[0m - %s(%.2f)", s->name, s->weight); - } - else { - PRINT_FUNC ("\nSymbol - %s(%.2f)", s->name, s->weight); - } - if (s->options) { - PRINT_FUNC (": "); - cur = g_list_first (s->options); - while (cur) { - if (cur->next) { - PRINT_FUNC ("%s,", (const gchar *)cur->data); - } - else { - PRINT_FUNC ("%s", (const gchar *)cur->data); - } - cur = g_list_next (cur); - } - } - if (s->description) { - PRINT_FUNC (" - \"%s\"", s->description); - } - } - else { - if (! first) { - PRINT_FUNC (", "); - } - else { - first = FALSE; - } - PRINT_FUNC ("%s(%.2f)", s->name, s->weight); - - if (s->options) { - PRINT_FUNC ("("); - cur = g_list_first (s->options); - while (cur) { - if (cur->next) { - PRINT_FUNC ("%s,", (const gchar *)cur->data); - } - else { - PRINT_FUNC ("%s)", (const gchar *)cur->data); - } - cur = g_list_next (cur); - } - } - - } - } + g_hash_table_foreach (metric->symbols, show_symbol_result, NULL); } PRINT_FUNC ("\n"); } } static void -print_rspamd_result (struct rspamd_result *res) +show_header_result (gpointer key, gpointer value, gpointer ud) { - GHashTableIter it; - gpointer k, v; + if (tty) { + PRINT_FUNC ("\033[1m%s:\033[0m %s\n", (const gchar *)key, (const gchar *)value); + } + else { + PRINT_FUNC ("%s: %s\n", (const gchar *)key, (const gchar *)value); + } +} +static void +print_rspamd_result (struct rspamd_result *res) +{ g_assert (res != 0); if (tty) { @@ -288,16 +295,8 @@ print_rspamd_result (struct rspamd_result *res) } g_hash_table_foreach (res->metrics, show_metric_result, NULL); /* Show other headers */ - g_hash_table_iter_init (&it, res->headers); PRINT_FUNC ("\n"); - while (g_hash_table_iter_next (&it, &k, &v)) { - if (tty) { - PRINT_FUNC ("\033[1m%s:\033[0m %s\n", (const gchar *)k, (const gchar *)v); - } - else { - PRINT_FUNC ("%s: %s\n", (const gchar *)k, (const gchar *)v); - } - } + g_hash_table_foreach (res->headers, show_header_result, NULL); PRINT_FUNC ("\n"); } |