commit 057df47: [Minor] Some style fixes + reformat

Vsevolod Stakhov vsevolod at rspamd.com
Sat Jan 21 15:28:03 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-01-21 14:22:57 +0000
URL: https://github.com/rspamd/rspamd/commit/057df47a8d35a4cfd96fa23afe3f73ba6cbebd65

[Minor] Some style fixes + reformat

---
 contrib/uthash/uthash.h |  76 ++--
 src/client/rspamc.cxx   | 907 ++++++++++++++++++++++++------------------------
 2 files changed, 494 insertions(+), 489 deletions(-)

diff --git a/contrib/uthash/uthash.h b/contrib/uthash/uthash.h
index 824bb2a76..1547d3023 100644
--- a/contrib/uthash/uthash.h
+++ b/contrib/uthash/uthash.h
@@ -22,7 +22,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef UTHASH_H
-#define UTHASH_H 
+#define UTHASH_H
 
 #include <string.h>   /* memcmp,strlen */
 #include <stddef.h>   /* ptrdiff_t */
@@ -49,7 +49,7 @@ do {
   char **_da_dst = (char**)(&(dst));                                             \
   *_da_dst = (char*)(src);                                                       \
 } while(0)
-#else 
+#else
 #define DECLTYPE_ASSIGN(dst,src)                                                 \
 do {                                                                             \
   (dst) = DECLTYPE(dst)(src);                                                    \
@@ -114,12 +114,12 @@ do {
   if (!((tbl)->bloom_bv))  { uthash_fatal( "out of memory"); }                   \
   memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN);                                \
   (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE;                                       \
-} while (0) 
+} while (0)
 
 #define HASH_BLOOM_FREE(tbl)                                                     \
 do {                                                                             \
   uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN);                              \
-} while (0) 
+} while (0)
 
 #define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8)))
 #define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8)))
@@ -131,9 +131,9 @@ do {
   HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
 
 #else
-#define HASH_BLOOM_MAKE(tbl) 
-#define HASH_BLOOM_FREE(tbl) 
-#define HASH_BLOOM_ADD(tbl,hashv) 
+#define HASH_BLOOM_MAKE(tbl)
+#define HASH_BLOOM_FREE(tbl)
+#define HASH_BLOOM_ADD(tbl,hashv)
 #define HASH_BLOOM_TEST(tbl,hashv) (1)
 #define HASH_BLOOM_BYTELEN 0
 #endif
@@ -169,7 +169,7 @@ do {
   };                                                                             \
   HASH_ADD(hh,head,fieldname,keylen_in,add);                                     \
 } while(0)
- 
+
 #define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \
 do {                                                                             \
  unsigned _ha_bkt;                                                               \
@@ -327,10 +327,10 @@ do {
     }                                                                            \
 } while (0)
 #else
-#define HASH_FSCK(hh,head) 
+#define HASH_FSCK(hh,head)
 #endif
 
-/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to 
+/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to
  * the descriptor to which this macro is defined for tuning the hash function.
  * The app can #include <unistd.h> to get the prototype for write(2). */
 #ifdef HASH_EMIT_KEYS
@@ -340,12 +340,12 @@ do {
     write(HASH_EMIT_KEYS, &_klen, sizeof(_klen));                                \
     write(HASH_EMIT_KEYS, keyptr, fieldlen);                                     \
 } while (0)
-#else 
-#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)                    
+#else
+#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)
 #endif
 
 /* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */
-#ifdef HASH_FUNCTION 
+#ifdef HASH_FUNCTION
 #define HASH_FCN HASH_FUNCTION
 #else
 #define HASH_FCN HASH_JEN
@@ -362,7 +362,7 @@ do {
 } while (0)
 
 
