diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 18:56:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 18:56:33 +0000 |
commit | 14c13854d3cae9d93c3d148be30fb72f1eaffe55 (patch) | |
tree | 7b1a3e41b75490fac4d45722c90a1847543c6796 /utils | |
parent | 6b2b4167187fee09365271cca182866ecb029af3 (diff) | |
download | rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.tar.gz rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.zip |
[Rework] Further types conversion (no functional changes)
Diffstat (limited to 'utils')
-rw-r--r-- | utils/base64.c | 18 | ||||
-rw-r--r-- | utils/rspamd_http_bench.c | 54 | ||||
-rw-r--r-- | utils/rspamd_http_server.c | 34 |
3 files changed, 53 insertions, 53 deletions
diff --git a/utils/base64.c b/utils/base64.c index d1202db53..f6ec71125 100644 --- a/utils/base64.c +++ b/utils/base64.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -20,16 +20,16 @@ #include "cryptobox.h" #include "unix-std.h" -static gdouble total_time = 0; +static double total_time = 0; static void -rspamd_process_file(const gchar *fname, gint decode) +rspamd_process_file(const char *fname, int decode) { - gint fd; + int fd; gpointer map; struct stat st; - guint8 *dest; + uint8_t *dest; gsize destlen; fd = open(fname, O_RDONLY); @@ -61,7 +61,7 @@ rspamd_process_file(const gchar *fname, gint decode) dest = rspamd_encode_base64(map, st.st_size, 80, &destlen); } - rspamd_printf("%*s", (gint) destlen, dest); + rspamd_printf("%*s", (int) destlen, dest); g_free(dest); munmap(map, st.st_size); @@ -69,7 +69,7 @@ rspamd_process_file(const gchar *fname, gint decode) int main(int argc, char **argv) { - gint i, start = 1, decode = 0; + int i, start = 1, decode = 0; if (argc > 2 && *argv[1] == '-') { start = 2; diff --git a/utils/rspamd_http_bench.c b/utils/rspamd_http_bench.c index 4cb153102..84f94a5ae 100644 --- a/utils/rspamd_http_bench.c +++ b/utils/rspamd_http_bench.c @@ -28,23 +28,23 @@ #include <sys/wait.h> #endif -static guint port = 43000; -static gchar *host = "127.0.0.1"; -static gchar *server_key = NULL; -static guint cache_size = 10; -static guint nworkers = 1; +static unsigned int port = 43000; +static char *host = "127.0.0.1"; +static char *server_key = NULL; +static unsigned int cache_size = 10; +static unsigned int nworkers = 1; static gboolean openssl_mode = FALSE; -static guint file_size = 500; -static guint pconns = 100; -static gdouble test_time = 10.0; -static gchar *latencies_file = NULL; +static unsigned int file_size = 500; +static unsigned int pconns = 100; +static double test_time = 10.0; +static char *latencies_file = NULL; static gboolean csv_output = FALSE; /* Dynamic vars */ static rspamd_inet_addr_t *addr; static uint32_t workers_left = 0; static uint32_t *conns_done = NULL; -static const guint store_latencies = 1000; +static const unsigned int store_latencies = 1000; static uint32_t conns_pending = 0; static GOptionEntry entries[] = { @@ -73,16 +73,16 @@ static GOptionEntry entries[] = { {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}}; struct lat_elt { - gdouble lat; - guchar checked; + double lat; + unsigned char checked; }; static struct lat_elt *latencies; -static gint +static int rspamd_client_body(struct rspamd_http_connection *conn, struct rspamd_http_message *msg, - const gchar *chunk, gsize len) + const char *chunk, gsize len) { g_assert(chunk[0] == '\0'); @@ -92,7 +92,7 @@ rspamd_client_body(struct rspamd_http_connection *conn, struct client_cbdata { struct lat_elt *lat; uint32_t *wconns; - gdouble ts; + double ts; struct ev_loop *ev_base; }; @@ -107,7 +107,7 @@ rspamd_client_err(struct rspamd_http_connection *conn, GError *err) rspamd_http_connection_unref(conn); } -static gint +static int rspamd_client_finish(struct rspamd_http_connection *conn, struct rspamd_http_message *msg) { @@ -137,9 +137,9 @@ rspamd_http_client_func(struct ev_loop *ev_base, struct lat_elt *latency, { struct rspamd_http_message *msg; struct rspamd_http_connection *conn; - gchar urlbuf[PATH_MAX]; + char urlbuf[PATH_MAX]; struct client_cbdata *cb; - gint fd, flags; + int fd, flags; fd = rspamd_inet_address_connect(addr, SOCK_STREAM, TRUE); g_assert(fd != -1); @@ -176,7 +176,7 @@ rspamd_http_client_func(struct ev_loop *ev_base, struct lat_elt *latency, static void rspamd_worker_func(struct lat_elt *plat, uint32_t *wconns) { - guint i, j; + unsigned int i, j; struct ev_loop *ev_base; struct itimerval itv; struct rspamd_keypair_cache *c = NULL; @@ -224,8 +224,8 @@ cmpd(const void *p1, const void *p2) double rspamd_http_calculate_mean(struct lat_elt *lats, double *std) { - guint i, cnt, checked = 0; - gdouble mean = 0., dev = 0.; + unsigned int i, cnt, checked = 0; + double mean = 0., dev = 0.; cnt = store_latencies * pconns; qsort(lats, cnt, sizeof(*lats), cmpd); @@ -255,7 +255,7 @@ rspamd_http_calculate_mean(struct lat_elt *lats, double *std) static void rspamd_http_start_workers(pid_t *sfd) { - guint i; + unsigned int i; for (i = 0; i < nworkers; i++) { sfd[i] = fork(); g_assert(sfd[i] != -1); @@ -275,8 +275,8 @@ rspamd_http_start_workers(pid_t *sfd) static void rspamd_http_stop_workers(pid_t *sfd) { - guint i; - gint res; + unsigned int i; + int res; for (i = 0; i < nworkers; i++) { kill(sfd[i], SIGTERM); @@ -296,7 +296,7 @@ rspamd_http_bench_term(int fd, short what, void *arg) static void rspamd_http_bench_cld(int fd, short what, void *arg) { - gint res; + int res; while (waitpid(-1, &res, WNOHANG) > 0) { if (--workers_left == 0) { @@ -316,8 +316,8 @@ int main(int argc, char **argv) struct event term_ev, int_ev, cld_ev; uint64_t total_done; FILE *lat_file; - gdouble mean, std; - guint i; + double mean, std; + unsigned int i; rspamd_init_libs(); diff --git a/utils/rspamd_http_server.c b/utils/rspamd_http_server.c index ecd1d38c7..76e64e466 100644 --- a/utils/rspamd_http_server.c +++ b/utils/rspamd_http_server.c @@ -29,12 +29,12 @@ #include <sys/wait.h> #endif -static guint port = 43000; -static guint cache_size = 10; -static guint nworkers = 1; +static unsigned int port = 43000; +static unsigned int cache_size = 10; +static unsigned int nworkers = 1; static gboolean openssl_mode = FALSE; static GHashTable *maps = NULL; -static gchar *key = NULL; +static char *key = NULL; static struct rspamd_keypair_cache *c; static struct rspamd_cryptobox_keypair *server_key; static struct timeval io_tv = { @@ -57,9 +57,9 @@ static GOptionEntry entries[] = { struct rspamd_http_server_session { struct rspamd_http_connection *conn; struct ev_loop *ev_base; - guint req_size; + unsigned int req_size; gboolean reply; - gint fd; + int fd; }; static void @@ -81,8 +81,8 @@ rspamd_server_finish(struct rspamd_http_connection *conn, struct rspamd_http_server_session *session = conn->ud; struct rspamd_http_message *reply; gulong size; - const gchar *url_str; - guint url_len; + const char *url_str; + unsigned int url_len; rspamd_fstring_t *body; if (!session->reply) { @@ -127,12 +127,12 @@ rspamd_server_finish(struct rspamd_http_connection *conn, } static void -rspamd_server_accept(gint fd, short what, void *arg) +rspamd_server_accept(int fd, short what, void *arg) { struct ev_loop *ev_base = arg; struct rspamd_http_server_session *session; rspamd_inet_addr_t *addr; - gint nfd; + int nfd; do { if ((nfd = @@ -168,7 +168,7 @@ rspamd_server_accept(gint fd, short what, void *arg) } static void -rspamd_http_term_handler(gint fd, short what, void *arg) +rspamd_http_term_handler(int fd, short what, void *arg) { struct ev_loop *ev_base = arg; struct timeval tv = {0, 0}; @@ -177,7 +177,7 @@ rspamd_http_term_handler(gint fd, short what, void *arg) } static void -rspamd_http_server_func(gint fd, rspamd_inet_addr_t *addr) +rspamd_http_server_func(int fd, rspamd_inet_addr_t *addr) { struct ev_loop *ev_base = event_init(); struct event accept_ev, term_ev; @@ -196,8 +196,8 @@ rspamd_http_server_func(gint fd, rspamd_inet_addr_t *addr) static void rspamd_http_start_servers(pid_t *sfd, rspamd_inet_addr_t *addr) { - guint i; - gint fd; + unsigned int i; + int fd; fd = rspamd_inet_address_listen(addr, SOCK_STREAM, TRUE); g_assert(fd != -1); @@ -218,8 +218,8 @@ rspamd_http_start_servers(pid_t *sfd, rspamd_inet_addr_t *addr) static void rspamd_http_stop_servers(pid_t *sfd) { - guint i; - gint res; + unsigned int i; + int res; for (i = 0; i < nworkers; i++) { kill(sfd[i], SIGTERM); @@ -236,7 +236,7 @@ rspamd_http_server_term(int fd, short what, void *arg) event_loopexit(NULL); } -int main(int argc, gchar **argv) +int main(int argc, char **argv) { GOptionContext *context; GError *error = NULL; |