]> source.dussan.org Git - rspamd.git/commitdiff
Fixes types (use glib ones) no functional change.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 6 Oct 2010 16:03:57 +0000 (20:03 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 6 Oct 2010 16:03:57 +0000 (20:03 +0400)
Now all comments in commit logs beginning with '*' would be included in changelog, so
important changes would be separated from small ones.

87 files changed:
src/binlog.c
src/binlog.h
src/bloom.c
src/bloom.h
src/buffer.c
src/buffer.h
src/cfg_file.h
src/cfg_utils.c
src/cfg_xml.c
src/cfg_xml.h
src/controller.c
src/dns.c
src/dns.h
src/expressions.c
src/expressions.h
src/filter.c
src/filter.h
src/fstring.c
src/fstring.h
src/fuzzy.c
src/fuzzy.h
src/fuzzy_storage.c
src/fuzzy_storage.h
src/greylist_storage.c
src/html.c
src/html.h
src/images.c
src/images.h
src/lmtp.c
src/lmtp_proto.c
src/lmtp_proto.h
src/logger.c
src/logger.h
src/lua/lua_cfg_file.c
src/lua/lua_classifier.c
src/lua/lua_common.c
src/lua/lua_common.h
src/lua/lua_config.c
src/lua/lua_message.c
src/lua/lua_task.c
src/main.c
src/main.h
src/map.c
src/map.h
src/mem_pool.c
src/mem_pool.h
src/memcached-test.c
src/memcached.c
src/memcached.h
src/message.c
src/message.h
src/perl.c
src/perl.h
src/plugins/chartable.c
src/plugins/emails.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/plugins/spf.c
src/plugins/surbl.c
src/plugins/surbl.h
src/protocol.c
src/protocol.h
src/radix.c
src/radix.h
src/settings.c
src/settings.h
src/smtp.c
src/smtp.h
src/smtp_proto.c
src/smtp_proto.h
src/spf.c
src/spf.h
src/statfile.c
src/statfile.h
src/statfile_sync.c
src/symbols_cache.c
src/symbols_cache.h
src/trie.c
src/upstream.c
src/upstream.h
src/url.c
src/url.h
src/util.c
src/util.h
src/view.c
src/view.h
src/worker.c

index 83a57aacc11387fe8aa99594c25de11b67afffc4..d3b34b7c0ef1d7c5e478120f8d913511eb119906 100644 (file)
@@ -86,7 +86,7 @@ binlog_write_header (struct rspamd_binlog *log)
 static gboolean
 binlog_check_file (struct rspamd_binlog *log)
 {
-       static char valid_magic[] = VALID_MAGIC, valid_version[] = VALID_VERSION;
+       static gchar valid_magic[] = VALID_MAGIC, valid_version[] = VALID_VERSION;
 
        if (read (log->fd, &log->header, sizeof (struct rspamd_binlog_header)) != sizeof (struct rspamd_binlog_header)) {
                msg_warn ("cannot read file %s, error %d, %s", log->filename, errno, strerror (errno));
@@ -151,10 +151,10 @@ binlog_open_real (struct rspamd_binlog *log)
 
 
 struct rspamd_binlog* 
-binlog_open (memory_pool_t *pool, const char *path, time_t rotate_time, int rotate_jitter)
+binlog_open (memory_pool_t *pool, const gchar *path, time_t rotate_time, gint rotate_jitter)
 {
        struct rspamd_binlog *new;
-       int len = strlen (path);
+       gint                            len = strlen (path);
        struct stat st;
 
        new = memory_pool_alloc0 (pool, sizeof (struct rspamd_binlog));
@@ -248,7 +248,7 @@ write_binlog_tree (struct rspamd_binlog *log, GTree *nodes)
        /* Write index */
        idx = &log->cur_idx->indexes[log->cur_idx->last_index];
        idx->seek = seek;
-       idx->time = (uint64_t)time (NULL);
+       idx->time = (guint64)time (NULL);
        log->cur_time = idx->time;
        idx->len = g_tree_nnodes (nodes) * sizeof (struct rspamd_binlog_element);
        if (lseek (log->fd, log->metaindex->indexes[log->metaindex->last_index], SEEK_SET) == -1) {
@@ -311,7 +311,7 @@ create_new_metaindex_block (struct rspamd_binlog *log)
 static gboolean
 maybe_rotate_binlog (struct rspamd_binlog *log)
 {
-       uint64_t now = time (NULL);
+       guint64                         now = time (NULL);
 
        if (log->rotate_time && ((now - log->header.create_time) > log->rotate_time + log->rotate_jitter)) {
                return TRUE;
@@ -322,7 +322,7 @@ maybe_rotate_binlog (struct rspamd_binlog *log)
 static gboolean
 rotate_binlog (struct rspamd_binlog *log)
 {
-       char *backup_name;
+       gchar                           *backup_name;
        struct stat st;
 
        lock_file (log->fd, FALSE);
@@ -399,9 +399,9 @@ binlog_insert (struct rspamd_binlog *log, GTree *nodes)
 }
 
 gboolean 
-binlog_sync (struct rspamd_binlog *log, uint64_t from_rev, uint64_t *from_time, GByteArray **rep)
+binlog_sync (struct rspamd_binlog *log, guint64 from_rev, guint64 *from_time, GByteArray **rep)
 {
-       uint32_t metaindex_num;
+       guint32                         metaindex_num;
        struct rspamd_index_block *idxb;
        struct rspamd_binlog_index *idx;
        gboolean idx_mapped = FALSE, res = TRUE, is_first = FALSE;
@@ -467,8 +467,8 @@ binlog_sync (struct rspamd_binlog *log, uint64_t from_rev, uint64_t *from_time,
        /* Now fill reply structure */
        (*rep)->len = idx->len;
        /* Read result */
-       msg_info ("update from binlog '%s' from revision: %ul to revision %ul size is %ul",
-                       log->filename, (long unsigned)from_rev, (long unsigned)log->cur_seq, (long unsigned)idx->len);
+       msg_info ("update from binlog '%s' from revision: %uL to revision %uL size is %uL",
+                       log->filename, from_rev, log->cur_seq, idx->len);
        if (lseek (log->fd, idx->seek, SEEK_SET) == -1) {
                msg_warn ("cannot seek file %s, error %d, %s", log->filename, errno, strerror (errno));
                res = FALSE;
@@ -538,7 +538,7 @@ maybe_write_binlog (struct classifier_config *ccf, struct statfile *st, stat_fil
        }
 
        if (binlog_insert (log, nodes)) {
-               msg_info ("set new revision of statfile %s: %ul", st->symbol, (long unsigned)log->cur_seq);
+               msg_info ("set new revision of statfile %s: %uL", st->symbol, log->cur_seq);
                (void)statfile_set_revision (file, log->cur_seq, log->cur_time);
                return TRUE;
        }
index bb8b8f244a1fe8834560bf51f027b5f0944c1daa..4f840105dc35814fdd1ceb824d9d6f308422fa79 100644 (file)
 
 /* Assume 8 bytes words */
 struct rspamd_binlog_header {
-       char magic[3];
-       char version[2];
-       char padding[3];
-       uint64_t create_time;
+       gchar magic[3];
+       gchar version[2];
+       gchar padding[3];
+       guint64 create_time;
 };
 
 struct rspamd_binlog_index {
-       uint64_t time;
-       uint64_t seek;
-       uint32_t len;
+       guint64 time;
+       guint64 seek;
+       guint32 len;
 };
 
 struct rspamd_index_block {
        struct rspamd_binlog_index indexes[BINLOG_IDX_LEN];
-       uint32_t last_index;
+       guint32 last_index;
 };
 
 struct rspamd_binlog_metaindex {
-       uint64_t indexes[METAINDEX_LEN];
-       uint64_t last_index;
+       guint64 indexes[METAINDEX_LEN];
+       guint64 last_index;
 };
 
 struct rspamd_binlog_element {
-       uint32_t h1;
-       uint32_t h2;
+       guint32 h1;
+       guint32 h2;
        float value;
 } __attribute__((__packed__));
 
 struct rspamd_binlog {
-       char *filename;
+       gchar *filename;
        time_t rotate_time;
-       int rotate_jitter;
-       uint64_t cur_seq;
-       uint64_t cur_time;
-       int fd;
+       gint rotate_jitter;
+       guint64 cur_seq;
+       guint64 cur_time;
+       gint fd;
        memory_pool_t *pool;
 
        struct rspamd_binlog_header header;
@@ -55,11 +55,11 @@ struct rspamd_binlog {
 
 struct classifier_config;
 
-struct rspamd_binlog* binlog_open (memory_pool_t *pool, const char *path, time_t rotate_time, int rotate_jitter);
+struct rspamd_binlog* binlog_open (memory_pool_t *pool, const gchar *path, time_t rotate_time, gint rotate_jitter);
 struct rspamd_binlog* get_binlog_by_statfile (struct statfile *st);
 void binlog_close (struct rspamd_binlog *log);
 gboolean binlog_insert (struct rspamd_binlog *log, GTree *nodes);
-gboolean binlog_sync (struct rspamd_binlog *log, uint64_t from_rev, uint64_t *from_time, GByteArray **rep);
+gboolean binlog_sync (struct rspamd_binlog *log, guint64 from_rev, guint64 *from_time, GByteArray **rep);
 gboolean maybe_write_binlog (struct classifier_config *ccf, struct statfile *st, stat_file_t *file, GTree *nodes);
 
 #endif
index 154296e16fdca88bdcf264a2587279d4f96814ce..483d596d708a26c2347ac04e01beb65552a63ccd 100644 (file)
 #define GETBIT(a, n) (a[n * SIZE_BIT / CHAR_BIT] & (0xF << (n % (CHAR_BIT/SIZE_BIT) * SIZE_BIT)))
 
 /* Common hash functions */
-unsigned int
-bloom_sax_hash (const char *key)
+guint
+bloom_sax_hash (const gchar *key)
 {
-       unsigned int                    h = 0;
+       guint                           h = 0;
 
        while (*key)
-               h ^= (h << 5) + (h >> 2) + (unsigned char)*key++;
+               h ^= (h << 5) + (h >> 2) + (gchar)*key++;
 
        return h;
 }
 
-unsigned int
-bloom_sdbm_hash (const char *key)
+guint
+bloom_sdbm_hash (const gchar *key)
 {
-       unsigned int                    h = 0;
+       guint                           h = 0;
 
        while (*key)
-               h = (unsigned char)*key++ + (h << 6) + (h << 16) - h;
+               h = (gchar)*key++ + (h << 6) + (h << 16) - h;
 
        return h;
 }
 
-unsigned int
-bloom_fnv_hash (const char *key)
+guint
+bloom_fnv_hash (const gchar *key)
 {
-       unsigned int                    h = 0;
+       guint                           h = 0;
 
        while (*key) {
-               h ^= (unsigned char)*key++;
+               h ^= (gchar)*key++;
                h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24);
        }
 
        return h;
 }
 
-unsigned int
-bloom_rs_hash (const char *key)
+guint
+bloom_rs_hash (const gchar *key)
 {
-       unsigned int                    b = 378551;
-       unsigned int                    a = 63689;
-       unsigned int                    hash = 0;
+       guint                           b = 378551;
+       guint                           a = 63689;
+       guint                           hash = 0;
 
        while (*key) {
-               hash = hash * a + (unsigned char)*key++;
+               hash = hash * a + (gchar)*key++;
                a = a * b;
        }
 
        return hash;
 }
 
-unsigned int
-bloom_js_hash (const char *key)
+guint
+bloom_js_hash (const gchar *key)
 {
-       unsigned int                    hash = 1315423911;
+       guint                           hash = 1315423911;
 
        while (*key) {
-               hash ^= ((hash << 5) + (unsigned char)*key++ + (hash >> 2));
+               hash ^= ((hash << 5) + (gchar)*key++ + (hash >> 2));
        }
 
        return hash;
 }
 
 
-unsigned int
-bloom_elf_hash (const char *key)
+guint
+bloom_elf_hash (const gchar *key)
 {
-       unsigned int                    hash = 0;
-       unsigned int                    x = 0;
+       guint                           hash = 0;
+       guint                           x = 0;
 
        while (*key) {
-               hash = (hash << 4) + (unsigned char)*key++;
+               hash = (hash << 4) + (gchar)*key++;
                if ((x = hash & 0xF0000000L) != 0) {
                        hash ^= (x >> 24);
                }
@@ -131,28 +131,28 @@ bloom_elf_hash (const char *key)
 }
 
 
-unsigned int
-bloom_bkdr_hash (const char *key)
+guint
+bloom_bkdr_hash (const gchar *key)
 {
-       unsigned int                    seed = 131;     /* 31 131 1313 13131 131313 etc.. */
-       unsigned int                    hash = 0;
+       guint                           seed = 131;     /* 31 131 1313 13131 131313 etc.. */
+       guint                           hash = 0;
 
        while (*key) {
-               hash = (hash * seed) + (unsigned char)*key++;
+               hash = (hash * seed) + (gchar)*key++;
        }
 
        return hash;
 }
 
 
-unsigned int
-bloom_ap_hash (const char *key)
+guint
+bloom_ap_hash (const gchar *key)
 {
-       unsigned int                    hash = 0xAAAAAAAA;
-       unsigned int                    i = 0;
+       guint                           hash = 0xAAAAAAAA;
+       guint                           i = 0;
 
        while (*key) {
-               hash ^= ((i & 1) == 0) ? ((hash << 7) ^ ((unsigned char)*key) * (hash >> 3)) : (~((hash << 11) + (((unsigned char)*key) ^ (hash >> 5))));
+               hash ^= ((i & 1) == 0) ? ((hash << 7) ^ ((gchar)*key) * (hash >> 3)) : (~((hash << 11) + (((gchar)*key) ^ (hash >> 5))));
                key++;
        }
 
@@ -164,12 +164,12 @@ bloom_create (size_t size, size_t nfuncs, ...)
 {
        bloom_filter_t                 *bloom;
        va_list                         l;
-       int                             n;
+       gint                            n;
 
        if (!(bloom = g_malloc (sizeof (bloom_filter_t)))) {
                return NULL;
        }
-       if (!(bloom->a = g_new0 (char,  (size + CHAR_BIT - 1) / CHAR_BIT * SIZE_BIT))) {
+       if (!(bloom->a = g_new0 (gchar,  (size + CHAR_BIT - 1) / CHAR_BIT * SIZE_BIT))) {
                g_free (bloom);
                return NULL;
        }
@@ -200,7 +200,7 @@ bloom_destroy (bloom_filter_t * bloom)
 }
 
 gboolean
-bloom_add (bloom_filter_t * bloom, const char *s)
+bloom_add (bloom_filter_t * bloom, const gchar *s)
 {
        size_t                          n;
        u_char                          t;
@@ -213,7 +213,7 @@ bloom_add (bloom_filter_t * bloom, const char *s)
 }
 
 gboolean
-bloom_del (bloom_filter_t * bloom, const char *s)
+bloom_del (bloom_filter_t * bloom, const gchar *s)
 {
        size_t                          n;
        u_char                          t;
@@ -227,7 +227,7 @@ bloom_del (bloom_filter_t * bloom, const char *s)
 }
 
 gboolean
-bloom_check (bloom_filter_t * bloom, const char *s)
+bloom_check (bloom_filter_t * bloom, const gchar *s)
 {
        size_t                          n;
 
index e97b0aaee01ffc021d02cf105b9e717b256dc730..bd53613a9c2bfa2d8bee464fa425414b3c792e75 100644 (file)
@@ -3,31 +3,31 @@
 
 #include "config.h"
 
-typedef unsigned int (*hashfunc_t) (const char *);
+typedef guint (*hashfunc_t) (const gchar *);
 
 typedef struct bloom_filter_s {
        size_t          asize;
-       unsigned char  *a;
+       gchar          *a;
        size_t          nfuncs;
        hashfunc_t     *funcs;
 } bloom_filter_t;
 
 /* Hash functions */
-unsigned int bloom_sax_hash (const char *key);
-unsigned int bloom_sdbm_hash (const char *key);
-unsigned int bloom_fnv_hash (const char *key);
-unsigned int bloom_rs_hash (const char *key);
-unsigned int bloom_js_hash (const char *key);
-unsigned int bloom_elf_hash (const char *key);
-unsigned int bloom_bkdr_hash (const char *key);
-unsigned int bloom_ap_hash (const char *key);
+guint bloom_sax_hash (const gchar *key);
+guint bloom_sdbm_hash (const gchar *key);
+guint bloom_fnv_hash (const gchar *key);
+guint bloom_rs_hash (const gchar *key);
+guint bloom_js_hash (const gchar *key);
+guint bloom_elf_hash (const gchar *key);
+guint bloom_bkdr_hash (const gchar *key);
+guint bloom_ap_hash (const gchar *key);
 
 #define DEFAULT_BLOOM_HASHES 8, bloom_sax_hash, bloom_sdbm_hash, bloom_fnv_hash, bloom_rs_hash, bloom_js_hash, bloom_elf_hash, bloom_bkdr_hash, bloom_ap_hash
 
 bloom_filter_t* bloom_create (size_t size, size_t nfuncs, ...);
 void bloom_destroy (bloom_filter_t * bloom);
-gboolean bloom_add (bloom_filter_t * bloom, const char *s);
-gboolean bloom_del (bloom_filter_t * bloom, const char *s);
-gboolean bloom_check (bloom_filter_t * bloom, const char *s);
+gboolean bloom_add (bloom_filter_t * bloom, const gchar *s);
+gboolean bloom_del (bloom_filter_t * bloom, const gchar *s);
+gboolean bloom_check (bloom_filter_t * bloom, const gchar *s);
 
 #endif
index c5b775dfc8d372b57b4eaa4ee21c7b696138f348..45b788ca992d40987b7432e3b932f51b8ec634c2 100644 (file)
@@ -28,7 +28,7 @@
 
 #define G_DISPATCHER_ERROR dispatcher_error_quark()
 
-static void                     dispatcher_cb (int fd, short what, void *arg);
+static void                     dispatcher_cb (gint fd, short what, void *arg);
 
 static inline                   GQuark
 dispatcher_error_quark (void)
@@ -39,7 +39,7 @@ dispatcher_error_quark (void)
 static gboolean
 sendfile_callback (rspamd_io_dispatcher_t *d)
 {
-       ssize_t                         r;
+
        GError                         *err;
 
 #ifdef HAVE_SENDFILE
@@ -81,6 +81,7 @@ sendfile_callback (rspamd_io_dispatcher_t *d)
                d->in_sendfile = FALSE;
        }
 # else
+       ssize_t                         r;
        /* Linux version */
        r = sendfile (d->fd, d->sendfile_fd, &d->offset, d->file_size);
        if (r == -1) {
@@ -120,6 +121,7 @@ sendfile_callback (rspamd_io_dispatcher_t *d)
        }
 # endif
 #else
+       ssize_t                         r;
        r = write (d->fd, d->map, d->file_size - d->offset);
        if (r == -1) {
                if (errno != EAGAIN) {
@@ -164,7 +166,7 @@ sendfile_callback (rspamd_io_dispatcher_t *d)
 #define BUFREMAIN(x) (x)->data->size - ((x)->pos - (x)->data->begin)
 
 static                          gboolean
-write_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean is_delayed)
+write_buffers (gint fd, rspamd_io_dispatcher_t * d, gboolean is_delayed)
 {
        GList                          *cur;
        GError                         *err;
@@ -247,13 +249,13 @@ write_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean is_delayed)
 }
 
 static void
-read_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean skip_read)
+read_buffers (gint fd, rspamd_io_dispatcher_t * d, gboolean skip_read)
 {
        ssize_t                         r;
        GError                         *err;
        f_str_t                         res;
-       char                           *c, *b;
-       char                           *end;
+       gchar                           *c, *b;
+       gchar                           *end;
        size_t                          len;
        enum io_policy                  saved_policy;
 
@@ -437,12 +439,12 @@ read_buffers (int fd, rspamd_io_dispatcher_t * d, gboolean skip_read)
 #undef BUFREMAIN
 
 static void
-dispatcher_cb (int fd, short what, void *arg)
+dispatcher_cb (gint fd, short what, void *arg)
 {
        rspamd_io_dispatcher_t         *d = (rspamd_io_dispatcher_t *) arg;
        GError                         *err;
 
-       debug_ip (d->peer_addr, "in dispatcher callback, what: %d, fd: %d", (int)what, fd);
+       debug_ip (d->peer_addr, "in dispatcher callback, what: %d, fd: %d", (gint)what, fd);
 
        switch (what) {
        case EV_TIMEOUT:
@@ -476,7 +478,7 @@ dispatcher_cb (int fd, short what, void *arg)
 
 
 rspamd_io_dispatcher_t         *
-rspamd_create_dispatcher (int fd, enum io_policy policy,
+rspamd_create_dispatcher (gint fd, enum io_policy policy,
        dispatcher_read_callback_t read_cb, dispatcher_write_callback_t write_cb, dispatcher_err_callback_t err_cb, struct timeval *tv, void *user_data)
 {
        rspamd_io_dispatcher_t         *new;
@@ -531,7 +533,7 @@ void
 rspamd_set_dispatcher_policy (rspamd_io_dispatcher_t * d, enum io_policy policy, size_t nchars)
 {
        f_str_t                        *tmp;
-       int                             t;
+       gint                            t;
 
        if (d->policy != policy) {
                d->policy = policy;
@@ -571,7 +573,7 @@ rspamd_dispatcher_write (rspamd_io_dispatcher_t * d, void *data, size_t len, gbo
        newbuf = memory_pool_alloc (d->pool, sizeof (rspamd_buffer_t));
        if (len == 0) {
                /* Assume NULL terminated */
-               len = strlen ((char *)data);
+               len = strlen ((gchar *)data);
        }
 
        if (!allocated) {
@@ -600,7 +602,7 @@ rspamd_dispatcher_write (rspamd_io_dispatcher_t * d, void *data, size_t len, gbo
 
 
 gboolean 
-rspamd_dispatcher_sendfile (rspamd_io_dispatcher_t *d, int fd, size_t len)
+rspamd_dispatcher_sendfile (rspamd_io_dispatcher_t *d, gint fd, size_t len)
 {
        if (lseek (fd, 0, SEEK_SET) == -1) {
                msg_warn ("lseek failed: %s", strerror (errno));
index c63fb8c6aca140dd8420da463d957256c0e8bda6..fc92511b054aa60f86c57c36766b643b974cd556 100644 (file)
@@ -28,7 +28,7 @@ enum io_policy {
  */
 typedef struct rspamd_buffer_s {
        f_str_t *data;                                                                                                  /**< buffer logic                       */
-       char *pos;                                                                                                              /**< current position           */
+       gchar *pos;                                                                                                             /**< current position           */
 } rspamd_buffer_t;
 
 typedef struct rspamd_io_dispatcher_s {
@@ -39,8 +39,8 @@ typedef struct rspamd_io_dispatcher_s {
        memory_pool_t *pool;                                                                                    /**< where to store data        */
        enum io_policy policy;                                                                                  /**< IO policy                          */
        size_t nchars;                                                                                                  /**< how many chars to read     */
-       int fd;                                                                                                                 /**< descriptor                         */
-       uint32_t peer_addr;                                                                                             /**< address of peer for debugging */
+       gint fd;                                                                                                                        /**< descriptor                         */
+       guint32 peer_addr;                                                                                              /**< address of peer for debugging */
        gboolean wanna_die;                                                                                             /**< if dispatcher should be stopped */
        dispatcher_read_callback_t read_callback;                                               /**< read callback                      */
        dispatcher_write_callback_t write_callback;                                             /**< write callback                     */
@@ -48,7 +48,7 @@ typedef struct rspamd_io_dispatcher_s {
        void *user_data;                                                                                                /**< user's data for callbacks */
        off_t offset;                                                                                                   /**< for sendfile use           */
        size_t file_size;
-       int sendfile_fd;
+       gint sendfile_fd;
        gboolean in_sendfile;                                                                                   /**< whether buffer is in sendfile mode */
        gboolean strip_eol;                                                                                             /**< strip or not line ends in BUFFER_LINE policy */
 #ifndef HAVE_SENDFILE
@@ -67,7 +67,7 @@ typedef struct rspamd_io_dispatcher_s {
  * @param user_data pointer to user's data
  * @return new dispatcher object or NULL in case of failure
  */
-rspamd_io_dispatcher_t* rspamd_create_dispatcher (int fd, 
+rspamd_io_dispatcher_t* rspamd_create_dispatcher (gint fd, 
                                                                                                  enum io_policy policy,
                                                                                                  dispatcher_read_callback_t read_cb,
                                                                                                  dispatcher_write_callback_t write_cb,
@@ -101,7 +101,7 @@ gboolean rspamd_dispatcher_write (rspamd_io_dispatcher_t *d,
  * @param fd descriptor of file
  * @param len length of data
  */
-gboolean rspamd_dispatcher_sendfile (rspamd_io_dispatcher_t *d, int fd, size_t len) G_GNUC_WARN_UNUSED_RESULT;
+gboolean rspamd_dispatcher_sendfile (rspamd_io_dispatcher_t *d, gint fd, size_t len) G_GNUC_WARN_UNUSED_RESULT;
 
 /**
  * Pause IO events on dispatcher
index d770c237e8c9d704aa994e9c5f4f876afe3998e1..ddc78b15065338e85cebb428074227a4a7335c06 100644 (file)
@@ -91,9 +91,9 @@ struct rspamd_regexp {
 struct memcached_server {
        struct upstream up;                                                             /**< common upstream base                                                               */
        struct in_addr addr;                                                    /**< address of server                                                                  */
-       uint16_t port;                                                                  /**< port to connect                                                                    */
+       guint16 port;                                                                   /**< port to connect                                                                    */
        short alive;                                                                    /**< is this server alive                                                               */
-       short int num;                                                                  /**< number of servers in case of mirror                                */
+       gint16 num;                                                                     /**< number of servers in case of mirror                                */
 };
 
 /**
@@ -129,8 +129,8 @@ struct module_opt {
  * Statfile section definition
  */
 struct statfile_section {
-       uint32_t code;                                                                  /**< section's code                                                                             */
-       uint64_t size;                                                                  /**< size of section                                                                    */
+       guint32 code;                                                                   /**< section's code                                                                             */
+       guint64 size;                                                                   /**< size of section                                                                    */
        double weight;                                                                  /**< weight coefficient for section                                             */
 };
 
@@ -160,7 +160,7 @@ struct statfile_binlog_params {
        enum sync_affinity affinity;
        time_t rotate_time;
        struct in_addr master_addr;
-       uint16_t master_port;
+       guint16 master_port;
 };
 
 typedef double (*statfile_normalize_func)(struct config_file *cfg, long double score, void *params);
@@ -211,15 +211,15 @@ struct config_scalar {
  * Config params for rspamd worker
  */
 struct worker_conf {
-       int type;                                                                               /**< worker type                                                                                */
+       gint type;                                                                              /**< worker type                                                                                */
        gchar *bind_host;                                                               /**< bind line                                                                                  */
        struct in_addr bind_addr;                                               /**< bind address in case of TCP socket                                 */
-       uint16_t bind_port;                                                             /**< bind port in case of TCP socket                                    */
-       uint16_t bind_family;                                                   /**< bind type (AF_UNIX or AF_INET)                                             */
-       uint16_t count;                                                                 /**< number of workers                                                                  */
-       int listen_sock;                                                                /**< listening socket desctiptor                                                */
-       uint32_t rlimit_nofile;                                                 /**< max files limit                                                                    */
-       uint32_t rlimit_maxcore;                                                /**< maximum core file size                                                             */
+       guint16 bind_port;                                                              /**< bind port in case of TCP socket                                    */
+       guint16 bind_family;                                                    /**< bind type (AF_UNIX or AF_INET)                                             */
+       guint16 count;                                                                  /**< number of workers                                                                  */
+       gint listen_sock;                                                               /**< listening socket desctiptor                                                */
+       guint32 rlimit_nofile;                                                  /**< max files limit                                                                    */
+       guint32 rlimit_maxcore;                                         /**< maximum core file size                                                             */
        GHashTable *params;                                                             /**< params for worker                                                                  */
        GQueue *active_workers;                                                 /**< linked list of spawned workers                                             */
        gboolean has_socket;                                                    /**< whether we should make listening socket in main process */
@@ -245,11 +245,11 @@ struct config_file {
        gboolean convert_config;                                                /**< convert config to XML format                                               */
 
        enum rspamd_log_type log_type;                                  /**< log type                                                                                   */
-       int log_facility;                                                               /**< log facility in case of syslog                                             */
-       int log_level;                                                                  /**< log level trigger                                                                  */
+       gint log_facility;                                                              /**< log facility in case of syslog                                             */
+       gint log_level;                                                                 /**< log level trigger                                                                  */
        gchar *log_file;                                                                /**< path to logfile in case of file logging                    */
        gboolean log_buffered;                                                  /**< whether logging is buffered                                                */
-       uint32_t log_buf_size;                                                  /**< length of log buffer                                                               */
+       guint32 log_buf_size;                                                   /**< length of log buffer                                                               */
        gchar *debug_ip_map;                                                /**< turn on debugging for specified ip addresses       */
        gboolean log_urls;                                                              /**< whether we should log URLs                         */
        GList *debug_symbols;                                                   /**< symbols to debug                                                                   */
@@ -259,10 +259,10 @@ struct config_file {
        struct memcached_server memcached_servers[MAX_MEMCACHED_SERVERS];       /**< memcached servers                          */
        gsize memcached_servers_num;                                    /**< number of memcached servers                                                */
        memc_proto_t memcached_protocol;                                /**< memcached protocol                                                                 */
-       unsigned int memcached_error_time;                              /**< memcached error time (see upstream documentation)  */
-       unsigned int memcached_dead_time;                               /**< memcached dead time                                                                */
-       unsigned int memcached_maxerrors;                               /**< maximum number of errors                                                   */
-       unsigned int memcached_connect_timeout;                 /**< connection timeout                                                                 */
+       guint memcached_error_time;                             /**< memcached error time (see upstream documentation)  */
+       guint memcached_dead_time;                              /**< memcached dead time                                                                */
+       guint memcached_maxerrors;                              /**< maximum number of errors                                                   */
+       guint memcached_connect_timeout;                        /**< connection timeout                                                                 */
 
        gboolean delivery_enable;                                               /**< is delivery agent is enabled                                               */
        gchar *deliver_host;                                                    /**< host for mail deliviring                                                   */
@@ -294,10 +294,10 @@ struct config_file {
        GHashTable* user_settings;                      /**< settings per-user                                  */
        gchar* domain_settings_str;                                             /**< string representation of settings                                  */
        gchar* user_settings_str;
-       int clock_res;                                                                  /**< resolution of clock used                                                   */
+       gint clock_res;                                                                 /**< resolution of clock used                                                   */
 
        struct symbols_cache *cache;                                    /**< symbols cache object                                                               */ 
-       char *cache_filename;                                                   /**< filename of cache file                                                             */
+       gchar *cache_filename;                                                  /**< filename of cache file                                                             */
        struct metric *default_metric;                                  /**< default metric                                                                             */
        
        gchar* checksum;                                                                /**< real checksum of config file                                               */ 
@@ -316,7 +316,7 @@ struct config_file {
  * @param port port
  * @return TRUE if string was parsed
  */
-gboolean parse_host_port (const gchar *str, struct in_addr *ina, uint16_t *port);
+gboolean parse_host_port (const gchar *str, struct in_addr *ina, guint16 *port);
 
 /**
  * Parse bind credits
@@ -325,7 +325,7 @@ gboolean parse_host_port (const gchar *str, struct in_addr *ina, uint16_t *port)
  * @param type type of credits
  * @return 1 if line was successfully parsed and 0 in case of error
  */
-int parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str);
+gint parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str);
 
 /**
  * Init default values
@@ -360,7 +360,7 @@ gsize parse_limit (const gchar *limit);
  * @param t string representation of seconds (eg. 1D)
  * @return numeric value of string
  */
-unsigned int parse_seconds (const gchar *t);
+guint parse_seconds (const gchar *t);
 
 /**
  * Parse flag
index 1f78b5ca31ccad153f49d80224c1c87ae73f5e8d..7e8bb3abc6991818353761b54ab4983b63c502c2 100644 (file)
 
 
 gboolean
-parse_host_port (const gchar *str, struct in_addr *ina, uint16_t *port)
+parse_host_port (const gchar *str, struct in_addr *ina, guint16 *port)
 {
        gchar                           **tokens, *err_str;
        struct hostent                 *hent;
-       unsigned int                    port_parsed, saved_errno = errno;
+       guint                           port_parsed, saved_errno = errno;
 
        tokens = g_strsplit_set (str, ":", 0);
        if (!tokens || !tokens[0]) {
@@ -98,11 +98,11 @@ err:
        return FALSE;
 }
 
-int
+gint
 parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str)
 {
        gchar                          **host;
-       int16_t                        *family, *port;
+       gint16                        *family, *port;
        struct in_addr                 *addr;
 
        if (str == NULL)
@@ -118,7 +118,7 @@ parse_bind_line (struct config_file *cfg, struct worker_conf *cf, gchar *str)
 #ifdef HAVE_DIRNAME
                /* Try to check path of bind credit */
                struct stat                     st;
-               int                             fd;
+               gint                            fd;
                gchar                           *copy = memory_pool_strdup (cfg->cfg_pool, str);
                if (stat (copy, &st) == -1) {
                        if (errno == ENOENT) {
@@ -215,7 +215,7 @@ get_module_opt (struct config_file *cfg, gchar *module_name, gchar *opt_name)
 {
        GList                          *cur_opt;
        struct module_opt              *cur;
-       static char                     numbuf[64];
+       static gchar                     numbuf[64];
 
        cur_opt = g_hash_table_lookup (cfg->modules_opts, module_name);
        if (cur_opt == NULL) {
@@ -241,7 +241,7 @@ get_module_opt (struct config_file *cfg, gchar *module_name, gchar *opt_name)
                                                snprintf (numbuf, sizeof (numbuf), "%s", *(gboolean *)cur->actual_data ? "yes" : "no");
                                                return numbuf;
                                        case LUA_VAR_STRING:
-                                               return (char *)cur->actual_data;
+                                               return (gchar *)cur->actual_data;
                                        case LUA_VAR_FUNCTION:
                                                msg_info ("option %s is dynamic, so it cannot be aqquired statically", opt_name);
                                                return NULL;
@@ -286,10 +286,10 @@ parse_limit (const gchar *limit)
        return result;
 }
 
-unsigned int
+guint
 parse_seconds (const gchar *t)
 {
-       unsigned int                    result = 0;
+       guint                           result = 0;
        gchar                           *err_str;
 
        if (!t || *t == '\0')
@@ -431,7 +431,7 @@ parse_filters_str (struct config_file *cfg, const gchar *str)
 {
        gchar                         **strvec, **p;
        struct filter                  *cur;
-       int                             i;
+       gint                            i;
 
        if (str == NULL) {
                return;
@@ -502,7 +502,7 @@ fill_cfg_params (struct config_file *cfg)
 gboolean
 get_config_checksum (struct config_file *cfg) 
 {
-       int                             fd;
+       gint                            fd;
        void                           *map;
        struct stat                     st;
 
@@ -555,7 +555,7 @@ post_load_config (struct config_file *cfg)
        clock_getres (CLOCK_REALTIME, &ts);
 # endif
 
-       cfg->clock_res = (int)log10 (1000000 / ts.tv_nsec);
+       cfg->clock_res = (gint)log10 (1000000 / ts.tv_nsec);
        if (cfg->clock_res < 0) {
                cfg->clock_res = 0;
        }
@@ -588,7 +588,7 @@ parse_err (const gchar *fmt, ...)
 {
        va_list                         aq;
        gchar                            logbuf[BUFSIZ], readbuf[32];
-       int                             r;
+       gint                            r;
 
        va_start (aq, fmt);
        g_strlcpy (readbuf, yytext, sizeof (readbuf));
@@ -605,7 +605,7 @@ parse_warn (const gchar *fmt, ...)
 {
        va_list                         aq;
        gchar                            logbuf[BUFSIZ], readbuf[32];
-       int                             r;
+       gint                            r;
 
        va_start (aq, fmt);
        g_strlcpy (readbuf, yytext, sizeof (readbuf));
@@ -763,7 +763,7 @@ parse_lua_normalizer (struct config_file *cfg, struct statfile *st, const gchar
 {
     gchar *code_begin;
     GList *params = NULL;
-    int len;
+    gint                            len;
 
     code_begin = strchr (line, ':');
     
@@ -826,7 +826,7 @@ gboolean
 read_xml_config (struct config_file *cfg, const gchar *filename)
 {
        struct stat st;
-       int fd;
+       gint                            fd;
        gchar *data;
        gboolean res;
        GMarkupParseContext *ctx;
index 9e86997e0b3687075122d9a832e47b9bea2ae01d..cf09dbe65115432826778a5942df4a15c7f053a6 100644 (file)
@@ -64,9 +64,9 @@ enum xml_config_section {
 };
 
 struct xml_config_param {
-       const char *name;
+       const gchar *name;
        element_handler_func handler;
-       int offset;
+       gint                            offset;
        gpointer user_data;
 };
 
@@ -450,10 +450,10 @@ extract_attr (const gchar *attr, const gchar **attribute_names, const gchar **at
        return FALSE;
 }
 
-static inline char*
+static inline gchar*
 xml_asciiz_string (memory_pool_t *pool, const gchar *text, gsize len)
 {
-       char                           *val;
+       gchar                           *val;
 
        val = memory_pool_alloc (pool, len + 1);
        g_strlcpy (val, text, len + 1);
@@ -494,7 +494,7 @@ call_param_handler (struct rspamd_xml_userdata *ctx, const gchar *name, gchar *v
 {
        struct xml_parser_rule         *rule;
        struct xml_config_param        *param;
-       int                             i;
+       gint                            i;
        
        /* First find required section */
        for (i = 0; i < G_N_ELEMENTS (grammar); i ++) {
@@ -526,9 +526,9 @@ call_param_handler (struct rspamd_xml_userdata *ctx, const gchar *name, gchar *v
 
 /* Logging section */
 gboolean 
-handle_log_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_log_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
-       char                           *val;
+       gchar                           *val;
        if (g_ascii_strcasecmp (data, "file") == 0) {
                /* Find filename attribute */
                if ((val = g_hash_table_lookup (attrs, "filename")) == NULL) {
@@ -601,7 +601,7 @@ handle_log_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHash
 }
 
 gboolean 
-handle_log_level (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_log_level (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        if (g_ascii_strcasecmp (data, "error") == 0) {
                cfg->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
@@ -625,10 +625,10 @@ handle_log_level (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHas
 
 /* Worker section */
 gboolean 
-worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct worker_conf             *wrk = ctx->section_pointer;
-       char                           *name;
+       gchar                           *name;
 
        if ((name = g_hash_table_lookup (attrs, "name")) == NULL) {
                msg_err ("worker param tag must have \"name\" attribute");
@@ -640,7 +640,7 @@ worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, G
        return TRUE;
 }
 gboolean 
-worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct worker_conf             *wrk = ctx->section_pointer;
 
@@ -678,7 +678,7 @@ worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GH
 }
 
 gboolean 
-worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct worker_conf             *wrk = ctx->section_pointer;
 
@@ -713,7 +713,7 @@ check_action (const gchar *data, gint *result)
 }
 
 gboolean
-handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct metric                  *metric = ctx->section_pointer;
        gchar                          *p, *errstr;
@@ -749,9 +749,9 @@ handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx,
 }
 
 gboolean
-handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
-       char                           *strval, *err;
+       gchar                           *strval, *err;
        double                         *value;
        GList                          *metric_list;
        struct metric                  *metric = ctx->section_pointer;
@@ -787,9 +787,9 @@ handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx,
 
 /* Modules section */
 gboolean 
-handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
-       char                           *name, *val;
+       gchar                           *name, *val;
        GList                          *cur_opt;
        struct module_opt              *cur;
        gboolean                        is_lua = FALSE;
@@ -818,7 +818,7 @@ handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHa
 
 /* Handle lua tag */
 gboolean 
-handle_lua (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_lua (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        gchar                        *val, *cur_dir, *lua_dir, *lua_file, *tmp1, *tmp2;
        lua_State                    *L = cfg->lua_state;
@@ -888,14 +888,14 @@ handle_lua (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable
 
 /* Modules section */
 gboolean 
-handle_module_path (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_module_path (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct stat st;
        struct script_module *cur;
        glob_t globbuf;
-       char *pattern;
+       gchar                           *pattern;
        size_t len;
-       int i;
+       gint                            i;
 
        if (stat (data, &st) == -1) {
                msg_err ("cannot stat path %s, %s", data, strerror (errno));
@@ -937,7 +937,7 @@ handle_module_path (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GH
 
 /* Variables and composites */
 gboolean 
-handle_variable (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_variable (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        gchar                        *val;
        
@@ -951,7 +951,7 @@ handle_variable (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHash
 }
 
 gboolean 
-handle_composite (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_composite (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        gchar                        *val;
        struct expression            *expr;
@@ -972,7 +972,7 @@ handle_composite (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHas
 
 /* View section */
 gboolean 
-handle_view_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_view_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct rspamd_view          *view = ctx->section_pointer;
 
@@ -984,7 +984,7 @@ handle_view_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashT
        return TRUE;
 }
 gboolean 
-handle_view_client_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_view_client_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct rspamd_view          *view = ctx->section_pointer;
 
@@ -996,7 +996,7 @@ handle_view_client_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx,
        return TRUE;
 }
 gboolean 
-handle_view_from (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_view_from (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct rspamd_view          *view = ctx->section_pointer;
 
@@ -1008,7 +1008,7 @@ handle_view_from (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHas
        return TRUE;
 }
 gboolean 
-handle_view_rcpt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_view_rcpt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct rspamd_view          *view = ctx->section_pointer;
 
@@ -1020,7 +1020,7 @@ handle_view_rcpt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHas
        return TRUE;
 }
 gboolean
-handle_view_symbols (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_view_symbols (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct rspamd_view          *view = ctx->section_pointer;
 
@@ -1035,7 +1035,7 @@ handle_view_symbols (struct config_file *cfg, struct rspamd_xml_userdata *ctx, G
 
 /* Settings */
 gboolean 
-handle_user_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_user_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        if (!read_settings (data, cfg, cfg->user_settings)) {
                msg_err ("cannot read settings %s", data);
@@ -1046,7 +1046,7 @@ handle_user_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx,
        return TRUE;
 }
 gboolean 
-handle_domain_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_domain_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        if (!read_settings (data, cfg, cfg->domain_settings)) {
                msg_err ("cannot read settings %s", data);
@@ -1058,7 +1058,7 @@ handle_domain_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx
 
 /* Classifier */
 gboolean 
-handle_classifier_tokenizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_classifier_tokenizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct classifier_config     *ccf = ctx->section_pointer;
        
@@ -1071,7 +1071,7 @@ handle_classifier_tokenizer (struct config_file *cfg, struct rspamd_xml_userdata
 }
 
 gboolean 
-handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct classifier_config     *ccf = ctx->section_pointer;
        gchar                        *val;
@@ -1087,14 +1087,14 @@ handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx,
 
 /* Statfile */
 gboolean 
-handle_statfile_normalizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_statfile_normalizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        msg_info ("normalizer option is now not available as rspamd always use internal normalizer for winnow (hyperbolic tanhent)");
        return TRUE;
 }
 
 gboolean 
-handle_statfile_binlog (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_statfile_binlog (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct statfile             *st = ctx->section_pointer;
 
@@ -1115,7 +1115,7 @@ handle_statfile_binlog (struct config_file *cfg, struct rspamd_xml_userdata *ctx
 }
 
 gboolean 
-handle_statfile_binlog_rotate (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_statfile_binlog_rotate (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct statfile             *st = ctx->section_pointer;
 
@@ -1128,7 +1128,7 @@ handle_statfile_binlog_rotate (struct config_file *cfg, struct rspamd_xml_userda
 }
 
 gboolean 
-handle_statfile_binlog_master (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+handle_statfile_binlog_master (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        struct statfile             *st = ctx->section_pointer;
        if (st->binlog == NULL) {
@@ -1145,19 +1145,19 @@ handle_statfile_binlog_master (struct config_file *cfg, struct rspamd_xml_userda
 
 /* Common handlers */
 gboolean 
-xml_handle_string (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_string (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        /* Simply assign pointer to pointer */
        gchar                       **dest;
 
-       dest = (char **)G_STRUCT_MEMBER_P (dest_struct, offset);
+       dest = (gchar **)G_STRUCT_MEMBER_P (dest_struct, offset);
        *dest = memory_pool_strdup (cfg->cfg_pool, data);
 
        return TRUE;
 }
 
 gboolean
-xml_handle_string_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_string_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        GList                      **dest;
        gchar                      **tokens, **cur;
@@ -1181,7 +1181,7 @@ xml_handle_string_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx
 
 
 gboolean 
-xml_handle_size (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_size (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        gsize                      *dest;
 
@@ -1192,7 +1192,7 @@ xml_handle_size (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHash
 }
 
 gboolean 
-xml_handle_seconds (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_seconds (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        guint32                      *dest;
 
@@ -1203,7 +1203,7 @@ xml_handle_seconds (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GH
 }
 
 gboolean 
-xml_handle_boolean (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_boolean (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        gboolean                    *dest;
 
@@ -1222,10 +1222,10 @@ xml_handle_boolean (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GH
 }
 
 gboolean 
-xml_handle_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
        double                      *dest;
-       char                        *err = NULL;
+       gchar                           *err = NULL;
 
        dest = (double *)G_STRUCT_MEMBER_P (dest_struct, offset);
        errno = 0;
@@ -1239,12 +1239,12 @@ xml_handle_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHa
 }
 
 gboolean 
-xml_handle_int (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_int (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
-       int                         *dest;
-       char                        *err = NULL;
+       gint                            *dest;
+       gchar                           *err = NULL;
 
-       dest = (int *)G_STRUCT_MEMBER_P (dest_struct, offset);
+       dest = (gint *)G_STRUCT_MEMBER_P (dest_struct, offset);
        errno = 0;
        *dest = strtol (data, &err, 10);
        if (errno != 0 || (err != NULL && *err != 0)) {
@@ -1256,12 +1256,12 @@ xml_handle_int (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashT
 }
 
 gboolean 
-xml_handle_uint32 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_uint32 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
-       uint32_t                    *dest;
-       char                        *err = NULL;
+       guint32                         *dest;
+       gchar                           *err = NULL;
 
-       dest = (uint32_t *)G_STRUCT_MEMBER_P (dest_struct, offset);
+       dest = (guint32 *)G_STRUCT_MEMBER_P (dest_struct, offset);
        errno = 0;
        *dest = strtoul (data, &err, 10);
        if (errno != 0 || (err != NULL && *err != 0)) {
@@ -1273,12 +1273,12 @@ xml_handle_uint32 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHa
 }
 
 gboolean 
-xml_handle_uint16 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset)
+xml_handle_uint16 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset)
 {
-       uint16_t                    *dest;
-       char                        *err = NULL;
+       guint16                    *dest;
+       gchar                           *err = NULL;
 
-       dest = (uint16_t *)G_STRUCT_MEMBER_P (dest_struct, offset);
+       dest = (guint16 *)G_STRUCT_MEMBER_P (dest_struct, offset);
        errno = 0;
        *dest = strtoul (data, &err, 10);
        if (errno != 0 || (err != NULL && *err != 0)) {
@@ -1537,7 +1537,7 @@ void
 rspamd_xml_text (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error)
 {
        struct rspamd_xml_userdata *ud = user_data;
-       char *val;
+       gchar                           *val;
        struct config_file *cfg = ud->cfg;
        
        /* Strip space symbols */
@@ -1665,45 +1665,45 @@ rspamd_xml_error (GMarkupParseContext *context, GError *error, gpointer user_dat
 static gboolean
 xml_dump_main (struct config_file *cfg, FILE *f)
 {
-       char *escaped_str;
+       gchar                           *escaped_str;
        
        /* Print header comment */
-       fprintf (f, "<!-- Main section -->" EOL);
+       rspamd_fprintf (f, "<!-- Main section -->" EOL);
 
        escaped_str = g_markup_escape_text (cfg->temp_dir, -1); 
-       fprintf (f, "<tempdir>%s</tempdir>" EOL, escaped_str);
+       rspamd_fprintf (f, "<tempdir>%s</tempdir>" EOL, escaped_str);
        g_free (escaped_str);
 
        escaped_str = g_markup_escape_text (cfg->pid_file, -1); 
-       fprintf (f, "<pidfile>%s</pidfile>" EOL, escaped_str);
+       rspamd_fprintf (f, "<pidfile>%s</pidfile>" EOL, escaped_str);
        g_free (escaped_str);
 
        escaped_str = g_markup_escape_text (cfg->filters_str, -1); 
-       fprintf (f, "<filters>%s</filters>" EOL, escaped_str);
+       rspamd_fprintf (f, "<filters>%s</filters>" EOL, escaped_str);
        g_free (escaped_str);
        
        if (cfg->user_settings_str) {
                escaped_str = g_markup_escape_text (cfg->user_settings_str, -1); 
-               fprintf (f, "<user_settings>%s</user_settings>" EOL, escaped_str);
+               rspamd_fprintf (f, "<user_settings>%s</user_settings>" EOL, escaped_str);
                g_free (escaped_str);
        }
        if (cfg->domain_settings_str) {
                escaped_str = g_markup_escape_text (cfg->domain_settings_str, -1); 
-               fprintf (f, "<domain_settings>%s</domain_settings>" EOL, escaped_str);
+               rspamd_fprintf (f, "<domain_settings>%s</domain_settings>" EOL, escaped_str);
                g_free (escaped_str);
        }
-       fprintf (f, "<statfile_pool_size>%llu</statfile_pool_size>" EOL, (long long unsigned)cfg->max_statfile_size);
+       rspamd_fprintf (f, "<statfile_pool_size>%z</statfile_pool_size>" EOL, cfg->max_statfile_size);
 
        if (cfg->checksum)  {
                escaped_str = g_markup_escape_text (cfg->checksum, -1); 
-               fprintf (f, "<checksum>%s</checksum>" EOL, escaped_str);
+               rspamd_fprintf (f, "<checksum>%s</checksum>" EOL, escaped_str);
                g_free (escaped_str);
        }
 
-       fprintf (f, "<raw_mode>%s</raw_mode>" EOL, cfg->raw_mode ? "yes" : "no");
+       rspamd_fprintf (f, "<raw_mode>%s</raw_mode>" EOL, cfg->raw_mode ? "yes" : "no");
 
        /* Print footer comment */
-       fprintf (f, "<!-- End of main section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of main section -->" EOL EOL);
 
        return TRUE;
 }
@@ -1713,11 +1713,11 @@ static void
 xml_variable_callback (gpointer key, gpointer value, gpointer user_data)
 {
        FILE *f = user_data;
-       char *escaped_key, *escaped_value;
+       gchar                           *escaped_key, *escaped_value;
 
        escaped_key = g_markup_escape_text (key, -1); 
        escaped_value = g_markup_escape_text (value, -1);
-       fprintf (f,  "<variable name=\"%s\">%s</variable>" EOL, escaped_key, escaped_value);
+       rspamd_fprintf (f,  "<variable name=\"%s\">%s</variable>" EOL, escaped_key, escaped_value);
        g_free (escaped_key);
        g_free (escaped_value);
 }
@@ -1726,13 +1726,13 @@ static gboolean
 xml_dump_variables (struct config_file *cfg, FILE *f)
 {
        /* Print header comment */
-       fprintf (f, "<!-- Variables section -->" EOL);
+       rspamd_fprintf (f, "<!-- Variables section -->" EOL);
 
        /* Iterate through variables */
        g_hash_table_foreach (cfg->variables, xml_variable_callback, (gpointer)f);
 
        /* Print footer comment */
-       fprintf (f, "<!-- End of variables section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of variables section -->" EOL EOL);
 
        return TRUE;
 }
@@ -1743,13 +1743,13 @@ xml_composite_callback (gpointer key, gpointer value, gpointer user_data)
 {
        FILE *f = user_data;
        struct expression *expr;
-       char *escaped_key, *escaped_value;
+       gchar                           *escaped_key, *escaped_value;
        
        expr = value;
 
        escaped_key = g_markup_escape_text (key, -1); 
        escaped_value = g_markup_escape_text (expr->orig, -1);
-       fprintf (f,  "<composite name=\"%s\">%s</composite>" EOL, escaped_key, escaped_value);
+       rspamd_fprintf (f,  "<composite name=\"%s\">%s</composite>" EOL, escaped_key, escaped_value);
        g_free (escaped_key);
        g_free (escaped_value);
 }
@@ -1758,13 +1758,13 @@ static gboolean
 xml_dump_composites (struct config_file *cfg, FILE *f)
 {
        /* Print header comment */
-       fprintf (f, "<!-- Composites section -->" EOL);
+       rspamd_fprintf (f, "<!-- Composites section -->" EOL);
 
        /* Iterate through variables */
        g_hash_table_foreach (cfg->composite_symbols, xml_composite_callback, (gpointer)f);
 
        /* Print footer comment */
-       fprintf (f, "<!-- End of composites section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of composites section -->" EOL EOL);
 
        return TRUE;
 }
@@ -1774,11 +1774,11 @@ static void
 xml_worker_param_callback (gpointer key, gpointer value, gpointer user_data)
 {
        FILE *f = user_data;
-       char *escaped_key, *escaped_value;
+       gchar                           *escaped_key, *escaped_value;
 
        escaped_key = g_markup_escape_text (key, -1); 
        escaped_value = g_markup_escape_text (value, -1);
-       fprintf (f,  "    <param name=\"%s\">%s</param>" EOL, escaped_key, escaped_value);
+       rspamd_fprintf (f,  "    <param name=\"%s\">%s</param>" EOL, escaped_key, escaped_value);
        g_free (escaped_key);
        g_free (escaped_value);
 }
@@ -1788,53 +1788,53 @@ xml_dump_workers (struct config_file *cfg, FILE *f)
 {
        GList *cur;
        struct worker_conf *wrk;
-       char *escaped_str;
+       gchar                           *escaped_str;
 
        /* Print header comment */
-       fprintf (f, "<!-- Workers section -->" EOL);
+       rspamd_fprintf (f, "<!-- Workers section -->" EOL);
 
        /* Iterate through list */
        cur = g_list_first (cfg->workers);
        while (cur) {
                wrk = cur->data;
                
-               fprintf (f, "<worker>" EOL);
+               rspamd_fprintf (f, "<worker>" EOL);
                switch (wrk->type) {
                        case TYPE_WORKER:
-                               fprintf (f, "  <type>normal</type>" EOL);
+                               rspamd_fprintf (f, "  <type>normal</type>" EOL);
                                break;
                        case TYPE_CONTROLLER:
-                               fprintf (f, "  <type>controller</type>" EOL);
+                               rspamd_fprintf (f, "  <type>controller</type>" EOL);
                                break;
                        case TYPE_FUZZY:
-                               fprintf (f, "  <type>fuzzy</type>" EOL);
+                               rspamd_fprintf (f, "  <type>fuzzy</type>" EOL);
                                break;
                        case TYPE_LMTP:
-                               fprintf (f, "  <type>lmtp</type>" EOL);
+                               rspamd_fprintf (f, "  <type>lmtp</type>" EOL);
                                break;
                        case TYPE_SMTP:
-                               fprintf (f, "  <type>smtp</type>" EOL);
+                               rspamd_fprintf (f, "  <type>smtp</type>" EOL);
                                break;
                }
                escaped_str = g_markup_escape_text (wrk->bind_host, -1); 
-               fprintf (f, "  <bind_socket>%s</bind_socket>" EOL, escaped_str);
+               rspamd_fprintf (f, "  <bind_socket>%s</bind_socket>" EOL, escaped_str);
                g_free (escaped_str);
 
-               fprintf (f, "  <count>%ud</count>" EOL, wrk->count);
-               fprintf (f, "  <maxfiles>%ud</maxfiles>" EOL, wrk->rlimit_nofile);
-               fprintf (f, "  <maxcore>%ud</maxcore>" EOL, wrk->rlimit_maxcore);
+               rspamd_fprintf (f, "  <count>%ud</count>" EOL, wrk->count);
+               rspamd_fprintf (f, "  <maxfiles>%ud</maxfiles>" EOL, wrk->rlimit_nofile);
+               rspamd_fprintf (f, "  <maxcore>%ud</maxcore>" EOL, wrk->rlimit_maxcore);
                
                /* Now dump other attrs */
-               fprintf (f, "<!-- Other params -->" EOL);
+               rspamd_fprintf (f, "<!-- Other params -->" EOL);
                g_hash_table_foreach (wrk->params, xml_worker_param_callback, f);
 
-               fprintf (f, "</worker>" EOL);
+               rspamd_fprintf (f, "</worker>" EOL);
 
                cur = g_list_next (cur);
        }
 
        /* Print footer comment */
-       fprintf (f, "<!-- End of workers section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of workers section -->" EOL EOL);
 
        return TRUE;
 }
@@ -1844,13 +1844,13 @@ static void
 xml_module_callback (gpointer key, gpointer value, gpointer user_data)
 {
        FILE *f = user_data;
-       char *escaped_key, *escaped_value;
+       gchar                           *escaped_key, *escaped_value;
        GList *cur;
        struct module_opt *opt;
        
        escaped_key = g_markup_escape_text (key, -1); 
-       fprintf (f, "<!-- %s -->" EOL, escaped_key);
-       fprintf (f, "<module name=\"%s\">" EOL, escaped_key);
+       rspamd_fprintf (f, "<!-- %s -->" EOL, escaped_key);
+       rspamd_fprintf (f, "<module name=\"%s\">" EOL, escaped_key);
        g_free (escaped_key);
 
        cur = g_list_first (value);
@@ -1858,25 +1858,25 @@ xml_module_callback (gpointer key, gpointer value, gpointer user_data)
                opt = cur->data;
                escaped_key = g_markup_escape_text (opt->param, -1); 
                escaped_value = g_markup_escape_text (opt->value, -1);
-               fprintf (f,  "  <option name=\"%s\">%s</option>" EOL, escaped_key, escaped_value);
+               rspamd_fprintf (f,  "  <option name=\"%s\">%s</option>" EOL, escaped_key, escaped_value);
                g_free (escaped_key);
                g_free (escaped_value);
                cur = g_list_next (cur);
        }
-       fprintf (f, "</module>" EOL EOL);
+       rspamd_fprintf (f, "</module>" EOL EOL);
 }
 
 static gboolean
 xml_dump_modules (struct config_file *cfg, FILE *f)
 {
        /* Print header comment */
-       fprintf (f, "<!-- Modules section -->" EOL);
+       rspamd_fprintf (f, "<!-- Modules section -->" EOL);
 
        /* Iterate through variables */
        g_hash_table_foreach (cfg->modules_opts, xml_module_callback, (gpointer)f);
 
        /* Print footer comment */
-       fprintf (f, "<!-- End of modules section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of modules section -->" EOL EOL);
 
        return TRUE;
 }
@@ -1886,11 +1886,11 @@ static void
 xml_classifier_callback (gpointer key, gpointer value, gpointer user_data)
 {
        FILE *f = user_data;
-       char *escaped_key, *escaped_value;
+       gchar                           *escaped_key, *escaped_value;
 
        escaped_key = g_markup_escape_text (key, -1); 
        escaped_value = g_markup_escape_text (value, -1);
-       fprintf (f,  " <option name=\"%s\">%s</option>" EOL, escaped_key, escaped_value);
+       rspamd_fprintf (f,  " <option name=\"%s\">%s</option>" EOL, escaped_key, escaped_value);
        g_free (escaped_key);
        g_free (escaped_value);
 }
@@ -1903,46 +1903,46 @@ xml_dump_classifiers (struct config_file *cfg, FILE *f)
        struct statfile *st;
 
        /* Print header comment */
-       fprintf (f, "<!-- Classifiers section -->" EOL);
+       rspamd_fprintf (f, "<!-- Classifiers section -->" EOL);
 
        /* Iterate through classifiers */
        cur = g_list_first (cfg->classifiers);
        while (cur) {
                ccf = cur->data;
-               fprintf (f, "<classifier type=\"%s\">" EOL, ccf->classifier->name);
-               fprintf (f, " <tokenizer>%s</tokenizer>" EOL, ccf->tokenizer->name);
-               fprintf (f, " <metric>%s</metric>" EOL, ccf->metric);
+               rspamd_fprintf (f, "<classifier type=\"%s\">" EOL, ccf->classifier->name);
+               rspamd_fprintf (f, " <tokenizer>%s</tokenizer>" EOL, ccf->tokenizer->name);
+               rspamd_fprintf (f, " <metric>%s</metric>" EOL, ccf->metric);
                g_hash_table_foreach (ccf->opts, xml_classifier_callback, f);
                /* Statfiles */
                cur_st = g_list_first (ccf->statfiles);
                while (cur_st) {
                        st = cur_st->data;
-                       fprintf (f, " <statfile>" EOL);
-                       fprintf (f, "  <symbol>%s</symbol>" EOL "  <size>%lu</size>" EOL "  <path>%s</path>" EOL,
-                                               st->symbol, (long unsigned)st->size, st->path);
-                       fprintf (f, "  <normalizer>%s</normalizer>" EOL, st->normalizer_str);
+                       rspamd_fprintf (f, " <statfile>" EOL);
+                       rspamd_fprintf (f, "  <symbol>%s</symbol>" EOL "  <size>%z</size>" EOL "  <path>%s</path>" EOL,
+                                               st->symbol, st->size, st->path);
+                       rspamd_fprintf (f, "  <normalizer>%s</normalizer>" EOL, st->normalizer_str);
                        /* Binlog */
                        if (st->binlog) {
                                if (st->binlog->affinity == AFFINITY_MASTER) {
-                                       fprintf (f, "  <binlog>master</binlog>" EOL);
+                                       rspamd_fprintf (f, "  <binlog>master</binlog>" EOL);
                                }
                                else if (st->binlog->affinity == AFFINITY_SLAVE) {
-                                       fprintf (f, "  <binlog>slave</binlog>" EOL);
-                                       fprintf (f, "  <binlog_master>%s:%d</binlog_master>" EOL, 
-                                                       inet_ntoa (st->binlog->master_addr), ntohs (st->binlog->master_port)); 
+                                       rspamd_fprintf (f, "  <binlog>slave</binlog>" EOL);
+                                       rspamd_fprintf (f, "  <binlog_master>%s:%d</binlog_master>" EOL, 
+                                                       inet_ntoa (st->binlog->master_addr), (gint)ntohs (st->binlog->master_port)); 
                                }
-                               fprintf (f, "  <binlog_rotate>%lu</binlog_rotate>" EOL, (long unsigned)st->binlog->rotate_time);
+                               rspamd_fprintf (f, "  <binlog_rotate>%T</binlog_rotate>" EOL, st->binlog->rotate_time);
                        }
-                       fprintf (f, " </statfile>" EOL);
+                       rspamd_fprintf (f, " </statfile>" EOL);
                        cur_st = g_list_next (cur_st);
                }
 
-               fprintf (f, "</classifier>" EOL);
+               rspamd_fprintf (f, "</classifier>" EOL);
                cur = g_list_next (cur);
        }
 
        /* Print footer comment */
-       fprintf (f, "<!-- End of classifiers section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of classifiers section -->" EOL EOL);
 
        return TRUE;
 
@@ -1955,42 +1955,42 @@ xml_dump_logging (struct config_file *cfg, FILE *f)
        gchar *escaped_value;
 
        /* Print header comment */
-       fprintf (f, "<!-- Logging section -->" EOL);
-       fprintf (f, "<logging>" EOL);
+       rspamd_fprintf (f, "<!-- Logging section -->" EOL);
+       rspamd_fprintf (f, "<logging>" EOL);
        
        /* Level */
        if (cfg->log_level < G_LOG_LEVEL_WARNING) {
-               fprintf (f, " <level>error</level>" EOL);
+               rspamd_fprintf (f, " <level>error</level>" EOL);
        }
        else if (cfg->log_level < G_LOG_LEVEL_MESSAGE) {
-               fprintf (f, " <level>warning</level>" EOL);
+               rspamd_fprintf (f, " <level>warning</level>" EOL);
        }
        else if (cfg->log_level < G_LOG_LEVEL_DEBUG) {
-               fprintf (f, " <level>info</level>" EOL);
+               rspamd_fprintf (f, " <level>info</level>" EOL);
        }
        else {
-               fprintf (f, " <level>debug</level>" EOL);
+               rspamd_fprintf (f, " <level>debug</level>" EOL);
        }
        
        /* Other options */
-       fprintf (f, " <log_urls>%s</log_urls>" EOL, cfg->log_urls ? "yes" : "no");
+       rspamd_fprintf (f, " <log_urls>%s</log_urls>" EOL, cfg->log_urls ? "yes" : "no");
        if (cfg->log_buf_size != 0) {
-               fprintf (f, " <log_buffer>%ud</log_buffer>" EOL, (unsigned)cfg->log_buf_size);
+               rspamd_fprintf (f, " <log_buffer>%ud</log_buffer>" EOL, (guint)cfg->log_buf_size);
        }
        if (cfg->debug_ip_map != NULL) {
                escaped_value = g_markup_escape_text (cfg->debug_ip_map, -1);
-               fprintf (f, " <debug_ip>%s</debug_ip>" EOL, escaped_value);
+               rspamd_fprintf (f, " <debug_ip>%s</debug_ip>" EOL, escaped_value);
                g_free (escaped_value);
        }
        
        /* Handle type */
        if (cfg->log_type == RSPAMD_LOG_FILE) {
                escaped_value = g_markup_escape_text (cfg->log_file, -1);
-               fprintf (f, " <type filename=\"%s\">file</type>" EOL, escaped_value);
+               rspamd_fprintf (f, " <type filename=\"%s\">file</type>" EOL, escaped_value);
                g_free (escaped_value);
        }
        else if (cfg->log_type == RSPAMD_LOG_CONSOLE) {
-               fprintf (f, " <type>console</type>" EOL);
+               rspamd_fprintf (f, " <type>console</type>" EOL);
        }
        else if (cfg->log_type == RSPAMD_LOG_SYSLOG) {
                escaped_value = NULL;
@@ -2035,11 +2035,11 @@ xml_dump_logging (struct config_file *cfg, FILE *f)
                                escaped_value = "LOG_LOCAL7";
                                break;
                }
-               fprintf (f, " <type facility=\"%s\">syslog</type>" EOL, escaped_value);
+               rspamd_fprintf (f, " <type facility=\"%s\">syslog</type>" EOL, escaped_value);
        }
-       fprintf (f, "</logging>" EOL);
+       rspamd_fprintf (f, "</logging>" EOL);
        /* Print footer comment */
-       fprintf (f, "<!-- End of logging section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of logging section -->" EOL EOL);
 
        return TRUE;
 }
@@ -2053,21 +2053,21 @@ xml_dump_modules_paths (struct config_file *cfg, FILE *f)
        struct script_module           *module;
 
        /* Print header comment */
-       fprintf (f, "<!-- Modules section -->" EOL);
-       fprintf (f, "<modules>" EOL);
+       rspamd_fprintf (f, "<!-- Modules section -->" EOL);
+       rspamd_fprintf (f, "<modules>" EOL);
 
        cur = cfg->script_modules;
        while (cur) {
                module = cur->data;
                escaped_value = g_markup_escape_text (module->path, -1);
-               fprintf (f, " <path>%s</path>" EOL, escaped_value);
+               rspamd_fprintf (f, " <path>%s</path>" EOL, escaped_value);
                g_free (escaped_value);
                cur = g_list_next (cur);
        }
 
-       fprintf (f, "</modules>" EOL);
+       rspamd_fprintf (f, "</modules>" EOL);
        /* Print footer comment */
-       fprintf (f, "<!-- End of modules section -->" EOL EOL);
+       rspamd_fprintf (f, "<!-- End of modules section -->" EOL EOL);
 
        return TRUE;
 }
@@ -2075,7 +2075,7 @@ xml_dump_modules_paths (struct config_file *cfg, FILE *f)
 
 #define CHECK_RES do { if (!res) { fclose (f); return FALSE; } } while (0)
 gboolean 
-xml_dump_config (struct config_file *cfg, const char *filename)
+xml_dump_config (struct config_file *cfg, const gchar *filename)
 {
        FILE *f;
        gboolean res = FALSE;
@@ -2087,7 +2087,7 @@ xml_dump_config (struct config_file *cfg, const char *filename)
        }
        
        /* Header */
-       fprintf (f, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" EOL "<rspamd>" EOL);
+       rspamd_fprintf (f, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" EOL "<rspamd>" EOL);
        /* Now dump all parts of config */
        res = xml_dump_main (cfg, f);
        CHECK_RES;
@@ -2106,7 +2106,7 @@ xml_dump_config (struct config_file *cfg, const char *filename)
        res = xml_dump_modules_paths (cfg, f);
        CHECK_RES;
        /* Footer */
-       fprintf (f, "</rspamd>" EOL);
+       rspamd_fprintf (f, "</rspamd>" EOL);
        fclose (f);
 
        return TRUE;
index a72eb46f4f168a49ad8b5eb679a0312611022855..456d37fa8e0349e1340d57008416714f86b3bd6e 100644 (file)
@@ -38,7 +38,7 @@ struct rspamd_xml_userdata {
 };
 
 /* Text is NULL terminated here */
-typedef gboolean (*element_handler_func) (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+typedef gboolean (*element_handler_func) (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
 /* Callbacks */
 
@@ -73,58 +73,58 @@ void rspamd_xml_error       (GMarkupParseContext            *context,
 
 /* Handlers */
 /* Basic xml parsing functions */
-gboolean xml_handle_string (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean xml_handle_string_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean xml_handle_string (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean xml_handle_string_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
 /* Numeric params */
-gboolean xml_handle_size (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean xml_handle_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean xml_handle_seconds (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean xml_handle_int (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean xml_handle_uint32 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean xml_handle_uint16 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean xml_handle_size (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean xml_handle_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean xml_handle_seconds (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean xml_handle_int (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean xml_handle_uint32 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean xml_handle_uint16 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
 /* Flags */
-gboolean xml_handle_boolean (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean xml_handle_boolean (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
 /* Specific params */
-gboolean worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_log_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_log_level (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_log_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_log_level (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_lua (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_lua (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_module_path (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_module_path (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_variable (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_composite (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_variable (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_composite (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_view_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_view_client_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_view_from (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_view_rcpt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_view_symbols (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_view_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_view_client_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_view_from (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_view_rcpt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_view_symbols (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_user_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_domain_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_user_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_domain_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_classifier_tokenizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_classifier_tokenizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
-gboolean handle_statfile_normalizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_statfile_binlog (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_statfile_binlog_rotate (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
-gboolean handle_statfile_binlog_master (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset);
+gboolean handle_statfile_normalizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_statfile_binlog (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_statfile_binlog_rotate (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
+gboolean handle_statfile_binlog_master (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset);
 
 /* Dumper functions */
-gboolean xml_dump_config (struct config_file *cfg, const char *filename);
+gboolean xml_dump_config (struct config_file *cfg, const gchar *filename);
 
 #endif
index 2f14735404c93a73fe83447b7cd7f731dba4034b..9f274bc65a37e8c182594ab47e701ecf84a08618 100644 (file)
@@ -55,13 +55,13 @@ enum command_type {
 };
 
 struct controller_command {
-       char                           *command;
+       gchar                           *command;
        gboolean                        privilleged;
        enum command_type               type;
 };
 
 struct custom_controller_command {
-       const char                     *command;
+       const gchar                     *command;
        gboolean                        privilleged;
        gboolean                        require_message;
        controller_func_t               handler;
@@ -86,7 +86,7 @@ static GList                   *custom_commands = NULL;
 static GCompletion             *comp;
 static time_t                   start_time;
 
-static char                     greetingbuf[1024];
+static gchar                     greetingbuf[1024];
 static sig_atomic_t             wanna_die = 0;
 extern rspamd_hash_t           *counters;
 
@@ -94,10 +94,10 @@ static gboolean                 controller_write_socket (void *arg);
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        struct timeval                  tv;
@@ -122,7 +122,7 @@ sig_handler (int signo, siginfo_t *info, void *unused)
 }
 
 static void
-sigusr_handler (int fd, short what, void *arg)
+sigusr_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -167,11 +167,11 @@ free_session (void *ud)
        g_free (session);
 }
 
-static int
+static gint
 check_auth (struct controller_command *cmd, struct controller_session *session)
 {
-       char                            out_buf[128];
-       int                             r;
+       gchar                           out_buf[128];
+       gint                            r;
 
        if (cmd->privilleged && !session->authorized) {
                r = rspamd_snprintf (out_buf, sizeof (out_buf), "not authorized" CRLF);
@@ -189,25 +189,25 @@ counter_write_callback (gpointer key, gpointer value, void *data)
 {
        struct controller_session      *session = data;
        struct counter_data            *cd = value;
-       char                           *name = key;
-       char                            out_buf[128];
-       int                             r;
+       gchar                           *name = key;
+       gchar                           out_buf[128];
+       gint                            r;
 
-       r = rspamd_snprintf (out_buf, sizeof (out_buf), "%s: %ul" CRLF, name, (unsigned long int)cd->value);
+       r = rspamd_snprintf (out_buf, sizeof (out_buf), "%s: %uD" CRLF, name, (guint32)cd->value);
        if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, TRUE, FALSE)) {
                msg_warn ("cannot write to socket");
        }
 }
 
 static gboolean
-write_whole_statfile (struct controller_session *session, char *symbol, struct classifier_config *ccf)
+write_whole_statfile (struct controller_session *session, gchar *symbol, struct classifier_config *ccf)
 {
        stat_file_t                    *statfile;
        struct statfile                *st;
-       char                            out_buf[BUFSIZ];
-       int                             i;
-       uint64_t                        rev, ti, len, pos;
-       char                           *out;
+       gchar                           out_buf[BUFSIZ];
+       gint                            i;
+       guint64                         rev, ti, len, pos;
+       gchar                           *out;
        struct rspamd_binlog_element    log_elt;
        struct stat_file_block         *stat_elt;
 
@@ -253,11 +253,11 @@ write_whole_statfile (struct controller_session *session, char *symbol, struct c
 }
 
 static gboolean
-process_sync_command (struct controller_session *session, char **args)
+process_sync_command (struct controller_session *session, gchar **args)
 {
-       char                            out_buf[BUFSIZ], *arg, *err_str, *symbol;
-       int                             r;
-       uint64_t                        rev, time;
+       gchar                           out_buf[BUFSIZ], *arg, *err_str, *symbol;
+       gint                            r;
+       guint64                         rev, time;
        struct statfile                *st;
        struct classifier_config       *ccf;
        GList                          *cur;
@@ -318,7 +318,7 @@ process_sync_command (struct controller_session *session, char **args)
        }
        
        while (binlog_sync (binlog, rev, &time, &data)) {
-               r = rspamd_snprintf (out_buf, sizeof (out_buf), "%ul %ul %ul" CRLF, (long unsigned)rev, (long unsigned)time, (long unsigned)data->len);
+               r = rspamd_snprintf (out_buf, sizeof (out_buf), "%uL %uL %z" CRLF, rev, time, data->len);
                if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) {
                        if (data != NULL) {
                                g_free (data);
@@ -353,9 +353,9 @@ process_sync_command (struct controller_session *session, char **args)
 static gboolean
 process_stat_command (struct controller_session *session)
 {
-       char                            out_buf[BUFSIZ], *numbuf;
-       int                             r;
-       uint64_t                        used, total, rev;
+       gchar                           out_buf[BUFSIZ], *numbuf;
+       gint                            r;
+       guint64                         used, total, rev;
        time_t                          ti;
        memory_pool_stat_t              mem_st;
        struct classifier_config       *ccf;
@@ -374,13 +374,13 @@ process_stat_command (struct controller_session *session)
        r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Messages learned: %ud" CRLF, session->worker->srv->stat->messages_learned);
        r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Connections count: %ud" CRLF, session->worker->srv->stat->connections_count);
        r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Control connections count: %ud" CRLF, session->worker->srv->stat->control_connections_count);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Pools allocated: %l" CRLF, (long int)mem_st.pools_allocated);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Pools freed: %l" CRLF, (long int)mem_st.pools_freed);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Bytes allocated: %l" CRLF, (long int)mem_st.bytes_allocated);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Memory chunks allocated: %l" CRLF, (long int)mem_st.chunks_allocated);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Shared chunks allocated: %l" CRLF, (long int)mem_st.shared_chunks_allocated);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Chunks freed: %l" CRLF, (long int)mem_st.chunks_freed);
-       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Oversized chunks: %l" CRLF, (long int)mem_st.oversized_chunks);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Pools allocated: %z" CRLF, mem_st.pools_allocated);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Pools freed: %z" CRLF, mem_st.pools_freed);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Bytes allocated: %z" CRLF, mem_st.bytes_allocated);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Memory chunks allocated: %z" CRLF, mem_st.chunks_allocated);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Shared chunks allocated: %z" CRLF, mem_st.shared_chunks_allocated);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Chunks freed: %z" CRLF, mem_st.chunks_freed);
+       r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Oversized chunks: %z" CRLF, mem_st.oversized_chunks);
        r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Fuzzy hashes stored: %ud" CRLF, session->worker->srv->stat->fuzzy_hashes);
        r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, "Fuzzy hashes expired: %ud" CRLF, session->worker->srv->stat->fuzzy_hashes_expired);
        /* Now write statistics for each statfile */
@@ -397,12 +397,12 @@ process_stat_command (struct controller_session *session)
                                used = statfile_get_used_blocks (statfile);
                                total = statfile_get_total_blocks (statfile);
                                statfile_get_revision (statfile, &rev, &ti);
-                               if (total != (uint64_t)-1 && used != (uint64_t)-1) {
+                               if (total != (guint64)-1 && used != (guint64)-1) {
                                        numbuf = g_format_size_for_display (st->size);
                                        r += rspamd_snprintf (out_buf + r, sizeof (out_buf) - r, 
-                                                       "Statfile: %s (version %ul); length: %s; free blocks: %ul; total blocks: %ul; free: %.2f%%" CRLF,
-                                                       st->symbol, (long unsigned)rev, numbuf, 
-                                                       (long unsigned)(total - used), (long unsigned)total,
+                                                       "Statfile: %s (version %uL); length: %s; free blocks: %uL; total blocks: %uL; free: %.2f%%" CRLF,
+                                                       st->symbol, rev, numbuf, 
+                                                       (total - used), total,
                                                        (double)((double)(total - used) / (double)total) * 100.);
                                        g_free (numbuf);
                                }
@@ -416,14 +416,14 @@ process_stat_command (struct controller_session *session)
 }
 
 static gboolean
-process_command (struct controller_command *cmd, char **cmd_args, struct controller_session *session)
+process_command (struct controller_command *cmd, gchar **cmd_args, struct controller_session *session)
 {
-       char                            out_buf[BUFSIZ], *arg, *err_str;
-       int                             r = 0, days, hours, minutes;
+       gchar                           out_buf[BUFSIZ], *arg, *err_str;
+       gint                            r = 0, days, hours, minutes;
        time_t                          uptime;
-       unsigned long                   size = 0;
+       guint32                   size = 0;
        struct classifier_config       *cl;
-       char                           *password = g_hash_table_lookup (session->worker->cf->params, "password");
+       gchar                           *password = g_hash_table_lookup (session->worker->cf->params, "password");
 
        switch (cmd->type) {
        case COMMAND_PASSWORD:
@@ -496,14 +496,14 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control
                        }
                        /* If uptime is less than 1 minute print only seconds */
                        else if (uptime / 60 == 0) {
-                               r = rspamd_snprintf (out_buf, sizeof (out_buf), "%d second%s" CRLF, (int)uptime, (int)uptime > 1 ? "s" : " ");
+                               r = rspamd_snprintf (out_buf, sizeof (out_buf), "%d second%s" CRLF, (gint)uptime, (gint)uptime > 1 ? "s" : " ");
                        }
                        /* Else print the minutes and seconds. */
                        else {
                                hours = uptime / 3600;
                                minutes = uptime / 60 - hours * 60;
                                uptime -= hours * 3600 + minutes * 60;
-                               r = rspamd_snprintf (out_buf, sizeof (out_buf), "%d hour%s %d minute%s %d second%s" CRLF, hours, hours > 1 ? "s" : " ", minutes, minutes > 1 ? "s" : " ", (int)uptime, uptime > 1 ? "s" : " ");
+                               r = rspamd_snprintf (out_buf, sizeof (out_buf), "%d hour%s %d minute%s %d second%s" CRLF, hours, hours > 1 ? "s" : " ", minutes, minutes > 1 ? "s" : " ", (gint)uptime, uptime > 1 ? "s" : " ");
                        }
                        if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) {
                                return FALSE;
@@ -691,7 +691,7 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control
 }
 
 static                          gboolean
-process_custom_command (char *line, char **cmd_args, struct controller_session *session)
+process_custom_command (gchar *line, gchar **cmd_args, struct controller_session *session)
 {
        GList                          *cur;
        struct custom_controller_command *cmd;
@@ -717,8 +717,8 @@ controller_read_socket (f_str_t * in, void *arg)
        struct classifier_ctx          *cls_ctx;
        stat_file_t                    *statfile;
        struct statfile                *st;
-       int                             len, i, r;
-       char                           *s, **params, *cmd, out_buf[128];
+       gint                            len, i, r;
+       gchar                           *s, **params, *cmd, out_buf[128];
        struct worker_task             *task;
        struct mime_text_part          *part;
        GList                          *comp_list, *cur = NULL;
@@ -1013,14 +1013,14 @@ controller_err_socket (GError * err, void *arg)
 }
 
 static void
-accept_socket (int fd, short what, void *arg)
+accept_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        struct sockaddr_storage         ss;
        struct controller_session      *new_session;
        struct timeval                 *io_tv;
        socklen_t                       addrlen = sizeof (ss);
-       int                             nfd;
+       gint                            nfd;
 
        if ((nfd = accept_from_socket (fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
                msg_warn ("accept failed: %s", strerror (errno));
@@ -1057,10 +1057,10 @@ void
 start_controller (struct rspamd_worker *worker)
 {
        struct sigaction                signals;
-       int                             i;
+       gint                            i;
        GList                          *comp_list = NULL;
-       char                           *hostbuf;
-       long int                        hostmax;
+       gchar                          *hostbuf;
+       gsize                           hostmax;
 
        worker->srv->pid = getpid ();
        event_init ();
@@ -1106,7 +1106,7 @@ start_controller (struct rspamd_worker *worker)
 }
 
 void
-register_custom_controller_command (const char *name, controller_func_t handler, gboolean privilleged, gboolean require_message)
+register_custom_controller_command (const gchar *name, controller_func_t handler, gboolean privilleged, gboolean require_message)
 {
        struct custom_controller_command *cmd;
 
index c50b9f3883cf7ae141204ee28ea85ef00c83d2e3..57c9550052a2585e9b4e42cfec3c2d312778d981 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
 #define DNS_K_TEA_CYCLES       32
 #define DNS_K_TEA_MAGIC                0x9E3779B9U
 
-static void dns_retransmit_handler (int fd, short what, void *arg);
+static void dns_retransmit_handler (gint fd, short what, void *arg);
 
 
 static void 
-dns_k_tea_init(struct dns_k_tea *tea, uint32_t key[], unsigned cycles) 
+dns_k_tea_init(struct dns_k_tea *tea, guint32 key[], guint cycles) 
 {
        memcpy(tea->key, key, sizeof tea->key);
 
@@ -72,7 +72,7 @@ dns_k_tea_init(struct dns_k_tea *tea, uint32_t key[], unsigned cycles)
 
 
 static void 
-dns_k_tea_encrypt (struct dns_k_tea *tea, uint32_t v[], uint32_t *w) 
+dns_k_tea_encrypt (struct dns_k_tea *tea, guint32 v[], guint32 *w) 
 {
        guint32 y, z, sum, n;
 
@@ -113,10 +113,10 @@ dns_k_tea_encrypt (struct dns_k_tea *tea, uint32_t v[], uint32_t *w)
 
 
 
-static inline unsigned int
-dns_k_permutor_powof (unsigned int n) 
+static inline guint
+dns_k_permutor_powof (guint n) 
 {
-       unsigned int m, i = 0;
+       guint                           m, i = 0;
 
        for (m = 1; m < n; m <<= 1, i++);
 
@@ -124,10 +124,10 @@ dns_k_permutor_powof (unsigned int n)
 } /* dns_k_permutor_powof() */
 
 static void 
-dns_k_permutor_init (struct dns_k_permutor *p, unsigned low, unsigned high) 
+dns_k_permutor_init (struct dns_k_permutor *p, guint low, guint high) 
 {
-       uint32_t key[DNS_K_TEA_KEY_SIZE / sizeof (uint32_t)];
-       unsigned width, i;
+       guint32                         key[DNS_K_TEA_KEY_SIZE / sizeof (guint32)];
+       guint width, i;
 
        p->stepi        = 0;
 
@@ -150,10 +150,10 @@ dns_k_permutor_init (struct dns_k_permutor *p, unsigned low, unsigned high)
 } /* dns_k_permutor_init() */
 
 
-static unsigned 
-dns_k_permutor_F (struct dns_k_permutor *p, unsigned k, unsigned x) 
+static guint 
+dns_k_permutor_F (struct dns_k_permutor *p, guint k, guint x) 
 {
-       uint32_t in[DNS_K_TEA_BLOCK_SIZE / sizeof (uint32_t)], out[DNS_K_TEA_BLOCK_SIZE / sizeof (uint32_t)];
+       guint32                         in[DNS_K_TEA_BLOCK_SIZE / sizeof (guint32)], out[DNS_K_TEA_BLOCK_SIZE / sizeof (guint32)];
 
        memset(in, '\0', sizeof in);
 
@@ -166,11 +166,11 @@ dns_k_permutor_F (struct dns_k_permutor *p, unsigned k, unsigned x)
 } /* dns_k_permutor_F() */
 
 
-static unsigned 
-dns_k_permutor_E (struct dns_k_permutor *p, unsigned n) 
+static guint 
+dns_k_permutor_E (struct dns_k_permutor *p, guint n) 
 {
-       unsigned l[2], r[2];
-       unsigned i;
+       guint l[2], r[2];
+       guint i;
 
        i       = 0;
        l[i]    = p->mask & (n >> p->shift);
@@ -187,11 +187,11 @@ dns_k_permutor_E (struct dns_k_permutor *p, unsigned n)
 } /* dns_k_permutor_E() */
 
 
-static unsigned 
-dns_k_permutor_D (struct dns_k_permutor *p, unsigned n) 
+static guint 
+dns_k_permutor_D (struct dns_k_permutor *p, guint n) 
 {
-       unsigned l[2], r[2];
-       unsigned i;
+       guint l[2], r[2];
+       guint i;
 
        i               = p->rounds - 1;
        l[i % 2]        = p->mask & (n >> p->shift);
@@ -208,10 +208,10 @@ dns_k_permutor_D (struct dns_k_permutor *p, unsigned n)
 } /* dns_k_permutor_D() */
 
 
-static unsigned 
+static guint 
 dns_k_permutor_step(struct dns_k_permutor *p) 
 {
-       unsigned n;
+       guint n;
 
        do {
                n       = dns_k_permutor_E(p, p->stepi++);
@@ -225,10 +225,10 @@ dns_k_permutor_step(struct dns_k_permutor *p)
  * Simple permutation box. Useful for shuffling rrsets from an iterator.
  * Uses AES s-box to provide good diffusion.
  */
-static unsigned short 
-dns_k_shuffle16 (unsigned short n, unsigned s) 
+static guint16 
+dns_k_shuffle16 (guint16 n, guint s) 
 {
-       static const unsigned char sbox[256] =
+       static const guint8 sbox[256] =
        { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
          0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
          0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
@@ -261,8 +261,8 @@ dns_k_shuffle16 (unsigned short n, unsigned s)
          0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
          0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
          0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 };
-       unsigned char a, b;
-       unsigned i;
+       guchar                          a, b;
+       guint                           i;
 
        a = 0xff & (n >> 0);
        b = 0xff & (n >> 8);
@@ -347,7 +347,7 @@ make_dns_header (struct rspamd_dns_request *req)
 }
 
 static void
-format_dns_name (struct rspamd_dns_request *req, const char *name, guint namelen)
+format_dns_name (struct rspamd_dns_request *req, const gchar *name, guint namelen)
 {
        guint8 *pos = req->packet + req->pos, *end, *dot, *begin;
        guint remain = req->packet_len - req->pos - 5, label_len;
@@ -425,15 +425,15 @@ format_dns_name (struct rspamd_dns_request *req, const char *name, guint namelen
 static void
 make_ptr_req (struct rspamd_dns_request *req, struct in_addr addr)
 {
-       char ipbuf[sizeof("255.255.255.255.in-addr.arpa")];
+       gchar                           ipbuf[sizeof("255.255.255.255.in-addr.arpa")];
        guint32 a = ntohl (addr.s_addr), r;
        guint16 *p;
 
        r = rspamd_snprintf (ipbuf, sizeof(ipbuf), "%d.%d.%d.%d.in-addr.arpa",
-                       (int)(guint8)((a        ) & 0xff),
-                       (int)(guint8)((a>>8 ) & 0xff),
-                       (int)(guint8)((a>>16) & 0xff),
-                       (int)(guint8)((a>>24) & 0xff));
+                       (gint)(guint8)((a       ) & 0xff),
+                       (gint)(guint8)((a>>8 ) & 0xff),
+                       (gint)(guint8)((a>>16) & 0xff),
+                       (gint)(guint8)((a>>24) & 0xff));
        
        allocate_packet (req, r);
        make_dns_header (req);
@@ -447,7 +447,7 @@ make_ptr_req (struct rspamd_dns_request *req, struct in_addr addr)
 }
 
 static void
-make_a_req (struct rspamd_dns_request *req, const char *name)
+make_a_req (struct rspamd_dns_request *req, const gchar *name)
 {
        guint16 *p;
 
@@ -463,7 +463,7 @@ make_a_req (struct rspamd_dns_request *req, const char *name)
 }
 
 static void
-make_txt_req (struct rspamd_dns_request *req, const char *name)
+make_txt_req (struct rspamd_dns_request *req, const gchar *name)
 {
        guint16 *p;
 
@@ -479,7 +479,7 @@ make_txt_req (struct rspamd_dns_request *req, const char *name)
 }
 
 static void
-make_mx_req (struct rspamd_dns_request *req, const char *name)
+make_mx_req (struct rspamd_dns_request *req, const gchar *name)
 {
        guint16 *p;
 
@@ -495,7 +495,7 @@ make_mx_req (struct rspamd_dns_request *req, const char *name)
 }
 
 static void
-make_srv_req (struct rspamd_dns_request *req, const char *service, const char *proto, const char *name)
+make_srv_req (struct rspamd_dns_request *req, const gchar *service, const gchar *proto, const gchar *name)
 {
        guint16 *p;
        guint len;
@@ -517,7 +517,7 @@ make_srv_req (struct rspamd_dns_request *req, const char *service, const char *p
 }
 
 static void
-make_spf_req (struct rspamd_dns_request *req, const char *name)
+make_spf_req (struct rspamd_dns_request *req, const gchar *name)
 {
        guint16 *p;
 
@@ -532,7 +532,7 @@ make_spf_req (struct rspamd_dns_request *req, const char *name)
        req->requested_name = name;
 }
 
-static int
+static gint
 send_dns_request (struct rspamd_dns_request *req)
 {
        gint r;
@@ -584,7 +584,7 @@ decompress_label (guint8 *begin, guint16 *len, guint16 max)
 }
 
 static guint8 *
-dns_request_reply_cmp (struct rspamd_dns_request *req, guint8 *in, int len)
+dns_request_reply_cmp (struct rspamd_dns_request *req, guint8 *in, gint len)
 {
        guint8 *p, *c, *l1, *l2;
        guint16 len1, len2;
@@ -666,7 +666,7 @@ dns_request_reply_cmp (struct rspamd_dns_request *req, guint8 *in, int len)
 #define MAX_RECURSION_LEVEL 10
 
 static gboolean
-dns_parse_labels (guint8 *in, char **target, guint8 **pos, struct rspamd_dns_reply *rep, int *remain, gboolean make_name)
+dns_parse_labels (guint8 *in, gchar **target, guint8 **pos, struct rspamd_dns_reply *rep, gint *remain, gboolean make_name)
 {
        guint16 namelen = 0;
        guint8 *p = *pos, *begin = *pos, *l, *t, *end = *pos + *remain;
@@ -760,7 +760,7 @@ end:
 #define GET32(x) do {if (*remain < sizeof (guint32)) {goto err;} memcpy (&(x), p, sizeof (guint32)); (x) = ntohl ((x)); p += sizeof (guint32); *remain -= sizeof (guint32); } while(0)
 
 static gint
-dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct rspamd_dns_reply *rep, int *remain)
+dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct rspamd_dns_reply *rep, gint *remain)
 {
        guint8 *p = *pos, parts;
        guint16 type, datalen, txtlen, copied;
@@ -897,19 +897,19 @@ dns_parse_rr (guint8 *in, union rspamd_reply_element *elt, guint8 **pos, struct
        return 0;
 
 err:
-       msg_info ("incomplete RR, only %d bytes remain, packet length %d", (int)*remain, (int)(*pos - in));
+       msg_info ("incomplete RR, only %d bytes remain, packet length %d", (gint)*remain, (gint)(*pos - in));
        return -1;
 }
 
 static struct rspamd_dns_reply *
-dns_parse_reply (guint8 *in, int r, struct rspamd_dns_resolver *resolver, struct rspamd_dns_request **req_out)
+dns_parse_reply (guint8 *in, gint r, struct rspamd_dns_resolver *resolver, struct rspamd_dns_request **req_out)
 {
        struct dns_header *header = (struct dns_header *)in;
        struct rspamd_dns_request *req;
        struct rspamd_dns_reply *rep;
        union rspamd_reply_element *elt;
        guint8 *pos;
-       int i, t;
+       gint                            i, t;
        
        /* First check header fields */
        if (header->qr == 0) {
@@ -961,11 +961,11 @@ dns_parse_reply (guint8 *in, int r, struct rspamd_dns_resolver *resolver, struct
 }
 
 static void
-dns_read_cb (int fd, short what, void *arg)
+dns_read_cb (gint fd, short what, void *arg)
 {
        struct rspamd_dns_resolver *resolver = arg;
        struct rspamd_dns_request *req = NULL;
-       int r;
+       gint                            r;
        struct rspamd_dns_reply *rep;
        guint8 in[UDP_PACKET_SIZE];
 
@@ -982,11 +982,11 @@ dns_read_cb (int fd, short what, void *arg)
 }
 
 static void
-dns_timer_cb (int fd, short what, void *arg)
+dns_timer_cb (gint fd, short what, void *arg)
 {
        struct rspamd_dns_request *req = arg;
        struct rspamd_dns_reply *rep;
-       int r;
+       gint                            r;
        
        /* Retransmit dns request */
        req->retransmits ++;
@@ -1045,7 +1045,7 @@ dns_timer_cb (int fd, short what, void *arg)
 }
 
 static void
-dns_retransmit_handler (int fd, short what, void *arg)
+dns_retransmit_handler (gint fd, short what, void *arg)
 {
        struct rspamd_dns_request *req = arg;
        struct rspamd_dns_reply *rep;
@@ -1095,7 +1095,7 @@ make_dns_request (struct rspamd_dns_resolver *resolver,
        va_list args;
        struct rspamd_dns_request *req;
        struct in_addr addr;
-       const char *name, *service, *proto;
+       const gchar *name, *service, *proto;
        gint r;
 
        req = memory_pool_alloc (pool, sizeof (struct rspamd_dns_request));
@@ -1113,25 +1113,25 @@ make_dns_request (struct rspamd_dns_resolver *resolver,
                        make_ptr_req (req, addr);
                        break;
                case DNS_REQUEST_MX:
-                       name = va_arg (args, const char *);
+                       name = va_arg (args, const gchar *);
                        make_mx_req (req, name);
                        break;
                case DNS_REQUEST_A:
-                       name = va_arg (args, const char *);
+                       name = va_arg (args, const gchar *);
                        make_a_req (req, name);
                        break;
                case DNS_REQUEST_TXT:
-                       name = va_arg (args, const char *);
+                       name = va_arg (args, const gchar *);
                        make_txt_req (req, name);
                        break;
                case DNS_REQUEST_SPF:
-                       name = va_arg (args, const char *);
+                       name = va_arg (args, const gchar *);
                        make_spf_req (req, name);
                        break;
                case DNS_REQUEST_SRV:
-                       service = va_arg (args, const char *);
-                       proto = va_arg (args, const char *);
-                       name = va_arg (args, const char *);
+                       service = va_arg (args, const gchar *);
+                       proto = va_arg (args, const gchar *);
+                       name = va_arg (args, const gchar *);
                        make_srv_req (req, service, proto, name);
                        break;
        }
@@ -1186,7 +1186,7 @@ static gboolean
 parse_resolv_conf (struct rspamd_dns_resolver *resolver)
 {
        FILE *r;
-       char buf[BUFSIZ], *p;
+       gchar                           buf[BUFSIZ], *p;
        struct rspamd_dns_server *new;
        struct in_addr addr;
 
@@ -1234,8 +1234,8 @@ dns_resolver_init (struct config_file *cfg)
 {
        GList *cur;
        struct rspamd_dns_resolver *new;
-       char *begin, *p;
-       int priority, i;
+       gchar                           *begin, *p;
+       gint                            priority, i;
        struct rspamd_dns_server *serv;
        
        new = memory_pool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_dns_resolver));
@@ -1305,7 +1305,7 @@ dns_resolver_init (struct config_file *cfg)
        return new;
 }
 
-static char dns_rcodes[16][16] = {
+static gchar dns_rcodes[16][16] = {
        [DNS_RC_NOERROR]  = "NOERROR",
        [DNS_RC_FORMERR]  = "FORMERR",
        [DNS_RC_SERVFAIL] = "SERVFAIL",
@@ -1319,20 +1319,20 @@ static char dns_rcodes[16][16] = {
        [DNS_RC_NOTZONE]  = "NOTZONE",
 };
 
-const char *
+const gchar *
 dns_strerror (enum dns_rcode rcode)
 {
        rcode &= 0xf;
-       static char numbuf[16];
+       static gchar numbuf[16];
 
        if ('\0' == dns_rcodes[rcode][0]) {
-               rspamd_snprintf (numbuf, sizeof (numbuf), "UNKNOWN: %d", (int)rcode);
+               rspamd_snprintf (numbuf, sizeof (numbuf), "UNKNOWN: %d", (gint)rcode);
                return numbuf;
        }
        return dns_rcodes[rcode];
 }
 
-static char dns_types[6][16] = {
+static gchar dns_types[6][16] = {
                [DNS_REQUEST_A] = "A request",
                [DNS_REQUEST_PTR] = "PTR request",
                [DNS_REQUEST_MX] = "MX request",
@@ -1341,7 +1341,7 @@ static char dns_types[6][16] = {
                [DNS_REQUEST_SPF] = "SPF request"
 };
 
-const char *
+const gchar *
 dns_strtype (enum rspamd_request_type type)
 {
        return dns_types[type];
index c0a79a6b04792852bcbb2404bbd96b3d8025f360..57877748b100848d5eafc24ff895f3a651550a81 100644 (file)
--- a/src/dns.h
+++ b/src/dns.h
@@ -23,21 +23,21 @@ typedef void (*dns_callback_type) (struct rspamd_dns_reply *reply, gpointer arg)
 struct rspamd_dns_server {
        struct upstream up;                                     /**< upstream structure                                         */
        struct in_addr addr;                            /**< address of DNS server                                      */
-       char *name;                                                     /**< name of DNS server                                         */
-       int sock;                                                       /**< persistent socket                                          */
+       gchar *name;                                                    /**< name of DNS server                                         */
+       gint sock;                                                      /**< persistent socket                                          */
        struct event ev;
 };
 
 #define DNS_K_TEA_KEY_SIZE     16
 
 struct dns_k_tea {
-       uint32_t key[DNS_K_TEA_KEY_SIZE / sizeof (uint32_t)];
-       unsigned cycles;
+       guint32 key[DNS_K_TEA_KEY_SIZE / sizeof (guint32)];
+       guint cycles;
 }; /* struct dns_k_tea */
 
 struct dns_k_permutor {
-       unsigned stepi, length, limit;
-       unsigned shift, mask, rounds;
+       guint stepi, length, limit;
+       guint shift, mask, rounds;
 
        struct dns_k_tea tea;
 };
@@ -78,10 +78,10 @@ struct rspamd_dns_request {
        struct rspamd_async_session *session;
        struct rspamd_dns_reply *reply;
        guint8 *packet;
-       const char *requested_name;
+       const gchar *requested_name;
        off_t pos;
        guint packet_len;
-       int sock;
+       gint sock;
        enum rspamd_request_type type;
        time_t time;
 };
@@ -138,34 +138,34 @@ struct rspamd_dns_reply {
 /* Internal DNS structs */
 
 struct dns_header {
-               unsigned qid:16;
+               guint qid:16;
 
 #if __BYTE_ORDER == BIG_ENDIAN
-               unsigned qr:1;
-               unsigned opcode:4;
-               unsigned aa:1;
-               unsigned tc:1;
-               unsigned rd:1;
-
-               unsigned ra:1;
-               unsigned unused:3;
-               unsigned rcode:4;
+               guint qr:1;
+               guint opcode:4;
+               guint aa:1;
+               guint tc:1;
+               guint rd:1;
+
+               guint ra:1;
+               guint unused:3;
+               guint rcode:4;
 #else
-               unsigned rd:1;
-               unsigned tc:1;
-               unsigned aa:1;
-               unsigned opcode:4;
-               unsigned qr:1;
-
-               unsigned rcode:4;
-               unsigned unused:3;
-               unsigned ra:1;
+               guint rd:1;
+               guint tc:1;
+               guint aa:1;
+               guint opcode:4;
+               guint qr:1;
+
+               guint rcode:4;
+               guint unused:3;
+               guint ra:1;
 #endif
 
-               unsigned qdcount:16;
-               unsigned ancount:16;
-               unsigned nscount:16;
-               unsigned arcount:16;
+               guint qdcount:16;
+               guint ancount:16;
+               guint nscount:16;
+               guint arcount:16;
 };
 
 enum dns_section {
@@ -215,9 +215,9 @@ enum dns_class {
 }; /* enum dns_class */
 
 struct dns_query {
-       char *qname;
-       unsigned qtype:16;
-       unsigned qclass:16;
+       gchar *qname;
+       guint qtype:16;
+       guint qclass:16;
 };
 
 /* Rspamd DNS API */
@@ -225,7 +225,7 @@ struct rspamd_dns_resolver *dns_resolver_init (struct config_file *cfg);
 gboolean make_dns_request (struct rspamd_dns_resolver *resolver, 
                struct rspamd_async_session *session, memory_pool_t *pool, dns_callback_type cb, 
                gpointer ud, enum rspamd_request_type type, ...);
-const char *dns_strerror (enum dns_rcode rcode);
-const char *dns_strtype (enum rspamd_request_type type);
+const gchar *dns_strerror (enum dns_rcode rcode);
+const gchar *dns_strtype (enum rspamd_request_type type);
 
 #endif
index 5df36711b1e9618951d549b8d8d0f842d2622fcf..e9e98551c2b2ab4f950c3a76060a3b9c7a77d382 100644 (file)
@@ -54,7 +54,7 @@ gboolean                        rspamd_has_fake_html (struct worker_task *task,
  * Sorted by name to use bsearch
  */
 static struct _fl {
-       const char                     *name;
+       const gchar                     *name;
        rspamd_internal_func_t          func;
        void                           *user_data;
 } rspamd_functions_list[] = {
@@ -77,11 +77,11 @@ static struct _fl {
        "is_recipients_sorted", rspamd_is_recipients_sorted, NULL},};
 
 static struct _fl              *list_ptr = &rspamd_functions_list[0];
-static uint32_t                 functions_number = sizeof (rspamd_functions_list) / sizeof (struct _fl);
+static guint32                 functions_number = sizeof (rspamd_functions_list) / sizeof (struct _fl);
 static gboolean                 list_allocated = FALSE;
 
 /* Bsearch routine */
-static int
+static gint
 fl_cmp (const void *s1, const void *s2)
 {
        struct _fl                     *fl1 = (struct _fl *)s1;
@@ -91,7 +91,7 @@ fl_cmp (const void *s1, const void *s2)
 
 /* Cache for regular expressions that are used in functions */
 void                           *
-re_cache_check (const char *line, memory_pool_t *pool)
+re_cache_check (const gchar *line, memory_pool_t *pool)
 {
        GHashTable              *re_cache;
        
@@ -106,7 +106,7 @@ re_cache_check (const char *line, memory_pool_t *pool)
 }
 
 void
-re_cache_add (char *line, void *pointer, memory_pool_t *pool)
+re_cache_add (gchar *line, void *pointer, memory_pool_t *pool)
 {
        GHashTable              *re_cache;
        
@@ -122,7 +122,7 @@ re_cache_add (char *line, void *pointer, memory_pool_t *pool)
 
 /* Task cache functions */
 void
-task_cache_add (struct worker_task *task, struct rspamd_regexp *re, int32_t result)
+task_cache_add (struct worker_task *task, struct rspamd_regexp *re, gint32 result)
 {
        if (result == 0) {
                result = -1;
@@ -131,11 +131,11 @@ task_cache_add (struct worker_task *task, struct rspamd_regexp *re, int32_t resu
        g_hash_table_insert (task->re_cache, re->regexp_text, GINT_TO_POINTER (result));
 }
 
-int32_t
+gint32
 task_cache_check (struct worker_task *task, struct rspamd_regexp *re)
 {
        gpointer                        res;
-       int32_t                         r;
+       gint32                          r;
 
        if ((res = g_hash_table_lookup (task->re_cache, re->regexp_text)) != NULL) {
                r = GPOINTER_TO_INT (res);
@@ -151,7 +151,7 @@ task_cache_check (struct worker_task *task, struct rspamd_regexp *re)
  * Functions for parsing expressions
  */
 struct expression_stack {
-       char                            op;
+       gchar                           op;
        struct expression_stack        *next;
 };
 
@@ -159,7 +159,7 @@ struct expression_stack {
  * Push operand or operator to stack  
  */
 static struct expression_stack *
-push_expression_stack (memory_pool_t * pool, struct expression_stack *head, char op)
+push_expression_stack (memory_pool_t * pool, struct expression_stack *head, gchar op)
 {
        struct expression_stack        *new;
        new = memory_pool_alloc (pool, sizeof (struct expression_stack));
@@ -171,11 +171,11 @@ push_expression_stack (memory_pool_t * pool, struct expression_stack *head, char
 /*
  * Delete symbol from stack, return pointer to operand or operator (casted to void* )
  */
-static char
+static gchar
 delete_expression_stack (struct expression_stack **head)
 {
        struct expression_stack        *cur;
-       char                            res;
+       gchar                           res;
 
        if (*head == NULL)
                return 0;
@@ -190,8 +190,8 @@ delete_expression_stack (struct expression_stack **head)
 /*
  * Return operation priority
  */
-static int
-logic_priority (char a)
+static gint
+logic_priority (gchar a)
 {
        switch (a) {
        case '!':
@@ -211,7 +211,7 @@ logic_priority (char a)
  * Return TRUE if symbol is operation symbol
  */
 static                          gboolean
-is_operation_symbol (char a)
+is_operation_symbol (gchar a)
 {
        switch (a) {
        case '!':
@@ -229,7 +229,7 @@ is_operation_symbol (char a)
  * Return TRUE if symbol can be regexp flag
  */
 static                          gboolean
-is_regexp_flag (char a)
+is_regexp_flag (gchar a)
 {
        switch (a) {
        case 'i':
@@ -252,7 +252,7 @@ is_regexp_flag (char a)
 }
 
 static void
-insert_expression (memory_pool_t * pool, struct expression **head, int type, char op, void *operand, const char *orig)
+insert_expression (memory_pool_t * pool, struct expression **head, gint type, gchar op, void *operand, const gchar *orig)
 {
        struct expression              *new, *cur;
 
@@ -280,10 +280,10 @@ insert_expression (memory_pool_t * pool, struct expression **head, int type, cha
 }
 
 static struct expression       *
-maybe_parse_expression (memory_pool_t * pool, char *line)
+maybe_parse_expression (memory_pool_t * pool, gchar *line)
 {
        struct expression              *expr;
-       char                           *p = line;
+       gchar                           *p = line;
 
        while (*p) {
                if (is_operation_symbol (*p)) {
@@ -305,16 +305,16 @@ maybe_parse_expression (memory_pool_t * pool, char *line)
  * Memory is allocated from given pool
  */
 struct expression              *
-parse_expression (memory_pool_t * pool, char *line)
+parse_expression (memory_pool_t * pool, gchar *line)
 {
        struct expression              *expr = NULL;
        struct expression_stack        *stack = NULL;
        struct expression_function     *func = NULL, *old;
        struct expression              *arg;
        GQueue                         *function_stack;
-       char                           *p, *c, *str, op, *copy;
+       gchar                           *p, *c, *str, op, *copy;
        gboolean                        in_regexp = FALSE;
-       int                             brackets = 0;
+       gint                            brackets = 0;
 
        enum {
                SKIP_SPACES,
@@ -544,11 +544,11 @@ parse_expression (memory_pool_t * pool, char *line)
  * Rspamd regexp utility functions
  */
 struct rspamd_regexp           *
-parse_regexp (memory_pool_t * pool, char *line, gboolean raw_mode)
+parse_regexp (memory_pool_t * pool, gchar *line, gboolean raw_mode)
 {
-       char                           *begin, *end, *p, *src, *start;
+       gchar                           *begin, *end, *p, *src, *start;
        struct rspamd_regexp           *result, *check;
-       int                             regexp_flags = G_REGEX_OPTIMIZE | G_REGEX_NO_AUTO_CAPTURE;
+       gint                            regexp_flags = G_REGEX_OPTIMIZE | G_REGEX_NO_AUTO_CAPTURE;
        GError                         *err = NULL;
 
        src = line;
@@ -854,7 +854,7 @@ get_function_arg (struct expression *expr, struct worker_task *task, gboolean wa
 }
 
 void
-register_expression_function (const char *name, rspamd_internal_func_t func, void *user_data)
+register_expression_function (const gchar *name, rspamd_internal_func_t func, void *user_data)
 {
        static struct _fl              *new;
 
@@ -909,8 +909,8 @@ rspamd_header_exists (struct worker_task * task, GList * args, void *unused)
                return FALSE;
        }
 
-       debug_task ("try to get header %s", (char *)arg->data);
-       headerlist = message_get_header (task->task_pool, task->message, (char *)arg->data);
+       debug_task ("try to get header %s", (gchar *)arg->data);
+       headerlist = message_get_header (task->task_pool, task->message, (gchar *)arg->data);
        if (headerlist) {
                g_list_free (headerlist);
                return TRUE;
@@ -927,7 +927,7 @@ rspamd_header_exists (struct worker_task * task, GList * args, void *unused)
 gboolean
 rspamd_parts_distance (struct worker_task * task, GList * args, void *unused)
 {
-       int                             threshold, diff;
+       gint                            threshold, diff;
        struct mime_text_part          *p1, *p2;
        GList                          *cur;
        struct expression_argument     *arg;
@@ -942,9 +942,9 @@ rspamd_parts_distance (struct worker_task * task, GList * args, void *unused)
        else {
                errno = 0;
                arg = get_function_arg (args->data, task, TRUE);
-               threshold = strtoul ((char *)arg->data, NULL, 10);
+               threshold = strtoul ((gchar *)arg->data, NULL, 10);
                if (errno != 0) {
-                       msg_info ("bad numeric value for threshold \"%s\", assume it 100", (char *)args->data);
+                       msg_info ("bad numeric value for threshold \"%s\", assume it 100", (gchar *)args->data);
                        threshold = 100;
                }
        }
@@ -998,13 +998,13 @@ rspamd_parts_distance (struct worker_task * task, GList * args, void *unused)
 gboolean
 rspamd_content_type_compare_param (struct worker_task * task, GList * args, void *unused)
 {
-       char                           *param_name, *param_pattern;
-       const char                     *param_data;
+       gchar                           *param_name, *param_pattern;
+       const gchar                     *param_data;
        struct rspamd_regexp           *re;
        struct expression_argument     *arg;
        GMimeObject                    *part;
        const GMimeContentType         *ct;
-       int                             r;
+       gint                            r;
 
        if (args == NULL) {
                msg_warn ("no parameters to function");
@@ -1066,8 +1066,8 @@ rspamd_content_type_compare_param (struct worker_task * task, GList * args, void
 gboolean
 rspamd_content_type_has_param (struct worker_task * task, GList * args, void *unused)
 {
-       char                           *param_name;
-       const char                     *param_data;
+       gchar                           *param_name;
+       const gchar                     *param_data;
        struct expression_argument     *arg;
        GMimeObject                    *part;
        const GMimeContentType         *ct;
@@ -1098,12 +1098,12 @@ rspamd_content_type_has_param (struct worker_task * task, GList * args, void *un
 gboolean
 rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *unused)
 {
-       char                           *param_pattern;
+       gchar                           *param_pattern;
        struct rspamd_regexp           *re;
        struct expression_argument     *arg;
        GMimeObject                    *part;
        GMimeContentType               *ct;
-       int                             r;
+       gint                            r;
 
        if (args == NULL) {
                msg_warn ("no parameters to function");
@@ -1158,12 +1158,12 @@ rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *un
 gboolean
 rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unused)
 {
-       char                           *param_pattern;
+       gchar                           *param_pattern;
        struct rspamd_regexp           *re;
        GMimeObject                    *part;
        GMimeContentType               *ct;
        struct expression_argument     *arg;
-       int                             r;
+       gint                            r;
 
        if (args == NULL) {
                msg_warn ("no parameters to function");
@@ -1217,8 +1217,8 @@ rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unus
 }
 
 struct addr_list {
-       const char                     *name;
-       const char                     *addr;
+       const gchar                     *name;
+       const gchar                     *addr;
 };
 
 #define COMPARE_RCPT_LEN 3
@@ -1232,8 +1232,8 @@ rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused
        InternetAddress                *addr;
        double                          threshold;
        struct addr_list               *ar;
-       char                           *c;
-       int                             num, i, j, hits = 0, total = 0;
+       gchar                           *c;
+       gint                            num, i, j, hits = 0, total = 0;
 
        if (args == NULL) {
                msg_warn ("no parameters to function");
@@ -1242,9 +1242,9 @@ rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused
 
        arg = get_function_arg (args->data, task, TRUE);
        errno = 0;
-       threshold = strtod ((char *)arg->data, NULL);
+       threshold = strtod ((gchar *)arg->data, NULL);
        if (errno != 0) {
-               msg_warn ("invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
+               msg_warn ("invalid numeric value '%s': %s", (gchar *)arg->data, strerror (errno));
                return FALSE;
        }
 
@@ -1338,7 +1338,7 @@ is_recipient_list_sorted (const InternetAddressList * ia)
        struct addr_list                current = { NULL, NULL }, previous = {
        NULL, NULL};
 #ifdef GMIME24
-       int                             num, i;
+       gint                            num, i;
 #endif
 
        /* Do not check to short address lists */
@@ -1350,7 +1350,7 @@ is_recipient_list_sorted (const InternetAddressList * ia)
        cur = ia;
        for (i = 0; i < num; i ++) {
                addr = internet_address_list_get_address ((InternetAddressList *)cur, i);
-               current.addr = (char *)internet_address_get_name (addr);
+               current.addr = (gchar *)internet_address_get_name (addr);
                if (previous.addr != NULL) {
                        if (current.addr && g_ascii_strcasecmp (current.addr, previous.addr) < 0) {
                                res = FALSE;
@@ -1398,10 +1398,10 @@ rspamd_is_recipients_sorted (struct worker_task * task, GList * args, void *unus
 }
 
 static inline                   gboolean
-compare_subtype (struct worker_task *task, GMimeContentType * ct, char *subtype)
+compare_subtype (struct worker_task *task, GMimeContentType * ct, gchar *subtype)
 {
        struct rspamd_regexp           *re;
-       int                             r;
+       gint                            r;
 
        if (*subtype == '/') {
                /* This is regexp, so compile and create g_regexp object */
@@ -1435,7 +1435,7 @@ compare_subtype (struct worker_task *task, GMimeContentType * ct, char *subtype)
 }
 
 static inline                   gboolean
-compare_len (struct mime_part *part, int min, int max)
+compare_len (struct mime_part *part, gint min, gint max)
 {
        if (min == 0 && max == 0) {
                return TRUE;
@@ -1453,13 +1453,13 @@ compare_len (struct mime_part *part, int min, int max)
 }
 
 gboolean
-common_has_content_part (struct worker_task * task, char *param_type, char *param_subtype, int min_len, int max_len)
+common_has_content_part (struct worker_task * task, gchar *param_type, gchar *param_subtype, gint min_len, gint max_len)
 {
        struct rspamd_regexp           *re;
        struct mime_part               *part;
        GList                          *cur;
        GMimeContentType               *ct;
-       int                             r;
+       gint                            r;
 
        cur = g_list_first (task->parts);
        while (cur) {
@@ -1537,7 +1537,7 @@ common_has_content_part (struct worker_task * task, char *param_type, char *para
 gboolean
 rspamd_has_content_part (struct worker_task * task, GList * args, void *unused)
 {
-       char                           *param_type = NULL, *param_subtype = NULL;
+       gchar                           *param_type = NULL, *param_subtype = NULL;
        struct expression_argument     *arg;
 
        if (args == NULL) {
@@ -1559,8 +1559,8 @@ rspamd_has_content_part (struct worker_task * task, GList * args, void *unused)
 gboolean
 rspamd_has_content_part_len (struct worker_task * task, GList * args, void *unused)
 {
-       char                           *param_type = NULL, *param_subtype = NULL;
-       int                             min = 0, max = 0;
+       gchar                           *param_type = NULL, *param_subtype = NULL;
+       gint                            min = 0, max = 0;
        struct expression_argument     *arg;
 
        if (args == NULL) {
@@ -1580,7 +1580,7 @@ rspamd_has_content_part_len (struct worker_task * task, GList * args, void *unus
                        errno = 0;
                        min = strtoul (arg->data, NULL, 10);
                        if (errno != 0) {
-                               msg_warn ("invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
+                               msg_warn ("invalid numeric value '%s': %s", (gchar *)arg->data, strerror (errno));
                                return FALSE;
                        }
                        args = args->next;
@@ -1588,7 +1588,7 @@ rspamd_has_content_part_len (struct worker_task * task, GList * args, void *unus
                                arg = get_function_arg (args->data, task, TRUE);
                                max = strtoul (arg->data, NULL, 10);
                                if (errno != 0) {
-                                       msg_warn ("invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
+                                       msg_warn ("invalid numeric value '%s': %s", (gchar *)arg->data, strerror (errno));
                                        return FALSE;
                                }
                        }
@@ -1622,7 +1622,7 @@ rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void
        enc_req = g_mime_content_encoding_from_string (arg->data);
        if (enc_req == GMIME_CONTENT_ENCODING_DEFAULT) {
 #endif
-               msg_warn ("bad encoding type: %s", (char *)arg->data);
+               msg_warn ("bad encoding type: %s", (gchar *)arg->data);
                return FALSE;
        }
 
@@ -1644,7 +1644,7 @@ rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void
 #endif
 
 
-                       debug_task ("got encoding in part: %d and compare with %d", (int)part_enc, (int)enc_req);
+                       debug_task ("got encoding in part: %d and compare with %d", (gint)part_enc, (gint)enc_req);
 #ifndef GMIME24
                        g_object_unref (part);
 #endif
@@ -1725,7 +1725,7 @@ rspamd_has_html_tag (struct worker_task * task, GList * args, void *unused)
        arg = get_function_arg (args->data, task, TRUE);
        tag = get_tag_by_name (arg->data);
        if (tag == NULL) {
-               msg_warn ("unknown tag type passed as argument: %s", (char *)arg->data);
+               msg_warn ("unknown tag type passed as argument: %s", (gchar *)arg->data);
                return FALSE;
        }
 
index 6ffc7359d06cedafd1ae01ec09dade45204a4c1f..6a25dd9e13a21d3ec3d65bcbbcbb7bfa19f69fa4 100644 (file)
@@ -15,7 +15,7 @@ struct rspamd_regexp;
  * Rspamd expression function
  */
 struct expression_function {
-       char *name;                                                                                                     /**< name of function                                                           */
+       gchar *name;                                                                                                    /**< name of function                                                           */
        GList *args;                                                                                            /**< its args                                                                           */
 };
 
@@ -44,7 +44,7 @@ struct expression {
        } type;                                                                                                         /**< expression type                                                            */
        union {
                void *operand;
-               char operation;
+               gchar operation;
        } content;                                                                                                      /**< union for storing operand or operation code        */
        const gchar *orig;                                                                                      /**< original line                                                                      */
        struct expression *next;                                                                        /**< chain link                                                                         */
@@ -58,7 +58,7 @@ typedef gboolean (*rspamd_internal_func_t)(struct worker_task *, GList *args, vo
  * @param line incoming line
  * @return regexp structure or NULL in case of error
  */
-struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line, gboolean raw_mode);
+struct rspamd_regexp* parse_regexp (memory_pool_t *pool, gchar *line, gboolean raw_mode);
 
 /**
  * Parse composites line to composites structure (eg. "SYMBOL1&SYMBOL2|!SYMBOL3")
@@ -66,7 +66,7 @@ struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line, gboolean ra
  * @param line incoming line
  * @return expression structure or NULL in case of error
  */
-struct expression* parse_expression (memory_pool_t *pool, char *line);
+struct expression* parse_expression (memory_pool_t *pool, gchar *line);
 
 /**
  * Call specified fucntion and return boolean result
@@ -81,21 +81,21 @@ gboolean call_expression_function (struct expression_function *func, struct work
  * @param name name of function
  * @param func pointer to function
  */
-void register_expression_function (const char *name, rspamd_internal_func_t func, void *user_data);
+void register_expression_function (const gchar *name, rspamd_internal_func_t func, void *user_data);
 
 /**
  * Add regexp to regexp cache
  * @param line symbolic representation
  * @param pointer regexp data
  */
-void re_cache_add (char *line, void *pointer, memory_pool_t *pool);
+void re_cache_add (gchar *line, void *pointer, memory_pool_t *pool);
 
 /**
  * Check regexp in cache
  * @param line symbolic representation
  * @return pointer to regexp data or NULL if regexp is not found
  */
-void * re_cache_check (const char *line, memory_pool_t *pool);
+void * re_cache_check (const gchar *line, memory_pool_t *pool);
 
 /**
  * Add regexp to regexp task cache
@@ -103,7 +103,7 @@ void * re_cache_check (const char *line, memory_pool_t *pool);
  * @param pointer regexp data
  * @param result numeric result of this regexp
  */
-void task_cache_add (struct worker_task *task, struct rspamd_regexp *re, int32_t result);
+void task_cache_add (struct worker_task *task, struct rspamd_regexp *re, gint32 result);
 
 /**
  * Check regexp in cache
@@ -111,7 +111,7 @@ void task_cache_add (struct worker_task *task, struct rspamd_regexp *re, int32_t
  * @param pointer regexp data
  * @return numeric result if value exists or -1 if not
  */
-int32_t task_cache_check (struct worker_task *task, struct rspamd_regexp *re);
+gint32 task_cache_check (struct worker_task *task, struct rspamd_regexp *re);
 
 /**
  * Parse and return a single function argument for a function (may recurse)
index f38831c007a99efd776b3fb6ff0b14a8773101a1..53beb762ed82485a09b701f8aed19485912e74cf 100644 (file)
@@ -44,7 +44,7 @@
 #endif
 
 static void
-insert_metric_result (struct worker_task *task, struct metric *metric, const char *symbol, double flag, GList * opts)
+insert_metric_result (struct worker_task *task, struct metric *metric, const gchar *symbol, double flag, GList * opts)
 {
        struct metric_result           *metric_res;
        struct symbol                  *s;
@@ -115,7 +115,7 @@ insert_metric_result (struct worker_task *task, struct metric *metric, const cha
 }
 
 void
-insert_result (struct worker_task *task, const char *symbol, double flag, GList * opts)
+insert_result (struct worker_task *task, const gchar *symbol, double flag, GList * opts)
 {
        struct metric                  *metric;
        struct cache_item              *item;
@@ -165,10 +165,10 @@ insert_result (struct worker_task *task, const char *symbol, double flag, GList
  * Call perl or C module function for specified part of message 
  */
 static void
-call_filter_by_name (struct worker_task *task, const char *name, enum filter_type filt_type)
+call_filter_by_name (struct worker_task *task, const gchar *name, enum filter_type filt_type)
 {
        struct module_ctx              *c_module;
-       int                             res = 0;
+       gint                            res = 0;
 
        switch (filt_type) {
        case C_FILTER:
@@ -193,7 +193,7 @@ call_filter_by_name (struct worker_task *task, const char *name, enum filter_typ
                break;
        }
 
-       debug_task ("filter name: %s, result: %d", name, (int)res);
+       debug_task ("filter name: %s, result: %d", name, (gint)res);
 }
 
 /* Return true if metric has score that is more than spam score for it */
@@ -214,7 +214,7 @@ check_metric_is_spam (struct worker_task *task, struct metric *metric)
        return FALSE;
 }
 
-static int
+static gint
 continue_process_filters (struct worker_task *task)
 {
        GList                          *cur;
@@ -256,7 +256,7 @@ end:
        return 1;
 }
 
-int
+gint
 process_filters (struct worker_task *task)
 {
        GList                          *cur;
@@ -385,12 +385,12 @@ composites_foreach_callback (gpointer key, gpointer value, void *data)
 static                          gboolean
 check_autolearn (struct statfile_autolearn_params *params, struct worker_task *task)
 {
-       char                           *metric_name = DEFAULT_METRIC;
+       gchar                           *metric_name = DEFAULT_METRIC;
        struct metric_result           *metric_res;
        GList                          *cur;
 
        if (params->metric != NULL) {
-               metric_name = (char *)params->metric;
+               metric_name = (gchar *)params->metric;
        }
 
        /* First check threshold */
@@ -425,7 +425,7 @@ check_autolearn (struct statfile_autolearn_params *params, struct worker_task *t
 }
 
 void
-process_autolearn (struct statfile *st, struct worker_task *task, GTree * tokens, struct classifier *classifier, char *filename, struct classifier_ctx *ctx)
+process_autolearn (struct statfile *st, struct worker_task *task, GTree * tokens, struct classifier *classifier, gchar *filename, struct classifier_ctx *ctx)
 {
        stat_file_t                    *statfile;
        struct statfile                *unused;
@@ -479,7 +479,7 @@ classifiers_callback (gpointer value, void *arg)
        GTree                          *tokens = NULL;
        GList                          *cur;
        f_str_t                         c;
-       char                           *header = NULL;
+       gchar                           *header = NULL;
        
        if ((header = g_hash_table_lookup (cl->opts, "header")) != NULL) {
                cur = message_get_header (task->task_pool, task->message, header);
@@ -567,9 +567,9 @@ static void
 insert_metric_header (gpointer metric_name, gpointer metric_value, gpointer data)
 {
        struct worker_task             *task = (struct worker_task *)data;
-       int                             r = 0;
+       gint                            r = 0;
        /* Try to be rfc2822 compatible and avoid long headers with folding */
-       char                            header_name[128], outbuf[1000];
+       gchar                           header_name[128], outbuf[1000];
        GList                          *symbols = NULL, *cur;
        struct metric_result           *metric_res = (struct metric_result *)metric_value;
        double                          ms, rs;
@@ -590,10 +590,10 @@ insert_metric_header (gpointer metric_name, gpointer metric_value, gpointer data
        cur = symbols;
        while (cur) {
                if (g_list_next (cur) != NULL) {
-                       r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s,", (char *)cur->data);
+                       r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s,", (gchar *)cur->data);
                }
                else {
-                       r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s", (char *)cur->data);
+                       r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s", (gchar *)cur->data);
                }
                cur = g_list_next (cur);
        }
index 7996f16e66e2af4b26157ac4eb2f53d0830a0972..bc8d98de5933c9929a89d3d916425f25f523f36c 100644 (file)
@@ -11,7 +11,7 @@
 
 struct worker_task;
 
-typedef double (*metric_cons_func)(struct worker_task *task, const char *metric_name, const char *func_name);
+typedef double (*metric_cons_func)(struct worker_task *task, const gchar *metric_name, const gchar *func_name);
 typedef void (*filter_func)(struct worker_task *task);
 
 enum filter_type { C_FILTER, PERL_FILTER };
@@ -20,7 +20,7 @@ enum filter_type { C_FILTER, PERL_FILTER };
  * Filter structure
  */
 struct filter {
-       char *func_name;                                                                /**< function name                                                      */
+       gchar *func_name;                                                               /**< function name                                                      */
        enum filter_type type;                                                  /**< filter type (c or perl)                            */
     module_t *module;
 };
@@ -51,8 +51,8 @@ struct metric_action {
  * Common definition of metric
  */
 struct metric {
-       char *name;                                                                             /**< name of metric                                                                     */
-       char *func_name;                                                                /**< name of consolidation function                                     */
+       gchar *name;                                                                            /**< name of metric                                                                     */
+       gchar *func_name;                                                               /**< name of consolidation function                                     */
        metric_cons_func func;                                                  /**< c consolidation function                                           */
        double grow_factor;                                                             /**< grow factor for metric                                                     */
        double required_score;                                                  /**< required score for this metric                                     */
@@ -78,7 +78,7 @@ struct metric_result {
  * @param task worker's task that present message from user
  * @return 0 - if there is non-finished tasks and 1 if processing is completed
  */
-int process_filters (struct worker_task *task);
+gint process_filters (struct worker_task *task);
 
 /**
  * Process message with statfiles
@@ -94,7 +94,7 @@ void process_statfiles (struct worker_task *task);
  * @param flag numeric weight for symbol
  * @param opts list of symbol's options
  */
-void insert_result (struct worker_task *task, const char *symbol, double flag, GList *opts);
+void insert_result (struct worker_task *task, const gchar *symbol, double flag, GList *opts);
 
 /**
  * Process all results and form composite metrics from existent metrics as it is defined in config
@@ -109,6 +109,6 @@ void make_composites (struct worker_task *task);
  * @param metric_name name of metric
  * @return result metric weight
  */
-double factor_consolidation_func (struct worker_task *task, const char *metric_name, const char *unused);
+double factor_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *unused);
 
 #endif
index d325aa421d76a723a3993c493527b1774693f9c3..5fcb12bd2a2e0a84d0303ed0ec6f3ed8971b3dcd 100644 (file)
@@ -28,7 +28,7 @@
  * Search first occurence of character in string
  */
 ssize_t
-fstrchr (f_str_t * src, char c)
+fstrchr (f_str_t * src, gchar c)
 {
        register ssize_t                cur = 0;
 
@@ -46,7 +46,7 @@ fstrchr (f_str_t * src, char c)
  * Search last occurence of character in string
  */
 ssize_t
-fstrrchr (f_str_t * src, char c)
+fstrrchr (f_str_t * src, gchar c)
 {
        register ssize_t                cur = src->len;
 
@@ -130,11 +130,11 @@ fstrstri (f_str_t * orig, f_str_t * pattern)
  *                     1 - word was extracted and there are more words
  *                     0 - last word extracted
  */
-int
-fstrtok (f_str_t * text, const char *sep, f_tok_t * state)
+gint
+fstrtok (f_str_t * text, const gchar *sep, f_tok_t * state)
 {
        register size_t                 cur;
-       const char                     *csep = sep;
+       const gchar                     *csep = sep;
 
        if (state->pos >= text->len) {
                return -1;
@@ -191,7 +191,7 @@ size_t
 fstrcat (f_str_t * dest, f_str_t * src)
 {
        register size_t                 cur = 0;
-       char                           *p = dest->begin + dest->len;
+       gchar                           *p = dest->begin + dest->len;
 
        if (dest->size < src->len + dest->len) {
                return 0;
@@ -212,10 +212,10 @@ fstrcat (f_str_t * dest, f_str_t * src)
 /*
  * Make copy of string to 0-terminated string
  */
-char                           *
+gchar                           *
 fstrcstr (f_str_t * str, memory_pool_t * pool)
 {
-       char                           *res;
+       gchar                           *res;
        res = memory_pool_alloc (pool, str->len + 1);
 
        memcpy (res, str->begin, str->len);
@@ -227,8 +227,8 @@ fstrcstr (f_str_t * str, memory_pool_t * pool)
 /*
  * Push one character to fstr
  */
-int
-fstrpush (f_str_t * dest, char c)
+gint
+fstrpush (f_str_t * dest, gchar c)
 {
        if (dest->size < dest->len) {
                /* Need to reallocate string */
@@ -300,13 +300,13 @@ fstrgrow (memory_pool_t * pool, f_str_t * orig, size_t newlen)
 /*
  * Return hash value for a string
  */
-uint32_t
+guint32
 fstrhash (f_str_t * str)
 {
        size_t                          i;
-       uint32_t                        hval;
-       uint32_t                        tmp;
-       char                           *c = str->begin;
+       guint32                         hval;
+       guint32                         tmp;
+       gchar                           *c = str->begin;
 
        if (str == NULL) {
                return 0;
@@ -343,8 +343,8 @@ fstrhash (f_str_t * str)
 void
 fstrstrip (f_str_t * str)
 {
-       char                           *p = str->begin;
-       int                             r = 0;
+       gchar                           *p = str->begin;
+       gint                            r = 0;
 
        while (r < str->len) {
                if (g_ascii_isspace (*p)) {
index 00fac9039efdac447ab4f2a66c61400edcc2a1ae..616287fe493bda7869b4227b715245aa723b5470 100644 (file)
 #define update_buf_size(x) (x)->free = (x)->buf->size - ((x)->pos - (x)->buf->begin); (x)->buf->len = (x)->pos - (x)->buf->begin
 
 typedef struct f_str_s {
-       char *begin;
+       gchar *begin;
        size_t len;
        size_t size;
 } f_str_t;
 
 typedef struct f_str_buf_s {
        f_str_t *buf;
-       char *pos;
+       gchar *pos;
        size_t free;
 } f_str_buf_t;
 
@@ -30,12 +30,12 @@ typedef struct f_tok_s {
 /*
  * Search first occurence of character in string
  */
-ssize_t fstrchr (f_str_t *src, char c);
+ssize_t fstrchr (f_str_t *src, gchar c);
 
 /*
  * Search last occurence of character in string
  */
-ssize_t fstrrchr (f_str_t *src, char c);
+ssize_t fstrrchr (f_str_t *src, gchar c);
 
 /*
  * Search for pattern in orig
@@ -51,7 +51,7 @@ ssize_t fstrstri (f_str_t *orig, f_str_t *pattern);
  * Split string by tokens
  * word contains parsed word
  */
-int fstrtok (f_str_t *text, const char *sep, f_tok_t *state);
+gint fstrtok (f_str_t *text, const gchar *sep, f_tok_t *state);
 
 /*
  * Copy one string into other
@@ -66,7 +66,7 @@ size_t fstrcat (f_str_t *dest, f_str_t *src);
 /*
  * Push one character to fstr
  */
-int fstrpush (f_str_t *dest, char c);
+gint fstrpush (f_str_t *dest, gchar c);
 
 /*
  * Allocate memory for f_str_t
@@ -91,12 +91,12 @@ f_str_t* fstrgrow (memory_pool_t *pool, f_str_t *orig, size_t newlen);
 /*
  * Return fast hash value for fixed string
  */
-uint32_t fstrhash (f_str_t *str);
+guint32 fstrhash (f_str_t *str);
 
 /*
  * Make copy of string to 0-terminated string
  */
-char* fstrcstr (f_str_t *str, memory_pool_t *pool);
+gchar* fstrcstr (f_str_t *str, memory_pool_t *pool);
 
 /*
  * Strip fstr string from space symbols
index b71fcb6502f1b32a73b5500b8922782b3ea93fef..286f1696dde62cc202147bb9919b897f02564cc9 100644 (file)
 #define HASH_INIT      0x28021967
 
 struct roll_state {
-       uint32_t                        h[3];
-       char                            window[ROLL_WINDOW_SIZE];
-       int                             n;
+       guint32                         h[3];
+       gchar                           window[ROLL_WINDOW_SIZE];
+       gint                            n;
 };
 
 static struct roll_state        rs;
 
 
 /* Rolling hash function based on Adler-32 checksum */
-static                          uint32_t
-fuzzy_roll_hash (char c)
+static                          guint32
+fuzzy_roll_hash (gchar c)
 {
        /* Check window position */
        if (rs.n == ROLL_WINDOW_SIZE) {
@@ -67,8 +67,8 @@ fuzzy_roll_hash (char c)
 }
 
 /* A simple non-rolling hash, based on the FNV hash */
-static                          uint32_t
-fuzzy_fnv_hash (char c, uint32_t hval)
+static                          guint32
+fuzzy_fnv_hash (gchar c, guint32 hval)
 {
        hval ^= c;
        hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
@@ -76,8 +76,8 @@ fuzzy_fnv_hash (char c, uint32_t hval)
 }
 
 /* Calculate blocksize depending on length of input */
-static                          uint32_t
-fuzzy_blocksize (uint32_t len)
+static                          guint32
+fuzzy_blocksize (guint32 len)
 {
 
        if (len < MIN_FUZZY_BLOCK_SIZE) {
@@ -88,7 +88,7 @@ fuzzy_blocksize (uint32_t len)
 
 /* Update hash with new symbol */
 void
-fuzzy_update (fuzzy_hash_t * h, char c)
+fuzzy_update (fuzzy_hash_t * h, gchar c)
 {
        h->rh = fuzzy_roll_hash (c);
        h->h = fuzzy_fnv_hash (c, h->h);
@@ -107,15 +107,15 @@ fuzzy_update (fuzzy_hash_t * h, char c)
  *
  * Replace cost is normally 1, and 2 with nonzero xcost.
  */
-uint32_t
-lev_distance (char *s1, int len1, char *s2, int len2)
+guint32
+lev_distance (gchar *s1, gint len1, gchar *s2, gint len2)
 {
-       int                             i;
-       int                            *row;    /* we only need to keep one row of costs */
-       int                            *end;
-       int                             half, nx;
-       char                           *sx, *char2p, char1;
-       int                            *p, D, x, offset, c3;
+       gint                            i;
+       gint                            *row;   /* we only need to keep one row of costs */
+       gint                            *end;
+       gint                            half, nx;
+       gchar                           *sx, *char2p, char1;
+       gint                            *p, D, x, offset, c3;
 
        /* strip common prefix */
        while (len1 > 0 && len2 > 0 && *s1 == *s2) {
@@ -159,7 +159,7 @@ lev_distance (char *s1, int len1, char *s2, int len2)
        half = len1 >> 1;
 
        /* initalize first row */
-       row = g_malloc (len2 * sizeof (int));
+       row = g_malloc (len2 * sizeof (gint));
        end = row + len2 - 1;
        for (i = 0; i < len2; i++) {
                row[i] = i;
@@ -225,8 +225,8 @@ fuzzy_hash_t                   *
 fuzzy_init (f_str_t * in, memory_pool_t * pool)
 {
        fuzzy_hash_t                   *new;
-       int                             i, repeats = 0;
-       char                           *c = in->begin, last = '\0';
+       gint                            i, repeats = 0;
+       gchar                           *c = in->begin, last = '\0';
 
        new = memory_pool_alloc0 (pool, sizeof (fuzzy_hash_t));
        bzero (&rs, sizeof (rs));
@@ -261,10 +261,10 @@ fuzzy_init_byte_array (GByteArray * in, memory_pool_t * pool)
 }
 
 /* Compare score of difference between two hashes 0 - different hashes, 100 - identical hashes */
-int
+gint
 fuzzy_compare_hashes (fuzzy_hash_t * h1, fuzzy_hash_t * h2)
 {
-       int                             res, l1, l2;
+       gint                            res, l1, l2;
 
        /* If we have hashes of different size, input strings are too different */
        if (h1->block_size != h2->block_size) {
index 4895e6c53179c76d2ddc1b88afb3db8cc9964e31..8db2779d1e2a718268d46705f7a9545d9a785aeb 100644 (file)
 #define FUZZY_HASHLEN 64
 
 typedef struct fuzzy_hash_s {
-       char hash_pipe[FUZZY_HASHLEN];                  /**< result hash                                        */
-       uint32_t block_size;                                    /**< current blocksize                          */
-       uint32_t rh;                                                    /**< roll hash value                            */
-       uint32_t h;                                                             /**< hash of block                                      */
-       uint32_t hi;                                                    /**< current index in hash pipe         */
+       gchar hash_pipe[FUZZY_HASHLEN];                 /**< result hash                                        */
+       guint32 block_size;                                     /**< current blocksize                          */
+       guint32 rh;                                                     /**< roll hash value                            */
+       guint32 h;                                                              /**< hash of block                                      */
+       guint32 hi;                                                     /**< current index in hash pipe         */
 } fuzzy_hash_t;
 
 /**
@@ -35,9 +35,9 @@ fuzzy_hash_t * fuzzy_init_byte_array (GByteArray *in, memory_pool_t *pool);
  * @param h2 second hash
  * @return result in percents 0 - different hashes, 100 - identical hashes 
  */
-int fuzzy_compare_hashes (fuzzy_hash_t *h1, fuzzy_hash_t *h2);
+gint fuzzy_compare_hashes (fuzzy_hash_t *h1, fuzzy_hash_t *h2);
 
-uint32_t lev_distance (char *s1, int len1, char *s2, int len2);
+guint32 lev_distance (gchar *s1, gint len1, gchar *s2, gint len2);
 
 
 #endif
index 4b8b4ca9d7830b19e59eccdbaa51a3212cd482ed..d967fcfe28c43ec40774751c6f08382f576ae3cb 100644 (file)
@@ -71,29 +71,29 @@ static gboolean                 use_judy = FALSE;
 static bloom_filter_t          *bf;
 
 /* Number of cache modifications */
-static uint32_t                 mods = 0;
-static uint32_t                 max_mods = DEFAULT_MOD_LIMIT;
+static guint32                 mods = 0;
+static guint32                 max_mods = DEFAULT_MOD_LIMIT;
 /* Frequent score number */
-static uint32_t                 frequent_score = DEFAULT_FREQUENT_SCORE;
+static guint32                 frequent_score = DEFAULT_FREQUENT_SCORE;
 /* For evtimer */
 static struct timeval           tmv;
 static struct event             tev;
 static struct rspamd_stat      *server_stat;
 
 struct rspamd_fuzzy_node {
-       int32_t                         value;
-       int32_t                         flag;
-       uint64_t                        time;
+       gint32                          value;
+       gint32                          flag;
+       guint64                         time;
        fuzzy_hash_t                    h;
 };
 
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        switch (signo) {
@@ -119,14 +119,14 @@ compare_nodes (gconstpointer a, gconstpointer b, gpointer unused)
 static void
 sync_cache (struct rspamd_worker *wrk)
 {
-       int                             fd, i;
-       char                           *filename, *exp_str, header[4];
+       gint                            fd, i;
+       gchar                           *filename, *exp_str, header[4];
        GList                          *cur, *tmp;
        struct rspamd_fuzzy_node       *node;
-       uint64_t                        expire, now;
+       guint64                         expire, now;
 #ifdef WITH_JUDY
        PPvoid_t                        pvalue;
-       char                            indexbuf[1024], tmpindex[1024];
+       gchar                           indexbuf[1024], tmpindex[1024];
 #endif
 
        /* Check for modifications */
@@ -154,11 +154,11 @@ sync_cache (struct rspamd_worker *wrk)
 
        (void)lock_file (fd, FALSE);
 
-       now = (uint64_t) time (NULL);
+       now = (guint64) time (NULL);
        
        /* Fill header */
        memcpy (header, FUZZY_FILE_MAGIC, 3);
-       header[3] = (char)CURRENT_FUZZY_VERSION;
+       header[3] = (gchar)CURRENT_FUZZY_VERSION;
        if (write (fd, header, sizeof (header)) == -1) {
                msg_err ("cannot write file %s while writing header: %s", filename, strerror (errno));
                goto end;
@@ -231,7 +231,7 @@ end:
 }
 
 static void
-sigterm_handler (int fd, short what, void *arg)
+sigterm_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        static struct timeval           tv = {
@@ -249,7 +249,7 @@ sigterm_handler (int fd, short what, void *arg)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (int fd, short what, void *arg)
+sigusr_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -271,14 +271,14 @@ sigusr_handler (int fd, short what, void *arg)
 static                          gboolean
 read_hashes_file (struct rspamd_worker *wrk)
 {
-       int                             r, fd, i, version = 0;
+       gint                            r, fd, i, version = 0;
        struct stat                     st;
-       char                           *filename, header[4];
+       gchar                           *filename, header[4];
        gboolean                        touch_stat = TRUE;
        struct rspamd_fuzzy_node       *node;
        struct {
-               int32_t                         value;
-               uint64_t                        time;
+               gint32                          value;
+               guint64                         time;
                fuzzy_hash_t                    h;
        }                                                               legacy_node;
 #ifdef WITH_JUDY
@@ -319,12 +319,12 @@ read_hashes_file (struct rspamd_worker *wrk)
        if ((r = read (fd, header, sizeof (header))) == sizeof (header)) {
                if (memcmp (header, FUZZY_FILE_MAGIC, sizeof (header) - 1) == 0) {
                        /* We have version in last byte of header */
-                       version = (int)header[3];
+                       version = (gint)header[3];
                        if (version > CURRENT_FUZZY_VERSION) {
                                msg_err ("unsupported version of fuzzy hash file: %d", version);
                                return FALSE;
                        }
-                       msg_info ("reading fuzzy hashes storage file of version %d of size %d", version, (int)(st.st_size - sizeof (header)) / sizeof (struct rspamd_fuzzy_node));
+                       msg_info ("reading fuzzy hashes storage file of version %d of size %d", version, (gint)(st.st_size - sizeof (header)) / sizeof (struct rspamd_fuzzy_node));
                }
                else {
                        /* Old version */
@@ -402,11 +402,11 @@ read_hashes_file (struct rspamd_worker *wrk)
 }
 
 static inline struct rspamd_fuzzy_node *
-check_hash_node (GQueue *hash, fuzzy_hash_t *s, int update_value)
+check_hash_node (GQueue *hash, fuzzy_hash_t *s, gint update_value)
 {
        GList                          *cur;
        struct rspamd_fuzzy_node       *h;
-       int                             prob = 0;
+       gint                            prob = 0;
 #ifdef WITH_JUDY
        PPvoid_t                         pvalue;
 
@@ -465,8 +465,8 @@ check_hash_node (GQueue *hash, fuzzy_hash_t *s, int update_value)
        return NULL;
 }
 
-static                          int
-process_check_command (struct fuzzy_cmd *cmd, int *flag)
+static                          gint
+process_check_command (struct fuzzy_cmd *cmd, gint *flag)
 {
        fuzzy_hash_t                    s;
        struct rspamd_fuzzy_node       *h;
@@ -518,7 +518,7 @@ process_write_command (struct fuzzy_cmd *cmd)
        h = g_malloc (sizeof (struct rspamd_fuzzy_node));
        memcpy (&h->h.hash_pipe, &cmd->hash, sizeof (cmd->hash));
        h->h.block_size = cmd->blocksize;
-       h->time = (uint64_t) time (NULL);
+       h->time = (guint64) time (NULL);
        h->value = cmd->value;
        h->flag = cmd->flag;
 #ifdef WITH_JUDY
@@ -641,8 +641,8 @@ else {                                                                                                                                                                                      \
 static void
 process_fuzzy_command (struct fuzzy_session *session)
 {
-       int r, flag = 0;
-       char buf[64];
+       gint                            r, flag = 0;
+       gchar                           buf[64];
 
        switch (session->cmd.cmd) {
        case FUZZY_CHECK:
@@ -679,15 +679,15 @@ process_fuzzy_command (struct fuzzy_session *session)
  * Accept new connection and construct task
  */
 static void
-accept_fuzzy_socket (int fd, short what, void *arg)
+accept_fuzzy_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        struct fuzzy_session            session;
        ssize_t                         r;
        struct {
                u_char                      cmd;
-               uint32_t                    blocksize;
-               int32_t                     value;
+               guint32                         blocksize;
+               gint32                          value;
                u_char                      hash[FUZZY_HASHLEN];
        }                                                               legacy_cmd;
 
@@ -725,7 +725,7 @@ accept_fuzzy_socket (int fd, short what, void *arg)
 }
 
 static void
-sync_callback (int fd, short what, void *arg)
+sync_callback (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Timer event */
@@ -746,8 +746,8 @@ start_fuzzy_storage (struct rspamd_worker *worker)
 {
        struct sigaction                signals;
        struct event                    sev;
-       int                             retries = 0;
-       char                           *value;
+       gint                            retries = 0;
+       gchar                           *value;
 
        worker->srv->pid = getpid ();
        worker->srv->type = TYPE_FUZZY;
index c317bd99f8a1b0b835bc8a4c2377e57f1caea071..5a02d48712cade19a3a999ff7e01956505b6c1b6 100644 (file)
 
 struct fuzzy_cmd {
        u_char cmd;
-       uint32_t blocksize;
-       int32_t value;
-       int32_t flag;
+       guint32 blocksize;
+       gint32 value;
+       gint32 flag;
        u_char hash[FUZZY_HASHLEN];
 };
 
 struct fuzzy_session {
        struct rspamd_worker *worker;
        struct fuzzy_cmd cmd;
-       int fd;
+       gint fd;
        u_char *pos;
        socklen_t salen;
        struct sockaddr_storage sa;
index 47b769b1ed1e1ae13e2717f0d0c5a539039845f6..2217c4d536014dc1f8b03ac37fa51937de581b1f 100644 (file)
@@ -56,10 +56,10 @@ struct greylist_ctx {
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        switch (signo) {
@@ -77,7 +77,7 @@ sig_handler (int signo, siginfo_t *info, void *unused)
 }
 
 static void
-sigterm_handler (int fd, short what, void *arg)
+sigterm_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        static struct timeval           tv = {
@@ -93,7 +93,7 @@ sigterm_handler (int fd, short what, void *arg)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (int fd, short what, void *arg)
+sigusr_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -112,7 +112,7 @@ sigusr_handler (int fd, short what, void *arg)
 
 struct greylist_session {
        struct rspamd_worker *worker;
-       int fd;
+       gint                            fd;
        socklen_t salen;
        struct sockaddr_storage sa;
        guint8 *pos;
@@ -160,7 +160,7 @@ greylist_process_delete_command (struct rspamd_grey_command *cmd, struct greylis
 {
        struct rspamd_grey_reply          reply;
 #ifdef WITH_JUDY
-       int                               rc;
+       gint                            rc;
        struct rspamd_grey_item         **pitem = NULL;
 
        JHSG (pitem, ctx->jtree, cmd->data, CHECKSUM_SIZE);
@@ -256,7 +256,7 @@ process_greylist_command (struct greylist_session *session)
  * Accept new connection and construct task
  */
 static void
-accept_greylist_socket (int fd, short what, void *arg)
+accept_greylist_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        struct greylist_session         session;
@@ -288,7 +288,7 @@ static gboolean
 config_greylist_worker (struct rspamd_worker *worker)
 {
        struct greylist_ctx            *ctx;
-       char                           *value;
+       gchar                           *value;
 
        ctx = g_malloc0 (sizeof (struct greylist_ctx));
 #ifdef WITH_JUDY
@@ -319,7 +319,7 @@ start_greylist_storage (struct rspamd_worker *worker)
 {
        struct sigaction                signals;
        struct event                    sev;
-       int                             retries = 0;
+       gint                            retries = 0;
 
        worker->srv->pid = getpid ();
        worker->srv->type = TYPE_GREYLIST;
index be1f1ef16afedf391618d07dc9ddd6c663784133..15f3e9b17f25d6a856a72cd3db7a856bfc247359 100644 (file)
@@ -161,9 +161,9 @@ struct _entity;
 typedef struct _entity          entity;
 
 struct _entity {
-       char                           *name;
+       gchar                           *name;
        uint                            code;
-       char                           *replacement;
+       gchar                           *replacement;
 };
 
 
@@ -375,7 +375,7 @@ static entity                   entities_defs[] = {
        {"or", 8744, "|"},
        {"cap", 8745, NULL},
        {"cup", 8746, NULL},
-       {"int", 8747, NULL},
+       {"gint", 8747, NULL},
        {"there4", 8756, NULL},
        {"sim", 8764, NULL},
        {"cong", 8773, NULL},
@@ -440,7 +440,7 @@ static entity                   entities_defs[] = {
 
 static entity                  *entities_defs_num = NULL;
 
-static int
+static gint
 tag_cmp (const void *m1, const void *m2)
 {
        const struct html_tag          *p1 = m1;
@@ -449,7 +449,7 @@ tag_cmp (const void *m1, const void *m2)
        return g_ascii_strcasecmp (p1->name, p2->name);
 }
 
-static int
+static gint
 entity_cmp (const void *m1, const void *m2)
 {
        const entity                   *p1 = m1;
@@ -458,7 +458,7 @@ entity_cmp (const void *m1, const void *m2)
        return g_ascii_strcasecmp (p1->name, p2->name);
 }
 
-static int
+static gint
 entity_cmp_num (const void *m1, const void *m2)
 {
        const entity                   *p1 = m1;
@@ -468,13 +468,13 @@ entity_cmp_num (const void *m1, const void *m2)
 }
 
 static GNode                   *
-construct_html_node (memory_pool_t * pool, char *text)
+construct_html_node (memory_pool_t * pool, gchar *text)
 {
        struct html_node               *html;
        GNode                          *n = NULL;
        struct html_tag                 key, *found;
-       char                            t;
-       int                             taglen = strlen (text);
+       gchar                           t;
+       gint                            taglen = strlen (text);
 
        if (text == NULL || *text == '\0') {
                return NULL;
@@ -551,7 +551,7 @@ check_balance (GNode * node, GNode ** cur_level)
 }
 
 struct html_tag                *
-get_tag_by_name (const char *name)
+get_tag_by_name (const gchar *name)
 {
        struct html_tag                 key;
 
@@ -562,14 +562,14 @@ get_tag_by_name (const char *name)
 
 /* Decode HTML entitles in text */
 void
-decode_entitles (char *s, guint * len)
+decode_entitles (gchar *s, guint * len)
 {
        guint                           l, rep_len;
-       char                           *t = s;  /* t - tortoise */
-       char                           *h = s;  /* h - hare     */
-       char                           *e = s;
-       char                           *end_ptr;
-       int                             state = 0, val, base;
+       gchar                           *t = s; /* t - tortoise */
+       gchar                           *h = s; /* h - hare     */
+       gchar                           *e = s;
+       gchar                           *end_ptr;
+       gint                            state = 0, val, base;
        entity                         *found, key;
 
        if (len == NULL || *len == 0) {
@@ -662,7 +662,7 @@ decode_entitles (char *s, guint * len)
 static gchar *
 html_strcasestr (const gchar *s, const gchar *find)
 {
-       char c, sc;
+       gchar                           c, sc;
        size_t len;
 
        if ((c = *find++) != 0) {
@@ -680,11 +680,11 @@ html_strcasestr (const gchar *s, const gchar *find)
 }
 
 static void
-parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t id, char *tag_text)
+parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t id, gchar *tag_text)
 {
-       char                           *c = NULL, *p;
-       int                             len, rc;
-       char                           *url_text;
+       gchar                           *c = NULL, *p;
+       gint                            len, rc;
+       gchar                           *url_text;
        struct uri                     *url;
        gboolean                        got_single_quote = FALSE, got_double_quote = FALSE;
 
@@ -770,7 +770,7 @@ parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t i
 }
 
 gboolean
-add_html_node (struct worker_task *task, memory_pool_t * pool, struct mime_text_part *part, char *tag_text, GNode ** cur_level)
+add_html_node (struct worker_task *task, memory_pool_t * pool, struct mime_text_part *part, gchar *tag_text, GNode ** cur_level)
 {
        GNode                          *new;
        struct html_node               *data;
index e81a9d11c89366c63e51955b00dde6d7f5bf6e3d..048598f3749e2c7630f262591cd66a67f51e691d 100644 (file)
@@ -195,20 +195,20 @@ typedef enum
 
 struct html_tag {
        tag_id_t id;
-       const char *name;
-       int flags;
+       const gchar *name;
+       gint flags;
 };
 
 struct html_node {
        struct html_tag *tag;
-       int flags;
+       gint flags;
 };
 
 /* Forwarded declaration */
 struct worker_task;
 
-gboolean add_html_node (struct worker_task *task, memory_pool_t *pool, struct mime_text_part *part, char *tag_text, GNode **cur_level);
-struct html_tag * get_tag_by_name (const char *name);
-void decode_entitles (char *s, guint *len);
+gboolean add_html_node (struct worker_task *task, memory_pool_t *pool, struct mime_text_part *part, gchar *tag_text, GNode **cur_level);
+struct html_tag * get_tag_by_name (const gchar *name);
+void decode_entitles (gchar *s, guint *len);
 
 #endif
index d071c38e717f941643df9496b38220d358c9713e..6613a77379af934aae66dfe3bcca1d1f5d17e110 100644 (file)
@@ -231,7 +231,7 @@ process_image (struct worker_task *task, struct mime_part *part)
        }
 }
 
-const char *
+const gchar *
 image_type_str (enum known_image_types type)
 {
        switch (type) {
index f7616a680bf01e69e3dc9b3f10468097168d1bf0..b807ab24da8a11dd570975c02d0789217cf3ac71 100644 (file)
@@ -17,10 +17,10 @@ struct rspamd_image {
        GByteArray *data;
        guint32 width;
        guint32 height;
-       const char *filename;
+       const gchar *filename;
 };
 
 void process_images (struct worker_task *task);
-const char *image_type_str (enum known_image_types type);
+const gchar *image_type_str (enum known_image_types type);
 
 #endif /* IMAGES_H_ */
index c3d1bf9019205d7584c0388d4a4d3d5a43a0be52..6e7d38c99b5bd2d120048d0e11a08f80658158c0 100644 (file)
 #include "modules.h"
 #include "message.h"
 
-static char                     greetingbuf[1024];
+static gchar                     greetingbuf[1024];
 static struct timeval           io_tv;
 
 static gboolean                 lmtp_write_socket (void *arg);
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        switch (signo) {
@@ -61,7 +61,7 @@ sig_handler (int signo, siginfo_t *info, void *unused)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (int fd, short what, void *arg)
+sigusr_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -221,14 +221,14 @@ lmtp_err_socket (GError * err, void *arg)
  * Accept new connection and construct task
  */
 static void
-accept_socket (int fd, short what, void *arg)
+accept_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        union sa_union                  su;
        struct worker_task             *new_task;
        struct rspamd_lmtp_proto       *lmtp;
        socklen_t                       addrlen = sizeof (su.ss);
-       int                             nfd;
+       gint                            nfd;
 
        if ((nfd = accept_from_socket (fd, (struct sockaddr *)&su.ss, &addrlen)) == -1) {
                msg_warn ("accept failed: %s", strerror (errno));
@@ -274,9 +274,9 @@ void
 start_lmtp_worker (struct rspamd_worker *worker)
 {
        struct sigaction                signals;
-       int                             i;
-       char                           *hostbuf;
-       long int                        hostmax;
+       gint                            i;
+       gchar                          *hostbuf;
+       gsize                           hostmax;
 
        worker->srv->pid = getpid ();
        worker->srv->type = TYPE_LMTP;
index 1bf56f6775a9b9e5f586142e2a80254eb2cf87ea..b81daf2401c22ba80d4cde19ec448a9862f14146 100644 (file)
@@ -58,18 +58,18 @@ static f_str_t                  data_dot = {
        .len = sizeof (".\r\n") - 1
 };
 
-static const char              *mail_regexp = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
+static const gchar              *mail_regexp = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
 static GRegex                  *mail_re = NULL;
 
 /*
  * Extract e-mail from read line 
  * return <> if no valid address detected
  */
-static char                    *
+static gchar                    *
 extract_mail (memory_pool_t * pool, f_str_t * line)
 {
        GError                         *err = NULL;
-       char                           *match;
+       gchar                           *match;
        GMatchInfo                     *info;
 
        if (mail_re == NULL) {
@@ -89,10 +89,10 @@ extract_mail (memory_pool_t * pool, f_str_t * line)
 }
 
 static gboolean
-out_lmtp_reply (struct worker_task *task, int code, char *rcode, char *msg)
+out_lmtp_reply (struct worker_task *task, gint code, gchar *rcode, gchar *msg)
 {
-       char                            outbuf[OUTBUFSIZ];
-       int                             r;
+       gchar                           outbuf[OUTBUFSIZ];
+       gint                            r;
 
        if (*rcode == '\0') {
                r = rspamd_snprintf (outbuf, OUTBUFSIZ, "%d %s\r\n", code, msg);
@@ -106,12 +106,12 @@ out_lmtp_reply (struct worker_task *task, int code, char *rcode, char *msg)
        return TRUE;
 }
 
-int
+gint
 read_lmtp_input_line (struct rspamd_lmtp_proto *lmtp, f_str_t * line)
 {
-       char                           *c, *rcpt;
+       gchar                           *c, *rcpt;
        f_str_t                         fstr;
-       unsigned int                    i = 0, l = 0, size;
+       guint                           i = 0, l = 0, size;
 
        switch (lmtp->state) {
        case LMTP_READ_LHLO:
@@ -267,7 +267,7 @@ struct mta_callback_data {
 static                          gboolean
 parse_mta_str (f_str_t * in, struct mta_callback_data *cd)
 {
-       int                             r;
+       gint                            r;
        static f_str_t                  okres1 = {
                .begin = "250 ",
                .len = sizeof ("250 ") - 1,
@@ -320,8 +320,8 @@ static                          gboolean
 mta_read_socket (f_str_t * in, void *arg)
 {
        struct mta_callback_data       *cd = (struct mta_callback_data *)arg;
-       char                            outbuf[1024], *hostbuf, *c;
-       int                             hostmax, r;
+       gchar                           outbuf[1024], *hostbuf, *c;
+       gint                            hostmax, r;
        GList                          *cur;
        static f_str_t                  contres1 = {
                .begin = "250-",
@@ -378,7 +378,7 @@ mta_read_socket (f_str_t * in, void *arg)
                cur = g_list_first (cd->task->rcpt);
                r = 0;
                while (cur) {
-                       r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "RCPT TO: <%s>" CRLF, (char *)cur->data);
+                       r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "RCPT TO: <%s>" CRLF, (gchar *)cur->data);
                        cur = g_list_next (cur);
                }
 
@@ -443,10 +443,10 @@ mta_err_socket (GError * err, void *arg)
 /*
  * Deliver mail via smtp or lmtp
  */
-static int
+static gint
 lmtp_deliver_mta (struct worker_task *task)
 {
-       int                             sock;
+       gint                            sock;
        struct sockaddr_un             *un;
        struct mta_callback_data       *cd;
 
@@ -468,10 +468,10 @@ lmtp_deliver_mta (struct worker_task *task)
        return 0;
 }
 
-static char                    *
+static gchar                    *
 format_lda_args (struct worker_task *task)
 {
-       char                           *res, *c, *r;
+       gchar                           *res, *c, *r;
        size_t                          len;
        GList                          *rcpt;
        gboolean                        got_args = FALSE;
@@ -497,7 +497,7 @@ format_lda_args (struct worker_task *task)
                                rcpt = g_list_first (task->rcpt);
                                len -= 2;
                                while (rcpt) {
-                                       len += strlen ((char *)rcpt->data) + 1;
+                                       len += strlen ((gchar *)rcpt->data) + 1;
                                        rcpt = g_list_next (rcpt);
                                }
                                break;
@@ -528,7 +528,7 @@ format_lda_args (struct worker_task *task)
                                c += 2;
                                rcpt = g_list_first (task->rcpt);
                                while (rcpt) {
-                                       len = strlen ((char *)rcpt->data) + 1;
+                                       len = strlen ((gchar *)rcpt->data) + 1;
                                        memcpy (r, rcpt->data, len);
                                        r += len;
                                        *r++ = ' ';
@@ -552,12 +552,12 @@ format_lda_args (struct worker_task *task)
        return res;
 }
 
-static int
+static gint
 lmtp_deliver_lda (struct worker_task *task)
 {
-       char                           *args, **argv;
+       gchar                           *args, **argv;
        GMimeStream                    *stream;
-       int                             rc, ecode, p[2], argc;
+       gint                            rc, ecode, p[2], argc;
        pid_t                           cpid, pid;
 
        if ((args = format_lda_args (task)) == NULL) {
@@ -649,7 +649,7 @@ lmtp_deliver_lda (struct worker_task *task)
        return -1;
 }
 
-int
+gint
 lmtp_deliver_message (struct worker_task *task)
 {
        if (task->cfg->deliver_agent_path != NULL) {
@@ -662,10 +662,10 @@ lmtp_deliver_message (struct worker_task *task)
        }
 }
 
-int
+gint
 write_lmtp_reply (struct rspamd_lmtp_proto *lmtp)
 {
-       int                             r;
+       gint                            r;
        struct worker_task             *task = lmtp->task;
 
        debug_task ("writing reply to client");
index 24cba2c5e0b2f638b270eda13867f6cac10c9a2e..11d994e698de442debcdcfcfabc171c24d863df5 100644 (file)
@@ -25,20 +25,20 @@ struct rspamd_lmtp_proto {
  * @param line line of user's input
  * @return 0 if line was successfully parsed and -1 if we have protocol error
  */
-int read_lmtp_input_line (struct rspamd_lmtp_proto *lmtp, f_str_t *line);
+gint read_lmtp_input_line (struct rspamd_lmtp_proto *lmtp, f_str_t *line);
 
 /**
  * Deliver message via lmtp/smtp or pipe to LDA
  * @param task task object
  * @return 0 if we wrote message and -1 if there was some error
  */
-int lmtp_deliver_message (struct worker_task *task);
+gint lmtp_deliver_message (struct worker_task *task);
 
 /**
  * Write reply for specified lmtp object
  * @param lmtp lmtp object
  * @return 0 if we wrote reply and -1 if there was some error
  */
-int write_lmtp_reply (struct rspamd_lmtp_proto *lmtp);
+gint write_lmtp_reply (struct rspamd_lmtp_proto *lmtp);
 
 #endif
index c7626a03c1f64574028b5b966d8dd92550b40f93..01e0210ec8a514ad5f6fcc3436d400c0810ef7b0 100644 (file)
@@ -41,11 +41,11 @@ typedef struct rspamd_logger_s {
        rspamd_log_func_t        log_func;
        struct config_file              *cfg;
        struct {
-               uint32_t size;
-               uint32_t used;
+               guint32                         size;
+               guint32                         used;
                u_char *buf;
        }                        io_buf;
-       int                      fd;
+       gint                            fd;
        gboolean                 is_buffered;
        gboolean                 enabled;
        gboolean                 is_debug;
@@ -55,15 +55,15 @@ typedef struct rspamd_logger_s {
        pid_t                    pid;
        enum process_type                process_type;
        radix_tree_t            *debug_ip;
-       uint32_t                 last_line_cksum;
-       uint32_t                 repeats;
+       guint32                         last_line_cksum;
+       guint32                         repeats;
        gchar                   *saved_message;
        gchar                   *saved_function;
 } rspamd_logger_t;
 
 rspamd_logger_t *rspamd_log = NULL;
 
-static const char lf_chr = '\n';
+static const gchar lf_chr = '\n';
 
 static void
 syslog_log_function (const gchar * log_domain, const gchar *function, 
@@ -74,16 +74,16 @@ file_log_function (const gchar * log_domain, const gchar *function,
                                        GLogLevelFlags log_level, const gchar * message, 
                                        gboolean forced, gpointer arg);
 
-static inline uint32_t
+static inline guint32
 rspamd_log_calculate_cksum (const gchar *message, size_t mlen)
 {
        const gchar                    *bp = message;
        const gchar                    *be = bp + mlen;
-       uint32_t                        hval = 0;
+       guint32                         hval = 0;
 
     while (bp < be) {
                hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
-               hval ^= (uint32_t)*bp++;
+               hval ^= (guint32)*bp++;
     }
 
     /* return our new hash value */
@@ -92,12 +92,12 @@ rspamd_log_calculate_cksum (const gchar *message, size_t mlen)
 }
 
 static void
-direct_write_log_line (void *data, int count, gboolean is_iov)
+direct_write_log_line (void *data, gint count, gboolean is_iov)
 {
-       char                           errmsg[128];
+       gchar                           errmsg[128];
        struct iovec                  *iov;
-       const char                    *line;
-       int                            r;
+       const gchar                    *line;
+       gint                            r;
        
        if (rspamd_log->enabled) {
                if (is_iov) {
@@ -105,7 +105,7 @@ direct_write_log_line (void *data, int count, gboolean is_iov)
                        r = writev (rspamd_log->fd, iov, count);
                }
                else {
-                       line = (const char *)data;
+                       line = (const gchar *)data;
                        r = write (rspamd_log->fd, line, count);
                }
                if (r == -1) {
@@ -136,7 +136,7 @@ direct_write_log_line (void *data, int count, gboolean is_iov)
 }
 
 /* Logging utility functions */
-int
+gint
 open_log (void)
 {
 
@@ -163,7 +163,7 @@ open_log (void)
 void
 close_log (void)
 {
-       char            tmpbuf[256];
+       gchar                           tmpbuf[256];
        flush_log_buf ();
 
        switch (rspamd_log->type) {
@@ -204,10 +204,10 @@ close_log (void)
 void
 rspamd_set_logger (enum rspamd_log_type type, enum process_type ptype, struct config_file *cfg)
 {
-       char                          **strvec, *p, *err;
-       int                             num, i, k;
+       gchar                           **strvec, *p, *err;
+       gint                            num, i, k;
        struct in_addr                  addr;
-       uint32_t                        mask = 0xFFFFFFFF;
+       guint32                         mask = 0xFFFFFFFF;
 
        if (rspamd_log == NULL) {
                rspamd_log = g_malloc (sizeof (rspamd_logger_t));
@@ -286,7 +286,7 @@ rspamd_set_logger (enum rspamd_log_type type, enum process_type ptype, struct co
        }
 }
 
-int
+gint
 reopen_log (void)
 {
        close_log ();
@@ -316,9 +316,9 @@ flush_log_buf (void)
 
 
 void
-rspamd_common_log_function (GLogLevelFlags log_level, const char *function, const char *fmt, ...)
+rspamd_common_log_function (GLogLevelFlags log_level, const gchar *function, const gchar *fmt, ...)
 {
-       static char                     logbuf[BUFSIZ];
+       static gchar                     logbuf[BUFSIZ];
        va_list                         vp;
     u_char                         *end;
 
@@ -334,9 +334,9 @@ rspamd_common_log_function (GLogLevelFlags log_level, const char *function, cons
 
 /* Fill buffer with message (limits must be checked BEFORE this call) */
 static void
-fill_buffer (const struct iovec *iov, int iovcnt)
+fill_buffer (const struct iovec *iov, gint iovcnt)
 {
-       int                            i;
+       gint                            i;
 
        for (i = 0; i < iovcnt; i ++) {
                memcpy (rspamd_log->io_buf.buf + rspamd_log->io_buf.used, iov[i].iov_base, iov[i].iov_len);
@@ -347,10 +347,10 @@ fill_buffer (const struct iovec *iov, int iovcnt)
 
 /* Write message to buffer or to file */
 static void
-file_log_helper (const struct iovec *iov, int iovcnt)
+file_log_helper (const struct iovec *iov, gint iovcnt)
 {
        size_t                         len = 0;
-       int                            i;
+       gint                            i;
 
        if (! rspamd_log->is_buffered) {
                /* Write string directly */
@@ -424,14 +424,14 @@ syslog_log_function (const gchar * log_domain, const gchar *function, GLogLevelF
 static void
 file_log_function (const gchar * log_domain, const gchar *function, GLogLevelFlags log_level, const gchar * message, gboolean forced, gpointer arg)
 {
-       char                            tmpbuf[256], timebuf[32];
+       gchar                           tmpbuf[256], timebuf[32];
        time_t                          now;
        struct tm                      *tms;
        struct iovec                    iov[3];
-       int                             r;
-       uint32_t                        cksum;
+       gint                            r;
+       guint32                         cksum;
        size_t                          mlen;
-       const char                     *cptype = NULL;
+       const gchar                     *cptype = NULL;
        gboolean                        got_time = FALSE;
 
        if (! rspamd_log->enabled) {
@@ -548,9 +548,9 @@ file_log_function (const gchar * log_domain, const gchar *function, GLogLevelFla
 }
 
 void
-rspamd_conditional_debug (uint32_t addr, const char *function, const char *fmt, ...) 
+rspamd_conditional_debug (guint32 addr, const gchar *function, const gchar *fmt, ...) 
 {
-       static char                     logbuf[BUFSIZ];
+       static gchar                     logbuf[BUFSIZ];
        va_list                         vp;
     u_char                         *end;
 
index f25da864550513a33860e66937c7c9cec9da2cf3..84c8a41ff1ade3cf2aa04eb5ada418ce4f7f100a 100644 (file)
@@ -29,7 +29,7 @@ void rspamd_set_logger (enum rspamd_log_type type, enum process_type ptype, stru
 /**
  * Open log file or initialize other structures
  */
-int open_log (void);
+gint open_log (void);
 /**
  * Close log file or destroy other structures
  */
@@ -37,7 +37,7 @@ void close_log (void);
 /**
  * Close and open log again
  */
-int reopen_log (void);
+gint reopen_log (void);
 /**
  * Set log pid
  */
@@ -55,12 +55,12 @@ void rspamd_glib_log_function (const gchar *log_domain, GLogLevelFlags log_level
 /**
  * Function with variable number of arguments support 
  */
-void rspamd_common_log_function (GLogLevelFlags log_level, const char *function, const char *fmt, ...);
+void rspamd_common_log_function (GLogLevelFlags log_level, const gchar *function, const gchar *fmt, ...);
 
 /**
  * Conditional debug function
  */
-void rspamd_conditional_debug (uint32_t addr, const char *function, const char *fmt, ...) ;
+void rspamd_conditional_debug (guint32 addr, const gchar *function, const gchar *fmt, ...) ;
 
 /**
  * Temporary turn on debug
index 799a603c066c317138a4b8adf3f0ffb218992ccf..b67466d7b82ea4c54b3c9a7973e406c0ac5315db 100644 (file)
@@ -68,7 +68,7 @@ lua_process_module (lua_State *L, const gchar *param, struct config_file *cfg)
 {
        GList                               *cur_opt;
        struct module_opt                   *cur;
-       const char                          *name;
+       const gchar                          *name;
        gboolean                             new_module = FALSE;
 
        /* Get module opt structure */
@@ -95,10 +95,10 @@ lua_process_module (lua_State *L, const gchar *param, struct config_file *cfg)
 
 /* Process single element */
 void
-lua_process_element (struct config_file *cfg, const char *name, struct module_opt *opt, int idx) 
+lua_process_element (struct config_file *cfg, const gchar *name, struct module_opt *opt, gint idx) 
 {
        lua_State                            *L = cfg->lua_state;
-       int                                   t;
+       gint                            t;
        double                               *num;
        gboolean                             *flag;
        
index 86378c5e57f385ae1b5a6823ce5b314653329202..f7ce173a71d8b0f2d079fd440ea1f61ca9d1e167 100644 (file)
@@ -48,7 +48,7 @@ static const struct luaL_reg    statfilelib_m[] = {
 
 struct classifier_callback_data {
        lua_State *L;
-       const char *name;
+       const gchar *name;
 };
 
 static struct statfile* lua_check_statfile (lua_State * L);
@@ -73,7 +73,7 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task
        struct classifier_config      **pccf;
        struct worker_task            **ptask;
        struct statfile                *st;
-       int                             i, len;
+       gint                            i, len;
 
        /* Go throught all callbacks and call them, appending results to list */
        cur = g_list_first (ccf->pre_callbacks);
@@ -153,12 +153,12 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_tas
 
 }
 
-static int
+static gint
 lua_classifier_register_pre_callback (lua_State *L)
 {
        struct classifier_config       *ccf = lua_check_classifier (L);
        struct classifier_callback_data *cd;
-       const char                     *name;
+       const gchar                     *name;
 
        if (ccf) {
                name = luaL_checkstring (L, 2);
@@ -174,12 +174,12 @@ lua_classifier_register_pre_callback (lua_State *L)
 
 }
 
-static int
+static gint
 lua_classifier_register_post_callback (lua_State *L)
 {
        struct classifier_config       *ccf = lua_check_classifier (L);
        struct classifier_callback_data *cd;
-       const char                     *name;
+       const gchar                     *name;
 
        if (ccf) {
                name = luaL_checkstring (L, 2);
@@ -195,7 +195,7 @@ lua_classifier_register_post_callback (lua_State *L)
 }
 
 /* Return table of statfiles indexed by theirs name */
-static int
+static gint
 lua_classifier_get_statfiles (lua_State *L)
 {
        struct classifier_config       *ccf = lua_check_classifier (L);
@@ -237,7 +237,7 @@ lua_check_statfile (lua_State * L)
 
 /* Open functions */
 
-int
+gint
 luaopen_classifier (lua_State * L)
 {
        lua_newclass (L, "rspamd{classifier}", classifierlib_m);
@@ -246,7 +246,7 @@ luaopen_classifier (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_statfile (lua_State * L)
 {
        lua_newclass (L, "rspamd{statfile}", statfilelib_m);
index adf26e686e07bbc2c676a49cb508ddaeca6247e1..38111ea38247f72370d984d3755308a844f2cdb8 100644 (file)
@@ -50,7 +50,7 @@ static const struct luaL_reg    loggerlib_m[] = {
 
 /* Util functions */
 void
-lua_newclass (lua_State * L, const char *classname, const struct luaL_reg *func)
+lua_newclass (lua_State * L, const gchar *classname, const struct luaL_reg *func)
 {
        luaL_newmetatable (L, classname);       /* mt */
        lua_pushstring (L, "__index");
@@ -64,10 +64,10 @@ lua_newclass (lua_State * L, const char *classname, const struct luaL_reg *func)
        luaL_openlib (L, NULL, func, 0);
 }
 
-int
+gint
 lua_class_tostring (lua_State * L)
 {
-       char                            buf[32];
+       gchar                           buf[32];
 
        if (!lua_getmetatable (L, 1)) {
                goto error;
@@ -99,7 +99,7 @@ lua_class_tostring (lua_State * L)
 
 
 void
-lua_setclass (lua_State * L, const char *classname, int objidx)
+lua_setclass (lua_State * L, const gchar *classname, gint objidx)
 {
        luaL_getmetatable (L, classname);
        if (objidx < 0) {
@@ -110,7 +110,7 @@ lua_setclass (lua_State * L, const char *classname, int objidx)
 
 /* assume that table is at the top */
 void
-lua_set_table_index (lua_State * L, const char *index, const char *value)
+lua_set_table_index (lua_State * L, const gchar *index, const gchar *value)
 {
 
        lua_pushstring (L, index);
@@ -119,10 +119,10 @@ lua_set_table_index (lua_State * L, const char *index, const char *value)
 }
 
 static void
-lua_common_log (GLogLevelFlags level, lua_State *L, const char *msg)
+lua_common_log (GLogLevelFlags level, lua_State *L, const gchar *msg)
 {
        lua_Debug                      d;
-       char                           func_buf[128], *p;
+       gchar                           func_buf[128], *p;
 
        if (lua_getstack (L, 1, &d) == 1) {
                (void)lua_getinfo(L, "Sl", &d);
@@ -151,37 +151,37 @@ lua_common_log (GLogLevelFlags level, lua_State *L, const char *msg)
 }
 
 /*** Logger interface ***/
-static int
+static gint
 lua_logger_err (lua_State * L)
 {
-       const char                     *msg;
+       const gchar                     *msg;
        msg = luaL_checkstring (L, 2);
        lua_common_log (G_LOG_LEVEL_CRITICAL, L, msg);
        return 1;
 }
 
-static int
+static gint
 lua_logger_warn (lua_State * L)
 {
-       const char                     *msg;
+       const gchar                     *msg;
        msg = luaL_checkstring (L, 2);
        lua_common_log (G_LOG_LEVEL_WARNING, L, msg);
        return 1;
 }
 
-static int
+static gint
 lua_logger_info (lua_State * L)
 {
-       const char                     *msg;
+       const gchar                     *msg;
        msg = luaL_checkstring (L, 2);
        lua_common_log (G_LOG_LEVEL_INFO, L, msg);
        return 1;
 }
 
-static int
+static gint
 lua_logger_debug (lua_State * L)
 {
-       const char                     *msg;
+       const gchar                     *msg;
        msg = luaL_checkstring (L, 2);
        lua_common_log (G_LOG_LEVEL_DEBUG, L, msg);
        return 1;
@@ -190,7 +190,7 @@ lua_logger_debug (lua_State * L)
 
 /*** Init functions ***/
 
-int
+gint
 luaopen_rspamd (lua_State * L)
 {
        luaL_openlib (L, "rspamd", null_reg, 0);
@@ -202,7 +202,7 @@ luaopen_rspamd (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_logger (lua_State * L)
 {
 
@@ -304,10 +304,10 @@ init_lua_filters (struct config_file *cfg)
 
 /* Callback functions */
 
-int
-lua_call_filter (const char *function, struct worker_task *task)
+gint
+lua_call_filter (const gchar *function, struct worker_task *task)
 {
-       int                             result;
+       gint                            result;
        struct worker_task            **ptask;
        lua_State                      *L = task->cfg->lua_state;
 
@@ -329,10 +329,10 @@ lua_call_filter (const char *function, struct worker_task *task)
        return result;
 }
 
-int
-lua_call_chain_filter (const char *function, struct worker_task *task, int *marks, unsigned int number)
+gint
+lua_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number)
 {
-       int                             result, i;
+       gint                            result, i;
        lua_State                      *L = task->cfg->lua_state;
 
        lua_getglobal (L, function);
@@ -355,13 +355,13 @@ lua_call_chain_filter (const char *function, struct worker_task *task, int *mark
 
 /* Call custom lua function in rspamd expression */
 gboolean 
-lua_call_expression_func (const char *function, struct worker_task *task, GList *args, gboolean *res)
+lua_call_expression_func (const gchar *function, struct worker_task *task, GList *args, gboolean *res)
 {
        lua_State                      *L = task->cfg->lua_state;
        struct worker_task            **ptask;
        GList                          *cur;
        struct expression_argument     *arg;
-       int                             nargs = 0;
+       gint                            nargs = 0;
 
        lua_getglobal (L, function);
        ptask = lua_newuserdata (L, sizeof (struct worker_task *));
@@ -409,7 +409,7 @@ lua_call_expression_func (const char *function, struct worker_task *task, GList
 struct consolidation_callback_data {
        struct worker_task             *task;
        double                          score;
-       const char                     *func;
+       const gchar                     *func;
 };
 
 static void
@@ -422,7 +422,7 @@ lua_consolidation_callback (gpointer key, gpointer value, gpointer arg)
 
        lua_getglobal (L, data->func);
 
-       lua_pushstring (L, (const char *)key);
+       lua_pushstring (L, (const gchar *)key);
        lua_pushnumber (L, s->score);
        if (lua_pcall (L, 2, 1, 0) != 0) {
                msg_info ("call to %s failed", data->func);
@@ -438,7 +438,7 @@ lua_consolidation_callback (gpointer key, gpointer value, gpointer arg)
 }
 
 double
-lua_consolidation_func (struct worker_task *task, const char *metric_name, const char *function_name)
+lua_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *function_name)
 {
        struct metric_result           *metric_res;
        double                          res = 0.;
index 105fb7ca235fb1ca702eb0402f2f9215cead5600..ede42562a85474305b3079f12a7087254831fb09 100644 (file)
 #include <lualib.h>
 
 /* Interface definitions */
-#define LUA_FUNCTION_DEF(class, name) static int lua_##class##_##name(lua_State *L)
+#define LUA_FUNCTION_DEF(class, name) static gint lua_##class##_##name(lua_State *L)
 #define LUA_INTERFACE_DEF(class, name) { #name, lua_##class##_##name }
 
 extern const luaL_reg null_reg[];
 
 /* Common utility functions */
-void lua_newclass (lua_State *L, const char *classname, const struct luaL_reg *func);
-void lua_setclass (lua_State *L, const char *classname, int objidx);
-void lua_set_table_index (lua_State *L, const char *index, const char *value);
-int lua_class_tostring (lua_State *L);
-int luaopen_message (lua_State *L);
-int luaopen_task (lua_State *L);
-int luaopen_config (lua_State *L);
-int luaopen_metric (lua_State *L);
-int luaopen_radix (lua_State *L);
-int luaopen_hash_table (lua_State *L);
-int luaopen_trie (lua_State * L);
-int luaopen_textpart (lua_State *L);
-int luaopen_image (lua_State *L);
-int luaopen_classifier (lua_State *L);
-int luaopen_statfile (lua_State * L);
+void lua_newclass (lua_State *L, const gchar *classname, const struct luaL_reg *func);
+void lua_setclass (lua_State *L, const gchar *classname, gint objidx);
+void lua_set_table_index (lua_State *L, const gchar *index, const gchar *value);
+gint lua_class_tostring (lua_State *L);
+gint luaopen_message (lua_State *L);
+gint luaopen_task (lua_State *L);
+gint luaopen_config (lua_State *L);
+gint luaopen_metric (lua_State *L);
+gint luaopen_radix (lua_State *L);
+gint luaopen_hash_table (lua_State *L);
+gint luaopen_trie (lua_State * L);
+gint luaopen_textpart (lua_State *L);
+gint luaopen_image (lua_State *L);
+gint luaopen_classifier (lua_State *L);
+gint luaopen_statfile (lua_State * L);
 void init_lua (struct config_file *cfg);
 gboolean init_lua_filters (struct config_file *cfg);
 
 /* Filters functions */
-int lua_call_filter (const char *function, struct worker_task *task);
-int lua_call_chain_filter (const char *function, struct worker_task *task, int *marks, unsigned int number);
-double lua_consolidation_func (struct worker_task *task, const char *metric_name, const char *function_name);
-gboolean lua_call_expression_func (const char *function, struct worker_task *task, GList *args, gboolean *res);
+gint lua_call_filter (const gchar *function, struct worker_task *task);
+gint lua_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number);
+double lua_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *function_name);
+gboolean lua_call_expression_func (const gchar *function, struct worker_task *task, GList *args, gboolean *res);
 void lua_call_post_filters (struct worker_task *task);
-void add_luabuf (const char *line);
+void add_luabuf (const gchar *line);
 
 /* Classify functions */
 GList *call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task *task);
@@ -51,7 +51,7 @@ double lua_normalizer_func (struct config_file *cfg, long double score, void *pa
 
 /* Config file functions */
 void lua_post_load_config (struct config_file *cfg);
-void lua_process_element (struct config_file *cfg, const char *name, struct module_opt *opt, int idx);
+void lua_process_element (struct config_file *cfg, const gchar *name, struct module_opt *opt, gint idx);
 gboolean lua_handle_param (struct worker_task *task, gchar *mname, gchar *optname, 
                                                        enum lua_var_type expected_type, gpointer *res);
 
index a247bbbf7bbce1a3281a5eafe1b7778d6ba86c3a..92eaf0b2051e9d7f2573566ff4b9aa8e49fc00ce 100644 (file)
@@ -121,18 +121,18 @@ lua_check_trie (lua_State * L)
 }
 
 /*** Config functions ***/
-static int
+static gint
 lua_config_get_module_opt (lua_State * L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *mname, *optname, *val;
+       const gchar                     *mname, *optname, *val;
 
        if (cfg) {
                mname = luaL_checkstring (L, 2);
                optname = luaL_checkstring (L, 3);
 
                if (mname && optname) {
-                       val = get_module_opt (cfg, (char *)mname, (char *)optname);
+                       val = get_module_opt (cfg, (gchar *)mname, (gchar *)optname);
                        if (val) {
                                lua_pushstring (L, val);
                                return 1;
@@ -143,7 +143,7 @@ lua_config_get_module_opt (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 opt_compare (gconstpointer a, gconstpointer b)
 {
        const struct module_opt        *o1 = a,
@@ -152,14 +152,14 @@ opt_compare (gconstpointer a, gconstpointer b)
        return g_ascii_strcasecmp (o1->param, o2->param);
 }
 
-static int
+static gint
 lua_config_get_all_opt (lua_State * L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *mname;
+       const gchar                     *mname;
        GList                          *cur_opt, *next_opt;
        struct module_opt              *opt, *tmp;
-       int                             i;
+       gint                            i;
 
        if (cfg) {
                mname = luaL_checkstring (L, 2);
@@ -227,12 +227,12 @@ lua_config_get_all_opt (lua_State * L)
 }
 
 
-static int
+static gint
 lua_config_get_classifier (lua_State * L)
 {
        struct config_file             *cfg = lua_check_config (L);
        struct classifier_config       *clc = NULL, **pclc = NULL;
-       const char                     *name;
+       const gchar                     *name;
        GList                          *cur;
 
        if (cfg) {
@@ -261,7 +261,7 @@ lua_config_get_classifier (lua_State * L)
 }
 
 struct lua_callback_data {
-       const char                     *name;
+       const gchar                     *name;
        lua_State                      *L;
 };
 
@@ -270,7 +270,7 @@ lua_config_function_callback (struct worker_task *task, GList *args, void *user_
 {
        struct lua_callback_data       *cd = user_data;
        struct worker_task            **ptask;
-       int                             i = 1;
+       gint                            i = 1;
        struct expression_argument     *arg;
        GList                          *cur;
        gboolean                        res = FALSE;
@@ -283,7 +283,7 @@ lua_config_function_callback (struct worker_task *task, GList *args, void *user_
        cur = args;
        while (cur) {
                arg = get_function_arg (cur->data, task, TRUE);
-               lua_pushstring (cd->L, (const char *)arg->data);
+               lua_pushstring (cd->L, (const gchar *)arg->data);
                cur = g_list_next (cur);
                i ++;
        }
@@ -300,11 +300,11 @@ lua_config_function_callback (struct worker_task *task, GList *args, void *user_
        return res;
 }
 
-static int
+static gint
 lua_config_register_function (lua_State *L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *name, *callback;
+       const gchar                     *name, *callback;
        struct lua_callback_data       *cd;
        
        if (cfg) {
@@ -343,11 +343,11 @@ lua_call_post_filters (struct worker_task *task)
        }
 }
 
-static int
+static gint
 lua_config_register_post_filter (lua_State *L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *callback;
+       const gchar                     *callback;
        struct lua_callback_data       *cd;
 
        if (cfg) {
@@ -363,11 +363,11 @@ lua_config_register_post_filter (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_config_add_radix_map (lua_State *L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *map_line;
+       const gchar                     *map_line;
        radix_tree_t                   **r, ***ud;
 
        if (cfg) {
@@ -393,11 +393,11 @@ lua_config_add_radix_map (lua_State *L)
 
 }
 
-static int
+static gint
 lua_config_add_hash_map (lua_State *L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *map_line;
+       const gchar                     *map_line;
        GHashTable                    **r, ***ud;
 
        if (cfg) {
@@ -442,11 +442,11 @@ lua_metric_symbol_callback (struct worker_task *task, gpointer ud)
        }
 }
 
-static int
+static gint
 lua_config_register_symbol (lua_State * L)
 {
        struct config_file             *cfg = lua_check_config (L);
-       const char                     *name, *callback;
+       const gchar                     *name, *callback;
        double                          weight;
        struct lua_callback_data       *cd;
 
@@ -465,11 +465,11 @@ lua_config_register_symbol (lua_State * L)
 }
 
 /* Radix and hash table functions */
-static int
+static gint
 lua_radix_get_key (lua_State * L)
 {
        radix_tree_t                  *radix = lua_check_radix (L);
-       uint32_t                       key;
+       guint32                         key;
 
        if (radix) {
                key = luaL_checkint (L, 2);
@@ -484,11 +484,11 @@ lua_radix_get_key (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_hash_table_get_key (lua_State * L)
 {
        GHashTable                    *tbl = lua_check_hash_table (L);
-       const char                    *key;
+       const gchar                    *key;
 
        if (tbl) {
                key = luaL_checkstring (L, 2);
@@ -504,7 +504,7 @@ lua_hash_table_get_key (lua_State * L)
 }
 
 /* Trie functions */
-static int
+static gint
 lua_trie_create (lua_State *L)
 {
        rspamd_trie_t                 *trie, **ptrie;
@@ -523,7 +523,7 @@ lua_trie_create (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_trie_add_pattern (lua_State *L)
 {
        rspamd_trie_t                 *trie = lua_check_trie (L);
@@ -545,7 +545,7 @@ lua_trie_add_pattern (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_trie_search_text (lua_State *L)
 {
        rspamd_trie_t                 *trie = lua_check_trie (L);
@@ -573,7 +573,7 @@ lua_trie_search_text (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_trie_search_task (lua_State *L)
 {
        rspamd_trie_t                 *trie = lua_check_trie (L);
@@ -614,7 +614,7 @@ lua_trie_search_task (lua_State *L)
 }
 /* Init functions */
 
-int
+gint
 luaopen_config (lua_State * L)
 {
        lua_newclass (L, "rspamd{config}", configlib_m);
@@ -623,7 +623,7 @@ luaopen_config (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_radix (lua_State * L)
 {
        lua_newclass (L, "rspamd{radix}", radixlib_m);
@@ -632,7 +632,7 @@ luaopen_radix (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_hash_table (lua_State * L)
 {
        lua_newclass (L, "rspamd{hash_table}", hashlib_m);
@@ -641,7 +641,7 @@ luaopen_hash_table (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_trie (lua_State * L)
 {
        lua_newclass (L, "rspamd{trie}", trielib_m);
index 98a4ae6ede48231640f1e049118365cfe7dff5cd..04adec24a2502d21848cb9469c9684ad6acd85eb 100644 (file)
@@ -27,7 +27,7 @@
 #include "../message.h"
 
 #define LUA_GMIME_BRIDGE_GET(class, name, mime_class)                                                                  \
-static int                                                                                                                                                             \
+static gint                                                                                                                                                            \
 lua_##class##_##name(lua_State *L)                                                                                                             \
 {                                                                                                                                                                              \
        GMime##mime_class *obj = lua_check_##class(L);                                                                          \
@@ -41,10 +41,10 @@ lua_##class##_##name(lua_State *L)                                                                                                          \
 }
 
 #define LUA_GMIME_BRIDGE_SET(class, name, mime_class)                                                                  \
-static int                                                                                                                                                             \
+static gint                                                                                                                                                            \
 lua_##class##_##name(lua_State *L)                                                                                                             \
 {                                                                                                                                                                              \
-       const char *str;                                                                                                                                        \
+       const gchar *str;                                                                                                                                       \
        GMime##mime_class *obj = lua_check_##class(L);                                                                          \
        if (obj != NULL) {                                                                                                                                      \
                str = luaL_checkstring (L, 2);                                                                                                  \
@@ -105,13 +105,13 @@ LUA_GMIME_BRIDGE_SET (message, set_sender, Message)
 LUA_GMIME_BRIDGE_GET (message, get_reply_to, Message)
 LUA_GMIME_BRIDGE_SET (message, set_reply_to, Message)
 
-static int
+static gint
 lua_message_get_header (lua_State * L)
 {
-       const char                     *headern;
+       const gchar                     *headern;
        GMimeMessage                   *obj = lua_check_message (L);
        GList                          *res = NULL, *cur;
-       int                             i = 1;
+       gint                            i = 1;
 
        if (obj != NULL) {
                headern = luaL_checkstring (L, 2);
@@ -121,7 +121,7 @@ lua_message_get_header (lua_State * L)
                                cur = res;
                                lua_newtable (L);
                                while (cur) {
-                                       lua_pushstring (L, (const char *)cur->data);
+                                       lua_pushstring (L, (const gchar *)cur->data);
                                        lua_rawseti (L, -2, i++);
                                        g_free (cur->data);
                                        cur = g_list_next (cur);
@@ -144,10 +144,10 @@ lua_message_get_header (lua_State * L)
 }
 
 
-static int
+static gint
 lua_message_set_header (lua_State * L)
 {
-       const char                     *headern, *headerv;
+       const gchar                     *headern, *headerv;
        GMimeMessage                   *obj = lua_check_message (L);
 
        if (obj != NULL) {
@@ -168,7 +168,7 @@ lua_message_set_header (lua_State * L)
 }
 
 
-int
+gint
 luaopen_message (lua_State * L)
 {
        lua_newclass (L, "rspamd{message}", msglib_m);
index cb9433d5e958984a61157dffc8dd347b2701b3ff..c5adedcfe056b3852e0e6dd37bff95599034cfd3 100644 (file)
@@ -39,7 +39,7 @@
 #include "../statfile_sync.h"
 
 extern stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf,
-               const char *symbol, struct statfile **st, gboolean try_create);
+               const gchar *symbol, struct statfile **st, gboolean try_create);
 
 /* Task methods */
 LUA_FUNCTION_DEF (task, get_message);
@@ -148,7 +148,7 @@ lua_check_image (lua_State * L)
 }
 
 /*** Task interface    ***/
-static int
+static gint
 lua_task_get_message (lua_State * L)
 {
        GMimeMessage                  **pmsg;
@@ -163,14 +163,14 @@ lua_task_get_message (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_task_insert_result (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
-       const char                     *symbol_name, *param;
+       const gchar                     *symbol_name, *param;
        double                          flag;
        GList                          *params = NULL;
-       int                             i, top;
+       gint                            i, top;
 
        if (task != NULL) {
                symbol_name = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 2));
@@ -187,10 +187,10 @@ lua_task_insert_result (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_urls (lua_State * L)
 {
-       int                             i = 1;
+       gint                            i = 1;
        struct worker_task             *task = lua_check_task (L);
        GList                          *cur;
        struct uri                     *url;
@@ -209,10 +209,10 @@ lua_task_get_urls (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_text_parts (lua_State * L)
 {
-       int                             i = 1;
+       gint                            i = 1;
        struct worker_task             *task = lua_check_task (L);
        GList                          *cur;
        struct mime_text_part          *part, **ppart;
@@ -235,7 +235,7 @@ lua_task_get_text_parts (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_raw_headers (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -250,13 +250,13 @@ lua_task_get_raw_headers (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_received_headers (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
        GList                          *cur;
        struct received_header         *rh;
-       int                             i = 1;
+       gint                            i = 1;
 
        if (task) {
                lua_newtable (L);
@@ -283,15 +283,15 @@ lua_task_get_received_headers (lua_State * L)
 struct lua_dns_callback_data {
        lua_State                      *L;
        struct worker_task             *task;
-       const char                     *callback;
-       const char                     *to_resolve;
+       const gchar                     *callback;
+       const gchar                     *to_resolve;
 };
 
 static void
 lua_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
 {
        struct lua_dns_callback_data   *cd = arg;
-       int                             i = 0;
+       gint                            i = 0;
        struct in_addr                  ina;
        struct worker_task            **ptask;
        union rspamd_reply_element     *elt;
@@ -365,7 +365,7 @@ lua_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
        }
 }
 
-static int
+static gint
 lua_task_resolve_dns_a (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -388,7 +388,7 @@ lua_task_resolve_dns_a (lua_State * L)
        return 0;
 }
 
-static int
+static gint
 lua_task_resolve_dns_txt (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -411,7 +411,7 @@ lua_task_resolve_dns_txt (lua_State * L)
        return 0;
 }
 
-static int
+static gint
 lua_task_resolve_dns_ptr (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -436,23 +436,23 @@ lua_task_resolve_dns_ptr (lua_State * L)
        return 0;
 }
 
-static int
+static gint
 lua_task_call_rspamd_function (lua_State * L)
 {
        struct worker_task             *task = lua_check_task (L);
        struct expression_function      f;
-       int                             i, top;
+       gint                            i, top;
        gboolean                        res;
-       char                           *arg;
+       gchar                           *arg;
 
        if (task) {
-               f.name = (char *)luaL_checkstring (L, 2);
+               f.name = (gchar *)luaL_checkstring (L, 2);
                if (f.name) {
                        f.args = NULL;
                        top = lua_gettop (L);
                        /* Get arguments after function name */
                        for (i = 3; i <= top; i++) {
-                               arg = (char *)luaL_checkstring (L, i);
+                               arg = (gchar *)luaL_checkstring (L, i);
                                if (arg != NULL) {
                                        f.args = g_list_prepend (f.args, arg);
                                }
@@ -473,11 +473,11 @@ lua_task_call_rspamd_function (lua_State * L)
 
 }
 
-static int
+static gint
 lua_task_get_recipients (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
-       int                                 i = 1;
+       gint                            i = 1;
        GList                          *cur;
 
        if (task) {
@@ -485,7 +485,7 @@ lua_task_get_recipients (lua_State *L)
                if (cur != NULL) {
                        lua_newtable (L);
                        while (cur) {
-                               lua_pushstring (L, (char *)cur->data);
+                               lua_pushstring (L, (gchar *)cur->data);
                                lua_rawseti (L, -2, i++);
                                cur = g_list_next (cur);
                        }
@@ -497,14 +497,14 @@ lua_task_get_recipients (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_from (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
        
        if (task) {
                if (task->from != NULL) {
-                       lua_pushstring (L, (char *)task->from);
+                       lua_pushstring (L, (gchar *)task->from);
                        return 1;
                }
        }
@@ -513,7 +513,7 @@ lua_task_get_from (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_from_ip (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -529,7 +529,7 @@ lua_task_get_from_ip (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_from_ip_num (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -545,7 +545,7 @@ lua_task_get_from_ip_num (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_client_ip_num (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
@@ -561,14 +561,14 @@ lua_task_get_client_ip_num (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_helo (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
        
        if (task) {
                if (task->helo != NULL) {
-                       lua_pushstring (L, (char *)task->helo);
+                       lua_pushstring (L, (gchar *)task->helo);
                        return 1;
                }
        }
@@ -577,11 +577,11 @@ lua_task_get_helo (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_images (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
-       int                                 i = 1;
+       gint                            i = 1;
        GList                          *cur;
        struct rspamd_image           **pimg;
 
@@ -605,11 +605,11 @@ lua_task_get_images (lua_State *L)
 }
 
 G_INLINE_FUNC gboolean
-lua_push_symbol_result (lua_State *L, struct worker_task *task, struct metric *metric, const char *symbol)
+lua_push_symbol_result (lua_State *L, struct worker_task *task, struct metric *metric, const gchar *symbol)
 {
        struct metric_result           *metric_res;
        struct symbol                  *s;
-       int                             j;
+       gint                            j;
        GList                          *opt;
 
        metric_res = g_hash_table_lookup (task->results, metric->name);
@@ -642,15 +642,15 @@ lua_push_symbol_result (lua_State *L, struct worker_task *task, struct metric *m
        return FALSE;
 }
 
-static int
+static gint
 lua_task_get_symbol (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
-       const char                     *symbol;
+       const gchar                     *symbol;
        struct metric                  *metric;
        GList                          *cur = NULL, *metric_list;
        gboolean                        found = FALSE;
-       int                             i = 1;
+       gint                            i = 1;
 
        symbol = luaL_checkstring (L, 2);
 
@@ -688,11 +688,11 @@ lua_task_get_symbol (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_learn_statfile (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
-       const char                     *symbol;
+       const gchar                     *symbol;
        struct classifier_config       *cl;
        GTree                          *tokens;
        struct statfile                *st;
@@ -731,11 +731,11 @@ lua_task_learn_statfile (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_task_get_metric_score (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
-       const char                     *metric_name;
+       const gchar                     *metric_name;
        struct metric_result           *metric_res;
 
        metric_name = luaL_checkstring (L, 2);
@@ -759,11 +759,11 @@ lua_task_get_metric_score (lua_State *L)
        return 0;
 }
 
-static int
+static gint
 lua_task_get_metric_action (lua_State *L)
 {
        struct worker_task             *task = lua_check_task (L);
-       const char                     *metric_name;
+       const gchar                     *metric_name;
        struct metric_result           *metric_res;
        enum rspamd_metric_action       action;
 
@@ -785,7 +785,7 @@ lua_task_get_metric_action (lua_State *L)
 
 /**** Textpart implementation *****/
 
-static int
+static gint
 lua_textpart_get_content (lua_State * L)
 {
        struct mime_text_part          *part = lua_check_textpart (L);
@@ -800,7 +800,7 @@ lua_textpart_get_content (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_textpart_is_empty (lua_State * L)
 {
        struct mime_text_part          *part = lua_check_textpart (L);
@@ -815,7 +815,7 @@ lua_textpart_is_empty (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_textpart_is_html (lua_State * L)
 {
        struct mime_text_part          *part = lua_check_textpart (L);
@@ -830,7 +830,7 @@ lua_textpart_is_html (lua_State * L)
        return 1;
 }
 
-static int
+static gint
 lua_textpart_get_fuzzy (lua_State * L)
 {
        struct mime_text_part          *part = lua_check_textpart (L);
@@ -845,7 +845,7 @@ lua_textpart_get_fuzzy (lua_State * L)
 }
 
 /* Image functions */
-static int
+static gint
 lua_image_get_width (lua_State *L)
 {
        struct rspamd_image             *img = lua_check_image (L);
@@ -859,7 +859,7 @@ lua_image_get_width (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_image_get_height (lua_State *L)
 {
        struct rspamd_image             *img = lua_check_image (L);
@@ -874,7 +874,7 @@ lua_image_get_height (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_image_get_type (lua_State *L)
 {
        struct rspamd_image             *img = lua_check_image (L);
@@ -889,7 +889,7 @@ lua_image_get_type (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_image_get_size (lua_State *L)
 {
        struct rspamd_image             *img = lua_check_image (L);
@@ -904,7 +904,7 @@ lua_image_get_size (lua_State *L)
        return 1;
 }
 
-static int
+static gint
 lua_image_get_filename (lua_State *L)
 {
        struct rspamd_image             *img = lua_check_image (L);
@@ -920,7 +920,7 @@ lua_image_get_filename (lua_State *L)
 }
 
 /* Init part */
-int
+gint
 luaopen_task (lua_State * L)
 {
        lua_newclass (L, "rspamd{task}", tasklib_m);
@@ -929,7 +929,7 @@ luaopen_task (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_textpart (lua_State * L)
 {
        lua_newclass (L, "rspamd{textpart}", textpartlib_m);
@@ -938,7 +938,7 @@ luaopen_textpart (lua_State * L)
        return 1;
 }
 
-int
+gint
 luaopen_image (lua_State * L)
 {
        lua_newclass (L, "rspamd{image}", imagelib_m);
index b196bd3ea2830c62698eae7f6babc7adca234938..a2ae832bb527c4f0c06471d7cd20e54219e90e00 100644 (file)
@@ -100,10 +100,10 @@ static GOptionEntry entries[] =
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
 #ifdef HAVE_SA_SIGINFO
@@ -138,8 +138,8 @@ sig_handler (int signo, siginfo_t *info, void *unused)
 
 #ifdef HAVE_SA_SIGINFO
 
-static const char *
-chldsigcode (int code) {
+static const gchar *
+chldsigcode (gint code) {
        switch (code) {
 #ifdef CLD_EXITED
                case CLD_EXITED:
@@ -168,8 +168,8 @@ print_signals_info ()
                                        inf->si_pid, chldsigcode (inf->si_code));
                }
                else {
-                       msg_info ("got signal: '%s'; received from pid: %P; uid: %l",
-                                       g_strsignal (inf->si_signo), inf->si_pid, (long int)inf->si_uid);
+                       msg_info ("got signal: '%s'; received from pid: %P; uid: %ul",
+                                       g_strsignal (inf->si_signo), inf->si_pid, (gulong)inf->si_uid);
                }
                g_free (inf);
        }
@@ -178,7 +178,7 @@ print_signals_info ()
 
 
 static void
-read_cmd_line (int argc, char **argv, struct config_file *cfg)
+read_cmd_line (gint argc, gchar **argv, struct config_file *cfg)
 {
        GError                         *error = NULL;
        GOptionContext                 *context;
@@ -217,7 +217,7 @@ drop_priv (struct config_file *cfg)
                                exit (-errno);
                        }
                        if (setgid (grp->gr_gid) == -1) {
-                               msg_err ("cannot setgid to %d (%s), aborting", (int)grp->gr_gid, strerror (errno));
+                               msg_err ("cannot setgid to %d (%s), aborting", (gint)grp->gr_gid, strerror (errno));
                                exit (-errno);
                        }
                        if (initgroups (cfg->rspamd_user, grp->gr_gid) == -1) {
@@ -226,7 +226,7 @@ drop_priv (struct config_file *cfg)
                        }
                }
                if (setuid (pwd->pw_uid) == -1) {
-                       msg_err ("cannot setuid to %d (%s), aborting", (int)pwd->pw_uid, strerror (errno));
+                       msg_err ("cannot setuid to %d (%s), aborting", (gint)pwd->pw_uid, strerror (errno));
                        exit (-errno);
                }
        }
@@ -251,7 +251,7 @@ static void
 reread_config (struct rspamd_main *rspamd)
 {
        struct config_file             *tmp_cfg;
-       char                           *cfg_file;
+       gchar                           *cfg_file;
        GList                          *l;
        struct filter                  *filt;
 
@@ -432,7 +432,7 @@ dump_module_variables (gpointer key, gpointer value, gpointer data)
 static void
 dump_all_variables (gpointer key, gpointer value, gpointer data)
 {
-       printf ("$%s = \"%s\"\n", (char *)key, (char *)value);
+       printf ("$%s = \"%s\"\n", (gchar *)key, (gchar *)value);
 }
 
 
@@ -442,10 +442,10 @@ dump_cfg_vars (struct config_file *cfg)
        g_hash_table_foreach (cfg->variables, dump_all_variables, NULL);
 }
 
-static int
-create_listen_socket (struct in_addr *addr, int port, int family, char *path)
+static gint
+create_listen_socket (struct in_addr *addr, gint port, gint family, gchar *path)
 {
-       int                             listen_sock = -1;
+       gint                            listen_sock = -1;
        struct sockaddr_un             *un_addr;
        /* Create listen socket */
        if (family == AF_INET) {
@@ -486,21 +486,21 @@ fork_delayed (struct rspamd_main *rspamd)
 }
 
 static inline uintptr_t
-make_listen_key (struct in_addr *addr, int port, int family, char *path)
+make_listen_key (struct in_addr *addr, gint port, gint family, gchar *path)
 {
        uintptr_t                       res = 0;
-       char                           *key;
+       gchar                           *key;
 
        if (family == AF_INET) {
                /* Make fnv hash from bytes of addr and port */
-               key = (char *)&addr->s_addr;
-               while (key - (char *)&addr->s_addr < sizeof (addr->s_addr)) {
-                       res ^= (char)*key++;
+               key = (gchar *)&addr->s_addr;
+               while (key - (gchar *)&addr->s_addr < sizeof (addr->s_addr)) {
+                       res ^= (gchar)*key++;
                        res += (res << 1) + (res << 4) + (res << 7) + (res << 8) + (res << 24);
                }
-               key = (char *)&port;
-               while (key - (char *)&port < sizeof (addr->s_addr)) {
-                       res ^= (char)*key++;
+               key = (gchar *)&port;
+               while (key - (gchar *)&port < sizeof (addr->s_addr)) {
+                       res ^= (gchar)*key++;
                        res += (res << 1) + (res << 4) + (res << 7) + (res << 8) + (res << 24);
                }
        }
@@ -508,7 +508,7 @@ make_listen_key (struct in_addr *addr, int port, int family, char *path)
                /* Make fnv hash from bytes of path */
                key = path;
                while (*key) {
-                       res ^= (char)*key++;
+                       res ^= (gchar)*key++;
                        res += (res << 1) + (res << 4) + (res << 7) + (res << 8) + (res << 24);
                }
        }
@@ -521,7 +521,7 @@ spawn_workers (struct rspamd_main *rspamd)
 {
        GList                          *cur;
        struct worker_conf             *cf;
-       int                             i, listen_sock;
+       gint                            i, listen_sock;
        gpointer                        p;
 
        cur = rspamd->cfg->workers;
@@ -564,7 +564,7 @@ spawn_workers (struct rspamd_main *rspamd)
        }
 }
 
-static const char              *
+static const gchar              *
 get_process_type (enum process_type type)
 {
        switch (type) {
@@ -600,7 +600,7 @@ static gboolean
 wait_for_workers (gpointer key, gpointer value, gpointer unused)
 {
        struct rspamd_worker          *w = value;
-       int                            res = 0;
+       gint                            res = 0;
 
        waitpid (w->pid, &res, 0);
 
@@ -724,7 +724,7 @@ print_symbols_cache (struct config_file *cfg)
 {
        GList                          *cur;
        struct cache_item              *item;
-       int                             i;
+       gint                            i;
 
        if (!init_symbols_cache (cfg->cfg_pool, cfg->cache, cfg, cfg->cache_filename)) {
                exit (EXIT_FAILURE);
@@ -755,11 +755,11 @@ print_symbols_cache (struct config_file *cfg)
        }
 }
 
-int
-main (int argc, char **argv, char **env)
+gint
+main (gint argc, gchar **argv, gchar **env)
 {
        struct rspamd_main             *rspamd;
-       int                             res = 0;
+       gint                            res = 0;
        struct sigaction                signals;
        struct rspamd_worker           *cur;
        struct rlimit                   rlim;
index e26f3fbd0846385fdae1b54351226f993a547ffd..67542079656c56c880876dddfc1e0eb556c94658 100644 (file)
@@ -70,14 +70,14 @@ struct rspamd_dns_resolver;
  * Server statistics
  */
 struct rspamd_stat {
-       unsigned int messages_scanned;                                                          /**< total number of messages scanned                           */
-       unsigned int messages_spam;                                                                     /**< messages treated as spam                                           */
-       unsigned int messages_ham;                                                                      /**< messages treated as ham                                            */
-       unsigned int connections_count;                                                         /**< total connections count                                            */
-       unsigned int control_connections_count;                                         /**< connections count to control interface                     */
-       unsigned int messages_learned;                                                          /**< messages learned                                                           */
-       unsigned int fuzzy_hashes;                                                                      /**< number of fuzzy hashes stored                                      */
-       unsigned int fuzzy_hashes_expired;                                                      /**< number of fuzzy hashes expired                                     */
+       guint messages_scanned;                                                         /**< total number of messages scanned                           */
+       guint messages_spam;                                                                    /**< messages treated as spam                                           */
+       guint messages_ham;                                                                     /**< messages treated as ham                                            */
+       guint connections_count;                                                                /**< total connections count                                            */
+       guint control_connections_count;                                                /**< connections count to control interface                     */
+       guint messages_learned;                                                         /**< messages learned                                                           */
+       guint fuzzy_hashes;                                                                     /**< number of fuzzy hashes stored                                      */
+       guint fuzzy_hashes_expired;                                                     /**< number of fuzzy hashes expired                                     */
 };
 
 /**
@@ -89,7 +89,7 @@ struct rspamd_main {
        /* Pid file structure */
        struct pidfh *pfh;                                                                                      /**< struct pidfh for pidfile                                           */
        enum process_type type;                                                                         /**< process type                                                                       */
-       unsigned int ev_initialized;                                                            /**< is event system is initialized                                     */
+       guint ev_initialized;                                                           /**< is event system is initialized                                     */
        struct rspamd_stat *stat;                                                                       /**< pointer to statistics                                                      */
 
        memory_pool_t *server_pool;                                                                     /**< server's memory pool                                                       */
@@ -98,8 +98,8 @@ struct rspamd_main {
 };
 
 struct counter_data {
-       uint64_t value;
-       int number;
+       guint64 value;
+       gint number;
 };
 
 /**
@@ -108,7 +108,7 @@ struct counter_data {
 struct save_point {
        GList *entry;                                                                                           /**< pointer to saved metric                                            */
        void *item;                                                                                                     /**< pointer to saved item                                                      */
-       unsigned int saved;                                                                                     /**< how much time we have delayed processing           */
+       guint saved;                                                                                    /**< how much time we have delayed processing           */
 };
 
 
@@ -135,27 +135,27 @@ struct controller_session {
                STATE_WAIT,
                STATE_WEIGHTS
        } state;                                                                                                        /**< current session state                                                      */
-       int sock;                                                                                                       /**< socket descriptor                                                          */
+       gint sock;                                                                                                      /**< socket descriptor                                                          */
        /* Access to authorized commands */
-       int authorized;                                                                                         /**< whether this session is authorized                         */
+       gint authorized;                                                                                                /**< whether this session is authorized                         */
        memory_pool_t *session_pool;                                                            /**< memory pool for session                                            */
        struct config_file *cfg;                                                                        /**< pointer to config file                                                     */
-       char *learn_rcpt;                                                                                       /**< recipient for learning                                                     */
-       char *learn_from;                                                                                       /**< from address for learning                                          */
+       gchar *learn_rcpt;                                                                                      /**< recipient for learning                                                     */
+       gchar *learn_from;                                                                                      /**< from address for learning                                          */
        struct classifier_config *learn_classifier;
-       char *learn_symbol;                                                                                     /**< symbol to train                                                            */
+       gchar *learn_symbol;                                                                                    /**< symbol to train                                                            */
        double learn_multiplier;                                                                        /**< multiplier for learning                                            */
        rspamd_io_dispatcher_t *dispatcher;                                                     /**< IO dispatcher object                                                       */
        f_str_t *learn_buf;                                                                                     /**< learn input                                                                        */
        GList *parts;                                                                                           /**< extracted mime parts                                                       */
-       int in_class;                                                                                           /**< positive or negative learn                                         */
+       gint in_class;                                                                                          /**< positive or negative learn                                         */
        void (*other_handler)(struct controller_session *session, 
                                                                f_str_t *in);                                   /**< other command handler to execute at the end of processing */
        void *other_data;                                                                                       /**< and its data                                                                       */
     struct rspamd_async_session* s;                                                            /**< async session object                                                       */
 };
 
-typedef void (*controller_func_t)(char **args, struct controller_session *session);
+typedef void (*controller_func_t)(gchar **args, struct controller_session *session);
 
 /**
  * Worker task structure
@@ -176,30 +176,30 @@ struct worker_task {
        guint proto_ver;                                                                                        /**< protocol version                                                           */
        enum rspamd_command cmd;                                                                        /**< command                                                                            */
        struct custom_command *custom_cmd;                                                      /**< custom command if any                                                      */      
-       int sock;                                                                                                       /**< socket descriptor                                                          */
+       gint sock;                                                                                                      /**< socket descriptor                                                          */
     gboolean is_mime;                                           /**< if this task is mime task                      */
     gboolean is_skipped;                                        /**< whether message was skipped by configuration   */
-       char *helo;                                                                                                     /**< helo header value                                                          */
-       char *from;                                                                                                     /**< from header value                                                          */
-       char *queue_id;                                                                                         /**< queue id if specified                                                      */
-       const char *message_id;                                                                         /**< message id                                                                         */
+       gchar *helo;                                                                                                    /**< helo header value                                                          */
+       gchar *from;                                                                                                    /**< from header value                                                          */
+       gchar *queue_id;                                                                                                /**< queue id if specified                                                      */
+       const gchar *message_id;                                                                                /**< message id                                                                         */
        GList *rcpt;                                                                                            /**< recipients list                                                            */
-       unsigned int nrcpt;                                                                                     /**< number of recipients                                                       */
+       guint nrcpt;                                                                                    /**< number of recipients                                                       */
        struct in_addr from_addr;                                                                       /**< client addr in numeric form                                        */
        struct in_addr client_addr;                                                                     /**< client addr in numeric form                                        */
-       char *deliver_to;                                                                                       /**< address to deliver                                                         */
-       char *user;                                                                                                     /**< user to deliver                                                            */
-       char *subject;                                                                                          /**< subject (for non-mime)                                                     */
+       gchar *deliver_to;                                                                                      /**< address to deliver                                                         */
+       gchar *user;                                                                                                    /**< user to deliver                                                            */
+       gchar *subject;                                                                                         /**< subject (for non-mime)                                                     */
        f_str_t *msg;                                                                                           /**< message buffer                                                                     */
        rspamd_io_dispatcher_t *dispatcher;                                                     /**< IO dispatcher object                                                       */
     struct rspamd_async_session* s;                                                            /**< async session object                                                       */
-       int parts_count;                                                                                        /**< mime parts count                                                           */
+       gint parts_count;                                                                                       /**< mime parts count                                                           */
        GMimeMessage *message;                                                                          /**< message, parsed with GMime                                         */
        GMimeObject *parser_parent_part;                                                        /**< current parent part                                                        */
        InternetAddressList *rcpts;                                                                     /**< list of all recipients                                             */
        GList *parts;                                                                                           /**< list of parsed parts                                                       */
        GList *text_parts;                                                                                      /**< list of text parts                                                         */
-       char *raw_headers;                                                                                      /**< list of raw headers                                                        */
+       gchar *raw_headers;                                                                                     /**< list of raw headers                                                        */
        GList *received;                                                                                        /**< list of received headers                                           */
        GList *urls;                                                                                            /**< list of parsed urls                                                        */
        GList *images;                                                                                          /**< list of images                                                                     */
@@ -211,8 +211,8 @@ struct worker_task {
        GHashTable *re_cache;                                                                           /**< cache for matched or not matched regexps           */
        struct config_file *cfg;                                                                        /**< pointer to config object                                           */
        struct save_point save;                                                                         /**< save point for delayed processing                          */
-       char *last_error;                                                                                       /**< last error                                                                         */
-       int error_code;                                                                                         /**< code of last error                                                         */
+       gchar *last_error;                                                                                      /**< last error                                                                         */
+       gint error_code;                                                                                                /**< code of last error                                                         */
        memory_pool_t *task_pool;                                                                       /**< memory pool for task                                                       */
 #ifdef HAVE_CLOCK_GETTIME
        struct timespec ts;                                                                                     /**< time of connection                                                         */
@@ -221,7 +221,7 @@ struct worker_task {
        struct rspamd_view *view;                                                                       /**< matching view                                                                      */
        gboolean view_checked;
        gboolean pass_all_filters;                                                                      /**< pass task throught every rule                                      */
-       uint32_t parser_recursion;                                                                      /**< for avoiding recursion stack overflow                      */
+       guint32 parser_recursion;                                                                       /**< for avoiding recursion stack overflow                      */
        gboolean (*fin_callback)(void *arg);                                            /**< calback for filters finalizing                                     */
        void *fin_arg;                                                                                          /**< argument for fin callback                                          */
 
@@ -232,14 +232,14 @@ struct worker_task {
  * Common structure representing C module context
  */
 struct module_ctx {
-       int (*filter)(struct worker_task *task);                                        /**< pointer to headers process function                        */
+       gint (*filter)(struct worker_task *task);                                       /**< pointer to headers process function                        */
 };
 
 /**
  * Common structure for C module
  */
 struct c_module {
-       const char *name;                                                                                       /**< name                                                                                       */
+       const gchar *name;                                                                                      /**< name                                                                                       */
        struct module_ctx *ctx;                                                                         /**< pointer to context                                                         */
 };
 
@@ -250,7 +250,7 @@ void start_greylist_storage (struct rspamd_worker *worker);
 /**
  * Register custom controller function
  */
-void register_custom_controller_command (const char *name, controller_func_t handler, gboolean privilleged, gboolean require_message);
+void register_custom_controller_command (const gchar *name, controller_func_t handler, gboolean privilleged, gboolean require_message);
 
 /**
  * Construct new task for worker
index 12b833ae0a053a4eba01b2b4db5b69c6b83cae51..2dd898f02e9b7edc85ab507134150da92238975d 100644 (file)
--- a/src/map.c
+++ b/src/map.c
 static memory_pool_t           *map_pool = NULL;
 
 static GList                   *maps = NULL;
-static char                    *hash_fill = "1";
+static gchar                    *hash_fill = "1";
 
 /* Http reply */
 struct http_reply {
-       int                             code;
+       gint                            code;
        GHashTable                     *headers;
-       char                           *cur_header;
+       gchar                           *cur_header;
 
-       int                             parser_state;
+       gint                            parser_state;
 };
 
 struct http_callback_data {
@@ -53,8 +53,8 @@ struct http_callback_data {
        struct http_reply              *reply;
        struct map_cb_data              cbdata;
 
-       int                             state;
-       int                             fd;
+       gint                            state;
+       gint                            fd;
 };
 
 /* Value in seconds after whitch we would try to do stat on list file */
@@ -63,10 +63,10 @@ struct http_callback_data {
 #define HTTP_CONNECT_TIMEOUT 2
 #define HTTP_READ_TIMEOUT 10
 
-static int
+static gint
 connect_http (struct rspamd_map *map, struct http_map_data *data, gboolean is_async)
 {
-       int                             sock;
+       gint                            sock;
 
        if ((sock = make_tcp_socket (&data->addr, data->port, FALSE, is_async)) == -1) {
                msg_info ("cannot connect to http server %s: %d, %s", data->host, errno, strerror (errno));
@@ -77,10 +77,10 @@ connect_http (struct rspamd_map *map, struct http_map_data *data, gboolean is_as
 }
 
 static void
-write_http_request (struct rspamd_map *map, struct http_map_data *data, int sock)
+write_http_request (struct rspamd_map *map, struct http_map_data *data, gint sock)
 {
-       char                            outbuf[BUFSIZ];
-       int                             r;
+       gchar                           outbuf[BUFSIZ];
+       gint                            r;
 
        r = rspamd_snprintf (outbuf, sizeof (outbuf), "GET %s%s HTTP/1.1" CRLF "Connection: close" CRLF "Host: %s" CRLF, (*data->path == '/') ? "" : "/", data->path, data->host);
        if (data->last_checked != 0) {
@@ -111,7 +111,7 @@ parse_http_reply (u_char * chunk, size_t len, struct http_reply *reply)
                        }
                        else {
                                /* Try to parse HTTP reply code */
-                               reply->code = strtoul (++p, (char **)&err_str, 10);
+                               reply->code = strtoul (++p, (gchar **)&err_str, 10);
                                if (*err_str != ' ') {
                                        msg_info ("error while reading HTTP status code: %s", p);
                                        return NULL;
@@ -182,11 +182,11 @@ parse_http_reply (u_char * chunk, size_t len, struct http_reply *reply)
        return s;
 }
 
-static int
+static gint
 read_chunk_header (u_char * buf, size_t len, struct http_map_data *data)
 {
        u_char                          chunkbuf[32], *p, *c;
-       int                             skip = 0;
+       gint                            skip = 0;
 
        p = chunkbuf;
        c = buf;
@@ -214,7 +214,7 @@ static                          gboolean
 read_http_chunked (u_char * buf, size_t len, struct rspamd_map *map, struct http_map_data *data, struct map_cb_data *cbdata)
 {
        u_char                         *p = buf, *remain;
-       uint32_t                        skip = 0;
+       guint32                         skip = 0;
 
        if (data->chunk == 0) {
                /* Read first chunk data */
@@ -239,7 +239,7 @@ read_http_chunked (u_char * buf, size_t len, struct rspamd_map *map, struct http
                                return TRUE;
                        }
                        else {
-                               msg_info ("invalid chunked reply: %*s", (int)len, buf);
+                               msg_info ("invalid chunked reply: %*s", (gint)len, buf);
                                return FALSE;
                        }
                }
@@ -270,11 +270,11 @@ read_http_chunked (u_char * buf, size_t len, struct rspamd_map *map, struct http
 }
 
 static                          gboolean
-read_http_common (struct rspamd_map *map, struct http_map_data *data, struct http_reply *reply, struct map_cb_data *cbdata, int fd)
+read_http_common (struct rspamd_map *map, struct http_map_data *data, struct http_reply *reply, struct map_cb_data *cbdata, gint fd)
 {
        u_char                         *remain, *pos;
        ssize_t                         r;
-       char                           *te;
+       gchar                           *te;
        
        if ((r = read (fd, data->read_buf + data->rlen, sizeof (data->read_buf) - data->rlen)) > 0) {
                r += data->rlen;
@@ -327,7 +327,7 @@ static void
 read_http_sync (struct rspamd_map *map, struct http_map_data *data)
 {
        struct map_cb_data              cbdata;
-       int                             fd;
+       gint                            fd;
        struct http_reply              *repl;
 
        if (map->read_callback == NULL || map->fin_callback == NULL) {
@@ -368,7 +368,7 @@ read_map_file (struct rspamd_map *map, struct file_map_data *data)
        struct map_cb_data              cbdata;
        u_char                          buf[BUFSIZ], *remain;
        ssize_t                         r;
-       int                             fd, rlen;
+       gint                            fd, rlen;
 
        if (map->read_callback == NULL || map->fin_callback == NULL) {
                msg_err ("bad callback for reading map file");
@@ -403,15 +403,15 @@ read_map_file (struct rspamd_map *map, struct file_map_data *data)
 }
 
 gboolean
-add_map (const char *map_line, map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data)
+add_map (const gchar *map_line, map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data)
 {
        struct rspamd_map              *new_map;
        enum fetch_proto                proto;
-       const char                     *def, *p, *hostend;
+       const gchar                     *def, *p, *hostend;
        struct file_map_data           *fdata;
        struct http_map_data           *hdata;
-       char                            portbuf[6];
-       int                             i, s, fd;
+       gchar                           portbuf[6];
+       gint                            i, s, fd;
        struct hostent                 *hent;
 
        /* First of all detect protocol line */
@@ -581,13 +581,13 @@ radix_tree_insert_helper (gpointer st, gconstpointer key, gpointer value)
 {
        radix_tree_t                   *tree = st;
 
-       uint32_t                        mask = 0xFFFFFFFF;
-       uint32_t                        ip;
-       char                           *token, *ipnet, *err_str, **strv, **cur;
+       guint32                         mask = 0xFFFFFFFF;
+       guint32                         ip;
+       gchar                           *token, *ipnet, *err_str, **strv, **cur;
        struct in_addr                  ina;
-       int                             k;
+       gint                            k;
 
-       strv = g_strsplit_set ((char *)key, " ,;", 0);
+       strv = g_strsplit_set ((gchar *)key, " ,;", 0);
        cur = strv;
        while (*cur) {
                if (**cur == '\0') {
@@ -616,7 +616,7 @@ radix_tree_insert_helper (gpointer st, gconstpointer key, gpointer value)
                        return;
                }
 
-               ip = ntohl ((uint32_t) ina.s_addr);
+               ip = ntohl ((guint32) ina.s_addr);
                k = radix32tree_insert (tree, ip, mask, 1);
                if (k == -1) {
                        msg_warn ("cannot insert ip to tree: %s, mask %X", inet_ntoa (ina), mask);
@@ -665,7 +665,7 @@ fin_radix_list (memory_pool_t * pool, struct map_cb_data *data)
 }
 
 static void
-file_callback (int fd, short what, void *ud)
+file_callback (gint fd, short what, void *ud)
 {
        struct rspamd_map              *map = ud;
        struct file_map_data           *data = map->map_data;
@@ -701,7 +701,7 @@ free_http_cbdata (struct http_callback_data *cbd)
 }
 
 static void
-http_async_callback (int fd, short what, void *ud)
+http_async_callback (gint fd, short what, void *ud)
 {
        struct http_callback_data      *cbd = ud;
 
@@ -768,11 +768,11 @@ http_async_callback (int fd, short what, void *ud)
 
 
 static void
-http_callback (int fd, short what, void *ud)
+http_callback (gint fd, short what, void *ud)
 {
        struct rspamd_map              *map = ud;
        struct http_map_data           *data = map->map_data;
-       int                             sock;
+       gint                            sock;
        struct http_callback_data      *cbd;
 
        /* Plan event again with jitter */
index fe3a2b36bc62267cdc7362aa0c26cc97ba87bf32..d07b40cc2e704259433a887c639052bb26bcc3e6 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -11,27 +11,27 @@ enum fetch_proto {
 };
 
 struct map_cb_data {
-       int state;
+       gint state;
        void *prev_data;
        void *cur_data;
 };
 
 struct file_map_data {
-       const char *filename;
+       const gchar *filename;
        struct stat st;
 };
 
 struct http_map_data {
        struct in_addr addr;
-       uint16_t port;
-       char *path;
-       char *host;
+       guint16 port;
+       gchar *path;
+       gchar *host;
        time_t last_checked;
        gboolean chunked;
        u_char read_buf[BUFSIZ];
-       uint32_t rlen;
-       uint32_t chunk;
-       uint32_t chunk_read;
+       guint32 rlen;
+       guint32 chunk;
+       guint32 chunk_read;
 };
 
 typedef u_char* (*map_cb_t)(memory_pool_t *pool, u_char *chunk, size_t len, struct map_cb_data *data);
@@ -48,7 +48,7 @@ struct rspamd_map {
        void *map_data;
 };
 
-gboolean add_map (const char *map_line, map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data);
+gboolean add_map (const gchar *map_line, map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data);
 void start_map_watch (void);
 void remove_all_maps (void);
 
index 3398cbf41127628a16c7e26d5acaa66ed91bd0da..5487b6768dd6161abb390383925c5bc185fb2a59 100644 (file)
@@ -53,7 +53,7 @@ pthread_mutex_t                 stat_mtx = PTHREAD_MUTEX_INITIALIZER;
 static memory_pool_stat_t      *mem_pool_stat = NULL;
 
 static struct _pool_chain      *
-pool_chain_new (memory_pool_ssize_t size)
+pool_chain_new (gsize size)
 {
        struct _pool_chain             *chain;
 
@@ -78,7 +78,7 @@ pool_chain_new (memory_pool_ssize_t size)
 }
 
 static struct _pool_chain_shared *
-pool_chain_new_shared (memory_pool_ssize_t size)
+pool_chain_new_shared (gsize size)
 {
        struct _pool_chain_shared      *chain;
 
@@ -87,7 +87,7 @@ pool_chain_new_shared (memory_pool_ssize_t size)
        g_assert (chain != MAP_FAILED);
        chain->begin = ((u_char *) chain) + sizeof (struct _pool_chain_shared);
 #elif defined(HAVE_MMAP_ZERO)
-       int                             fd;
+       gint                            fd;
 
        fd = open ("/dev/zero", O_RDWR);
        if (fd == -1) {
@@ -117,7 +117,7 @@ pool_chain_new_shared (memory_pool_ssize_t size)
  * @return new memory pool object
  */
 memory_pool_t                  *
-memory_pool_new (memory_pool_ssize_t size)
+memory_pool_new (gsize size)
 {
        memory_pool_t                  *new;
 
@@ -128,7 +128,7 @@ memory_pool_new (memory_pool_ssize_t size)
                mem_pool_stat = (memory_pool_stat_t *)mmap (NULL, sizeof (memory_pool_stat_t), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
                g_assert (stat != MAP_FAILED);
 #elif defined(HAVE_MMAP_ZERO)
-               int                             fd;
+               gint                            fd;
 
                fd = open ("/dev/zero", O_RDWR);
                g_assert (fd != -1);
@@ -155,7 +155,7 @@ memory_pool_new (memory_pool_ssize_t size)
 }
 
 void                           *
-memory_pool_alloc (memory_pool_t * pool, memory_pool_ssize_t size)
+memory_pool_alloc (memory_pool_t * pool, gsize size)
 {
        u_char                         *tmp;
        struct _pool_chain             *new, *cur;
@@ -199,7 +199,7 @@ memory_pool_alloc (memory_pool_t * pool, memory_pool_ssize_t size)
 }
 
 void                           *
-memory_pool_alloc0 (memory_pool_t * pool, memory_pool_ssize_t size)
+memory_pool_alloc0 (memory_pool_t * pool, gsize size)
 {
        void                           *pointer = memory_pool_alloc (pool, size);
        if (pointer) {
@@ -209,7 +209,7 @@ memory_pool_alloc0 (memory_pool_t * pool, memory_pool_ssize_t size)
 }
 
 void                           *
-memory_pool_alloc0_shared (memory_pool_t * pool, memory_pool_ssize_t size)
+memory_pool_alloc0_shared (memory_pool_t * pool, gsize size)
 {
        void                           *pointer = memory_pool_alloc_shared (pool, size);
        if (pointer) {
@@ -218,11 +218,11 @@ memory_pool_alloc0_shared (memory_pool_t * pool, memory_pool_ssize_t size)
        return pointer;
 }
 
-char                           *
-memory_pool_strdup (memory_pool_t * pool, const char *src)
+gchar                           *
+memory_pool_strdup (memory_pool_t * pool, const gchar *src)
 {
-       memory_pool_ssize_t             len;
-       char                           *newstr;
+       gsize             len;
+       gchar                           *newstr;
 
        if (src == NULL) {
                return NULL;
@@ -235,10 +235,10 @@ memory_pool_strdup (memory_pool_t * pool, const char *src)
        return newstr;
 }
 
-char                           *
+gchar                           *
 memory_pool_fstrdup (memory_pool_t * pool, const struct f_str_s *src)
 {
-       char                           *newstr;
+       gchar                           *newstr;
 
        if (src == NULL) {
                return NULL;
@@ -251,11 +251,11 @@ memory_pool_fstrdup (memory_pool_t * pool, const struct f_str_s *src)
 }
 
 
-char                           *
-memory_pool_strdup_shared (memory_pool_t * pool, const char *src)
+gchar                           *
+memory_pool_strdup_shared (memory_pool_t * pool, const gchar *src)
 {
-       memory_pool_ssize_t             len;
-       char                           *newstr;
+       gsize             len;
+       gchar                           *newstr;
 
        if (src == NULL) {
                return NULL;
@@ -270,7 +270,7 @@ memory_pool_strdup_shared (memory_pool_t * pool, const char *src)
 
 
 void                           *
-memory_pool_alloc_shared (memory_pool_t * pool, memory_pool_ssize_t size)
+memory_pool_alloc_shared (memory_pool_t * pool, gsize size)
 {
        u_char                         *tmp;
        struct _pool_chain_shared      *new, *cur;
@@ -330,7 +330,7 @@ memory_pool_find_pool (memory_pool_t * pool, void *pointer)
        return NULL;
 }
 
-static inline int
+static inline gint
 __mutex_spin (memory_pool_mutex_t * mutex)
 {
        /* check spin count */
@@ -506,7 +506,7 @@ memory_pool_stat (memory_pool_stat_t * st)
 
 /* By default allocate 8Kb chunks of memory */
 #define FIXED_POOL_SIZE 8192
-memory_pool_ssize_t
+gsize
 memory_pool_get_size ()
 {
 #ifdef HAVE_GETPAGESIZE
index 14f83d9c592fdad4b4333fc96ebdb81ed3570001..df1b9aff28688a525c229c2659931ced44d2d737 100644 (file)
@@ -22,11 +22,6 @@ struct f_str_s;
  */
 typedef void (*pool_destruct_func)(void *ptr);
 
-/**
- * Type that represents allocating size
- */
-typedef long int memory_pool_ssize_t;
-
 /**
  * Pool mutex structure
  */
@@ -42,7 +37,7 @@ typedef struct memory_pool_mutex_s {
 struct _pool_chain {
        u_char *begin;                                  /**< begin of pool chain block                          */
        u_char *pos;                                    /**< current start of free space in block       */
-       memory_pool_ssize_t len;                /**< length of block                                            */
+       gsize len;              /**< length of block                                            */
        struct _pool_chain *next;               /**< chain link                                                         */
 };
 
@@ -52,7 +47,7 @@ struct _pool_chain {
 struct _pool_chain_shared {
        u_char *begin;
        u_char *pos;
-       memory_pool_ssize_t len;
+       gsize len;
        memory_pool_mutex_t *lock;
        struct _pool_chain_shared *next;
 };
@@ -81,13 +76,13 @@ typedef struct memory_pool_s {
  * Statistics structure
  */
 typedef struct memory_pool_stat_s {
-       memory_pool_ssize_t pools_allocated;                            /**< total number of allocated pools                                    */
-       memory_pool_ssize_t pools_freed;                                        /**< number of freed pools                                                              */
-       memory_pool_ssize_t bytes_allocated;                            /**< bytes that are allocated with pool allocator               */
-       memory_pool_ssize_t chunks_allocated;                           /**< number of chunks that are allocated                                */
-       memory_pool_ssize_t shared_chunks_allocated;            /**< shared chunks allocated                                                    */
-       memory_pool_ssize_t chunks_freed;                                       /**< chunks freed                                                                               */
-       memory_pool_ssize_t oversized_chunks;                           /**< oversized chunks                                                                   */
+       gsize pools_allocated;                          /**< total number of allocated pools                                    */
+       gsize pools_freed;                                      /**< number of freed pools                                                              */
+       gsize bytes_allocated;                          /**< bytes that are allocated with pool allocator               */
+       gsize chunks_allocated;                         /**< number of chunks that are allocated                                */
+       gsize shared_chunks_allocated;          /**< shared chunks allocated                                                    */
+       gsize chunks_freed;                                     /**< chunks freed                                                                               */
+       gsize oversized_chunks;                         /**< oversized chunks                                                                   */
 } memory_pool_stat_t;
 
 /**
@@ -103,7 +98,7 @@ typedef struct memory_pool_rwlock_s {
  * @param size size of pool's page
  * @return new memory pool object
  */
-memory_pool_t* memory_pool_new (memory_pool_ssize_t size);
+memory_pool_t* memory_pool_new (gsize size);
 
 /** 
  * Get memory from pool
@@ -111,7 +106,7 @@ memory_pool_t* memory_pool_new (memory_pool_ssize_t size);
  * @param size bytes to allocate
  * @return pointer to allocated object
  */
-void* memory_pool_alloc (memory_pool_t* pool, memory_pool_ssize_t size);
+void* memory_pool_alloc (memory_pool_t* pool, gsize size);
 
 /**
  * Get memory and set it to zero
@@ -119,7 +114,7 @@ void* memory_pool_alloc (memory_pool_t* pool, memory_pool_ssize_t size);
  * @param size bytes to allocate
  * @return pointer to allocated object
  */
-void* memory_pool_alloc0 (memory_pool_t* pool, memory_pool_ssize_t size);
+void* memory_pool_alloc0 (memory_pool_t* pool, gsize size);
 
 /**
  * Make a copy of string in pool
@@ -127,7 +122,7 @@ void* memory_pool_alloc0 (memory_pool_t* pool, memory_pool_ssize_t size);
  * @param src source string
  * @return pointer to newly created string that is copy of src
  */
-char* memory_pool_strdup (memory_pool_t* pool, const char *src);
+gchar* memory_pool_strdup (memory_pool_t* pool, const gchar *src);
 
 /**
  * Make a copy of fixed string in pool as null terminated string
@@ -135,16 +130,16 @@ char* memory_pool_strdup (memory_pool_t* pool, const char *src);
  * @param src source string
  * @return pointer to newly created string that is copy of src
  */
-char* memory_pool_fstrdup (memory_pool_t* pool, const struct f_str_s *src);
+gchar* memory_pool_fstrdup (memory_pool_t* pool, const struct f_str_s *src);
 
 /**
  * Allocate piece of shared memory
  * @param pool memory pool object
  * @param size bytes to allocate
  */
-void* memory_pool_alloc_shared (memory_pool_t *pool, memory_pool_ssize_t size);
-void* memory_pool_alloc0_shared (memory_pool_t *pool, memory_pool_ssize_t size);
-char* memory_pool_strdup_shared (memory_pool_t* pool, const char *src);
+void* memory_pool_alloc_shared (memory_pool_t *pool, gsize size);
+void* memory_pool_alloc0_shared (memory_pool_t *pool, gsize size);
+gchar* memory_pool_strdup_shared (memory_pool_t* pool, const gchar *src);
 
 /**
  * Lock chunk of shared memory in which pointer is placed
@@ -243,7 +238,7 @@ void memory_pool_stat (memory_pool_stat_t *st);
  * Get optimal pool size based on page size for this system
  * @return size of memory page in system
  */
-memory_pool_ssize_t memory_pool_get_size ();
+gsize memory_pool_get_size ();
 
 /**
  * Set memory pool variable
index 5e55573377f01a7edb2a428063a8d9094843ca1c..37cb17462dc971c498a823680aa285e45bc20d1b 100644 (file)
@@ -42,36 +42,36 @@ memcached_param_t               cur_param;
 static void
 test_memc_callback (memcached_ctx_t * ctx, memc_error_t error, void *data)
 {
-       int                             s;
-       int                             r;
-       int                            *num = ((int *)data);
+       gint                            s;
+       gint                            r;
+       gint                            *num = ((gint *)data);
        printf ("result of memc command '%s' is '%s'\n", ctx->cmd, memc_strerror (error));
        /* Connect */
        if (*num == 0) {
-               printf ("Setting value to memcached: %s -> %s\n", cur_param.key, (char *)cur_param.buf);
+               printf ("Setting value to memcached: %s -> %s\n", cur_param.key, (gchar *)cur_param.buf);
                s = 1;
                r = memc_set (ctx, &cur_param, &s, 60);
                (*num)++;
        }
        else if (*num == 1) {
-               printf ("Getting value from memcached: %s -> %s\n", cur_param.key, (char *)cur_param.buf);
+               printf ("Getting value from memcached: %s -> %s\n", cur_param.key, (gchar *)cur_param.buf);
                s = 1;
                r = memc_get (ctx, &cur_param, &s);
                (*num)++;
        }
        else {
-               printf ("Got value from memcached: %s -> %s\n", cur_param.key, (char *)cur_param.buf);
+               printf ("Got value from memcached: %s -> %s\n", cur_param.key, (gchar *)cur_param.buf);
                event_loopexit (NULL);
        }
 }
 
 
-int
-main (int argc, char **argv)
+gint
+main (gint argc, gchar **argv)
 {
        memcached_ctx_t                 mctx;
-       char                           *addr, buf[512];
-       int                             num = 0;
+       gchar                           *addr, buf[512];
+       gint                            num = 0;
 
        event_init ();
        strcpy (cur_param.key, "testkey");
index 77078aa064e352ddee664c3bc9c48d9beee1817b..135c7cb68ed26c9e3572b3c1e60929cb7c3e2f58 100644 (file)
 
 /* Header for udp protocol */
 struct memc_udp_header {
-       uint16_t                        req_id;
-       uint16_t                        seq_num;
-       uint16_t                        dg_sent;
-       uint16_t                        unused;
+       guint16                        req_id;
+       guint16                        seq_num;
+       guint16                        dg_sent;
+       guint16                        unused;
 };
 
-static void                     socket_callback (int fd, short what, void *arg);
-static int                      memc_parse_header (char *buf, size_t * len, char **end);
+static void                     socket_callback (gint fd, short what, void *arg);
+static gint                      memc_parse_header (gchar *buf, size_t * len, gchar **end);
 
 /*
  * Write to syslog if OPT_DEBUG is specified
  */
 static void
-memc_log (const memcached_ctx_t * ctx, int line, const char *fmt, ...)
+memc_log (const memcached_ctx_t * ctx, gint line, const gchar *fmt, ...)
 {
        va_list                         args;
        if (ctx->options & MEMC_OPT_DEBUG) {
@@ -93,10 +93,10 @@ memc_log (const memcached_ctx_t * ctx, int line, const char *fmt, ...)
  * Callback for write command
  */
 static void
-write_handler (int fd, short what, memcached_ctx_t * ctx)
+write_handler (gint fd, short what, memcached_ctx_t * ctx)
 {
-       char                            read_buf[READ_BUFSIZ];
-       int                             retries;
+       gchar                           read_buf[READ_BUFSIZ];
+       gint                            retries;
        ssize_t                         r;
        struct memc_udp_header          header;
        struct iovec                    iov[4];
@@ -196,15 +196,15 @@ write_handler (int fd, short what, memcached_ctx_t * ctx)
  * Callback for read command
  */
 static void
-read_handler (int fd, short what, memcached_ctx_t * ctx)
+read_handler (gint fd, short what, memcached_ctx_t * ctx)
 {
-       char                            read_buf[READ_BUFSIZ];
-       char                           *p;
+       gchar                           read_buf[READ_BUFSIZ];
+       gchar                           *p;
        ssize_t                         r;
        size_t                          datalen;
        struct memc_udp_header          header;
        struct iovec                    iov[2];
-       int                             retries = 0, t;
+       gint                            retries = 0, t;
 
        if (what == EV_WRITE) {
                /* Send command to memcached */
@@ -330,10 +330,10 @@ read_handler (int fd, short what, memcached_ctx_t * ctx)
  * Callback for delete command
  */
 static void
-delete_handler (int fd, short what, memcached_ctx_t * ctx)
+delete_handler (gint fd, short what, memcached_ctx_t * ctx)
 {
-       char                            read_buf[READ_BUFSIZ];
-       int                             retries;
+       gchar                           read_buf[READ_BUFSIZ];
+       gint                            retries;
        ssize_t                         r;
        struct memc_udp_header          header;
        struct iovec                    iov[2];
@@ -414,7 +414,7 @@ delete_handler (int fd, short what, memcached_ctx_t * ctx)
  * Callback for our socket events
  */
 static void
-socket_callback (int fd, short what, void *arg)
+socket_callback (gint fd, short what, void *arg)
 {
        memcached_ctx_t                *ctx = (memcached_ctx_t *) arg;
 
@@ -461,11 +461,11 @@ common_memc_callback (memcached_ctx_t * ctx, memc_error_t error, void *data)
 /*
  * Make socket for udp connection
  */
-static int
+static gint
 memc_make_udp_sock (memcached_ctx_t * ctx)
 {
        struct sockaddr_in              sc;
-       int                             ofl;
+       gint                            ofl;
 
        bzero (&sc, sizeof (struct sockaddr_in *));
        sc.sin_family = AF_INET;
@@ -496,11 +496,11 @@ memc_make_udp_sock (memcached_ctx_t * ctx)
 /*
  * Make socket for tcp connection
  */
-static int
+static gint
 memc_make_tcp_sock (memcached_ctx_t * ctx)
 {
        struct sockaddr_in              sc;
-       int                             ofl, r;
+       gint                            ofl, r;
 
        bzero (&sc, sizeof (struct sockaddr_in *));
        sc.sin_family = AF_INET;
@@ -535,11 +535,11 @@ memc_make_tcp_sock (memcached_ctx_t * ctx)
 /* 
  * Parse VALUE reply from server and set len argument to value returned by memcached 
  */
-static int
-memc_parse_header (char *buf, size_t * len, char **end)
+static gint
+memc_parse_header (gchar *buf, size_t * len, gchar **end)
 {
-       char                           *p, *c;
-       int                             i;
+       gchar                           *p, *c;
+       gint                            i;
 
        /* VALUE <key> <flags> <bytes> [<cas unique>]\r\n */
        c = strstr (buf, CRLF);
@@ -575,7 +575,7 @@ memc_parse_header (char *buf, size_t * len, char **end)
  * Common read command handler for memcached
  */
 memc_error_t
-memc_read (memcached_ctx_t * ctx, const char *cmd, memcached_param_t * param)
+memc_read (memcached_ctx_t * ctx, const gchar *cmd, memcached_param_t * param)
 {
        ctx->cmd = cmd;
        ctx->op = CMD_READ;
@@ -590,7 +590,7 @@ memc_read (memcached_ctx_t * ctx, const char *cmd, memcached_param_t * param)
  * Common write command handler for memcached
  */
 memc_error_t
-memc_write (memcached_ctx_t * ctx, const char *cmd, memcached_param_t * param, int expire)
+memc_write (memcached_ctx_t * ctx, const gchar *cmd, memcached_param_t * param, gint expire)
 {
        ctx->cmd = cmd;
        ctx->op = CMD_WRITE;
@@ -622,7 +622,7 @@ memc_delete (memcached_ctx_t * ctx, memcached_param_t * param)
  * writing is done to each memcached server
  */
 memc_error_t
-memc_write_mirror (memcached_ctx_t * ctx, size_t memcached_num, const char *cmd, memcached_param_t * param, int expire)
+memc_write_mirror (memcached_ctx_t * ctx, size_t memcached_num, const gchar *cmd, memcached_param_t * param, gint expire)
 {
        memc_error_t                    r, result = OK;
 
@@ -645,7 +645,7 @@ memc_write_mirror (memcached_ctx_t * ctx, size_t memcached_num, const char *cmd,
  * reading is done from first active memcached server
  */
 memc_error_t
-memc_read_mirror (memcached_ctx_t * ctx, size_t memcached_num, const char *cmd, memcached_param_t * param)
+memc_read_mirror (memcached_ctx_t * ctx, size_t memcached_num, const gchar *cmd, memcached_param_t * param)
 {
        memc_error_t                    r, result = OK;
 
@@ -676,7 +676,7 @@ memc_read_mirror (memcached_ctx_t * ctx, size_t memcached_num, const char *cmd,
  * deleting is done for each active memcached server
  */
 memc_error_t
-memc_delete_mirror (memcached_ctx_t * ctx, size_t memcached_num, const char *cmd, memcached_param_t * param)
+memc_delete_mirror (memcached_ctx_t * ctx, size_t memcached_num, const gchar *cmd, memcached_param_t * param)
 {
        memc_error_t                    r, result = OK;
 
@@ -700,7 +700,7 @@ memc_delete_mirror (memcached_ctx_t * ctx, size_t memcached_num, const char *cmd
 /* 
  * Initialize memcached context for specified protocol
  */
-int
+gint
 memc_init_ctx (memcached_ctx_t * ctx)
 {
        if (ctx == NULL) {
@@ -733,10 +733,10 @@ memc_init_ctx (memcached_ctx_t * ctx)
 /*
  * Mirror init
  */
-int
+gint
 memc_init_ctx_mirror (memcached_ctx_t * ctx, size_t memcached_num)
 {
-       int                             r, result = -1;
+       gint                            r, result = -1;
        while (memcached_num--) {
                if (ctx[memcached_num].alive == 1) {
                        r = memc_init_ctx (&ctx[memcached_num]);
@@ -756,7 +756,7 @@ memc_init_ctx_mirror (memcached_ctx_t * ctx, size_t memcached_num)
 /*
  * Close context connection
  */
-int
+gint
 memc_close_ctx (memcached_ctx_t * ctx)
 {
        if (ctx != NULL && ctx->sock != -1) {
@@ -770,10 +770,10 @@ memc_close_ctx (memcached_ctx_t * ctx)
 /* 
  * Mirror close
  */
-int
+gint
 memc_close_ctx_mirror (memcached_ctx_t * ctx, size_t memcached_num)
 {
-       int                             r = 0;
+       gint                            r = 0;
        while (memcached_num--) {
                if (ctx[memcached_num].alive == 1) {
                        r = memc_close_ctx (&ctx[memcached_num]);
@@ -788,10 +788,10 @@ memc_close_ctx_mirror (memcached_ctx_t * ctx, size_t memcached_num)
 }
 
 
-const char                     *
+const gchar                     *
 memc_strerror (memc_error_t err)
 {
-       const char                     *p;
+       const gchar                     *p;
 
        switch (err) {
        case OK:
index 46bcae4657473753afb385c184abd7a4e28fa2cb..098e26eeae12a824ca0846835a0b4bf1b9c7c267 100644 (file)
@@ -40,11 +40,11 @@ typedef enum memc_op {
 } memc_opt_t;
 
 typedef struct memcached_param_s {
-       char key[MAXKEYLEN];
+       gchar key[MAXKEYLEN];
        u_char *buf;
        size_t bufsize;
        size_t bufpos;
-       int expire;
+       gint expire;
 } memcached_param_t;
 
 
@@ -52,11 +52,11 @@ typedef struct memcached_param_s {
 typedef struct memcached_ctx_s {
        memc_proto_t protocol;
        struct in_addr addr;
-       uint16_t port;
-       int sock;
+       guint16 port;
+       gint sock;
        struct timeval timeout;
        /* Counter that is used for memcached operations in network byte order */
-       uint16_t count;
+       guint16 count;
        /* Flag that signalize that this memcached is alive */
        short alive;
        /* Options that can be specified for memcached connection */
@@ -64,7 +64,7 @@ typedef struct memcached_ctx_s {
        /* Current operation */
        memc_opt_t op;
        /* Current command */
-       const char *cmd;
+       const gchar *cmd;
        /* Current param */
        memcached_param_t *param;
        /* Callback for current operation */
@@ -84,8 +84,8 @@ typedef void (*memcached_callback_t) (memcached_ctx_t *ctx, memc_error_t error,
  * 0 - success
  * -1 - error (error is stored in errno)
  */
-int memc_init_ctx (memcached_ctx_t *ctx);
-int memc_init_ctx_mirror (memcached_ctx_t *ctx, size_t memcached_num);
+gint memc_init_ctx (memcached_ctx_t *ctx);
+gint memc_init_ctx_mirror (memcached_ctx_t *ctx, size_t memcached_num);
 /*
  * Memcached function for getting, setting, adding values to memcached server
  * ctx - valid memcached context
@@ -124,19 +124,19 @@ int memc_init_ctx_mirror (memcached_ctx_t *ctx, size_t memcached_num);
 #define memc_prepend_mirror(ctx, num, param, expire) memc_write_mirror(ctx, num, "prepend", param, expire)
 
 
-memc_error_t memc_read (memcached_ctx_t *ctx, const char *cmd, memcached_param_t *param);
-memc_error_t memc_write (memcached_ctx_t *ctx, const char *cmd, memcached_param_t *param, int expire);
+memc_error_t memc_read (memcached_ctx_t *ctx, const gchar *cmd, memcached_param_t *param);
+memc_error_t memc_write (memcached_ctx_t *ctx, const gchar *cmd, memcached_param_t *param, gint expire);
 memc_error_t memc_delete (memcached_ctx_t *ctx, memcached_param_t *params);
 
-memc_error_t memc_write_mirror (memcached_ctx_t *ctx, size_t memcached_num, const char *cmd, memcached_param_t *param, int expire);
-memc_error_t memc_read_mirror (memcached_ctx_t *ctx, size_t memcached_num, const char *cmd, memcached_param_t *param);
-memc_error_t memc_delete_mirror (memcached_ctx_t *ctx, size_t memcached_num, const char *cmd, memcached_param_t *param);
+memc_error_t memc_write_mirror (memcached_ctx_t *ctx, size_t memcached_num, const gchar *cmd, memcached_param_t *param, gint expire);
+memc_error_t memc_read_mirror (memcached_ctx_t *ctx, size_t memcached_num, const gchar *cmd, memcached_param_t *param);
+memc_error_t memc_delete_mirror (memcached_ctx_t *ctx, size_t memcached_num, const gchar *cmd, memcached_param_t *param);
 
 /* Return symbolic name of memcached error*/
-const char * memc_strerror (memc_error_t err);
+const gchar * memc_strerror (memc_error_t err);
 
 /* Destroy socket from ctx */
-int memc_close_ctx (memcached_ctx_t *ctx);
-int memc_close_ctx_mirror (memcached_ctx_t *ctx, size_t memcached_num);
+gint memc_close_ctx (memcached_ctx_t *ctx);
+gint memc_close_ctx_mirror (memcached_ctx_t *ctx, size_t memcached_num);
 
 #endif
index 9df569f02933851d69c1a04b336fa3c9fbe20572..845386b219dbb1bfa6bb56dcb5a17c7cd87f4eff 100644 (file)
 #define UTF8_CHARSET "UTF-8"
 
 GByteArray                     *
-strip_html_tags (struct worker_task *task, memory_pool_t * pool, struct mime_text_part *part, GByteArray * src, int *stateptr)
+strip_html_tags (struct worker_task *task, memory_pool_t * pool, struct mime_text_part *part, GByteArray * src, gint *stateptr)
 {
        uint8_t                        *tbuf = NULL, *p, *tp = NULL, *rp, *tbegin = NULL, c, lc;
-       int                             br, i = 0, depth = 0, in_q = 0;
-       int                             state = 0;
+       gint                            br, i = 0, depth = 0, in_q = 0;
+       gint                            state = 0;
        GByteArray                     *buf;
        GNode                          *level_ptr = NULL;
 
@@ -248,9 +248,9 @@ strip_html_tags (struct worker_task *task, memory_pool_t * pool, struct mime_tex
 }
 
 static void
-parse_qmail_recv (memory_pool_t * pool, char *line, struct received_header *r)
+parse_qmail_recv (memory_pool_t * pool, gchar *line, struct received_header *r)
 {
-       char                           *s, *p, t;
+       gchar                           *s, *p, t;
 
        /* We are intersted only with received from network headers */
        if ((p = strstr (line, "from network")) == NULL) {
@@ -288,10 +288,10 @@ parse_qmail_recv (memory_pool_t * pool, char *line, struct received_header *r)
 }
 
 static void
-parse_recv_header (memory_pool_t * pool, char *line, struct received_header *r)
+parse_recv_header (memory_pool_t * pool, gchar *line, struct received_header *r)
 {
-       char                           *p, *s, t, **res = NULL;
-       int                             state = 0, next_state = 0;
+       gchar                           *p, *s, t, **res = NULL;
+       gint                            state = 0, next_state = 0;
 
        g_strstrip (line);
        p = line;
@@ -490,7 +490,7 @@ convert_text_to_utf (struct worker_task *task, GByteArray * part_content, GMimeC
 {
        GError                         *err = NULL;
        gsize                           read_bytes, write_bytes;
-       const char                     *charset;
+       const gchar                     *charset;
        gchar                          *res_str;
        GByteArray                     *result_array;
 
@@ -530,7 +530,7 @@ process_text_part (struct worker_task *task, GByteArray *part_content, GMimeCont
                GMimeObject *part, GMimeObject *parent, gboolean is_empty)
 {
        struct mime_text_part          *text_part;
-       const char                     *cd;
+       const gchar                     *cd;
 
        /* Skip attachements */
 #ifndef GMIME24
@@ -740,7 +740,7 @@ destroy_message (void *pointer)
        g_object_unref (msg);
 }
 
-int
+gint
 process_message (struct worker_task *task)
 {
        GMimeMessage                   *message;
@@ -751,7 +751,7 @@ process_message (struct worker_task *task)
        GMimePart                      *part;
        GMimeDataWrapper               *wrapper;
        struct received_header         *recv;
-       char                           *mid;
+       gchar                           *mid;
 
        tmp = memory_pool_alloc (task->task_pool, sizeof (GByteArray));
        tmp->data = task->msg->begin;
@@ -766,7 +766,7 @@ process_message (struct worker_task *task)
 
        if (task->is_mime) {
 
-               debug_task ("construct mime parser from string length %d", (int)task->msg->len);
+               debug_task ("construct mime parser from string length %d", (gint)task->msg->len);
                /* create a new parser object to parse the stream */
                parser = g_mime_parser_new_with_stream (stream);
                g_object_unref (stream);
@@ -887,7 +887,7 @@ process_message (struct worker_task *task)
                if (task->rcpt) {
                        cur = task->rcpt;
                        while (cur) {
-                               g_mime_message_add_recipient (task->message, GMIME_RECIPIENT_TYPE_TO, NULL, (char *)cur->data);
+                               g_mime_message_add_recipient (task->message, GMIME_RECIPIENT_TYPE_TO, NULL, (gchar *)cur->data);
                                cur = g_list_next (cur);
                        }
                }
@@ -899,8 +899,8 @@ process_message (struct worker_task *task)
 
 struct raw_header {
        struct raw_header              *next;
-       char                           *name;
-       char                           *value;
+       gchar                           *name;
+       gchar                           *value;
 };
 
 typedef struct _GMimeHeader {
@@ -926,7 +926,7 @@ enum {
 
 #ifndef GMIME24
 static void
-header_iterate (memory_pool_t * pool, struct raw_header *h, GList ** ret, const char *field)
+header_iterate (memory_pool_t * pool, struct raw_header *h, GList ** ret, const gchar *field)
 {
        while (h) {
                if (h->value && !g_strncasecmp (field, h->name, strlen (field))) {
@@ -942,10 +942,10 @@ header_iterate (memory_pool_t * pool, struct raw_header *h, GList ** ret, const
 }
 #else
 static void
-header_iterate (memory_pool_t * pool, GMimeHeaderList * ls, GList ** ret, const char *field)
+header_iterate (memory_pool_t * pool, GMimeHeaderList * ls, GList ** ret, const gchar *field)
 {
        GMimeHeaderIter                *iter;
-       const char                     *name;
+       const gchar                     *name;
 
        if (ls == NULL) {
                *ret = NULL;
@@ -977,9 +977,9 @@ header_iterate (memory_pool_t * pool, GMimeHeaderList * ls, GList ** ret, const
 struct multipart_cb_data {
        GList                          *ret;
        memory_pool_t                  *pool;
-       const char                     *field;
+       const gchar                     *field;
        gboolean                        try_search;
-       int                             rec;
+       gint                            rec;
 };
 
 #define MAX_REC 10
@@ -1030,7 +1030,7 @@ multipart_iterate (GMimeObject * part, gpointer user_data)
 }
 
 static GList                   *
-local_message_get_header (memory_pool_t * pool, GMimeMessage * message, const char *field)
+local_message_get_header (memory_pool_t * pool, GMimeMessage * message, const gchar *field)
 {
        GList                          *gret = NULL;
        GMimeObject                    *part;
@@ -1113,7 +1113,7 @@ void
 local_mime_message_set_date_from_string (GMimeMessage * message, const gchar * string)
 {
        time_t                          date;
-       int                             offset = 0;
+       gint                            offset = 0;
 
        date = g_mime_utils_header_decode_date (string, &offset);
        g_mime_message_set_date (message, date, offset);
@@ -1122,11 +1122,11 @@ local_mime_message_set_date_from_string (GMimeMessage * message, const gchar * s
 /*
  * Replacements for standart gmime functions but converting adresses to IA
  */
-static const char              *
+static const gchar              *
 local_message_get_sender (GMimeMessage * message)
 {
-       char                           *res;
-       const char                     *from = g_mime_message_get_sender (message);
+       gchar                           *res;
+       const gchar                     *from = g_mime_message_get_sender (message);
        InternetAddressList            *ia;
 
 #ifndef        GMIME24
@@ -1147,11 +1147,11 @@ local_message_get_sender (GMimeMessage * message)
        return res;
 }
 
-static const char              *
+static const gchar              *
 local_message_get_reply_to (GMimeMessage * message)
 {
-       char                           *res;
-       const char                     *from = g_mime_message_get_reply_to (message);
+       gchar                           *res;
+       const gchar                     *from = g_mime_message_get_reply_to (message);
        InternetAddressList            *ia;
 
 #ifndef        GMIME24
@@ -1190,7 +1190,7 @@ ADD_RECIPIENT_TEMPLATE (to, GMIME_RECIPIENT_TYPE_TO)
        ADD_RECIPIENT_TEMPLATE (bcc, GMIME_RECIPIENT_TYPE_BCC)
 #   define GET_RECIPIENT_TEMPLATE(type,def)                                                                                                            \
 static InternetAddressList*                                                                                                                                            \
-local_message_get_recipients_##type (GMimeMessage *message, const char *unused)                                        \
+local_message_get_recipients_##type (GMimeMessage *message, const gchar *unused)                                       \
 {                                                                                                                                                                                              \
        return g_mime_message_get_recipients (message, (def));                                                                          \
 }
@@ -1199,17 +1199,17 @@ local_message_get_recipients_##type (GMimeMessage *message, const char *unused)
        GET_RECIPIENT_TEMPLATE (bcc, GMIME_RECIPIENT_TYPE_BCC)
 #endif
 /* different declarations for different types of set and get functions */
-  typedef const char             *(*GetFunc) (GMimeMessage * message);
-  typedef InternetAddressList    *(*GetRcptFunc) (GMimeMessage * message, const char *type);
-  typedef GList                  *(*GetListFunc) (memory_pool_t * pool, GMimeMessage * message, const char *type);
-  typedef void                    (*SetFunc) (GMimeMessage * message, const char *value);
-  typedef void                    (*SetListFunc) (GMimeMessage * message, const char *field, const char *value);
+  typedef const gchar             *(*GetFunc) (GMimeMessage * message);
+  typedef InternetAddressList    *(*GetRcptFunc) (GMimeMessage * message, const gchar *type);
+  typedef GList                  *(*GetListFunc) (memory_pool_t * pool, GMimeMessage * message, const gchar *type);
+  typedef void                    (*SetFunc) (GMimeMessage * message, const gchar *value);
+  typedef void                    (*SetListFunc) (GMimeMessage * message, const gchar *field, const gchar *value);
 
 /** different types of functions
 *
 * FUNC_CHARPTR
 *      - function with no arguments
-*      - get returns char*
+*      - get returns gchar*
 *
 * FUNC_IA (from Internet Address)
 *      - function with additional "field" argument from the fieldfunc table,
@@ -1231,7 +1231,7 @@ local_message_get_recipients_##type (GMimeMessage *message, const char *unused)
 * functions.
 **/
   static struct {
-         char                           *name;
+         gchar                           *name;
          GetFunc                         func;
          GetRcptFunc                     rcptfunc;
          GetListFunc                     getlistfunc;
@@ -1272,7 +1272,7 @@ local_message_get_recipients_##type (GMimeMessage *message, const char *unused)
 * message_set_header: set header of any type excluding special (Content- and MIME-Version:)
 **/
 void
-message_set_header (GMimeMessage * message, const char *field, const char *value)
+message_set_header (GMimeMessage * message, const gchar *field, const gchar *value)
 {
        gint                            i;
 
@@ -1305,10 +1305,10 @@ message_set_header (GMimeMessage * message, const char *field, const char *value
 * You should free the GList list by yourself.
 **/
 GList                          *
-message_get_header (memory_pool_t * pool, GMimeMessage * message, const char *field)
+message_get_header (memory_pool_t * pool, GMimeMessage * message, const gchar *field)
 {
        gint                            i;
-       char                           *ret = NULL, *ia_string;
+       gchar                           *ret = NULL, *ia_string;
        GList                          *gret = NULL;
        InternetAddressList            *ia_list = NULL, *ia;
 
@@ -1316,10 +1316,10 @@ message_get_header (memory_pool_t * pool, GMimeMessage * message, const char *fi
                if (!fieldfunc[i].name || !g_strncasecmp (field, fieldfunc[i].name, strlen (fieldfunc[i].name))) {
                        switch (fieldfunc[i].functype) {
                        case FUNC_CHARFREEPTR:
-                               ret = (char *)(*(fieldfunc[i].func)) (message);
+                               ret = (gchar *)(*(fieldfunc[i].func)) (message);
                                break;
                        case FUNC_CHARPTR:
-                               ret = (char *)(*(fieldfunc[i].func)) (message);
+                               ret = (gchar *)(*(fieldfunc[i].func)) (message);
                                break;
                        case FUNC_IA:
                                ia_list = (*(fieldfunc[i].rcptfunc)) (message, field);
index 4b51064ab7d9b7e3d0b9d9a14cefad92202955d4..d8be944e33937544e829604a64583cb67acfe2de 100644 (file)
@@ -17,7 +17,7 @@ struct mime_part {
        GByteArray *content;
        GMimeObject *parent;
        gchar *checksum;
-       const char *filename;
+       const gchar *filename;
 };
 
 struct mime_text_part {
@@ -37,12 +37,12 @@ struct mime_text_part {
 };
 
 struct received_header {
-       char *from_hostname;
-       char *from_ip;
-       char *real_hostname;
-       char *real_ip;
-       char *by_hostname;
-       int is_error;
+       gchar *from_hostname;
+       gchar *from_ip;
+       gchar *real_hostname;
+       gchar *real_ip;
+       gchar *by_hostname;
+       gint is_error;
 };
 
 /**
@@ -51,9 +51,9 @@ struct received_header {
  * @param task worker_task object
  * @return 0 if we have delayed filters to process and 1 if we have finished with processing
  */
-int process_message (struct worker_task *task);
+gint process_message (struct worker_task *task);
 
-void message_set_header (GMimeMessage *message, const char *field, const char *value);
-GList* message_get_header (memory_pool_t *pool, GMimeMessage *message, const char *field);
+void message_set_header (GMimeMessage *message, const gchar *field, const gchar *value);
+GList* message_get_header (memory_pool_t *pool, GMimeMessage *message, const gchar *field);
 
 #endif
index 74dca3d8470098736dc6049887b684044688e2a3..342a0e75fd98c9bcb72d914ef23c6d6918d9622d 100644 (file)
@@ -62,7 +62,7 @@ void
 init_perl_filters (struct config_file *cfg)
 {
        struct perl_module             *module;
-       char                           *init_func;
+       gchar                           *init_func;
        size_t                          funclen;
        SV                             *sv;
 
@@ -93,10 +93,10 @@ init_perl_filters (struct config_file *cfg)
 }
 
 
-int
-perl_call_header_filter (const char *function, struct worker_task *task)
+gint
+perl_call_header_filter (const gchar *function, struct worker_task *task)
 {
-       int                             result;
+       gint                            result;
        SV                             *sv;
 
        dTHXa (perl_interpreter);
@@ -125,10 +125,10 @@ perl_call_header_filter (const char *function, struct worker_task *task)
        return result;
 }
 
-int
-perl_call_chain_filter (const char *function, struct worker_task *task, int *marks, unsigned int number)
+gint
+perl_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number)
 {
-       int                             result, i;
+       gint                            result, i;
        AV                             *av;
        SV                             *sv;
 
@@ -207,7 +207,7 @@ perl_call_memcached_callback (memcached_ctx_t * ctx, memc_error_t error, void *d
 struct consolidation_callback_data {
        struct worker_task             *task;
        double                          score;
-       const char                     *func;
+       const gchar                     *func;
 };
 
 static void
@@ -226,7 +226,7 @@ perl_consolidation_callback (gpointer key, gpointer value, gpointer arg)
 
        PUSHMARK (SP);
 
-       XPUSHs (sv_2mortal (newSVpv ((const char *)key, 0)));
+       XPUSHs (sv_2mortal (newSVpv ((const gchar *)key, 0)));
        XPUSHs (sv_2mortal (newSVnv (s->score)));
        PUTBACK;
 
@@ -240,7 +240,7 @@ perl_consolidation_callback (gpointer key, gpointer value, gpointer arg)
 }
 
 double
-perl_consolidation_func (struct worker_task *task, const char *metric_name, const char *function_name)
+perl_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *function_name)
 {
        struct metric_result           *metric_res;
        double                          res = 0.;
index 109ead48d1cbad79fa32731bfbde1d27515f6804..5bc75cd3ef7497c940bcaa230fafa407c1f4e92b 100644 (file)
@@ -12,11 +12,11 @@ struct config_file;
 
 void init_perl_filters (struct config_file *cfg);
 
-int perl_call_filter (const char *function, struct worker_task *task);
-int perl_call_chain_filter (const char *function, struct worker_task *task, int *marks, unsigned int number);
+gint perl_call_filter (const gchar *function, struct worker_task *task);
+gint perl_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number);
 
 void perl_call_memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data);
 
-double perl_consolidation_func (struct worker_task *task, const char *metric_name, const char *function_name);
+double perl_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *function_name);
 
 #endif
index 785cd3a598ca45bca42f3f20a88d1f1a622bd962..2f62464a630b9f522f692c3117e5fb5d319d8c16 100644 (file)
@@ -43,8 +43,8 @@
 #define DEFAULT_THRESHOLD 0.1
 
 struct chartable_ctx {
-       int                             (*filter) (struct worker_task * task);
-       char                           *symbol;
+       gint                            (*filter) (struct worker_task * task);
+       gchar                           *symbol;
        double                          threshold;
 
        memory_pool_t                  *chartable_pool;
@@ -52,10 +52,10 @@ struct chartable_ctx {
 
 static struct chartable_ctx    *chartable_module_ctx = NULL;
 
-static int                      chartable_mime_filter (struct worker_task *task);
+static gint                      chartable_mime_filter (struct worker_task *task);
 static void                     chartable_symbol_callback (struct worker_task *task, void *unused);
 
-int
+gint
 chartable_module_init (struct config_file *cfg, struct module_ctx **ctx)
 {
        chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx));
@@ -69,11 +69,11 @@ chartable_module_init (struct config_file *cfg, struct module_ctx **ctx)
 }
 
 
-int
+gint
 chartable_module_config (struct config_file *cfg)
 {
-       char                           *value;
-       int                             res = TRUE;
+       gchar                           *value;
+       gint                            res = TRUE;
 
        if ((value = get_module_opt (cfg, "chartable", "symbol")) != NULL) {
                chartable_module_ctx->symbol = memory_pool_strdup (chartable_module_ctx->chartable_pool, value);
@@ -98,7 +98,7 @@ chartable_module_config (struct config_file *cfg)
        return res;
 }
 
-int
+gint
 chartable_module_reconfig (struct config_file *cfg)
 {
        memory_pool_delete (chartable_module_ctx->chartable_pool);
@@ -110,11 +110,11 @@ chartable_module_reconfig (struct config_file *cfg)
 static                          gboolean
 check_part (struct mime_text_part *part, gboolean raw_mode)
 {
-       unsigned char                  *p, *p1;
+       guchar                          *p, *p1;
        gunichar                        c, t;
        GUnicodeScript                  scc, sct;
-       uint32_t                        mark = 0, total = 0;
-       uint32_t                        remain = part->content->len;
+       guint32                         mark = 0, total = 0;
+       guint32                         remain = part->content->len;
 
        p = part->content->data;
 
@@ -188,7 +188,7 @@ chartable_symbol_callback (struct worker_task *task, void *unused)
 
 }
 
-static int
+static gint
 chartable_mime_filter (struct worker_task *task)
 {
        /* XXX: remove it */
index 1b20b27420ad76fc71ea38ddfd2074341e6df1d5..29dc040a35eff496678739638715231b6bbef1e9 100644 (file)
 
 #define DEFAULT_SYMBOL "R_BAD_EMAIL"
 
-static const char              *email_re_text =
+static const gchar              *email_re_text =
        "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\\b";
 
 struct email_ctx {
-       int                             (*filter) (struct worker_task * task);
-       char                           *symbol;
+       gint                            (*filter) (struct worker_task * task);
+       gchar                           *symbol;
        GRegex                         *email_re;
 
        GHashTable                     *blacklist;
-       char                           *blacklist_file;
+       gchar                           *blacklist_file;
 
        memory_pool_t                  *email_pool;
 };
 
 static struct email_ctx        *email_module_ctx = NULL;
 
-static int                      emails_mime_filter (struct worker_task *task);
+static gint                      emails_mime_filter (struct worker_task *task);
 static void                     emails_symbol_callback (struct worker_task *task, void *unused);
-static int                      emails_command_handler (struct worker_task *task);
+static gint                      emails_command_handler (struct worker_task *task);
 
-int
+gint
 emails_module_init (struct config_file *cfg, struct module_ctx **ctx)
 {
        GError                         *err = NULL;
@@ -82,11 +82,11 @@ emails_module_init (struct config_file *cfg, struct module_ctx **ctx)
 }
 
 
-int
+gint
 emails_module_config (struct config_file *cfg)
 {
-       char                           *value;
-       int                             res = TRUE;
+       gchar                           *value;
+       gint                            res = TRUE;
 
        if ((value = get_module_opt (cfg, "emails", "symbol")) != NULL) {
                email_module_ctx->symbol = memory_pool_strdup (email_module_ctx->email_pool, value);
@@ -106,7 +106,7 @@ emails_module_config (struct config_file *cfg)
        return res;
 }
 
-int
+gint
 emails_module_reconfig (struct config_file *cfg)
 {
        memory_pool_delete (email_module_ctx->email_pool);
@@ -122,8 +122,8 @@ extract_emails (struct worker_task *task)
        GMatchInfo                     *info;
        GError                         *err = NULL;
        struct mime_text_part          *part;
-       char                           *email_str;
-       int                             rc;
+       gchar                           *email_str;
+       gint                            rc;
 
        cur = g_list_first (task->text_parts);
        while (cur) {
@@ -134,7 +134,7 @@ extract_emails (struct worker_task *task)
                        continue;
                }
 
-               rc = g_regex_match_full (email_module_ctx->email_re, (const char *)part->orig->data, part->orig->len, 0, 0, &info, &err);
+               rc = g_regex_match_full (email_module_ctx->email_re, (const gchar *)part->orig->data, part->orig->len, 0, 0, &info, &err);
                if (rc) {
                        while (g_match_info_matches (info)) {
                                email_str = g_match_info_fetch (info, 0);
@@ -163,12 +163,12 @@ extract_emails (struct worker_task *task)
        return res;
 }
 
-static int
+static gint
 emails_command_handler (struct worker_task *task)
 {
        GList                          *emails, *cur;
-       char                            outbuf[BUFSIZ];
-       int                             r, num = 0;
+       gchar                           outbuf[BUFSIZ];
+       gint                            r, num = 0;
 
        emails = extract_emails (task);
 
@@ -181,10 +181,10 @@ emails_command_handler (struct worker_task *task)
        while (cur) {
                num++;
                if (g_list_next (cur) != NULL) {
-                       r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s, ", (char *)cur->data);
+                       r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s, ", (gchar *)cur->data);
                }
                else {
-                       r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s", (char *)cur->data);
+                       r += snprintf (outbuf + r, sizeof (outbuf) - r - 2, "%s", (gchar *)cur->data);
                }
                cur = g_list_next (cur);
        }
@@ -213,7 +213,7 @@ emails_symbol_callback (struct worker_task *task, void *unused)
 
                        while (cur) {
                                if (g_hash_table_lookup (email_module_ctx->blacklist, cur->data) != NULL) {
-                                       insert_result (task, email_module_ctx->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, (char *)cur->data)));
+                                       insert_result (task, email_module_ctx->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, (gchar *)cur->data)));
 
                                }
                                cur = g_list_next (cur);
@@ -223,7 +223,7 @@ emails_symbol_callback (struct worker_task *task, void *unused)
 
 }
 
-static int
+static gint
 emails_mime_filter (struct worker_task *task)
 {
        /* XXX: remove this */
index edfc1caa8a8d51c39e3771c3187f8c350db21590..1942d3c5aa811f257bc9a8e41cb0f2925be7345b 100644 (file)
 
 struct storage_server {
        struct upstream                 up;
-       char                           *name;
+       gchar                           *name;
        struct in_addr                  addr;
-       uint16_t                        port;
+       guint16                        port;
 };
 
 struct fuzzy_mapping {
-       uint32_t fuzzy_flag;
-       char *symbol;
+       guint32                         fuzzy_flag;
+       gchar                           *symbol;
        double weight;
 };
 
 struct fuzzy_mime_type {
-       char *type;
-       char *subtype;
+       gchar                           *type;
+       gchar                           *subtype;
 };
 
 struct fuzzy_ctx {
-       int                             (*filter) (struct worker_task * task);
-       char                           *symbol;
+       gint                            (*filter) (struct worker_task * task);
+       gchar                           *symbol;
        struct storage_server          *servers;
-       int                             servers_num;
+       gint                            servers_num;
        memory_pool_t                  *fuzzy_pool;
        double                          max_score;
        gint32                          min_hash_len;
@@ -94,43 +94,43 @@ struct fuzzy_ctx {
 };
 
 struct fuzzy_client_session {
-       int                             state;
+       gint                            state;
        fuzzy_hash_t                   *h;
        struct event                    ev;
        struct timeval                  tv;
        struct worker_task             *task;
        struct storage_server          *server;
-       int                             fd;
+       gint                            fd;
 };
 
 struct fuzzy_learn_session {
        struct event                    ev;
        fuzzy_hash_t                   *h;
-       int                             cmd;
-       int                             value;
-       int                             flag;
-       int                            *saved;
+       gint                            cmd;
+       gint                            value;
+       gint                            flag;
+       gint                            *saved;
        struct timeval                  tv;
        struct controller_session      *session;
        struct storage_server          *server;
        struct worker_task             *task;
-       int                             fd;
+       gint                            fd;
 };
 
 static struct fuzzy_ctx        *fuzzy_module_ctx = NULL;
 static const gchar              hex_digits[] = "0123456789abcdef";
 
-static int                      fuzzy_mime_filter (struct worker_task *task);
+static gint                      fuzzy_mime_filter (struct worker_task *task);
 static void                     fuzzy_symbol_callback (struct worker_task *task, void *unused);
-static void                     fuzzy_add_handler (char **args, struct controller_session *session);
-static void                     fuzzy_delete_handler (char **args, struct controller_session *session);
+static void                     fuzzy_add_handler (gchar **args, struct controller_session *session);
+static void                     fuzzy_delete_handler (gchar **args, struct controller_session *session);
 
 /* Flags string is in format <numeric_flag>:<SYMBOL>:weight[, <numeric_flag>:<SYMBOL>:weight...] */
 static void
-parse_flags_string (char *str)
+parse_flags_string (gchar *str)
 {
-       char                          **strvec, *item, *err_str, **map_str;
-       int                             num, i, t;
+       gchar                           **strvec, *item, *err_str, **map_str;
+       gint                            num, i, t;
        struct fuzzy_mapping           *map;
        
        strvec = g_strsplit_set (str, ", ;", 0);
@@ -169,10 +169,10 @@ parse_flags_string (char *str)
 }
 
 static GList *
-parse_mime_types (const char *str)
+parse_mime_types (const gchar *str)
 {
-       char                          **strvec, *p;
-       int                             num, i;
+       gchar                           **strvec, *p;
+       gint                            num, i;
        struct fuzzy_mime_type         *type;
        GList                          *res = NULL;
 
@@ -218,10 +218,10 @@ fuzzy_check_content_type (GMimeContentType *type)
 }
 
 static void
-parse_servers_string (char *str)
+parse_servers_string (gchar *str)
 {
-       char                          **strvec, *p, portbuf[6], *name;
-       int                             num, i, j, port;
+       gchar                           **strvec, *p, portbuf[6], *name;
+       gint                            num, i, j, port;
        struct hostent                 *hent;
        struct in_addr                  addr;
 
@@ -277,7 +277,7 @@ parse_servers_string (char *str)
 }
 
 static double
-fuzzy_normalize (int32_t in, double weight)
+fuzzy_normalize (gint32 in, double weight)
 {
        double ms = weight, ams = fabs (ms), ain = fabs (in);
        
@@ -297,11 +297,11 @@ fuzzy_normalize (int32_t in, double weight)
        return (double)in;
 }
 
-static const char *
+static const gchar *
 fuzzy_to_string (fuzzy_hash_t *h)
 {
-       static char strbuf [FUZZY_HASHLEN * 2 + 1];
-       int i;
+       static gchar strbuf [FUZZY_HASHLEN * 2 + 1];
+       gint                            i;
        guint8 byte;
 
        for (i = 0; i < FUZZY_HASHLEN; i ++) {
@@ -318,7 +318,7 @@ fuzzy_to_string (fuzzy_hash_t *h)
        return strbuf;
 }
 
-int
+gint
 fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx)
 {
        fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx));
@@ -334,11 +334,11 @@ fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx)
        return 0;
 }
 
-int
+gint
 fuzzy_check_module_config (struct config_file *cfg)
 {
-       char                           *value;
-       int                             res = TRUE;
+       gchar                           *value;
+       gint                            res = TRUE;
 
        if ((value = get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) {
                fuzzy_module_ctx->symbol = memory_pool_strdup (fuzzy_module_ctx->fuzzy_pool, value);
@@ -406,7 +406,7 @@ fuzzy_check_module_config (struct config_file *cfg)
        return res;
 }
 
-int
+gint
 fuzzy_check_module_reconfig (struct config_file *cfg)
 {
        memory_pool_delete (fuzzy_module_ctx->fuzzy_pool);
@@ -436,13 +436,13 @@ fuzzy_io_fin (void *ud)
 
 /* Call this whenever we got data from fuzzy storage */
 static void
-fuzzy_io_callback (int fd, short what, void *arg)
+fuzzy_io_callback (gint fd, short what, void *arg)
 {
        struct fuzzy_client_session    *session = arg;
        struct fuzzy_cmd                cmd;
        struct fuzzy_mapping           *map;
-       char                            buf[62], *err_str, *symbol;
-       int                             value = 0, flag = 0, r;
+       gchar                           buf[62], *err_str, *symbol;
+       gint                            value = 0, flag = 0, r;
        double                          nval;
 
        if (what == EV_WRITE) {
@@ -522,12 +522,12 @@ fuzzy_learn_fin (void *arg)
 }
 
 static void
-fuzzy_learn_callback (int fd, short what, void *arg)
+fuzzy_learn_callback (gint fd, short what, void *arg)
 {
        struct fuzzy_learn_session     *session = arg;
        struct fuzzy_cmd                cmd;
-       char                            buf[64];
-       int                             r;
+       gchar                           buf[64];
+       gint                            r;
 
        if (what == EV_WRITE) {
                /* Send command to storage */
@@ -588,7 +588,7 @@ register_fuzzy_call (struct worker_task *task, fuzzy_hash_t *h)
 {
        struct fuzzy_client_session    *session;
        struct storage_server          *selected;
-       int                             sock;
+       gint                            sock;
 
        /* Get upstream */
 #ifdef HAVE_CLOCK_GETTIME
@@ -629,14 +629,14 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused)
        struct mime_text_part          *part;
        struct mime_part               *mime_part;
        struct rspamd_image            *image;
-       char                           *checksum;
+       gchar                           *checksum;
        GList                          *cur;
        fuzzy_hash_t                   *fake_fuzzy;
 
 
        /* Check whitelist */
        if (fuzzy_module_ctx->whitelist && task->from_addr.s_addr != 0) {
-               if (radix32tree_find (fuzzy_module_ctx->whitelist, ntohl ((uint32_t) task->from_addr.s_addr)) != RADIX_NO_VALUE) {
+               if (radix32tree_find (fuzzy_module_ctx->whitelist, ntohl ((guint32) task->from_addr.s_addr)) != RADIX_NO_VALUE) {
                        msg_info ("<%s>, address %s is whitelisted, skip fuzzy check",
                                        task->message_id, inet_ntoa (task->from_addr));
                        return;
@@ -703,12 +703,12 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused)
 
 G_INLINE_FUNC gboolean
 register_fuzzy_controller_call (struct controller_session *session, struct worker_task *task, fuzzy_hash_t *h,
-               int cmd, int value, int flag, int *saved)
+               gint                            cmd, gint value, gint flag, gint *saved)
 {
        struct fuzzy_learn_session     *s;
        struct storage_server          *selected;
-       int                             sock, r;
-       char                            out_buf[BUFSIZ];
+       gint                            sock, r;
+       gchar                           out_buf[BUFSIZ];
 
        /* Get upstream */
 #ifdef HAVE_CLOCK_GETTIME
@@ -765,8 +765,8 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in)
        struct mime_part               *mime_part;
        struct rspamd_image            *image;
        GList                          *cur;
-       int                             r, cmd = 0, value = 0, flag = 0, *saved, *sargs;
-       char                            out_buf[BUFSIZ], *checksum;
+       gint                            r, cmd = 0, value = 0, flag = 0, *saved, *sargs;
+       gchar                           out_buf[BUFSIZ], *checksum;
        fuzzy_hash_t                    fake_fuzzy;
 
        /* Extract arguments */
@@ -788,7 +788,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in)
        task->msg->len = in->len;
        
 
-       saved = memory_pool_alloc0 (session->session_pool, sizeof (int));
+       saved = memory_pool_alloc0 (session->session_pool, sizeof (gint));
        r = process_message (task);
        if (r == -1) {
                msg_warn ("processing of message failed");
@@ -897,11 +897,11 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in)
 }
 
 static void
-fuzzy_controller_handler (char **args, struct controller_session *session, int cmd)
+fuzzy_controller_handler (gchar **args, struct controller_session *session, gint cmd)
 {
-       char                           *arg, out_buf[BUFSIZ], *err_str;
-       uint32_t                        size;
-       int                             r, value = 1, flag = 0, *sargs;
+       gchar                           *arg, out_buf[BUFSIZ], *err_str;
+       guint32                         size;
+       gint                            r, value = 1, flag = 0, *sargs;
 
        /* Process size */
        arg = args[0];
@@ -949,7 +949,7 @@ fuzzy_controller_handler (char **args, struct controller_session *session, int c
        rspamd_set_dispatcher_policy (session->dispatcher, BUFFER_CHARACTER, size);
        session->other_handler = fuzzy_process_handler;
        /* Prepare args */
-       sargs = memory_pool_alloc (session->session_pool, sizeof (int) * 3);
+       sargs = memory_pool_alloc (session->session_pool, sizeof (gint) * 3);
        sargs[0] = cmd;
        sargs[1] = value;
        sargs[2] = flag;
@@ -957,18 +957,18 @@ fuzzy_controller_handler (char **args, struct controller_session *session, int c
 }
 
 static void
-fuzzy_add_handler (char **args, struct controller_session *session)
+fuzzy_add_handler (gchar **args, struct controller_session *session)
 {
        fuzzy_controller_handler (args, session, FUZZY_WRITE);
 }
 
 static void
-fuzzy_delete_handler (char **args, struct controller_session *session)
+fuzzy_delete_handler (gchar **args, struct controller_session *session)
 {
        fuzzy_controller_handler (args, session, FUZZY_DEL);
 }
 
-static int
+static gint
 fuzzy_mime_filter (struct worker_task *task)
 {
        /* XXX: remove this */
index 81c267a4a554b1bb42c2e491bf4b866e5c745ecf..1b726fd30077fabfba47788700e71071f312bc01 100644 (file)
 #define DEFAULT_STATFILE_PREFIX "./"
 
 struct regexp_module_item {
-       struct expression              *expr;
-       char                           *symbol;
-       long int                        avg_time;
+       struct expression               *expr;
+       gchar                           *symbol;
+       guint32                         avg_time;
        gpointer                        lua_function;
 };
 
 struct autolearn_data {
-       char                           *statfile_name;
-       char                           *symbol;
+       gchar                           *statfile_name;
+       gchar                           *symbol;
        float                           weight;
 };
 
 struct regexp_ctx {
-       int                             (*filter) (struct worker_task * task);
+       gint                            (*filter) (struct worker_task * task);
        GHashTable                     *autolearn_symbols;
-       char                           *statfile_prefix;
+       gchar                           *statfile_prefix;
 
        memory_pool_t                  *regexp_pool;
        memory_pool_t                  *dynamic_pool;
 };
 
 struct regexp_json_buf {
-       u_char                         *buf;
-       u_char                         *pos;
+       guint8                         *buf;
+       guint8                         *pos;
        size_t                          buflen;
        struct config_file             *cfg;
 };
 
 static struct regexp_ctx       *regexp_module_ctx = NULL;
 
-static int                      regexp_common_filter (struct worker_task *task);
+static gint                      regexp_common_filter (struct worker_task *task);
 static gboolean                 rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused);
 static gboolean                 rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused);
 static gboolean                 rspamd_check_smtp_data (struct worker_task *task, GList * args, void *unused);
@@ -83,17 +83,17 @@ static void                     process_regexp_item (struct worker_task *task, v
 static void 
 regexp_dynamic_insert_result (struct worker_task *task, void *user_data)
 {
-       char                           *symbol = user_data;
+       gchar                           *symbol = user_data;
                
        insert_result (task, symbol, 1, NULL);
 }
 
 static gboolean
-parse_regexp_ipmask (const char *begin, struct dynamic_map_item *addr)
+parse_regexp_ipmask (const gchar *begin, struct dynamic_map_item *addr)
 {
-       const char *pos;
-       char ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p;
-       int state = 0, dots = 0;
+       const gchar *pos;
+       gchar                           ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p;
+       gint                            state = 0, dots = 0;
        
        bzero (ip_buf, sizeof (ip_buf));
        bzero (mask_buf, sizeof (mask_buf));
@@ -173,7 +173,7 @@ parse_regexp_ipmask (const char *begin, struct dynamic_map_item *addr)
 
 /* Process regexp expression */
 static                          gboolean
-read_regexp_expression (memory_pool_t * pool, struct regexp_module_item *chain, char *symbol, char *line, gboolean raw_mode)
+read_regexp_expression (memory_pool_t * pool, struct regexp_module_item *chain, gchar *symbol, gchar *line, gboolean raw_mode)
 {
        struct expression              *e, *cur;
 
@@ -201,8 +201,8 @@ read_regexp_expression (memory_pool_t * pool, struct regexp_module_item *chain,
 
 
 /* Callbacks for reading json dynamic rules */
-u_char                         *
-json_regexp_read_cb (memory_pool_t * pool, u_char * chunk, size_t len, struct map_cb_data *data)
+guint8                         *
+json_regexp_read_cb (memory_pool_t * pool, guint8 * chunk, size_t len, struct map_cb_data *data)
 {
        struct regexp_json_buf                *jb;
        size_t                          free, off;
@@ -245,10 +245,10 @@ void
 json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
 {
        struct regexp_json_buf         *jb;
-       int                             nelts, i, j;
+       gint                            nelts, i, j;
        json_t                         *js, *cur_elt, *cur_nm, *it_val;
        json_error_t                    je;
-       char                           *cur_rule, *cur_symbol;
+       gchar                           *cur_rule, *cur_symbol;
        double                          score;
        gboolean                        enabled;
        struct regexp_module_item      *cur_item;
@@ -375,7 +375,7 @@ json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
 }
 
 /* Init function */
-int
+gint
 regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
 {
        regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx));
@@ -399,10 +399,10 @@ regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
  * SYMBOL:statfile:weight
  */
 void
-parse_autolearn_param (const char *param, const char *value, struct config_file *cfg)
+parse_autolearn_param (const gchar *param, const gchar *value, struct config_file *cfg)
 {
        struct autolearn_data          *d;
-       char                           *p;
+       gchar                           *p;
 
        p = memory_pool_strdup (regexp_module_ctx->regexp_pool, value);
        d = memory_pool_alloc (regexp_module_ctx->regexp_pool, sizeof (struct autolearn_data));
@@ -425,14 +425,14 @@ parse_autolearn_param (const char *param, const char *value, struct config_file
        }
 }
 
-int
+gint
 regexp_module_config (struct config_file *cfg)
 {
        GList                          *cur_opt = NULL;
        struct module_opt              *cur;
        struct regexp_module_item      *cur_item;
-       char                           *value;
-       int                             res = TRUE;
+       gchar                           *value;
+       gint                            res = TRUE;
        struct regexp_json_buf         *jb, **pjb;
 
        if ((value = get_module_opt (cfg, "regexp", "statfile_prefix")) != NULL) {
@@ -502,7 +502,7 @@ regexp_module_config (struct config_file *cfg)
        return res;
 }
 
-int
+gint
 regexp_module_reconfig (struct config_file *cfg)
 {
        memory_pool_delete (regexp_module_ctx->regexp_pool);
@@ -511,10 +511,10 @@ regexp_module_reconfig (struct config_file *cfg)
        return regexp_module_config (cfg);
 }
 
-static const char              *
-find_raw_header_pos (const char *headers, const char *headerv)
+static const gchar              *
+find_raw_header_pos (const gchar *headers, const gchar *headerv)
 {
-       const char                     *p = headers;
+       const gchar                     *p = headers;
        gsize                           headerlen = strlen (headerv);
 
        if (headers == NULL) {
@@ -581,9 +581,9 @@ tree_url_callback (gpointer key, gpointer value, void *data)
 }
 
 static                          gsize
-process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *additional)
+process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar *additional)
 {
-       char                           *headerv, *c, t;
+       gchar                           *headerv, *c, t;
        struct mime_text_part          *part;
        GList                          *cur, *headerlist;
        GRegex                         *regexp;
@@ -594,7 +594,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
                .re = re,
                .found = FALSE
        };
-       int                             r;
+       gint                            r;
 
 
        if (re == NULL) {
@@ -654,17 +654,17 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
                        }
                        cur = headerlist;
                        while (cur) {
-                               debug_task ("found header \"%s\" with value \"%s\"", re->header, (const char *)cur->data);
+                               debug_task ("found header \"%s\" with value \"%s\"", re->header, (const gchar *)cur->data);
 
                                if (cur->data && g_regex_match_full (re->regexp, cur->data, -1, 0, 0, NULL, &err) == TRUE) {
                                        if (G_UNLIKELY (re->is_test)) {
-                                               msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const char *)cur->data);
+                                               msg_info ("process test regexp %s for header %s with value '%s' returned TRUE", re->regexp_text, re->header, (const gchar *)cur->data);
                                        }
                                        task_cache_add (task, re, 1);
                                        return 1;
                                }
                                else if (G_UNLIKELY (re->is_test)) {
-                                       msg_info ("process test regexp %s for header %s with value '%s' returned FALSE", re->regexp_text, re->header, (const char *)cur->data);
+                                       msg_info ("process test regexp %s for header %s with value '%s' returned FALSE", re->regexp_text, re->header, (const gchar *)cur->data);
                                }
                                if (err != NULL) {
                                        msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
@@ -700,7 +700,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
                                return 1;
                        }
                        else if (G_UNLIKELY (re->is_test)) {
-                               msg_info ("process test regexp %s for mime part of length %d returned FALSE", re->regexp_text, (int)part->orig->len);
+                               msg_info ("process test regexp %s for mime part of length %d returned FALSE", re->regexp_text, (gint)part->orig->len);
                        }
                        if (err != NULL) {
                                msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
@@ -714,13 +714,13 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
 
                if (g_regex_match_full (re->raw_regexp, task->msg->begin, task->msg->len, 0, 0, NULL, &err) == TRUE) {
                        if (G_UNLIKELY (re->is_test)) {
-                               msg_info ("process test regexp %s for message of length %d returned TRUE", re->regexp_text, (int)task->msg->len);
+                               msg_info ("process test regexp %s for message of length %d returned TRUE", re->regexp_text, (gint)task->msg->len);
                        }
                        task_cache_add (task, re, 1);
                        return 1;
                }
                else if (G_UNLIKELY (re->is_test)) {
-                       msg_info ("process test regexp %s for message of length %d returned FALSE", re->regexp_text, (int)task->msg->len);
+                       msg_info ("process test regexp %s for message of length %d returned FALSE", re->regexp_text, (gint)task->msg->len);
                }
                if (err != NULL) {
                        msg_info ("error occured while processing regexp \"%s\": %s", re->regexp_text, err->message);
@@ -766,7 +766,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const char *
                        task_cache_add (task, re, 0);
                        return 0;
                }
-               if ((headerv = (char *)find_raw_header_pos (task->raw_headers, re->header)) == NULL) {
+               if ((headerv = (gchar *)find_raw_header_pos (task->raw_headers, re->header)) == NULL) {
                        /* No header was found */
                        task_cache_add (task, re, 0);
                        return 0;
@@ -826,7 +826,7 @@ optimize_regexp_expression (struct expression **e, GQueue * stack, gboolean res)
 {
        struct expression              *it = (*e)->next;
        gboolean                        ret = FALSE, is_nearest = TRUE;
-       int                             skip_level = 0;
+       gint                            skip_level = 0;
 
        /* Skip nearest logical operators from optimization */
        if (!it || (it->type == EXPR_OPERATION && it->content.operation != '!')) {
@@ -878,7 +878,7 @@ optimize_regexp_expression (struct expression **e, GQueue * stack, gboolean res)
 }
 
 static                          gboolean
-process_regexp_expression (struct expression *expr, char *symbol, struct worker_task *task, const char *additional)
+process_regexp_expression (struct expression *expr, gchar *symbol, struct worker_task *task, const gchar *additional)
 {
        GQueue                         *stack;
        gsize                           cur, op1, op2;
@@ -996,7 +996,7 @@ process_regexp_item (struct worker_task *task, void *user_data)
        }
 }
 
-static int
+static gint
 regexp_common_filter (struct worker_task *task)
 {
        /* XXX: remove this shit too */
@@ -1006,7 +1006,7 @@ regexp_common_filter (struct worker_task *task)
 static                          gboolean
 rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused)
 {
-       int                             param_count, res = 0;
+       gint                            param_count, res = 0;
        struct expression_argument     *arg;
        GList                          *cur;
 
@@ -1054,7 +1054,7 @@ rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused)
                msg_warn ("invalid argument to function is passed");
                return FALSE;
        }
-       if (find_raw_header_pos (task->raw_headers, (char *)arg->data) == NULL) {
+       if (find_raw_header_pos (task->raw_headers, (gchar *)arg->data) == NULL) {
                return FALSE;
        }
 
@@ -1062,20 +1062,20 @@ rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused)
 }
 
 static gboolean
-match_smtp_data (struct worker_task *task, const char *re_text, const char *what)
+match_smtp_data (struct worker_task *task, const gchar *re_text, const gchar *what)
 {
        struct rspamd_regexp           *re;
-       int                             r;
+       gint                            r;
 
        if (*re_text == '/') {
                /* This is a regexp */
                if ((re = re_cache_check (re_text, task->cfg->cfg_pool)) == NULL) {
-                       re = parse_regexp (task->cfg->cfg_pool, (char *)re_text, task->cfg->raw_mode);
+                       re = parse_regexp (task->cfg->cfg_pool, (gchar *)re_text, task->cfg->raw_mode);
                        if (re == NULL) {
                                msg_warn ("cannot compile regexp for function");
                                return FALSE;
                        }
-                       re_cache_add ((char *)re_text, re, task->cfg->cfg_pool);
+                       re_cache_add ((gchar *)re_text, re, task->cfg->cfg_pool);
                }
                if ((r = task_cache_check (task, re)) == -1) {
                        if (g_regex_match (re->regexp, what, 0, NULL) == TRUE) {
@@ -1100,7 +1100,7 @@ rspamd_check_smtp_data (struct worker_task *task, GList * args, void *unused)
 {
        struct expression_argument     *arg;
        GList                          *cur, *rcpt_list = NULL;
-       char                           *type, *what = NULL;
+       gchar                           *type, *what = NULL;
 
        if (args == NULL) {
                msg_warn ("no parameters to function");
index 315e57f581145ab6d4782e98d24871daec4e1d12..868ad7a3280517ab5b2770ebfcfcec2e89c681a9 100644 (file)
 #define DEFAULT_SYMBOL_ALLOW "R_SPF_ALLOW"
 
 struct spf_ctx {
-       int                             (*filter) (struct worker_task * task);
-       char                           *symbol_fail;
-       char                           *symbol_softfail;
-       char                           *symbol_allow;
+       gint                            (*filter) (struct worker_task * task);
+       gchar                           *symbol_fail;
+       gchar                           *symbol_softfail;
+       gchar                           *symbol_allow;
 
        memory_pool_t                  *spf_pool;
        radix_tree_t                   *whitelist_ip;
@@ -61,7 +61,7 @@ static struct spf_ctx        *spf_module_ctx = NULL;
 
 static void                   spf_symbol_callback (struct worker_task *task, void *unused);
 
-int
+gint
 spf_module_init (struct config_file *cfg, struct module_ctx **ctx)
 {
        spf_module_ctx = g_malloc (sizeof (struct spf_ctx));
@@ -74,11 +74,11 @@ spf_module_init (struct config_file *cfg, struct module_ctx **ctx)
 }
 
 
-int
+gint
 spf_module_config (struct config_file *cfg)
 {
-       char                           *value;
-       int                             res = TRUE;
+       gchar                           *value;
+       gint                            res = TRUE;
 
        spf_module_ctx->whitelist_ip = radix_tree_create ();
        
@@ -111,7 +111,7 @@ spf_module_config (struct config_file *cfg)
        return res;
 }
 
-int
+gint
 spf_module_reconfig (struct config_file *cfg)
 {
        memory_pool_delete (spf_module_ctx->spf_pool);
@@ -126,7 +126,7 @@ spf_plugin_callback (struct spf_record *record, struct worker_task *task)
 {
        GList *cur;
        struct spf_addr *addr;
-       uint32_t s, m;
+       guint32                         s, m;
 
        if (record) {
                cur = g_list_first (record->addrs);
index 25132a0f91f8f9c6ea0e3cfea6638ddd203d2508..71fbbd55d16614e88a89c8e4f8c887c3f547f026 100644 (file)
 
 static struct surbl_ctx        *surbl_module_ctx = NULL;
 
-static int                      surbl_filter (struct worker_task *task);
+static gint                      surbl_filter (struct worker_task *task);
 static void                     surbl_test_url (struct worker_task *task, void *user_data);
 static void                     dns_callback (struct rspamd_dns_reply *reply, gpointer arg);
-static void                     process_dns_results (struct worker_task *task, struct suffix_item *suffix, char *url, uint32_t addr);
-static int                      urls_command_handler (struct worker_task *task);
+static void                     process_dns_results (struct worker_task *task, struct suffix_item *suffix, gchar *url, guint32 addr);
+static gint                      urls_command_handler (struct worker_task *task);
 
 #define NO_REGEXP (gpointer)-1
 
@@ -73,8 +73,8 @@ static void
 exception_insert (gpointer st, gconstpointer key, gpointer value)
 {
        GHashTable                    **t = st;
-       int                             level = 0;
-       const char                     *p = key;
+       gint                            level = 0;
+       const gchar                     *p = key;
        f_str_t                        *val;
        
 
@@ -85,12 +85,12 @@ exception_insert (gpointer st, gconstpointer key, gpointer value)
                p ++;
        }
        if (level >= MAX_LEVELS) {
-               msg_err ("invalid domain in exceptions list: %s, levels: %d", (char *)key, level);
+               msg_err ("invalid domain in exceptions list: %s, levels: %d", (gchar *)key, level);
                return;
        }
        
        val = g_malloc (sizeof (f_str_t));
-       val->begin = (char *)key;
+       val->begin = (gchar *)key;
        val->len = strlen (key);
        if (t[level] == NULL) {
                t[level] = g_hash_table_new_full (fstr_strcase_hash, fstr_strcase_equal, g_free, NULL);
@@ -111,7 +111,7 @@ static void
 fin_exceptions_list (memory_pool_t * pool, struct map_cb_data *data)
 {
        GHashTable                    **t;
-       int                             i;
+       gint                            i;
 
        if (data->prev_data) {
                t = data->prev_data;
@@ -127,7 +127,7 @@ static void
 redirector_insert (gpointer st, gconstpointer key, gpointer value)
 {
        GHashTable                     *t = st;
-       const char                     *p = key, *begin = key;
+       const gchar                     *p = key, *begin = key;
        gchar                          *new;
        gsize                           len;
        GRegex                                     *re = NO_REGEXP;
@@ -190,7 +190,7 @@ fin_redirectors_list (memory_pool_t * pool, struct map_cb_data *data)
        }
 }
 
-int
+gint
 surbl_module_init (struct config_file *cfg, struct module_ctx **ctx)
 {
        surbl_module_ctx = g_malloc (sizeof (struct surbl_ctx));
@@ -228,7 +228,7 @@ surbl_module_init (struct config_file *cfg, struct module_ctx **ctx)
        return 0;
 }
 
-int
+gint
 surbl_module_config (struct config_file *cfg)
 {
        GList                          *cur_opt;
@@ -236,7 +236,7 @@ surbl_module_config (struct config_file *cfg)
        struct suffix_item             *new_suffix;
        struct surbl_bit_item          *new_bit;
 
-       char                           *value, *str, **strvec;
+       gchar                           *value, *str, **strvec;
        guint32                         bit;
        gint                            i, idx;
 
@@ -337,7 +337,7 @@ surbl_module_config (struct config_file *cfg)
                                        new_bit = memory_pool_alloc (surbl_module_ctx->surbl_pool, sizeof (struct surbl_bit_item));
                                        new_bit->bit = bit;
                                        new_bit->symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, cur->value);
-                                       msg_debug ("add new bit suffix: %d with symbol: %s", (int)new_bit->bit, new_bit->symbol);
+                                       msg_debug ("add new bit suffix: %d with symbol: %s", (gint)new_bit->bit, new_bit->symbol);
                                        surbl_module_ctx->bits = g_list_prepend (surbl_module_ctx->bits, new_bit);
                                }
                        }
@@ -357,7 +357,7 @@ surbl_module_config (struct config_file *cfg)
        return TRUE;
 }
 
-int
+gint
 surbl_module_reconfig (struct config_file *cfg)
 {
        /* Delete pool and objects */
@@ -394,13 +394,13 @@ surbl_module_reconfig (struct config_file *cfg)
 
 
 
-static char                    *
+static gchar                    *
 format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_item *suffix,
                gboolean append_suffix, GError ** err, gboolean forced)
 {
        GHashTable                     *t;
-       char                           *result = NULL, *dots[MAX_LEVELS], num_buf[sizeof("18446744073709551616")], *p;
-       int                             len, slen, r, i, dots_num = 0, level = MAX_LEVELS;
+       gchar                           *result = NULL, *dots[MAX_LEVELS], num_buf[sizeof("18446744073709551616")], *p;
+       gint                            len, slen, r, i, dots_num = 0, level = MAX_LEVELS;
        gboolean                        is_numeric = TRUE;
        guint64                         ip_num;
        f_str_t                         f;
@@ -433,13 +433,13 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it
                /* This is ip address */
                result = memory_pool_alloc (pool, len);
                r = rspamd_snprintf (result, len, "%*s.%*s.%*s.%*s", 
-                               (int)(hostname->len - (dots[2] - hostname->begin + 1)),
+                               (gint)(hostname->len - (dots[2] - hostname->begin + 1)),
                                dots[2] + 1,
-                               (int)(dots[2] - dots[1] - 1),
+                               (gint)(dots[2] - dots[1] - 1),
                                dots[1] + 1,
-                               (int)(dots[1] - dots[0] - 1),
+                               (gint)(dots[1] - dots[0] - 1),
                                dots[0] + 1,
-                               (int)(dots[0] - hostname->begin),
+                               (gint)(dots[0] - hostname->begin),
                                hostname->begin);
        }
        else if (is_numeric && dots_num == 0) {
@@ -461,7 +461,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it
                ip_num &= 0xFFFFFFFF;
                /* Get octets */
                r = rspamd_snprintf (result, len, "%ud.%ud.%ud.%ud",
-                       (uint32_t) ip_num & 0x000000FF, (uint32_t) (ip_num & 0x0000FF00) >> 8, (uint32_t) (ip_num & 0x00FF0000) >> 16, (uint32_t) (ip_num & 0xFF000000) >> 24);
+                       (guint32) ip_num & 0x000000FF, (guint32) (ip_num & 0x0000FF00) >> 8, (guint32) (ip_num & 0x00FF0000) >> 16, (guint32) (ip_num & 0xFF000000) >> 24);
        }
        else {
                /* Not a numeric url */
@@ -482,21 +482,21 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it
                }
                if (level != MAX_LEVELS) {
                        if (level == 0) {
-                               r = rspamd_snprintf (result, len, "%*s", (int)hostname->len, hostname->begin);
+                               r = rspamd_snprintf (result, len, "%*s", (gint)hostname->len, hostname->begin);
                        }
                        else {
                                r = rspamd_snprintf (result, len, "%*s", 
-                                       (int)(hostname->len - (dots[level - 1] - hostname->begin + 1)),
+                                       (gint)(hostname->len - (dots[level - 1] - hostname->begin + 1)),
                                        dots[level - 1] + 1);
                        }
                }
                else if (dots_num >= 2) {
                        r = rspamd_snprintf (result, len, "%*s",
-                                       (int)(hostname->len - (dots[dots_num - 2] - hostname->begin + 1)),
+                                       (gint)(hostname->len - (dots[dots_num - 2] - hostname->begin + 1)),
                                        dots[dots_num - 2] + 1);
                }
                else {
-                       r = rspamd_snprintf (result, len, "%*s", (int)hostname->len, hostname->begin);
+                       r = rspamd_snprintf (result, len, "%*s", (gint)hostname->len, hostname->begin);
                }
        }
 
@@ -514,7 +514,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it
                r += rspamd_snprintf (result + r, len - r, ".%s", suffix->suffix);
        }
 
-       msg_debug ("request: %s, dots: %d, level: %d, orig: %*s", result, dots_num, level, (int)hostname->len, hostname->begin);
+       msg_debug ("request: %s, dots: %d, level: %d, orig: %*s", result, dots_num, level, (gint)hostname->len, hostname->begin);
 
        return result;
 }
@@ -523,7 +523,7 @@ static void
 make_surbl_requests (struct uri *url, struct worker_task *task, GTree * tree,
                struct suffix_item *suffix, gboolean forced)
 {
-       char                           *surbl_req;
+       gchar                           *surbl_req;
        f_str_t                         f;
        GError                         *err = NULL;
        struct dns_param               *param;
@@ -564,20 +564,20 @@ make_surbl_requests (struct uri *url, struct worker_task *task, GTree * tree,
 }
 
 static void
-process_dns_results (struct worker_task *task, struct suffix_item *suffix, char *url, uint32_t addr)
+process_dns_results (struct worker_task *task, struct suffix_item *suffix, gchar *url, guint32 addr)
 {
-       char                           *c, *symbol;
+       gchar                           *c, *symbol;
        GList                          *cur;
        struct surbl_bit_item          *bit;
-       int                             len, found = 0;
+       gint                            len, found = 0;
 
        if ((c = strchr (suffix->symbol, '%')) != NULL && *(c + 1) == 'b') {
                cur = g_list_first (surbl_module_ctx->bits);
 
                while (cur) {
                        bit = (struct surbl_bit_item *)cur->data;
-                       debug_task ("got result(%d) AND bit(%d): %d", (int)addr, (int)ntohl (bit->bit), (int)bit->bit & (int)ntohl (addr));
-                       if (((int)bit->bit & (int)ntohl (addr)) != 0) {
+                       debug_task ("got result(%d) AND bit(%d): %d", (gint)addr, (gint)ntohl (bit->bit), (gint)bit->bit & (gint)ntohl (addr));
+                       if (((gint)bit->bit & (gint)ntohl (addr)) != 0) {
                                len = strlen (suffix->symbol) - 2 + strlen (bit->symbol) + 1;
                                *c = '\0';
                                symbol = memory_pool_alloc (task->task_pool, len);
@@ -610,7 +610,7 @@ dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
        if (reply->code == DNS_RC_NOERROR && reply->elements) {
                msg_info ("<%s> domain [%s] is in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix);
                elt = reply->elements->data;
-               process_dns_results (param->task, param->suffix, param->host_resolve, (uint32_t)elt->a.addr[0].s_addr);
+               process_dns_results (param->task, param->suffix, param->host_resolve, (guint32)elt->a.addr[0].s_addr);
        }
        else {
                debug_task ("<%s> domain [%s] is not in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix);
@@ -628,7 +628,7 @@ static void
 memcached_callback (memcached_ctx_t * ctx, memc_error_t error, void *data)
 {
        struct memcached_param         *param = (struct memcached_param *)data;
-       int                            *url_count;
+       gint                            *url_count;
 
        switch (ctx->op) {
        case CMD_CONNECT:
@@ -658,7 +658,7 @@ memcached_callback (memcached_ctx_t * ctx, memc_error_t error, void *data)
                        }
                }
                else {
-                       url_count = (int *)param->ctx->param->buf;
+                       url_count = (gint *)param->ctx->param->buf;
                        /* Do not check DNS for urls that have count more than max_urls */
                        if (*url_count > surbl_module_ctx->max_urls) {
                                msg_info ("url '%s' has count %d, max: %d", struri (param->url), *url_count, surbl_module_ctx->max_urls);
@@ -696,11 +696,11 @@ register_memcached_call (struct uri *url, struct worker_task *task, GTree * url_
        struct memcached_server        *selected;
        memcached_param_t              *cur_param;
        gchar                          *sum_str;
-       int                            *url_count;
+       gint                            *url_count;
 
        param = memory_pool_alloc (task->task_pool, sizeof (struct memcached_param));
        cur_param = memory_pool_alloc0 (task->task_pool, sizeof (memcached_param_t));
-       url_count = memory_pool_alloc (task->task_pool, sizeof (int));
+       url_count = memory_pool_alloc (task->task_pool, sizeof (gint));
 
        param->url = url;
        param->task = task;
@@ -710,7 +710,7 @@ register_memcached_call (struct uri *url, struct worker_task *task, GTree * url_
        param->ctx = memory_pool_alloc0 (task->task_pool, sizeof (memcached_ctx_t));
 
        cur_param->buf = (u_char *) url_count;
-       cur_param->bufsize = sizeof (int);
+       cur_param->bufsize = sizeof (gint);
 
        sum_str = g_compute_checksum_for_string (G_CHECKSUM_MD5, struri (url), -1);
        g_strlcpy (cur_param->key, sum_str, sizeof (cur_param->key));
@@ -759,14 +759,14 @@ free_redirector_session (void *ud)
 }
 
 static void
-redirector_callback (int fd, short what, void *arg)
+redirector_callback (gint fd, short what, void *arg)
 {
        struct redirector_param        *param = (struct redirector_param *)arg;
        struct worker_task             *task = param->task;
-       char                            url_buf[1024];
-       int                             r;
+       gchar                           url_buf[1024];
+       gint                            r;
        struct timeval                 *timeout;
-       char                           *p, *c;
+       gchar                           *p, *c;
 
        switch (param->state) {
        case STATE_CONNECT:
@@ -829,7 +829,7 @@ redirector_callback (int fd, short what, void *arg)
 static void
 register_redirector_call (struct uri *url, struct worker_task *task, GTree * url_tree, struct suffix_item *suffix)
 {
-       int                             s = -1;
+       gint                            s = -1;
        struct redirector_param        *param;
        struct timeval                 *timeout;
        struct redirector_upstream     *selected;
@@ -876,7 +876,7 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data)
        struct worker_task             *task = param->task;
        struct uri                     *url = value;
        f_str_t                         f;
-       char                           *red_domain;
+       gchar                           *red_domain;
        GRegex                         *re;
        guint                           idx;
 
@@ -945,7 +945,7 @@ surbl_test_url (struct worker_task *task, void *user_data)
        memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_tree_destroy, url_tree);
 }
 
-static int
+static gint
 surbl_filter (struct worker_task *task)
 {
        /* XXX: remove this shit */
@@ -956,8 +956,8 @@ static gboolean
 urls_command_handler (struct worker_task *task)
 {
        GList                          *cur;
-       char                           *outbuf, *urlstr;
-       int                             r, num = 0, buflen;
+       gchar                           *outbuf, *urlstr;
+       gint                            r, num = 0, buflen;
        struct uri                     *url;
        GError                         *err = NULL;
        GTree                          *url_tree;
@@ -976,7 +976,7 @@ urls_command_handler (struct worker_task *task)
 
        buflen += sizeof (RSPAMD_REPLY_BANNER " 0 OK" CRLF CRLF "Urls: ");
 
-       outbuf = memory_pool_alloc (task->task_pool, buflen * sizeof (char));
+       outbuf = memory_pool_alloc (task->task_pool, buflen * sizeof (gchar));
 
        r = rspamd_snprintf (outbuf, buflen, "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK");
 
@@ -993,10 +993,10 @@ urls_command_handler (struct worker_task *task)
                        f.len = url->hostlen;
                        if ((urlstr = format_surbl_request (task->task_pool, &f, NULL, FALSE, &err, FALSE)) != NULL) {
                                if (g_list_next (cur) != NULL) {
-                                       r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">, ", (char *)urlstr, struri (url));
+                                       r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">, ", (gchar *)urlstr, struri (url));
                                }
                                else {
-                                       r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">", (char *)urlstr, struri (url));
+                                       r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">", (gchar *)urlstr, struri (url));
                                }
                        }
                }
index 1df6fae3175735f00324b108e16e837a4e125f15..3760f58081f647b275b44cb9b90ad4869a99da6f 100644 (file)
@@ -26,37 +26,37 @@ struct redirector_upstream {
 };
 
 struct surbl_ctx {
-       int (*filter)(struct worker_task *task);
-       uint16_t weight;
-       unsigned int connect_timeout;
-       unsigned int read_timeout;
-       unsigned int max_urls;
-       unsigned int url_expire;
+       gint (*filter)(struct worker_task *task);
+       guint16 weight;
+       guint connect_timeout;
+       guint read_timeout;
+       guint max_urls;
+       guint url_expire;
        GList *suffixes;
        GList *bits;
-       char *metric;
-       const char *tld2_file;
-       const char *whitelist_file;
+       gchar *metric;
+       const gchar *tld2_file;
+       const gchar *whitelist_file;
        GHashTable **exceptions;
        GHashTable *whitelist;
        GHashTable *redirector_hosts;
        rspamd_trie_t *redirector_trie;
        GPtrArray *redirector_ptrs;
-       unsigned use_redirector;
+       guint use_redirector;
        struct redirector_upstream *redirectors;
        guint32 redirectors_number;
        memory_pool_t *surbl_pool;
 };
 
 struct suffix_item {
-       const char *suffix;
-       const char *symbol;
+       const gchar *suffix;
+       const gchar *symbol;
 };
 
 struct dns_param {
        struct uri *url;
        struct worker_task *task;
-       char *host_resolve;
+       gchar *host_resolve;
        struct suffix_item *suffix;
 };
 
@@ -69,7 +69,7 @@ struct redirector_param {
                STATE_READ,
        } state;
        struct event ev;
-       int sock;
+       gint sock;
        GTree *tree;
        struct suffix_item *suffix;
 };
@@ -83,8 +83,8 @@ struct memcached_param {
 };
 
 struct surbl_bit_item {
-       uint32_t bit;
-       const char *symbol;
+       guint32 bit;
+       const gchar *symbol;
 };
 
 #endif
index d3afe619462d127d93934684c068f6d4738cfbbd..11f82bd47a29b41ca0674a01c04f25cc74ef020c 100644 (file)
@@ -92,7 +92,7 @@ static GList                   *custom_commands = NULL;
 /* For default metric, dirty hack, but much faster than hash lookup */
 static double default_score, default_required_score;
 
-G_INLINE_FUNC const char *
+G_INLINE_FUNC const gchar *
 rspamc_proto_str (guint ver)
 {
        if (ver >= 12) {
@@ -106,11 +106,11 @@ rspamc_proto_str (guint ver)
        }
 }
 
-static char                    *
-separate_command (f_str_t * in, char c)
+static gchar                    *
+separate_command (f_str_t * in, gchar c)
 {
-       int                             r = 0;
-       char                           *p = in->begin, *b;
+       gint                            r = 0;
+       gchar                           *p = in->begin, *b;
        b = p;
 
        while (r < in->len) {
@@ -127,10 +127,10 @@ separate_command (f_str_t * in, char c)
        return NULL;
 }
 
-static int
+static gint
 parse_command (struct worker_task *task, f_str_t * line)
 {
-       char                           *token;
+       gchar                           *token;
        struct custom_command          *cmd;
        GList                          *cur;
 
@@ -240,10 +240,10 @@ parse_command (struct worker_task *task, f_str_t * line)
        return 0;
 }
 
-static int
+static gint
 parse_header (struct worker_task *task, f_str_t * line)
 {
-       char                           *headern, *err, *tmp;
+       gchar                           *headern, *err, *tmp;
 
        /* Check end of headers */
        if (line->len == 0) {
@@ -283,7 +283,7 @@ parse_header (struct worker_task *task, f_str_t * line)
                        if (task->content_length == 0) {
                                tmp = memory_pool_fstrdup (task->task_pool, line);
                                task->content_length = strtoul (tmp, &err, 10);
-                               debug_task ("read Content-Length header, value: %ul", (unsigned long int)task->content_length);
+                               debug_task ("read Content-Length header, value: %ul", (guint32)task->content_length);
                        }
                }
                else {
@@ -350,7 +350,7 @@ parse_header (struct worker_task *task, f_str_t * line)
                else if (g_ascii_strncasecmp (headern, NRCPT_HEADER, sizeof (NRCPT_HEADER) - 1) == 0) {
                        tmp = memory_pool_fstrdup (task->task_pool, line);
                        task->nrcpt = strtoul (tmp, &err, 10);
-                       debug_task ("read rcpt header, value: %d", (int)task->nrcpt);
+                       debug_task ("read rcpt header, value: %d", (gint)task->nrcpt);
                }
                else {
                        msg_info ("wrong header: %s", headern);
@@ -410,7 +410,7 @@ parse_header (struct worker_task *task, f_str_t * line)
        return 0;
 }
 
-int
+gint
 read_rspamd_input_line (struct worker_task *task, f_str_t * line)
 {
        switch (task->state) {
@@ -428,14 +428,14 @@ read_rspamd_input_line (struct worker_task *task, f_str_t * line)
 
 struct metric_callback_data {
        struct worker_task             *task;
-       char                           *log_buf;
-       int                             log_offset;
-       int                             log_size;
+       gchar                           *log_buf;
+       gint                            log_offset;
+       gint                            log_size;
        gboolean                        alive;
 };
 
 static void
-write_hashes_to_log (struct worker_task *task, char *logbuf, int offset, int size) 
+write_hashes_to_log (struct worker_task *task, gchar *logbuf, gint offset, gint size) 
 {
        GList                          *cur;
        struct mime_text_part          *text_part;
@@ -472,8 +472,8 @@ compare_url_func (gconstpointer a, gconstpointer b)
 static gboolean
 show_url_header (struct worker_task *task)
 {
-       int                             r = 0;
-       char                            outbuf[OUTBUFSIZ], c;
+       gint                            r = 0;
+       gchar                           outbuf[OUTBUFSIZ], c;
        struct uri                     *url;
        GList                          *cur;
        f_str_t                         host;
@@ -538,8 +538,8 @@ metric_symbols_callback (gpointer key, gpointer value, void *user_data)
 {
        struct metric_callback_data    *cd = (struct metric_callback_data *)user_data;
        struct worker_task             *task = cd->task;
-       int                             r = 0;
-       char                            outbuf[OUTBUFSIZ];
+       gint                            r = 0;
+       gchar                           outbuf[OUTBUFSIZ];
        struct symbol                  *s = (struct symbol *)value;
        GList                          *cur;
 
@@ -549,18 +549,18 @@ metric_symbols_callback (gpointer key, gpointer value, void *user_data)
 
        if (s->options) {
                if (task->proto_ver >= 12) {
-                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s(%.2f); ", (char *)key, s->score);
+                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s(%.2f); ", (gchar *)key, s->score);
                }
                else {
-                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s; ", (char *)key);
+                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s; ", (gchar *)key);
                }
                cur = s->options;
                while (cur) {
                        if (g_list_next (cur)) {
-                               r += rspamd_snprintf (outbuf + r, OUTBUFSIZ - r, "%s,", (char *)cur->data);
+                               r += rspamd_snprintf (outbuf + r, OUTBUFSIZ - r, "%s,", (gchar *)cur->data);
                        }
                        else {
-                               r += rspamd_snprintf (outbuf + r, OUTBUFSIZ - r, "%s" CRLF, (char *)cur->data);
+                               r += rspamd_snprintf (outbuf + r, OUTBUFSIZ - r, "%s" CRLF, (gchar *)cur->data);
                        }
                        cur = g_list_next (cur);
                }
@@ -572,13 +572,13 @@ metric_symbols_callback (gpointer key, gpointer value, void *user_data)
        }
        else {
                if (task->proto_ver >= 12) {
-                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s(%.2f)" CRLF, (char *)key, s->score);
+                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s(%.2f)" CRLF, (gchar *)key, s->score);
                }
                else {
-                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s" CRLF, (char *)key);
+                       r = rspamd_snprintf (outbuf, OUTBUFSIZ, "Symbol: %s" CRLF, (gchar *)key);
                }
        }
-       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "%s,", (char *)key);
+       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "%s,", (gchar *)key);
 
        if (! rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE)) {
                cd->alive = FALSE;
@@ -588,19 +588,19 @@ metric_symbols_callback (gpointer key, gpointer value, void *user_data)
 static gboolean
 show_metric_symbols (struct metric_result *metric_res, struct metric_callback_data *cd)
 {
-       int                             r = 0;
+       gint                            r = 0;
        GList                          *symbols, *cur;
-       char                            outbuf[OUTBUFSIZ];
+       gchar                           outbuf[OUTBUFSIZ];
 
        if (cd->task->proto == SPAMC_PROTO) {
                symbols = g_hash_table_get_keys (metric_res->symbols);
                cur = symbols;
                while (cur) {
                        if (g_list_next (cur) != NULL) {
-                               r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s,", (char *)cur->data);
+                               r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s,", (gchar *)cur->data);
                        }
                        else {
-                               r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s" CRLF, (char *)cur->data);
+                               r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "%s" CRLF, (gchar *)cur->data);
                        }
                        cur = g_list_next (cur);
                }
@@ -620,7 +620,7 @@ show_metric_symbols (struct metric_result *metric_res, struct metric_callback_da
        return TRUE;
 }
 
-const char *
+const gchar *
 str_action_metric (enum rspamd_metric_action action)
 {
        switch (action) {
@@ -676,11 +676,11 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
 {
        struct metric_callback_data    *cd = (struct metric_callback_data *)user_data;
        struct worker_task             *task = cd->task;
-       int                             r = 0;
-       char                            outbuf[OUTBUFSIZ];
+       gint                            r = 0;
+       gchar                           outbuf[OUTBUFSIZ];
        struct metric_result           *metric_res = (struct metric_result *)metric_value;
        struct metric                  *m;
-       int                             is_spam = 0;
+       gint                            is_spam = 0;
        double                          ms = 0, rs = 0;
        enum rspamd_metric_action       action;
 
@@ -741,26 +741,26 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
                        if (task->proto_ver >= 11) {
                 if (!task->is_skipped) {
                                    r = rspamd_snprintf (outbuf, sizeof (outbuf), "Metric: %s; %s; %.2f / %.2f / %.2f" CRLF, 
-                                               (char *)metric_name, (is_spam) ? "True" : "False", metric_res->score, ms, rs);
+                                               (gchar *)metric_name, (is_spam) ? "True" : "False", metric_res->score, ms, rs);
                 }
                 else {
                                    r = rspamd_snprintf (outbuf, sizeof (outbuf), "Metric: %s; Skip; %.2f / %.2f / %.2f" CRLF, 
-                                               (char *)metric_name, metric_res->score, ms, rs);
+                                               (gchar *)metric_name, metric_res->score, ms, rs);
                 }
                        }
                        else {
                                r = rspamd_snprintf (outbuf, sizeof (outbuf), "Metric: %s; %s; %.2f / %.2f" CRLF, 
-                                               (char *)metric_name, (is_spam) ? "True" : "False", metric_res->score, ms);
+                                               (gchar *)metric_name, (is_spam) ? "True" : "False", metric_res->score, ms);
                        }
                        r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "Action: %s" CRLF, str_action_metric(action));
                }
         if (!task->is_skipped) {
                    cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: %c (%s): [%.2f/%.2f/%.2f] [",
-                               (char *)metric_name, is_spam ? 'T' : 'F', str_action_metric (action), metric_res->score, ms, rs);
+                               (gchar *)metric_name, is_spam ? 'T' : 'F', str_action_metric (action), metric_res->score, ms, rs);
         }
         else {
-                   cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: %c (%s): [%.2f/%.2f/%.2f] [",
-                               (char *)metric_name, 'S', metric_res->score, ms, rs);
+                   cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: %c (default): [%.2f/%.2f/%.2f] [",
+                               (gchar *)metric_name, 'S', metric_res->score, ms, rs);
         
         }
        }
@@ -785,24 +785,24 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
                }
        }
 #ifdef HAVE_CLOCK_GETTIME
-       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "]), len: %l, time: %s,",
-               (long int)task->msg->len, calculate_check_time (&task->tv, &task->ts, task->cfg->clock_res));
+       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "]), len: %z, time: %s,",
+               task->msg->len, calculate_check_time (&task->tv, &task->ts, task->cfg->clock_res));
 #else
-       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "]), len: %l, time: %s,",
-               (long int)task->msg->len, calculate_check_time (&task->tv, task->cfg->clock_res));
+       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "]), len: %z, time: %s,",
+               task->msg->len, calculate_check_time (&task->tv, task->cfg->clock_res));
 #endif
 }
 
 static gboolean
 show_messages (struct worker_task *task)
 {
-       int                             r = 0;
-       char                            outbuf[OUTBUFSIZ];
+       gint                            r = 0;
+       gchar                           outbuf[OUTBUFSIZ];
        GList                          *cur;
        
        cur = task->messages;
        while (cur) {
-               r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "Message: %s" CRLF, (char *)cur->data);
+               r += rspamd_snprintf (outbuf + r, sizeof (outbuf) - r, "Message: %s" CRLF, (gchar *)cur->data);
                cur = g_list_next (cur);
        }
 
@@ -816,8 +816,8 @@ show_messages (struct worker_task *task)
 static gboolean
 write_check_reply (struct worker_task *task)
 {
-       int                             r;
-       char                            outbuf[OUTBUFSIZ], logbuf[OUTBUFSIZ];
+       gint                            r;
+       gchar                           outbuf[OUTBUFSIZ], logbuf[OUTBUFSIZ];
        struct metric_result           *metric_res;
        struct metric_callback_data     cd;
 
@@ -910,9 +910,9 @@ write_check_reply (struct worker_task *task)
 static gboolean
 write_process_reply (struct worker_task *task)
 {
-       int                             r;
-       char                           *outmsg;
-       char                            outbuf[OUTBUFSIZ], logbuf[OUTBUFSIZ];
+       gint                            r;
+       gchar                           *outmsg;
+       gchar                           outbuf[OUTBUFSIZ], logbuf[OUTBUFSIZ];
        struct metric_result           *metric_res;
        struct metric_callback_data     cd;
 
@@ -1002,8 +1002,8 @@ write_process_reply (struct worker_task *task)
 gboolean
 write_reply (struct worker_task *task)
 {
-       int                             r;
-       char                            outbuf[OUTBUFSIZ];
+       gint                            r;
+       gchar                           outbuf[OUTBUFSIZ];
 
        debug_task ("writing reply to client");
        if (task->error_code != 0) {
@@ -1051,7 +1051,7 @@ write_reply (struct worker_task *task)
 }
 
 void
-register_protocol_command (const char *name, protocol_reply_func func)
+register_protocol_command (const gchar *name, protocol_reply_func func)
 {
        struct custom_command          *cmd;
 
index affcccd5c3adb28ebe7447c03e3d3910134b0289..b950c2681185da4b4015397cfe6dde4dabe25bf8 100644 (file)
@@ -47,10 +47,10 @@ enum rspamd_command {
 };
 
 
-typedef int (*protocol_reply_func)(struct worker_task *task);
+typedef gint (*protocol_reply_func)(struct worker_task *task);
 
 struct custom_command {
-       const char *name;
+       const gchar *name;
        protocol_reply_func func;
 };
 
@@ -60,7 +60,7 @@ struct custom_command {
  * @param line line of user's input
  * @return 0 if line was successfully parsed and -1 if we have protocol error
  */
-int read_rspamd_input_line (struct worker_task *task, f_str_t *line);
+gint read_rspamd_input_line (struct worker_task *task, f_str_t *line);
 
 /**
  * Write reply for specified task command
@@ -75,9 +75,9 @@ gboolean write_reply (struct worker_task *task) G_GNUC_WARN_UNUSED_RESULT;
  * @param name symbolic name of custom function
  * @param func callback function for writing reply
  */
-void register_protocol_command (const char *name, protocol_reply_func func);
+void register_protocol_command (const gchar *name, protocol_reply_func func);
 
-const char *str_action_metric (enum rspamd_metric_action action);
+const gchar *str_action_metric (enum rspamd_metric_action action);
 gint check_metric_action (double score, double required_score, struct metric *metric);
 
 #endif
index 94b5b1ab5fc1b46882eb4d9e10e06f03b23e7997..e8a68848df06dff458289f8ebb9a2d330cb43bba 100644 (file)
@@ -62,9 +62,9 @@ enum radix_insert_type {
 };
 
 static uintptr_t
-radix32tree_insert_common (radix_tree_t * tree, uint32_t key, uint32_t mask, uintptr_t value, enum radix_insert_type type)
+radix32tree_insert_common (radix_tree_t * tree, guint32 key, guint32 mask, uintptr_t value, enum radix_insert_type type)
 {
-       uint32_t                        bit;
+       guint32                         bit;
        radix_node_t                   *node, *next;
 
        bit = 0x80000000;
@@ -137,32 +137,32 @@ radix32tree_insert_common (radix_tree_t * tree, uint32_t key, uint32_t mask, uin
        return 0;
 }
 
-int 
-radix32tree_insert (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr_t value)
+gint 
+radix32tree_insert (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value)
 {
-       return (int)radix32tree_insert_common (tree, key, mask, value, RADIX_INSERT);
+       return (gint)radix32tree_insert_common (tree, key, mask, value, RADIX_INSERT);
 }
 
 uintptr_t 
-radix32tree_add (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr_t value)
+radix32tree_add (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value)
 {
        return radix32tree_insert_common (tree, key, mask, value, RADIX_ADD);
 }
 
-int 
-radix32tree_replace (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr_t value)
+gint 
+radix32tree_replace (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value)
 {
-       return (int)radix32tree_insert_common (tree, key, mask, value, RADIX_REPLACE);
+       return (gint)radix32tree_insert_common (tree, key, mask, value, RADIX_REPLACE);
 }
 
 /*
  * per recursion step:
- * ptr + ptr + ptr + int = 4 words
+ * ptr + ptr + ptr + gint = 4 words
  * result = 1 word
  * 5 words total in stack
  */
 static gboolean
-radix_recurse_nodes (radix_node_t *node, radix_tree_traverse_func func, void *user_data, int level)
+radix_recurse_nodes (radix_node_t *node, radix_tree_traverse_func func, void *user_data, gint level)
 {
        if (node->left) {
                if (radix_recurse_nodes (node->left, func, user_data, level + 1)) {
@@ -192,10 +192,10 @@ radix32tree_traverse (radix_tree_t *tree, radix_tree_traverse_func func, void *u
 }
 
 
-int
-radix32tree_delete (radix_tree_t * tree, uint32_t key, uint32_t mask)
+gint
+radix32tree_delete (radix_tree_t * tree, guint32 key, guint32 mask)
 {
-       uint32_t                        bit;
+       guint32                         bit;
        radix_node_t                   *node;
        radix_node_t                   *tmp;
 
@@ -257,9 +257,9 @@ radix32tree_delete (radix_tree_t * tree, uint32_t key, uint32_t mask)
 
 
 uintptr_t
-radix32tree_find (radix_tree_t * tree, uint32_t key)
+radix32tree_find (radix_tree_t * tree, guint32 key)
 {
-       uint32_t                        bit;
+       guint32                         bit;
        uintptr_t                       value;
        radix_node_t                   *node;
 
@@ -290,7 +290,7 @@ radix32tree_find (radix_tree_t * tree, uint32_t key)
 static void                    *
 radix_alloc (radix_tree_t * tree)
 {
-       char                           *p;
+       gchar                           *p;
 
        p = memory_pool_alloc (tree->pool, sizeof (radix_node_t));
 
index 70aac1f74d040e8df65af3271911835191f199a3..1a1cd26fd160c35a27cac73ec39844604af8daa9 100644 (file)
@@ -13,7 +13,7 @@ struct radix_node_s {
     radix_node_t *left;
     radix_node_t *parent;
     uintptr_t value;
-       uint32_t key;
+       guint32 key;
 };
 
 
@@ -23,7 +23,7 @@ typedef struct {
        memory_pool_t *pool;
 } radix_tree_t;
 
-typedef gboolean (*radix_tree_traverse_func)(uint32_t key, uint32_t mask, uintptr_t value, void *user_data);
+typedef gboolean (*radix_tree_traverse_func)(guint32 key, guint32 mask, uintptr_t value, void *user_data);
 
 /**
  * Create new radix tree
@@ -36,7 +36,7 @@ radix_tree_t *radix_tree_create ();
  *          0 if operation was successfull
  *          -1 if there was some error
  */
-int radix32tree_insert (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr_t value);
+gint radix32tree_insert (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value);
 
 /**
  * Add value to radix tree or insert it if value does not exists
@@ -44,7 +44,7 @@ int radix32tree_insert (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr
  *          0 if value was inserted
  *          -1 if there was some error
  */
-uintptr_t radix32tree_add (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr_t value);
+uintptr_t radix32tree_add (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value);
 
 /**
  * Replace value in radix tree or insert it if value does not exists
@@ -52,7 +52,7 @@ uintptr_t radix32tree_add (radix_tree_t *tree, uint32_t key, uint32_t mask, uint
  *          0 if value was inserted
  *          -1 if there was some error
  */
-int radix32tree_replace (radix_tree_t *tree, uint32_t key, uint32_t mask, uintptr_t value);
+gint radix32tree_replace (radix_tree_t *tree, guint32 key, guint32 mask, uintptr_t value);
 
 /**
  * Delete value from radix tree
@@ -60,14 +60,14 @@ int radix32tree_replace (radix_tree_t *tree, uint32_t key, uint32_t mask, uintpt
  *          0 if value was deleted
  *          -1 if there was some error
  */
-int radix32tree_delete (radix_tree_t *tree, uint32_t key, uint32_t mask);
+gint radix32tree_delete (radix_tree_t *tree, guint32 key, guint32 mask);
 
 /**
  * Find value in radix tree
  * returns: value if value was found
  *                     RADIX_NO_VALUE if value was not found
  */
-uintptr_t radix32tree_find (radix_tree_t *tree, uint32_t key);
+uintptr_t radix32tree_find (radix_tree_t *tree, guint32 key);
 
 /**
  * Traverse via the whole tree calling specified callback
index dd4127c19e773afbc6f1eceef303d822bd4b4465..e2998984d5e8b9205e273a0104706c490fc22869 100644 (file)
@@ -104,11 +104,11 @@ void
 json_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
 {
        struct json_buf                *jb;
-       int                             nelts, i, n, a;
+       gint                            nelts, i, n, a;
        json_t                         *js, *cur_elt, *cur_nm, *it_val;
        json_error_t                    je;
        struct rspamd_settings         *cur_settings;
-       char                           *cur_name;
+       gchar                           *cur_name;
        void                           *json_it;
        double                         *score;
 
@@ -246,7 +246,7 @@ json_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
 }
 
 gboolean
-read_settings (const char *path, struct config_file *cfg, GHashTable * table)
+read_settings (const gchar *path, struct config_file *cfg, GHashTable * table)
 {
        struct json_buf                *jb = g_malloc (sizeof (struct json_buf)), **pjb;
 
@@ -274,7 +274,7 @@ init_settings (struct config_file *cfg)
 static                          gboolean
 check_setting (struct worker_task *task, struct rspamd_settings **user_settings, struct rspamd_settings **domain_settings)
 {
-       char                           *field = NULL, *domain = NULL;
+       gchar                           *field = NULL, *domain = NULL;
 
        if (task->deliver_to != NULL) {
                /* First try to use deliver-to field */
@@ -321,7 +321,7 @@ check_setting (struct worker_task *task, struct rspamd_settings **user_settings,
 static                         gboolean
 check_whitelist(struct worker_task *task, struct rspamd_settings *s)
 {
-       char *src_email = NULL, *src_domain = NULL;
+       gchar                           *src_email = NULL, *src_domain = NULL;
 
        if (task->from != NULL) {
                src_email = task->from;
@@ -391,7 +391,7 @@ check_metric_settings (struct worker_task * task, struct metric * metric, double
 }
 
 gboolean
-check_factor_settings (struct worker_task * task, const char *symbol, double *factor)
+check_factor_settings (struct worker_task * task, const gchar *symbol, double *factor)
 {
        struct rspamd_settings         *us = NULL, *ds = NULL;
        double                         *fc;
index 1f7ee743f305902c4c20fe6a3faa0346573c6462..a1d712a8722a55062e9d7d96e055ccbc45ccb86c 100644 (file)
@@ -9,15 +9,15 @@ struct rspamd_settings {
        GHashTable *reject_scores;                      /**< hash table of metric reject scores for this setting                */
        GHashTable *factors;                            /**< hash table of new factors for this setting                 */
        GHashTable *whitelist;                          /**< hash table of whitelist for this setting                   */
-       char *statfile_alias;                           /**< alias for statfile used                                                    */
+       gchar *statfile_alias;                          /**< alias for statfile used                                                    */
        gboolean want_spam;                                     /**< if true disable rspamd checks                                              */
 };
 
 
-gboolean read_settings (const char *path, struct config_file *cfg, GHashTable *table);
+gboolean read_settings (const gchar *path, struct config_file *cfg, GHashTable *table);
 void init_settings (struct config_file *cfg);
 gboolean check_metric_settings (struct worker_task *task, struct metric *metric, double *score, double *rscore);
-gboolean check_factor_settings (struct worker_task *task, const char *symbol, double *factor);
+gboolean check_factor_settings (struct worker_task *task, const gchar *symbol, double *factor);
 gboolean check_want_spam (struct worker_task *task);
 
 #endif
index aefdf2ca7b6a73da5fc0ae3dc2523111dd4ea820..d4abdb7f9a43060df449fdbadf6a8d5befdd095d 100644 (file)
@@ -51,10 +51,10 @@ static sig_atomic_t                    wanna_die = 0;
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t *info, void *unused)
 #endif
 {
        struct timeval                  tv;
@@ -114,7 +114,7 @@ free_smtp_session (gpointer arg)
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (int fd, short what, void *arg)
+sigusr_handler (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        /* Do not accept new connections, preparing to end worker's process */
@@ -194,8 +194,8 @@ static gboolean
 read_smtp_command (struct smtp_session *session, f_str_t *line)
 {
        struct smtp_command             *cmd;
-       char                             outbuf[BUFSIZ];
-       int                              r;
+       gchar                           outbuf[BUFSIZ];
+       gint                            r;
        
        if (! parse_smtp_command (session, line, &cmd)) {
                session->error = SMTP_ERROR_BAD_COMMAND;
@@ -363,10 +363,10 @@ static gboolean
 process_smtp_data (struct smtp_session *session)
 {
        struct stat                     st;
-       int                             r;
+       gint                            r;
        GList                          *cur, *t;
        f_str_t                        *f;
-       char                           *s;
+       gchar                           *s;
 
        if (fstat (session->temp_fd, &st) == -1) {
                msg_err ("fstat failed: %s", strerror (errno));
@@ -535,10 +535,10 @@ smtp_write_socket (void *arg)
 {
        struct smtp_session            *session = arg;
        double                          ms = 0, rs = 0;
-       int                             r;
+       gint                            r;
        struct metric_result           *metric_res;
        struct metric                  *m;
-       char                            logbuf[1024];
+       gchar                           logbuf[1024];
        gboolean                        is_spam = FALSE;
        GList                          *symbols, *cur;  
 
@@ -567,25 +567,25 @@ smtp_write_socket (void *arg)
 
                                r = rspamd_snprintf (logbuf, sizeof (logbuf), "msg ok, id: <%s>, ", session->task->message_id);
                                r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "(%s: %s: [%.2f/%.2f/%.2f] [", 
-                                               (char *)m->name, is_spam ? "T" : "F", metric_res->score, ms, rs);
+                                               (gchar *)m->name, is_spam ? "T" : "F", metric_res->score, ms, rs);
                                symbols = g_hash_table_get_keys (metric_res->symbols);
                                cur = symbols;
                                while (cur) {
                                        if (g_list_next (cur) != NULL) {
-                                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "%s,", (char *)cur->data);
+                                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "%s,", (gchar *)cur->data);
                                        }
                                        else {
-                                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "%s", (char *)cur->data);
+                                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "%s", (gchar *)cur->data);
                                        }
                                        cur = g_list_next (cur);
                                }
                                g_list_free (symbols);
 #ifdef HAVE_CLOCK_GETTIME
-                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "]), len: %l, time: %s",
-                                       (long int)session->task->msg->len, calculate_check_time (&session->task->tv, &session->task->ts, session->cfg->clock_res));
+                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "]), len: %z, time: %s",
+                                       session->task->msg->len, calculate_check_time (&session->task->tv, &session->task->ts, session->cfg->clock_res));
 #else
-                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "]), len: %l, time: %s",
-                                       (long int)session->task->msg->len, calculate_check_time (&session->task->tv, session->cfg->clock_res));
+                               r += rspamd_snprintf (logbuf + r, sizeof (logbuf) - r, "]), len: %z, time: %s",
+                                       session->task->msg->len, calculate_check_time (&session->task->tv, session->cfg->clock_res));
 #endif
                                msg_info ("%s", logbuf);
 
@@ -653,7 +653,7 @@ write_smtp_greeting (struct smtp_session *session)
  * Return from a delay
  */
 static void
-smtp_delay_handler (int fd, short what, void *arg)
+smtp_delay_handler (gint fd, short what, void *arg)
 {
        struct smtp_session            *session = arg;
        
@@ -709,7 +709,7 @@ static void
 smtp_dns_cb (struct rspamd_dns_reply *reply, void *arg)
 {
        struct smtp_session            *session = arg;
-       int                             res = 0;
+       gint                            res = 0;
        union rspamd_reply_element     *elt;
        GList                          *cur;
        
@@ -790,7 +790,7 @@ smtp_dns_cb (struct rspamd_dns_reply *reply, void *arg)
  * Accept new connection and construct task
  */
 static void
-accept_socket (int fd, short what, void *arg)
+accept_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        union sa_union                  su;
@@ -798,7 +798,7 @@ accept_socket (int fd, short what, void *arg)
        struct smtp_worker_ctx         *ctx;
 
        socklen_t                       addrlen = sizeof (su.ss);
-       int                             nfd;
+       gint                            nfd;
 
        if ((nfd = accept_from_socket (fd, (struct sockaddr *)&su.ss, &addrlen)) == -1) {
                msg_warn ("accept failed: %s", strerror (errno));
@@ -849,13 +849,13 @@ accept_socket (int fd, short what, void *arg)
 }
 
 static void
-parse_smtp_banner (struct smtp_worker_ctx *ctx, const char *line)
+parse_smtp_banner (struct smtp_worker_ctx *ctx, const gchar *line)
 {
-       int                             hostmax, banner_len = sizeof ("220 ") - 1;
-       char                           *p, *t, *hostbuf = NULL;
+       gint                            hostmax, banner_len = sizeof ("220 ") - 1;
+       gchar                           *p, *t, *hostbuf = NULL;
        gboolean                        has_crlf = FALSE;
 
-       p = (char *)line;
+       p = (gchar *)line;
        while (*p) {
                if (*p == '%') {
                        p ++;
@@ -895,7 +895,7 @@ parse_smtp_banner (struct smtp_worker_ctx *ctx, const char *line)
 
        ctx->smtp_banner = memory_pool_alloc (ctx->pool, banner_len + 1);
        t = ctx->smtp_banner;
-       p = (char *)line;
+       p = (gchar *)line;
 
        if (has_crlf) {
                t = g_stpcpy (t, "220-");
@@ -923,7 +923,7 @@ parse_smtp_banner (struct smtp_worker_ctx *ctx, const char *line)
                                        p ++;
                                        break;
                                default:
-                                       /* Copy all %<char> to dest */
+                                       /* Copy all %<gchar> to dest */
                                        *t++ = *(p - 1); *t++ = *p;
                                        break;
                        }
@@ -941,12 +941,12 @@ parse_smtp_banner (struct smtp_worker_ctx *ctx, const char *line)
 }
 
 static gboolean
-parse_upstreams_line (struct smtp_worker_ctx *ctx, const char *line)
+parse_upstreams_line (struct smtp_worker_ctx *ctx, const gchar *line)
 {
-       char                          **strv, *p, *t, *tt, *err_str;
-       uint32_t                        num, i;
+       gchar                           **strv, *p, *t, *tt, *err_str;
+       guint32                         num, i;
        struct smtp_upstream           *cur;
-       char                            resolved_path[PATH_MAX];
+       gchar                           resolved_path[PATH_MAX];
        
        strv = g_strsplit_set (line, ",; ", -1);
        num = g_strv_length (strv);
@@ -996,10 +996,10 @@ parse_upstreams_line (struct smtp_worker_ctx *ctx, const char *line)
 }
 
 static void
-make_capabilities (struct smtp_worker_ctx *ctx, const char *line)
+make_capabilities (struct smtp_worker_ctx *ctx, const gchar *line)
 {
-       char                          **strv, *p, *result, *hostbuf;
-       uint32_t                        num, i, len, hostmax;
+       gchar                           **strv, *p, *result, *hostbuf;
+       guint32                         num, i, len, hostmax;
 
        strv = g_strsplit_set (line, ",;", -1);
        num = g_strv_length (strv);
@@ -1043,8 +1043,8 @@ static gboolean
 config_smtp_worker (struct rspamd_worker *worker)
 {
        struct smtp_worker_ctx         *ctx;
-       char                           *value;
-       uint32_t                        timeout;
+       gchar                           *value;
+       guint32                         timeout;
 
        ctx = g_malloc0 (sizeof (struct smtp_worker_ctx));
        ctx->pool = memory_pool_new (memory_pool_get_size ());
index 411d03003368c75c2b2854f5571b5f83f51bf48b..1933376c3804c6a51f6b9f027f04511fde467ced 100644 (file)
@@ -8,9 +8,9 @@
 struct smtp_upstream {
        struct upstream up;
        
-       const char *name;
+       const gchar *name;
        struct in_addr addr;
-       uint16_t port;
+       guint16 port;
        gboolean is_unix;
 }; 
 
@@ -33,18 +33,18 @@ struct smtp_worker_ctx {
        size_t upstream_num;
        
        memory_pool_t *pool;
-       char *smtp_banner;
-       uint32_t smtp_delay;
-       uint32_t delay_jitter;
+       gchar *smtp_banner;
+       guint32 smtp_delay;
+       guint32 delay_jitter;
        struct timeval smtp_timeout;
 
        gboolean use_xclient;
        gboolean helo_required;
-       char *smtp_capabilities;
-       char *reject_message;
+       gchar *smtp_capabilities;
+       gchar *reject_message;
        size_t max_size;
        guint max_errors;
-       char *metric;
+       gchar *metric;
        GList *smtp_filters[SMTP_STAGE_MAX];
        struct rspamd_dns_resolver *resolver;
 };
@@ -79,12 +79,12 @@ struct smtp_session {
        struct rspamd_worker *worker;
        struct worker_task *task;
        struct in_addr client_addr;
-       char *hostname;
-       char *error;
-       char *temp_name;
-       int sock;
-       int upstream_sock;
-       int temp_fd;
+       gchar *hostname;
+       gchar *error;
+       gchar *temp_name;
+       gint sock;
+       gint upstream_sock;
+       gint temp_fd;
        size_t temp_size;
        time_t session_time;
 
index dd1e6cbc317cd4f3b844e351032d274306e8e60d..dc8fccec1a6d51057a2a8ed2aad50768bdd92e0e 100644 (file)
 #include "smtp.h"
 #include "smtp_proto.h"
 
-char *
-make_smtp_error (struct smtp_session *session, int error_code, const char *format, ...)
+gchar                           *
+make_smtp_error (struct smtp_session *session, gint error_code, const gchar *format, ...)
 {
        va_list                         vp;
-       char                           *result = NULL, *p;
+       gchar                           *result = NULL, *p;
        size_t                          len;
        
        va_start (vp, format);
@@ -61,7 +61,7 @@ parse_smtp_command (struct smtp_session *session, f_str_t *line, struct smtp_com
                SMTP_PARSE_DONE
        }                              state;
        gchar                         *p, *c, ch, cmd_buf[4];
-       int                            i;
+       gint                            i;
        f_str_t                       *arg = NULL;
        struct smtp_command           *pcmd;
        
@@ -144,7 +144,7 @@ parse_smtp_command (struct smtp_session *session, f_str_t *line, struct smtp_com
                                        }
                                }
                                else if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z')) {
-                                       msg_info ("invalid letter code in SMTP command: %d", (int)ch);
+                                       msg_info ("invalid letter code in SMTP command: %d", (gint)ch);
                                        return FALSE;
                                }
                                break;
@@ -201,8 +201,8 @@ end:
 static gboolean
 check_smtp_path (f_str_t *path)
 {
-       int                            i;
-       char                          *p;
+       gint                            i;
+       gchar                           *p;
 
        p = path->begin;
        if (*p != '<' || path->len < 2) {
@@ -328,10 +328,10 @@ parse_smtp_rcpt (struct smtp_session *session, struct smtp_command *cmd)
 }
 
 /* Return -1 if there are some error, 1 if all is ok and 0 in case of incomplete reply */
-static int
-check_smtp_ustream_reply (f_str_t *in, char success_code)
+static gint
+check_smtp_ustream_reply (f_str_t *in, gchar success_code)
 {
-       char                           *p;
+       gchar                           *p;
 
        /* Check for 250 at the begin of line */
        if (in->len >= sizeof ("220 ") - 1) {
@@ -354,7 +354,7 @@ check_smtp_ustream_reply (f_str_t *in, char success_code)
 }
 
 size_t
-smtp_upstream_write_list (GList *args, char *buf, size_t buflen)
+smtp_upstream_write_list (GList *args, gchar *buf, size_t buflen)
 {
        GList                          *cur = args;
        size_t                          r = 0;
@@ -390,8 +390,8 @@ gboolean
 smtp_upstream_read_socket (f_str_t * in, void *arg)
 {
        struct smtp_session            *session = arg;
-       char                            outbuf[BUFSIZ];
-       int                             r;
+       gchar                           outbuf[BUFSIZ];
+       gint                            r;
        
        switch (session->upstream_state) {
                case SMTP_STATE_GREETING:
index d44cbe7b1c06de6690ec995f81cbdb93573baea7..eb03ceb1675b040c9d6a40592f74217fa9b693c3 100644 (file)
@@ -36,7 +36,7 @@ struct smtp_command {
        GList *args;
 };
 
-char * make_smtp_error (struct smtp_session *session, int error_code, const char *format, ...);
+gchar * make_smtp_error (struct smtp_session *session, gint error_code, const gchar *format, ...);
 gboolean parse_smtp_command (struct smtp_session *session, f_str_t *line, struct smtp_command **cmd);
 gboolean parse_smtp_helo (struct smtp_session *session, struct smtp_command *cmd);
 gboolean parse_smtp_from (struct smtp_session *session, struct smtp_command *cmd);
@@ -47,6 +47,6 @@ gboolean smtp_upstream_read_socket (f_str_t * in, void *arg);
 gboolean smtp_upstream_write_socket (void *arg);
 void smtp_upstream_err_socket (GError *err, void *arg);
 void smtp_upstream_finalize_connection (gpointer data);
-size_t smtp_upstream_write_list (GList *args, char *buf, size_t buflen);
+size_t smtp_upstream_write_list (GList *args, gchar *buf, size_t buflen);
 
 #endif
index d1a03e3d9d3d27bc3915fbfaf73602dba23d4455..fcfdbd05cc69bd28cf2923aa12f934120eba3988 100644 (file)
--- a/src/spf.c
+++ b/src/spf.c
@@ -85,11 +85,11 @@ do {                                                                                                                \
 } while (0)                                                                                                    \
 
 static gboolean parse_spf_record (struct worker_task *task, struct spf_record *rec);
-static void start_spf_parse (struct spf_record *rec, char *begin);
+static void start_spf_parse (struct spf_record *rec, gchar *begin);
 
 /* Determine spf mech */
 static spf_mech_t
-check_spf_mech (const char *elt, gboolean *need_shift)
+check_spf_mech (const gchar *elt, gboolean *need_shift)
 {
        g_assert (elt != NULL);
        
@@ -111,11 +111,11 @@ check_spf_mech (const char *elt, gboolean *need_shift)
 }
 
 static gboolean
-parse_spf_ipmask (const char *begin, struct spf_addr *addr)
+parse_spf_ipmask (const gchar *begin, struct spf_addr *addr)
 {
-       const char *pos;
-       char ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p;
-       int state = 0, dots = 0;
+       const gchar *pos;
+       gchar                           ip_buf[sizeof ("255.255.255.255")], mask_buf[3], *p;
+       gint                            state = 0, dots = 0;
        struct in_addr in;
        
        bzero (ip_buf, sizeof (ip_buf));
@@ -192,11 +192,11 @@ parse_spf_ipmask (const char *begin, struct spf_addr *addr)
 
 }
 
-static char *
-parse_spf_hostmask (struct worker_task *task, const char *begin, struct spf_addr *addr, struct spf_record *rec)
+static gchar *
+parse_spf_hostmask (struct worker_task *task, const gchar *begin, struct spf_addr *addr, struct spf_record *rec)
 {
-       char *host = NULL, *p,  mask_buf[3];
-       int hostlen;
+       gchar                           *host = NULL, *p,  mask_buf[3];
+       gint                            hostlen;
 
        bzero (mask_buf, sizeof (mask_buf));
        if (*begin == '\0' || *begin == '/') {
@@ -231,7 +231,7 @@ static void
 spf_record_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
 {
        struct spf_dns_cb *cb = arg;
-       char *begin;
+       gchar                           *begin;
        union rspamd_reply_element *elt_data;
        GList *tmp = NULL, *tmp1, *elt, *last;
        struct worker_task *task;
@@ -385,10 +385,10 @@ spf_record_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
 }
 
 static gboolean
-parse_spf_a (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_a (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
-       char *host;
+       gchar                           *host;
        
        CHECK_REC (rec);
        
@@ -420,7 +420,7 @@ parse_spf_a (struct worker_task *task, const char *begin, struct spf_record *rec
 }
 
 static gboolean
-parse_spf_ptr (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_ptr (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        CHECK_REC (rec);
        
@@ -429,10 +429,10 @@ parse_spf_ptr (struct worker_task *task, const char *begin, struct spf_record *r
 }
 
 static gboolean
-parse_spf_mx (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_mx (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
-       char *host;
+       gchar                           *host;
        
        CHECK_REC (rec);
        
@@ -465,7 +465,7 @@ parse_spf_mx (struct worker_task *task, const char *begin, struct spf_record *re
 }
 
 static gboolean
-parse_spf_all (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_all (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        /* All is 0/0 */
        if (rec->in_include) {
@@ -482,7 +482,7 @@ parse_spf_all (struct worker_task *task, const char *begin, struct spf_record *r
 }
 
 static gboolean
-parse_spf_ip4 (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_ip4 (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        /* ip4:addr[/mask] */
 
@@ -491,10 +491,10 @@ parse_spf_ip4 (struct worker_task *task, const char *begin, struct spf_record *r
 }
 
 static gboolean
-parse_spf_include (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_include (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
-       char              *domain;
+       gchar                           *domain;
 
        CHECK_REC (rec);
 
@@ -521,7 +521,7 @@ parse_spf_include (struct worker_task *task, const char *begin, struct spf_recor
 }
 
 static gboolean
-parse_spf_exp (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_exp (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        CHECK_REC (rec);
 
@@ -530,10 +530,10 @@ parse_spf_exp (struct worker_task *task, const char *begin, struct spf_record *r
 }
 
 static gboolean
-parse_spf_redirect (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_redirect (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
-       char              *domain;
+       gchar                           *domain;
 
        CHECK_REC (rec);
 
@@ -559,10 +559,10 @@ parse_spf_redirect (struct worker_task *task, const char *begin, struct spf_reco
 }
 
 static gboolean
-parse_spf_exists (struct worker_task *task, const char *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_exists (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
-       char              *host;
+       gchar                           *host;
 
        CHECK_REC (rec);
        
@@ -590,10 +590,10 @@ parse_spf_exists (struct worker_task *task, const char *begin, struct spf_record
 }
 
 static void
-reverse_spf_ip (char *ip, int len)
+reverse_spf_ip (gchar *ip, gint len)
 {
-       char ipbuf[sizeof("255.255.255.255") - 1], *p, *c;
-       int t = 0, l = len;
+       gchar                           ipbuf[sizeof("255.255.255.255") - 1], *p, *c;
+       gint                            t = 0, l = len;
 
        if (len > sizeof (ipbuf)) {
                msg_info ("cannot reverse string of length %d", len);
@@ -621,11 +621,11 @@ reverse_spf_ip (char *ip, int len)
        memcpy (ip, ipbuf, len);
 }
 
-static char *
-expand_spf_macro (struct worker_task *task, struct spf_record *rec, char *begin)
+static gchar *
+expand_spf_macro (struct worker_task *task, struct spf_record *rec, gchar *begin)
 {
-       char *p, *c, *new, *tmp;
-       int len = 0, slen = 0, state = 0;
+       gchar                           *p, *c, *new, *tmp;
+       gint                            len = 0, slen = 0, state = 0;
        gboolean need_expand = FALSE;
 
        p = begin;
@@ -856,7 +856,7 @@ parse_spf_record (struct worker_task *task, struct spf_record *rec)
 {
        struct spf_addr *new = NULL;
        gboolean need_shift, res = FALSE;
-       char *begin;
+       gchar                           *begin;
        
        rec->cur_elt = rec->elts[rec->elt_num];
        if (rec->cur_elt == NULL) {
@@ -978,7 +978,7 @@ parse_spf_record (struct worker_task *task, struct spf_record *rec)
 #undef NEW_ADDR
 
 static void
-parse_spf_scopes (struct spf_record *rec, char **begin)
+parse_spf_scopes (struct spf_record *rec, gchar **begin)
 {
        for (;;) {
                if (g_ascii_strncasecmp (*begin, SPF_SCOPE_PRA, sizeof (SPF_SCOPE_PRA) - 1) == 0) {
@@ -1000,7 +1000,7 @@ parse_spf_scopes (struct spf_record *rec, char **begin)
 }
 
 static void
-start_spf_parse (struct spf_record *rec, char *begin)
+start_spf_parse (struct spf_record *rec, gchar *begin)
 {
        /* Skip spaces */
        while (g_ascii_isspace (*begin)) {
@@ -1080,7 +1080,7 @@ gboolean
 resolve_spf (struct worker_task *task, spf_cb_t callback)
 {
        struct spf_record *rec;
-       char *domain;
+       gchar                           *domain;
        GList *domains;
 
        rec = memory_pool_alloc0 (task->task_pool, sizeof (struct spf_record));
index ab15cb91180d02fdd39795ded06a459009c14867..c65a1bf15101e310b1ccfffa7cad5b1081bbcbd2 100644 (file)
--- a/src/spf.h
+++ b/src/spf.h
@@ -26,25 +26,25 @@ typedef enum spf_action_e {
 } spf_action_t;
 
 struct spf_addr {
-       uint32_t addr;
-       uint32_t mask;
+       guint32 addr;
+       guint32 mask;
        spf_mech_t mech;
-       char *spf_string;
+       gchar *spf_string;
 };
 
 struct spf_record {
-       char **elts;
+       gchar **elts;
 
-       char *cur_elt;
-       int elt_num;
-       int nested;
-       int dns_requests;
+       gchar *cur_elt;
+       gint elt_num;
+       gint nested;
+       gint dns_requests;
 
        GList *addrs;
-       char *cur_domain;
-       char *sender;
-       char *sender_domain;
-       char *local_part;
+       gchar *cur_domain;
+       gchar *sender;
+       gchar *sender_domain;
+       gchar *local_part;
        struct worker_task *task;
        spf_cb_t callback;
 
index 1660a29f4362743a79c1a1d375ee8ecf24cc4f38..b26664fd50cc85bc6fb064e97d3b83fe477446be 100644 (file)
 #define STATFILES_MAX 255
 static void statfile_pool_set_block_common (
                                statfile_pool_t * pool, stat_file_t * file, 
-                               uint32_t h1, uint32_t h2, 
+                               guint32                         h1, guint32 h2, 
                                time_t t, double value, 
                                gboolean from_now);
 
-static int
+static gint
 cmpstatfile (const void *a, const void *b)
 {
        const stat_file_t              *s1 = a, *s2 = b;
@@ -51,13 +51,13 @@ struct stat_file_header_10 {
        u_char magic[3];                                                /**< magic signature ('r' 's' 'd')              */
        u_char version[2];                                              /**< version of statfile                                */
        u_char padding[3];                                              /**< padding                                                    */
-       uint64_t create_time;                                   /**< create time (time_t->uint64_t)             */
+       guint64                         create_time;                                    /**< create time (time_t->guint64)              */
 };
 
 static gboolean
 convert_statfile_10 (stat_file_t * file)
 {
-       char *backup_name;
+       gchar                           *backup_name;
        struct stat st;
        struct stat_file_header         header = {
                .magic = {'r', 's', 'd'},
@@ -117,12 +117,12 @@ convert_statfile_10 (stat_file_t * file)
 }
 
 /* Check whether specified file is statistic file and calculate its len in blocks */
-static int
+static gint
 statfile_pool_check (stat_file_t * file)
 {
        struct stat_file               *f;
-       char                           *c;
-       static char                     valid_version[] = RSPAMD_STATFILE_VERSION;
+       gchar                           *c;
+       static gchar                     valid_version[] = RSPAMD_STATFILE_VERSION;
 
 
        if (!file || !file->map) {
@@ -169,17 +169,17 @@ statfile_pool_check (stat_file_t * file)
 
 struct expiration_data {
        statfile_pool_t                *pool;
-       uint64_t                        oldest;
-       char                           *filename;
+       guint64                         oldest;
+       gchar                           *filename;
 };
 
 
-static int
+static gint
 statfile_pool_expire (statfile_pool_t * pool)
 {
        struct expiration_data          exp;
        stat_file_t                    *file;
-       int                             i;
+       gint                            i;
 
        if (pool->opened == 0) {
                return -1;
@@ -191,7 +191,7 @@ statfile_pool_expire (statfile_pool_t * pool)
 
        for (i = 0; i < pool->opened; i++) {
                file = &pool->files[i];
-               if ((uint64_t) file->access_time < exp.oldest) {
+               if ((guint64) file->access_time < exp.oldest) {
                        exp.oldest = file->access_time;
                        exp.filename = file->filename;
                }
@@ -219,10 +219,10 @@ statfile_pool_new (memory_pool_t *pool, size_t max_size)
 }
 
 static stat_file_t *
-statfile_pool_reindex (statfile_pool_t * pool, char *filename, size_t old_size, size_t size)
+statfile_pool_reindex (statfile_pool_t * pool, gchar *filename, size_t old_size, size_t size)
 {
-       char                           *backup;
-       int                             fd;
+       gchar                           *backup;
+       gint                            fd;
        stat_file_t                    *new;
        u_char                         *map, *pos;
        struct stat_file_block         *block;
@@ -283,7 +283,7 @@ statfile_pool_reindex (statfile_pool_t * pool, char *filename, size_t old_size,
 }
 
 stat_file_t                    *
-statfile_pool_open (statfile_pool_t * pool, char *filename, size_t size, gboolean forced)
+statfile_pool_open (statfile_pool_t * pool, gchar *filename, size_t size, gboolean forced)
 {
        struct stat                     st;
        stat_file_t                    *new_file;
@@ -365,7 +365,7 @@ statfile_pool_open (statfile_pool_t * pool, char *filename, size_t size, gboolea
        return statfile_pool_is_open (pool, filename);
 }
 
-int
+gint
 statfile_pool_close (statfile_pool_t * pool, stat_file_t * file, gboolean keep_sorted)
 {
        stat_file_t                    *pos;
@@ -398,8 +398,8 @@ statfile_pool_close (statfile_pool_t * pool, stat_file_t * file, gboolean keep_s
        return 0;
 }
 
-int
-statfile_pool_create (statfile_pool_t * pool, char *filename, size_t size)
+gint
+statfile_pool_create (statfile_pool_t * pool, gchar *filename, size_t size)
 {
        struct stat_file_header         header = {
                .magic = {'r', 's', 'd'},
@@ -413,9 +413,9 @@ statfile_pool_create (statfile_pool_t * pool, char *filename, size_t size)
                .code = STATFILE_SECTION_COMMON,
        };
        struct stat_file_block          block = { 0, 0, 0 };
-       int                             fd;
-       unsigned int                    buflen = 0, nblocks;
-       char                           *buf = NULL;
+       gint                            fd;
+       guint                           buflen = 0, nblocks;
+       gchar                           *buf = NULL;
 
        if (statfile_pool_is_open (pool, filename) != NULL) {
                msg_info ("file %s is already opened", filename);
@@ -432,7 +432,7 @@ statfile_pool_create (statfile_pool_t * pool, char *filename, size_t size)
                return -1;
        }
 
-       header.create_time = (uint64_t) time (NULL);
+       header.create_time = (guint64) time (NULL);
        if (write (fd, &header, sizeof (header)) == -1) {
                msg_info ("cannot write header to file %s, error %d, %s", filename, errno, strerror (errno));
                close (fd);
@@ -440,7 +440,7 @@ statfile_pool_create (statfile_pool_t * pool, char *filename, size_t size)
                return -1;
        }
 
-       section.length = (uint64_t) nblocks;
+       section.length = (guint64) nblocks;
        if (write (fd, &section, sizeof (section)) == -1) {
                msg_info ("cannot write section header to file %s, error %d, %s", filename, errno, strerror (errno));
                close (fd);
@@ -493,7 +493,7 @@ statfile_pool_create (statfile_pool_t * pool, char *filename, size_t size)
 void
 statfile_pool_delete (statfile_pool_t * pool)
 {
-       int                             i;
+       gint                            i;
 
        for (i = 0; i < pool->opened; i++) {
                statfile_pool_close (pool, &pool->files[i], FALSE);
@@ -516,11 +516,11 @@ statfile_pool_unlock_file (statfile_pool_t * pool, stat_file_t * file)
 }
 
 double
-statfile_pool_get_block (statfile_pool_t * pool, stat_file_t * file, uint32_t h1, uint32_t h2, time_t now)
+statfile_pool_get_block (statfile_pool_t * pool, stat_file_t * file, guint32 h1, guint32 h2, time_t now)
 {
        struct stat_file_block         *block;
        struct stat_file_header        *header;
-       unsigned int                    i, blocknum;
+       guint                           i, blocknum;
        u_char                         *c;
 
 
@@ -551,11 +551,11 @@ statfile_pool_get_block (statfile_pool_t * pool, stat_file_t * file, uint32_t h1
 
 #define RANDOM_EXPIRE G_MAXINT / CHAIN_LENGTH
 static void
-statfile_pool_set_block_common (statfile_pool_t * pool, stat_file_t * file, uint32_t h1, uint32_t h2, time_t t, double value, gboolean from_now)
+statfile_pool_set_block_common (statfile_pool_t * pool, stat_file_t * file, guint32 h1, guint32 h2, time_t t, double value, gboolean from_now)
 {
        struct stat_file_block         *block, *to_expire = NULL;
        struct stat_file_header        *header;
-       unsigned int                    i, blocknum;
+       guint                           i, blocknum;
        u_char                         *c;
     double                          min = G_MAXDOUBLE;
 
@@ -624,13 +624,13 @@ statfile_pool_set_block_common (statfile_pool_t * pool, stat_file_t * file, uint
 }
 
 void
-statfile_pool_set_block (statfile_pool_t * pool, stat_file_t * file, uint32_t h1, uint32_t h2, time_t now, double value)
+statfile_pool_set_block (statfile_pool_t * pool, stat_file_t * file, guint32 h1, guint32 h2, time_t now, double value)
 {
        statfile_pool_set_block_common (pool, file, h1, h2, now, value, TRUE);
 }
 
 stat_file_t                    *
-statfile_pool_is_open (statfile_pool_t * pool, char *filename)
+statfile_pool_is_open (statfile_pool_t * pool, gchar *filename)
 {
        static stat_file_t              f, *ret;
        g_strlcpy (f.filename, filename, sizeof (f.filename));
@@ -638,7 +638,7 @@ statfile_pool_is_open (statfile_pool_t * pool, char *filename)
        return ret;
 }
 
-uint32_t
+guint32
 statfile_pool_get_section (statfile_pool_t * pool, stat_file_t * file)
 {
 
@@ -646,7 +646,7 @@ statfile_pool_get_section (statfile_pool_t * pool, stat_file_t * file)
 }
 
 gboolean
-statfile_pool_set_section (statfile_pool_t * pool, stat_file_t * file, uint32_t code, gboolean from_begin)
+statfile_pool_set_section (statfile_pool_t * pool, stat_file_t * file, guint32 code, gboolean from_begin)
 {
        struct stat_file_section       *sec;
        off_t                           cur_offset;
@@ -660,7 +660,7 @@ statfile_pool_set_section (statfile_pool_t * pool, stat_file_t * file, uint32_t
                cur_offset = file->seek_pos - sizeof (struct stat_file_section);
        }
        while (cur_offset < file->len) {
-               sec = (struct stat_file_section *)((char *)file->map + cur_offset);
+               sec = (struct stat_file_section *)((gchar *)file->map + cur_offset);
                if (sec->code == code) {
                        file->cur_section.code = code;
                        file->cur_section.length = sec->length;
@@ -674,7 +674,7 @@ statfile_pool_set_section (statfile_pool_t * pool, stat_file_t * file, uint32_t
 }
 
 gboolean
-statfile_pool_add_section (statfile_pool_t * pool, stat_file_t * file, uint32_t code, uint64_t length)
+statfile_pool_add_section (statfile_pool_t * pool, stat_file_t * file, guint32 code, guint64 length)
 {
        struct stat_file_section        sect;
        struct stat_file_block          block = { 0, 0, 0 };
@@ -706,7 +706,7 @@ statfile_pool_add_section (statfile_pool_t * pool, stat_file_t * file, uint32_t
        file->len += length;
 
        if (file->len > pool->max) {
-               msg_info ("cannot attach file to pool, too large: %lu", (long int)file->len);
+               msg_info ("cannot attach file to pool, too large: %z", file->len);
                return FALSE;
        }
 
@@ -727,8 +727,8 @@ statfile_pool_add_section (statfile_pool_t * pool, stat_file_t * file, uint32_t
 
 }
 
-uint32_t
-statfile_get_section_by_name (const char *name)
+guint32
+statfile_get_section_by_name (const gchar *name)
 {
        if (g_ascii_strcasecmp (name, "common") == 0) {
                return STATFILE_SECTION_COMMON;
@@ -747,7 +747,7 @@ statfile_get_section_by_name (const char *name)
 }
 
 gboolean 
-statfile_set_revision (stat_file_t *file, uint64_t rev, time_t time)
+statfile_set_revision (stat_file_t *file, guint64 rev, time_t time)
 {
        struct stat_file_header        *header;
 
@@ -764,7 +764,7 @@ statfile_set_revision (stat_file_t *file, uint64_t rev, time_t time)
 }
 
 gboolean 
-statfile_get_revision (stat_file_t *file, uint64_t *rev, time_t *time)
+statfile_get_revision (stat_file_t *file, guint64 *rev, time_t *time)
 {
        struct stat_file_header        *header;
 
@@ -780,13 +780,13 @@ statfile_get_revision (stat_file_t *file, uint64_t *rev, time_t *time)
        return TRUE;
 }
 
-uint64_t 
+guint64 
 statfile_get_used_blocks (stat_file_t *file)
 {
        struct stat_file_header        *header;
 
        if (file == NULL || file->map == NULL) {
-               return (uint64_t)-1;
+               return (guint64)-1;
        }
        
        header = (struct stat_file_header *)file->map;
@@ -794,13 +794,13 @@ statfile_get_used_blocks (stat_file_t *file)
        return header->used_blocks;
 }
 
-uint64_t 
+guint64 
 statfile_get_total_blocks (stat_file_t *file)
 {
        struct stat_file_header        *header;
 
        if (file == NULL || file->map == NULL) {
-               return (uint64_t)-1;
+               return (guint64)-1;
        }
        
        header = (struct stat_file_header *)file->map;
@@ -814,11 +814,11 @@ statfile_get_total_blocks (stat_file_t *file)
 }
 
 static void
-statfile_pool_invalidate_callback (int fd, short what, void *ud)
+statfile_pool_invalidate_callback (gint fd, short what, void *ud)
 {
        statfile_pool_t                *pool = ud;
        stat_file_t                    *file;
-       int                             i;
+       gint                            i;
 
        msg_info ("invalidating %d statfiles", pool->opened);
 
@@ -843,6 +843,6 @@ statfile_pool_plan_invalidate (statfile_pool_t *pool, time_t seconds, time_t jit
                pool->invalidate_tv.tv_usec = 0;
                evtimer_set (pool->invalidate_event, statfile_pool_invalidate_callback, pool);
                evtimer_add (pool->invalidate_event, &pool->invalidate_tv);
-               msg_info ("invalidate of statfile pool is planned in %d seconds", (int)pool->invalidate_tv.tv_sec);
+               msg_info ("invalidate of statfile pool is planned in %d seconds", (gint)pool->invalidate_tv.tv_sec);
        }
 }
index dfdd16dbe7cf7dac8a6f326e0d400807e23462d0..5714641966c1b45540243d5738dbbc7f9d6f962d 100644 (file)
@@ -28,11 +28,11 @@ struct stat_file_header {
        u_char magic[3];                                                /**< magic signature ('r' 's' 'd')              */
        u_char version[2];                                              /**< version of statfile                                */
        u_char padding[3];                                              /**< padding                                                    */
-       uint64_t create_time;                                   /**< create time (time_t->uint64_t)             */
-       uint64_t revision;                                              /**< revision number                                    */
-       uint64_t rev_time;                                              /**< revision time                                              */
-       uint64_t used_blocks;                                   /**< used blocks number                                 */
-       uint64_t total_blocks;                                  /**< total number of blocks                             */
+       guint64 create_time;                                    /**< create time (time_t->guint64)              */
+       guint64 revision;                                               /**< revision number                                    */
+       guint64 rev_time;                                               /**< revision time                                              */
+       guint64 used_blocks;                                    /**< used blocks number                                 */
+       guint64 total_blocks;                                   /**< total number of blocks                             */
        u_char unused[239];                                             /**< some bytes that can be used in future */
 };
 
@@ -40,16 +40,16 @@ struct stat_file_header {
  * Section header
  */
 struct stat_file_section {
-       uint64_t code;                                                  /**< section's code                                             */
-       uint64_t length;                                                /**< section's length in blocks                 */
+       guint64 code;                                                   /**< section's code                                             */
+       guint64 length;                                         /**< section's length in blocks                 */
 };
 
 /**
  * Block of data in statfile
  */
 struct stat_file_block {
-       uint32_t hash1;                                                 /**< hash1 (also acts as index)                 */                              
-       uint32_t hash2;                                                 /**< hash2                                                              */
+       guint32 hash1;                                                  /**< hash1 (also acts as index)                 */                              
+       guint32 hash2;                                                  /**< hash2                                                              */
        double value;                                                   /**< double value                                               */
 };
 
@@ -67,11 +67,11 @@ struct stat_file {
  */
 typedef struct stat_file_s {
 #ifdef HAVE_PATH_MAX
-       char filename[PATH_MAX];                                /**< name of file                                               */
+       gchar filename[PATH_MAX];                               /**< name of file                                               */
 #else
-       char filename[MAXPATHLEN];                              /**< name of file                                               */
+       gchar filename[MAXPATHLEN];                             /**< name of file                                               */
 #endif
-       int fd;                                                                 /**< descriptor                                                 */
+       gint fd;                                                                        /**< descriptor                                                 */
        void *map;                                                              /**< mmaped area                                                */
        off_t seek_pos;                                                 /**< current seek position                              */
        struct stat_file_section cur_section;   /**< current section                                    */
@@ -87,7 +87,7 @@ typedef struct stat_file_s {
 typedef struct statfile_pool_s {
        stat_file_t *files;                                             /**< hash table of opened files indexed by name */
        void **maps;                                                    /**< shared hash table of mmaped areas indexed by name  */
-       int opened;                                                             /**< number of opened files                             */
+       gint opened;                                                            /**< number of opened files                             */
        size_t max;                                                             /**< maximum size                                               */
        size_t occupied;                                                /**< current size                                               */
        memory_pool_t *pool;                                    /**< memory pool object                                 */
@@ -109,7 +109,7 @@ statfile_pool_t* statfile_pool_new (memory_pool_t *pool, size_t max_size);
  * @param filename name of statfile to open
  * @return 0 if specified statfile is attached and -1 in case of error
  */
-stat_file_t* statfile_pool_open (statfile_pool_t *pool, char *filename, size_t len, gboolean forced);
+stat_file_t* statfile_pool_open (statfile_pool_t *pool, gchar *filename, size_t len, gboolean forced);
 
 /**
  * Create new statfile but DOES NOT attach it to pool, use @see statfile_pool_open for attaching
@@ -118,7 +118,7 @@ stat_file_t* statfile_pool_open (statfile_pool_t *pool, char *filename, size_t l
  * @param len length of new statfile
  * @return 0 if file was created and -1 in case of error
  */
-int statfile_pool_create (statfile_pool_t *pool, char *filename, size_t len);
+gint statfile_pool_create (statfile_pool_t *pool, gchar *filename, size_t len);
 
 /**
  * Close specified statfile
@@ -127,7 +127,7 @@ int statfile_pool_create (statfile_pool_t *pool, char *filename, size_t len);
  * @param remove_hash remove filename from opened files hash also
  * @return 0 if file was closed and -1 if statfile was not opened
  */
-int statfile_pool_close (statfile_pool_t *pool, stat_file_t *file, gboolean keep_sorted);
+gint statfile_pool_close (statfile_pool_t *pool, stat_file_t *file, gboolean keep_sorted);
 
 /**
  * Delete statfile pool and close all attached statfiles
@@ -158,7 +158,7 @@ void statfile_pool_unlock_file (statfile_pool_t *pool, stat_file_t *file);
  * @param now current time
  * @return block value or 0 if block is not found
  */
-double statfile_pool_get_block (statfile_pool_t *pool, stat_file_t *file, uint32_t h1, uint32_t h2, time_t now);
+double statfile_pool_get_block (statfile_pool_t *pool, stat_file_t *file, guint32 h1, guint32 h2, time_t now);
 
 /**
  * Set specified block in statfile
@@ -169,7 +169,7 @@ double statfile_pool_get_block (statfile_pool_t *pool, stat_file_t *file, uint32
  * @param now current time
  * @param value value of block
  */
-void statfile_pool_set_block (statfile_pool_t *pool, stat_file_t *file, uint32_t h1, uint32_t h2, time_t now, double value);
+void statfile_pool_set_block (statfile_pool_t *pool, stat_file_t *file, guint32 h1, guint32 h2, time_t now, double value);
 
 /**
  * Check whether statfile is opened
@@ -177,7 +177,7 @@ void statfile_pool_set_block (statfile_pool_t *pool, stat_file_t *file, uint32_t
  * @param filename name of statfile
  * @return TRUE if specified statfile is opened and FALSE otherwise
  */
-stat_file_t* statfile_pool_is_open (statfile_pool_t *pool, char *filename);
+stat_file_t* statfile_pool_is_open (statfile_pool_t *pool, gchar *filename);
 
 /**
  * Returns current statfile section
@@ -185,7 +185,7 @@ stat_file_t* statfile_pool_is_open (statfile_pool_t *pool, char *filename);
  * @param filename name of statfile
  * @return code of section or 0 if file is not opened
  */
-uint32_t statfile_pool_get_section (statfile_pool_t *pool, stat_file_t *file);
+guint32 statfile_pool_get_section (statfile_pool_t *pool, stat_file_t *file);
 
 /**
  * Go to other section of statfile
@@ -195,7 +195,7 @@ uint32_t statfile_pool_get_section (statfile_pool_t *pool, stat_file_t *file);
  * @param from_begin search for section from begin of file if true
  * @return TRUE if section was set and FALSE otherwise
  */
-gboolean statfile_pool_set_section (statfile_pool_t *pool, stat_file_t *file, uint32_t code, gboolean from_begin);
+gboolean statfile_pool_set_section (statfile_pool_t *pool, stat_file_t *file, guint32 code, gboolean from_begin);
 
 /**
  * Add new section to statfile
@@ -205,7 +205,7 @@ gboolean statfile_pool_set_section (statfile_pool_t *pool, stat_file_t *file, ui
  * @param length length in blocks of new section
  * @return TRUE if section was successfully added and FALSE in case of error
  */
-gboolean statfile_pool_add_section (statfile_pool_t *pool, stat_file_t *file, uint32_t code, uint64_t length);
+gboolean statfile_pool_add_section (statfile_pool_t *pool, stat_file_t *file, guint32 code, guint64 length);
 
 
 /**
@@ -213,7 +213,7 @@ gboolean statfile_pool_add_section (statfile_pool_t *pool, stat_file_t *file, ui
  * @param name name of section
  * @return code of section or 0 if name of section is unknown
  */
-uint32_t statfile_get_section_by_name (const char *name);
+guint32 statfile_get_section_by_name (const gchar *name);
 
 /**
  * Set statfile revision and revision time
@@ -222,7 +222,7 @@ uint32_t statfile_get_section_by_name (const char *name);
  * @param time time of revision
  * @return TRUE if revision was set
  */
-gboolean statfile_set_revision (stat_file_t *file, uint64_t rev, time_t time);
+gboolean statfile_set_revision (stat_file_t *file, guint64 rev, time_t time);
 
 /**
  * Set statfile revision and revision time
@@ -231,21 +231,21 @@ gboolean statfile_set_revision (stat_file_t *file, uint64_t rev, time_t time);
  * @param time saved time of revision
  * @return TRUE if revision was saved in rev and time
  */
-gboolean statfile_get_revision (stat_file_t *file, uint64_t *rev, time_t *time);
+gboolean statfile_get_revision (stat_file_t *file, guint64 *rev, time_t *time);
 
 /**
  * Get statfile used blocks
  * @param file file to get number of used blocks
- * @return number of used blocks or (uint64_t)-1 in case of error
+ * @return number of used blocks or (guint64)-1 in case of error
  */
-uint64_t statfile_get_used_blocks (stat_file_t *file);
+guint64 statfile_get_used_blocks (stat_file_t *file);
 
 /**
  * Get statfile total blocks
  * @param file file to get number of used blocks
- * @return number of used blocks or (uint64_t)-1 in case of error
+ * @return number of used blocks or (guint64)-1 in case of error
  */
-uint64_t statfile_get_total_blocks (stat_file_t *file);
+guint64 statfile_get_total_blocks (stat_file_t *file);
 
 
 /**
index 56328c77b73dd0aadda2fe36b765a99b9fca2b8a..2d2ead525134929bafeb9a154042328ee6e51f13 100644 (file)
@@ -54,22 +54,22 @@ struct rspamd_sync_ctx {
 
        struct timeval interval;
        struct timeval io_tv;
-       int sock;
+       gint                            sock;
        enum rspamd_sync_state state;
        gboolean is_busy;
 
-       uint64_t new_rev;
-       uint64_t new_time;
-       uint64_t new_len;
+       guint64                         new_rev;
+       guint64                         new_time;
+       guint64                         new_len;
 };
 
 static void
-log_next_sync (const char *symbol, time_t delay)
+log_next_sync (const gchar *symbol, time_t delay)
 {
-       char outstr[200];
+       gchar                           outstr[200];
     time_t t;
        struct tm *tmp;
-       int r;
+       gint                            r;
 
        t = time(NULL);
        t += delay;
@@ -86,9 +86,9 @@ log_next_sync (const char *symbol, time_t delay)
 static                          gboolean
 parse_revision_line (struct rspamd_sync_ctx *ctx, f_str_t *in)
 {
-       int i, state = 0;
-       char *p, *c, numbuf[sizeof("18446744073709551615")];
-       uint64_t *val;
+       gint                            i, state = 0;
+       gchar                           *p, *c, numbuf[sizeof("18446744073709551615")];
+       guint64                         *val;
 
        /* First of all try to find END line */
        if (in->len >= sizeof ("END") - 1 && memcmp (in->begin, "END", sizeof ("END") - 1) == 0) {
@@ -150,7 +150,7 @@ static                          gboolean
 read_blocks (struct rspamd_sync_ctx *ctx, f_str_t *in)
 {
        struct rspamd_binlog_element *elt;
-       int                           i;
+       gint                            i;
        
        statfile_pool_lock_file (ctx->pool, ctx->real_statfile);
        elt = (struct rspamd_binlog_element *)in->begin;
@@ -166,8 +166,8 @@ static                          gboolean
 sync_read (f_str_t * in, void *arg)
 {
        struct rspamd_sync_ctx *ctx = arg;
-       char                    buf[256];
-       uint64_t                rev = 0;
+       gchar                           buf[256];
+       guint64                         rev = 0;
        time_t                  ti = 0;
 
        if (in->len == 0) {
@@ -179,14 +179,14 @@ sync_read (f_str_t * in, void *arg)
                        /* Skip greeting line and write sync command */
                        /* Write initial data */
                        statfile_get_revision (ctx->real_statfile, &rev, &ti);
-                       rev = rspamd_snprintf (buf, sizeof (buf), "sync %s %l %l" CRLF, ctx->st->symbol, (long int)rev, (long int)ti);
+                       rev = rspamd_snprintf (buf, sizeof (buf), "sync %s %uL %T" CRLF, ctx->st->symbol, rev, ti);
                        ctx->state = SYNC_STATE_READ_LINE;
                        return rspamd_dispatcher_write (ctx->dispatcher, buf, rev, FALSE, FALSE);       
                        break;
                case SYNC_STATE_READ_LINE:
                        /* Try to parse line from server */
                        if (!parse_revision_line (ctx, in)) {
-                               msg_info ("cannot parse line of length %z: '%*s'", in->len, (int)in->len, in->begin);
+                               msg_info ("cannot parse line of length %z: '%*s'", in->len, (gint)in->len, in->begin);
                                close (ctx->sock);
                                rspamd_remove_dispatcher (ctx->dispatcher);
                                ctx->is_busy = FALSE;
@@ -216,7 +216,7 @@ sync_read (f_str_t * in, void *arg)
                                return FALSE;
                        }
                        statfile_set_revision (ctx->real_statfile, ctx->new_rev, ctx->new_time);
-                       msg_info ("set new revision: %ul, readed %ul bytes", (long unsigned)ctx->new_rev, (long unsigned)in->len);
+                       msg_info ("set new revision: %uL, readed %z bytes", ctx->new_rev, in->len);
                        /* Now try to read other revision or END line */
                        ctx->state = SYNC_STATE_READ_LINE;
                        rspamd_set_dispatcher_policy (ctx->dispatcher, BUFFER_LINE, 0);
@@ -244,7 +244,7 @@ sync_err (GError *err, void *arg)
 
 
 static void
-sync_timer_callback (int fd, short what, void *ud)
+sync_timer_callback (gint fd, short what, void *ud)
 {
        struct rspamd_sync_ctx *ctx = ud;
        
index d615ba74b4faa2e6282c5c662d1c876c73a0ac69..e82e83b87d1ad2ede1ce6dd3d9021fddb8c6b9d6 100644 (file)
 
 #define MIN_CACHE 17
 
-static uint64_t                 total_frequency = 0;
-static uint32_t                 nsymbols = 0;
+static guint64                 total_frequency = 0;
+static guint32                 nsymbols = 0;
 
-int
+gint
 cache_cmp (const void *p1, const void *p2)
 {
        const struct cache_item        *i1 = p1, *i2 = p2;
@@ -53,7 +53,7 @@ cache_cmp (const void *p1, const void *p2)
        return strcmp (i1->s->symbol, i2->s->symbol);
 }
 
-int
+gint
 cache_logic_cmp (const void *p1, const void *p2)
 {
        const struct cache_item        *i1 = p1, *i2 = p2;
@@ -67,7 +67,7 @@ cache_logic_cmp (const void *p1, const void *p2)
        w1 = abs (i1->s->weight) * WEIGHT_MULT + f1 * FREQUENCY_MULT + i1->s->avg_time * TIME_MULT;
        w2 = abs (i2->s->weight) * WEIGHT_MULT + f2 * FREQUENCY_MULT + i2->s->avg_time * TIME_MULT;
 
-       return (int)w2 - w1;
+       return (gint)w2 - w1;
 }
 
 static GChecksum               *
@@ -137,10 +137,10 @@ unmap_cache_file (gpointer arg)
 }
 
 static                          gboolean
-mmap_cache_file (struct symbols_cache *cache, int fd, memory_pool_t *pool)
+mmap_cache_file (struct symbols_cache *cache, gint fd, memory_pool_t *pool)
 {
        guint8                         *map;
-       int                             i;
+       gint                            i;
        GList                          *cur;
        struct cache_item              *item;
 
@@ -177,7 +177,7 @@ mmap_cache_file (struct symbols_cache *cache, int fd, memory_pool_t *pool)
 
 /* Fd must be opened for writing, after creating file is mmapped */
 static                          gboolean
-create_cache_file (struct symbols_cache *cache, const char *filename, int fd, memory_pool_t *pool)
+create_cache_file (struct symbols_cache *cache, const gchar *filename, gint fd, memory_pool_t *pool)
 {
        GChecksum                      *cksum;
        u_char                         *digest;
@@ -244,7 +244,7 @@ create_cache_file (struct symbols_cache *cache, const char *filename, int fd, me
 }
 
 void
-register_symbol (struct symbols_cache **cache, const char *name, double weight, symbol_func_t func, gpointer user_data)
+register_symbol (struct symbols_cache **cache, const gchar *name, double weight, symbol_func_t func, gpointer user_data)
 {
        struct cache_item              *item = NULL;
        struct symbols_cache           *pcache = *cache;
@@ -287,7 +287,7 @@ register_symbol (struct symbols_cache **cache, const char *name, double weight,
 
 void
 register_dynamic_symbol (memory_pool_t *dynamic_pool, struct symbols_cache **cache,
-               const char *name, double weight, symbol_func_t func, 
+               const gchar *name, double weight, symbol_func_t func, 
                gpointer user_data, GList *networks)
 {
        struct cache_item              *item = NULL;
@@ -295,7 +295,7 @@ register_dynamic_symbol (memory_pool_t *dynamic_pool, struct symbols_cache **cac
        GList                          *t, *cur;
        uintptr_t                       r;
        double                         *w;  
-       uint32_t                        mask = 0xFFFFFFFF;
+       guint32                         mask = 0xFFFFFFFF;
        struct dynamic_map_item        *it;
 
        if (*cache == NULL) {
@@ -438,10 +438,10 @@ free_cache (gpointer arg)
 }
 
 gboolean
-init_symbols_cache (memory_pool_t * pool, struct symbols_cache *cache, struct config_file *cfg, const char *filename)
+init_symbols_cache (memory_pool_t * pool, struct symbols_cache *cache, struct config_file *cfg, const gchar *filename)
 {
        struct stat                     st;
-       int                             fd;
+       gint                            fd;
        GChecksum                      *cksum;
        u_char                         *mem_sum, *file_sum;
        gsize                           cklen;
@@ -583,13 +583,13 @@ check_negative_dynamic_item (struct worker_task *task, struct symbols_cache *cac
 }
 
 static gboolean
-check_debug_symbol (struct config_file *cfg, const char *symbol)
+check_debug_symbol (struct config_file *cfg, const gchar *symbol)
 {
        GList                         *cur;
 
        cur = cfg->debug_symbols;
        while (cur) {
-               if (strcmp (symbol, (const char *)cur->data) == 0) {
+               if (strcmp (symbol, (const gchar *)cur->data) == 0) {
                        return TRUE;
                }
                cur = g_list_next (cur);
@@ -617,7 +617,7 @@ call_symbol_callback (struct worker_task * task, struct symbols_cache * cache, g
 #else
        struct timeval                  tv1, tv2;
 #endif
-       uint64_t                        diff;
+       guint64                         diff;
        struct cache_item              *item = NULL;
        struct symbol_callback_data    *s = *save;
 
index 81e6e3bc815efbe4fc0a41463b484ee36e23aa00..8e7ba636fdf7f268a3051803dd71abba11949706 100644 (file)
@@ -12,15 +12,15 @@ struct config_file;
 typedef void (*symbol_func_t)(struct worker_task *task, gpointer user_data);
 
 struct saved_cache_item {
-       char symbol[MAX_SYMBOL];
+       gchar symbol[MAX_SYMBOL];
        double weight;
-       uint32_t frequency;
+       guint32 frequency;
        double avg_time;
 };
 
 struct dynamic_map_item {
        struct in_addr addr;
-       uint32_t mask;
+       guint32 mask;
        gboolean negative;
 };
 
@@ -30,7 +30,7 @@ struct cache_item {
 
        /* For dynamic rules */
        struct dynamic_map_item *networks;
-       uint32_t networks_number;
+       guint32 networks_number;
        gboolean is_dynamic;
        
        /* Callback data */
@@ -66,7 +66,7 @@ struct symbols_cache {
 /**
  * Load symbols cache from file, must be called _after_ init_symbols_cache
  */
-gboolean init_symbols_cache (memory_pool_t *pool, struct symbols_cache *cache, struct config_file *cfg, const char *filename);
+gboolean init_symbols_cache (memory_pool_t *pool, struct symbols_cache *cache, struct config_file *cfg, const gchar *filename);
 
 /**
  * Register function for symbols parsing
@@ -74,7 +74,7 @@ gboolean init_symbols_cache (memory_pool_t *pool, struct symbols_cache *cache, s
  * @param func pointer to handler
  * @param user_data pointer to user_data
  */
-void register_symbol (struct symbols_cache **cache, const char *name, double weight, symbol_func_t func, gpointer user_data);
+void register_symbol (struct symbols_cache **cache, const gchar *name, double weight, symbol_func_t func, gpointer user_data);
 
 /**
  * Register function for dynamic symbols parsing
@@ -82,7 +82,7 @@ void register_symbol (struct symbols_cache **cache, const char *name, double wei
  * @param func pointer to handler
  * @param user_data pointer to user_data
  */
-void register_dynamic_symbol (memory_pool_t *pool, struct symbols_cache **cache, const char *name, 
+void register_dynamic_symbol (memory_pool_t *pool, struct symbols_cache **cache, const gchar *name, 
                                                double weight, symbol_func_t func, 
                                                gpointer user_data, GList *networks);
 
index 945a2aa8ea1742e8a23a5ccca7a88ec28f970002..03f600cdb11737440396cb253f0bd6f95206dfed 100644 (file)
@@ -114,7 +114,7 @@ rspamd_trie_insert (rspamd_trie_t *trie, const gchar *pattern, gint pattern_id)
                c = trie->icase ? g_ascii_tolower (*p) : *p;
                m = check_match (q, c);
                if (m == NULL) {
-                       /* Insert char at specified level depth */
+                       /* Insert gchar at specified level depth */
                        q = rspamd_trie_insert_char (trie, depth, q, c);
                }
                else {
index cf96f4624d7cc2abd581f3fc6d3a02d17fd17c34..115db51377bcf2adaa14d08517ccadad5bc450f7 100644 (file)
@@ -49,7 +49,7 @@ pthread_rwlock_t                upstream_mtx = PTHREAD_RWLOCK_INITIALIZER;
  * Init: 0x0
  */
 
-static const uint32_t           crc32lookup[256] = {
+static const guint32           crc32lookup[256] = {
        0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, 0x706af48fU,
        0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, 0xe0d5e91eU, 0x97d2d988U,
        0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U,
@@ -161,7 +161,7 @@ upstream_ok (struct upstream *up, time_t now)
 void
 revive_all_upstreams (void *ups, size_t members, size_t msize)
 {
-       int                             i;
+       gint                            i;
        struct upstream                *cur;
        u_char                         *p;
 
@@ -182,10 +182,10 @@ revive_all_upstreams (void *ups, size_t members, size_t msize)
  * Scan all upstreams for errors and mark upstreams dead or alive depends on conditions,
  * return number of alive upstreams 
  */
-static int
+static gint
 rescan_upstreams (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
 {
-       int                             i, alive;
+       gint                            i, alive;
        struct upstream                *cur;
        u_char                         *p;
 
@@ -212,9 +212,9 @@ rescan_upstreams (void *ups, size_t members, size_t msize, time_t now, time_t er
 
 /* Return alive upstream by its number */
 static struct upstream         *
-get_upstream_by_number (void *ups, size_t members, size_t msize, int selected)
+get_upstream_by_number (void *ups, size_t members, size_t msize, gint selected)
 {
-       int                             i;
+       gint                            i;
        u_char                         *p, *c;
        struct upstream                *cur;
 
@@ -252,11 +252,11 @@ get_upstream_by_number (void *ups, size_t members, size_t msize, int selected)
 /*
  * Get hash key for specified key (perl hash)
  */
-static                          uint32_t
-get_hash_for_key (uint32_t hash, char *key, size_t keylen)
+static                          guint32
+get_hash_for_key (guint32 hash, gchar *key, size_t keylen)
 {
-       uint32_t                        h, index;
-       const char                     *end = key + keylen;
+       guint32                         h, index;
+       const gchar                     *end = key + keylen;
 
        h = ~hash;
 
@@ -275,7 +275,7 @@ get_hash_for_key (uint32_t hash, char *key, size_t keylen)
 struct upstream                *
 get_random_upstream (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
 {
-       int                             alive, selected;
+       gint                            alive, selected;
 
        alive = rescan_upstreams (ups, members, msize, now, error_timeout, revive_timeout, max_errors);
        selected = rand () % alive;
@@ -287,11 +287,11 @@ get_random_upstream (void *ups, size_t members, size_t msize, time_t now, time_t
  * Return upstream by hash, that is calculated from active upstreams number
  */
 struct upstream                *
-get_upstream_by_hash (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors, char *key, size_t keylen)
+get_upstream_by_hash (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors, gchar *key, size_t keylen)
 {
-       int                             alive, tries = 0, r;
-       uint32_t                        h = 0, ht;
-       char                           *p, numbuf[4];
+       gint                            alive, tries = 0, r;
+       guint32                         h = 0, ht;
+       gchar                           *p, numbuf[4];
        struct upstream                *cur;
 
        alive = rescan_upstreams (ups, members, msize, now, error_timeout, revive_timeout, max_errors);
@@ -307,7 +307,7 @@ get_upstream_by_hash (void *ups, size_t members, size_t msize, time_t now, time_
        h %= members;
 
        for (;;) {
-               p = (char *)ups + msize * h;
+               p = (gchar *)ups + msize * h;
                cur = (struct upstream *)p;
                if (!cur->dead) {
                        break;
@@ -339,7 +339,7 @@ get_upstream_by_hash (void *ups, size_t members, size_t msize, time_t now, time_
 struct upstream                *
 get_upstream_round_robin (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
 {
-       int                             alive, max_weight, i;
+       gint                            alive, max_weight, i;
        struct upstream                *cur, *selected = NULL;
        u_char                         *p;
 
@@ -388,7 +388,7 @@ get_upstream_round_robin (void *ups, size_t members, size_t msize, time_t now, t
 struct upstream                *
 get_upstream_master_slave (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
 {
-       int                             alive, max_weight, i;
+       gint                            alive, max_weight, i;
        struct upstream                *cur, *selected = NULL;
        u_char                         *p;
 
@@ -418,26 +418,26 @@ get_upstream_master_slave (void *ups, size_t members, size_t msize, time_t now,
  * Ketama manipulation functions
  */
 
-static int
+static gint
 ketama_sort_cmp (const void *a1, const void *a2)
 {
-       return *((uint32_t *) a1) - *((uint32_t *) a2);
+       return *((guint32 *) a1) - *((guint32 *) a2);
 }
 
 /*
  * Add ketama points for specified upstream
  */
-int
-upstream_ketama_add (struct upstream *up, char *up_key, size_t keylen, size_t keypoints)
+gint
+upstream_ketama_add (struct upstream *up, gchar *up_key, size_t keylen, size_t keypoints)
 {
-       uint32_t                        h = 0;
-       char                            tmp[4];
-       int                             i;
+       guint32                         h = 0;
+       gchar                           tmp[4];
+       gint                            i;
 
        /* Allocate ketama points array */
        if (up->ketama_points == NULL) {
                up->ketama_points_size = keypoints;
-               up->ketama_points = malloc (sizeof (uint32_t) * up->ketama_points_size);
+               up->ketama_points = malloc (sizeof (guint32) * up->ketama_points_size);
                if (up->ketama_points == NULL) {
                        return -1;
                }
@@ -451,11 +451,11 @@ upstream_ketama_add (struct upstream *up, char *up_key, size_t keylen, size_t ke
                tmp[2] = (i >> 16) & 0xff;
                tmp[3] = (i >> 24) & 0xff;
 
-               h = get_hash_for_key (h, tmp, sizeof (tmp) * sizeof (char));
+               h = get_hash_for_key (h, tmp, sizeof (tmp) * sizeof (gchar));
                up->ketama_points[i] = h;
        }
        /* Keep points sorted */
-       qsort (up->ketama_points, keypoints, sizeof (uint32_t), ketama_sort_cmp);
+       qsort (up->ketama_points, keypoints, sizeof (guint32), ketama_sort_cmp);
 
        return 0;
 }
@@ -464,11 +464,11 @@ upstream_ketama_add (struct upstream *up, char *up_key, size_t keylen, size_t ke
  * Return upstream by hash and find nearest ketama point in some server
  */
 struct upstream                *
-get_upstream_by_hash_ketama (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors, char *key, size_t keylen)
+get_upstream_by_hash_ketama (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors, gchar *key, size_t keylen)
 {
-       int                             alive, i;
-       uint32_t                        h = 0, step, middle, d, min_diff = UINT_MAX;
-       char                           *p;
+       gint                            alive, i;
+       guint32                         h = 0, step, middle, d, min_diff = UINT_MAX;
+       gchar                           *p;
        struct upstream                *cur = NULL, *nearest = NULL;
 
        alive = rescan_upstreams (ups, members, msize, now, error_timeout, revive_timeout, max_errors);
index a6c6b22005d7e172f8ffcdfd67b4e1f24eeaeb01..501071a42f3bb17e2c6ba4c1e131992653de73e1 100644 (file)
@@ -5,19 +5,19 @@
 #include <stdint.h>
 
 struct upstream {
-       unsigned int errors;
+       guint errors;
        time_t time;
-       unsigned char dead;
-       unsigned char priority;
-       int16_t weight;
-       uint32_t *ketama_points;
+       guint dead;
+       guint priority;
+       gint16 weight;
+       guint32 *ketama_points;
        size_t ketama_points_size;
 };
 
 void upstream_fail (struct upstream *up, time_t now);
 void upstream_ok (struct upstream *up, time_t now);
 void revive_all_upstreams (void *ups, size_t members, size_t msize);
-int upstream_ketama_add (struct upstream *up, char *up_key, size_t keylen, size_t keypoints);
+gint upstream_ketama_add (struct upstream *up, gchar *up_key, size_t keylen, size_t keypoints);
 
 struct upstream* get_random_upstream   (void *ups, size_t members, size_t msize, 
                                                                                time_t now, time_t error_timeout, 
@@ -26,7 +26,7 @@ struct upstream* get_random_upstream   (void *ups, size_t members, size_t msize,
 struct upstream* get_upstream_by_hash  (void *ups, size_t members, size_t msize, 
                                                                                time_t now,  time_t error_timeout, 
                                                                                time_t revive_timeout, size_t max_errors,
-                                                                               char *key, size_t keylen);
+                                                                               gchar *key, size_t keylen);
 
 struct upstream* get_upstream_round_robin (void *ups, size_t members, size_t msize, 
                                                                                time_t now, time_t error_timeout, 
@@ -34,7 +34,7 @@ struct upstream* get_upstream_round_robin (void *ups, size_t members, size_t msi
 
 struct upstream* get_upstream_by_hash_ketama (void *ups, size_t members, size_t msize, time_t now, 
                                                                                time_t error_timeout, time_t revive_timeout, size_t max_errors,
-                                                                               char *key, size_t keylen);
+                                                                               gchar *key, size_t keylen);
 
 
 #endif /* UPSTREAM_H */
index 5a166567493aef8183be7c3b1bbe317f84edd562..e32c1df97a62f386cf2d30c5c8044c30a3dd88bf 100644 (file)
--- a/src/url.c
+++ b/src/url.c
     (LOWEST_PORT <= (port) && (port) <= HIGHEST_PORT)
 
 struct _proto {
-       unsigned char                  *name;
-       int                             port;
+       guchar                          *name;
+       gint                            port;
        uintptr_t                      *unused;
-       unsigned int                    need_slashes:1;
-       unsigned int                    need_slash_after_host:1;
-       unsigned int                    free_syntax:1;
-       unsigned int                    need_ssl:1;
+       guint                           need_slashes:1;
+       guint                           need_slash_after_host:1;
+       guint                           free_syntax:1;
+       guint                           need_ssl:1;
 };
 
 typedef struct url_match_s {
@@ -160,7 +160,7 @@ enum {
 #define is_urlsafe(x) ((url_scanner_table[(guchar)(x)] & (IS_ALPHA|IS_DIGIT|IS_URLSAFE)) != 0)
 
 
-static const char              *
+static const gchar              *
 url_strerror (enum uri_errno err)
 {
        switch (err) {
@@ -192,30 +192,30 @@ url_strerror (enum uri_errno err)
        return NULL;
 }
 
-static inline int
-end_of_dir (unsigned char c)
+static inline gint
+end_of_dir (gchar c)
 {
        return c == POST_CHAR || c == '#' || c == ';' || c == '?';
 }
 
-static inline int
-is_uri_dir_sep (struct uri *uri, unsigned char pos)
+static inline gint
+is_uri_dir_sep (struct uri *uri, gchar pos)
 {
        return (pos == '/');
 }
 
-static int
-check_uri_file (unsigned char *name)
+static gint
+check_uri_file (gchar *name)
 {
-       static const unsigned char      chars[] = POST_CHAR_S "#?";
+       static const gchar      chars[] = POST_CHAR_S "#?";
 
        return strcspn (name, chars);
 }
 
-static int
+static gint
 url_init (void)
 {
-       int                             i;
+       gint                            i;
        if (url_scanner == NULL) {
                url_scanner = g_malloc (sizeof (struct url_match_scanner));
                url_scanner->matchers = matchers;
@@ -230,15 +230,15 @@ url_init (void)
 }
 
 enum protocol
-get_protocol (unsigned char *name, int namelen)
+get_protocol (gchar *name, gint namelen)
 {
        /* These are really enum protocol values but can take on negative
         * values and since 0 <= -1 for enum values it's better to use clean
         * integer type. */
-       int                             start, end;
+       gint                            start, end;
        enum protocol                   protocol;
-       unsigned char                  *pname;
-       int                             pnamelen, minlen, compare;
+       guchar                          *pname;
+       gint                            pnamelen, minlen, compare;
 
        /* Almost dichotomic search is used here */
        /* Starting at the HTTP entry which is the most common that will make
@@ -276,34 +276,34 @@ get_protocol (unsigned char *name, int namelen)
 }
 
 
-int
+gint
 get_protocol_port (enum protocol protocol)
 {
        return protocol_backends[protocol].port;
 }
 
-int
+gint
 get_protocol_need_slashes (enum protocol protocol)
 {
        return protocol_backends[protocol].need_slashes;
 }
 
-int
+gint
 get_protocol_need_slash_after_host (enum protocol protocol)
 {
        return protocol_backends[protocol].need_slash_after_host;
 }
 
-int
+gint
 get_protocol_free_syntax (enum protocol protocol)
 {
        return protocol_backends[protocol].free_syntax;
 }
 
-static int
-get_protocol_length (const unsigned char *url)
+static gint
+get_protocol_length (const gchar *url)
 {
-       unsigned char                  *end = (unsigned char *)url;
+       gchar                          *end = (gchar *)url;
 
        /* Seek the end of the protocol name if any. */
        /* RFC1738:
@@ -320,11 +320,11 @@ get_protocol_length (const unsigned char *url)
 /*
  * Calcualte new length of unescaped hostlen
  */
-static unsigned int
-url_calculate_escaped_hostlen (char *host, unsigned int hostlen)
+static guint
+url_calculate_escaped_hostlen (gchar *host, guint hostlen)
 {
-       unsigned int                    i, result = hostlen;
-       char                           *p = host, c;
+       guint                           i, result = hostlen;
+       gchar                           *p = host, c;
 
        for (i = 0; i < hostlen; i++, p++) {
                if (*p == '%' && g_ascii_isxdigit (*(p + 1)) && g_ascii_isxdigit (*(p + 2)) && i < hostlen - 2) {
@@ -348,10 +348,10 @@ url_calculate_escaped_hostlen (char *host, unsigned int hostlen)
    string intact, make a copy before calling this function.  */
 
 static void
-url_unescape (char *s)
+url_unescape (gchar *s)
 {
-       char                           *t = s;  /* t - tortoise */
-       char                           *h = s;  /* h - hare     */
+       gchar                           *t = s; /* t - tortoise */
+       gchar                           *h = s; /* h - hare     */
 
        for (; *h; h++, t++) {
                if (*h != '%') {
@@ -359,7 +359,7 @@ url_unescape (char *s)
                        *t = *h;
                }
                else {
-                       char                            c;
+                       gchar                           c;
                        /* Do nothing if '%' is not followed by two hex digits. */
                        if (!h[1] || !h[2] || !(g_ascii_isxdigit (h[1]) && g_ascii_isxdigit (h[2])))
                                goto copychar;
@@ -376,10 +376,10 @@ url_unescape (char *s)
 }
 
 static void
-url_strip (char *s)
+url_strip (gchar *s)
 {
-       char                           *t = s;  /* t - tortoise */
-       char                           *h = s;  /* h - hare     */
+       gchar                           *t = s; /* t - tortoise */
+       gchar                           *h = s; /* h - hare     */
 
        while (*h) {
                if (g_ascii_isgraph (*h)) {
@@ -391,13 +391,13 @@ url_strip (char *s)
        *t = '\0';
 }
 
-static char                    *
-url_escape_1 (const char *s, int allow_passthrough, memory_pool_t * pool)
+static gchar                    *
+url_escape_1 (const gchar *s, gint allow_passthrough, memory_pool_t * pool)
 {
-       const char                     *p1;
-       char                           *p2, *newstr;
-       int                             newlen;
-       int                             addition = 0;
+       const gchar                     *p1;
+       gchar                           *p2, *newstr;
+       gint                            newlen;
+       gint                            addition = 0;
 
        for (p1 = s; *p1; p1++)
                if (!is_urlsafe (*p1)) {
@@ -406,7 +406,7 @@ url_escape_1 (const char *s, int allow_passthrough, memory_pool_t * pool)
 
        if (!addition) {
                if (allow_passthrough) {
-                       return (char *)s;
+                       return (gchar *)s;
                }
                else {
                        return memory_pool_strdup (pool, s);
@@ -414,14 +414,14 @@ url_escape_1 (const char *s, int allow_passthrough, memory_pool_t * pool)
        }
 
        newlen = (p1 - s) + addition;
-       newstr = (char *)memory_pool_alloc (pool, newlen + 1);
+       newstr = (gchar *)memory_pool_alloc (pool, newlen + 1);
 
        p1 = s;
        p2 = newstr;
        while (*p1) {
                /* Quote the characters that match the test mask. */
                if (!is_urlsafe (*p1)) {
-                       unsigned char                   c = *p1++;
+                       guchar                          c = *p1++;
                        *p2++ = '%';
                        *p2++ = XNUM_TO_DIGIT (c >> 4);
                        *p2++ = XNUM_TO_DIGIT (c & 0xf);
@@ -437,8 +437,8 @@ url_escape_1 (const char *s, int allow_passthrough, memory_pool_t * pool)
 /* URL-escape the unsafe characters (see urlchr_table) in a given
    string, returning a freshly allocated string.  */
 
-char                           *
-url_escape (const char *s, memory_pool_t * pool)
+gchar                           *
+url_escape (const gchar *s, memory_pool_t * pool)
 {
        return url_escape_1 (s, 0, pool);
 }
@@ -446,20 +446,20 @@ url_escape (const char *s, memory_pool_t * pool)
 /* URL-escape the unsafe characters (see urlchr_table) in a given
    string.  If no characters are unsafe, S is returned.  */
 
-static char                    *
-url_escape_allow_passthrough (const char *s, memory_pool_t * pool)
+static gchar                    *
+url_escape_allow_passthrough (const gchar *s, memory_pool_t * pool)
 {
        return url_escape_1 (s, 1, pool);
 }
 
-/* Decide whether the char at position P needs to be encoded.  (It is
-   not enough to pass a single char *P because the function may need
+/* Decide whether the gchar at position P needs to be encoded.  (It is
+   not enough to pass a single gchar *P because the function may need
    to inspect the surrounding context.)
 
-   Return 1 if the char should be escaped as %XX, 0 otherwise.  */
+   Return 1 if the gchar should be escaped as %XX, 0 otherwise.  */
 
-static inline int
-char_needs_escaping (const char *p)
+static inline gint
+char_needs_escaping (const gchar *p)
 {
        if (*p == '%') {
                if (g_ascii_isxdigit (*(p + 1)) && g_ascii_isxdigit (*(p + 2)))
@@ -486,14 +486,14 @@ char_needs_escaping (const char *p)
    further transformations of the result yield the same output.
 */
 
-static char                    *
-reencode_escapes (char *s, memory_pool_t * pool)
+static gchar                    *
+reencode_escapes (gchar *s, memory_pool_t * pool)
 {
-       const char                     *p1;
-       char                           *newstr, *p2;
-       int                             oldlen, newlen;
+       const gchar                     *p1;
+       gchar                           *newstr, *p2;
+       gint                            oldlen, newlen;
 
-       int                             encode_count = 0;
+       gint                            encode_count = 0;
 
        /* First pass: inspect the string to see if there's anything to do,
           and to calculate the new length.  */
@@ -518,7 +518,7 @@ reencode_escapes (char *s, memory_pool_t * pool)
 
        while (*p1)
                if (char_needs_escaping (p1)) {
-                       unsigned char                   c = *p1++;
+                       guchar                          c = *p1++;
                        *p2++ = '%';
                        *p2++ = XNUM_TO_DIGIT (c >> 4);
                        *p2++ = XNUM_TO_DIGIT (c & 0xf);
@@ -536,12 +536,12 @@ reencode_escapes (char *s, memory_pool_t * pool)
    count of unescaped chars.  */
 
 static void
-unescape_single_char (char *str, char chr)
+unescape_single_char (gchar *str, gchar chr)
 {
-       const char                      c1 = XNUM_TO_DIGIT (chr >> 4);
-       const char                      c2 = XNUM_TO_DIGIT (chr & 0xf);
-       char                           *h = str;        /* hare */
-       char                           *t = str;        /* tortoise */
+       const gchar                      c1 = XNUM_TO_DIGIT (chr >> 4);
+       const gchar                      c2 = XNUM_TO_DIGIT (chr & 0xf);
+       gchar                           *h = str;       /* hare */
+       gchar                           *t = str;       /* tortoise */
 
        for (; *h; h++, t++) {
                if (h[0] == '%' && h[1] == c1 && h[2] == c2) {
@@ -558,12 +558,12 @@ unescape_single_char (char *str, char chr)
 /* Escape unsafe and reserved characters, except for the slash
         characters.  */
 
-static char                    *
-url_escape_dir (const char *dir, memory_pool_t * pool)
+static gchar                    *
+url_escape_dir (const gchar *dir, memory_pool_t * pool)
 {
-       char                           *newdir = url_escape_1 (dir, 1, pool);
+       gchar                           *newdir = url_escape_1 (dir, 1, pool);
        if (newdir == dir)
-               return (char *)dir;
+               return (gchar *)dir;
 
        unescape_single_char (newdir, '/');
        return newdir;
@@ -583,13 +583,13 @@ url_escape_dir (const char *dir, memory_pool_t * pool)
    function, run test_path_simplify to make sure you haven't broken a
    test case.  */
 
-static int
-path_simplify (char *path)
+static gint
+path_simplify (gchar *path)
 {
-       char                           *h = path;       /* hare */
-       char                           *t = path;       /* tortoise */
-       char                           *beg = path;     /* boundary for backing the tortoise */
-       char                           *end = path + strlen (path);
+       gchar                           *h = path;      /* hare */
+       gchar                           *t = path;      /* tortoise */
+       gchar                           *beg = path;    /* boundary for backing the tortoise */
+       gchar                           *end = path + strlen (path);
 
        while (h < end) {
                /* Hare should be at the beginning of a path element. */
@@ -643,12 +643,12 @@ path_simplify (char *path)
 }
 
 enum uri_errno
-parse_uri (struct uri *uri, unsigned char *uristring, memory_pool_t * pool)
+parse_uri (struct uri *uri, gchar *uristring, memory_pool_t * pool)
 {
-       unsigned char                  *prefix_end, *host_end, *p;
-       unsigned char                  *lbracket, *rbracket;
-       int                             datalen, n, addrlen;
-       unsigned char                  *frag_or_post, *user_end, *port_end;
+       guchar                          *prefix_end, *host_end, *p;
+       guchar                          *lbracket, *rbracket;
+       gint                            datalen, n, addrlen;
+       guchar                          *frag_or_post, *user_end, *port_end;
 
        memset (uri, 0, sizeof (*uri));
 
@@ -915,7 +915,7 @@ url_file_end (const gchar *begin, const gchar *end, const gchar *pos, url_match_
 {
        const gchar                    *p;
        gchar                           stop;
-       int                             i;
+       gint                            i;
 
        p = pos + strlen (match->pattern);
        if (*p == '/') {
@@ -961,7 +961,7 @@ url_web_end (const gchar *begin, const gchar *end, const gchar *pos, url_match_t
 {
        const gchar                    *p, *c;
        gchar                           open_brace = '\0', close_brace = '\0';
-       int                             i, brace_stack;
+       gint                            i, brace_stack;
        gboolean                        passwd;
        guint                           port;
 
@@ -1148,8 +1148,8 @@ void
 url_parse_text (memory_pool_t * pool, struct worker_task *task, struct mime_text_part *part, gboolean is_html)
 {
        struct url_matcher             *matcher;
-       int                             rc, idx;
-       char                           *url_str = NULL;
+       gint                            rc, idx;
+       gchar                           *url_str = NULL;
        struct uri                     *new;
        const guint8                   *p, *end, *pos;
        url_match_t                     m;
index c5ff469904203d9eb75204e9ff06120fb1d449a3..de7e8fe851cbef3ffa9e5b8c4c16384df6074deb 100644 (file)
--- a/src/url.h
+++ b/src/url.h
@@ -10,39 +10,39 @@ struct mime_text_part;
 
 struct uri {
        /* The start of the uri (and thus start of the protocol string). */
-       unsigned char *string;
+       gchar *string;
 
        /* The internal type of protocol. Can _never_ be PROTOCOL_UNKNOWN. */
-       int protocol; /* enum protocol */
+       gint protocol; /* enum protocol */
 
-       int ip_family;
+       gint ip_family;
 
-       unsigned char *user;
-       unsigned char *password;
-       unsigned char *host;
-       unsigned char *port;
+       gchar *user;
+       gchar *password;
+       gchar *host;
+       gchar *port;
        /* @data can contain both the path and query uri fields.
         * It can never be NULL but can have zero length. */
-       unsigned char *data;
-       unsigned char *fragment;
+       gchar *data;
+       gchar *fragment;
        /* @post can contain some special encoded form data, used internally
         * to make form data handling more efficient. The data is marked by
         * POST_CHAR in the uri string. */
-       unsigned char *post;
+       gchar *post;
 
        /* @protocollen should only be usable if @protocol is either
         * PROTOCOL_USER or an uri string should be composed. */
-       unsigned int protocollen;
-       unsigned int userlen;
-       unsigned int passwordlen;
-       unsigned int hostlen;
-       unsigned int portlen;
-       unsigned int datalen;
-       unsigned int fragmentlen;
+       guint protocollen;
+       guint userlen;
+       guint passwordlen;
+       guint hostlen;
+       guint portlen;
+       guint datalen;
+       guint fragmentlen;
 
        /* Flags */
-       unsigned int ipv6;      /* URI contains IPv6 host */
-       unsigned int form;      /* URI originated from form */
+       guint ipv6;     /* URI contains IPv6 host */
+       guint form;     /* URI originated from form */
 };
 
 enum uri_errno {
@@ -72,6 +72,6 @@ enum protocol {
 #define struri(uri) ((uri)->string)
 
 void url_parse_text (memory_pool_t *pool, struct worker_task *task, struct mime_text_part *part, gboolean is_html);
-enum uri_errno parse_uri(struct uri *uri, unsigned char *uristring, memory_pool_t *pool);
+enum uri_errno parse_uri(struct uri *uri, gchar *uristring, memory_pool_t *pool);
 
 #endif
index dc8569cdf75cf7f655a3d956f89695ac09871182..8c640bc6800992c7b3ddcd40584093fa24e35ce9 100644 (file)
 extern rspamd_hash_t           *counters;
 #endif
 
-static u_char* rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero, unsigned int hexadecimal, unsigned int width);
+static gchar* rspamd_sprintf_num (gchar *buf, gchar *last, guint64 ui64, gchar zero, guint hexadecimal, guint width);
 
-int
-make_socket_nonblocking (int fd)
+gint
+make_socket_nonblocking (gint fd)
 {
-       int                             ofl;
+       gint                            ofl;
 
        ofl = fcntl (fd, F_GETFL, 0);
 
@@ -56,10 +56,10 @@ make_socket_nonblocking (int fd)
        return 0;
 }
 
-int
-make_socket_blocking (int fd)
+gint
+make_socket_blocking (gint fd)
 {
-       int                             ofl;
+       gint                            ofl;
 
        ofl = fcntl (fd, F_GETFL, 0);
 
@@ -70,10 +70,10 @@ make_socket_blocking (int fd)
        return 0;
 }
 
-int
-poll_sync_socket (int fd, int timeout, short events)
+gint
+poll_sync_socket (gint fd, gint timeout, short events)
 {
-       int                             r;
+       gint                            r;
        struct pollfd                   fds[1];
 
        fds->fd = fd;
@@ -88,11 +88,11 @@ poll_sync_socket (int fd, int timeout, short events)
        return r;
 }
 
-static int
-make_inet_socket (int family, struct in_addr *addr, u_short port, gboolean is_server, gboolean async)
+static gint
+make_inet_socket (gint family, struct in_addr *addr, u_short port, gboolean is_server, gboolean async)
 {
-       int                             fd, r, optlen, on = 1, s_error;
-       int                             serrno;
+       gint                            fd, r, optlen, on = 1, s_error;
+       gint                            serrno;
        struct sockaddr_in              sin;
 
        /* Create socket */
@@ -120,7 +120,7 @@ make_inet_socket (int family, struct in_addr *addr, u_short port, gboolean is_se
        sin.sin_addr.s_addr = addr->s_addr;
 
        if (is_server) {
-               setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof (int));
+               setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof (gint));
                r = bind (fd, (struct sockaddr *)&sin, sizeof (struct sockaddr_in));
        }
        else {
@@ -167,23 +167,23 @@ make_inet_socket (int family, struct in_addr *addr, u_short port, gboolean is_se
        return (-1);
 }
 
-int
+gint
 make_tcp_socket (struct in_addr *addr, u_short port, gboolean is_server, gboolean async)
 {
        return make_inet_socket (SOCK_STREAM, addr, port, is_server, async);
 }
 
-int
+gint
 make_udp_socket (struct in_addr *addr, u_short port, gboolean is_server, gboolean async)
 {
        return make_inet_socket (SOCK_DGRAM, addr, port, is_server, async);
 }
 
-int
-accept_from_socket (int listen_sock, struct sockaddr *addr, socklen_t * len)
+gint
+accept_from_socket (gint listen_sock, struct sockaddr *addr, socklen_t * len)
 {
-       int                             nfd;
-       int                             serrno;
+       gint                            nfd;
+       gint                            serrno;
 
        if ((nfd = accept (listen_sock, addr, len)) == -1) {
                if (errno == EAGAIN) {
@@ -214,10 +214,10 @@ accept_from_socket (int listen_sock, struct sockaddr *addr, socklen_t * len)
 
 }
 
-int
-make_unix_socket (const char *path, struct sockaddr_un *addr, gboolean is_server)
+gint
+make_unix_socket (const gchar *path, struct sockaddr_un *addr, gboolean is_server)
 {
-       int                             fd, s_error, r, optlen, serrno, on = 1;
+       gint                            fd, s_error, r, optlen, serrno, on = 1;
 
        if (path == NULL)
                return -1;
@@ -246,7 +246,7 @@ make_unix_socket (const char *path, struct sockaddr_un *addr, gboolean is_server
                goto out;
        }
        if (is_server) {
-               setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof (int));
+               setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (const void *)&on, sizeof (gint));
                r = bind (fd, (struct sockaddr *)addr, SUN_LEN (addr));
        }
        else {
@@ -279,7 +279,7 @@ make_unix_socket (const char *path, struct sockaddr_un *addr, gboolean is_server
        return (-1);
 }
 
-int
+gint
 write_pid (struct rspamd_main *main)
 {
        pid_t                           pid;
@@ -300,7 +300,7 @@ write_pid (struct rspamd_main *main)
 
 #ifdef HAVE_SA_SIGINFO
 void
-init_signals (struct sigaction *signals, void (*sig_handler)(int, siginfo_t *, void *))
+init_signals (struct sigaction *signals, void (*sig_handler)(gint, siginfo_t *, void *))
 #else
 void
 init_signals (struct sigaction *signals, sighandler_t sig_handler)
@@ -348,19 +348,19 @@ static void
 pass_signal_cb (gpointer key, gpointer value, gpointer ud)
 {
        struct rspamd_worker           *cur = value;
-    int                             signo = GPOINTER_TO_INT (ud);
+    gint                            signo = GPOINTER_TO_INT (ud);
 
        kill (cur->pid, signo);
 }
 
 void
-pass_signal_worker (GHashTable * workers, int signo)
+pass_signal_worker (GHashTable * workers, gint signo)
 {
     g_hash_table_foreach (workers, pass_signal_cb, GINT_TO_POINTER (signo));
 }
 
 void
-convert_to_lowercase (char *str, unsigned int size)
+convert_to_lowercase (gchar *str, guint size)
 {
        while (size--) {
                *str = g_ascii_tolower (*str);
@@ -370,12 +370,12 @@ convert_to_lowercase (char *str, unsigned int size)
 
 #ifndef HAVE_SETPROCTITLE
 
-static char                    *title_buffer = 0;
+static gchar                    *title_buffer = 0;
 static size_t                   title_buffer_size = 0;
-static char                    *title_progname, *title_progname_full;
+static gchar                    *title_progname, *title_progname_full;
 
-int
-setproctitle (const char *fmt, ...)
+gint
+setproctitle (const gchar *fmt, ...)
 {
        if (!title_buffer || !title_buffer_size) {
                errno = ENOMEM;
@@ -417,15 +417,15 @@ setproctitle (const char *fmt, ...)
   functions gets called without arguments.
 */
 
-int
-init_title (int argc, char *argv[], char *envp[])
+gint
+init_title (gint argc, gchar *argv[], gchar *envp[])
 {
 #if defined(DARWIN) || defined(SOLARIS)
        /* XXX: try to handle these OSes too */
        return 0;
 #else
-       char                           *begin_of_buffer = 0, *end_of_buffer = 0;
-       int                             i;
+       gchar                           *begin_of_buffer = 0, *end_of_buffer = 0;
+       gint                            i;
 
        for (i = 0; i < argc; ++i) {
                if (!begin_of_buffer)
@@ -444,7 +444,7 @@ init_title (int argc, char *argv[], char *envp[])
        if (!end_of_buffer)
                return 0;
 
-       char                          **new_environ = g_malloc ((i + 1) * sizeof (envp[0]));
+       gchar                           **new_environ = g_malloc ((i + 1) * sizeof (envp[0]));
 
        if (!new_environ)
                return 0;
@@ -461,7 +461,7 @@ init_title (int argc, char *argv[], char *envp[])
                if (!title_progname_full)
                        goto cleanup_enomem;
 
-               char                           *p = strrchr (title_progname_full, '/');
+               gchar                           *p = strrchr (title_progname_full, '/');
 
                if (p)
                        title_progname = p + 1;
@@ -489,10 +489,10 @@ init_title (int argc, char *argv[], char *envp[])
 #endif
 
 #ifndef HAVE_PIDFILE
-extern char                    *__progname;
-static int                      _pidfile_remove (struct pidfh *pfh, int freeit);
+extern gchar                    *__progname;
+static gint                      _pidfile_remove (struct pidfh *pfh, gint freeit);
 
-static int
+static gint
 pidfile_verify (struct pidfh *pfh)
 {
        struct stat                     sb;
@@ -509,11 +509,11 @@ pidfile_verify (struct pidfh *pfh)
        return 0;
 }
 
-static int
-pidfile_read (const char *path, pid_t * pidptr)
+static gint
+pidfile_read (const gchar *path, pid_t * pidptr)
 {
-       char                            buf[16], *endptr;
-       int                             error, fd, i;
+       gchar                           buf[16], *endptr;
+       gint                            error, fd, i;
 
        fd = open (path, O_RDONLY);
        if (fd == -1)
@@ -536,11 +536,11 @@ pidfile_read (const char *path, pid_t * pidptr)
 }
 
 struct pidfh                   *
-pidfile_open (const char *path, mode_t mode, pid_t * pidptr)
+pidfile_open (const gchar *path, mode_t mode, pid_t * pidptr)
 {
        struct pidfh                   *pfh;
        struct stat                     sb;
-       int                             error, fd, len, count;
+       gint                            error, fd, len, count;
        struct timespec                 rqtp;
 
        pfh = g_malloc (sizeof (*pfh));
@@ -551,7 +551,7 @@ pidfile_open (const char *path, mode_t mode, pid_t * pidptr)
                len = snprintf (pfh->pf_path, sizeof (pfh->pf_path), "/var/run/%s.pid", g_get_prgname ());
        else
                len = snprintf (pfh->pf_path, sizeof (pfh->pf_path), "%s", path);
-       if (len >= (int)sizeof (pfh->pf_path)) {
+       if (len >= (gint)sizeof (pfh->pf_path)) {
                g_free (pfh);
                errno = ENAMETOOLONG;
                return NULL;
@@ -604,11 +604,11 @@ pidfile_open (const char *path, mode_t mode, pid_t * pidptr)
        return pfh;
 }
 
-int
+gint
 pidfile_write (struct pidfh *pfh)
 {
-       char                            pidstr[16];
-       int                             error, fd;
+       gchar                           pidstr[16];
+       gint                            error, fd;
 
        /*
         * Check remembered descriptor, so we don't overwrite some other
@@ -633,7 +633,7 @@ pidfile_write (struct pidfh *pfh)
                return -1;
        }
 
-       snprintf (pidstr, sizeof (pidstr), "%lu", (long unsigned)getpid ());
+       rspamd_snprintf (pidstr, sizeof (pidstr), "%P", getpid ());
        if (pwrite (fd, pidstr, strlen (pidstr), 0) != (ssize_t) strlen (pidstr)) {
                error = errno;
                _pidfile_remove (pfh, 0);
@@ -644,10 +644,10 @@ pidfile_write (struct pidfh *pfh)
        return 0;
 }
 
-int
+gint
 pidfile_close (struct pidfh *pfh)
 {
-       int                             error;
+       gint                            error;
 
        error = pidfile_verify (pfh);
        if (error != 0) {
@@ -665,10 +665,10 @@ pidfile_close (struct pidfh *pfh)
        return 0;
 }
 
-static int
-_pidfile_remove (struct pidfh *pfh, int freeit)
+static gint
+_pidfile_remove (struct pidfh *pfh, gint freeit)
 {
-       int                             error;
+       gint                            error;
 
        error = pidfile_verify (pfh);
        if (error != 0) {
@@ -697,7 +697,7 @@ _pidfile_remove (struct pidfh *pfh, int freeit)
        return 0;
 }
 
-int
+gint
 pidfile_remove (struct pidfh *pfh)
 {
 
@@ -706,12 +706,12 @@ pidfile_remove (struct pidfh *pfh)
 #endif
 
 /* Replace %r with rcpt value and %f with from value, new string is allocated in pool */
-char                           *
-resolve_stat_filename (memory_pool_t * pool, char *pattern, char *rcpt, char *from)
+gchar                           *
+resolve_stat_filename (memory_pool_t * pool, gchar *pattern, gchar *rcpt, gchar *from)
 {
-       int                             need_to_format = 0, len = 0;
-       int                             rcptlen, fromlen;
-       char                           *c = pattern, *new, *s;
+       gint                            need_to_format = 0, len = 0;
+       gint                            rcptlen, fromlen;
+       gchar                           *c = pattern, *new, *s;
 
        if (rcpt) {
                rcptlen = strlen (rcpt);
@@ -777,16 +777,16 @@ resolve_stat_filename (memory_pool_t * pool, char *pattern, char *rcpt, char *fr
 }
 
 #ifdef HAVE_CLOCK_GETTIME
-const char                     *
-calculate_check_time (struct timeval *tv, struct timespec *begin, int resolution)
+const gchar                     *
+calculate_check_time (struct timeval *tv, struct timespec *begin, gint resolution)
 #else
-const char                     *
-calculate_check_time (struct timeval *begin, int resolution)
+const gchar                     *
+calculate_check_time (struct timeval *begin, gint resolution)
 #endif
 {
        double                          vdiff, diff;
-       static char                     res[64];
-       static char                     fmt[sizeof ("%.10f ms real, %.10f ms virtual")];
+       static gchar                     res[64];
+       static gchar                     fmt[sizeof ("%.10f ms real, %.10f ms virtual")];
        struct timeval                  tv_now;
        if (gettimeofday (&tv_now, NULL) == -1) {
                msg_warn ("gettimeofday failed: %s", strerror (errno));
@@ -816,16 +816,16 @@ calculate_check_time (struct timeval *begin, int resolution)
        sprintf (fmt, "%%.%dfms real, %%.%dfms virtual", resolution, resolution);
        snprintf (res, sizeof (res), fmt, diff, vdiff);
 
-       return (const char *)res;
+       return (const gchar *)res;
 }
 
 double
-set_counter (const char *name, long int value)
+set_counter (const gchar *name, guint32 value)
 {
 #ifdef RSPAMD_MAIN
        struct counter_data            *cd;
        double                          alpha;
-       char                           *key;
+       gchar                           *key;
 
        cd = rspamd_hash_lookup (counters, (gpointer) name);
 
@@ -859,7 +859,7 @@ set_counter (const char *name, long int value)
 gboolean
 rspamd_strcase_equal (gconstpointer v, gconstpointer v2)
 {
-       if (g_ascii_strcasecmp ((const char *)v, (const char *)v2) == 0) {
+       if (g_ascii_strcasecmp ((const gchar *)v, (const gchar *)v2) == 0) {
                return TRUE;
        }
 
@@ -870,7 +870,7 @@ rspamd_strcase_equal (gconstpointer v, gconstpointer v2)
 guint
 rspamd_strcase_hash (gconstpointer key)
 {
-       const char                     *p = key;
+       const gchar                     *p = key;
        guint                           h = 0;
 
        while (*p != '\0') {
@@ -897,7 +897,7 @@ guint
 fstr_strcase_hash (gconstpointer key)
 {
        const f_str_t                  *f = key;
-       const char                     *p;
+       const gchar                     *p;
        guint                           h = 0;
        
        p = f->begin;
@@ -910,10 +910,10 @@ fstr_strcase_hash (gconstpointer key)
 }
 
 void
-gperf_profiler_init (struct config_file *cfg, const char *descr)
+gperf_profiler_init (struct config_file *cfg, const gchar *descr)
 {
 #if defined(WITH_GPERF_TOOLS) && defined(RSPAMD_MAIN)
-       char                            prof_path[PATH_MAX];
+       gchar                           prof_path[PATH_MAX];
 
        if (getenv ("CPUPROFILE")) {
 
@@ -925,7 +925,7 @@ gperf_profiler_init (struct config_file *cfg, const char *descr)
                cfg->profile_path = g_strdup_printf ("%s/rspamd-profile", cfg->temp_dir);
        }
 
-       snprintf (prof_path, sizeof (prof_path), "%s-%s.%d", cfg->profile_path, descr, (int)getpid ());
+       snprintf (prof_path, sizeof (prof_path), "%s-%s.%d", cfg->profile_path, descr, (gint)getpid ());
        if (ProfilerStart (prof_path)) {
                /* start ITIMER_PROF timer */
                ProfilerRegisterThread ();
@@ -940,9 +940,9 @@ gperf_profiler_init (struct config_file *cfg, const char *descr)
 #ifdef HAVE_FLOCK
 /* Flock version */
 gboolean 
-lock_file (int fd, gboolean async)
+lock_file (gint fd, gboolean async)
 {
-    int flags;
+    gint                            flags;
 
     if (async) {
         flags = LOCK_EX | LOCK_NB;
@@ -963,9 +963,9 @@ lock_file (int fd, gboolean async)
 }
 
 gboolean 
-unlock_file (int fd, gboolean async)
+unlock_file (gint fd, gboolean async)
 {
-    int flags;
+    gint                            flags;
 
     if (async) {
         flags = LOCK_UN | LOCK_NB;
@@ -988,7 +988,7 @@ unlock_file (int fd, gboolean async)
 #else /* HAVE_FLOCK */
 /* Fctnl version */
 gboolean 
-lock_file (int fd, gboolean async)
+lock_file (gint fd, gboolean async)
 {
     struct flock fl = {
         .l_type = F_WRLCK,
@@ -1009,7 +1009,7 @@ lock_file (int fd, gboolean async)
 }
 
 gboolean 
-unlock_file (int fd, gboolean async)
+unlock_file (gint fd, gboolean async)
 {
     struct flock fl = {
         .l_type = F_UNLCK,
@@ -1034,7 +1034,7 @@ unlock_file (int fd, gboolean async)
 #ifdef RSPAMD_MAIN
 stat_file_t *
 get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf, 
-        const char *symbol, struct statfile **st, gboolean try_create)
+        const gchar *symbol, struct statfile **st, gboolean try_create)
 {
     stat_file_t *res = NULL;
     GList *cur;
@@ -1078,38 +1078,28 @@ get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf,
 }
 #endif /* RSPAMD_MAIN */
 
-/*
- * supported formats:
- *     %[0][width][x][X]O              off_t
- *     %[0][width]T                      time_t
- *     %[0][width][u][x|X]z      ssize_t/size_t
- *     %[0][width][u][x|X]d      int/u_int
- *     %[0][width][u][x|X]l      long
- *     %[0][width|m][u][x|X]i    int/ngx_int_t
- *     %[0][width][u][x|X]D      int32_t/uint32_t
- *     %[0][width][u][x|X]L      int64_t/uint64_t
- *     %[0][width][.width]f      double
- *     %[0][width][.width]F      long double
- *     %[0][width][.width]g      double
- *     %[0][width][.width]G      long double
- *     %P                                              pid_t
- *     %r                                              rlim_t
- *     %p                                              void *
- *     %V                                              f_str_t *
- *     %s                                              null-terminated string
- *     %*s                                        length and string
- *     %Z                                              '\0'
- *     %N                                              '\n'
- *     %c                                              char
- *     %%                                              %
- *
- */
 
+gint
+rspamd_fprintf (FILE *f, const gchar *fmt, ...)
+{
+       gchar   *p;
+       va_list   args;
+    gchar buf[BUFSIZ];
+    gint r;
+
+       va_start (args, fmt);
+       p = rspamd_vsnprintf (buf, sizeof (buf), fmt, args);
+       va_end (args);
+
+    r = fprintf (f, "%s", buf);
+
+    return r;
+}
 
-int
-rspamd_sprintf (u_char *buf, const char *fmt, ...)
+gint
+rspamd_sprintf (gchar *buf, const gchar *fmt, ...)
 {
-       u_char   *p;
+       gchar   *p;
        va_list   args;
 
        va_start (args, fmt);
@@ -1120,10 +1110,10 @@ rspamd_sprintf (u_char *buf, const char *fmt, ...)
 }
 
 
-int
-rspamd_snprintf (u_char *buf, size_t max, const char *fmt, ...)
+gint
+rspamd_snprintf (gchar *buf, size_t max, const gchar *fmt, ...)
 {
-       u_char   *p;
+       gchar   *p;
        va_list   args;
 
        va_start (args, fmt);
@@ -1135,16 +1125,16 @@ rspamd_snprintf (u_char *buf, size_t max, const char *fmt, ...)
 }
 
 
-u_char *
-rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
+gchar *
+rspamd_vsnprintf (gchar *buf, size_t max, const gchar *fmt, va_list args)
 {
-       u_char             *p, zero, *last;
-       int                 d;
+       gchar             *p, zero, *last;
+       gint                            d;
        long double         f, scale;
        size_t              len, slen;
-       int64_t                         i64;
-       uint64_t                        ui64;
-       unsigned int        width, sign, hex, max_width, frac_width, i;
+       gint64                          i64;
+       guint64                         ui64;
+       guint                           width, sign, hex, max_width, frac_width, i;
        f_str_t                    *v;
 
        if (max == 0) {
@@ -1165,7 +1155,7 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                        i64 = 0;
                        ui64 = 0;
 
-                       zero = (u_char) ((*++fmt == '0') ? '0' : ' ');
+                       zero = (gchar) ((*++fmt == '0') ? '0' : ' ');
                        width = 0;
                        sign = 1;
                        hex = 0;
@@ -1212,7 +1202,7 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                        break;
 
                                case '*':
-                                       d = (int)va_arg (args, int);
+                                       d = (gint)va_arg (args, gint);
                                        if (G_UNLIKELY (d < 0)) {
                                                msg_err ("crititcal error: size is less than 0");
                                                g_assert (0);
@@ -1237,13 +1227,13 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                len = v->len;
                                len = (buf + len < last) ? len : (size_t) (last - buf);
 
-                               buf = ((u_char *)memcpy (buf, v->begin, len)) + len;
+                               buf = ((gchar *)memcpy (buf, v->begin, len)) + len;
                                fmt++;
 
                                continue;
 
                        case 's':
-                               p = va_arg(args, u_char *);
+                               p = va_arg(args, gchar *);
                                if (p == NULL) {
                                        p = "(NULL)";
                                }
@@ -1256,7 +1246,7 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                } else {
                                        len = (buf + slen < last) ? slen : (size_t) (last - buf);
 
-                                       buf = ((u_char *)memcpy (buf, p, len)) + len;
+                                       buf = ((gchar *)memcpy (buf, p, len)) + len;
                                }
 
                                fmt++;
@@ -1264,57 +1254,57 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                continue;
 
                        case 'O':
-                               i64 = (int64_t) va_arg (args, off_t);
+                               i64 = (gint64) va_arg (args, off_t);
                                sign = 1;
                                break;
 
                        case 'P':
-                               i64 = (int64_t) va_arg (args, pid_t);
+                               i64 = (gint64) va_arg (args, pid_t);
                                sign = 1;
                                break;
 
                        case 'T':
-                               i64 = (int64_t) va_arg (args, time_t);
+                               i64 = (gint64) va_arg (args, time_t);
                                sign = 1;
                                break;
 
                        case 'z':
                                if (sign) {
-                                       i64 = (int64_t) va_arg (args, ssize_t);
+                                       i64 = (gint64) va_arg (args, ssize_t);
                                } else {
-                                       ui64 = (uint64_t) va_arg (args, size_t);
+                                       ui64 = (guint64) va_arg (args, size_t);
                                }
                                break;
 
                        case 'd':
                                if (sign) {
-                                       i64 = (int64_t) va_arg (args, int);
+                                       i64 = (gint64) va_arg (args, gint);
                                } else {
-                                       ui64 = (uint64_t) va_arg (args, unsigned int);
+                                       ui64 = (guint64) va_arg (args, guint);
                                }
                                break;
 
                        case 'l':
                                if (sign) {
-                                       i64 = (int64_t) va_arg(args, long);
+                                       i64 = (gint64) va_arg(args, long);
                                } else {
-                                       ui64 = (uint64_t) va_arg(args, unsigned long);
+                                       ui64 = (guint64) va_arg(args, guint32);
                                }
                                break;
 
                        case 'D':
                                if (sign) {
-                                       i64 = (int64_t) va_arg(args, int32_t);
+                                       i64 = (gint64) va_arg(args, gint32);
                                } else {
-                                       ui64 = (uint64_t) va_arg(args, uint32_t);
+                                       ui64 = (guint64) va_arg(args, guint32);
                                }
                                break;
 
                        case 'L':
                                if (sign) {
-                                       i64 = va_arg (args, int64_t);
+                                       i64 = va_arg (args, gint64);
                                } else {
-                                       ui64 = va_arg (args, uint64_t);
+                                       ui64 = va_arg (args, guint64);
                                }
                                break;
 
@@ -1326,7 +1316,7 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                        f = -f;
                                }
                                
-                               ui64 = (int64_t) f;
+                               ui64 = (gint64) f;
 
                                buf = rspamd_sprintf_num (buf, last, ui64, zero, 0, width);
 
@@ -1343,10 +1333,10 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                        }
 
                                        /*
-                                       * (int64_t) cast is required for msvc6:
-                                       * it can not convert uint64_t to double
+                                       * (gint64) cast is required for msvc6:
+                                       * it can not convert guint64 to double
                                        */
-                                       ui64 = (uint64_t) ((f - (int64_t) ui64) * scale);
+                                       ui64 = (guint64) ((f - (gint64) ui64) * scale);
 
                                        buf = rspamd_sprintf_num (buf, last, ui64, '0', 0, frac_width);
                                }
@@ -1363,7 +1353,7 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                        f = -f;
                                }
 
-                               ui64 = (int64_t) f;
+                               ui64 = (gint64) f;
 
                                buf = rspamd_sprintf_num (buf, last, ui64, zero, 0, width);
 
@@ -1380,10 +1370,10 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                        }
 
                                        /*
-                                       * (int64_t) cast is required for msvc6:
-                                       * it can not convert uint64_t to double
+                                       * (gint64) cast is required for msvc6:
+                                       * it can not convert guint64 to double
                                        */
-                                       ui64 = (uint64_t) ((f - (int64_t) ui64) * scale);
+                                       ui64 = (guint64) ((f - (gint64) ui64) * scale);
 
                                        buf = rspamd_sprintf_num (buf, last, ui64, '0', 0, frac_width);
                                }
@@ -1427,8 +1417,8 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                                break;
 
                        case 'c':
-                               d = va_arg (args, int);
-                               *buf++ = (u_char) (d & 0xff);
+                               d = va_arg (args, gint);
+                               *buf++ = (gchar) (d & 0xff);
                                fmt++;
 
                                continue;
@@ -1460,10 +1450,10 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
                        if (sign) {
                                if (i64 < 0) {
                                        *buf++ = '-';
-                                       ui64 = (uint64_t) -i64;
+                                       ui64 = (guint64) -i64;
 
                                } else {
-                                       ui64 = (uint64_t) i64;
+                                       ui64 = (guint64) i64;
                                }
                        }
 
@@ -1480,15 +1470,15 @@ rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args)
 }
 
 
-static u_char *
-rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero,
-       unsigned int hexadecimal, unsigned int width)
+static gchar *
+rspamd_sprintf_num (gchar *buf, gchar *last, guint64 ui64, gchar zero,
+       guint                           hexadecimal, guint width)
 {
-       u_char             *p, temp[sizeof ("18446744073709551615")];
+       gchar              *p, temp[sizeof ("18446744073709551615")];
        size_t              len;
-       uint32_t                ui32;
-       static u_char   hex[] = "0123456789abcdef";
-       static u_char   HEX[] = "0123456789ABCDEF";
+       guint32                         ui32;
+       static gchar   hex[] = "0123456789abcdef";
+       static gchar   HEX[] = "0123456789ABCDEF";
 
        p = temp + sizeof(temp);
 
@@ -1506,20 +1496,20 @@ rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero,
                         *
                         * For 32-bit numbers and some divisors gcc and icc use
                         * a inlined multiplication and shifts.  For example,
-                        * unsigned "i32 / 10" is compiled to
+                        * guint "i32 / 10" is compiled to
                         *
                         *       (i32 * 0xCCCCCCCD) >> 35
                         */
 
-                       ui32 = (uint32_t) ui64;
+                       ui32 = (guint32) ui64;
 
                        do {
-                               *--p = (u_char) (ui32 % 10 + '0');
+                               *--p = (gchar) (ui32 % 10 + '0');
                        } while (ui32 /= 10);
 
                } else {
                        do {
-                               *--p = (u_char) (ui64 % 10 + '0');
+                               *--p = (gchar) (ui64 % 10 + '0');
                        } while (ui64 /= 10);
                }
 
@@ -1527,8 +1517,8 @@ rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero,
 
                do {
 
-                       /* the "(uint32_t)" cast disables the BCC's warning */
-                       *--p = hex[(uint32_t) (ui64 & 0xf)];
+                       /* the "(guint32)" cast disables the BCC's warning */
+                       *--p = hex[(guint32) (ui64 & 0xf)];
 
                } while (ui64 >>= 4);
 
@@ -1536,8 +1526,8 @@ rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero,
 
                do {
 
-                       /* the "(uint32_t)" cast disables the BCC's warning */
-                       *--p = HEX[(uint32_t) (ui64 & 0xf)];
+                       /* the "(guint32)" cast disables the BCC's warning */
+                       *--p = HEX[(guint32) (ui64 & 0xf)];
 
                } while (ui64 >>= 4);
        }
@@ -1558,7 +1548,7 @@ rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero,
                len = last - buf;
        }
 
-       return ((u_char *)memcpy (buf, p, len)) + len;
+       return ((gchar *)memcpy (buf, p, len)) + len;
 }
 
 
index b3e9338abe196848cdeff7f14ddecfeee19f7780..403d3447ec2ec551aa746b41475572e11ef2e8aa 100644 (file)
@@ -13,82 +13,108 @@ struct statfile;
 struct classifier_config;
 
 /* Create socket and bind or connect it to specified address and port */
-int make_tcp_socket (struct in_addr *, u_short, gboolean is_server, gboolean async);
+gint make_tcp_socket (struct in_addr *, u_short, gboolean is_server, gboolean async);
 /* Create socket and bind or connect it to specified address and port */
-int make_udp_socket (struct in_addr *, u_short, gboolean is_server, gboolean async);
+gint make_udp_socket (struct in_addr *, u_short, gboolean is_server, gboolean async);
 /* Accept from socket */
-int accept_from_socket (int listen_sock, struct sockaddr *addr, socklen_t *len);
+gint accept_from_socket (gint listen_sock, struct sockaddr *addr, socklen_t *len);
 /* Create and bind or connect unix socket */
-int make_unix_socket (const char *, struct sockaddr_un *, gboolean is_server);
+gint make_unix_socket (const gchar *, struct sockaddr_un *, gboolean is_server);
 /* Write pid to file */
-int write_pid (struct rspamd_main *);
+gint write_pid (struct rspamd_main *);
 /* Make specified socket non-blocking */
-int make_socket_nonblocking (int);
-int make_socket_blocking (int);
+gint make_socket_nonblocking (gint);
+gint make_socket_blocking (gint);
 /* Poll sync socket for specified events */
-int poll_sync_socket (int fd, int timeout, short events);
+gint poll_sync_socket (gint fd, gint timeout, short events);
 /* Init signals */
 #ifdef HAVE_SA_SIGINFO
-void init_signals (struct sigaction *sa, void (*sig_handler)(int, siginfo_t *, void *));
+void init_signals (struct sigaction *sa, void (*sig_handler)(gint, siginfo_t *, void *));
 #else
 void init_signals (struct sigaction *sa, sighandler_t);
 #endif
 /* Send specified signal to each worker */
-void pass_signal_worker (GHashTable *, int );
+void pass_signal_worker (GHashTable *, gint );
 /* Convert string to lowercase */
-void convert_to_lowercase (char *str, unsigned int size);
+void convert_to_lowercase (gchar *str, guint size);
 
 #ifndef HAVE_SETPROCTITLE
-int init_title(int argc, char *argv[], char *envp[]);
-int setproctitle(const char *fmt, ...);
+gint init_title(gint argc, gchar *argv[], gchar *envp[]);
+gint setproctitle(const gchar *fmt, ...);
 #endif
 
 #ifndef HAVE_PIDFILE
 struct pidfh {
-       int pf_fd;
+       gint pf_fd;
 #ifdef HAVE_PATH_MAX
-       char    pf_path[PATH_MAX + 1];
+       gchar    pf_path[PATH_MAX + 1];
 #elif defined(HAVE_MAXPATHLEN)
-       char    pf_path[MAXPATHLEN + 1];
+       gchar    pf_path[MAXPATHLEN + 1];
 #else
-       char    pf_path[1024 + 1];
+       gchar    pf_path[1024 + 1];
 #endif
        dev_t pf_dev;
        ino_t   pf_ino;
 };
-struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr);
-int pidfile_write(struct pidfh *pfh);
-int pidfile_close(struct pidfh *pfh);
-int pidfile_remove(struct pidfh *pfh);
+struct pidfh *pidfile_open(const gchar *path, mode_t mode, pid_t *pidptr);
+gint pidfile_write(struct pidfh *pfh);
+gint pidfile_close(struct pidfh *pfh);
+gint pidfile_remove(struct pidfh *pfh);
 #endif
 
 /* Replace %r with rcpt value and %f with from value, new string is allocated in pool */
-char* resolve_stat_filename (memory_pool_t *pool, char *pattern, char *rcpt, char *from);
+gchar* resolve_stat_filename (memory_pool_t *pool, gchar *pattern, gchar *rcpt, gchar *from);
 #ifdef HAVE_CLOCK_GETTIME
-const char* calculate_check_time (struct timeval *tv, struct timespec *begin, int resolution);
+const gchar* calculate_check_time (struct timeval *tv, struct timespec *begin, gint resolution);
 #else
-const char* calculate_check_time (struct timeval *begin, int resolution);
+const gchar* calculate_check_time (struct timeval *begin, gint resolution);
 #endif
 
-double set_counter (const char *name, long int value);
+double set_counter (const gchar *name, guint32 value);
 
-gboolean lock_file (int fd, gboolean async);
-gboolean unlock_file (int fd, gboolean async);
+gboolean lock_file (gint fd, gboolean async);
+gboolean unlock_file (gint fd, gboolean async);
 
 guint rspamd_strcase_hash (gconstpointer key);
 gboolean rspamd_strcase_equal (gconstpointer v, gconstpointer v2);
 guint fstr_strcase_hash (gconstpointer key);
 gboolean fstr_strcase_equal (gconstpointer v, gconstpointer v2);
 
-void gperf_profiler_init (struct config_file *cfg, const char *descr);
+void gperf_profiler_init (struct config_file *cfg, const gchar *descr);
 
 #ifdef RSPAMD_MAIN
 stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf, 
-               const char *symbol, struct statfile **st, gboolean try_create);
+               const gchar *symbol, struct statfile **st, gboolean try_create);
 #endif
 
-int rspamd_sprintf (u_char *buf, const char *fmt, ...);
-int rspamd_snprintf (u_char *buf, size_t max, const char *fmt, ...);
-u_char *rspamd_vsnprintf (u_char *buf, size_t max, const char *fmt, va_list args);
+/*
+ * supported formats:
+ *     %[0][width][x][X]O                  off_t
+ *     %[0][width]T                        time_t
+ *     %[0][width][u][x|X]z        ssize_t/size_t
+ *     %[0][width][u][x|X]d        gint/guint
+ *     %[0][width][u][x|X]l        long
+ *     %[0][width][u][x|X]D        gint32/guint32
+ *     %[0][width][u][x|X]L        gint64/guint64
+ *     %[0][width][.width]f        double
+ *     %[0][width][.width]F        long double
+ *     %[0][width][.width]g        double
+ *     %[0][width][.width]G        long double
+ *     %P                                                  pid_t
+ *     %r                                          rlim_t
+ *     %p                                                  void *
+ *     %V                                                  f_str_t *
+ *     %s                                                  null-terminated string
+ *     %*s                                             length and string
+ *     %Z                                                  '\0'
+ *     %N                                                  '\n'
+ *     %c                                                  gchar
+ *     %%                                                  %
+ *
+ */
+gint rspamd_sprintf (gchar *buf, const gchar *fmt, ...);
+gint rspamd_fprintf (FILE *f, const gchar *fmt, ...);
+gint rspamd_snprintf (gchar *buf, size_t max, const gchar *fmt, ...);
+gchar *rspamd_vsnprintf (gchar *buf, size_t max, const gchar *fmt, va_list args);
 
 #endif
index ebfc06dc06e8ab625f457f2bbc46479965366986..3477b35ef00d3d523eb0649620fd149269032452 100644 (file)
@@ -50,7 +50,7 @@ init_view (memory_pool_t * pool)
 }
 
 gboolean
-add_view_from (struct rspamd_view * view, char *line)
+add_view_from (struct rspamd_view * view, gchar *line)
 {
        struct rspamd_regexp           *re = NULL;
 
@@ -66,7 +66,7 @@ add_view_from (struct rspamd_view * view, char *line)
 }
 
 gboolean
-add_view_rcpt (struct rspamd_view * view, char *line)
+add_view_rcpt (struct rspamd_view * view, gchar *line)
 {
        struct rspamd_regexp           *re = NULL;
 
@@ -82,7 +82,7 @@ add_view_rcpt (struct rspamd_view * view, char *line)
 }
 
 gboolean
-add_view_symbols (struct rspamd_view * view, char *line)
+add_view_symbols (struct rspamd_view * view, gchar *line)
 {
        struct rspamd_regexp           *re = NULL;
        GList                          *symbols;
@@ -98,7 +98,7 @@ add_view_symbols (struct rspamd_view * view, char *line)
                /* Try to parse symbols line as comma separated list */
                symbols = parse_comma_list (view->pool, line);
                while (symbols) {
-                       g_hash_table_insert (view->symbols_hash, (char *)symbols->data, symbols->data);
+                       g_hash_table_insert (view->symbols_hash, (gchar *)symbols->data, symbols->data);
                        /* Symbols list would be free at pool destruction */
                        symbols = g_list_next (symbols);
                }
@@ -109,7 +109,7 @@ add_view_symbols (struct rspamd_view * view, char *line)
 }
 
 gboolean
-add_view_ip (struct rspamd_view * view, char *line)
+add_view_ip (struct rspamd_view * view, gchar *line)
 {
        if (add_map (line, read_radix_list, fin_radix_list, (void **)&view->ip_tree)) {
                return TRUE;
@@ -119,7 +119,7 @@ add_view_ip (struct rspamd_view * view, char *line)
 }
 
 gboolean
-add_view_client_ip (struct rspamd_view * view, char *line)
+add_view_client_ip (struct rspamd_view * view, gchar *line)
 {
        if (add_map (line, read_radix_list, fin_radix_list, (void **)&view->client_ip_tree)) {
                return TRUE;
@@ -211,14 +211,14 @@ G_INLINE_FUNC gboolean
 check_view_rcpt (struct rspamd_view *v, struct worker_task *task)
 {
        GList                          *cur, *cur_re;
-       char                            rcpt_user[256], *p;
+       gchar                           rcpt_user[256], *p;
        gint                            l;
        struct rspamd_regexp           *re;
 
        cur = task->rcpt;
        while (cur) {
                if ((p = strchr (cur->data, '@')) != NULL) {
-                       l = MIN (sizeof (rcpt_user) - 1, p - (char *)cur->data);
+                       l = MIN (sizeof (rcpt_user) - 1, p - (gchar *)cur->data);
                        memcpy (rcpt_user, cur->data, l);
                        rcpt_user[l] = '\0';
                        /* First try to lookup in hashtable */
@@ -279,7 +279,7 @@ find_view_by_rcpt (GList * views, struct worker_task *task)
 }
 
 static                          gboolean
-match_view_symbol (struct rspamd_view *v, const char *symbol)
+match_view_symbol (struct rspamd_view *v, const gchar *symbol)
 {
        GList                          *cur;
        struct rspamd_regexp           *re;
@@ -307,7 +307,7 @@ match_view_symbol (struct rspamd_view *v, const char *symbol)
 }
 
 gboolean
-check_view (GList * views, const char *symbol, struct worker_task * task)
+check_view (GList * views, const gchar *symbol, struct worker_task * task)
 {
        struct rspamd_view             *selected = NULL;
 
index 0b3412c85278ad79155cc3a344670ac114c300ab..0c7e7a433bcf2359cdacd4ad3db409c84df74f6e 100644 (file)
@@ -24,13 +24,13 @@ struct rspamd_view {
 
 struct rspamd_view* init_view (memory_pool_t *pool);
 
-gboolean add_view_from (struct rspamd_view *view, char *line);
-gboolean add_view_rcpt (struct rspamd_view *view, char *line);
-gboolean add_view_ip (struct rspamd_view *view, char *line);
-gboolean add_view_client_ip (struct rspamd_view *view, char *line);
-gboolean add_view_symbols (struct rspamd_view *view, char *line);
+gboolean add_view_from (struct rspamd_view *view, gchar *line);
+gboolean add_view_rcpt (struct rspamd_view *view, gchar *line);
+gboolean add_view_ip (struct rspamd_view *view, gchar *line);
+gboolean add_view_client_ip (struct rspamd_view *view, gchar *line);
+gboolean add_view_symbols (struct rspamd_view *view, gchar *line);
 
-gboolean check_view (GList *views, const char *symbol, struct worker_task *task);
+gboolean check_view (GList *views, const gchar *symbol, struct worker_task *task);
 gboolean check_skip (GList *views, struct worker_task *task);
 
 #endif
index aa8e40cc041a3f48725af45a4c2c2a47730cf8a7..80c7dc48c8bc2ffb42ad5ed8cd0fcc3a6a5f950d 100644 (file)
@@ -41,8 +41,8 @@
 #include "lua/lua_common.h"
 
 #ifndef WITHOUT_PERL
-#   include <EXTERN.h>                 /* from the Perl distribution     */
-#   include <perl.h>                   /* from the Perl distribution   */
+#   include <EXTERN.h>         /* from the Perl distribution     */
+#   include <perl.h>           /* from the Perl distribution   */
 
 extern PerlInterpreter         *perl_interpreter;
 #endif
@@ -59,14 +59,15 @@ extern PerlInterpreter         *perl_interpreter;
 #define MODULE_AFTER_CONNECT_FUNC "after_connect"
 #define MODULE_PARSE_LINE_FUNC "parse_line"
 
-struct custom_filter {
-       char *filename;                                 /*< filename           */
-       GModule *handle;                                /*< returned by dlopen */
-       void (*init_func)(struct config_file *cfg);             /*< called at start of worker */
-       void* (*before_connect)(void);  /*< called when clients connects */
-       gboolean (*process_line)(const char *line, size_t len, char **output, void *user_data); /*< called when client send data line */
-       void (*after_connect)(char **output, char **log_line, void *user_data); /*< called when client disconnects */
-       void (*fin_func)(void); 
+struct custom_filter
+{
+  gchar                          *filename;    /*< filename           */
+  GModule                        *handle;      /*< returned by dlopen */
+  void                            (*init_func) (struct config_file * cfg);     /*< called at start of worker */
+  void                           *(*before_connect) (void);    /*< called when clients connects */
+                                  gboolean (*process_line) (const gchar * line, size_t len, gchar ** output, void *user_data); /*< called when client send data line */
+  void                            (*after_connect) (gchar ** output, gchar ** log_line, void *user_data);      /*< called when client disconnects */
+  void                            (*fin_func) (void);
 };
 
 #endif
@@ -74,70 +75,74 @@ struct custom_filter {
 /*
  * Worker's context
  */
-struct rspamd_worker_ctx {
-       struct timeval io_tv;
-       /* Detect whether this worker is mime worker */
-       gboolean is_mime;
-       /* Detect whether this worker is mime worker */
-       gboolean is_custom;
-       GList *custom_filters;
-       /* DNS resolver */
-       struct rspamd_dns_resolver *resolver;
+struct rspamd_worker_ctx
+{
+  struct timeval                  io_tv;
+  /* Detect whether this worker is mime worker */
+  gboolean                        is_mime;
+  /* Detect whether this worker is mime worker */
+  gboolean                        is_custom;
+  GList                          *custom_filters;
+  /* DNS resolver */
+  struct rspamd_dns_resolver     *resolver;
 };
 
 static gboolean                 write_socket (void *arg);
 
-static sig_atomic_t                    wanna_die = 0;
+static sig_atomic_t             wanna_die = 0;
 
 #ifndef HAVE_SA_SIGINFO
 static void
-sig_handler (int signo)
+sig_handler (gint signo)
 #else
 static void
-sig_handler (int signo, siginfo_t *info, void *unused)
+sig_handler (gint signo, siginfo_t * info, void *unused)
 #endif
 {
-       struct timeval                  tv;
-
-       switch (signo) {
-       case SIGUSR1:
-               reopen_log ();
-               break;
-       case SIGINT:
-       case SIGTERM:
-               if (!wanna_die) {
-                       wanna_die = 1;
-                       tv.tv_sec = 0;
-                       tv.tv_usec = 0;
-                       event_loopexit (&tv);
+  struct timeval                  tv;
+
+  switch (signo)
+    {
+    case SIGUSR1:
+      reopen_log ();
+      break;
+    case SIGINT:
+    case SIGTERM:
+      if (!wanna_die)
+       {
+         wanna_die = 1;
+         tv.tv_sec = 0;
+         tv.tv_usec = 0;
+         event_loopexit (&tv);
 
 #ifdef WITH_GPERF_TOOLS
-                       ProfilerStop ();
+         ProfilerStop ();
 #endif
-               }
-               break;
        }
+      break;
+    }
 }
 
 /*
  * Config reload is designed by sending sigusr to active workers and pending shutdown of them
  */
 static void
-sigusr_handler (int fd, short what, void *arg)
+sigusr_handler (gint fd, short what, void *arg)
 {
-       struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
-       /* Do not accept new connections, preparing to end worker's process */
-       struct timeval                  tv;
-       if (! wanna_die) {
-               tv.tv_sec = SOFT_SHUTDOWN_TIME;
-               tv.tv_usec = 0;
-               event_del (&worker->sig_ev);
-               event_del (&worker->bind_ev);
-               do_reopen_log = 1;
-               msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
-               event_loopexit (&tv);
-       }
-       return;
+  struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+  /* Do not accept new connections, preparing to end worker's process */
+  struct timeval                  tv;
+  if (!wanna_die)
+    {
+      tv.tv_sec = SOFT_SHUTDOWN_TIME;
+      tv.tv_usec = 0;
+      event_del (&worker->sig_ev);
+      event_del (&worker->bind_ev);
+      do_reopen_log = 1;
+      msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
+      event_loopexit (&tv);
+    }
+  return;
 }
 
 /*
@@ -146,79 +151,94 @@ sigusr_handler (int fd, short what, void *arg)
 static void
 rcpt_destruct (void *pointer)
 {
-       struct worker_task             *task = (struct worker_task *)pointer;
+  struct worker_task             *task = (struct worker_task *) pointer;
 
-       if (task->rcpt) {
-               g_list_free (task->rcpt);
-       }
+  if (task->rcpt)
+    {
+      g_list_free (task->rcpt);
+    }
 }
 
-#ifndef BUILD_STATIC   
+#ifndef BUILD_STATIC
 static void
 fin_custom_filters (struct worker_task *task)
 {
-       GList                          *cur, *curd;
-       struct custom_filter           *filt;
-       char                           *output = NULL, *log = NULL;
-       struct rspamd_worker_ctx       *ctx = task->worker->ctx;
-
-       cur = ctx->custom_filters;
-       curd = task->rcpt;
-       while (cur) {
-               filt = cur->data;
-               if (filt->after_connect) {
-                       filt->after_connect (&output, &log, curd->data);
-                       if (output != NULL) {
-                               if (! rspamd_dispatcher_write (task->dispatcher, output, strlen (output), FALSE, FALSE)) {
-                                       g_free (output);
-                                       return;
-                               }
-                               g_free (output);
-                       }
-                       if (log != NULL) {
-                               msg_info ("%s", log);
-                               g_free (log);
-                       }
-                       if (curd->next) {
-                               curd = g_list_next (curd);
-                       }
+  GList                          *cur, *curd;
+  struct custom_filter           *filt;
+  gchar                          *output = NULL, *log = NULL;
+  struct rspamd_worker_ctx       *ctx = task->worker->ctx;
+
+  cur = ctx->custom_filters;
+  curd = task->rcpt;
+  while (cur)
+    {
+      filt = cur->data;
+      if (filt->after_connect)
+       {
+         filt->after_connect (&output, &log, curd->data);
+         if (output != NULL)
+           {
+             if (!rspamd_dispatcher_write
+                 (task->dispatcher, output, strlen (output), FALSE, FALSE))
+               {
+                 g_free (output);
+                 return;
                }
-               cur = g_list_next (cur);
+             g_free (output);
+           }
+         if (log != NULL)
+           {
+             msg_info ("%s", log);
+             g_free (log);
+           }
+         if (curd->next)
+           {
+             curd = g_list_next (curd);
+           }
        }
+      cur = g_list_next (cur);
+    }
 }
 
-static gboolean
-parse_line_custom (struct worker_task *task, f_str_t *in)
+static                          gboolean
+parse_line_custom (struct worker_task *task, f_str_t * in)
 {
-       GList                          *cur, *curd;
-       struct custom_filter           *filt;
-       char                           *output = NULL;
-       gboolean                        res = TRUE;
-       struct rspamd_worker_ctx       *ctx = task->worker->ctx;
-
-       cur = ctx->custom_filters;
-       curd = task->rcpt;
-       while (cur) {
-               filt = cur->data;
-               if (filt->after_connect) {
-                       if (! filt->process_line (in->begin, in->len, &output, curd->data)) {
-                               res = FALSE;
-                       }
-                       if (output != NULL) {
-                               if (! rspamd_dispatcher_write (task->dispatcher, output, strlen (output), FALSE, FALSE)) {
-                                       g_free (output);
-                                       return FALSE;
-                               }
-                               g_free (output);
-                       }
-                       if (curd->next) {
-                               curd = g_list_next (curd);
-                       }
+  GList                          *cur, *curd;
+  struct custom_filter           *filt;
+  gchar                          *output = NULL;
+  gboolean                        res = TRUE;
+  struct rspamd_worker_ctx       *ctx = task->worker->ctx;
+
+  cur = ctx->custom_filters;
+  curd = task->rcpt;
+  while (cur)
+    {
+      filt = cur->data;
+      if (filt->after_connect)
+       {
+         if (!filt->process_line (in->begin, in->len, &output, curd->data))
+           {
+             res = FALSE;
+           }
+         if (output != NULL)
+           {
+             if (!rspamd_dispatcher_write
+                 (task->dispatcher, output, strlen (output), FALSE, FALSE))
+               {
+                 g_free (output);
+                 return FALSE;
                }
-               cur = g_list_next (cur);
+             g_free (output);
+           }
+         if (curd->next)
+           {
+             curd = g_list_next (curd);
+           }
        }
+      cur = g_list_next (cur);
+    }
 
-       return res;
+  return res;
 }
 #else
 /* Stubs */
@@ -227,10 +247,11 @@ fin_custom_filters (struct worker_task *task)
 {
 
 }
-static gboolean
-parse_line_custom (struct worker_task *task, f_str_t *in)
+
+static                          gboolean
+parse_line_custom (struct worker_task *task, f_str_t * in)
 {
-       return FALSE;
+  return FALSE;
 }
 #endif
 
@@ -240,60 +261,70 @@ parse_line_custom (struct worker_task *task, f_str_t *in)
 void
 free_task (struct worker_task *task, gboolean is_soft)
 {
-       GList                          *part;
-       struct mime_part               *p;
-
-       if (task) {
-               debug_task ("free pointer %p", task);
-               while ((part = g_list_first (task->parts))) {
-                       task->parts = g_list_remove_link (task->parts, part);
-                       p = (struct mime_part *)part->data;
-                       g_byte_array_free (p->content, TRUE);
-                       g_list_free_1 (part);
-               }
-               if (task->text_parts) {
-                       g_list_free (task->text_parts);
-               }
-               if (task->urls) {
-                       g_list_free (task->urls);
-               }
-               if (task->images) {
-                       g_list_free (task->images);
-               }
-               if (task->messages) {
-                       g_list_free (task->messages);
-               }
-               memory_pool_delete (task->task_pool);
-               if (task->dispatcher) {
-                       if (is_soft) {
-                               /* Plan dispatcher shutdown */
-                               task->dispatcher->wanna_die = 1;
-                       }
-                       else {
-                               rspamd_remove_dispatcher (task->dispatcher);
-                       }
-               }
-               if (task->sock != -1) {
-                       close (task->sock);
-               }
-               g_free (task);
+  GList                          *part;
+  struct mime_part               *p;
+
+  if (task)
+    {
+      debug_task ("free pointer %p", task);
+      while ((part = g_list_first (task->parts)))
+       {
+         task->parts = g_list_remove_link (task->parts, part);
+         p = (struct mime_part *) part->data;
+         g_byte_array_free (p->content, TRUE);
+         g_list_free_1 (part);
+       }
+      if (task->text_parts)
+       {
+         g_list_free (task->text_parts);
+       }
+      if (task->urls)
+       {
+         g_list_free (task->urls);
+       }
+      if (task->images)
+       {
+         g_list_free (task->images);
+       }
+      if (task->messages)
+       {
+         g_list_free (task->messages);
+       }
+      memory_pool_delete (task->task_pool);
+      if (task->dispatcher)
+       {
+         if (is_soft)
+           {
+             /* Plan dispatcher shutdown */
+             task->dispatcher->wanna_die = 1;
+           }
+         else
+           {
+             rspamd_remove_dispatcher (task->dispatcher);
+           }
+       }
+      if (task->sock != -1)
+       {
+         close (task->sock);
        }
+      g_free (task);
+    }
 }
 
 void
 free_task_hard (gpointer ud)
 {
-       struct worker_task             *task = ud;
+  struct worker_task             *task = ud;
 
-       free_task (task, FALSE);
+  free_task (task, FALSE);
 }
 
 void
 free_task_soft (gpointer ud)
 {
-       struct worker_task             *task = ud;
+  struct worker_task             *task = ud;
 
-       free_task (task, FALSE);
+  free_task (task, FALSE);
 }
 
 /*
@@ -302,78 +333,89 @@ free_task_soft (gpointer ud)
 static                          gboolean
 read_socket (f_str_t * in, void *arg)
 {
-       struct worker_task             *task = (struct worker_task *)arg;
-       struct rspamd_worker_ctx       *ctx;
-       ssize_t                         r;
-
-       ctx = task->worker->ctx;
-       switch (task->state) {
-       case READ_COMMAND:
-       case READ_HEADER:
-               if (ctx->is_custom) {
-                       if (! parse_line_custom (task, in)) {
-                               task->last_error = "Read error";
-                               task->error_code = RSPAMD_NETWORK_ERROR;
-                               task->state = WRITE_ERROR;
-                       }       
-               }
-               else {
-                       if (read_rspamd_input_line (task, in) != 0) {
-                               task->last_error = "Read error";
-                               task->error_code = RSPAMD_NETWORK_ERROR;
-                               task->state = WRITE_ERROR;
-                       }
-               }
-               if (task->state == WRITE_REPLY || task->state == WRITE_ERROR) {
-                       return write_socket (task);
-               }
-               break;
-       case READ_MESSAGE:
-               task->msg = memory_pool_alloc (task->task_pool, sizeof (f_str_t));
-               task->msg->begin = in->begin;
-               task->msg->len = in->len;
-               debug_task ("got string of length %ld", (long int)task->msg->len);
-               r = process_message (task);
-               if (r == -1) {
-                       msg_warn ("processing of message failed");
-                       task->last_error = "MIME processing error";
-                       task->error_code = RSPAMD_FILTER_ERROR;
-                       task->state = WRITE_ERROR;
-                       return write_socket (task);
-               }
-               if (task->cmd == CMD_OTHER) {
-                       /* Skip filters */
-                       task->state = WRITE_REPLY;
-                       return write_socket (task);
-               }
-               r = process_filters (task);
-               if (r == -1) {
-                       task->last_error = "Filter processing error";
-                       task->error_code = RSPAMD_FILTER_ERROR;
-                       task->state = WRITE_ERROR;
-                       return write_socket (task);
-               }
-               else if (r == 0) {
-                       task->state = WAIT_FILTER;
-                       rspamd_dispatcher_pause (task->dispatcher);
-               }
-               else {
-                       process_statfiles (task);
-                       lua_call_post_filters (task);
-                       task->state = WRITE_REPLY;
-                       return write_socket (task);
-               }
-               break;
-       case WRITE_REPLY:
-       case WRITE_ERROR:
-               return write_socket (task);
-               break;
-       default:
-               debug_task ("invalid state on reading stage");
-               break;
+  struct worker_task             *task = (struct worker_task *) arg;
+  struct rspamd_worker_ctx       *ctx;
+  ssize_t                         r;
+
+  ctx = task->worker->ctx;
+  switch (task->state)
+    {
+    case READ_COMMAND:
+    case READ_HEADER:
+      if (ctx->is_custom)
+       {
+         if (!parse_line_custom (task, in))
+           {
+             task->last_error = "Read error";
+             task->error_code = RSPAMD_NETWORK_ERROR;
+             task->state = WRITE_ERROR;
+           }
        }
-
-       return TRUE;
+      else
+       {
+         if (read_rspamd_input_line (task, in) != 0)
+           {
+             task->last_error = "Read error";
+             task->error_code = RSPAMD_NETWORK_ERROR;
+             task->state = WRITE_ERROR;
+           }
+       }
+      if (task->state == WRITE_REPLY || task->state == WRITE_ERROR)
+       {
+         return write_socket (task);
+       }
+      break;
+    case READ_MESSAGE:
+      task->msg = memory_pool_alloc (task->task_pool, sizeof (f_str_t));
+      task->msg->begin = in->begin;
+      task->msg->len = in->len;
+      debug_task ("got string of length %z", task->msg->len);
+      r = process_message (task);
+      if (r == -1)
+       {
+         msg_warn ("processing of message failed");
+         task->last_error = "MIME processing error";
+         task->error_code = RSPAMD_FILTER_ERROR;
+         task->state = WRITE_ERROR;
+         return write_socket (task);
+       }
+      if (task->cmd == CMD_OTHER)
+       {
+         /* Skip filters */
+         task->state = WRITE_REPLY;
+         return write_socket (task);
+       }
+      r = process_filters (task);
+      if (r == -1)
+       {
+         task->last_error = "Filter processing error";
+         task->error_code = RSPAMD_FILTER_ERROR;
+         task->state = WRITE_ERROR;
+         return write_socket (task);
+       }
+      else if (r == 0)
+       {
+         task->state = WAIT_FILTER;
+         rspamd_dispatcher_pause (task->dispatcher);
+       }
+      else
+       {
+         process_statfiles (task);
+         lua_call_post_filters (task);
+         task->state = WRITE_REPLY;
+         return write_socket (task);
+       }
+      break;
+    case WRITE_REPLY:
+    case WRITE_ERROR:
+      return write_socket (task);
+      break;
+    default:
+      debug_task ("invalid state on reading stage");
+      break;
+    }
+
+  return TRUE;
 }
 
 /*
@@ -382,51 +424,58 @@ read_socket (f_str_t * in, void *arg)
 static                          gboolean
 write_socket (void *arg)
 {
-       struct worker_task             *task = (struct worker_task *)arg;
-       struct rspamd_worker_ctx       *ctx;
-
-       ctx = task->worker->ctx;
-
-       switch (task->state) {
-       case WRITE_REPLY:
-               if (! write_reply (task)) {
-                       destroy_session (task->s);
-                       return FALSE;
-               }
-               if (ctx->is_custom) {
-                       fin_custom_filters (task);
-               }
-               destroy_session (task->s);
-               return FALSE;
-               break;
-       case WRITE_ERROR:
-               if (! write_reply (task)) {
-                       return FALSE;
-               }
-               if (ctx->is_custom) {
-                       fin_custom_filters (task);
-               }
-               destroy_session (task->s);
-               return FALSE;
-               break;
-       case CLOSING_CONNECTION:
-               debug_task ("normally closing connection");
-               if (ctx->is_custom) {
-                       fin_custom_filters (task);
-               }
-               destroy_session (task->s);
-               return FALSE;
-               break;
-       default:
-               msg_info ("abnormally closing connection");
-               if (ctx->is_custom) {
-                       fin_custom_filters (task);
-               }
-               destroy_session (task->s);
-               return FALSE;
-               break;
+  struct worker_task             *task = (struct worker_task *) arg;
+  struct rspamd_worker_ctx       *ctx;
+
+  ctx = task->worker->ctx;
+
+  switch (task->state)
+    {
+    case WRITE_REPLY:
+      if (!write_reply (task))
+       {
+         destroy_session (task->s);
+         return FALSE;
+       }
+      if (ctx->is_custom)
+       {
+         fin_custom_filters (task);
+       }
+      destroy_session (task->s);
+      return FALSE;
+      break;
+    case WRITE_ERROR:
+      if (!write_reply (task))
+       {
+         return FALSE;
+       }
+      if (ctx->is_custom)
+       {
+         fin_custom_filters (task);
        }
-       return TRUE;
+      destroy_session (task->s);
+      return FALSE;
+      break;
+    case CLOSING_CONNECTION:
+      debug_task ("normally closing connection");
+      if (ctx->is_custom)
+       {
+         fin_custom_filters (task);
+       }
+      destroy_session (task->s);
+      return FALSE;
+      break;
+    default:
+      msg_info ("abnormally closing connection");
+      if (ctx->is_custom)
+       {
+         fin_custom_filters (task);
+       }
+      destroy_session (task->s);
+      return FALSE;
+      break;
+    }
+  return TRUE;
 }
 
 /*
@@ -435,214 +484,251 @@ write_socket (void *arg)
 static void
 err_socket (GError * err, void *arg)
 {
-       struct worker_task             *task = (struct worker_task *)arg;
-       struct rspamd_worker_ctx       *ctx;
-
-       ctx = task->worker->ctx;
-       msg_info ("abnormally closing connection, error: %s", err->message);
-       /* Free buffers */
-       if (ctx->is_custom) {
-               fin_custom_filters (task);
-       }
-       if (task->state != WRITE_REPLY) {
-               destroy_session (task->s);
-       }
+  struct worker_task             *task = (struct worker_task *) arg;
+  struct rspamd_worker_ctx       *ctx;
+
+  ctx = task->worker->ctx;
+  msg_info ("abnormally closing connection, error: %s", err->message);
+  /* Free buffers */
+  if (ctx->is_custom)
+    {
+      fin_custom_filters (task);
+    }
+  if (task->state != WRITE_REPLY)
+    {
+      destroy_session (task->s);
+    }
 }
 
 struct worker_task             *
 construct_task (struct rspamd_worker *worker)
 {
-       struct worker_task             *new_task;
+  struct worker_task             *new_task;
 
-       new_task = g_malloc (sizeof (struct worker_task));
+  new_task = g_malloc (sizeof (struct worker_task));
 
-       bzero (new_task, sizeof (struct worker_task));
-       new_task->worker = worker;
-       new_task->state = READ_COMMAND;
-       new_task->cfg = worker->srv->cfg;
-       new_task->from_addr.s_addr = INADDR_NONE;
-       new_task->view_checked = FALSE;
+  bzero (new_task, sizeof (struct worker_task));
+  new_task->worker = worker;
+  new_task->state = READ_COMMAND;
+  new_task->cfg = worker->srv->cfg;
+  new_task->from_addr.s_addr = INADDR_NONE;
+  new_task->view_checked = FALSE;
 #ifdef HAVE_CLOCK_GETTIME
 # ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
-       clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &new_task->ts);
+  clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &new_task->ts);
 # elif defined(HAVE_CLOCK_VIRTUAL)
-       clock_gettime (CLOCK_VIRTUAL, &new_task->ts);
+  clock_gettime (CLOCK_VIRTUAL, &new_task->ts);
 # else
-       clock_gettime (CLOCK_REALTIME, &new_task->ts);
+  clock_gettime (CLOCK_REALTIME, &new_task->ts);
 # endif
 #endif
-       if (gettimeofday (&new_task->tv, NULL) == -1) {
-               msg_warn ("gettimeofday failed: %s", strerror (errno));
-       }
-
-       new_task->task_pool = memory_pool_new (memory_pool_get_size ());
-
-       /* Add destructor for recipients list (it would be better to use anonymous function here */
-       memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func) rcpt_destruct, new_task);
-       new_task->results = g_hash_table_new (g_str_hash, g_str_equal);
-       memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func) g_hash_table_destroy, new_task->results);
-       new_task->re_cache = g_hash_table_new (g_str_hash, g_str_equal);
-       memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func) g_hash_table_destroy, new_task->re_cache);
-       new_task->s = new_async_session (new_task->task_pool, free_task_hard, new_task);
-       new_task->sock = -1;
-       new_task->is_mime = TRUE;
-
-       return new_task;
+  if (gettimeofday (&new_task->tv, NULL) == -1)
+    {
+      msg_warn ("gettimeofday failed: %s", strerror (errno));
+    }
+
+  new_task->task_pool = memory_pool_new (memory_pool_get_size ());
+
+  /* Add destructor for recipients list (it would be better to use anonymous function here */
+  memory_pool_add_destructor (new_task->task_pool,
+                             (pool_destruct_func) rcpt_destruct, new_task);
+  new_task->results = g_hash_table_new (g_str_hash, g_str_equal);
+  memory_pool_add_destructor (new_task->task_pool,
+                             (pool_destruct_func) g_hash_table_destroy,
+                             new_task->results);
+  new_task->re_cache = g_hash_table_new (g_str_hash, g_str_equal);
+  memory_pool_add_destructor (new_task->task_pool,
+                             (pool_destruct_func) g_hash_table_destroy,
+                             new_task->re_cache);
+  new_task->s =
+    new_async_session (new_task->task_pool, free_task_hard, new_task);
+  new_task->sock = -1;
+  new_task->is_mime = TRUE;
+
+  return new_task;
 }
 
 /*
  * Accept new connection and construct task
  */
 static void
-accept_socket (int fd, short what, void *arg)
+accept_socket (gint fd, short what, void *arg)
 {
-       struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
-       struct rspamd_worker_ctx       *ctx;
-       union sa_union                  su;
-       struct worker_task             *new_task;
-       GList                          *cur;
-       struct custom_filter           *filt;
-
-       socklen_t                       addrlen = sizeof (su.ss);
-       int                             nfd;
-
-       ctx = worker->ctx;
-       if ((nfd = accept_from_socket (fd, (struct sockaddr *)&su.ss, &addrlen)) == -1) {
-               msg_warn ("accept failed: %s", strerror (errno));
-               return;
-       }
-       /* Check for EAGAIN */
-       if (nfd == 0) {
-               return;
-       }
-       
-       new_task = construct_task (worker);
-
-       if (su.ss.ss_family == AF_UNIX) {
-               msg_info ("accepted connection from unix socket");
-               new_task->client_addr.s_addr = INADDR_NONE;
-       }
-       else if (su.ss.ss_family == AF_INET) {
-               msg_info ("accepted connection from %s port %d", inet_ntoa (su.s4.sin_addr), ntohs (su.s4.sin_port));
-               memcpy (&new_task->client_addr, &su.s4.sin_addr, sizeof (struct in_addr));
-       }
-
-       new_task->sock = nfd;
-       new_task->is_mime = ctx->is_mime;
-       worker->srv->stat->connections_count++;
-       new_task->resolver = ctx->resolver;
-       ctx->io_tv.tv_sec = WORKER_IO_TIMEOUT;
-       ctx->io_tv.tv_usec = 0;
-
-       /* Set up dispatcher */
-       new_task->dispatcher = rspamd_create_dispatcher (nfd, BUFFER_LINE, read_socket, write_socket, err_socket, &ctx->io_tv, (void *)new_task);
-       new_task->dispatcher->peer_addr = new_task->client_addr.s_addr;
-       
-       /* Init custom filters */
-#ifndef BUILD_STATIC   
-       if (ctx->is_custom) {
-               cur = ctx->custom_filters;
-               while (cur) {
-                       filt = cur->data;
-                       if (filt->before_connect) {
-                               /* XXX: maybe not use rcpt list here for custom filters data, but this can save some bytes in task structure */
-                               new_task->rcpt = g_list_prepend (new_task->rcpt, filt->before_connect ());
-                       }
-                       cur = g_list_next (cur);
-               }
-               /* Keep user data in the same order as custom filters */
-               new_task->rcpt = g_list_reverse (new_task->rcpt);
+  struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
+  struct rspamd_worker_ctx       *ctx;
+  union sa_union                  su;
+  struct worker_task             *new_task;
+  GList                          *cur;
+  struct custom_filter           *filt;
+
+  socklen_t                       addrlen = sizeof (su.ss);
+  gint                            nfd;
+
+  ctx = worker->ctx;
+  if ((nfd =
+       accept_from_socket (fd, (struct sockaddr *) &su.ss, &addrlen)) == -1)
+    {
+      msg_warn ("accept failed: %s", strerror (errno));
+      return;
+    }
+  /* Check for EAGAIN */
+  if (nfd == 0)
+    {
+      return;
+    }
+
+  new_task = construct_task (worker);
+
+  if (su.ss.ss_family == AF_UNIX)
+    {
+      msg_info ("accepted connection from unix socket");
+      new_task->client_addr.s_addr = INADDR_NONE;
+    }
+  else if (su.ss.ss_family == AF_INET)
+    {
+      msg_info ("accepted connection from %s port %d",
+               inet_ntoa (su.s4.sin_addr), ntohs (su.s4.sin_port));
+      memcpy (&new_task->client_addr, &su.s4.sin_addr,
+             sizeof (struct in_addr));
+    }
+
+  new_task->sock = nfd;
+  new_task->is_mime = ctx->is_mime;
+  worker->srv->stat->connections_count++;
+  new_task->resolver = ctx->resolver;
+  ctx->io_tv.tv_sec = WORKER_IO_TIMEOUT;
+  ctx->io_tv.tv_usec = 0;
+
+  /* Set up dispatcher */
+  new_task->dispatcher =
+    rspamd_create_dispatcher (nfd, BUFFER_LINE, read_socket, write_socket,
+                             err_socket, &ctx->io_tv, (void *) new_task);
+  new_task->dispatcher->peer_addr = new_task->client_addr.s_addr;
+
+  /* Init custom filters */
+#ifndef BUILD_STATIC
+  if (ctx->is_custom)
+    {
+      cur = ctx->custom_filters;
+      while (cur)
+       {
+         filt = cur->data;
+         if (filt->before_connect)
+           {
+             /* XXX: maybe not use rcpt list here for custom filters data, but this can save some bytes in task structure */
+             new_task->rcpt =
+               g_list_prepend (new_task->rcpt, filt->before_connect ());
+           }
+         cur = g_list_next (cur);
        }
+      /* Keep user data in the same order as custom filters */
+      new_task->rcpt = g_list_reverse (new_task->rcpt);
+    }
 #endif
 
 }
 
 #ifndef BUILD_STATIC
-static gboolean
-load_custom_filter (struct config_file *cfg, const char *file, struct rspamd_worker_ctx *ctx)
+static                          gboolean
+load_custom_filter (struct config_file *cfg, const gchar * file,
+                   struct rspamd_worker_ctx *ctx)
 {
-       struct custom_filter           *filt;
-       struct stat                     st;
-
-       if (stat (file, &st) == -1 || !S_ISREG (st.st_mode)) {
-               msg_info ("stat failed for %s", file);
-               return FALSE;
-       }
-
-       filt = g_malloc (sizeof (struct custom_filter));
-
-       filt->handle = g_module_open (file, G_MODULE_BIND_LAZY);
-       if (!filt->handle) {
-               msg_info ("module load failed: %s", g_module_error ());
-               g_free (filt);
-               return FALSE;
-       }
-       
-       /* Now extract functions from custom module */
-       if (!g_module_symbol (filt->handle, MODULE_INIT_FUNC, (gpointer *)&filt->init_func) ||
-               !g_module_symbol (filt->handle, MODULE_FINIT_FUNC, (gpointer *)&filt->fin_func) ||
-               !g_module_symbol (filt->handle, MODULE_BEFORE_CONNECT_FUNC, (gpointer *)&filt->before_connect) ||
-               !g_module_symbol (filt->handle, MODULE_AFTER_CONNECT_FUNC, (gpointer *)&filt->after_connect) ||
-               !g_module_symbol (filt->handle, MODULE_PARSE_LINE_FUNC, (gpointer *)&filt->process_line)) {
-
-               msg_info ("cannot find handlers in module %s: %s", file, g_module_error ());
-               g_free (filt);
-               return FALSE;
-       }
-       
-       filt->init_func (cfg);
-       filt->filename = g_strdup (file);
-       ctx->custom_filters = g_list_prepend (ctx->custom_filters, filt);
-
-       return TRUE;
+  struct custom_filter           *filt;
+  struct stat                     st;
+
+  if (stat (file, &st) == -1 || !S_ISREG (st.st_mode))
+    {
+      msg_info ("stat failed for %s", file);
+      return FALSE;
+    }
+
+  filt = g_malloc (sizeof (struct custom_filter));
+
+  filt->handle = g_module_open (file, G_MODULE_BIND_LAZY);
+  if (!filt->handle)
+    {
+      msg_info ("module load failed: %s", g_module_error ());
+      g_free (filt);
+      return FALSE;
+    }
+
+  /* Now extract functions from custom module */
+  if (!g_module_symbol
+      (filt->handle, MODULE_INIT_FUNC, (gpointer *) & filt->init_func)
+      || !g_module_symbol (filt->handle, MODULE_FINIT_FUNC,
+                          (gpointer *) & filt->fin_func)
+      || !g_module_symbol (filt->handle, MODULE_BEFORE_CONNECT_FUNC,
+                          (gpointer *) & filt->before_connect)
+      || !g_module_symbol (filt->handle, MODULE_AFTER_CONNECT_FUNC,
+                          (gpointer *) & filt->after_connect)
+      || !g_module_symbol (filt->handle, MODULE_PARSE_LINE_FUNC,
+                          (gpointer *) & filt->process_line))
+    {
+
+      msg_info ("cannot find handlers in module %s: %s", file,
+               g_module_error ());
+      g_free (filt);
+      return FALSE;
+    }
+
+  filt->init_func (cfg);
+  filt->filename = g_strdup (file);
+  ctx->custom_filters = g_list_prepend (ctx->custom_filters, filt);
+
+  return TRUE;
 }
 
 /*
  * Load custom filters from specified path
  */
-static gboolean
-load_custom_filters (struct rspamd_worker *worker, const char *path)
+static                          gboolean
+load_custom_filters (struct rspamd_worker *worker, const gchar * path)
 {
-       glob_t                          gp;
-       int                             r, i;
-       struct rspamd_worker_ctx       *ctx = worker->ctx;
-
-       gp.gl_offs = 0;
-    if ((r = glob (path, GLOB_NOSORT, NULL, &gp)) != 0) {
-               msg_warn ("glob failed: %s, %d", strerror (errno), r);
-               return FALSE;
-       }
-       
-       for (i = 0; i < gp.gl_pathc; i ++) {
-               if (! load_custom_filter (worker->srv->cfg, gp.gl_pathv[i], ctx)) {
-                       globfree (&gp);
-                       return FALSE;
-               }
+  glob_t                          gp;
+  gint                            r, i;
+  struct rspamd_worker_ctx       *ctx = worker->ctx;
+
+  gp.gl_offs = 0;
+  if ((r = glob (path, GLOB_NOSORT, NULL, &gp)) != 0)
+    {
+      msg_warn ("glob failed: %s, %d", strerror (errno), r);
+      return FALSE;
+    }
+
+  for (i = 0; i < gp.gl_pathc; i++)
+    {
+      if (!load_custom_filter (worker->srv->cfg, gp.gl_pathv[i], ctx))
+       {
+         globfree (&gp);
+         return FALSE;
        }
+    }
 
-       globfree (&gp);
+  globfree (&gp);
 
-       return TRUE;
+  return TRUE;
 }
 
 static void
 unload_custom_filters (struct rspamd_worker_ctx *ctx)
 {
-       GList                          *cur;
-       struct custom_filter           *filt;
-
-       cur = ctx->custom_filters;
-       while (cur) {
-               filt = cur->data;
-               if (filt->fin_func) {
-                       filt->fin_func ();
-               }
-               g_module_close (filt->handle);
-               g_free (filt);
-               cur = g_list_next (cur);
+  GList                          *cur;
+  struct custom_filter           *filt;
+
+  cur = ctx->custom_filters;
+  while (cur)
+    {
+      filt = cur->data;
+      if (filt->fin_func)
+       {
+         filt->fin_func ();
        }
+      g_module_close (filt->handle);
+      g_free (filt);
+      cur = g_list_next (cur);
+    }
 
-       g_list_free (ctx->custom_filters);
+  g_list_free (ctx->custom_filters);
 }
 
 #endif
@@ -653,72 +739,82 @@ unload_custom_filters (struct rspamd_worker_ctx *ctx)
 void
 start_worker (struct rspamd_worker *worker)
 {
-       struct sigaction                signals;
-       char                           *is_mime_str;
-       char                           *is_custom_str;
-       struct rspamd_worker_ctx       *ctx;
+  struct sigaction                signals;
+  gchar                          *is_mime_str;
+  gchar                          *is_custom_str;
+  struct rspamd_worker_ctx       *ctx;
 
 #ifdef WITH_PROFILER
-       extern void                     _start (void), etext (void);
-       monstartup ((u_long) & _start, (u_long) & etext);
+  extern void                     _start (void), etext (void);
+  monstartup ((u_long) & _start, (u_long) & etext);
 #endif
 
-       gperf_profiler_init (worker->srv->cfg, "worker");
+  gperf_profiler_init (worker->srv->cfg, "worker");
 
-       worker->srv->pid = getpid ();
+  worker->srv->pid = getpid ();
 
-       event_init ();
+  event_init ();
 
-       init_signals (&signals, sig_handler);
-       sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
+  init_signals (&signals, sig_handler);
+  sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
 
-       /* SIGUSR2 handler */
-       signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
-       signal_add (&worker->sig_ev, NULL);
+  /* SIGUSR2 handler */
+  signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *) worker);
+  signal_add (&worker->sig_ev, NULL);
 
-       /* Accept event */
-       event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST, accept_socket, (void *)worker);
-       event_add (&worker->bind_ev, NULL);
+  /* Accept event */
+  event_set (&worker->bind_ev, worker->cf->listen_sock, EV_READ | EV_PERSIST,
+            accept_socket, (void *) worker);
+  event_add (&worker->bind_ev, NULL);
 
-       /* Fill ctx */
-       ctx = g_malloc0 (sizeof (struct rspamd_worker_ctx));
-       worker->ctx = ctx;
+  /* Fill ctx */
+  ctx = g_malloc0 (sizeof (struct rspamd_worker_ctx));
+  worker->ctx = ctx;
 
-#ifndef BUILD_STATIC   
-       /* Check if this worker is not usual rspamd worker, but uses custom filters from specified path */
-       is_custom_str = g_hash_table_lookup (worker->cf->params, "custom_filters");
-       if (is_custom_str && g_module_supported () && load_custom_filters (worker, is_custom_str)) {
-               msg_info ("starting custom process, loaded modules from %s", is_custom_str);
-               ctx->is_custom = TRUE;
-       }
-       else {
+#ifndef BUILD_STATIC
+  /* Check if this worker is not usual rspamd worker, but uses custom filters from specified path */
+  is_custom_str = g_hash_table_lookup (worker->cf->params, "custom_filters");
+  if (is_custom_str && g_module_supported ()
+      && load_custom_filters (worker, is_custom_str))
+    {
+      msg_info ("starting custom process, loaded modules from %s",
+               is_custom_str);
+      ctx->is_custom = TRUE;
+    }
+  else
+    {
 #endif
-               /* Maps events */
-               start_map_watch ();
-               /* Check whether we are mime worker */
-               is_mime_str = g_hash_table_lookup (worker->cf->params, "mime");
-               if (is_mime_str != NULL && (g_ascii_strcasecmp (is_mime_str, "no") == 0 || g_ascii_strcasecmp (is_mime_str, "false") == 0)) {
-                       ctx->is_mime = FALSE;
-               }
-               else {
-                       ctx->is_mime = TRUE;
-               }
-#ifndef BUILD_STATIC   
+      /* Maps events */
+      start_map_watch ();
+      /* Check whether we are mime worker */
+      is_mime_str = g_hash_table_lookup (worker->cf->params, "mime");
+      if (is_mime_str != NULL
+         && (g_ascii_strcasecmp (is_mime_str, "no") == 0
+             || g_ascii_strcasecmp (is_mime_str, "false") == 0))
+       {
+         ctx->is_mime = FALSE;
        }
+      else
+       {
+         ctx->is_mime = TRUE;
+       }
+#ifndef BUILD_STATIC
+    }
 #endif
 
-       ctx->resolver = dns_resolver_init (worker->srv->cfg);
+  ctx->resolver = dns_resolver_init (worker->srv->cfg);
 
-       event_loop (0);
-       
-#ifndef BUILD_STATIC   
-       if (ctx->is_custom) {
-               unload_custom_filters (ctx);
-       }
+  event_loop (0);
+
+#ifndef BUILD_STATIC
+  if (ctx->is_custom)
+    {
+      unload_custom_filters (ctx);
+    }
 #endif
 
-       close_log ();
-       exit (EXIT_SUCCESS);
+  close_log ();
+  exit (EXIT_SUCCESS);
 }
 
 /*