commit 537a718: [Rework] Use clang-format to unify formatting in all sources

Vsevolod Stakhov vsevolod at rspamd.com
Wed Jul 26 09:56:28 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-07-26 10:49:23 +0100
URL: https://github.com/rspamd/rspamd/commit/537a7180a0d5132c11636c4fd8b1450cd99d352c (HEAD -> master)

[Rework] Use clang-format to unify formatting in all sources
No meaningful changes.

---
 .clang-format                                      |   67 +
 clang-plugin/printf_check.h                        |   18 +-
 src/client/rspamc.cxx                              |  781 ++--
 src/client/rspamdclient.c                          |  299 +-
 src/client/rspamdclient.h                          |   66 +-
 src/controller.c                                   | 3477 ++++++++-------
 src/fuzzy_storage.c                                | 2164 +++++-----
 src/hs_helper.c                                    |  308 +-
 src/libcryptobox/base64/avx2.c                     |  110 +-
 src/libcryptobox/base64/base64.c                   |  368 +-
 src/libcryptobox/base64/base64.h                   |    6 +-
 src/libcryptobox/base64/ref.c                      |  187 +-
 src/libcryptobox/base64/sse42.c                    |  111 +-
 src/libcryptobox/catena/catena.c                   |  286 +-
 src/libcryptobox/catena/catena.h                   |   27 +-
 src/libcryptobox/chacha20/chacha.c                 |  143 +-
 src/libcryptobox/chacha20/chacha.h                 |   34 +-
 src/libcryptobox/chacha20/ref.c                    |  135 +-
 src/libcryptobox/cryptobox.c                       | 1251 +++---
 src/libcryptobox/cryptobox.h                       |  186 +-
 src/libcryptobox/keypair.c                         |  691 ++-
 src/libcryptobox/keypair.h                         |  118 +-
 src/libcryptobox/keypair_private.h                 |   26 +-
 src/libcryptobox/keypairs_cache.c                  |  104 +-
 src/libcryptobox/keypairs_cache.h                  |   14 +-
 src/libmime/archives.c                             | 1029 ++---
 src/libmime/archives.h                             |    8 +-
 src/libmime/content_type.c                         |  456 +-
 src/libmime/content_type.h                         |   32 +-
 src/libmime/email_addr.c                           |  253 +-
 src/libmime/email_addr.h                           |   14 +-
 src/libmime/images.c                               |  309 +-
 src/libmime/images.h                               |   20 +-
 src/libmime/lang_detection.c                       | 1218 +++---
 src/libmime/lang_detection.h                       |   22 +-
 src/libmime/lang_detection_fasttext.cxx            |   45 +-
 src/libmime/lang_detection_fasttext.h              |    6 +-
 src/libmime/message.c                              | 1123 ++---
 src/libmime/message.h                              |   56 +-
 src/libmime/mime_encoding.c                        |  533 ++-
 src/libmime/mime_encoding.h                        |   62 +-
 src/libmime/mime_encoding_list.h                   | 3110 +++++++-------
 src/libmime/mime_expressions.c                     | 1380 +++---
 src/libmime/mime_expressions.h                     |   20 +-
 src/libmime/mime_headers.c                         |  665 +--
 src/libmime/mime_headers.h                         |   61 +-
 src/libmime/mime_parser.c                          | 1030 ++---
 src/libmime/mime_parser.h                          |   10 +-
 src/libmime/mime_string.cxx                        |  236 +-
 src/libmime/mime_string.hxx                        |  251 +-
 src/libmime/received.cxx                           |  383 +-
 src/libmime/received.h                             |    8 +-
 src/libmime/received.hxx                           |   89 +-
 src/libmime/scan_result.c                          |  609 +--
 src/libmime/scan_result.h                          |  110 +-
 src/libmime/scan_result_private.h                  |   42 +-
 src/libmime/smtp_parsers.h                         |   26 +-
 src/libserver/async_session.c                      |  271 +-
 src/libserver/async_session.h                      |   48 +-
 src/libserver/cfg_file.h                           |  618 +--
 src/libserver/cfg_file_private.h                   |    4 +-
 src/libserver/cfg_rcl.c                            | 4513 ++++++++++----------
 src/libserver/cfg_rcl.h                            |  318 +-
 src/libserver/cfg_utils.c                          | 1832 ++++----
 src/libserver/composites/composites.cxx            |  267 +-
 src/libserver/composites/composites.h              |   14 +-
 src/libserver/composites/composites_internal.hxx   |   23 +-
 src/libserver/composites/composites_manager.cxx    |  133 +-
 src/libserver/css/css.cxx                          |   44 +-
 src/libserver/css/css.hxx                          |   29 +-
 src/libserver/css/css_colors_list.hxx              | 1404 +++---
 src/libserver/css/css_parser.cxx                   |  261 +-
 src/libserver/css/css_parser.hxx                   |  105 +-
 src/libserver/css/css_property.cxx                 |   28 +-
 src/libserver/css/css_property.hxx                 |   60 +-
 src/libserver/css/css_rule.cxx                     |   89 +-
 src/libserver/css/css_rule.hxx                     |   47 +-
 src/libserver/css/css_selector.cxx                 |   54 +-
 src/libserver/css/css_selector.hxx                 |   37 +-
 src/libserver/css/css_style.hxx                    |   30 +-
 src/libserver/css/css_tokeniser.cxx                |  125 +-
 src/libserver/css/css_tokeniser.hxx                |   62 +-
 src/libserver/css/css_util.cxx                     |   71 +-
 src/libserver/css/css_util.hxx                     |    4 +-
 src/libserver/css/css_value.cxx                    |  204 +-
 src/libserver/css/css_value.hxx                    |   99 +-
 src/libserver/css/parse_error.hxx                  |   19 +-
 src/libserver/dkim.c                               | 2203 +++++-----
 src/libserver/dkim.h                               |  178 +-
 src/libserver/dns.c                                |  821 ++--
 src/libserver/dns.h                                |   56 +-
 src/libserver/dynamic_cfg.c                        |  515 ++-
 src/libserver/dynamic_cfg.h                        |   36 +-
 src/libserver/fuzzy_backend/fuzzy_backend.c        |  379 +-
 src/libserver/fuzzy_backend/fuzzy_backend.h        |   70 +-
 src/libserver/fuzzy_backend/fuzzy_backend_redis.c  | 1289 +++---
 src/libserver/fuzzy_backend/fuzzy_backend_redis.h  |   52 +-
 src/libserver/fuzzy_backend/fuzzy_backend_sqlite.c |  926 ++--
 src/libserver/fuzzy_backend/fuzzy_backend_sqlite.h |   52 +-
 src/libserver/fuzzy_wire.h                         |   36 +-
 src/libserver/html/html.cxx                        |  381 +-
 src/libserver/html/html.h                          |   12 +-
 src/libserver/html/html.hxx                        |   45 +-
 src/libserver/html/html_block.hxx                  |  105 +-
 src/libserver/html/html_entities.cxx               | 4377 +++++++++----------
 src/libserver/html/html_entities.hxx               |    4 +-
 src/libserver/html/html_tag.hxx                    |   37 +-
 src/libserver/html/html_tag_defs.hxx               |  230 +-
 src/libserver/html/html_tags.h                     |  250 +-
 src/libserver/html/html_tests.cxx                  |  250 +-
 src/libserver/html/html_url.cxx                    |  120 +-
 src/libserver/html/html_url.hxx                    |   18 +-
 src/libserver/http/http_connection.c               | 2026 +++++----
 src/libserver/http/http_connection.h               |  160 +-
 src/libserver/http/http_context.c                  |  429 +-
 src/libserver/http/http_context.h                  |   44 +-
 src/libserver/http/http_message.c                  |  376 +-
 src/libserver/http/http_message.h                  |  105 +-
 src/libserver/http/http_private.h                  |   34 +-
 src/libserver/http/http_router.c                   |  401 +-
 src/libserver/http/http_router.h                   |   62 +-
 src/libserver/http/http_util.c                     |  113 +-
 src/libserver/http/http_util.h                     |    8 +-
 src/libserver/hyperscan_tools.cxx                  |  342 +-
 src/libserver/hyperscan_tools.h                    |    2 +-
 src/libserver/logger.h                             |  439 +-
 src/libserver/logger/logger.c                      |  731 ++--
 src/libserver/logger/logger_console.c              |  179 +-
 src/libserver/logger/logger_file.c                 |  372 +-
 src/libserver/logger/logger_private.h              |   96 +-
 src/libserver/logger/logger_syslog.c               |   91 +-
 src/libserver/maps/map.c                           | 2014 ++++-----
 src/libserver/maps/map.h                           |   92 +-
 src/libserver/maps/map_helpers.c                   | 1104 +++--
 src/libserver/maps/map_helpers.h                   |  156 +-
 src/libserver/maps/map_private.h                   |   54 +-
 src/libserver/milter.c                             | 1758 ++++----
 src/libserver/milter.h                             |   70 +-
 src/libserver/milter_internal.h                    |   94 +-
 src/libserver/monitored.c                          |  480 ++-
 src/libserver/monitored.h                          |   66 +-
 src/libserver/protocol.c                           | 1828 ++++----
 src/libserver/protocol.h                           |   48 +-
 src/libserver/protocol_internal.h                  |    6 +-
 src/libserver/re_cache.c                           | 1894 ++++----
 src/libserver/re_cache.h                           |  108 +-
 src/libserver/redis_pool.cxx                       |  124 +-
 src/libserver/redis_pool.h                         |   30 +-
 src/libserver/roll_history.c                       |  291 +-
 src/libserver/roll_history.h                       |   20 +-
 src/libserver/rspamd_control.c                     |  956 ++---
 src/libserver/rspamd_control.h                     |   66 +-
 src/libserver/rspamd_symcache.h                    |  278 +-
 src/libserver/spf.c                                | 1956 +++++----
 src/libserver/spf.h                                |   44 +-
 src/libserver/ssl_util.c                           |  614 ++-
 src/libserver/ssl_util.h                           |   58 +-
 src/libserver/symcache/symcache_c.cxx              |  195 +-
 src/libserver/symcache/symcache_id_list.hxx        |   16 +-
 src/libserver/symcache/symcache_impl.cxx           |  326 +-
 src/libserver/symcache/symcache_internal.hxx       |  229 +-
 src/libserver/symcache/symcache_item.cxx           |  179 +-
 src/libserver/symcache/symcache_item.hxx           |  167 +-
 src/libserver/symcache/symcache_periodic.hxx       |   22 +-
 src/libserver/symcache/symcache_runtime.cxx        |  182 +-
 src/libserver/symcache/symcache_runtime.hxx        |   21 +-
 src/libserver/task.c                               | 1149 ++---
 src/libserver/task.h                               |  214 +-
 src/libserver/url.c                                | 2537 ++++++-----
 src/libserver/url.h                                |   48 +-
 src/libserver/worker_util.c                        | 1768 ++++----
 src/libserver/worker_util.h                        |  165 +-
 src/libstat/backends/backends.h                    |  124 +-
 src/libstat/backends/cdb_backend.cxx               |  151 +-
 src/libstat/backends/http_backend.cxx              |  142 +-
 src/libstat/backends/mmaped_file.c                 |  880 ++--
 src/libstat/backends/redis_backend.c               | 1465 +++----
 src/libstat/backends/sqlite3_backend.c             |  857 ++--
 src/libstat/classifiers/bayes.c                    |  341 +-
 src/libstat/classifiers/classifiers.h              |   88 +-
 src/libstat/classifiers/lua_classifier.c           |  216 +-
 src/libstat/learn_cache/learn_cache.h              |   58 +-
 src/libstat/learn_cache/redis_cache.c              |  326 +-
 src/libstat/learn_cache/sqlite3_cache.c            |  251 +-
 src/libstat/stat_api.h                             |   42 +-
 src/libstat/stat_config.c                          |  419 +-
 src/libstat/stat_internal.h                        |   37 +-
 src/libstat/stat_process.c                         |  812 ++--
 src/libstat/tokenizers/osb.c                       |  213 +-
 src/libstat/tokenizers/tokenizers.c                |  476 +--
 src/libstat/tokenizers/tokenizers.h                |   68 +-
 src/libutil/addr.c                                 | 1108 +++--
 src/libutil/addr.h                                 |  132 +-
 src/libutil/cxx/error.hxx                          |   36 +-
 src/libutil/cxx/file_util.cxx                      |  296 +-
 src/libutil/cxx/file_util.hxx                      |   99 +-
 src/libutil/cxx/hash_util.hxx                      |   46 +-
 src/libutil/cxx/local_shared_ptr.hxx               |  222 +-
 src/libutil/cxx/utf8_util.cxx                      |  232 +-
 src/libutil/cxx/utf8_util.h                        |   10 +-
 src/libutil/cxx/util.hxx                           |   92 +-
 src/libutil/cxx/util_tests.cxx                     |   36 +-
 src/libutil/expression.c                           |  766 ++--
 src/libutil/expression.h                           |   86 +-
 src/libutil/fstring.c                              |  231 +-
 src/libutil/fstring.h                              |  115 +-
 src/libutil/hash.c                                 |  232 +-
 src/libutil/hash.h                                 |   50 +-
 src/libutil/heap.c                                 |  128 +-
 src/libutil/heap.h                                 |   26 +-
 src/libutil/libev_helper.c                         |   84 +-
 src/libutil/libev_helper.h                         |   26 +-
 src/libutil/mem_pool.c                             |  804 ++--
 src/libutil/mem_pool.h                             |  220 +-
 src/libutil/mem_pool_internal.h                    |   28 +-
 src/libutil/multipattern.c                         |  454 +-
 src/libutil/multipattern.h                         |   64 +-
 src/libutil/printf.c                               |  537 ++-
 src/libutil/printf.h                               |   36 +-
 src/libutil/radix.c                                |  274 +-
 src/libutil/radix.h                                |   48 +-
 src/libutil/ref.h                                  |   80 +-
 src/libutil/regexp.c                               |  642 ++-
 src/libutil/regexp.h                               |   90 +-
 src/libutil/rrd.c                                  |  963 +++--
 src/libutil/rrd.h                                  |  161 +-
 src/libutil/shingles.c                             |  269 +-
 src/libutil/shingles.h                             |   40 +-
 src/libutil/sqlite_utils.c                         |  491 ++-
 src/libutil/sqlite_utils.h                         |   26 +-
 src/libutil/str_util.c                             | 1690 ++++----
 src/libutil/str_util.h                             |  244 +-
 src/libutil/upstream.c                             | 1111 +++--
 src/libutil/upstream.h                             |  140 +-
 src/libutil/uthash_strcase.h                       |  112 +-
 src/libutil/util.c                                 | 1246 +++---
 src/libutil/util.h                                 |  229 +-
 src/lua/lua_cdb.c                                  |  198 +-
 src/lua/lua_cfg_file.c                             |  114 +-
 src/lua/lua_classifier.c                           |  155 +-
 src/lua/lua_common.c                               | 2103 +++++----
 src/lua/lua_common.h                               |  364 +-
 src/lua/lua_compress.c                             |  362 +-
 src/lua/lua_compress.h                             |   16 +-
 src/lua/lua_config.c                               | 3118 +++++++-------
 src/lua/lua_cryptobox.c                            | 1936 +++++----
 src/lua/lua_dns.c                                  |  137 +-
 src/lua/lua_dns_resolver.c                         |  494 ++-
 src/lua/lua_dns_resolver.h                         |    3 +-
 src/lua/lua_expression.c                           |  314 +-
 src/lua/lua_html.cxx                               |  389 +-
 src/lua/lua_http.c                                 |  813 ++--
 src/lua/lua_ip.c                                   |  340 +-
 src/lua/lua_kann.c                                 | 1181 ++---
 src/lua/lua_logger.c                               |  618 +--
 src/lua/lua_map.c                                  |  869 ++--
 src/lua/lua_map.h                                  |   20 +-
 src/lua/lua_mempool.c                              |  393 +-
 src/lua/lua_mimepart.c                             | 1293 +++---
 src/lua/lua_parsers.c                              |  237 +-
 src/lua/lua_parsers.h                              |   12 +-
 src/lua/lua_redis.c                                | 1082 +++--
 src/lua/lua_regexp.c                               |  504 +--
 src/lua/lua_rsa.c                                  |  609 ++-
 src/lua/lua_spf.c                                  |  406 +-
 src/lua/lua_sqlite3.c                              |  218 +-
 src/lua/lua_task.c                                 | 4236 +++++++++---------
 src/lua/lua_tcp.c                                  | 1520 +++----
 src/lua/lua_tensor.c                               |  541 ++-
 src/lua/lua_tensor.h                               |    6 +-
 src/lua/lua_text.c                                 |  955 +++--
 src/lua/lua_thread_pool.cxx                        |  149 +-
 src/lua/lua_thread_pool.h                          |   90 +-
 src/lua/lua_trie.c                                 |  369 +-
 src/lua/lua_udp.c                                  |  382 +-
 src/lua/lua_upstream.c                             |  364 +-
 src/lua/lua_url.c                                  |  808 ++--
 src/lua/lua_url.h                                  |   34 +-
 src/lua/lua_util.c                                 | 1922 +++++----
 src/lua/lua_worker.c                               |  673 ++-
 src/lua/lua_xmlrpc.c                               |  469 +-
 src/plugins/chartable.cxx                          | 1765 +++++++-
 src/plugins/dkim_check.c                           | 1361 +++---
 src/plugins/fuzzy_check.c                          | 3159 +++++++-------
 src/plugins/regexp.c                               |  443 +-
 src/rspamadm/commands.c                            |  197 +-
 src/rspamadm/configdump.c                          |  503 ++-
 src/rspamadm/confighelp.c                          |  256 +-
 src/rspamadm/configtest.c                          |  115 +-
 src/rspamadm/control.c                             |  233 +-
 src/rspamadm/fuzzy_convert.c                       |  133 +-
 src/rspamadm/lua_repl.c                            |  672 ++-
 src/rspamadm/pw.c                                  |  283 +-
 src/rspamadm/rspamadm.c                            |  454 +-
 src/rspamadm/rspamadm.h                            |   38 +-
 src/rspamadm/signtool.c                            |  585 ++-
 src/rspamadm/stat_convert.c                        |  266 +-
 src/rspamd.c                                       | 1240 +++---
 src/rspamd.h                                       |  183 +-
 src/rspamd_proxy.c                                 | 1849 ++++----
 src/worker.c                                       |  445 +-
 src/worker_private.h                               |   12 +-
 test/rspamd_cryptobox_test.c                       |  269 +-
 test/rspamd_cxx_local_ptr.hxx                      |  508 +--
 test/rspamd_cxx_unit.cxx                           |   17 +-
 test/rspamd_cxx_unit_dkim.hxx                      |   73 +-
 test/rspamd_cxx_unit_utils.hxx                     |  227 +-
 test/rspamd_dkim_test.c                            |   15 +-
 test/rspamd_dns_test.c                             |   83 +-
 test/rspamd_heap_test.c                            |  166 +-
 test/rspamd_http_test.c                            |  481 ++-
 test/rspamd_lua_pcall_vs_resume_test.c             |   97 +-
 test/rspamd_lua_test.c                             |  114 +-
 test/rspamd_mem_pool_test.c                        |   28 +-
 test/rspamd_radix_test.c                           |  313 +-
 test/rspamd_rrd_test.c                             |   70 +-
 test/rspamd_shingles_test.c                        |  321 +-
 test/rspamd_statfile_test.c                        |    3 +-
 test/rspamd_test_suite.c                           |  104 +-
 test/rspamd_upstream_test.c                        |  171 +-
 test/rspamd_url_test.c                             |   95 +-
 test/tests.h                                       |   32 +-
 utils/base64.c                                     |   41 +-
 utils/rspamd_http_bench.c                          |  340 +-
 utils/rspamd_http_server.c                         |  234 +-
 325 files changed, 73354 insertions(+), 71359 deletions(-)

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..89beadc23
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,67 @@
+# Generated from CLion C/C++ Code Style settings
+BasedOnStyle: LLVM
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: None
+AlignOperands: Align
+AllowAllArgumentsOnNextLine: false
+AllowAllConstructorInitializersOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: Always
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: Always
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterReturnType: None
+AlwaysBreakTemplateDeclarations: Yes
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterCaseLabel: false
+  AfterClass: false
+  AfterControlStatement: Never
+  AfterEnum: false
+  AfterFunction: true
+  AfterNamespace: false
+  AfterUnion: false
+  BeforeCatch: false
+  BeforeElse: true
+  IndentBraces: false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+BreakBeforeBinaryOperators: None
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+ColumnLimit: 0
+CompactNamespaces: false
+ContinuationIndentWidth: 4
+IndentCaseLabels: false
+IndentPPDirectives: None
+IndentWidth: 4
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 2
+NamespaceIndentation: None
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PointerAlignment: Right
+ReflowComments: false
+SortIncludes: Never
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 0
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 4
+UseTab: ForContinuationAndIndentation
diff --git a/clang-plugin/printf_check.h b/clang-plugin/printf_check.h
index 82eed6caa..6e0b1d165 100644
--- a/clang-plugin/printf_check.h
+++ b/clang-plugin/printf_check.h
@@ -24,16 +24,16 @@
 
 namespace rspamd {
 
-	class PrintfCheckVisitor : public clang::RecursiveASTVisitor<PrintfCheckVisitor> {
-		class impl;
-		std::unique_ptr<impl> pimpl;
+class PrintfCheckVisitor : public clang::RecursiveASTVisitor<PrintfCheckVisitor> {
+	class impl;
+	std::unique_ptr<impl> pimpl;
 
-	public:
-		PrintfCheckVisitor (clang::ASTContext *ctx, clang::CompilerInstance &ci);
-		virtual ~PrintfCheckVisitor (void);
-		bool VisitCallExpr (clang::CallExpr *E);
-	};
+public:
+	PrintfCheckVisitor(clang::ASTContext *ctx, clang::CompilerInstance &ci);
+	virtual ~PrintfCheckVisitor(void);
+	bool VisitCallExpr(clang::CallExpr *E);
+};
 
-}
+}// namespace rspamd
 
 #endif