-/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at 
+/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at
  * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */
 #define HASH_SAX(key,keylen,num_bkts,hashv,bkt)                                  \
 do {                                                                             \
@@ -382,8 +382,8 @@ do {
   for(_fn_i=0; _fn_i < keylen; _fn_i++)                                          \
       hashv = (hashv * 16777619) ^ _hf_key[_fn_i];                               \
   bkt = hashv & (num_bkts-1);                                                    \
-} while(0) 
- 
+} while(0)
+
 #define HASH_OAT(key,keylen,num_bkts,hashv,bkt)                                  \
 do {                                                                             \
   unsigned _ho_i;                                                                \
@@ -507,12 +507,12 @@ do {
     hashv ^= hashv << 25;                                                        \
     hashv += hashv >> 6;                                                         \
     bkt = hashv & (num_bkts-1);                                                  \
-} while(0) 
+} while(0)
 
 #ifdef HASH_USING_NO_STRICT_ALIASING
 /* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads.
  * For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error.
- * MurmurHash uses the faster approach only on CPU's where we know it's safe. 
+ * MurmurHash uses the faster approach only on CPU's where we know it's safe.
  *
  * Note the preprocessor built-in defines can be emitted using:
  *
@@ -635,36 +635,36 @@ do {
     }                                                                            \
     if (hh_del->hh_next) {                                                       \
         hh_del->hh_next->hh_prev = hh_del->hh_prev;                              \
-    }                                                                
+    }
 
 /* Bucket expansion has the effect of doubling the number of buckets
  * and redistributing the items into the new buckets. Ideally the
  * items will distribute more or less evenly into the new buckets
  * (the extent to which this is true is a measure of the quality of
- * the hash function as it applies to the key domain). 
- * 
+ * the hash function as it applies to the key domain).
+ *
  * With the items distributed into more buckets, the chain length
  * (item count) in each bucket is reduced. Thus by expanding buckets
- * the hash keeps a bound on the chain length. This bounded chain 
+ * the hash keeps a bound on the chain length. This bounded chain
  * length is the essence of how a hash provides constant time lookup.
- * 
+ *
  * The calculation of tbl->ideal_chain_maxlen below deserves some
  * explanation. First, keep in mind that we're calculating the ideal
  * maximum chain length based on the *new* (doubled) bucket count.
  * In fractions this is just n/b (n=number of items,b=new num buckets).
- * Since the ideal chain length is an integer, we want to calculate 
+ * Since the ideal chain length is an integer, we want to calculate
  * ceil(n/b). We don't depend on floating point arithmetic in this
  * hash, so to calculate ceil(n/b) with integers we could write
- * 
+ *
  *      ceil(n/b) = (n/b) + ((n%b)?1:0)
- * 
+ *
  * and in fact a previous version of this hash did just that.
  * But now we have improved things a bit by recognizing that b is
  * always a power of two. We keep its base 2 log handy (call it lb),
  * so now we can write this with a bit shift and logical AND:
- * 
+ *
  *      ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
- * 
+ *
  */
 #define HASH_EXPAND_BUCKETS(tbl)                                                 \
 do {                                                                             \
@@ -716,7 +716,7 @@ do {
 
 
 /* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */
-/* Note that HASH_SORT assumes the hash handle name to be hh. 
+/* Note that HASH_SORT assumes the hash handle name to be hh.
  * HASH_SRT was added to allow the hash handle name to be passed in. */
 #define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)
 #define HASH_SRT(hh,head,cmpfcn)                                                 \
@@ -806,10 +806,10 @@ do {
  }                                                                               \
 } while (0)
 
-/* This function selects items from one hash into another hash. 
- * The end result is that the selected items have dual presence 
- * in both hashes. There is no copy of the items made; rather 
- * they are added into the new hash through a secondary hash 
+/* This function selects items from one hash into another hash.
+ * The end result is that the selected items have dual presence
+ * in both hashes. There is no copy of the items made; rather
+ * they are added into the new hash through a secondary hash
  * hash handle that must be present in the structure. */
 #define HASH_SELECT(hh_dst, dst, hh_src, src, cond)                              \
 do {                                                                             \
@@ -869,7 +869,7 @@ do {
 #ifdef NO_DECLTYPE
 #define HASH_ITER(hh,head,el,tmp)                                                \
 for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL);       \
-  el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL)) 
+  el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL))
 #else
 #define HASH_ITER(hh,head,el,tmp)                                                \
 for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL);                 \
@@ -877,7 +877,7 @@ for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL);
 #endif
 
 /* obtain a count of items in the hash */
