CHECK_INCLUDE_FILES(sys/wait.h HAVE_SYS_WAIT_H)
CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)
CHECK_INCLUDE_FILES(sys/cdefs.h HAVE_SYS_CDEFS_H)
+CHECK_INCLUDE_FILES(sys/file.h HAVE_SYS_FILE_H)
CHECK_INCLUDE_FILES(netinet/in.h HAVE_NETINET_IN_H)
CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H)
CHECK_INCLUDE_FILES(netdb.h HAVE_NETDB_H)
MESSAGE(STATUS "WARNING: Using internal MD5 support")
ENDIF (MD5_INCLUDE)
-SET(CMAKE_C_WARN_FLAGS " -Wall -W -Wpointer-arith -Wno-unused-parameter -Wno-unused-function -Wunused-variable -Wno-sign-compare -Wunused-value")
+SET(CMAKE_C_WARN_FLAGS "-Wall -W -Wpointer-arith -Wno-unused-parameter -Wno-unused-function -Wunused-variable -Wno-sign-compare -Wunused-value -Wno-declaration-after-statement -Wno-pointer-sign")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS} -std=c99")
# Platform specific routines
IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
#cmakedefine HAVE_STDBOOL_H 1
+#cmakedefine HAVE_ARPA_INET_H 1
+#cmakedefine HAVE_NETINET_IN_H 1
+
#cmakedefine HAVE_NETDB_H 1
#cmakedefine HAVE_SYSLOG_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_SYS_WAIT_H 1
#cmakedefine HAVE_SYS_PARAM_H 1
+#cmakedefine HAVE_SYS_FILE_H 1
#cmakedefine HAVE_PIDFILE 1
#include <sys/socket.h>
#endif
+/* sys/file.h */
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+
/* sys/mman */
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
case 'r':
arg = *(cmd_args + 1);
if (!arg || *arg == '\0') {
- r = snprintf (out_buf, sizeof (out_buf), "recipient is not defined" CRLF, arg);
+ r = snprintf (out_buf, sizeof (out_buf), "recipient is not defined" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE);
return;
}
case 'f':
arg = *(cmd_args + 1);
if (!arg || *arg == '\0') {
- r = snprintf (out_buf, sizeof (out_buf), "from is not defined" CRLF, arg);
+ r = snprintf (out_buf, sizeof (out_buf), "from is not defined" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE);
return;
}
session->in_class = 0;
break;
default:
- r = snprintf (out_buf, sizeof (out_buf), "tokenizer is not defined" CRLF, arg);
+ r = snprintf (out_buf, sizeof (out_buf), "tokenizer is not defined" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE);
return;
}
session->state = STATE_REPLY;
break;
+ default:
+ msg_debug ("controller_read_socket: unknown state while reading %d", session->state);
+ break;
}
}
char *begin, *end, *p, *src;
struct rspamd_regexp *result;
int regexp_flags = 0;
- enum rspamd_regexp_type type = REGEXP_NONE;
GError *err = NULL;
src = line;
task->dispatcher->write_callback (task);
return 1;
}
+
+ return -1;
}
int
}
while (cur < orig->len) {
- if (tolower (*(orig->begin + cur)) == tolower (*pattern->begin)) {
+ if (g_ascii_tolower (*(orig->begin + cur)) == g_ascii_tolower (*pattern->begin)) {
while (cur < orig->len && pcur < pattern->len) {
- if (tolower (*(orig->begin + cur)) != tolower (*(pattern->begin + pcur))) {
+ if (g_ascii_tolower (*(orig->begin + cur)) != g_ascii_tolower (*(pattern->begin + pcur))) {
pcur = 0;
break;
}
fuzzy_fnv_hash (char c, uint32_t hval)
{
hval ^= c;
- hval = hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
+ hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
return hval;
}
#include "lmtp.h"
#include "lmtp_proto.h"
#include "cfg_file.h"
+#include "util.h"
#include "url.h"
#include "modules.h"
#include "message.h"
lmtp_write_socket (lmtp);
}
break;
+ default:
+ msg_debug ("lmtp_read_socket: invalid state while reading from socket %d", lmtp->task->state);
+ break;
}
}
msg_debug ("lmtp_write_socket: normally closing connection");
free_task (lmtp, TRUE);
break;
+ default:
+ msg_debug ("lmtp_write_socket: invalid state while writing to socket %d", lmtp->task->state);
+ break;
}
}
#include "config.h"
#include "main.h"
#include "cfg_file.h"
+#include "util.h"
#include "lmtp.h"
#include "lmtp_proto.h"
i += lhlo_command.len;
c = line->begin + i;
/* Skip spaces */
- while (isspace (*c) && i < line->len) {
+ while (g_ascii_isspace (*c) && i < line->len) {
i ++;
c ++;
}
i += data_command.len;
c = line->begin + i;
/* Skip spaces */
- while (isspace (*c++)) {
+ while (g_ascii_isspace (*c++)) {
i ++;
}
rcpt = memory_pool_alloc (lmtp->task->task_pool, line->len - i + 1);
return 0;
break;
}
+
+ return 0;
}
struct mta_callback_data {
rspamd_io_dispatcher_t *dispatcher;
enum {
LMTP_WANT_GREETING,
- LMTP_WANT_HELO,
LMTP_WANT_MAIL,
LMTP_WANT_RCPT,
LMTP_WANT_DATA,
switch (cd->state) {
case LMTP_WANT_GREETING:
- case LMTP_WANT_HELO:
case LMTP_WANT_MAIL:
case LMTP_WANT_RCPT:
case LMTP_WANT_DATA:
cd->dispatcher = rspamd_create_dispatcher (sock, BUFFER_LINE, mta_read_socket,
NULL, mta_err_socket, NULL,
(void *)cd);
+ return 0;
}
static char*
format_lda_args (struct worker_task *task)
{
- char *arg, *res, *c, *r;
+ char *res, *c, *r;
size_t len;
GList *rcpt;
gboolean got_args = FALSE;
write_lmtp_reply (struct rspamd_lmtp_proto *lmtp)
{
int r;
- char outbuf[OUTBUFSIZ];
msg_debug ("write_lmtp_reply: writing reply to client");
if (lmtp->task->error_code != 0) {
void
memory_pool_stat (memory_pool_stat_t *st)
{
- if (stat) {
- st->bytes_allocated = mem_pool_stat->bytes_allocated;
- st->chunks_allocated = mem_pool_stat->chunks_allocated;
- st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated;
- st->chunks_freed = mem_pool_stat->chunks_freed;
- }
+ st->bytes_allocated = mem_pool_stat->bytes_allocated;
+ st->chunks_allocated = mem_pool_stat->chunks_allocated;
+ st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated;
+ st->chunks_freed = mem_pool_stat->chunks_freed;
}
#define FIXED_POOL_SIZE 4095
case 'e':
/* !DOCTYPE exception */
if (state == 3 && p > src->data + 6
- && tolower(*(p-1)) == 'p'
- && tolower(*(p-2)) == 'y'
- && tolower(*(p-3)) == 't'
- && tolower(*(p-4)) == 'c'
- && tolower(*(p-5)) == 'o'
- && tolower(*(p-6)) == 'd') {
+ && g_ascii_tolower(*(p-1)) == 'p'
+ && g_ascii_tolower(*(p-2)) == 'y'
+ && g_ascii_tolower(*(p-3)) == 't'
+ && g_ascii_tolower(*(p-4)) == 'c'
+ && g_ascii_tolower(*(p-5)) == 'o'
+ && g_ascii_tolower(*(p-6)) == 'd') {
state = 1;
break;
}
process_regexp_item ((struct regexp_module_item *)cur_expr->data, task);
cur_expr = g_list_next (cur_expr);
}
+
+ return 0;
}
*/
#include "../config.h"
+#include "../util.h"
#include <evdns.h>
#include "surbl.h"
new_suffix->suffix, new_suffix->symbol);
surbl_module_ctx->suffixes = g_list_prepend (surbl_module_ctx->suffixes, new_suffix);
}
+
+ return 0;
}
int
{
struct memcached_param *param = (struct memcached_param *)data;
int *url_count;
- f_str_t c;
switch (ctx->op) {
case CMD_CONNECT:
}
make_surbl_requests (param->url, param->task, param->tree);
break;
+ default:
+ return;
}
}
surbl_test_url (struct worker_task *task)
{
struct uri *url;
- struct memcached_param *param;
GTree *url_tree;
url_tree = g_tree_new ((GCompareFunc)g_ascii_strcasecmp);
case READ_HEADER:
return parse_header (task, fstrcstr (line, task->task_pool));
break;
+ default:
+ return -1;
}
+ return -1;
}
struct metric_callback_data {
if (exp.filename) {
statfile_pool_close (pool, exp.filename, TRUE);
}
+
+ return 0;
}
statfile_pool_t*
cur_offset = file->seek_pos - sizeof (struct stat_file_section);
}
while (cur_offset < file->len) {
- sec = (struct stat_file_section *)(file->map + cur_offset);
+ sec = (struct stat_file_section *)((char *)file->map + cur_offset);
if (sec->code == code) {
file->cur_section.code = code;
file->cur_section.length = sec->length;
*/
#include "config.h"
-#include "url.h"
+#include "util.h"
#include "fstring.h"
#include "main.h"
+#include "url.h"
#define POST_CHAR 1
#define POST_CHAR_S "\001"
/* Convert an ASCII hex digit to the corresponding number between 0
and 15. H should be a hexadecimal digit that satisfies isxdigit;
otherwise, the result is undefined. */
-#define XDIGIT_TO_NUM(h) ((h) < 'A' ? (h) - '0' : toupper (h) - 'A' + 10)
+#define XDIGIT_TO_NUM(h) ((h) < 'A' ? (h) - '0' : g_ascii_toupper (h) - 'A' + 10)
#define X2DIGITS_TO_NUM(h1, h2) ((XDIGIT_TO_NUM (h1) << 4) + XDIGIT_TO_NUM (h2))
/* The reverse of the above: convert a number in the [0, 16) range to
the ASCII representation of the corresponding hexadecimal digit.
case URI_ERRNO_INVALID_PORT_RANGE:
return "Port number is not within 0-65535";
}
+ return NULL;
}
static inline int
/* RFC1738:
* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ]
* (but per its recommendations we accept "upalpha" too) */
- while (isalnum(*end) || *end == '+' || *end == '-' || *end == '.')
+ while (g_ascii_isalnum (*end) || *end == '+' || *end == '-' || *end == '.')
end++;
/* Also return 0 if there's no protocol name (@end == @url). */
else {
char c;
/* Do nothing if '%' is not followed by two hex digits. */
- if (!h[1] || !h[2] || !(isxdigit (h[1]) && isxdigit (h[2])))
+ if (!h[1] || !h[2] || !(g_ascii_isxdigit (h[1]) && g_ascii_isxdigit (h[2])))
goto copychar;
c = X2DIGITS_TO_NUM (h[1], h[2]);
/* Don't unescape %00 because there is no way to insert it
char_needs_escaping (const char *p)
{
if (*p == '%') {
- if (isxdigit (*(p + 1)) && isxdigit (*(p + 2)))
+ if (g_ascii_isxdigit (*(p + 1)) && g_ascii_isxdigit (*(p + 2)))
return 0;
else
/* Garbled %.. sequence: encode `%'. */
prefix_end = struri (uri) + uri->protocollen; /* ':' */
/* Check if there's a digit after the protocol name. */
- if (isdigit (*prefix_end)) {
+ if (g_ascii_isdigit (*prefix_end)) {
p = struri (uri);
uri->ip_family = p[uri->protocollen] - '0';
prefix_end++;
/* test if port is number */
for (; host_end < port_end; host_end++)
- if (!isdigit (*host_end))
+ if (!g_ascii_isdigit (*host_end))
return URI_ERRNO_INVALID_PORT;
/* Check valid port value, and let show an error message
void convert_to_lowercase (char *str, unsigned int size)
{
while (size--) {
- *str = tolower (*str);
+ *str = g_ascii_tolower (*str);
str ++;
}
}
}
return 0;
}
+ return -1;
}
void
write_socket (task);
}
break;
+ default:
+ msg_debug ("read_socket: invalid state on reading stage");
+ break;
}
}
bzero (ctx->param->buf, sizeof (buf));
memc_get (ctx, ctx->param);
break;
+ default:
+ return;
}
}