diff --git a/src/client/rspamc.cxx b/src/client/rspamc.cxx
index ed13f86fd..bf7a23c47 100644
--- a/src/client/rspamc.cxx
+++ b/src/client/rspamc.cxx
@@ -100,84 +100,83 @@ static gboolean rspamc_password_callback(const gchar *option_name,
 
 static GOptionEntry entries[] =
 	{
-		{"connect",          'h',  0,                          G_OPTION_ARG_STRING,       &connect_str,
-																															  "Specify host and port",                                                    nullptr},
-		{"password",         'P',  G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
-																						  (void *) &rspamc_password_callback, "Specify control password",                                                 nullptr},
-		{"classifier",       'c',  0,                          G_OPTION_ARG_STRING,       &classifier,
-																															  "Classifier to learn spam or ham",                                          nullptr},
-		{"weight",           'w',  0,                          G_OPTION_ARG_INT,          &weight,
-																															  "Weight for fuzzy operations",                                              nullptr},
-		{"flag",             'f',  0,                          G_OPTION_ARG_INT,          &flag,                              "Flag for fuzzy operations",
-																																																		  nullptr},
-		{"pass-all",         'p',  0,                          G_OPTION_ARG_NONE,         &pass_all,                          "Pass all filters",
-																																																		  nullptr},
-		{"verbose",          'v',  0,                          G_OPTION_ARG_NONE,         &verbose,                           "More verbose output",
-																																																		  nullptr},
-		{"ip",               'i',  0,                          G_OPTION_ARG_STRING,       &ip,
-																															  "Emulate that message was received from specified ip address",
-																																																		  nullptr},
-		{"user",             'u',  0,                          G_OPTION_ARG_STRING,       &user,
-																															  "Emulate that message was received from specified authenticated user",      nullptr},
-		{"deliver",          'd',  0,                          G_OPTION_ARG_STRING,       &deliver_to,
-																															  "Emulate that message is delivered to specified user (for LDA/statistics)", nullptr},
-		{"from",             'F',  0,                          G_OPTION_ARG_STRING,       &from,
-																															  "Emulate that message has specified SMTP FROM address",                     nullptr},
-		{"rcpt",             'r',  0,                          G_OPTION_ARG_STRING_ARRAY, &rcpts,
-																															  "Emulate that message has specified SMTP RCPT address",                     nullptr},
-		{"helo",             0,    0,                          G_OPTION_ARG_STRING,       &helo,
-																															  "Imitate SMTP HELO passing from MTA",                                       nullptr},
-		{"hostname",         0,    0,                          G_OPTION_ARG_STRING,       &hostname,
-																															  "Imitate hostname passing from MTA",                                        nullptr},
-		{"timeout",          't',  0,                          G_OPTION_ARG_DOUBLE,       &timeout,
-																															  "Time in seconds to wait for a reply",                                      nullptr},
-		{"bind",             'b',  0,                          G_OPTION_ARG_STRING,       &local_addr,
-																															  "Bind to specified ip address",                                             nullptr},
-		{"commands",         0,    0,                          G_OPTION_ARG_NONE,         &print_commands,
-																															  "List available commands",                                                  nullptr},
-		{"human",            'R',  0,                          G_OPTION_ARG_NONE,         &humanreport,                       "Output human readable report",                                             nullptr},
-		{"json",             'j',  0,                          G_OPTION_ARG_NONE,         &json,                              "Output json reply",                                                        nullptr},
-		{"compact",          '\0', 0,                          G_OPTION_ARG_NONE,         &compact,                           "Output compact json reply",                                                nullptr},
-		{"headers",          0,    0,                          G_OPTION_ARG_NONE,         &headers,                           "Output HTTP headers",
-																																																		  nullptr},
-		{"raw",              0,    0,                          G_OPTION_ARG_NONE,         &raw,                               "Input is a raw file, not an email file",
-																																																		  nullptr},
-		{"ucl",              0,    0,                          G_OPTION_ARG_NONE,         &ucl_reply,                         "Output ucl reply from rspamd",
-																																																		  nullptr},
-		{"max-requests",     'n',  0,                          G_OPTION_ARG_INT,          &max_requests,
-																															  "Maximum count of parallel requests to rspamd",                             nullptr},
-		{"extended-urls",    0,    0,                          G_OPTION_ARG_NONE,         &extended_urls,
-																															  "Output urls in extended format",                                           nullptr},
-		{"key",              0,    0,                          G_OPTION_ARG_STRING,       &pubkey,
-																															  "Use specified pubkey to encrypt request",                                  nullptr},
-		{"exec",             'e',  0,                          G_OPTION_ARG_STRING,       &execute,
-																															  "Execute the specified command and pass output to it",                      nullptr},
-		{"mime",             'm',  0,                          G_OPTION_ARG_NONE,         &mime_output,
-																															  "Write mime body of message with headers instead of just a scan's result",  nullptr},
-		{"header",           0,    0,                          G_OPTION_ARG_STRING_ARRAY, &http_headers,
-																															  "Add custom HTTP header to query (can be repeated)",                        nullptr},
-		{"exclude",          0,    0,                          G_OPTION_ARG_STRING_ARRAY, &exclude_patterns,
-																															  "Exclude specific glob patterns in file names (can be repeated)",           nullptr},
-		{"sort",             0,    0,                          G_OPTION_ARG_STRING,       &sort,
-																															  "Sort output in a specific order (name, weight, frequency, hits)",          nullptr},
-		{"empty",            'E',  0,                          G_OPTION_ARG_NONE,         &empty_input,
-																															  "Allow empty input instead of reading from stdin",                          nullptr},
-		{"fuzzy-symbol",     'S',  0,                          G_OPTION_ARG_STRING,       &fuzzy_symbol,
-																															  "Learn the specified fuzzy symbol",                                         nullptr},
-		{"compressed",       'z',  0,                          G_OPTION_ARG_NONE,         &compressed,
-																															  "Enable zstd compression",                                                  nullptr},
-		{"profile",          '\0', 0,                          G_OPTION_ARG_NONE,         &profile,
-																															  "Profile symbols execution time",                                           nullptr},
-		{"dictionary",       'D',  0,                          G_OPTION_ARG_FILENAME,     &dictionary,
-																															  "Use dictionary to compress data",                                          nullptr},
-		{"skip-images",      '\0', 0,                          G_OPTION_ARG_NONE,         &skip_images,
-																															  "Skip images when learning/unlearning fuzzy",                               nullptr},
-		{"skip-attachments", '\0', 0,                          G_OPTION_ARG_NONE,         &skip_attachments,
-																															  "Skip attachments when learning/unlearning fuzzy",                          nullptr},
-		{"user-agent",       'U',  0,                          G_OPTION_ARG_STRING,       &user_agent,
-																															  "Use specific User-Agent instead of \"rspamc\"",                            nullptr},
-		{nullptr,            0,    0,                          G_OPTION_ARG_NONE,         nullptr,                            nullptr,                                                                    nullptr}
-	};
+		{"connect", 'h', 0, G_OPTION_ARG_STRING, &connect_str,
+		 "Specify host and port", nullptr},
+		{"password", 'P', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
+		 (void *) &rspamc_password_callback, "Specify control password", nullptr},
+		{"classifier", 'c', 0, G_OPTION_ARG_STRING, &classifier,
+		 "Classifier to learn spam or ham", nullptr},
+		{"weight", 'w', 0, G_OPTION_ARG_INT, &weight,
+		 "Weight for fuzzy operations", nullptr},
+		{"flag", 'f', 0, G_OPTION_ARG_INT, &flag, "Flag for fuzzy operations",
+		 nullptr},
+		{"pass-all", 'p', 0, G_OPTION_ARG_NONE, &pass_all, "Pass all filters",
+		 nullptr},
+		{"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "More verbose output",
+		 nullptr},
+		{"ip", 'i', 0, G_OPTION_ARG_STRING, &ip,
+		 "Emulate that message was received from specified ip address",
+		 nullptr},
+		{"user", 'u', 0, G_OPTION_ARG_STRING, &user,
+		 "Emulate that message was received from specified authenticated user", nullptr},
+		{"deliver", 'd', 0, G_OPTION_ARG_STRING, &deliver_to,
+		 "Emulate that message is delivered to specified user (for LDA/statistics)", nullptr},
+		{"from", 'F', 0, G_OPTION_ARG_STRING, &from,
+		 "Emulate that message has specified SMTP FROM address", nullptr},
+		{"rcpt", 'r', 0, G_OPTION_ARG_STRING_ARRAY, &rcpts,
+		 "Emulate that message has specified SMTP RCPT address", nullptr},
+		{"helo", 0, 0, G_OPTION_ARG_STRING, &helo,
+		 "Imitate SMTP HELO passing from MTA", nullptr},
+		{"hostname", 0, 0, G_OPTION_ARG_STRING, &hostname,
+		 "Imitate hostname passing from MTA", nullptr},
+		{"timeout", 't', 0, G_OPTION_ARG_DOUBLE, &timeout,
+		 "Time in seconds to wait for a reply", nullptr},
+		{"bind", 'b', 0, G_OPTION_ARG_STRING, &local_addr,
+		 "Bind to specified ip address", nullptr},
+		{"commands", 0, 0, G_OPTION_ARG_NONE, &print_commands,
+		 "List available commands", nullptr},
+		{"human", 'R', 0, G_OPTION_ARG_NONE, &humanreport, "Output human readable report", nullptr},
+		{"json", 'j', 0, G_OPTION_ARG_NONE, &json, "Output json reply", nullptr},
+		{"compact", '\0', 0, G_OPTION_ARG_NONE, &compact, "Output compact json reply", nullptr},
+		{"headers", 0, 0, G_OPTION_ARG_NONE, &headers, "Output HTTP headers",
+		 nullptr},
+		{"raw", 0, 0, G_OPTION_ARG_NONE, &raw, "Input is a raw file, not an email file",
+		 nullptr},
+		{"ucl", 0, 0, G_OPTION_ARG_NONE, &ucl_reply, "Output ucl reply from rspamd",
+		 nullptr},
+		{"max-requests", 'n', 0, G_OPTION_ARG_INT, &max_requests,
+		 "Maximum count of parallel requests to rspamd", nullptr},
+		{"extended-urls", 0, 0, G_OPTION_ARG_NONE, &extended_urls,
+		 "Output urls in extended format", nullptr},
+		{"key", 0, 0, G_OPTION_ARG_STRING, &pubkey,
+		 "Use specified pubkey to encrypt request", nullptr},
+		{"exec", 'e', 0, G_OPTION_ARG_STRING, &execute,
+		 "Execute the specified command and pass output to it", nullptr},
+		{"mime", 'm', 0, G_OPTION_ARG_NONE, &mime_output,
+		 "Write mime body of message with headers instead of just a scan's result", nullptr},
+		{"header", 0, 0, G_OPTION_ARG_STRING_ARRAY, &http_headers,
+		 "Add custom HTTP header to query (can be repeated)", nullptr},
+		{"exclude", 0, 0, G_OPTION_ARG_STRING_ARRAY, &exclude_patterns,
+		 "Exclude specific glob patterns in file names (can be repeated)", nullptr},
+		{"sort", 0, 0, G_OPTION_ARG_STRING, &sort,
+		 "Sort output in a specific order (name, weight, frequency, hits)", nullptr},
+		{"empty", 'E', 0, G_OPTION_ARG_NONE, &empty_input,
+		 "Allow empty input instead of reading from stdin", nullptr},
+		{"fuzzy-symbol", 'S', 0, G_OPTION_ARG_STRING, &fuzzy_symbol,
+		 "Learn the specified fuzzy symbol", nullptr},
+		{"compressed", 'z', 0, G_OPTION_ARG_NONE, &compressed,
+		 "Enable zstd compression", nullptr},
+		{"profile", '\0', 0, G_OPTION_ARG_NONE, &profile,
+		 "Profile symbols execution time", nullptr},
+		{"dictionary", 'D', 0, G_OPTION_ARG_FILENAME, &dictionary,
+		 "Use dictionary to compress data", nullptr},
+		{"skip-images", '\0', 0, G_OPTION_ARG_NONE, &skip_images,
+		 "Skip images when learning/unlearning fuzzy", nullptr},
+		{"skip-attachments", '\0', 0, G_OPTION_ARG_NONE, &skip_attachments,
+		 "Skip attachments when learning/unlearning fuzzy", nullptr},
+		{"user-agent", 'U', 0, G_OPTION_ARG_STRING, &user_agent,
+		 "Use specific User-Agent instead of \"rspamc\"", nullptr},
+		{nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr}};
 
 static void rspamc_symbols_output(FILE *out, ucl_object_t *obj);
 