-#define HASH_COUNT(head) HASH_CNT(hh,head) 
+#define HASH_COUNT(head) HASH_CNT(hh,head)
 #define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0)
 
 typedef struct UT_hash_bucket {
@@ -886,7 +886,7 @@ typedef struct UT_hash_bucket {
 
    /* expand_mult is normally set to 0. In this situation, the max chain length
     * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If
-    * the bucket's chain exceeds this length, bucket expansion is triggered). 
+    * the bucket's chain exceeds this length, bucket expansion is triggered).
     * However, setting expand_mult to a non-zero value delays bucket expansion
     * (that would be triggered by additions to this particular bucket)
     * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH.
@@ -894,7 +894,7 @@ typedef struct UT_hash_bucket {
     * multiplier is to reduce bucket expansions, since they are expensive, in
     * situations where we know that a particular bucket tends to be overused.
     * It is better to let its chain length grow to a longer yet-still-bounded
-    * value, than to do an O(n) bucket expansion too often. 
+    * value, than to do an O(n) bucket expansion too often.
     */
    unsigned expand_mult;
 
@@ -920,7 +920,7 @@ typedef struct UT_hash_table {
     * hash distribution; reaching them in a chain traversal takes >ideal steps */
    unsigned nonideal_items;
 
-   /* ineffective expands occur when a bucket doubling was performed, but 
+   /* ineffective expands occur when a bucket doubling was performed, but
     * afterward, more than half the items in the hash had nonideal chain
     * positions. If this happens on two consecutive expansions we inhibit any
     * further expansion, as it's not helping; this happens when the hash
diff --git a/src/client/rspamc.cxx b/src/client/rspamc.cxx
index 5bb75ef38..1a425b881 100644
--- a/src/client/rspamc.cxx
+++ b/src/client/rspamc.cxx
@@ -84,7 +84,7 @@ static gboolean compressed = FALSE;
 static gboolean profile = FALSE;
 static gboolean skip_images = FALSE;
 static gboolean skip_attachments = FALSE;
-static const char *key = nullptr;
+static const char *pubkey = nullptr;
 static const char *user_agent = "rspamc";
 
 std::vector<GPid> children;
@@ -99,85 +99,85 @@ static gboolean rspamc_password_callback(const gchar *option_name,
 										 GError **error);
 
 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,       &key,
-																																	  "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);
 
@@ -217,129 +217,129 @@ struct rspamc_command {
 };
 
 static const constexpr auto rspamc_commands = rspamd::array_of(
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_SYMBOLS,
-				.name = "symbols",
-				.path = "checkv2",
-				.description = "scan message and show symbols (default command)",
-				.is_controller = FALSE,
-				.is_privileged = FALSE,
-				.need_input = TRUE,
-				.command_output_func = rspamc_symbols_output
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_LEARN_SPAM,
-				.name = "learn_spam",
-				.path = "learnspam",
-				.description = "learn message as spam",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = TRUE,
-				.command_output_func = nullptr
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_LEARN_HAM,
-				.name = "learn_ham",
-				.path = "learnham",
-				.description = "learn message as ham",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = TRUE,
-				.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)",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = TRUE,
-				.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)",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = TRUE,
-				.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)",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = FALSE,
-				.command_output_func = nullptr
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_STAT,
-				.name = "stat",
-				.path = "stat",
-				.description = "show rspamd statistics",
-				.is_controller = TRUE,
-				.is_privileged = FALSE,
-				.need_input = FALSE,
-				.command_output_func = rspamc_stat_output,
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_STAT_RESET,
-				.name = "stat_reset",
-				.path = "statreset",
-				.description = "show and reset rspamd statistics (useful for graphs)",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = FALSE,
-				.command_output_func = rspamc_stat_output
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_COUNTERS,
-				.name = "counters",
-				.path = "counters",
-				.description = "display rspamd symbols statistics",
-				.is_controller = TRUE,
-				.is_privileged = FALSE,
-				.need_input = FALSE,
-				.command_output_func = rspamc_counters_output
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_UPTIME,
-				.name = "uptime",
-				.path = "auth",
-				.description = "show rspamd uptime",
-				.is_controller = TRUE,
-				.is_privileged = FALSE,
-				.need_input = FALSE,
-				.command_output_func = rspamc_uptime_output
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_ADD_SYMBOL,
-				.name = "add_symbol",
-				.path = "addsymbol",
-				.description = "add or modify symbol settings in rspamd",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = FALSE,
-				.command_output_func = nullptr
-		},
-		rspamc_command{
-				.cmd = RSPAMC_COMMAND_ADD_ACTION,
-				.name = "add_action",
-				.path = "addaction",
-				.description = "add or modify action settings",
-				.is_controller = TRUE,
-				.is_privileged = TRUE,
-				.need_input = FALSE,
-				.command_output_func = nullptr
-		}
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_SYMBOLS,
+		.name = "symbols",
+		.path = "checkv2",
+		.description = "scan message and show symbols (default command)",
+		.is_controller = FALSE,
+		.is_privileged = FALSE,
+		.need_input = TRUE,
+		.command_output_func = rspamc_symbols_output
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_LEARN_SPAM,
+		.name = "learn_spam",
+		.path = "learnspam",
+		.description = "learn message as spam",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = TRUE,
+		.command_output_func = nullptr
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_LEARN_HAM,
+		.name = "learn_ham",
+		.path = "learnham",
+		.description = "learn message as ham",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = TRUE,
+		.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)",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = TRUE,
+		.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)",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = TRUE,
+		.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)",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = FALSE,
+		.command_output_func = nullptr
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_STAT,
+		.name = "stat",
+		.path = "stat",
+		.description = "show rspamd statistics",
+		.is_controller = TRUE,
+		.is_privileged = FALSE,
+		.need_input = FALSE,
+		.command_output_func = rspamc_stat_output,
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_STAT_RESET,
+		.name = "stat_reset",
+		.path = "statreset",
+		.description = "show and reset rspamd statistics (useful for graphs)",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = FALSE,
+		.command_output_func = rspamc_stat_output
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_COUNTERS,
+		.name = "counters",
+		.path = "counters",
+		.description = "display rspamd symbols statistics",
+		.is_controller = TRUE,
+		.is_privileged = FALSE,
+		.need_input = FALSE,
+		.command_output_func = rspamc_counters_output
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_UPTIME,
+		.name = "uptime",
+		.path = "auth",
+		.description = "show rspamd uptime",
+		.is_controller = TRUE,
+		.is_privileged = FALSE,
+		.need_input = FALSE,
+		.command_output_func = rspamc_uptime_output
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_ADD_SYMBOL,
+		.name = "add_symbol",
+		.path = "addsymbol",
+		.description = "add or modify symbol settings in rspamd",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = FALSE,
+		.command_output_func = nullptr
+	},
+	rspamc_command{
+		.cmd = RSPAMC_COMMAND_ADD_ACTION,
+		.name = "add_action",
+		.path = "addaction",
+		.description = "add or modify action settings",
+		.is_controller = TRUE,
+		.is_privileged = TRUE,
+		.need_input = FALSE,
+		.command_output_func = nullptr
+	}
 );
 
 struct rspamc_callback_data {
@@ -367,66 +367,66 @@ static constexpr auto emphasis_argument(const T &arg, int precision) -> auto {
 
 using sort_lambda = std::function<int(const ucl_object_t *, const ucl_object_t *)>;
 static const auto sort_map = frozen::make_unordered_map<frozen::string, sort_lambda>({
-		{"name", [](const ucl_object_t *o1, const ucl_object_t *o2) -> int {
-			const auto *elt1 = ucl_object_lookup(o1, "symbol");
-			const auto *elt2 = ucl_object_lookup(o2, "symbol");
-
-			if (elt1 && elt2) {
-				return strcmp(ucl_object_tostring(elt1),
-						ucl_object_tostring(elt2));
-			}
-			else if (ucl_object_key(o1) != nullptr && ucl_object_key(o2) != nullptr) {
-				return strcmp(ucl_object_key(o1),
-						ucl_object_key(o2));
-			}
-			return 0;
-		}},
-		{"weight", [](const ucl_object_t *o1, const ucl_object_t *o2) -> int {
*** OUTPUT TRUNCATED, 958 LINES SKIPPED ***


More information about the Commits mailing list