@@ -225,8 +224,7 @@ static const constexpr auto rspamc_commands = rspamd::array_of(
 		.is_controller = FALSE,
 		.is_privileged = FALSE,
 		.need_input = TRUE,
-		.command_output_func = rspamc_symbols_output
-	},
+		.command_output_func = rspamc_symbols_output},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_LEARN_SPAM,
 		.name = "learn_spam",
@@ -235,8 +233,7 @@ static const constexpr auto rspamc_commands = rspamd::array_of(
 		.is_controller = TRUE,
 		.is_privileged = TRUE,
 		.need_input = TRUE,
-		.command_output_func = nullptr
-	},
+		.command_output_func = nullptr},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_LEARN_HAM,
 		.name = "learn_ham",
@@ -245,41 +242,37 @@ static const constexpr auto rspamc_commands = rspamd::array_of(
 		.is_controller = TRUE,
 		.is_privileged = TRUE,
 		.need_input = TRUE,
-		.command_output_func = nullptr
-	},
+		.command_output_func = nullptr},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_FUZZY_ADD,
 		.name = "fuzzy_add",
 		.path = "fuzzyadd",
 		.description =
-		"add hashes from a message to the fuzzy storage (check -f and -w options for this command)",
+			"add hashes from a message to the fuzzy storage (check -f and -w options for this command)",
 		.is_controller = TRUE,
 		.is_privileged = TRUE,
 		.need_input = TRUE,
-		.command_output_func = nullptr
-	},
+		.command_output_func = nullptr},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_FUZZY_DEL,
 		.name = "fuzzy_del",
 		.path = "fuzzydel",
 		.description =
-		"delete hashes from a message from the fuzzy storage (check -f option for this command)",
+			"delete hashes from a message from the fuzzy storage (check -f option for this command)",
 		.is_controller = TRUE,
 		.is_privileged = TRUE,
 		.need_input = TRUE,
-		.command_output_func = nullptr
-	},
+		.command_output_func = nullptr},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_FUZZY_DELHASH,
 		.name = "fuzzy_delhash",
 		.path = "fuzzydelhash",
 		.description =
-		"delete a hash from fuzzy storage (check -f option for this command)",
+			"delete a hash from fuzzy storage (check -f option for this command)",
 		.is_controller = TRUE,
 		.is_privileged = TRUE,
 		.need_input = FALSE,
-		.command_output_func = nullptr
-	},
+		.command_output_func = nullptr},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_STAT,
 		.name = "stat",
@@ -298,8 +291,7 @@ static const constexpr auto rspamc_commands = rspamd::array_of(
 		.is_controller = TRUE,
 		.is_privileged = TRUE,
 		.need_input = FALSE,
-		.command_output_func = rspamc_stat_output
-	},
+		.command_output_func = rspamc_stat_output},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_COUNTERS,
 		.name = "counters",
@@ -308,8 +300,7 @@ static const constexpr auto rspamc_commands = rspamd::array_of(
 		.is_controller = TRUE,
 		.is_privileged = FALSE,
 		.need_input = FALSE,
-		.command_output_func = rspamc_counters_output
-	},
+		.command_output_func = rspamc_counters_output},
 	rspamc_command{
 		.cmd = RSPAMC_COMMAND_UPTIME,
 		.name = "uptime",
@@ -318,8 +309,7 @@ static const constexpr auto rspamc_commands = rspamd::array_of(
 		.is_controller = TRUE,
 		.is_privileged = FALSE,
 		.need_input = FALSE,
-		.command_output_func = rspamc_uptime_output
-	},
+		.command_output_func = rspamc_uptime_output},
*** OUTPUT TRUNCATED, 256534 LINES SKIPPED ***


More information about the Commits mailing list